Edit File by line
/home/barbar84/www/wp-inclu...
File: post.php
global $wp_post_types;
[1500] Fix | Delete
[1501] Fix | Delete
if ( ! post_type_exists( $post_type ) ) {
[1502] Fix | Delete
return new WP_Error( 'invalid_post_type', __( 'Invalid post type.' ) );
[1503] Fix | Delete
}
[1504] Fix | Delete
[1505] Fix | Delete
$post_type_object = get_post_type_object( $post_type );
[1506] Fix | Delete
[1507] Fix | Delete
// Do not allow unregistering internal post types.
[1508] Fix | Delete
if ( $post_type_object->_builtin ) {
[1509] Fix | Delete
return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) );
[1510] Fix | Delete
}
[1511] Fix | Delete
[1512] Fix | Delete
$post_type_object->remove_supports();
[1513] Fix | Delete
$post_type_object->remove_rewrite_rules();
[1514] Fix | Delete
$post_type_object->unregister_meta_boxes();
[1515] Fix | Delete
$post_type_object->remove_hooks();
[1516] Fix | Delete
$post_type_object->unregister_taxonomies();
[1517] Fix | Delete
[1518] Fix | Delete
unset( $wp_post_types[ $post_type ] );
[1519] Fix | Delete
[1520] Fix | Delete
/**
[1521] Fix | Delete
* Fires after a post type was unregistered.
[1522] Fix | Delete
*
[1523] Fix | Delete
* @since 4.5.0
[1524] Fix | Delete
*
[1525] Fix | Delete
* @param string $post_type Post type key.
[1526] Fix | Delete
*/
[1527] Fix | Delete
do_action( 'unregistered_post_type', $post_type );
[1528] Fix | Delete
[1529] Fix | Delete
return true;
[1530] Fix | Delete
}
[1531] Fix | Delete
[1532] Fix | Delete
/**
[1533] Fix | Delete
* Build an object with all post type capabilities out of a post type object
[1534] Fix | Delete
*
[1535] Fix | Delete
* Post type capabilities use the 'capability_type' argument as a base, if the
[1536] Fix | Delete
* capability is not set in the 'capabilities' argument array or if the
[1537] Fix | Delete
* 'capabilities' argument is not supplied.
[1538] Fix | Delete
*
[1539] Fix | Delete
* The capability_type argument can optionally be registered as an array, with
[1540] Fix | Delete
* the first value being singular and the second plural, e.g. array('story, 'stories')
[1541] Fix | Delete
* Otherwise, an 's' will be added to the value for the plural form. After
[1542] Fix | Delete
* registration, capability_type will always be a string of the singular value.
[1543] Fix | Delete
*
[1544] Fix | Delete
* By default, eight keys are accepted as part of the capabilities array:
[1545] Fix | Delete
*
[1546] Fix | Delete
* - edit_post, read_post, and delete_post are meta capabilities, which are then
[1547] Fix | Delete
* generally mapped to corresponding primitive capabilities depending on the
[1548] Fix | Delete
* context, which would be the post being edited/read/deleted and the user or
[1549] Fix | Delete
* role being checked. Thus these capabilities would generally not be granted
[1550] Fix | Delete
* directly to users or roles.
[1551] Fix | Delete
*
[1552] Fix | Delete
* - edit_posts - Controls whether objects of this post type can be edited.
[1553] Fix | Delete
* - edit_others_posts - Controls whether objects of this type owned by other users
[1554] Fix | Delete
* can be edited. If the post type does not support an author, then this will
[1555] Fix | Delete
* behave like edit_posts.
[1556] Fix | Delete
* - delete_posts - Controls whether objects of this post type can be deleted.
[1557] Fix | Delete
* - publish_posts - Controls publishing objects of this post type.
[1558] Fix | Delete
* - read_private_posts - Controls whether private objects can be read.
[1559] Fix | Delete
*
[1560] Fix | Delete
* These five primitive capabilities are checked in core in various locations.
[1561] Fix | Delete
* There are also six other primitive capabilities which are not referenced
[1562] Fix | Delete
* directly in core, except in map_meta_cap(), which takes the three aforementioned
[1563] Fix | Delete
* meta capabilities and translates them into one or more primitive capabilities
[1564] Fix | Delete
* that must then be checked against the user or role, depending on the context.
[1565] Fix | Delete
*
[1566] Fix | Delete
* - read - Controls whether objects of this post type can be read.
[1567] Fix | Delete
* - delete_private_posts - Controls whether private objects can be deleted.
[1568] Fix | Delete
* - delete_published_posts - Controls whether published objects can be deleted.
[1569] Fix | Delete
* - delete_others_posts - Controls whether objects owned by other users can be
[1570] Fix | Delete
* can be deleted. If the post type does not support an author, then this will
[1571] Fix | Delete
* behave like delete_posts.
[1572] Fix | Delete
* - edit_private_posts - Controls whether private objects can be edited.
[1573] Fix | Delete
* - edit_published_posts - Controls whether published objects can be edited.
[1574] Fix | Delete
*
[1575] Fix | Delete
* These additional capabilities are only used in map_meta_cap(). Thus, they are
[1576] Fix | Delete
* only assigned by default if the post type is registered with the 'map_meta_cap'
[1577] Fix | Delete
* argument set to true (default is false).
[1578] Fix | Delete
*
[1579] Fix | Delete
* @since 3.0.0
[1580] Fix | Delete
* @since 5.4.0 'delete_posts' is included in default capabilities.
[1581] Fix | Delete
*
[1582] Fix | Delete
* @see register_post_type()
[1583] Fix | Delete
* @see map_meta_cap()
[1584] Fix | Delete
*
[1585] Fix | Delete
* @param object $args Post type registration arguments.
[1586] Fix | Delete
* @return object Object with all the capabilities as member variables.
[1587] Fix | Delete
*/
[1588] Fix | Delete
function get_post_type_capabilities( $args ) {
[1589] Fix | Delete
if ( ! is_array( $args->capability_type ) ) {
[1590] Fix | Delete
$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
[1591] Fix | Delete
}
[1592] Fix | Delete
[1593] Fix | Delete
// Singular base for meta capabilities, plural base for primitive capabilities.
[1594] Fix | Delete
list( $singular_base, $plural_base ) = $args->capability_type;
[1595] Fix | Delete
[1596] Fix | Delete
$default_capabilities = array(
[1597] Fix | Delete
// Meta capabilities.
[1598] Fix | Delete
'edit_post' => 'edit_' . $singular_base,
[1599] Fix | Delete
'read_post' => 'read_' . $singular_base,
[1600] Fix | Delete
'delete_post' => 'delete_' . $singular_base,
[1601] Fix | Delete
// Primitive capabilities used outside of map_meta_cap():
[1602] Fix | Delete
'edit_posts' => 'edit_' . $plural_base,
[1603] Fix | Delete
'edit_others_posts' => 'edit_others_' . $plural_base,
[1604] Fix | Delete
'delete_posts' => 'delete_' . $plural_base,
[1605] Fix | Delete
'publish_posts' => 'publish_' . $plural_base,
[1606] Fix | Delete
'read_private_posts' => 'read_private_' . $plural_base,
[1607] Fix | Delete
);
[1608] Fix | Delete
[1609] Fix | Delete
// Primitive capabilities used within map_meta_cap():
[1610] Fix | Delete
if ( $args->map_meta_cap ) {
[1611] Fix | Delete
$default_capabilities_for_mapping = array(
[1612] Fix | Delete
'read' => 'read',
[1613] Fix | Delete
'delete_private_posts' => 'delete_private_' . $plural_base,
[1614] Fix | Delete
'delete_published_posts' => 'delete_published_' . $plural_base,
[1615] Fix | Delete
'delete_others_posts' => 'delete_others_' . $plural_base,
[1616] Fix | Delete
'edit_private_posts' => 'edit_private_' . $plural_base,
[1617] Fix | Delete
'edit_published_posts' => 'edit_published_' . $plural_base,
[1618] Fix | Delete
);
[1619] Fix | Delete
$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
[1620] Fix | Delete
}
[1621] Fix | Delete
[1622] Fix | Delete
$capabilities = array_merge( $default_capabilities, $args->capabilities );
[1623] Fix | Delete
[1624] Fix | Delete
// Post creation capability simply maps to edit_posts by default:
[1625] Fix | Delete
if ( ! isset( $capabilities['create_posts'] ) ) {
[1626] Fix | Delete
$capabilities['create_posts'] = $capabilities['edit_posts'];
[1627] Fix | Delete
}
[1628] Fix | Delete
[1629] Fix | Delete
// Remember meta capabilities for future reference.
[1630] Fix | Delete
if ( $args->map_meta_cap ) {
[1631] Fix | Delete
_post_type_meta_capabilities( $capabilities );
[1632] Fix | Delete
}
[1633] Fix | Delete
[1634] Fix | Delete
return (object) $capabilities;
[1635] Fix | Delete
}
[1636] Fix | Delete
[1637] Fix | Delete
/**
[1638] Fix | Delete
* Store or return a list of post type meta caps for map_meta_cap().
[1639] Fix | Delete
*
[1640] Fix | Delete
* @since 3.1.0
[1641] Fix | Delete
* @access private
[1642] Fix | Delete
*
[1643] Fix | Delete
* @global array $post_type_meta_caps Used to store meta capabilities.
[1644] Fix | Delete
*
[1645] Fix | Delete
* @param string[] $capabilities Post type meta capabilities.
[1646] Fix | Delete
*/
[1647] Fix | Delete
function _post_type_meta_capabilities( $capabilities = null ) {
[1648] Fix | Delete
global $post_type_meta_caps;
[1649] Fix | Delete
[1650] Fix | Delete
foreach ( $capabilities as $core => $custom ) {
[1651] Fix | Delete
if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ), true ) ) {
[1652] Fix | Delete
$post_type_meta_caps[ $custom ] = $core;
[1653] Fix | Delete
}
[1654] Fix | Delete
}
[1655] Fix | Delete
}
[1656] Fix | Delete
[1657] Fix | Delete
/**
[1658] Fix | Delete
* Builds an object with all post type labels out of a post type object.
[1659] Fix | Delete
*
[1660] Fix | Delete
* Accepted keys of the label array in the post type object:
[1661] Fix | Delete
*
[1662] Fix | Delete
* - `name` - General name for the post type, usually plural. The same and overridden
[1663] Fix | Delete
* by `$post_type_object->label`. Default is 'Posts' / 'Pages'.
[1664] Fix | Delete
* - `singular_name` - Name for one object of this post type. Default is 'Post' / 'Page'.
[1665] Fix | Delete
* - `add_new` - Default is 'Add New' for both hierarchical and non-hierarchical types.
[1666] Fix | Delete
* When internationalizing this string, please use a {@link https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#disambiguation-by-context gettext context}
[1667] Fix | Delete
* matching your post type. Example: `_x( 'Add New', 'product', 'textdomain' );`.
[1668] Fix | Delete
* - `add_new_item` - Label for adding a new singular item. Default is 'Add New Post' / 'Add New Page'.
[1669] Fix | Delete
* - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
[1670] Fix | Delete
* - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
[1671] Fix | Delete
* - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
[1672] Fix | Delete
* - `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
[1673] Fix | Delete
* - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
[1674] Fix | Delete
* - `not_found` - Label used when no items are found. Default is 'No posts found' / 'No pages found'.
[1675] Fix | Delete
* - `not_found_in_trash` - Label used when no items are in the Trash. Default is 'No posts found in Trash' /
[1676] Fix | Delete
* 'No pages found in Trash'.
[1677] Fix | Delete
* - `parent_item_colon` - Label used to prefix parents of hierarchical items. Not used on non-hierarchical
[1678] Fix | Delete
* post types. Default is 'Parent Page:'.
[1679] Fix | Delete
* - `all_items` - Label to signify all items in a submenu link. Default is 'All Posts' / 'All Pages'.
[1680] Fix | Delete
* - `archives` - Label for archives in nav menus. Default is 'Post Archives' / 'Page Archives'.
[1681] Fix | Delete
* - `attributes` - Label for the attributes meta box. Default is 'Post Attributes' / 'Page Attributes'.
[1682] Fix | Delete
* - `insert_into_item` - Label for the media frame button. Default is 'Insert into post' / 'Insert into page'.
[1683] Fix | Delete
* - `uploaded_to_this_item` - Label for the media frame filter. Default is 'Uploaded to this post' /
[1684] Fix | Delete
* 'Uploaded to this page'.
[1685] Fix | Delete
* - `featured_image` - Label for the featured image meta box title. Default is 'Featured image'.
[1686] Fix | Delete
* - `set_featured_image` - Label for setting the featured image. Default is 'Set featured image'.
[1687] Fix | Delete
* - `remove_featured_image` - Label for removing the featured image. Default is 'Remove featured image'.
[1688] Fix | Delete
* - `use_featured_image` - Label in the media frame for using a featured image. Default is 'Use as featured image'.
[1689] Fix | Delete
* - `menu_name` - Label for the menu name. Default is the same as `name`.
[1690] Fix | Delete
* - `filter_items_list` - Label for the table views hidden heading. Default is 'Filter posts list' /
[1691] Fix | Delete
* 'Filter pages list'.
[1692] Fix | Delete
* - `filter_by_date` - Label for the date filter in list tables. Default is 'Filter by date'.
[1693] Fix | Delete
* - `items_list_navigation` - Label for the table pagination hidden heading. Default is 'Posts list navigation' /
[1694] Fix | Delete
* 'Pages list navigation'.
[1695] Fix | Delete
* - `items_list` - Label for the table hidden heading. Default is 'Posts list' / 'Pages list'.
[1696] Fix | Delete
* - `item_published` - Label used when an item is published. Default is 'Post published.' / 'Page published.'
[1697] Fix | Delete
* - `item_published_privately` - Label used when an item is published with private visibility.
[1698] Fix | Delete
* Default is 'Post published privately.' / 'Page published privately.'
[1699] Fix | Delete
* - `item_reverted_to_draft` - Label used when an item is switched to a draft.
[1700] Fix | Delete
* Default is 'Post reverted to draft.' / 'Page reverted to draft.'
[1701] Fix | Delete
* - `item_scheduled` - Label used when an item is scheduled for publishing. Default is 'Post scheduled.' /
[1702] Fix | Delete
* 'Page scheduled.'
[1703] Fix | Delete
* - `item_updated` - Label used when an item is updated. Default is 'Post updated.' / 'Page updated.'
[1704] Fix | Delete
*
[1705] Fix | Delete
* Above, the first default value is for non-hierarchical post types (like posts)
[1706] Fix | Delete
* and the second one is for hierarchical post types (like pages).
[1707] Fix | Delete
*
[1708] Fix | Delete
* Note: To set labels used in post type admin notices, see the {@see 'post_updated_messages'} filter.
[1709] Fix | Delete
*
[1710] Fix | Delete
* @since 3.0.0
[1711] Fix | Delete
* @since 4.3.0 Added the `featured_image`, `set_featured_image`, `remove_featured_image`,
[1712] Fix | Delete
* and `use_featured_image` labels.
[1713] Fix | Delete
* @since 4.4.0 Added the `archives`, `insert_into_item`, `uploaded_to_this_item`, `filter_items_list`,
[1714] Fix | Delete
* `items_list_navigation`, and `items_list` labels.
[1715] Fix | Delete
* @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
[1716] Fix | Delete
* @since 4.7.0 Added the `view_items` and `attributes` labels.
[1717] Fix | Delete
* @since 5.0.0 Added the `item_published`, `item_published_privately`, `item_reverted_to_draft`,
[1718] Fix | Delete
* `item_scheduled`, and `item_updated` labels.
[1719] Fix | Delete
* @since 5.7.0 Added the `filter_by_date` label.
[1720] Fix | Delete
*
[1721] Fix | Delete
* @access private
[1722] Fix | Delete
*
[1723] Fix | Delete
* @param object|WP_Post_Type $post_type_object Post type object.
[1724] Fix | Delete
* @return object Object with all the labels as member variables.
[1725] Fix | Delete
*/
[1726] Fix | Delete
function get_post_type_labels( $post_type_object ) {
[1727] Fix | Delete
$nohier_vs_hier_defaults = array(
[1728] Fix | Delete
'name' => array( _x( 'Posts', 'post type general name' ), _x( 'Pages', 'post type general name' ) ),
[1729] Fix | Delete
'singular_name' => array( _x( 'Post', 'post type singular name' ), _x( 'Page', 'post type singular name' ) ),
[1730] Fix | Delete
'add_new' => array( _x( 'Add New', 'post' ), _x( 'Add New', 'page' ) ),
[1731] Fix | Delete
'add_new_item' => array( __( 'Add New Post' ), __( 'Add New Page' ) ),
[1732] Fix | Delete
'edit_item' => array( __( 'Edit Post' ), __( 'Edit Page' ) ),
[1733] Fix | Delete
'new_item' => array( __( 'New Post' ), __( 'New Page' ) ),
[1734] Fix | Delete
'view_item' => array( __( 'View Post' ), __( 'View Page' ) ),
[1735] Fix | Delete
'view_items' => array( __( 'View Posts' ), __( 'View Pages' ) ),
[1736] Fix | Delete
'search_items' => array( __( 'Search Posts' ), __( 'Search Pages' ) ),
[1737] Fix | Delete
'not_found' => array( __( 'No posts found.' ), __( 'No pages found.' ) ),
[1738] Fix | Delete
'not_found_in_trash' => array( __( 'No posts found in Trash.' ), __( 'No pages found in Trash.' ) ),
[1739] Fix | Delete
'parent_item_colon' => array( null, __( 'Parent Page:' ) ),
[1740] Fix | Delete
'all_items' => array( __( 'All Posts' ), __( 'All Pages' ) ),
[1741] Fix | Delete
'archives' => array( __( 'Post Archives' ), __( 'Page Archives' ) ),
[1742] Fix | Delete
'attributes' => array( __( 'Post Attributes' ), __( 'Page Attributes' ) ),
[1743] Fix | Delete
'insert_into_item' => array( __( 'Insert into post' ), __( 'Insert into page' ) ),
[1744] Fix | Delete
'uploaded_to_this_item' => array( __( 'Uploaded to this post' ), __( 'Uploaded to this page' ) ),
[1745] Fix | Delete
'featured_image' => array( _x( 'Featured image', 'post' ), _x( 'Featured image', 'page' ) ),
[1746] Fix | Delete
'set_featured_image' => array( _x( 'Set featured image', 'post' ), _x( 'Set featured image', 'page' ) ),
[1747] Fix | Delete
'remove_featured_image' => array( _x( 'Remove featured image', 'post' ), _x( 'Remove featured image', 'page' ) ),
[1748] Fix | Delete
'use_featured_image' => array( _x( 'Use as featured image', 'post' ), _x( 'Use as featured image', 'page' ) ),
[1749] Fix | Delete
'filter_items_list' => array( __( 'Filter posts list' ), __( 'Filter pages list' ) ),
[1750] Fix | Delete
'filter_by_date' => array( __( 'Filter by date' ), __( 'Filter by date' ) ),
[1751] Fix | Delete
'items_list_navigation' => array( __( 'Posts list navigation' ), __( 'Pages list navigation' ) ),
[1752] Fix | Delete
'items_list' => array( __( 'Posts list' ), __( 'Pages list' ) ),
[1753] Fix | Delete
'item_published' => array( __( 'Post published.' ), __( 'Page published.' ) ),
[1754] Fix | Delete
'item_published_privately' => array( __( 'Post published privately.' ), __( 'Page published privately.' ) ),
[1755] Fix | Delete
'item_reverted_to_draft' => array( __( 'Post reverted to draft.' ), __( 'Page reverted to draft.' ) ),
[1756] Fix | Delete
'item_scheduled' => array( __( 'Post scheduled.' ), __( 'Page scheduled.' ) ),
[1757] Fix | Delete
'item_updated' => array( __( 'Post updated.' ), __( 'Page updated.' ) ),
[1758] Fix | Delete
);
[1759] Fix | Delete
$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
[1760] Fix | Delete
[1761] Fix | Delete
$labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
[1762] Fix | Delete
[1763] Fix | Delete
$post_type = $post_type_object->name;
[1764] Fix | Delete
[1765] Fix | Delete
$default_labels = clone $labels;
[1766] Fix | Delete
[1767] Fix | Delete
/**
[1768] Fix | Delete
* Filters the labels of a specific post type.
[1769] Fix | Delete
*
[1770] Fix | Delete
* The dynamic portion of the hook name, `$post_type`, refers to
[1771] Fix | Delete
* the post type slug.
[1772] Fix | Delete
*
[1773] Fix | Delete
* @since 3.5.0
[1774] Fix | Delete
*
[1775] Fix | Delete
* @see get_post_type_labels() for the full list of labels.
[1776] Fix | Delete
*
[1777] Fix | Delete
* @param object $labels Object with labels for the post type as member variables.
[1778] Fix | Delete
*/
[1779] Fix | Delete
$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
[1780] Fix | Delete
[1781] Fix | Delete
// Ensure that the filtered labels contain all required default values.
[1782] Fix | Delete
$labels = (object) array_merge( (array) $default_labels, (array) $labels );
[1783] Fix | Delete
[1784] Fix | Delete
return $labels;
[1785] Fix | Delete
}
[1786] Fix | Delete
[1787] Fix | Delete
/**
[1788] Fix | Delete
* Build an object with custom-something object (post type, taxonomy) labels
[1789] Fix | Delete
* out of a custom-something object
[1790] Fix | Delete
*
[1791] Fix | Delete
* @since 3.0.0
[1792] Fix | Delete
* @access private
[1793] Fix | Delete
*
[1794] Fix | Delete
* @param object $object A custom-something object.
[1795] Fix | Delete
* @param array $nohier_vs_hier_defaults Hierarchical vs non-hierarchical default labels.
[1796] Fix | Delete
* @return object Object containing labels for the given custom-something object.
[1797] Fix | Delete
*/
[1798] Fix | Delete
function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
[1799] Fix | Delete
$object->labels = (array) $object->labels;
[1800] Fix | Delete
[1801] Fix | Delete
if ( isset( $object->label ) && empty( $object->labels['name'] ) ) {
[1802] Fix | Delete
$object->labels['name'] = $object->label;
[1803] Fix | Delete
}
[1804] Fix | Delete
[1805] Fix | Delete
if ( ! isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
[1806] Fix | Delete
$object->labels['singular_name'] = $object->labels['name'];
[1807] Fix | Delete
}
[1808] Fix | Delete
[1809] Fix | Delete
if ( ! isset( $object->labels['name_admin_bar'] ) ) {
[1810] Fix | Delete
$object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name;
[1811] Fix | Delete
}
[1812] Fix | Delete
[1813] Fix | Delete
if ( ! isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) ) {
[1814] Fix | Delete
$object->labels['menu_name'] = $object->labels['name'];
[1815] Fix | Delete
}
[1816] Fix | Delete
[1817] Fix | Delete
if ( ! isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) {
[1818] Fix | Delete
$object->labels['all_items'] = $object->labels['menu_name'];
[1819] Fix | Delete
}
[1820] Fix | Delete
[1821] Fix | Delete
if ( ! isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) {
[1822] Fix | Delete
$object->labels['archives'] = $object->labels['all_items'];
[1823] Fix | Delete
}
[1824] Fix | Delete
[1825] Fix | Delete
$defaults = array();
[1826] Fix | Delete
foreach ( $nohier_vs_hier_defaults as $key => $value ) {
[1827] Fix | Delete
$defaults[ $key ] = $object->hierarchical ? $value[1] : $value[0];
[1828] Fix | Delete
}
[1829] Fix | Delete
$labels = array_merge( $defaults, $object->labels );
[1830] Fix | Delete
$object->labels = (object) $object->labels;
[1831] Fix | Delete
[1832] Fix | Delete
return (object) $labels;
[1833] Fix | Delete
}
[1834] Fix | Delete
[1835] Fix | Delete
/**
[1836] Fix | Delete
* Add submenus for post types.
[1837] Fix | Delete
*
[1838] Fix | Delete
* @access private
[1839] Fix | Delete
* @since 3.1.0
[1840] Fix | Delete
*/
[1841] Fix | Delete
function _add_post_type_submenus() {
[1842] Fix | Delete
foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
[1843] Fix | Delete
$ptype_obj = get_post_type_object( $ptype );
[1844] Fix | Delete
// Sub-menus only.
[1845] Fix | Delete
if ( ! $ptype_obj->show_in_menu || true === $ptype_obj->show_in_menu ) {
[1846] Fix | Delete
continue;
[1847] Fix | Delete
}
[1848] Fix | Delete
add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
[1849] Fix | Delete
}
[1850] Fix | Delete
}
[1851] Fix | Delete
[1852] Fix | Delete
/**
[1853] Fix | Delete
* Registers support of certain features for a post type.
[1854] Fix | Delete
*
[1855] Fix | Delete
* All core features are directly associated with a functional area of the edit
[1856] Fix | Delete
* screen, such as the editor or a meta box. Features include: 'title', 'editor',
[1857] Fix | Delete
* 'comments', 'revisions', 'trackbacks', 'author', 'excerpt', 'page-attributes',
[1858] Fix | Delete
* 'thumbnail', 'custom-fields', and 'post-formats'.
[1859] Fix | Delete
*
[1860] Fix | Delete
* Additionally, the 'revisions' feature dictates whether the post type will
[1861] Fix | Delete
* store revisions, and the 'comments' feature dictates whether the comments
[1862] Fix | Delete
* count will show on the edit screen.
[1863] Fix | Delete
*
[1864] Fix | Delete
* A third, optional parameter can also be passed along with a feature to provide
[1865] Fix | Delete
* additional information about supporting that feature.
[1866] Fix | Delete
*
[1867] Fix | Delete
* Example usage:
[1868] Fix | Delete
*
[1869] Fix | Delete
* add_post_type_support( 'my_post_type', 'comments' );
[1870] Fix | Delete
* add_post_type_support( 'my_post_type', array(
[1871] Fix | Delete
* 'author', 'excerpt',
[1872] Fix | Delete
* ) );
[1873] Fix | Delete
* add_post_type_support( 'my_post_type', 'my_feature', array(
[1874] Fix | Delete
* 'field' => 'value',
[1875] Fix | Delete
* ) );
[1876] Fix | Delete
*
[1877] Fix | Delete
* @since 3.0.0
[1878] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
[1879] Fix | Delete
* by adding it to the function signature.
[1880] Fix | Delete
*
[1881] Fix | Delete
* @global array $_wp_post_type_features
[1882] Fix | Delete
*
[1883] Fix | Delete
* @param string $post_type The post type for which to add the feature.
[1884] Fix | Delete
* @param string|array $feature The feature being added, accepts an array of
[1885] Fix | Delete
* feature strings or a single string.
[1886] Fix | Delete
* @param mixed ...$args Optional extra arguments to pass along with certain features.
[1887] Fix | Delete
*/
[1888] Fix | Delete
function add_post_type_support( $post_type, $feature, ...$args ) {
[1889] Fix | Delete
global $_wp_post_type_features;
[1890] Fix | Delete
[1891] Fix | Delete
$features = (array) $feature;
[1892] Fix | Delete
foreach ( $features as $feature ) {
[1893] Fix | Delete
if ( $args ) {
[1894] Fix | Delete
$_wp_post_type_features[ $post_type ][ $feature ] = $args;
[1895] Fix | Delete
} else {
[1896] Fix | Delete
$_wp_post_type_features[ $post_type ][ $feature ] = true;
[1897] Fix | Delete
}
[1898] Fix | Delete
}
[1899] Fix | Delete
}
[1900] Fix | Delete
[1901] Fix | Delete
/**
[1902] Fix | Delete
* Remove support for a feature from a post type.
[1903] Fix | Delete
*
[1904] Fix | Delete
* @since 3.0.0
[1905] Fix | Delete
*
[1906] Fix | Delete
* @global array $_wp_post_type_features
[1907] Fix | Delete
*
[1908] Fix | Delete
* @param string $post_type The post type for which to remove the feature.
[1909] Fix | Delete
* @param string $feature The feature being removed.
[1910] Fix | Delete
*/
[1911] Fix | Delete
function remove_post_type_support( $post_type, $feature ) {
[1912] Fix | Delete
global $_wp_post_type_features;
[1913] Fix | Delete
[1914] Fix | Delete
unset( $_wp_post_type_features[ $post_type ][ $feature ] );
[1915] Fix | Delete
}
[1916] Fix | Delete
[1917] Fix | Delete
/**
[1918] Fix | Delete
* Get all the post type features
[1919] Fix | Delete
*
[1920] Fix | Delete
* @since 3.4.0
[1921] Fix | Delete
*
[1922] Fix | Delete
* @global array $_wp_post_type_features
[1923] Fix | Delete
*
[1924] Fix | Delete
* @param string $post_type The post type.
[1925] Fix | Delete
* @return array Post type supports list.
[1926] Fix | Delete
*/
[1927] Fix | Delete
function get_all_post_type_supports( $post_type ) {
[1928] Fix | Delete
global $_wp_post_type_features;
[1929] Fix | Delete
[1930] Fix | Delete
if ( isset( $_wp_post_type_features[ $post_type ] ) ) {
[1931] Fix | Delete
return $_wp_post_type_features[ $post_type ];
[1932] Fix | Delete
}
[1933] Fix | Delete
[1934] Fix | Delete
return array();
[1935] Fix | Delete
}
[1936] Fix | Delete
[1937] Fix | Delete
/**
[1938] Fix | Delete
* Check a post type's support for a given feature.
[1939] Fix | Delete
*
[1940] Fix | Delete
* @since 3.0.0
[1941] Fix | Delete
*
[1942] Fix | Delete
* @global array $_wp_post_type_features
[1943] Fix | Delete
*
[1944] Fix | Delete
* @param string $post_type The post type being checked.
[1945] Fix | Delete
* @param string $feature The feature being checked.
[1946] Fix | Delete
* @return bool Whether the post type supports the given feature.
[1947] Fix | Delete
*/
[1948] Fix | Delete
function post_type_supports( $post_type, $feature ) {
[1949] Fix | Delete
global $_wp_post_type_features;
[1950] Fix | Delete
[1951] Fix | Delete
return ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) );
[1952] Fix | Delete
}
[1953] Fix | Delete
[1954] Fix | Delete
/**
[1955] Fix | Delete
* Retrieves a list of post type names that support a specific feature.
[1956] Fix | Delete
*
[1957] Fix | Delete
* @since 4.5.0
[1958] Fix | Delete
*
[1959] Fix | Delete
* @global array $_wp_post_type_features Post type features
[1960] Fix | Delete
*
[1961] Fix | Delete
* @param array|string $feature Single feature or an array of features the post types should support.
[1962] Fix | Delete
* @param string $operator Optional. The logical operation to perform. 'or' means
[1963] Fix | Delete
* only one element from the array needs to match; 'and'
[1964] Fix | Delete
* means all elements must match; 'not' means no elements may
[1965] Fix | Delete
* match. Default 'and'.
[1966] Fix | Delete
* @return string[] A list of post type names.
[1967] Fix | Delete
*/
[1968] Fix | Delete
function get_post_types_by_support( $feature, $operator = 'and' ) {
[1969] Fix | Delete
global $_wp_post_type_features;
[1970] Fix | Delete
[1971] Fix | Delete
$features = array_fill_keys( (array) $feature, true );
[1972] Fix | Delete
[1973] Fix | Delete
return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );
[1974] Fix | Delete
}
[1975] Fix | Delete
[1976] Fix | Delete
/**
[1977] Fix | Delete
* Update the post type for the post ID.
[1978] Fix | Delete
*
[1979] Fix | Delete
* The page or post cache will be cleaned for the post ID.
[1980] Fix | Delete
*
[1981] Fix | Delete
* @since 2.5.0
[1982] Fix | Delete
*
[1983] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[1984] Fix | Delete
*
[1985] Fix | Delete
* @param int $post_id Optional. Post ID to change post type. Default 0.
[1986] Fix | Delete
* @param string $post_type Optional. Post type. Accepts 'post' or 'page' to
[1987] Fix | Delete
* name a few. Default 'post'.
[1988] Fix | Delete
* @return int|false Amount of rows changed. Should be 1 for success and 0 for failure.
[1989] Fix | Delete
*/
[1990] Fix | Delete
function set_post_type( $post_id = 0, $post_type = 'post' ) {
[1991] Fix | Delete
global $wpdb;
[1992] Fix | Delete
[1993] Fix | Delete
$post_type = sanitize_post_field( 'post_type', $post_type, $post_id, 'db' );
[1994] Fix | Delete
$return = $wpdb->update( $wpdb->posts, array( 'post_type' => $post_type ), array( 'ID' => $post_id ) );
[1995] Fix | Delete
[1996] Fix | Delete
clean_post_cache( $post_id );
[1997] Fix | Delete
[1998] Fix | Delete
return $return;
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function