Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: post.php
* @since 3.0.0
[1500] Fix | Delete
*
[1501] Fix | Delete
* @global stdClass[] $wp_post_statuses List of post statuses.
[1502] Fix | Delete
*
[1503] Fix | Delete
* @see register_post_status()
[1504] Fix | Delete
*
[1505] Fix | Delete
* @param array|string $args Optional. Array or string of post status arguments to compare against
[1506] Fix | Delete
* properties of the global `$wp_post_statuses objects`. Default empty array.
[1507] Fix | Delete
* @param string $output Optional. The type of output to return, either 'names' or 'objects'. Default 'names'.
[1508] Fix | Delete
* @param string $operator Optional. The logical operation to perform. 'or' means only one element
[1509] Fix | Delete
* from the array needs to match; 'and' means all elements must match.
[1510] Fix | Delete
* Default 'and'.
[1511] Fix | Delete
* @return string[]|stdClass[] A list of post status names or objects.
[1512] Fix | Delete
*/
[1513] Fix | Delete
function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) {
[1514] Fix | Delete
global $wp_post_statuses;
[1515] Fix | Delete
[1516] Fix | Delete
$field = ( 'names' === $output ) ? 'name' : false;
[1517] Fix | Delete
[1518] Fix | Delete
return wp_filter_object_list( $wp_post_statuses, $args, $operator, $field );
[1519] Fix | Delete
}
[1520] Fix | Delete
[1521] Fix | Delete
/**
[1522] Fix | Delete
* Determines whether the post type is hierarchical.
[1523] Fix | Delete
*
[1524] Fix | Delete
* A false return value might also mean that the post type does not exist.
[1525] Fix | Delete
*
[1526] Fix | Delete
* @since 3.0.0
[1527] Fix | Delete
*
[1528] Fix | Delete
* @see get_post_type_object()
[1529] Fix | Delete
*
[1530] Fix | Delete
* @param string $post_type Post type name
[1531] Fix | Delete
* @return bool Whether post type is hierarchical.
[1532] Fix | Delete
*/
[1533] Fix | Delete
function is_post_type_hierarchical( $post_type ) {
[1534] Fix | Delete
if ( ! post_type_exists( $post_type ) ) {
[1535] Fix | Delete
return false;
[1536] Fix | Delete
}
[1537] Fix | Delete
[1538] Fix | Delete
$post_type = get_post_type_object( $post_type );
[1539] Fix | Delete
return $post_type->hierarchical;
[1540] Fix | Delete
}
[1541] Fix | Delete
[1542] Fix | Delete
/**
[1543] Fix | Delete
* Determines whether a post type is registered.
[1544] Fix | Delete
*
[1545] Fix | Delete
* For more information on this and similar theme functions, check out
[1546] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[1547] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[1548] Fix | Delete
*
[1549] Fix | Delete
* @since 3.0.0
[1550] Fix | Delete
*
[1551] Fix | Delete
* @see get_post_type_object()
[1552] Fix | Delete
*
[1553] Fix | Delete
* @param string $post_type Post type name.
[1554] Fix | Delete
* @return bool Whether post type is registered.
[1555] Fix | Delete
*/
[1556] Fix | Delete
function post_type_exists( $post_type ) {
[1557] Fix | Delete
return (bool) get_post_type_object( $post_type );
[1558] Fix | Delete
}
[1559] Fix | Delete
[1560] Fix | Delete
/**
[1561] Fix | Delete
* Retrieves the post type of the current post or of a given post.
[1562] Fix | Delete
*
[1563] Fix | Delete
* @since 2.1.0
[1564] Fix | Delete
*
[1565] Fix | Delete
* @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post.
[1566] Fix | Delete
* @return string|false Post type on success, false on failure.
[1567] Fix | Delete
*/
[1568] Fix | Delete
function get_post_type( $post = null ) {
[1569] Fix | Delete
$post = get_post( $post );
[1570] Fix | Delete
if ( $post ) {
[1571] Fix | Delete
return $post->post_type;
[1572] Fix | Delete
}
[1573] Fix | Delete
[1574] Fix | Delete
return false;
[1575] Fix | Delete
}
[1576] Fix | Delete
[1577] Fix | Delete
/**
[1578] Fix | Delete
* Retrieves a post type object by name.
[1579] Fix | Delete
*
[1580] Fix | Delete
* @since 3.0.0
[1581] Fix | Delete
* @since 4.6.0 Object returned is now an instance of `WP_Post_Type`.
[1582] Fix | Delete
*
[1583] Fix | Delete
* @global array $wp_post_types List of post types.
[1584] Fix | Delete
*
[1585] Fix | Delete
* @see register_post_type()
[1586] Fix | Delete
*
[1587] Fix | Delete
* @param string $post_type The name of a registered post type.
[1588] Fix | Delete
* @return WP_Post_Type|null WP_Post_Type object if it exists, null otherwise.
[1589] Fix | Delete
*/
[1590] Fix | Delete
function get_post_type_object( $post_type ) {
[1591] Fix | Delete
global $wp_post_types;
[1592] Fix | Delete
[1593] Fix | Delete
if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) {
[1594] Fix | Delete
return null;
[1595] Fix | Delete
}
[1596] Fix | Delete
[1597] Fix | Delete
return $wp_post_types[ $post_type ];
[1598] Fix | Delete
}
[1599] Fix | Delete
[1600] Fix | Delete
/**
[1601] Fix | Delete
* Gets a list of all registered post type objects.
[1602] Fix | Delete
*
[1603] Fix | Delete
* @since 2.9.0
[1604] Fix | Delete
*
[1605] Fix | Delete
* @global array $wp_post_types List of post types.
[1606] Fix | Delete
*
[1607] Fix | Delete
* @see register_post_type() for accepted arguments.
[1608] Fix | Delete
*
[1609] Fix | Delete
* @param array|string $args Optional. An array of key => value arguments to match against
[1610] Fix | Delete
* the post type objects. Default empty array.
[1611] Fix | Delete
* @param string $output Optional. The type of output to return. Either 'names'
[1612] Fix | Delete
* or 'objects'. Default 'names'.
[1613] Fix | Delete
* @param string $operator Optional. The logical operation to perform. 'or' means only one
[1614] Fix | Delete
* element from the array needs to match; 'and' means all elements
[1615] Fix | Delete
* must match; 'not' means no elements may match. Default 'and'.
[1616] Fix | Delete
* @return string[]|WP_Post_Type[] An array of post type names or objects.
[1617] Fix | Delete
*/
[1618] Fix | Delete
function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) {
[1619] Fix | Delete
global $wp_post_types;
[1620] Fix | Delete
[1621] Fix | Delete
$field = ( 'names' === $output ) ? 'name' : false;
[1622] Fix | Delete
[1623] Fix | Delete
return wp_filter_object_list( $wp_post_types, $args, $operator, $field );
[1624] Fix | Delete
}
[1625] Fix | Delete
[1626] Fix | Delete
/**
[1627] Fix | Delete
* Registers a post type.
[1628] Fix | Delete
*
[1629] Fix | Delete
* Note: Post type registrations should not be hooked before the
[1630] Fix | Delete
* {@see 'init'} action. Also, any taxonomy connections should be
[1631] Fix | Delete
* registered via the `$taxonomies` argument to ensure consistency
[1632] Fix | Delete
* when hooks such as {@see 'parse_query'} or {@see 'pre_get_posts'}
[1633] Fix | Delete
* are used.
[1634] Fix | Delete
*
[1635] Fix | Delete
* Post types can support any number of built-in core features such
[1636] Fix | Delete
* as meta boxes, custom fields, post thumbnails, post statuses,
[1637] Fix | Delete
* comments, and more. See the `$supports` argument for a complete
[1638] Fix | Delete
* list of supported features.
[1639] Fix | Delete
*
[1640] Fix | Delete
* @since 2.9.0
[1641] Fix | Delete
* @since 3.0.0 The `show_ui` argument is now enforced on the new post screen.
[1642] Fix | Delete
* @since 4.4.0 The `show_ui` argument is now enforced on the post type listing
[1643] Fix | Delete
* screen and post editing screen.
[1644] Fix | Delete
* @since 4.6.0 Post type object returned is now an instance of `WP_Post_Type`.
[1645] Fix | Delete
* @since 4.7.0 Introduced `show_in_rest`, `rest_base` and `rest_controller_class`
[1646] Fix | Delete
* arguments to register the post type in REST API.
[1647] Fix | Delete
* @since 5.0.0 The `template` and `template_lock` arguments were added.
[1648] Fix | Delete
* @since 5.3.0 The `supports` argument will now accept an array of arguments for a feature.
[1649] Fix | Delete
* @since 5.9.0 The `rest_namespace` argument was added.
[1650] Fix | Delete
*
[1651] Fix | Delete
* @global array $wp_post_types List of post types.
[1652] Fix | Delete
*
[1653] Fix | Delete
* @param string $post_type Post type key. Must not exceed 20 characters and may only contain
[1654] Fix | Delete
* lowercase alphanumeric characters, dashes, and underscores. See sanitize_key().
[1655] Fix | Delete
* @param array|string $args {
[1656] Fix | Delete
* Array or string of arguments for registering a post type.
[1657] Fix | Delete
*
[1658] Fix | Delete
* @type string $label Name of the post type shown in the menu. Usually plural.
[1659] Fix | Delete
* Default is value of $labels['name'].
[1660] Fix | Delete
* @type string[] $labels An array of labels for this post type. If not set, post
[1661] Fix | Delete
* labels are inherited for non-hierarchical types and page
[1662] Fix | Delete
* labels for hierarchical ones. See get_post_type_labels() for a full
[1663] Fix | Delete
* list of supported labels.
[1664] Fix | Delete
* @type string $description A short descriptive summary of what the post type is.
[1665] Fix | Delete
* Default empty.
[1666] Fix | Delete
* @type bool $public Whether a post type is intended for use publicly either via
[1667] Fix | Delete
* the admin interface or by front-end users. While the default
[1668] Fix | Delete
* settings of $exclude_from_search, $publicly_queryable, $show_ui,
[1669] Fix | Delete
* and $show_in_nav_menus are inherited from $public, each does not
[1670] Fix | Delete
* rely on this relationship and controls a very specific intention.
[1671] Fix | Delete
* Default false.
[1672] Fix | Delete
* @type bool $hierarchical Whether the post type is hierarchical (e.g. page). Default false.
[1673] Fix | Delete
* @type bool $exclude_from_search Whether to exclude posts with this post type from front end search
[1674] Fix | Delete
* results. Default is the opposite value of $public.
[1675] Fix | Delete
* @type bool $publicly_queryable Whether queries can be performed on the front end for the post type
[1676] Fix | Delete
* as part of parse_request(). Endpoints would include:
[1677] Fix | Delete
* * ?post_type={post_type_key}
[1678] Fix | Delete
* * ?{post_type_key}={single_post_slug}
[1679] Fix | Delete
* * ?{post_type_query_var}={single_post_slug}
[1680] Fix | Delete
* If not set, the default is inherited from $public.
[1681] Fix | Delete
* @type bool $show_ui Whether to generate and allow a UI for managing this post type in the
[1682] Fix | Delete
* admin. Default is value of $public.
[1683] Fix | Delete
* @type bool|string $show_in_menu Where to show the post type in the admin menu. To work, $show_ui
[1684] Fix | Delete
* must be true. If true, the post type is shown in its own top level
[1685] Fix | Delete
* menu. If false, no menu is shown. If a string of an existing top
[1686] Fix | Delete
* level menu ('tools.php' or 'edit.php?post_type=page', for example), the
[1687] Fix | Delete
* post type will be placed as a sub-menu of that.
[1688] Fix | Delete
* Default is value of $show_ui.
[1689] Fix | Delete
* @type bool $show_in_nav_menus Makes this post type available for selection in navigation menus.
[1690] Fix | Delete
* Default is value of $public.
[1691] Fix | Delete
* @type bool $show_in_admin_bar Makes this post type available via the admin bar. Default is value
[1692] Fix | Delete
* of $show_in_menu.
[1693] Fix | Delete
* @type bool $show_in_rest Whether to include the post type in the REST API. Set this to true
[1694] Fix | Delete
* for the post type to be available in the block editor.
[1695] Fix | Delete
* @type string $rest_base To change the base URL of REST API route. Default is $post_type.
[1696] Fix | Delete
* @type string $rest_namespace To change the namespace URL of REST API route. Default is wp/v2.
[1697] Fix | Delete
* @type string $rest_controller_class REST API controller class name. Default is 'WP_REST_Posts_Controller'.
[1698] Fix | Delete
* @type string|bool $autosave_rest_controller_class REST API controller class name. Default is 'WP_REST_Autosaves_Controller'.
[1699] Fix | Delete
* @type string|bool $revisions_rest_controller_class REST API controller class name. Default is 'WP_REST_Revisions_Controller'.
[1700] Fix | Delete
* @type bool $late_route_registration A flag to direct the REST API controllers for autosave / revisions
[1701] Fix | Delete
* should be registered before/after the post type controller.
[1702] Fix | Delete
* @type int $menu_position The position in the menu order the post type should appear. To work,
[1703] Fix | Delete
* $show_in_menu must be true. Default null (at the bottom).
[1704] Fix | Delete
* @type string $menu_icon The URL to the icon to be used for this menu. Pass a base64-encoded
[1705] Fix | Delete
* SVG using a data URI, which will be colored to match the color scheme
[1706] Fix | Delete
* -- this should begin with 'data:image/svg+xml;base64,'. Pass the name
[1707] Fix | Delete
* of a Dashicons helper class to use a font icon, e.g.
[1708] Fix | Delete
* 'dashicons-chart-pie'. Pass 'none' to leave div.wp-menu-image empty
[1709] Fix | Delete
* so an icon can be added via CSS. Defaults to use the posts icon.
[1710] Fix | Delete
* @type string|array $capability_type The string to use to build the read, edit, and delete capabilities.
[1711] Fix | Delete
* May be passed as an array to allow for alternative plurals when using
[1712] Fix | Delete
* this argument as a base to construct the capabilities, e.g.
[1713] Fix | Delete
* array('story', 'stories'). Default 'post'.
[1714] Fix | Delete
* @type string[] $capabilities Array of capabilities for this post type. $capability_type is used
[1715] Fix | Delete
* as a base to construct capabilities by default.
[1716] Fix | Delete
* See get_post_type_capabilities().
[1717] Fix | Delete
* @type bool $map_meta_cap Whether to use the internal default meta capability handling.
[1718] Fix | Delete
* Default false.
[1719] Fix | Delete
* @type array|false $supports Core feature(s) the post type supports. Serves as an alias for calling
[1720] Fix | Delete
* add_post_type_support() directly. Core features include 'title',
[1721] Fix | Delete
* 'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt',
[1722] Fix | Delete
* 'page-attributes', 'thumbnail', 'custom-fields', and 'post-formats'.
[1723] Fix | Delete
* Additionally, the 'revisions' feature dictates whether the post type
[1724] Fix | Delete
* will store revisions, the 'autosave' feature dictates whether the post type
[1725] Fix | Delete
* will be autosaved, and the 'comments' feature dictates whether the
[1726] Fix | Delete
* comments count will show on the edit screen. For backward compatibility reasons,
[1727] Fix | Delete
* adding 'editor' support implies 'autosave' support too. A feature can also be
[1728] Fix | Delete
* specified as an array of arguments to provide additional information
[1729] Fix | Delete
* about supporting that feature.
[1730] Fix | Delete
* Example: `array( 'my_feature', array( 'field' => 'value' ) )`.
[1731] Fix | Delete
* If false, no features will be added.
[1732] Fix | Delete
* Default is an array containing 'title' and 'editor'.
[1733] Fix | Delete
* @type callable $register_meta_box_cb Provide a callback function that sets up the meta boxes for the
[1734] Fix | Delete
* edit form. Do remove_meta_box() and add_meta_box() calls in the
[1735] Fix | Delete
* callback. Default null.
[1736] Fix | Delete
* @type string[] $taxonomies An array of taxonomy identifiers that will be registered for the
[1737] Fix | Delete
* post type. Taxonomies can be registered later with register_taxonomy()
[1738] Fix | Delete
* or register_taxonomy_for_object_type().
[1739] Fix | Delete
* Default empty array.
[1740] Fix | Delete
* @type bool|string $has_archive Whether there should be post type archives, or if a string, the
[1741] Fix | Delete
* archive slug to use. Will generate the proper rewrite rules if
[1742] Fix | Delete
* $rewrite is enabled. Default false.
[1743] Fix | Delete
* @type bool|array $rewrite {
[1744] Fix | Delete
* Triggers the handling of rewrites for this post type. To prevent rewrite, set to false.
[1745] Fix | Delete
* Defaults to true, using $post_type as slug. To specify rewrite rules, an array can be
[1746] Fix | Delete
* passed with any of these keys:
[1747] Fix | Delete
*
[1748] Fix | Delete
* @type string $slug Customize the permastruct slug. Defaults to $post_type key.
[1749] Fix | Delete
* @type bool $with_front Whether the permastruct should be prepended with WP_Rewrite::$front.
[1750] Fix | Delete
* Default true.
[1751] Fix | Delete
* @type bool $feeds Whether the feed permastruct should be built for this post type.
[1752] Fix | Delete
* Default is value of $has_archive.
[1753] Fix | Delete
* @type bool $pages Whether the permastruct should provide for pagination. Default true.
[1754] Fix | Delete
* @type int $ep_mask Endpoint mask to assign. If not specified and permalink_epmask is set,
[1755] Fix | Delete
* inherits from $permalink_epmask. If not specified and permalink_epmask
[1756] Fix | Delete
* is not set, defaults to EP_PERMALINK.
[1757] Fix | Delete
* }
[1758] Fix | Delete
* @type string|bool $query_var Sets the query_var key for this post type. Defaults to $post_type
[1759] Fix | Delete
* key. If false, a post type cannot be loaded at
[1760] Fix | Delete
* ?{query_var}={post_slug}. If specified as a string, the query
[1761] Fix | Delete
* ?{query_var_string}={post_slug} will be valid.
[1762] Fix | Delete
* @type bool $can_export Whether to allow this post type to be exported. Default true.
[1763] Fix | Delete
* @type bool $delete_with_user Whether to delete posts of this type when deleting a user.
[1764] Fix | Delete
* * If true, posts of this type belonging to the user will be moved
[1765] Fix | Delete
* to Trash when the user is deleted.
[1766] Fix | Delete
* * If false, posts of this type belonging to the user will *not*
[1767] Fix | Delete
* be trashed or deleted.
[1768] Fix | Delete
* * If not set (the default), posts are trashed if post type supports
[1769] Fix | Delete
* the 'author' feature. Otherwise posts are not trashed or deleted.
[1770] Fix | Delete
* Default null.
[1771] Fix | Delete
* @type array $template Array of blocks to use as the default initial state for an editor
[1772] Fix | Delete
* session. Each item should be an array containing block name and
[1773] Fix | Delete
* optional attributes. Default empty array.
[1774] Fix | Delete
* @type string|false $template_lock Whether the block template should be locked if $template is set.
[1775] Fix | Delete
* * If set to 'all', the user is unable to insert new blocks,
[1776] Fix | Delete
* move existing blocks and delete blocks.
[1777] Fix | Delete
* * If set to 'insert', the user is able to move existing blocks
[1778] Fix | Delete
* but is unable to insert new blocks and delete blocks.
[1779] Fix | Delete
* Default false.
[1780] Fix | Delete
* @type bool $_builtin FOR INTERNAL USE ONLY! True if this post type is a native or
[1781] Fix | Delete
* "built-in" post_type. Default false.
[1782] Fix | Delete
* @type string $_edit_link FOR INTERNAL USE ONLY! URL segment to use for edit link of
[1783] Fix | Delete
* this post type. Default 'post.php?post=%d'.
[1784] Fix | Delete
* }
[1785] Fix | Delete
* @return WP_Post_Type|WP_Error The registered post type object on success,
[1786] Fix | Delete
* WP_Error object on failure.
[1787] Fix | Delete
*/
[1788] Fix | Delete
function register_post_type( $post_type, $args = array() ) {
[1789] Fix | Delete
global $wp_post_types;
[1790] Fix | Delete
[1791] Fix | Delete
if ( ! is_array( $wp_post_types ) ) {
[1792] Fix | Delete
$wp_post_types = array();
[1793] Fix | Delete
}
[1794] Fix | Delete
[1795] Fix | Delete
// Sanitize post type name.
[1796] Fix | Delete
$post_type = sanitize_key( $post_type );
[1797] Fix | Delete
[1798] Fix | Delete
if ( empty( $post_type ) || strlen( $post_type ) > 20 ) {
[1799] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Post type names must be between 1 and 20 characters in length.' ), '4.2.0' );
[1800] Fix | Delete
return new WP_Error( 'post_type_length_invalid', __( 'Post type names must be between 1 and 20 characters in length.' ) );
[1801] Fix | Delete
}
[1802] Fix | Delete
[1803] Fix | Delete
$post_type_object = new WP_Post_Type( $post_type, $args );
[1804] Fix | Delete
$post_type_object->add_supports();
[1805] Fix | Delete
$post_type_object->add_rewrite_rules();
[1806] Fix | Delete
$post_type_object->register_meta_boxes();
[1807] Fix | Delete
[1808] Fix | Delete
$wp_post_types[ $post_type ] = $post_type_object;
[1809] Fix | Delete
[1810] Fix | Delete
$post_type_object->add_hooks();
[1811] Fix | Delete
$post_type_object->register_taxonomies();
[1812] Fix | Delete
[1813] Fix | Delete
/**
[1814] Fix | Delete
* Fires after a post type is registered.
[1815] Fix | Delete
*
[1816] Fix | Delete
* @since 3.3.0
[1817] Fix | Delete
* @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
[1818] Fix | Delete
*
[1819] Fix | Delete
* @param string $post_type Post type.
[1820] Fix | Delete
* @param WP_Post_Type $post_type_object Arguments used to register the post type.
[1821] Fix | Delete
*/
[1822] Fix | Delete
do_action( 'registered_post_type', $post_type, $post_type_object );
[1823] Fix | Delete
[1824] Fix | Delete
/**
[1825] Fix | Delete
* Fires after a specific post type is registered.
[1826] Fix | Delete
*
[1827] Fix | Delete
* The dynamic portion of the filter name, `$post_type`, refers to the post type key.
[1828] Fix | Delete
*
[1829] Fix | Delete
* Possible hook names include:
[1830] Fix | Delete
*
[1831] Fix | Delete
* - `registered_post_type_post`
[1832] Fix | Delete
* - `registered_post_type_page`
[1833] Fix | Delete
*
[1834] Fix | Delete
* @since 6.0.0
[1835] Fix | Delete
*
[1836] Fix | Delete
* @param string $post_type Post type.
[1837] Fix | Delete
* @param WP_Post_Type $post_type_object Arguments used to register the post type.
[1838] Fix | Delete
*/
[1839] Fix | Delete
do_action( "registered_post_type_{$post_type}", $post_type, $post_type_object );
[1840] Fix | Delete
[1841] Fix | Delete
return $post_type_object;
[1842] Fix | Delete
}
[1843] Fix | Delete
[1844] Fix | Delete
/**
[1845] Fix | Delete
* Unregisters a post type.
[1846] Fix | Delete
*
[1847] Fix | Delete
* Cannot be used to unregister built-in post types.
[1848] Fix | Delete
*
[1849] Fix | Delete
* @since 4.5.0
[1850] Fix | Delete
*
[1851] Fix | Delete
* @global array $wp_post_types List of post types.
[1852] Fix | Delete
*
[1853] Fix | Delete
* @param string $post_type Post type to unregister.
[1854] Fix | Delete
* @return true|WP_Error True on success, WP_Error on failure or if the post type doesn't exist.
[1855] Fix | Delete
*/
[1856] Fix | Delete
function unregister_post_type( $post_type ) {
[1857] Fix | Delete
global $wp_post_types;
[1858] Fix | Delete
[1859] Fix | Delete
if ( ! post_type_exists( $post_type ) ) {
[1860] Fix | Delete
return new WP_Error( 'invalid_post_type', __( 'Invalid post type.' ) );
[1861] Fix | Delete
}
[1862] Fix | Delete
[1863] Fix | Delete
$post_type_object = get_post_type_object( $post_type );
[1864] Fix | Delete
[1865] Fix | Delete
// Do not allow unregistering internal post types.
[1866] Fix | Delete
if ( $post_type_object->_builtin ) {
[1867] Fix | Delete
return new WP_Error( 'invalid_post_type', __( 'Unregistering a built-in post type is not allowed' ) );
[1868] Fix | Delete
}
[1869] Fix | Delete
[1870] Fix | Delete
$post_type_object->remove_supports();
[1871] Fix | Delete
$post_type_object->remove_rewrite_rules();
[1872] Fix | Delete
$post_type_object->unregister_meta_boxes();
[1873] Fix | Delete
$post_type_object->remove_hooks();
[1874] Fix | Delete
$post_type_object->unregister_taxonomies();
[1875] Fix | Delete
[1876] Fix | Delete
unset( $wp_post_types[ $post_type ] );
[1877] Fix | Delete
[1878] Fix | Delete
/**
[1879] Fix | Delete
* Fires after a post type was unregistered.
[1880] Fix | Delete
*
[1881] Fix | Delete
* @since 4.5.0
[1882] Fix | Delete
*
[1883] Fix | Delete
* @param string $post_type Post type key.
[1884] Fix | Delete
*/
[1885] Fix | Delete
do_action( 'unregistered_post_type', $post_type );
[1886] Fix | Delete
[1887] Fix | Delete
return true;
[1888] Fix | Delete
}
[1889] Fix | Delete
[1890] Fix | Delete
/**
[1891] Fix | Delete
* Builds an object with all post type capabilities out of a post type object
[1892] Fix | Delete
*
[1893] Fix | Delete
* Post type capabilities use the 'capability_type' argument as a base, if the
[1894] Fix | Delete
* capability is not set in the 'capabilities' argument array or if the
[1895] Fix | Delete
* 'capabilities' argument is not supplied.
[1896] Fix | Delete
*
[1897] Fix | Delete
* The capability_type argument can optionally be registered as an array, with
[1898] Fix | Delete
* the first value being singular and the second plural, e.g. array('story, 'stories')
[1899] Fix | Delete
* Otherwise, an 's' will be added to the value for the plural form. After
[1900] Fix | Delete
* registration, capability_type will always be a string of the singular value.
[1901] Fix | Delete
*
[1902] Fix | Delete
* By default, eight keys are accepted as part of the capabilities array:
[1903] Fix | Delete
*
[1904] Fix | Delete
* - edit_post, read_post, and delete_post are meta capabilities, which are then
[1905] Fix | Delete
* generally mapped to corresponding primitive capabilities depending on the
[1906] Fix | Delete
* context, which would be the post being edited/read/deleted and the user or
[1907] Fix | Delete
* role being checked. Thus these capabilities would generally not be granted
[1908] Fix | Delete
* directly to users or roles.
[1909] Fix | Delete
*
[1910] Fix | Delete
* - edit_posts - Controls whether objects of this post type can be edited.
[1911] Fix | Delete
* - edit_others_posts - Controls whether objects of this type owned by other users
[1912] Fix | Delete
* can be edited. If the post type does not support an author, then this will
[1913] Fix | Delete
* behave like edit_posts.
[1914] Fix | Delete
* - delete_posts - Controls whether objects of this post type can be deleted.
[1915] Fix | Delete
* - publish_posts - Controls publishing objects of this post type.
[1916] Fix | Delete
* - read_private_posts - Controls whether private objects can be read.
[1917] Fix | Delete
*
[1918] Fix | Delete
* These five primitive capabilities are checked in core in various locations.
[1919] Fix | Delete
* There are also six other primitive capabilities which are not referenced
[1920] Fix | Delete
* directly in core, except in map_meta_cap(), which takes the three aforementioned
[1921] Fix | Delete
* meta capabilities and translates them into one or more primitive capabilities
[1922] Fix | Delete
* that must then be checked against the user or role, depending on the context.
[1923] Fix | Delete
*
[1924] Fix | Delete
* - read - Controls whether objects of this post type can be read.
[1925] Fix | Delete
* - delete_private_posts - Controls whether private objects can be deleted.
[1926] Fix | Delete
* - delete_published_posts - Controls whether published objects can be deleted.
[1927] Fix | Delete
* - delete_others_posts - Controls whether objects owned by other users can be
[1928] Fix | Delete
* can be deleted. If the post type does not support an author, then this will
[1929] Fix | Delete
* behave like delete_posts.
[1930] Fix | Delete
* - edit_private_posts - Controls whether private objects can be edited.
[1931] Fix | Delete
* - edit_published_posts - Controls whether published objects can be edited.
[1932] Fix | Delete
*
[1933] Fix | Delete
* These additional capabilities are only used in map_meta_cap(). Thus, they are
[1934] Fix | Delete
* only assigned by default if the post type is registered with the 'map_meta_cap'
[1935] Fix | Delete
* argument set to true (default is false).
[1936] Fix | Delete
*
[1937] Fix | Delete
* @since 3.0.0
[1938] Fix | Delete
* @since 5.4.0 'delete_posts' is included in default capabilities.
[1939] Fix | Delete
*
[1940] Fix | Delete
* @see register_post_type()
[1941] Fix | Delete
* @see map_meta_cap()
[1942] Fix | Delete
*
[1943] Fix | Delete
* @param object $args Post type registration arguments.
[1944] Fix | Delete
* @return object Object with all the capabilities as member variables.
[1945] Fix | Delete
*/
[1946] Fix | Delete
function get_post_type_capabilities( $args ) {
[1947] Fix | Delete
if ( ! is_array( $args->capability_type ) ) {
[1948] Fix | Delete
$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
[1949] Fix | Delete
}
[1950] Fix | Delete
[1951] Fix | Delete
// Singular base for meta capabilities, plural base for primitive capabilities.
[1952] Fix | Delete
list( $singular_base, $plural_base ) = $args->capability_type;
[1953] Fix | Delete
[1954] Fix | Delete
$default_capabilities = array(
[1955] Fix | Delete
// Meta capabilities.
[1956] Fix | Delete
'edit_post' => 'edit_' . $singular_base,
[1957] Fix | Delete
'read_post' => 'read_' . $singular_base,
[1958] Fix | Delete
'delete_post' => 'delete_' . $singular_base,
[1959] Fix | Delete
// Primitive capabilities used outside of map_meta_cap():
[1960] Fix | Delete
'edit_posts' => 'edit_' . $plural_base,
[1961] Fix | Delete
'edit_others_posts' => 'edit_others_' . $plural_base,
[1962] Fix | Delete
'delete_posts' => 'delete_' . $plural_base,
[1963] Fix | Delete
'publish_posts' => 'publish_' . $plural_base,
[1964] Fix | Delete
'read_private_posts' => 'read_private_' . $plural_base,
[1965] Fix | Delete
);
[1966] Fix | Delete
[1967] Fix | Delete
// Primitive capabilities used within map_meta_cap():
[1968] Fix | Delete
if ( $args->map_meta_cap ) {
[1969] Fix | Delete
$default_capabilities_for_mapping = array(
[1970] Fix | Delete
'read' => 'read',
[1971] Fix | Delete
'delete_private_posts' => 'delete_private_' . $plural_base,
[1972] Fix | Delete
'delete_published_posts' => 'delete_published_' . $plural_base,
[1973] Fix | Delete
'delete_others_posts' => 'delete_others_' . $plural_base,
[1974] Fix | Delete
'edit_private_posts' => 'edit_private_' . $plural_base,
[1975] Fix | Delete
'edit_published_posts' => 'edit_published_' . $plural_base,
[1976] Fix | Delete
);
[1977] Fix | Delete
$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
[1978] Fix | Delete
}
[1979] Fix | Delete
[1980] Fix | Delete
$capabilities = array_merge( $default_capabilities, $args->capabilities );
[1981] Fix | Delete
[1982] Fix | Delete
// Post creation capability simply maps to edit_posts by default:
[1983] Fix | Delete
if ( ! isset( $capabilities['create_posts'] ) ) {
[1984] Fix | Delete
$capabilities['create_posts'] = $capabilities['edit_posts'];
[1985] Fix | Delete
}
[1986] Fix | Delete
[1987] Fix | Delete
// Remember meta capabilities for future reference.
[1988] Fix | Delete
if ( $args->map_meta_cap ) {
[1989] Fix | Delete
_post_type_meta_capabilities( $capabilities );
[1990] Fix | Delete
}
[1991] Fix | Delete
[1992] Fix | Delete
return (object) $capabilities;
[1993] Fix | Delete
}
[1994] Fix | Delete
[1995] Fix | Delete
/**
[1996] Fix | Delete
* Stores or returns a list of post type meta caps for map_meta_cap().
[1997] Fix | Delete
*
[1998] Fix | Delete
* @since 3.1.0
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function