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
* @access private
[2000] Fix | Delete
*
[2001] Fix | Delete
* @global array $post_type_meta_caps Used to store meta capabilities.
[2002] Fix | Delete
*
[2003] Fix | Delete
* @param string[] $capabilities Post type meta capabilities.
[2004] Fix | Delete
*/
[2005] Fix | Delete
function _post_type_meta_capabilities( $capabilities = null ) {
[2006] Fix | Delete
global $post_type_meta_caps;
[2007] Fix | Delete
[2008] Fix | Delete
foreach ( $capabilities as $core => $custom ) {
[2009] Fix | Delete
if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ), true ) ) {
[2010] Fix | Delete
$post_type_meta_caps[ $custom ] = $core;
[2011] Fix | Delete
}
[2012] Fix | Delete
}
[2013] Fix | Delete
}
[2014] Fix | Delete
[2015] Fix | Delete
/**
[2016] Fix | Delete
* Builds an object with all post type labels out of a post type object.
[2017] Fix | Delete
*
[2018] Fix | Delete
* Accepted keys of the label array in the post type object:
[2019] Fix | Delete
*
[2020] Fix | Delete
* - `name` - General name for the post type, usually plural. The same and overridden
[2021] Fix | Delete
* by `$post_type_object->label`. Default is 'Posts' / 'Pages'.
[2022] Fix | Delete
* - `singular_name` - Name for one object of this post type. Default is 'Post' / 'Page'.
[2023] Fix | Delete
* - `add_new` - Label for adding a new item. Default is 'Add New Post' / 'Add New Page'.
[2024] Fix | Delete
* - `add_new_item` - Label for adding a new singular item. Default is 'Add New Post' / 'Add New Page'.
[2025] Fix | Delete
* - `edit_item` - Label for editing a singular item. Default is 'Edit Post' / 'Edit Page'.
[2026] Fix | Delete
* - `new_item` - Label for the new item page title. Default is 'New Post' / 'New Page'.
[2027] Fix | Delete
* - `view_item` - Label for viewing a singular item. Default is 'View Post' / 'View Page'.
[2028] Fix | Delete
* - `view_items` - Label for viewing post type archives. Default is 'View Posts' / 'View Pages'.
[2029] Fix | Delete
* - `search_items` - Label for searching plural items. Default is 'Search Posts' / 'Search Pages'.
[2030] Fix | Delete
* - `not_found` - Label used when no items are found. Default is 'No posts found' / 'No pages found'.
[2031] Fix | Delete
* - `not_found_in_trash` - Label used when no items are in the Trash. Default is 'No posts found in Trash' /
[2032] Fix | Delete
* 'No pages found in Trash'.
[2033] Fix | Delete
* - `parent_item_colon` - Label used to prefix parents of hierarchical items. Not used on non-hierarchical
[2034] Fix | Delete
* post types. Default is 'Parent Page:'.
[2035] Fix | Delete
* - `all_items` - Label to signify all items in a submenu link. Default is 'All Posts' / 'All Pages'.
[2036] Fix | Delete
* - `archives` - Label for archives in nav menus. Default is 'Post Archives' / 'Page Archives'.
[2037] Fix | Delete
* - `attributes` - Label for the attributes meta box. Default is 'Post Attributes' / 'Page Attributes'.
[2038] Fix | Delete
* - `insert_into_item` - Label for the media frame button. Default is 'Insert into post' / 'Insert into page'.
[2039] Fix | Delete
* - `uploaded_to_this_item` - Label for the media frame filter. Default is 'Uploaded to this post' /
[2040] Fix | Delete
* 'Uploaded to this page'.
[2041] Fix | Delete
* - `featured_image` - Label for the featured image meta box title. Default is 'Featured image'.
[2042] Fix | Delete
* - `set_featured_image` - Label for setting the featured image. Default is 'Set featured image'.
[2043] Fix | Delete
* - `remove_featured_image` - Label for removing the featured image. Default is 'Remove featured image'.
[2044] Fix | Delete
* - `use_featured_image` - Label in the media frame for using a featured image. Default is 'Use as featured image'.
[2045] Fix | Delete
* - `menu_name` - Label for the menu name. Default is the same as `name`.
[2046] Fix | Delete
* - `filter_items_list` - Label for the table views hidden heading. Default is 'Filter posts list' /
[2047] Fix | Delete
* 'Filter pages list'.
[2048] Fix | Delete
* - `filter_by_date` - Label for the date filter in list tables. Default is 'Filter by date'.
[2049] Fix | Delete
* - `items_list_navigation` - Label for the table pagination hidden heading. Default is 'Posts list navigation' /
[2050] Fix | Delete
* 'Pages list navigation'.
[2051] Fix | Delete
* - `items_list` - Label for the table hidden heading. Default is 'Posts list' / 'Pages list'.
[2052] Fix | Delete
* - `item_published` - Label used when an item is published. Default is 'Post published.' / 'Page published.'
[2053] Fix | Delete
* - `item_published_privately` - Label used when an item is published with private visibility.
[2054] Fix | Delete
* Default is 'Post published privately.' / 'Page published privately.'
[2055] Fix | Delete
* - `item_reverted_to_draft` - Label used when an item is switched to a draft.
[2056] Fix | Delete
* Default is 'Post reverted to draft.' / 'Page reverted to draft.'
[2057] Fix | Delete
* - `item_trashed` - Label used when an item is moved to Trash. Default is 'Post trashed.' / 'Page trashed.'
[2058] Fix | Delete
* - `item_scheduled` - Label used when an item is scheduled for publishing. Default is 'Post scheduled.' /
[2059] Fix | Delete
* 'Page scheduled.'
[2060] Fix | Delete
* - `item_updated` - Label used when an item is updated. Default is 'Post updated.' / 'Page updated.'
[2061] Fix | Delete
* - `item_link` - Title for a navigation link block variation. Default is 'Post Link' / 'Page Link'.
[2062] Fix | Delete
* - `item_link_description` - Description for a navigation link block variation. Default is 'A link to a post.' /
[2063] Fix | Delete
* 'A link to a page.'
[2064] Fix | Delete
*
[2065] Fix | Delete
* Above, the first default value is for non-hierarchical post types (like posts)
[2066] Fix | Delete
* and the second one is for hierarchical post types (like pages).
[2067] Fix | Delete
*
[2068] Fix | Delete
* Note: To set labels used in post type admin notices, see the {@see 'post_updated_messages'} filter.
[2069] Fix | Delete
*
[2070] Fix | Delete
* @since 3.0.0
[2071] Fix | Delete
* @since 4.3.0 Added the `featured_image`, `set_featured_image`, `remove_featured_image`,
[2072] Fix | Delete
* and `use_featured_image` labels.
[2073] Fix | Delete
* @since 4.4.0 Added the `archives`, `insert_into_item`, `uploaded_to_this_item`, `filter_items_list`,
[2074] Fix | Delete
* `items_list_navigation`, and `items_list` labels.
[2075] Fix | Delete
* @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
[2076] Fix | Delete
* @since 4.7.0 Added the `view_items` and `attributes` labels.
[2077] Fix | Delete
* @since 5.0.0 Added the `item_published`, `item_published_privately`, `item_reverted_to_draft`,
[2078] Fix | Delete
* `item_scheduled`, and `item_updated` labels.
[2079] Fix | Delete
* @since 5.7.0 Added the `filter_by_date` label.
[2080] Fix | Delete
* @since 5.8.0 Added the `item_link` and `item_link_description` labels.
[2081] Fix | Delete
* @since 6.3.0 Added the `item_trashed` label.
[2082] Fix | Delete
* @since 6.4.0 Changed default values for the `add_new` label to include the type of content.
[2083] Fix | Delete
* This matches `add_new_item` and provides more context for better accessibility.
[2084] Fix | Delete
* @since 6.6.0 Added the `template_name` label.
[2085] Fix | Delete
*
[2086] Fix | Delete
* @access private
[2087] Fix | Delete
*
[2088] Fix | Delete
* @param object|WP_Post_Type $post_type_object Post type object.
[2089] Fix | Delete
* @return object Object with all the labels as member variables.
[2090] Fix | Delete
*/
[2091] Fix | Delete
function get_post_type_labels( $post_type_object ) {
[2092] Fix | Delete
$nohier_vs_hier_defaults = WP_Post_Type::get_default_labels();
[2093] Fix | Delete
[2094] Fix | Delete
$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
[2095] Fix | Delete
[2096] Fix | Delete
$labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
[2097] Fix | Delete
[2098] Fix | Delete
if ( ! isset( $post_type_object->labels->template_name ) && isset( $post_type_object->labels->singular_name ) ) {
[2099] Fix | Delete
/* translators: %s: Post type name. */
[2100] Fix | Delete
$labels->template_name = sprintf( __( 'Single item: %s' ), $post_type_object->labels->singular_name );
[2101] Fix | Delete
}
[2102] Fix | Delete
[2103] Fix | Delete
$post_type = $post_type_object->name;
[2104] Fix | Delete
[2105] Fix | Delete
$default_labels = clone $labels;
[2106] Fix | Delete
[2107] Fix | Delete
/**
[2108] Fix | Delete
* Filters the labels of a specific post type.
[2109] Fix | Delete
*
[2110] Fix | Delete
* The dynamic portion of the hook name, `$post_type`, refers to
[2111] Fix | Delete
* the post type slug.
[2112] Fix | Delete
*
[2113] Fix | Delete
* Possible hook names include:
[2114] Fix | Delete
*
[2115] Fix | Delete
* - `post_type_labels_post`
[2116] Fix | Delete
* - `post_type_labels_page`
[2117] Fix | Delete
* - `post_type_labels_attachment`
[2118] Fix | Delete
*
[2119] Fix | Delete
* @since 3.5.0
[2120] Fix | Delete
*
[2121] Fix | Delete
* @see get_post_type_labels() for the full list of labels.
[2122] Fix | Delete
*
[2123] Fix | Delete
* @param object $labels Object with labels for the post type as member variables.
[2124] Fix | Delete
*/
[2125] Fix | Delete
$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
[2126] Fix | Delete
[2127] Fix | Delete
// Ensure that the filtered labels contain all required default values.
[2128] Fix | Delete
$labels = (object) array_merge( (array) $default_labels, (array) $labels );
[2129] Fix | Delete
[2130] Fix | Delete
return $labels;
[2131] Fix | Delete
}
[2132] Fix | Delete
[2133] Fix | Delete
/**
[2134] Fix | Delete
* Builds an object with custom-something object (post type, taxonomy) labels
[2135] Fix | Delete
* out of a custom-something object
[2136] Fix | Delete
*
[2137] Fix | Delete
* @since 3.0.0
[2138] Fix | Delete
* @access private
[2139] Fix | Delete
*
[2140] Fix | Delete
* @param object $data_object A custom-something object.
[2141] Fix | Delete
* @param array $nohier_vs_hier_defaults Hierarchical vs non-hierarchical default labels.
[2142] Fix | Delete
* @return object Object containing labels for the given custom-something object.
[2143] Fix | Delete
*/
[2144] Fix | Delete
function _get_custom_object_labels( $data_object, $nohier_vs_hier_defaults ) {
[2145] Fix | Delete
$data_object->labels = (array) $data_object->labels;
[2146] Fix | Delete
[2147] Fix | Delete
if ( isset( $data_object->label ) && empty( $data_object->labels['name'] ) ) {
[2148] Fix | Delete
$data_object->labels['name'] = $data_object->label;
[2149] Fix | Delete
}
[2150] Fix | Delete
[2151] Fix | Delete
if ( ! isset( $data_object->labels['singular_name'] ) && isset( $data_object->labels['name'] ) ) {
[2152] Fix | Delete
$data_object->labels['singular_name'] = $data_object->labels['name'];
[2153] Fix | Delete
}
[2154] Fix | Delete
[2155] Fix | Delete
if ( ! isset( $data_object->labels['name_admin_bar'] ) ) {
[2156] Fix | Delete
$data_object->labels['name_admin_bar'] =
[2157] Fix | Delete
isset( $data_object->labels['singular_name'] )
[2158] Fix | Delete
? $data_object->labels['singular_name']
[2159] Fix | Delete
: $data_object->name;
[2160] Fix | Delete
}
[2161] Fix | Delete
[2162] Fix | Delete
if ( ! isset( $data_object->labels['menu_name'] ) && isset( $data_object->labels['name'] ) ) {
[2163] Fix | Delete
$data_object->labels['menu_name'] = $data_object->labels['name'];
[2164] Fix | Delete
}
[2165] Fix | Delete
[2166] Fix | Delete
if ( ! isset( $data_object->labels['all_items'] ) && isset( $data_object->labels['menu_name'] ) ) {
[2167] Fix | Delete
$data_object->labels['all_items'] = $data_object->labels['menu_name'];
[2168] Fix | Delete
}
[2169] Fix | Delete
[2170] Fix | Delete
if ( ! isset( $data_object->labels['archives'] ) && isset( $data_object->labels['all_items'] ) ) {
[2171] Fix | Delete
$data_object->labels['archives'] = $data_object->labels['all_items'];
[2172] Fix | Delete
}
[2173] Fix | Delete
[2174] Fix | Delete
$defaults = array();
[2175] Fix | Delete
foreach ( $nohier_vs_hier_defaults as $key => $value ) {
[2176] Fix | Delete
$defaults[ $key ] = $data_object->hierarchical ? $value[1] : $value[0];
[2177] Fix | Delete
}
[2178] Fix | Delete
[2179] Fix | Delete
$labels = array_merge( $defaults, $data_object->labels );
[2180] Fix | Delete
$data_object->labels = (object) $data_object->labels;
[2181] Fix | Delete
[2182] Fix | Delete
return (object) $labels;
[2183] Fix | Delete
}
[2184] Fix | Delete
[2185] Fix | Delete
/**
[2186] Fix | Delete
* Adds submenus for post types.
[2187] Fix | Delete
*
[2188] Fix | Delete
* @access private
[2189] Fix | Delete
* @since 3.1.0
[2190] Fix | Delete
*/
[2191] Fix | Delete
function _add_post_type_submenus() {
[2192] Fix | Delete
foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
[2193] Fix | Delete
$ptype_obj = get_post_type_object( $ptype );
[2194] Fix | Delete
// Sub-menus only.
[2195] Fix | Delete
if ( ! $ptype_obj->show_in_menu || true === $ptype_obj->show_in_menu ) {
[2196] Fix | Delete
continue;
[2197] Fix | Delete
}
[2198] 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" );
[2199] Fix | Delete
}
[2200] Fix | Delete
}
[2201] Fix | Delete
[2202] Fix | Delete
/**
[2203] Fix | Delete
* Registers support of certain features for a post type.
[2204] Fix | Delete
*
[2205] Fix | Delete
* All core features are directly associated with a functional area of the edit
[2206] Fix | Delete
* screen, such as the editor or a meta box. Features include: 'title', 'editor',
[2207] Fix | Delete
* 'comments', 'revisions', 'trackbacks', 'author', 'excerpt', 'page-attributes',
[2208] Fix | Delete
* 'thumbnail', 'custom-fields', and 'post-formats'.
[2209] Fix | Delete
*
[2210] Fix | Delete
* Additionally, the 'revisions' feature dictates whether the post type will
[2211] Fix | Delete
* store revisions, the 'autosave' feature dictates whether the post type
[2212] Fix | Delete
* will be autosaved, and the 'comments' feature dictates whether the comments
[2213] Fix | Delete
* count will show on the edit screen.
[2214] Fix | Delete
*
[2215] Fix | Delete
* A third, optional parameter can also be passed along with a feature to provide
[2216] Fix | Delete
* additional information about supporting that feature.
[2217] Fix | Delete
*
[2218] Fix | Delete
* Example usage:
[2219] Fix | Delete
*
[2220] Fix | Delete
* add_post_type_support( 'my_post_type', 'comments' );
[2221] Fix | Delete
* add_post_type_support( 'my_post_type', array(
[2222] Fix | Delete
* 'author', 'excerpt',
[2223] Fix | Delete
* ) );
[2224] Fix | Delete
* add_post_type_support( 'my_post_type', 'my_feature', array(
[2225] Fix | Delete
* 'field' => 'value',
[2226] Fix | Delete
* ) );
[2227] Fix | Delete
*
[2228] Fix | Delete
* @since 3.0.0
[2229] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
[2230] Fix | Delete
* by adding it to the function signature.
[2231] Fix | Delete
*
[2232] Fix | Delete
* @global array $_wp_post_type_features
[2233] Fix | Delete
*
[2234] Fix | Delete
* @param string $post_type The post type for which to add the feature.
[2235] Fix | Delete
* @param string|array $feature The feature being added, accepts an array of
[2236] Fix | Delete
* feature strings or a single string.
[2237] Fix | Delete
* @param mixed ...$args Optional extra arguments to pass along with certain features.
[2238] Fix | Delete
*/
[2239] Fix | Delete
function add_post_type_support( $post_type, $feature, ...$args ) {
[2240] Fix | Delete
global $_wp_post_type_features;
[2241] Fix | Delete
[2242] Fix | Delete
$features = (array) $feature;
[2243] Fix | Delete
foreach ( $features as $feature ) {
[2244] Fix | Delete
if ( $args ) {
[2245] Fix | Delete
$_wp_post_type_features[ $post_type ][ $feature ] = $args;
[2246] Fix | Delete
} else {
[2247] Fix | Delete
$_wp_post_type_features[ $post_type ][ $feature ] = true;
[2248] Fix | Delete
}
[2249] Fix | Delete
}
[2250] Fix | Delete
}
[2251] Fix | Delete
[2252] Fix | Delete
/**
[2253] Fix | Delete
* Removes support for a feature from a post type.
[2254] Fix | Delete
*
[2255] Fix | Delete
* @since 3.0.0
[2256] Fix | Delete
*
[2257] Fix | Delete
* @global array $_wp_post_type_features
[2258] Fix | Delete
*
[2259] Fix | Delete
* @param string $post_type The post type for which to remove the feature.
[2260] Fix | Delete
* @param string $feature The feature being removed.
[2261] Fix | Delete
*/
[2262] Fix | Delete
function remove_post_type_support( $post_type, $feature ) {
[2263] Fix | Delete
global $_wp_post_type_features;
[2264] Fix | Delete
[2265] Fix | Delete
unset( $_wp_post_type_features[ $post_type ][ $feature ] );
[2266] Fix | Delete
}
[2267] Fix | Delete
[2268] Fix | Delete
/**
[2269] Fix | Delete
* Gets all the post type features
[2270] Fix | Delete
*
[2271] Fix | Delete
* @since 3.4.0
[2272] Fix | Delete
*
[2273] Fix | Delete
* @global array $_wp_post_type_features
[2274] Fix | Delete
*
[2275] Fix | Delete
* @param string $post_type The post type.
[2276] Fix | Delete
* @return array Post type supports list.
[2277] Fix | Delete
*/
[2278] Fix | Delete
function get_all_post_type_supports( $post_type ) {
[2279] Fix | Delete
global $_wp_post_type_features;
[2280] Fix | Delete
[2281] Fix | Delete
if ( isset( $_wp_post_type_features[ $post_type ] ) ) {
[2282] Fix | Delete
return $_wp_post_type_features[ $post_type ];
[2283] Fix | Delete
}
[2284] Fix | Delete
[2285] Fix | Delete
return array();
[2286] Fix | Delete
}
[2287] Fix | Delete
[2288] Fix | Delete
/**
[2289] Fix | Delete
* Checks a post type's support for a given feature.
[2290] Fix | Delete
*
[2291] Fix | Delete
* @since 3.0.0
[2292] Fix | Delete
*
[2293] Fix | Delete
* @global array $_wp_post_type_features
[2294] Fix | Delete
*
[2295] Fix | Delete
* @param string $post_type The post type being checked.
[2296] Fix | Delete
* @param string $feature The feature being checked.
[2297] Fix | Delete
* @return bool Whether the post type supports the given feature.
[2298] Fix | Delete
*/
[2299] Fix | Delete
function post_type_supports( $post_type, $feature ) {
[2300] Fix | Delete
global $_wp_post_type_features;
[2301] Fix | Delete
[2302] Fix | Delete
return ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) );
[2303] Fix | Delete
}
[2304] Fix | Delete
[2305] Fix | Delete
/**
[2306] Fix | Delete
* Retrieves a list of post type names that support a specific feature.
[2307] Fix | Delete
*
[2308] Fix | Delete
* @since 4.5.0
[2309] Fix | Delete
*
[2310] Fix | Delete
* @global array $_wp_post_type_features Post type features
[2311] Fix | Delete
*
[2312] Fix | Delete
* @param array|string $feature Single feature or an array of features the post types should support.
[2313] Fix | Delete
* @param string $operator Optional. The logical operation to perform. 'or' means
[2314] Fix | Delete
* only one element from the array needs to match; 'and'
[2315] Fix | Delete
* means all elements must match; 'not' means no elements may
[2316] Fix | Delete
* match. Default 'and'.
[2317] Fix | Delete
* @return string[] A list of post type names.
[2318] Fix | Delete
*/
[2319] Fix | Delete
function get_post_types_by_support( $feature, $operator = 'and' ) {
[2320] Fix | Delete
global $_wp_post_type_features;
[2321] Fix | Delete
[2322] Fix | Delete
$features = array_fill_keys( (array) $feature, true );
[2323] Fix | Delete
[2324] Fix | Delete
return array_keys( wp_filter_object_list( $_wp_post_type_features, $features, $operator ) );
[2325] Fix | Delete
}
[2326] Fix | Delete
[2327] Fix | Delete
/**
[2328] Fix | Delete
* Updates the post type for the post ID.
[2329] Fix | Delete
*
[2330] Fix | Delete
* The page or post cache will be cleaned for the post ID.
[2331] Fix | Delete
*
[2332] Fix | Delete
* @since 2.5.0
[2333] Fix | Delete
*
[2334] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2335] Fix | Delete
*
[2336] Fix | Delete
* @param int $post_id Optional. Post ID to change post type. Default 0.
[2337] Fix | Delete
* @param string $post_type Optional. Post type. Accepts 'post' or 'page' to
[2338] Fix | Delete
* name a few. Default 'post'.
[2339] Fix | Delete
* @return int|false Amount of rows changed. Should be 1 for success and 0 for failure.
[2340] Fix | Delete
*/
[2341] Fix | Delete
function set_post_type( $post_id = 0, $post_type = 'post' ) {
[2342] Fix | Delete
global $wpdb;
[2343] Fix | Delete
[2344] Fix | Delete
$post_type = sanitize_post_field( 'post_type', $post_type, $post_id, 'db' );
[2345] Fix | Delete
$return = $wpdb->update( $wpdb->posts, array( 'post_type' => $post_type ), array( 'ID' => $post_id ) );
[2346] Fix | Delete
[2347] Fix | Delete
clean_post_cache( $post_id );
[2348] Fix | Delete
[2349] Fix | Delete
return $return;
[2350] Fix | Delete
}
[2351] Fix | Delete
[2352] Fix | Delete
/**
[2353] Fix | Delete
* Determines whether a post type is considered "viewable".
[2354] Fix | Delete
*
[2355] Fix | Delete
* For built-in post types such as posts and pages, the 'public' value will be evaluated.
[2356] Fix | Delete
* For all others, the 'publicly_queryable' value will be used.
[2357] Fix | Delete
*
[2358] Fix | Delete
* @since 4.4.0
[2359] Fix | Delete
* @since 4.5.0 Added the ability to pass a post type name in addition to object.
[2360] Fix | Delete
* @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object.
[2361] Fix | Delete
* @since 5.9.0 Added `is_post_type_viewable` hook to filter the result.
[2362] Fix | Delete
*
[2363] Fix | Delete
* @param string|WP_Post_Type $post_type Post type name or object.
[2364] Fix | Delete
* @return bool Whether the post type should be considered viewable.
[2365] Fix | Delete
*/
[2366] Fix | Delete
function is_post_type_viewable( $post_type ) {
[2367] Fix | Delete
if ( is_scalar( $post_type ) ) {
[2368] Fix | Delete
$post_type = get_post_type_object( $post_type );
[2369] Fix | Delete
[2370] Fix | Delete
if ( ! $post_type ) {
[2371] Fix | Delete
return false;
[2372] Fix | Delete
}
[2373] Fix | Delete
}
[2374] Fix | Delete
[2375] Fix | Delete
if ( ! is_object( $post_type ) ) {
[2376] Fix | Delete
return false;
[2377] Fix | Delete
}
[2378] Fix | Delete
[2379] Fix | Delete
$is_viewable = $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public );
[2380] Fix | Delete
[2381] Fix | Delete
/**
[2382] Fix | Delete
* Filters whether a post type is considered "viewable".
[2383] Fix | Delete
*
[2384] Fix | Delete
* The returned filtered value must be a boolean type to ensure
[2385] Fix | Delete
* `is_post_type_viewable()` only returns a boolean. This strictness
[2386] Fix | Delete
* is by design to maintain backwards-compatibility and guard against
[2387] Fix | Delete
* potential type errors in PHP 8.1+. Non-boolean values (even falsey
[2388] Fix | Delete
* and truthy values) will result in the function returning false.
[2389] Fix | Delete
*
[2390] Fix | Delete
* @since 5.9.0
[2391] Fix | Delete
*
[2392] Fix | Delete
* @param bool $is_viewable Whether the post type is "viewable" (strict type).
[2393] Fix | Delete
* @param WP_Post_Type $post_type Post type object.
[2394] Fix | Delete
*/
[2395] Fix | Delete
return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type );
[2396] Fix | Delete
}
[2397] Fix | Delete
[2398] Fix | Delete
/**
[2399] Fix | Delete
* Determines whether a post status is considered "viewable".
[2400] Fix | Delete
*
[2401] Fix | Delete
* For built-in post statuses such as publish and private, the 'public' value will be evaluated.
[2402] Fix | Delete
* For all others, the 'publicly_queryable' value will be used.
[2403] Fix | Delete
*
[2404] Fix | Delete
* @since 5.7.0
[2405] Fix | Delete
* @since 5.9.0 Added `is_post_status_viewable` hook to filter the result.
[2406] Fix | Delete
*
[2407] Fix | Delete
* @param string|stdClass $post_status Post status name or object.
[2408] Fix | Delete
* @return bool Whether the post status should be considered viewable.
[2409] Fix | Delete
*/
[2410] Fix | Delete
function is_post_status_viewable( $post_status ) {
[2411] Fix | Delete
if ( is_scalar( $post_status ) ) {
[2412] Fix | Delete
$post_status = get_post_status_object( $post_status );
[2413] Fix | Delete
[2414] Fix | Delete
if ( ! $post_status ) {
[2415] Fix | Delete
return false;
[2416] Fix | Delete
}
[2417] Fix | Delete
}
[2418] Fix | Delete
[2419] Fix | Delete
if (
[2420] Fix | Delete
! is_object( $post_status ) ||
[2421] Fix | Delete
$post_status->internal ||
[2422] Fix | Delete
$post_status->protected
[2423] Fix | Delete
) {
[2424] Fix | Delete
return false;
[2425] Fix | Delete
}
[2426] Fix | Delete
[2427] Fix | Delete
$is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );
[2428] Fix | Delete
[2429] Fix | Delete
/**
[2430] Fix | Delete
* Filters whether a post status is considered "viewable".
[2431] Fix | Delete
*
[2432] Fix | Delete
* The returned filtered value must be a boolean type to ensure
[2433] Fix | Delete
* `is_post_status_viewable()` only returns a boolean. This strictness
[2434] Fix | Delete
* is by design to maintain backwards-compatibility and guard against
[2435] Fix | Delete
* potential type errors in PHP 8.1+. Non-boolean values (even falsey
[2436] Fix | Delete
* and truthy values) will result in the function returning false.
[2437] Fix | Delete
*
[2438] Fix | Delete
* @since 5.9.0
[2439] Fix | Delete
*
[2440] Fix | Delete
* @param bool $is_viewable Whether the post status is "viewable" (strict type).
[2441] Fix | Delete
* @param stdClass $post_status Post status object.
[2442] Fix | Delete
*/
[2443] Fix | Delete
return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
[2444] Fix | Delete
}
[2445] Fix | Delete
[2446] Fix | Delete
/**
[2447] Fix | Delete
* Determines whether a post is publicly viewable.
[2448] Fix | Delete
*
[2449] Fix | Delete
* Posts are considered publicly viewable if both the post status and post type
[2450] Fix | Delete
* are viewable.
[2451] Fix | Delete
*
[2452] Fix | Delete
* @since 5.7.0
[2453] Fix | Delete
*
[2454] Fix | Delete
* @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
[2455] Fix | Delete
* @return bool Whether the post is publicly viewable.
[2456] Fix | Delete
*/
[2457] Fix | Delete
function is_post_publicly_viewable( $post = null ) {
[2458] Fix | Delete
$post = get_post( $post );
[2459] Fix | Delete
[2460] Fix | Delete
if ( ! $post ) {
[2461] Fix | Delete
return false;
[2462] Fix | Delete
}
[2463] Fix | Delete
[2464] Fix | Delete
$post_type = get_post_type( $post );
[2465] Fix | Delete
$post_status = get_post_status( $post );
[2466] Fix | Delete
[2467] Fix | Delete
return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status );
[2468] Fix | Delete
}
[2469] Fix | Delete
[2470] Fix | Delete
/**
[2471] Fix | Delete
* Retrieves an array of the latest posts, or posts matching the given criteria.
[2472] Fix | Delete
*
[2473] Fix | Delete
* For more information on the accepted arguments, see the
[2474] Fix | Delete
* {@link https://developer.wordpress.org/reference/classes/wp_query/
[2475] Fix | Delete
* WP_Query} documentation in the Developer Handbook.
[2476] Fix | Delete
*
[2477] Fix | Delete
* The `$ignore_sticky_posts` and `$no_found_rows` arguments are ignored by
[2478] Fix | Delete
* this function and both are set to `true`.
[2479] Fix | Delete
*
[2480] Fix | Delete
* The defaults are as follows:
[2481] Fix | Delete
*
[2482] Fix | Delete
* @since 1.2.0
[2483] Fix | Delete
*
[2484] Fix | Delete
* @see WP_Query
[2485] Fix | Delete
* @see WP_Query::parse_query()
[2486] Fix | Delete
*
[2487] Fix | Delete
* @param array $args {
[2488] Fix | Delete
* Optional. Arguments to retrieve posts. See WP_Query::parse_query() for all available arguments.
[2489] Fix | Delete
*
[2490] Fix | Delete
* @type int $numberposts Total number of posts to retrieve. Is an alias of `$posts_per_page`
[2491] Fix | Delete
* in WP_Query. Accepts -1 for all. Default 5.
[2492] Fix | Delete
* @type int|string $category Category ID or comma-separated list of IDs (this or any children).
[2493] Fix | Delete
* Is an alias of `$cat` in WP_Query. Default 0.
[2494] Fix | Delete
* @type int[] $include An array of post IDs to retrieve, sticky posts will be included.
[2495] Fix | Delete
* Is an alias of `$post__in` in WP_Query. Default empty array.
[2496] Fix | Delete
* @type int[] $exclude An array of post IDs not to retrieve. Default empty array.
[2497] Fix | Delete
* @type bool $suppress_filters Whether to suppress filters. Default true.
[2498] Fix | Delete
* }
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function