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/clone/wp-inclu...
File: post.php
}
[7000] Fix | Delete
}
[7001] Fix | Delete
[7002] Fix | Delete
/**
[7003] Fix | Delete
* Filters the mime type icon.
[7004] Fix | Delete
*
[7005] Fix | Delete
* @since 2.1.0
[7006] Fix | Delete
*
[7007] Fix | Delete
* @param string $icon Path to the mime type icon.
[7008] Fix | Delete
* @param string $mime Mime type.
[7009] Fix | Delete
* @param int $post_id Attachment ID. Will equal 0 if the function passed
[7010] Fix | Delete
* the mime type.
[7011] Fix | Delete
*/
[7012] Fix | Delete
return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id );
[7013] Fix | Delete
}
[7014] Fix | Delete
[7015] Fix | Delete
/**
[7016] Fix | Delete
* Checks for changed slugs for published post objects and save the old slug.
[7017] Fix | Delete
*
[7018] Fix | Delete
* The function is used when a post object of any type is updated,
[7019] Fix | Delete
* by comparing the current and previous post objects.
[7020] Fix | Delete
*
[7021] Fix | Delete
* If the slug was changed and not already part of the old slugs then it will be
[7022] Fix | Delete
* added to the post meta field ('_wp_old_slug') for storing old slugs for that
[7023] Fix | Delete
* post.
[7024] Fix | Delete
*
[7025] Fix | Delete
* The most logically usage of this function is redirecting changed post objects, so
[7026] Fix | Delete
* that those that linked to an changed post will be redirected to the new post.
[7027] Fix | Delete
*
[7028] Fix | Delete
* @since 2.1.0
[7029] Fix | Delete
*
[7030] Fix | Delete
* @param int $post_id Post ID.
[7031] Fix | Delete
* @param WP_Post $post The post object.
[7032] Fix | Delete
* @param WP_Post $post_before The previous post object.
[7033] Fix | Delete
*/
[7034] Fix | Delete
function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
[7035] Fix | Delete
// Don't bother if it hasn't changed.
[7036] Fix | Delete
if ( $post->post_name == $post_before->post_name ) {
[7037] Fix | Delete
return;
[7038] Fix | Delete
}
[7039] Fix | Delete
[7040] Fix | Delete
// We're only concerned with published, non-hierarchical objects.
[7041] Fix | Delete
if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
[7042] Fix | Delete
return;
[7043] Fix | Delete
}
[7044] Fix | Delete
[7045] Fix | Delete
$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
[7046] Fix | Delete
[7047] Fix | Delete
// If we haven't added this old slug before, add it now.
[7048] Fix | Delete
if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs, true ) ) {
[7049] Fix | Delete
add_post_meta( $post_id, '_wp_old_slug', $post_before->post_name );
[7050] Fix | Delete
}
[7051] Fix | Delete
[7052] Fix | Delete
// If the new slug was used previously, delete it from the list.
[7053] Fix | Delete
if ( in_array( $post->post_name, $old_slugs, true ) ) {
[7054] Fix | Delete
delete_post_meta( $post_id, '_wp_old_slug', $post->post_name );
[7055] Fix | Delete
}
[7056] Fix | Delete
}
[7057] Fix | Delete
[7058] Fix | Delete
/**
[7059] Fix | Delete
* Checks for changed dates for published post objects and save the old date.
[7060] Fix | Delete
*
[7061] Fix | Delete
* The function is used when a post object of any type is updated,
[7062] Fix | Delete
* by comparing the current and previous post objects.
[7063] Fix | Delete
*
[7064] Fix | Delete
* If the date was changed and not already part of the old dates then it will be
[7065] Fix | Delete
* added to the post meta field ('_wp_old_date') for storing old dates for that
[7066] Fix | Delete
* post.
[7067] Fix | Delete
*
[7068] Fix | Delete
* The most logically usage of this function is redirecting changed post objects, so
[7069] Fix | Delete
* that those that linked to an changed post will be redirected to the new post.
[7070] Fix | Delete
*
[7071] Fix | Delete
* @since 4.9.3
[7072] Fix | Delete
*
[7073] Fix | Delete
* @param int $post_id Post ID.
[7074] Fix | Delete
* @param WP_Post $post The post object.
[7075] Fix | Delete
* @param WP_Post $post_before The previous post object.
[7076] Fix | Delete
*/
[7077] Fix | Delete
function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
[7078] Fix | Delete
$previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
[7079] Fix | Delete
$new_date = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
[7080] Fix | Delete
[7081] Fix | Delete
// Don't bother if it hasn't changed.
[7082] Fix | Delete
if ( $new_date == $previous_date ) {
[7083] Fix | Delete
return;
[7084] Fix | Delete
}
[7085] Fix | Delete
[7086] Fix | Delete
// We're only concerned with published, non-hierarchical objects.
[7087] Fix | Delete
if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
[7088] Fix | Delete
return;
[7089] Fix | Delete
}
[7090] Fix | Delete
[7091] Fix | Delete
$old_dates = (array) get_post_meta( $post_id, '_wp_old_date' );
[7092] Fix | Delete
[7093] Fix | Delete
// If we haven't added this old date before, add it now.
[7094] Fix | Delete
if ( ! empty( $previous_date ) && ! in_array( $previous_date, $old_dates, true ) ) {
[7095] Fix | Delete
add_post_meta( $post_id, '_wp_old_date', $previous_date );
[7096] Fix | Delete
}
[7097] Fix | Delete
[7098] Fix | Delete
// If the new slug was used previously, delete it from the list.
[7099] Fix | Delete
if ( in_array( $new_date, $old_dates, true ) ) {
[7100] Fix | Delete
delete_post_meta( $post_id, '_wp_old_date', $new_date );
[7101] Fix | Delete
}
[7102] Fix | Delete
}
[7103] Fix | Delete
[7104] Fix | Delete
/**
[7105] Fix | Delete
* Retrieves the private post SQL based on capability.
[7106] Fix | Delete
*
[7107] Fix | Delete
* This function provides a standardized way to appropriately select on the
[7108] Fix | Delete
* post_status of a post type. The function will return a piece of SQL code
[7109] Fix | Delete
* that can be added to a WHERE clause; this SQL is constructed to allow all
[7110] Fix | Delete
* published posts, and all private posts to which the user has access.
[7111] Fix | Delete
*
[7112] Fix | Delete
* @since 2.2.0
[7113] Fix | Delete
* @since 4.3.0 Added the ability to pass an array to `$post_type`.
[7114] Fix | Delete
*
[7115] Fix | Delete
* @param string|array $post_type Single post type or an array of post types. Currently only supports 'post' or 'page'.
[7116] Fix | Delete
* @return string SQL code that can be added to a where clause.
[7117] Fix | Delete
*/
[7118] Fix | Delete
function get_private_posts_cap_sql( $post_type ) {
[7119] Fix | Delete
return get_posts_by_author_sql( $post_type, false );
[7120] Fix | Delete
}
[7121] Fix | Delete
[7122] Fix | Delete
/**
[7123] Fix | Delete
* Retrieves the post SQL based on capability, author, and type.
[7124] Fix | Delete
*
[7125] Fix | Delete
* @since 3.0.0
[7126] Fix | Delete
* @since 4.3.0 Introduced the ability to pass an array of post types to `$post_type`.
[7127] Fix | Delete
*
[7128] Fix | Delete
* @see get_private_posts_cap_sql()
[7129] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[7130] Fix | Delete
*
[7131] Fix | Delete
* @param string|string[] $post_type Single post type or an array of post types.
[7132] Fix | Delete
* @param bool $full Optional. Returns a full WHERE statement instead of just
[7133] Fix | Delete
* an 'andalso' term. Default true.
[7134] Fix | Delete
* @param int $post_author Optional. Query posts having a single author ID. Default null.
[7135] Fix | Delete
* @param bool $public_only Optional. Only return public posts. Skips cap checks for
[7136] Fix | Delete
* $current_user. Default false.
[7137] Fix | Delete
* @return string SQL WHERE code that can be added to a query.
[7138] Fix | Delete
*/
[7139] Fix | Delete
function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
[7140] Fix | Delete
global $wpdb;
[7141] Fix | Delete
[7142] Fix | Delete
if ( is_array( $post_type ) ) {
[7143] Fix | Delete
$post_types = $post_type;
[7144] Fix | Delete
} else {
[7145] Fix | Delete
$post_types = array( $post_type );
[7146] Fix | Delete
}
[7147] Fix | Delete
[7148] Fix | Delete
$post_type_clauses = array();
[7149] Fix | Delete
foreach ( $post_types as $post_type ) {
[7150] Fix | Delete
$post_type_obj = get_post_type_object( $post_type );
[7151] Fix | Delete
[7152] Fix | Delete
if ( ! $post_type_obj ) {
[7153] Fix | Delete
continue;
[7154] Fix | Delete
}
[7155] Fix | Delete
[7156] Fix | Delete
/**
[7157] Fix | Delete
* Filters the capability to read private posts for a custom post type
[7158] Fix | Delete
* when generating SQL for getting posts by author.
[7159] Fix | Delete
*
[7160] Fix | Delete
* @since 2.2.0
[7161] Fix | Delete
* @deprecated 3.2.0 The hook transitioned from "somewhat useless" to "totally useless".
[7162] Fix | Delete
*
[7163] Fix | Delete
* @param string $cap Capability.
[7164] Fix | Delete
*/
[7165] Fix | Delete
$cap = apply_filters_deprecated( 'pub_priv_sql_capability', array( '' ), '3.2.0' );
[7166] Fix | Delete
[7167] Fix | Delete
if ( ! $cap ) {
[7168] Fix | Delete
$cap = current_user_can( $post_type_obj->cap->read_private_posts );
[7169] Fix | Delete
}
[7170] Fix | Delete
[7171] Fix | Delete
// Only need to check the cap if $public_only is false.
[7172] Fix | Delete
$post_status_sql = "post_status = 'publish'";
[7173] Fix | Delete
[7174] Fix | Delete
if ( false === $public_only ) {
[7175] Fix | Delete
if ( $cap ) {
[7176] Fix | Delete
// Does the user have the capability to view private posts? Guess so.
[7177] Fix | Delete
$post_status_sql .= " OR post_status = 'private'";
[7178] Fix | Delete
} elseif ( is_user_logged_in() ) {
[7179] Fix | Delete
// Users can view their own private posts.
[7180] Fix | Delete
$id = get_current_user_id();
[7181] Fix | Delete
if ( null === $post_author || ! $full ) {
[7182] Fix | Delete
$post_status_sql .= " OR post_status = 'private' AND post_author = $id";
[7183] Fix | Delete
} elseif ( $id == (int) $post_author ) {
[7184] Fix | Delete
$post_status_sql .= " OR post_status = 'private'";
[7185] Fix | Delete
} // Else none.
[7186] Fix | Delete
} // Else none.
[7187] Fix | Delete
}
[7188] Fix | Delete
[7189] Fix | Delete
$post_type_clauses[] = "( post_type = '" . $post_type . "' AND ( $post_status_sql ) )";
[7190] Fix | Delete
}
[7191] Fix | Delete
[7192] Fix | Delete
if ( empty( $post_type_clauses ) ) {
[7193] Fix | Delete
return $full ? 'WHERE 1 = 0' : '1 = 0';
[7194] Fix | Delete
}
[7195] Fix | Delete
[7196] Fix | Delete
$sql = '( ' . implode( ' OR ', $post_type_clauses ) . ' )';
[7197] Fix | Delete
[7198] Fix | Delete
if ( null !== $post_author ) {
[7199] Fix | Delete
$sql .= $wpdb->prepare( ' AND post_author = %d', $post_author );
[7200] Fix | Delete
}
[7201] Fix | Delete
[7202] Fix | Delete
if ( $full ) {
[7203] Fix | Delete
$sql = 'WHERE ' . $sql;
[7204] Fix | Delete
}
[7205] Fix | Delete
[7206] Fix | Delete
return $sql;
[7207] Fix | Delete
}
[7208] Fix | Delete
[7209] Fix | Delete
/**
[7210] Fix | Delete
* Retrieves the most recent time that a post on the site was published.
[7211] Fix | Delete
*
[7212] Fix | Delete
* The server timezone is the default and is the difference between GMT and
[7213] Fix | Delete
* server time. The 'blog' value is the date when the last post was posted.
[7214] Fix | Delete
* The 'gmt' is when the last post was posted in GMT formatted date.
[7215] Fix | Delete
*
[7216] Fix | Delete
* @since 0.71
[7217] Fix | Delete
* @since 4.4.0 The `$post_type` argument was added.
[7218] Fix | Delete
*
[7219] Fix | Delete
* @param string $timezone Optional. The timezone for the timestamp. Accepts 'server', 'blog', or 'gmt'.
[7220] Fix | Delete
* 'server' uses the server's internal timezone.
[7221] Fix | Delete
* 'blog' uses the `post_date` field, which proxies to the timezone set for the site.
[7222] Fix | Delete
* 'gmt' uses the `post_date_gmt` field.
[7223] Fix | Delete
* Default 'server'.
[7224] Fix | Delete
* @param string $post_type Optional. The post type to check. Default 'any'.
[7225] Fix | Delete
* @return string The date of the last post, or false on failure.
[7226] Fix | Delete
*/
[7227] Fix | Delete
function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) {
[7228] Fix | Delete
$lastpostdate = _get_last_post_time( $timezone, 'date', $post_type );
[7229] Fix | Delete
[7230] Fix | Delete
/**
[7231] Fix | Delete
* Filters the most recent time that a post on the site was published.
[7232] Fix | Delete
*
[7233] Fix | Delete
* @since 2.3.0
[7234] Fix | Delete
* @since 5.5.0 Added the `$post_type` parameter.
[7235] Fix | Delete
*
[7236] Fix | Delete
* @param string|false $lastpostdate The most recent time that a post was published,
[7237] Fix | Delete
* in 'Y-m-d H:i:s' format. False on failure.
[7238] Fix | Delete
* @param string $timezone Location to use for getting the post published date.
[7239] Fix | Delete
* See get_lastpostdate() for accepted `$timezone` values.
[7240] Fix | Delete
* @param string $post_type The post type to check.
[7241] Fix | Delete
*/
[7242] Fix | Delete
return apply_filters( 'get_lastpostdate', $lastpostdate, $timezone, $post_type );
[7243] Fix | Delete
}
[7244] Fix | Delete
[7245] Fix | Delete
/**
[7246] Fix | Delete
* Gets the most recent time that a post on the site was modified.
[7247] Fix | Delete
*
[7248] Fix | Delete
* The server timezone is the default and is the difference between GMT and
[7249] Fix | Delete
* server time. The 'blog' value is just when the last post was modified.
[7250] Fix | Delete
* The 'gmt' is when the last post was modified in GMT time.
[7251] Fix | Delete
*
[7252] Fix | Delete
* @since 1.2.0
[7253] Fix | Delete
* @since 4.4.0 The `$post_type` argument was added.
[7254] Fix | Delete
*
[7255] Fix | Delete
* @param string $timezone Optional. The timezone for the timestamp. See get_lastpostdate()
[7256] Fix | Delete
* for information on accepted values.
[7257] Fix | Delete
* Default 'server'.
[7258] Fix | Delete
* @param string $post_type Optional. The post type to check. Default 'any'.
[7259] Fix | Delete
* @return string The timestamp in 'Y-m-d H:i:s' format, or false on failure.
[7260] Fix | Delete
*/
[7261] Fix | Delete
function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
[7262] Fix | Delete
/**
[7263] Fix | Delete
* Pre-filter the return value of get_lastpostmodified() before the query is run.
[7264] Fix | Delete
*
[7265] Fix | Delete
* @since 4.4.0
[7266] Fix | Delete
*
[7267] Fix | Delete
* @param string|false $lastpostmodified The most recent time that a post was modified,
[7268] Fix | Delete
* in 'Y-m-d H:i:s' format, or false. Returning anything
[7269] Fix | Delete
* other than false will short-circuit the function.
[7270] Fix | Delete
* @param string $timezone Location to use for getting the post modified date.
[7271] Fix | Delete
* See get_lastpostdate() for accepted `$timezone` values.
[7272] Fix | Delete
* @param string $post_type The post type to check.
[7273] Fix | Delete
*/
[7274] Fix | Delete
$lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type );
[7275] Fix | Delete
[7276] Fix | Delete
if ( false !== $lastpostmodified ) {
[7277] Fix | Delete
return $lastpostmodified;
[7278] Fix | Delete
}
[7279] Fix | Delete
[7280] Fix | Delete
$lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );
[7281] Fix | Delete
$lastpostdate = get_lastpostdate( $timezone, $post_type );
[7282] Fix | Delete
[7283] Fix | Delete
if ( $lastpostdate > $lastpostmodified ) {
[7284] Fix | Delete
$lastpostmodified = $lastpostdate;
[7285] Fix | Delete
}
[7286] Fix | Delete
[7287] Fix | Delete
/**
[7288] Fix | Delete
* Filters the most recent time that a post on the site was modified.
[7289] Fix | Delete
*
[7290] Fix | Delete
* @since 2.3.0
[7291] Fix | Delete
* @since 5.5.0 Added the `$post_type` parameter.
[7292] Fix | Delete
*
[7293] Fix | Delete
* @param string|false $lastpostmodified The most recent time that a post was modified,
[7294] Fix | Delete
* in 'Y-m-d H:i:s' format. False on failure.
[7295] Fix | Delete
* @param string $timezone Location to use for getting the post modified date.
[7296] Fix | Delete
* See get_lastpostdate() for accepted `$timezone` values.
[7297] Fix | Delete
* @param string $post_type The post type to check.
[7298] Fix | Delete
*/
[7299] Fix | Delete
return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone, $post_type );
[7300] Fix | Delete
}
[7301] Fix | Delete
[7302] Fix | Delete
/**
[7303] Fix | Delete
* Gets the timestamp of the last time any post was modified or published.
[7304] Fix | Delete
*
[7305] Fix | Delete
* @since 3.1.0
[7306] Fix | Delete
* @since 4.4.0 The `$post_type` argument was added.
[7307] Fix | Delete
* @access private
[7308] Fix | Delete
*
[7309] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[7310] Fix | Delete
*
[7311] Fix | Delete
* @param string $timezone The timezone for the timestamp. See get_lastpostdate().
[7312] Fix | Delete
* for information on accepted values.
[7313] Fix | Delete
* @param string $field Post field to check. Accepts 'date' or 'modified'.
[7314] Fix | Delete
* @param string $post_type Optional. The post type to check. Default 'any'.
[7315] Fix | Delete
* @return string|false The timestamp in 'Y-m-d H:i:s' format, or false on failure.
[7316] Fix | Delete
*/
[7317] Fix | Delete
function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
[7318] Fix | Delete
global $wpdb;
[7319] Fix | Delete
[7320] Fix | Delete
if ( ! in_array( $field, array( 'date', 'modified' ), true ) ) {
[7321] Fix | Delete
return false;
[7322] Fix | Delete
}
[7323] Fix | Delete
[7324] Fix | Delete
$timezone = strtolower( $timezone );
[7325] Fix | Delete
[7326] Fix | Delete
$key = "lastpost{$field}:$timezone";
[7327] Fix | Delete
if ( 'any' !== $post_type ) {
[7328] Fix | Delete
$key .= ':' . sanitize_key( $post_type );
[7329] Fix | Delete
}
[7330] Fix | Delete
[7331] Fix | Delete
$date = wp_cache_get( $key, 'timeinfo' );
[7332] Fix | Delete
if ( false !== $date ) {
[7333] Fix | Delete
return $date;
[7334] Fix | Delete
}
[7335] Fix | Delete
[7336] Fix | Delete
if ( 'any' === $post_type ) {
[7337] Fix | Delete
$post_types = get_post_types( array( 'public' => true ) );
[7338] Fix | Delete
array_walk( $post_types, array( $wpdb, 'escape_by_ref' ) );
[7339] Fix | Delete
$post_types = "'" . implode( "', '", $post_types ) . "'";
[7340] Fix | Delete
} else {
[7341] Fix | Delete
$post_types = "'" . sanitize_key( $post_type ) . "'";
[7342] Fix | Delete
}
[7343] Fix | Delete
[7344] Fix | Delete
switch ( $timezone ) {
[7345] Fix | Delete
case 'gmt':
[7346] Fix | Delete
$date = $wpdb->get_var( "SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" );
[7347] Fix | Delete
break;
[7348] Fix | Delete
case 'blog':
[7349] Fix | Delete
$date = $wpdb->get_var( "SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" );
[7350] Fix | Delete
break;
[7351] Fix | Delete
case 'server':
[7352] Fix | Delete
$add_seconds_server = gmdate( 'Z' );
[7353] Fix | Delete
$date = $wpdb->get_var( "SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1" );
[7354] Fix | Delete
break;
[7355] Fix | Delete
}
[7356] Fix | Delete
[7357] Fix | Delete
if ( $date ) {
[7358] Fix | Delete
wp_cache_set( $key, $date, 'timeinfo' );
[7359] Fix | Delete
[7360] Fix | Delete
return $date;
[7361] Fix | Delete
}
[7362] Fix | Delete
[7363] Fix | Delete
return false;
[7364] Fix | Delete
}
[7365] Fix | Delete
[7366] Fix | Delete
/**
[7367] Fix | Delete
* Updates posts in cache.
[7368] Fix | Delete
*
[7369] Fix | Delete
* @since 1.5.1
[7370] Fix | Delete
*
[7371] Fix | Delete
* @param WP_Post[] $posts Array of post objects (passed by reference).
[7372] Fix | Delete
*/
[7373] Fix | Delete
function update_post_cache( &$posts ) {
[7374] Fix | Delete
if ( ! $posts ) {
[7375] Fix | Delete
return;
[7376] Fix | Delete
}
[7377] Fix | Delete
[7378] Fix | Delete
$data = array();
[7379] Fix | Delete
foreach ( $posts as $post ) {
[7380] Fix | Delete
if ( empty( $post->filter ) || 'raw' !== $post->filter ) {
[7381] Fix | Delete
$post = sanitize_post( $post, 'raw' );
[7382] Fix | Delete
}
[7383] Fix | Delete
$data[ $post->ID ] = $post;
[7384] Fix | Delete
}
[7385] Fix | Delete
wp_cache_add_multiple( $data, 'posts' );
[7386] Fix | Delete
}
[7387] Fix | Delete
[7388] Fix | Delete
/**
[7389] Fix | Delete
* Will clean the post in the cache.
[7390] Fix | Delete
*
[7391] Fix | Delete
* Cleaning means delete from the cache of the post. Will call to clean the term
[7392] Fix | Delete
* object cache associated with the post ID.
[7393] Fix | Delete
*
[7394] Fix | Delete
* This function not run if $_wp_suspend_cache_invalidation is not empty. See
[7395] Fix | Delete
* wp_suspend_cache_invalidation().
[7396] Fix | Delete
*
[7397] Fix | Delete
* @since 2.0.0
[7398] Fix | Delete
*
[7399] Fix | Delete
* @global bool $_wp_suspend_cache_invalidation
[7400] Fix | Delete
*
[7401] Fix | Delete
* @param int|WP_Post $post Post ID or post object to remove from the cache.
[7402] Fix | Delete
*/
[7403] Fix | Delete
function clean_post_cache( $post ) {
[7404] Fix | Delete
global $_wp_suspend_cache_invalidation;
[7405] Fix | Delete
[7406] Fix | Delete
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
[7407] Fix | Delete
return;
[7408] Fix | Delete
}
[7409] Fix | Delete
[7410] Fix | Delete
$post = get_post( $post );
[7411] Fix | Delete
[7412] Fix | Delete
if ( ! $post ) {
[7413] Fix | Delete
return;
[7414] Fix | Delete
}
[7415] Fix | Delete
[7416] Fix | Delete
wp_cache_delete( $post->ID, 'posts' );
[7417] Fix | Delete
wp_cache_delete( 'post_parent:' . (string) $post->ID, 'posts' );
[7418] Fix | Delete
wp_cache_delete( $post->ID, 'post_meta' );
[7419] Fix | Delete
[7420] Fix | Delete
clean_object_term_cache( $post->ID, $post->post_type );
[7421] Fix | Delete
[7422] Fix | Delete
wp_cache_delete( 'wp_get_archives', 'general' );
[7423] Fix | Delete
[7424] Fix | Delete
/**
[7425] Fix | Delete
* Fires immediately after the given post's cache is cleaned.
[7426] Fix | Delete
*
[7427] Fix | Delete
* @since 2.5.0
[7428] Fix | Delete
*
[7429] Fix | Delete
* @param int $post_id Post ID.
[7430] Fix | Delete
* @param WP_Post $post Post object.
[7431] Fix | Delete
*/
[7432] Fix | Delete
do_action( 'clean_post_cache', $post->ID, $post );
[7433] Fix | Delete
[7434] Fix | Delete
if ( 'page' === $post->post_type ) {
[7435] Fix | Delete
wp_cache_delete( 'all_page_ids', 'posts' );
[7436] Fix | Delete
[7437] Fix | Delete
/**
[7438] Fix | Delete
* Fires immediately after the given page's cache is cleaned.
[7439] Fix | Delete
*
[7440] Fix | Delete
* @since 2.5.0
[7441] Fix | Delete
*
[7442] Fix | Delete
* @param int $post_id Post ID.
[7443] Fix | Delete
*/
[7444] Fix | Delete
do_action( 'clean_page_cache', $post->ID );
[7445] Fix | Delete
}
[7446] Fix | Delete
[7447] Fix | Delete
wp_cache_set_posts_last_changed();
[7448] Fix | Delete
}
[7449] Fix | Delete
[7450] Fix | Delete
/**
[7451] Fix | Delete
* Updates post, term, and metadata caches for a list of post objects.
[7452] Fix | Delete
*
[7453] Fix | Delete
* @since 1.5.0
[7454] Fix | Delete
*
[7455] Fix | Delete
* @param WP_Post[] $posts Array of post objects (passed by reference).
[7456] Fix | Delete
* @param string $post_type Optional. Post type. Default 'post'.
[7457] Fix | Delete
* @param bool $update_term_cache Optional. Whether to update the term cache. Default true.
[7458] Fix | Delete
* @param bool $update_meta_cache Optional. Whether to update the meta cache. Default true.
[7459] Fix | Delete
*/
[7460] Fix | Delete
function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) {
[7461] Fix | Delete
// No point in doing all this work if we didn't match any posts.
[7462] Fix | Delete
if ( ! $posts ) {
[7463] Fix | Delete
return;
[7464] Fix | Delete
}
[7465] Fix | Delete
[7466] Fix | Delete
update_post_cache( $posts );
[7467] Fix | Delete
[7468] Fix | Delete
$post_ids = array();
[7469] Fix | Delete
foreach ( $posts as $post ) {
[7470] Fix | Delete
$post_ids[] = $post->ID;
[7471] Fix | Delete
}
[7472] Fix | Delete
[7473] Fix | Delete
if ( ! $post_type ) {
[7474] Fix | Delete
$post_type = 'any';
[7475] Fix | Delete
}
[7476] Fix | Delete
[7477] Fix | Delete
if ( $update_term_cache ) {
[7478] Fix | Delete
if ( is_array( $post_type ) ) {
[7479] Fix | Delete
$ptypes = $post_type;
[7480] Fix | Delete
} elseif ( 'any' === $post_type ) {
[7481] Fix | Delete
$ptypes = array();
[7482] Fix | Delete
// Just use the post_types in the supplied posts.
[7483] Fix | Delete
foreach ( $posts as $post ) {
[7484] Fix | Delete
$ptypes[] = $post->post_type;
[7485] Fix | Delete
}
[7486] Fix | Delete
$ptypes = array_unique( $ptypes );
[7487] Fix | Delete
} else {
[7488] Fix | Delete
$ptypes = array( $post_type );
[7489] Fix | Delete
}
[7490] Fix | Delete
[7491] Fix | Delete
if ( ! empty( $ptypes ) ) {
[7492] Fix | Delete
update_object_term_cache( $post_ids, $ptypes );
[7493] Fix | Delete
}
[7494] Fix | Delete
}
[7495] Fix | Delete
[7496] Fix | Delete
if ( $update_meta_cache ) {
[7497] Fix | Delete
update_postmeta_cache( $post_ids );
[7498] Fix | Delete
}
[7499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function