/** * Builds an object with all post type labels out of a post type object * * Accepted keys of the label array in the post type object: * - name - general name for the post type, usually plural. The same and overriden by $post_type_object->label. Default is Posts/Pages * - singular_name - name for one object of this post type. Default is Post/Page * - add_new - Default is Add New for both hierarchical and non-hierarchical types. When internationalizing this string, please use a {@link http://codex.wordpress.org/I18n_for_WordPress_Developers#Disambiguation_by_context gettext context} matching your post type. Example: <code>_x('Add New', 'product');</code> * - add_new_item - Default is Add New Post/Add New Page * - edit_item - Default is Edit Post/Edit Page * - new_item - Default is New Post/New Page * - view_item - Default is View Post/View Page * - search_items - Default is Search Posts/Search Pages * - not_found - Default is No posts found/No pages found * - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page: * * Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages). * * @since 3.0.0 * @param object $post_type_object * @return object object with all the labels as member variables */ function get_post_type_labels($post_type_object) { $nohier_vs_hier_defaults = array('name' => array(_x('Posts', 'post type general name'), _x('Pages', 'post type general name')), 'singular_name' => array(_x('Post', 'post type singular name'), _x('Page', 'post type singular name')), 'add_new' => array(_x('Add New', 'post'), _x('Add New', 'page')), 'add_new_item' => array(__('Add New Post'), __('Add New Page')), 'edit_item' => array(__('Edit Post'), __('Edit Page')), 'new_item' => array(__('New Post'), __('New Page')), 'view_item' => array(__('View Post'), __('View Page')), 'search_items' => array(__('Search Posts'), __('Search Pages')), 'not_found' => array(__('No posts found.'), __('No pages found.')), 'not_found_in_trash' => array(__('No posts found in Trash.'), __('No pages found in Trash.')), 'parent_item_colon' => array(null, __('Parent Page:'))); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; return _get_custom_object_labels($post_type_object, $nohier_vs_hier_defaults); }
/** * Build an object with all post type labels out of a post type object * * Accepted keys of the label array in the post type object: * * - name - general name for the post type, usually plural. The same and overridden * by $post_type_object->label. Default is Posts/Pages * - singular_name - name for one object of this post type. Default is Post/Page * - add_new - Default is Add New for both hierarchical and non-hierarchical types. * When internationalizing this string, please use a gettext context * {@link https://codex.wordpress.org/I18n_for_WordPress_Developers#Disambiguation_by_context} * matching your post type. Example: `_x( 'Add New', 'product' );`. * - add_new_item - Default is Add New Post/Add New Page. * - edit_item - Default is Edit Post/Edit Page. * - new_item - Default is New Post/New Page. * - view_item - Default is View Post/View Page. * - search_items - Default is Search Posts/Search Pages. * - not_found - Default is No posts found/No pages found. * - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash. * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical * ones the default is 'Parent Page:'. * - all_items - String for the submenu. Default is All Posts/All Pages. * - archives - String for use with archives in nav menus. Default is Post Archives/Page Archives. * - insert_into_item - String for the media frame button. Default is Insert into post/Insert into page. * - uploaded_to_this_item - String for the media frame filter. Default is Uploaded to this post/Uploaded to this page. * - featured_image - Default is Featured Image. * - set_featured_image - Default is Set featured image. * - remove_featured_image - Default is Remove featured image. * - use_featured_image - Default is Use as featured image. * - menu_name - Default is the same as `name`. * - filter_items_list - String for the table views hidden heading. * - items_list_navigation - String for the table pagination hidden heading. * - items_list - String for the table hidden heading. * * Above, the first default value is for non-hierarchical post types (like posts) * and the second one is for hierarchical post types (like pages). * * @since 3.0.0 * @since 4.3.0 Added the `featured_image`, `set_featured_image`, `remove_featured_image`, * and `use_featured_image` labels. * @since 4.4.0 Added the `insert_into_item`, `uploaded_to_this_item`, `filter_items_list`, * `items_list_navigation`, and `items_list` labels. * * @access private * * @param object $post_type_object Post type object. * @return object object with all the labels as member variables. */ function get_post_type_labels($post_type_object) { $nohier_vs_hier_defaults = array('name' => array(_x('Posts', 'post type general name'), _x('Pages', 'post type general name')), 'singular_name' => array(_x('Post', 'post type singular name'), _x('Page', 'post type singular name')), 'add_new' => array(_x('Add New', 'post'), _x('Add New', 'page')), 'add_new_item' => array(__('Add New Post'), __('Add New Page')), 'edit_item' => array(__('Edit Post'), __('Edit Page')), 'new_item' => array(__('New Post'), __('New Page')), 'view_item' => array(__('View Post'), __('View Page')), 'search_items' => array(__('Search Posts'), __('Search Pages')), 'not_found' => array(__('No posts found.'), __('No pages found.')), 'not_found_in_trash' => array(__('No posts found in Trash.'), __('No pages found in Trash.')), 'parent_item_colon' => array(null, __('Parent Page:')), 'all_items' => array(__('All Posts'), __('All Pages')), 'archives' => array(__('Post Archives'), __('Page Archives')), 'insert_into_item' => array(__('Insert into post'), __('Insert into page')), 'uploaded_to_this_item' => array(__('Uploaded to this post'), __('Uploaded to this page')), 'featured_image' => array(__('Featured Image'), __('Featured Image')), 'set_featured_image' => array(__('Set featured image'), __('Set featured image')), 'remove_featured_image' => array(__('Remove featured image'), __('Remove featured image')), 'use_featured_image' => array(__('Use as featured image'), __('Use as featured image')), 'filter_items_list' => array(__('Filter posts list'), __('Filter pages list')), 'items_list_navigation' => array(__('Posts list navigation'), __('Pages list navigation')), 'items_list' => array(__('Posts list'), __('Pages list'))); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; $labels = _get_custom_object_labels($post_type_object, $nohier_vs_hier_defaults); $post_type = $post_type_object->name; $default_labels = clone $labels; /** * Filter the labels of a specific post type. * * The dynamic portion of the hook name, `$post_type`, refers to * the post type slug. * * @since 3.5.0 * * @see get_post_type_labels() for the full list of labels. * * @param object $labels Object with labels for the post type as member variables. */ $labels = apply_filters("post_type_labels_{$post_type}", $labels); // Ensure that the filtered labels contain all required default values. $labels = (object) array_merge((array) $default_labels, (array) $labels); return $labels; }
/** * Builds an object with all taxonomy labels out of a taxonomy object * * Accepted keys of the label array in the taxonomy object: * * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories * - singular_name - name for one object of this taxonomy. Default is Tag/Category * - search_items - Default is Search Tags/Search Categories * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags * - all_items - Default is All Tags/All Categories * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category * - parent_item_colon - The same as `parent_item`, but with colon `:` in the end * - edit_item - Default is Edit Tag/Edit Category * - view_item - Default is View Tag/View Category * - update_item - Default is Update Tag/Update Category * - add_new_item - Default is Add New Tag/Add New Category * - new_item_name - Default is New Tag Name/New Category Name * - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas", used in the meta box. * - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags", used in the meta box when JavaScript is disabled. * - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags", used in the meta box. * - not_found - Default is "No tags found"/"No categories found", used in the meta box and taxonomy list table. * - no_terms - Default is "No tags"/"No categories", used in the posts and media list tables. * - pagination - String for the table pagination hidden heading. * - list - String for the table hidden heading. * * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories). * * @todo Better documentation for the labels array. * * @since 3.0.0 * @since 4.3.0 Added the `no_terms` label. * * @param object $tax Taxonomy object. * @return object object with all the labels as member variables. */ function get_taxonomy_labels($tax) { $tax->labels = (array) $tax->labels; if (isset($tax->helps) && empty($tax->labels['separate_items_with_commas'])) { $tax->labels['separate_items_with_commas'] = $tax->helps; } if (isset($tax->no_tagcloud) && empty($tax->labels['not_found'])) { $tax->labels['not_found'] = $tax->no_tagcloud; } $nohier_vs_hier_defaults = array('name' => array(_x('Tags', 'taxonomy general name'), _x('Categories', 'taxonomy general name')), 'singular_name' => array(_x('Tag', 'taxonomy singular name'), _x('Category', 'taxonomy singular name')), 'search_items' => array(__('Search Tags'), __('Search Categories')), 'popular_items' => array(__('Popular Tags'), null), 'all_items' => array(__('All Tags'), __('All Categories')), 'parent_item' => array(null, __('Parent Category')), 'parent_item_colon' => array(null, __('Parent Category:')), 'edit_item' => array(__('Edit Tag'), __('Edit Category')), 'view_item' => array(__('View Tag'), __('View Category')), 'update_item' => array(__('Update Tag'), __('Update Category')), 'add_new_item' => array(__('Add New Tag'), __('Add New Category')), 'new_item_name' => array(__('New Tag Name'), __('New Category Name')), 'separate_items_with_commas' => array(__('Separate tags with commas'), null), 'add_or_remove_items' => array(__('Add or remove tags'), null), 'choose_from_most_used' => array(__('Choose from the most used tags'), null), 'not_found' => array(__('No tags found.'), __('No categories found.')), 'no_terms' => array(__('No tags'), __('No categories')), 'pagination' => array(__('Tags list navigation'), __('Categories list navigation')), 'list' => array(__('Tags list'), __('Categories list'))); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; return _get_custom_object_labels($tax, $nohier_vs_hier_defaults); }
/** * Build an object with all post type labels out of a post type object * * Accepted keys of the label array in the post type object: * * - name - general name for the post type, usually plural. The same and overridden * by $post_type_object->label. Default is Posts/Pages * - singular_name - name for one object of this post type. Default is Post/Page * - add_new - Default is Add New for both hierarchical and non-hierarchical types. * When internationalizing this string, please use a gettext context * {@link http://codex.wordpress.org/I18n_for_WordPress_Developers#Disambiguation_by_context} * matching your post type. Example: `_x( 'Add New', 'product' );`. * - add_new_item - Default is Add New Post/Add New Page. * - edit_item - Default is Edit Post/Edit Page. * - new_item - Default is New Post/New Page. * - view_item - Default is View Post/View Page. * - search_items - Default is Search Posts/Search Pages. * - not_found - Default is No posts found/No pages found. * - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash. * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical * ones the default is 'Parent Page:'. * - all_items - String for the submenu. Default is All Posts/All Pages. * - menu_name - Default is the same as `name`. * * Above, the first default value is for non-hierarchical post types (like posts) * and the second one is for hierarchical post types (like pages). * * @since 3.0.0 * @access private * * @param object $post_type_object Post type object. * @return object object with all the labels as member variables. */ function get_post_type_labels($post_type_object) { $nohier_vs_hier_defaults = array('name' => array(_x('Posts', 'post type general name'), _x('Pages', 'post type general name')), 'singular_name' => array(_x('Post', 'post type singular name'), _x('Page', 'post type singular name')), 'add_new' => array(_x('Add New', 'post'), _x('Add New', 'page')), 'add_new_item' => array(__('Add New Post'), __('Add New Page')), 'edit_item' => array(__('Edit Post'), __('Edit Page')), 'new_item' => array(__('New Post'), __('New Page')), 'view_item' => array(__('View Post'), __('View Page')), 'search_items' => array(__('Search Posts'), __('Search Pages')), 'not_found' => array(__('No posts found.'), __('No pages found.')), 'not_found_in_trash' => array(__('No posts found in Trash.'), __('No pages found in Trash.')), 'parent_item_colon' => array(null, __('Parent Page:')), 'all_items' => array(__('All Posts'), __('All Pages'))); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; $labels = _get_custom_object_labels($post_type_object, $nohier_vs_hier_defaults); $post_type = $post_type_object->name; /** * Filter the labels of a specific post type. * * The dynamic portion of the hook name, `$post_type`, refers to * the post type slug. * * @since 3.5.0 * * @see get_post_type_labels() for the full list of labels. * * @param array $labels Array of labels for the given post type. */ return apply_filters("post_type_labels_{$post_type}", $labels); }
/** * Builds an object with all taxonomy labels out of a taxonomy object * * Accepted keys of the label array in the taxonomy object: * * - name - general name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default is Tags/Categories * - singular_name - name for one object of this taxonomy. Default is Tag/Category * - search_items - Default is Search Tags/Search Categories * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags * - all_items - Default is All Tags/All Categories * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category * - parent_item_colon - The same as `parent_item`, but with colon `:` in the end * - edit_item - Default is Edit Tag/Edit Category * - view_item - Default is View Tag/View Category * - update_item - Default is Update Tag/Update Category * - add_new_item - Default is Add New Tag/Add New Category * - new_item_name - Default is New Tag Name/New Category Name * - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas", used in the meta box. * - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags", used in the meta box when JavaScript is disabled. * - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags", used in the meta box. * - not_found - Default is "No tags found"/"No categories found", used in the meta box and taxonomy list table. * - no_terms - Default is "No tags"/"No categories", used in the posts and media list tables. * - items_list_navigation - String for the table pagination hidden heading. * - items_list - String for the table hidden heading. * * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories). * * @todo Better documentation for the labels array. * * @since 3.0.0 * @since 4.3.0 Added the `no_terms` label. * @since 4.4.0 Added the `items_list_navigation` and `items_list` labels. * * @param object $tax Taxonomy object. * @return object object with all the labels as member variables. */ function get_taxonomy_labels($tax) { $tax->labels = (array) $tax->labels; if (isset($tax->helps) && empty($tax->labels['separate_items_with_commas'])) { $tax->labels['separate_items_with_commas'] = $tax->helps; } if (isset($tax->no_tagcloud) && empty($tax->labels['not_found'])) { $tax->labels['not_found'] = $tax->no_tagcloud; } $nohier_vs_hier_defaults = array('name' => array(_x('Tags', 'taxonomy general name'), _x('Categories', 'taxonomy general name')), 'singular_name' => array(_x('Tag', 'taxonomy singular name'), _x('Category', 'taxonomy singular name')), 'search_items' => array(__('Search Tags'), __('Search Categories')), 'popular_items' => array(__('Popular Tags'), null), 'all_items' => array(__('All Tags'), __('All Categories')), 'parent_item' => array(null, __('Parent Category')), 'parent_item_colon' => array(null, __('Parent Category:')), 'edit_item' => array(__('Edit Tag'), __('Edit Category')), 'view_item' => array(__('View Tag'), __('View Category')), 'update_item' => array(__('Update Tag'), __('Update Category')), 'add_new_item' => array(__('Add New Tag'), __('Add New Category')), 'new_item_name' => array(__('New Tag Name'), __('New Category Name')), 'separate_items_with_commas' => array(__('Separate tags with commas'), null), 'add_or_remove_items' => array(__('Add or remove tags'), null), 'choose_from_most_used' => array(__('Choose from the most used tags'), null), 'not_found' => array(__('No tags found.'), __('No categories found.')), 'no_terms' => array(__('No tags'), __('No categories')), 'items_list_navigation' => array(__('Tags list navigation'), __('Categories list navigation')), 'items_list' => array(__('Tags list'), __('Categories list'))); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; $labels = _get_custom_object_labels($tax, $nohier_vs_hier_defaults); $taxonomy = $tax->name; $default_labels = clone $labels; /** * Filter the labels of a specific taxonomy. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 4.4.0 * * @see get_taxonomy_labels() for the full list of taxonomy labels. * * @param object $labels Object with labels for the taxonomy as member variables. */ $labels = apply_filters("taxonomy_labels_{$taxonomy}", $labels); // Ensure that the filtered labels contain all required default values. $labels = (object) array_merge((array) $default_labels, (array) $labels); return $labels; }
/** * Builds an object with all taxonomy labels out of a taxonomy object * * Accepted keys of the label array in the taxonomy object: * - name - general name for the taxonomy, usually plural. The same as and overriden by $tax->label. Default is Post Tags/Categories * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category * - search_items - Default is Search Tags/Search Categories * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags * - all_items - Default is All Tags/All Categories * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category * - parent_item_colon - The same as <code>parent_item</code>, but with colon <code>:</code> in the end * - edit_item - Default is Edit Tag/Edit Category * - update_item - Default is Update Tag/Update Category * - add_new_item - Default is Add New Tag/Add New Category * - new_item_name - Default is New Tag Name/New Category Name * - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas," used in the meta box. * - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags," used in the meta box when JavaScript is disabled. * - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags," used in the meta box. * * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.) * * @since 3.0.0 * @param object $tax Taxonomy object * @return object object with all the labels as member variables */ function get_taxonomy_labels($tax) { if (isset($tax->helps) && empty($tax->labels['separate_items_with_commas'])) { $tax->labels['separate_items_with_commas'] = $tax->helps; } $nohier_vs_hier_defaults = array('name' => array(_x('Post Tags', 'taxonomy general name'), _x('Categories', 'taxonomy general name')), 'singular_name' => array(_x('Post Tag', 'taxonomy singular name'), _x('Category', 'taxonomy singular name')), 'search_items' => array(__('Search Tags'), __('Search Categories')), 'popular_items' => array(__('Popular Tags'), null), 'all_items' => array(__('All Tags'), __('All Categories')), 'parent_item' => array(null, __('Parent Category')), 'parent_item_colon' => array(null, __('Parent Category:')), 'edit_item' => array(__('Edit Tag'), __('Edit Category')), 'update_item' => array(__('Update Tag'), __('Update Category')), 'add_new_item' => array(__('Add New Tag'), __('Add New Category')), 'new_item_name' => array(__('New Tag Name'), __('New Category Name')), 'separate_items_with_commas' => array(__('Separate tags with commas'), null), 'add_or_remove_items' => array(__('Add or remove tags'), null), 'choose_from_most_used' => array(__('Choose from the most used tags'), null)); return _get_custom_object_labels($tax, $nohier_vs_hier_defaults); }