Change wording of admin menu item?

I’m using the plugin Jigoshop and I’d like to change the wording of the admin menu to something other than “Products”:

enter image description here

Read More

How can I do this? What files need editing?

Related posts

Leave a Reply

4 comments

  1. Inside the plugin folder check for File: jigoshop_taxonomy.php
    Line no: 120

    You will see

    register_post_type( "product",
        array(
            'labels' => array(
                'name'              => __( 'Products', 'jigoshop' ),
                'singular_name'     => __( 'Product', 'jigoshop' ),
                'all_items'         => __( 'All Products', 'jigoshop' ),
                'add_new'           => __( 'Add Product', 'jigoshop' ),
                'add_new_item'      => __( 'Add New Product', 'jigoshop' ),
                'edit'              => __( 'Edit', 'jigoshop' ),
                'edit_item'         => __( 'Edit Product', 'jigoshop' ),
                'new_item'          => __( 'New Product', 'jigoshop' ),
                'view'              => __( 'View Product', 'jigoshop' ),
                'view_item'         => __( 'View Product', 'jigoshop' ),
                'search_items'      => __( 'Search Products', 'jigoshop' ),
                'not_found'         => __( 'No Products found', 'jigoshop' ),
                'not_found_in_trash'=> __( 'No Products found in trash', 'jigoshop' ),
                'parent'            => __( 'Parent Product', 'jigoshop' )
            ),
            'description'        => __( 'This is where you can add new products to your store.', 'jigoshop' ),
            'public'             => true,
            'show_ui'            => true,
            'capability_type'    => 'post',
            'publicly_queryable' => true,
            'exclude_from_search'=> false,
            'hierarchical'       => false, // Hierarchial causes a memory leak http://core.trac.wordpress.org/ticket/15459
            'rewrite'            => array( 'slug'=> $product_base, 'with_front'=> false, 'feeds'=> $base_slug ),
            'query_var'          => true,
            'supports'           => array( 'title', 'editor', 'thumbnail', 'comments', 'excerpt',/*, 'page-attributes'*/ ),
            'has_archive'        => $base_slug,
            'show_in_nav_menus'  => false,
        )
    );
    

    Update it as needed.

  2. As has been note by Geert, you should not edit plug-in files: changes will be overridden with an update (… and you really should be keeping your plug-ins up to date…). The best thing to do is…

    Ask the plug-in developers to add a hook to filter the label

    For now however you can do one of two things:

    • Use a hook for when the post type is registered to update post type object
    • Take advantage of the fact the label is translatable

    Method 1:

    add_action('registered_post_type','wpse54367_alter_post_type',10,2);
    
    function wpse54367_alter_post_type($post_type, $args){
         if( $post_type != 'product' )
             return;
    
         //Get labels and update them 
         $labels = get_post_type_labels( get_post_type_object( $post_type ) );
         $labels->name = 'Some things';
         $labels->singular_name= 'Some thing';
    
         //update args
         $args->labels = $labels;
         $args->label = $labels->name;
    
         //update post type
         global $wp_post_types;
         $wp_post_types[$post_type] = $args;
    }
    

    Method 2:

    since the label is ‘translatable’ you can use the gettext filter.

    add_filter( 'gettext', '54367_change_label', 10, 2 );
    
    function wpse51861_change_help_text( $translation, $text ) {
    
    if ( $text == 'Products' )
        return __('Something else','jigoshop');
    
    return $translation;
    }
    
  3. While Stephen’s answer is a great way to work with the current situation, a cleaner solution would exist if the plugin developers made a simple change.


    Action to be taken by the plugin developers:

    First of all, when registering a post type you should set the menu_name label. This label is specifically used for the menu; if it’s not set the name label is used by default.

    When setting the menu_name label, the _x() translation function should be used. That way translators can supply a specific translation just for the menu name. Otherwise, the translation for ‘Products’ would apply to the normal name label as well.

    register_post_type('product', array(
        'labels' => array(
            'name'      => __( 'Products', 'jigoshop' ),
            'menu_name' => _x( 'Products', 'Admin menu name', 'jigoshop' ),
            // ...
    

    Update: I opened a pull request on GitHub for these changes in WooCommerce. Jigoshop’s code is probably very similar.


    Action to be taken by the plugin user:

    Load a custom translation mo-file with a specific translation for the menu name string. In your po-file the entry would look like this:

    msgctxt "Admin menu name"
    msgid "Products"
    msgstr "My Productzz"
    

    To load a custom translation file you can hook into the load_textdomain() function. A well-built plugin would also allow you to drop custom translation files into the wp-content/languages/{plugin_name}/ directory. WooCommerce allows this, I’m not sure about Jigoshop.