1

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

How can I do this? What files need editing?

4 Answers 4

-4

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.

4
  • 9
    Note: editing plugin files directly is not recommended. Changes are lost during a plugin update.
    – Geert
    Jun 6, 2012 at 14:58
  • @Geert thanks for the note. You could rename the "Plugin Name" to avoid such loss. However you are going to lose new features if you do so.
    – tamilsweet
    Jun 6, 2012 at 15:05
  • 1
    Providing a custom translation for "Products" by loading an extra mo-file would be a better solution, but it would update "Products" everywhere throughout the shop.
    – Geert
    Jun 6, 2012 at 15:12
  • 2
    "However you are going to lose new features if you do so." If you don't rename (or change the version number of) the plugin, you're going to lose your own "new feature". If you suggest that that shouldn't be done either the "solution" is neither good nor permanent. If you'd pin the version it's only not good, but at least permanent. @Geert is completely right here. -1 Jun 6, 2012 at 17:52
7

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;
}
1
  • +1 for hooks. Am using the gettext filter here and there as well - not the cleanest, but nice to have for simple UI text fixes. @Teamworksdesign, this is by far the best answer and should be marked as correct, imho. Jun 6, 2012 at 17:46
1

You can use the Admin Menu Editor plugin.

1
  • D'oh, I've actually had that plugin for ages but didn't know you could rename things with it!!
    – Rob
    Jun 6, 2012 at 15:28
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.