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.../public_h.../wp-inclu...
File: class-wp-query.php
* @param string $groupby The GROUP BY clause of the query.
[3000] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3001] Fix | Delete
*/
[3002] Fix | Delete
$groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) );
[3003] Fix | Delete
[3004] Fix | Delete
/**
[3005] Fix | Delete
* Filters the JOIN clause of the query.
[3006] Fix | Delete
*
[3007] Fix | Delete
* For use by caching plugins.
[3008] Fix | Delete
*
[3009] Fix | Delete
* @since 2.5.0
[3010] Fix | Delete
*
[3011] Fix | Delete
* @param string $join The JOIN clause of the query.
[3012] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3013] Fix | Delete
*/
[3014] Fix | Delete
$join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) );
[3015] Fix | Delete
[3016] Fix | Delete
/**
[3017] Fix | Delete
* Filters the ORDER BY clause of the query.
[3018] Fix | Delete
*
[3019] Fix | Delete
* For use by caching plugins.
[3020] Fix | Delete
*
[3021] Fix | Delete
* @since 2.5.0
[3022] Fix | Delete
*
[3023] Fix | Delete
* @param string $orderby The ORDER BY clause of the query.
[3024] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3025] Fix | Delete
*/
[3026] Fix | Delete
$orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) );
[3027] Fix | Delete
[3028] Fix | Delete
/**
[3029] Fix | Delete
* Filters the DISTINCT clause of the query.
[3030] Fix | Delete
*
[3031] Fix | Delete
* For use by caching plugins.
[3032] Fix | Delete
*
[3033] Fix | Delete
* @since 2.5.0
[3034] Fix | Delete
*
[3035] Fix | Delete
* @param string $distinct The DISTINCT clause of the query.
[3036] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3037] Fix | Delete
*/
[3038] Fix | Delete
$distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) );
[3039] Fix | Delete
[3040] Fix | Delete
/**
[3041] Fix | Delete
* Filters the SELECT clause of the query.
[3042] Fix | Delete
*
[3043] Fix | Delete
* For use by caching plugins.
[3044] Fix | Delete
*
[3045] Fix | Delete
* @since 2.5.0
[3046] Fix | Delete
*
[3047] Fix | Delete
* @param string $fields The SELECT clause of the query.
[3048] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3049] Fix | Delete
*/
[3050] Fix | Delete
$fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) );
[3051] Fix | Delete
[3052] Fix | Delete
/**
[3053] Fix | Delete
* Filters the LIMIT clause of the query.
[3054] Fix | Delete
*
[3055] Fix | Delete
* For use by caching plugins.
[3056] Fix | Delete
*
[3057] Fix | Delete
* @since 2.5.0
[3058] Fix | Delete
*
[3059] Fix | Delete
* @param string $limits The LIMIT clause of the query.
[3060] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3061] Fix | Delete
*/
[3062] Fix | Delete
$limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) );
[3063] Fix | Delete
[3064] Fix | Delete
/**
[3065] Fix | Delete
* Filters all query clauses at once, for convenience.
[3066] Fix | Delete
*
[3067] Fix | Delete
* For use by caching plugins.
[3068] Fix | Delete
*
[3069] Fix | Delete
* Covers the WHERE, GROUP BY, JOIN, ORDER BY, DISTINCT,
[3070] Fix | Delete
* fields (SELECT), and LIMIT clauses.
[3071] Fix | Delete
*
[3072] Fix | Delete
* @since 3.1.0
[3073] Fix | Delete
*
[3074] Fix | Delete
* @param string[] $clauses {
[3075] Fix | Delete
* Associative array of the clauses for the query.
[3076] Fix | Delete
*
[3077] Fix | Delete
* @type string $where The WHERE clause of the query.
[3078] Fix | Delete
* @type string $groupby The GROUP BY clause of the query.
[3079] Fix | Delete
* @type string $join The JOIN clause of the query.
[3080] Fix | Delete
* @type string $orderby The ORDER BY clause of the query.
[3081] Fix | Delete
* @type string $distinct The DISTINCT clause of the query.
[3082] Fix | Delete
* @type string $fields The SELECT clause of the query.
[3083] Fix | Delete
* @type string $limits The LIMIT clause of the query.
[3084] Fix | Delete
* }
[3085] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3086] Fix | Delete
*/
[3087] Fix | Delete
$clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) );
[3088] Fix | Delete
[3089] Fix | Delete
$where = isset( $clauses['where'] ) ? $clauses['where'] : '';
[3090] Fix | Delete
$groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
[3091] Fix | Delete
$join = isset( $clauses['join'] ) ? $clauses['join'] : '';
[3092] Fix | Delete
$orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
[3093] Fix | Delete
$distinct = isset( $clauses['distinct'] ) ? $clauses['distinct'] : '';
[3094] Fix | Delete
$fields = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
[3095] Fix | Delete
$limits = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
[3096] Fix | Delete
}
[3097] Fix | Delete
[3098] Fix | Delete
if ( ! empty( $groupby ) ) {
[3099] Fix | Delete
$groupby = 'GROUP BY ' . $groupby;
[3100] Fix | Delete
}
[3101] Fix | Delete
if ( ! empty( $orderby ) ) {
[3102] Fix | Delete
$orderby = 'ORDER BY ' . $orderby;
[3103] Fix | Delete
}
[3104] Fix | Delete
[3105] Fix | Delete
$found_rows = '';
[3106] Fix | Delete
if ( ! $q['no_found_rows'] && ! empty( $limits ) ) {
[3107] Fix | Delete
$found_rows = 'SQL_CALC_FOUND_ROWS';
[3108] Fix | Delete
}
[3109] Fix | Delete
[3110] Fix | Delete
/*
[3111] Fix | Delete
* Beginning of the string is on a new line to prevent leading whitespace.
[3112] Fix | Delete
*
[3113] Fix | Delete
* The additional indentation of subsequent lines is to ensure the SQL
[3114] Fix | Delete
* queries are identical to those generated when splitting queries. This
[3115] Fix | Delete
* improves caching of the query by ensuring the same cache key is
[3116] Fix | Delete
* generated for the same database queries functionally.
[3117] Fix | Delete
*
[3118] Fix | Delete
* See https://core.trac.wordpress.org/ticket/56841.
[3119] Fix | Delete
* See https://github.com/WordPress/wordpress-develop/pull/6393#issuecomment-2088217429
[3120] Fix | Delete
*/
[3121] Fix | Delete
$old_request =
[3122] Fix | Delete
"SELECT $found_rows $distinct $fields
[3123] Fix | Delete
FROM {$wpdb->posts} $join
[3124] Fix | Delete
WHERE 1=1 $where
[3125] Fix | Delete
$groupby
[3126] Fix | Delete
$orderby
[3127] Fix | Delete
$limits";
[3128] Fix | Delete
[3129] Fix | Delete
$this->request = $old_request;
[3130] Fix | Delete
[3131] Fix | Delete
if ( ! $q['suppress_filters'] ) {
[3132] Fix | Delete
/**
[3133] Fix | Delete
* Filters the completed SQL query before sending.
[3134] Fix | Delete
*
[3135] Fix | Delete
* @since 2.0.0
[3136] Fix | Delete
*
[3137] Fix | Delete
* @param string $request The complete SQL query.
[3138] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3139] Fix | Delete
*/
[3140] Fix | Delete
$this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) );
[3141] Fix | Delete
}
[3142] Fix | Delete
[3143] Fix | Delete
/**
[3144] Fix | Delete
* Filters the posts array before the query takes place.
[3145] Fix | Delete
*
[3146] Fix | Delete
* Return a non-null value to bypass WordPress' default post queries.
[3147] Fix | Delete
*
[3148] Fix | Delete
* Filtering functions that require pagination information are encouraged to set
[3149] Fix | Delete
* the `found_posts` and `max_num_pages` properties of the WP_Query object,
[3150] Fix | Delete
* passed to the filter by reference. If WP_Query does not perform a database
[3151] Fix | Delete
* query, it will not have enough information to generate these values itself.
[3152] Fix | Delete
*
[3153] Fix | Delete
* @since 4.6.0
[3154] Fix | Delete
*
[3155] Fix | Delete
* @param WP_Post[]|int[]|null $posts Return an array of post data to short-circuit WP's query,
[3156] Fix | Delete
* or null to allow WP to run its normal queries.
[3157] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3158] Fix | Delete
*/
[3159] Fix | Delete
$this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) );
[3160] Fix | Delete
[3161] Fix | Delete
/*
[3162] Fix | Delete
* Ensure the ID database query is able to be cached.
[3163] Fix | Delete
*
[3164] Fix | Delete
* Random queries are expected to have unpredictable results and
[3165] Fix | Delete
* cannot be cached. Note the space before `RAND` in the string
[3166] Fix | Delete
* search, that to ensure against a collision with another
[3167] Fix | Delete
* function.
[3168] Fix | Delete
*
[3169] Fix | Delete
* If `$fields` has been modified by the `posts_fields`,
[3170] Fix | Delete
* `posts_fields_request`, `post_clauses` or `posts_clauses_request`
[3171] Fix | Delete
* filters, then caching is disabled to prevent caching collisions.
[3172] Fix | Delete
*/
[3173] Fix | Delete
$id_query_is_cacheable = ! str_contains( strtoupper( $orderby ), ' RAND(' );
[3174] Fix | Delete
[3175] Fix | Delete
$cacheable_field_values = array(
[3176] Fix | Delete
"{$wpdb->posts}.*",
[3177] Fix | Delete
"{$wpdb->posts}.ID, {$wpdb->posts}.post_parent",
[3178] Fix | Delete
"{$wpdb->posts}.ID",
[3179] Fix | Delete
);
[3180] Fix | Delete
[3181] Fix | Delete
if ( ! in_array( $fields, $cacheable_field_values, true ) ) {
[3182] Fix | Delete
$id_query_is_cacheable = false;
[3183] Fix | Delete
}
[3184] Fix | Delete
[3185] Fix | Delete
if ( $q['cache_results'] && $id_query_is_cacheable ) {
[3186] Fix | Delete
$new_request = str_replace( $fields, "{$wpdb->posts}.*", $this->request );
[3187] Fix | Delete
$cache_key = $this->generate_cache_key( $q, $new_request );
[3188] Fix | Delete
[3189] Fix | Delete
$cache_found = false;
[3190] Fix | Delete
if ( null === $this->posts ) {
[3191] Fix | Delete
$cached_results = wp_cache_get( $cache_key, 'post-queries', false, $cache_found );
[3192] Fix | Delete
[3193] Fix | Delete
if ( $cached_results ) {
[3194] Fix | Delete
/** @var int[] */
[3195] Fix | Delete
$post_ids = array_map( 'intval', $cached_results['posts'] );
[3196] Fix | Delete
[3197] Fix | Delete
$this->post_count = count( $post_ids );
[3198] Fix | Delete
$this->found_posts = $cached_results['found_posts'];
[3199] Fix | Delete
$this->max_num_pages = $cached_results['max_num_pages'];
[3200] Fix | Delete
[3201] Fix | Delete
if ( 'ids' === $q['fields'] ) {
[3202] Fix | Delete
$this->posts = $post_ids;
[3203] Fix | Delete
[3204] Fix | Delete
return $this->posts;
[3205] Fix | Delete
} elseif ( 'id=>parent' === $q['fields'] ) {
[3206] Fix | Delete
_prime_post_parent_id_caches( $post_ids );
[3207] Fix | Delete
[3208] Fix | Delete
$post_parent_cache_keys = array();
[3209] Fix | Delete
foreach ( $post_ids as $post_id ) {
[3210] Fix | Delete
$post_parent_cache_keys[] = 'post_parent:' . (string) $post_id;
[3211] Fix | Delete
}
[3212] Fix | Delete
[3213] Fix | Delete
/** @var int[] */
[3214] Fix | Delete
$post_parents = wp_cache_get_multiple( $post_parent_cache_keys, 'posts' );
[3215] Fix | Delete
[3216] Fix | Delete
foreach ( $post_parents as $cache_key => $post_parent ) {
[3217] Fix | Delete
$obj = new stdClass();
[3218] Fix | Delete
$obj->ID = (int) str_replace( 'post_parent:', '', $cache_key );
[3219] Fix | Delete
$obj->post_parent = (int) $post_parent;
[3220] Fix | Delete
[3221] Fix | Delete
$this->posts[] = $obj;
[3222] Fix | Delete
}
[3223] Fix | Delete
[3224] Fix | Delete
return $post_parents;
[3225] Fix | Delete
} else {
[3226] Fix | Delete
_prime_post_caches( $post_ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
[3227] Fix | Delete
/** @var WP_Post[] */
[3228] Fix | Delete
$this->posts = array_map( 'get_post', $post_ids );
[3229] Fix | Delete
}
[3230] Fix | Delete
}
[3231] Fix | Delete
}
[3232] Fix | Delete
}
[3233] Fix | Delete
[3234] Fix | Delete
if ( 'ids' === $q['fields'] ) {
[3235] Fix | Delete
if ( null === $this->posts ) {
[3236] Fix | Delete
$this->posts = $wpdb->get_col( $this->request );
[3237] Fix | Delete
}
[3238] Fix | Delete
[3239] Fix | Delete
/** @var int[] */
[3240] Fix | Delete
$this->posts = array_map( 'intval', $this->posts );
[3241] Fix | Delete
$this->post_count = count( $this->posts );
[3242] Fix | Delete
$this->set_found_posts( $q, $limits );
[3243] Fix | Delete
[3244] Fix | Delete
if ( $q['cache_results'] && $id_query_is_cacheable ) {
[3245] Fix | Delete
$cache_value = array(
[3246] Fix | Delete
'posts' => $this->posts,
[3247] Fix | Delete
'found_posts' => $this->found_posts,
[3248] Fix | Delete
'max_num_pages' => $this->max_num_pages,
[3249] Fix | Delete
);
[3250] Fix | Delete
[3251] Fix | Delete
wp_cache_set( $cache_key, $cache_value, 'post-queries' );
[3252] Fix | Delete
}
[3253] Fix | Delete
[3254] Fix | Delete
return $this->posts;
[3255] Fix | Delete
}
[3256] Fix | Delete
[3257] Fix | Delete
if ( 'id=>parent' === $q['fields'] ) {
[3258] Fix | Delete
if ( null === $this->posts ) {
[3259] Fix | Delete
$this->posts = $wpdb->get_results( $this->request );
[3260] Fix | Delete
}
[3261] Fix | Delete
[3262] Fix | Delete
$this->post_count = count( $this->posts );
[3263] Fix | Delete
$this->set_found_posts( $q, $limits );
[3264] Fix | Delete
[3265] Fix | Delete
/** @var int[] */
[3266] Fix | Delete
$post_parents = array();
[3267] Fix | Delete
$post_ids = array();
[3268] Fix | Delete
$post_parents_cache = array();
[3269] Fix | Delete
[3270] Fix | Delete
foreach ( $this->posts as $key => $post ) {
[3271] Fix | Delete
$this->posts[ $key ]->ID = (int) $post->ID;
[3272] Fix | Delete
$this->posts[ $key ]->post_parent = (int) $post->post_parent;
[3273] Fix | Delete
[3274] Fix | Delete
$post_parents[ (int) $post->ID ] = (int) $post->post_parent;
[3275] Fix | Delete
$post_ids[] = (int) $post->ID;
[3276] Fix | Delete
[3277] Fix | Delete
$post_parents_cache[ 'post_parent:' . (string) $post->ID ] = (int) $post->post_parent;
[3278] Fix | Delete
}
[3279] Fix | Delete
// Prime post parent caches, so that on second run, there is not another database query.
[3280] Fix | Delete
wp_cache_add_multiple( $post_parents_cache, 'posts' );
[3281] Fix | Delete
[3282] Fix | Delete
if ( $q['cache_results'] && $id_query_is_cacheable ) {
[3283] Fix | Delete
$cache_value = array(
[3284] Fix | Delete
'posts' => $post_ids,
[3285] Fix | Delete
'found_posts' => $this->found_posts,
[3286] Fix | Delete
'max_num_pages' => $this->max_num_pages,
[3287] Fix | Delete
);
[3288] Fix | Delete
[3289] Fix | Delete
wp_cache_set( $cache_key, $cache_value, 'post-queries' );
[3290] Fix | Delete
}
[3291] Fix | Delete
[3292] Fix | Delete
return $post_parents;
[3293] Fix | Delete
}
[3294] Fix | Delete
[3295] Fix | Delete
$is_unfiltered_query = $old_request == $this->request && "{$wpdb->posts}.*" === $fields;
[3296] Fix | Delete
[3297] Fix | Delete
if ( null === $this->posts ) {
[3298] Fix | Delete
$split_the_query = (
[3299] Fix | Delete
$is_unfiltered_query
[3300] Fix | Delete
&& (
[3301] Fix | Delete
wp_using_ext_object_cache()
[3302] Fix | Delete
|| ( ! empty( $limits ) && $q['posts_per_page'] < 500 )
[3303] Fix | Delete
)
[3304] Fix | Delete
);
[3305] Fix | Delete
[3306] Fix | Delete
/**
[3307] Fix | Delete
* Filters whether to split the query.
[3308] Fix | Delete
*
[3309] Fix | Delete
* Splitting the query will cause it to fetch just the IDs of the found posts
[3310] Fix | Delete
* (and then individually fetch each post by ID), rather than fetching every
[3311] Fix | Delete
* complete row at once. One massive result vs. many small results.
[3312] Fix | Delete
*
[3313] Fix | Delete
* @since 3.4.0
[3314] Fix | Delete
* @since 6.6.0 Added the `$old_request` and `$clauses` parameters.
[3315] Fix | Delete
*
[3316] Fix | Delete
* @param bool $split_the_query Whether or not to split the query.
[3317] Fix | Delete
* @param WP_Query $query The WP_Query instance.
[3318] Fix | Delete
* @param string $old_request The complete SQL query before filtering.
[3319] Fix | Delete
* @param string[] $clauses {
[3320] Fix | Delete
* Associative array of the clauses for the query.
[3321] Fix | Delete
*
[3322] Fix | Delete
* @type string $where The WHERE clause of the query.
[3323] Fix | Delete
* @type string $groupby The GROUP BY clause of the query.
[3324] Fix | Delete
* @type string $join The JOIN clause of the query.
[3325] Fix | Delete
* @type string $orderby The ORDER BY clause of the query.
[3326] Fix | Delete
* @type string $distinct The DISTINCT clause of the query.
[3327] Fix | Delete
* @type string $fields The SELECT clause of the query.
[3328] Fix | Delete
* @type string $limits The LIMIT clause of the query.
[3329] Fix | Delete
* }
[3330] Fix | Delete
*/
[3331] Fix | Delete
$split_the_query = apply_filters( 'split_the_query', $split_the_query, $this, $old_request, compact( $pieces ) );
[3332] Fix | Delete
[3333] Fix | Delete
if ( $split_the_query ) {
[3334] Fix | Delete
// First get the IDs and then fill in the objects.
[3335] Fix | Delete
[3336] Fix | Delete
// Beginning of the string is on a new line to prevent leading whitespace. See https://core.trac.wordpress.org/ticket/56841.
[3337] Fix | Delete
$this->request =
[3338] Fix | Delete
"SELECT $found_rows $distinct {$wpdb->posts}.ID
[3339] Fix | Delete
FROM {$wpdb->posts} $join
[3340] Fix | Delete
WHERE 1=1 $where
[3341] Fix | Delete
$groupby
[3342] Fix | Delete
$orderby
[3343] Fix | Delete
$limits";
[3344] Fix | Delete
[3345] Fix | Delete
/**
[3346] Fix | Delete
* Filters the Post IDs SQL request before sending.
[3347] Fix | Delete
*
[3348] Fix | Delete
* @since 3.4.0
[3349] Fix | Delete
*
[3350] Fix | Delete
* @param string $request The post ID request.
[3351] Fix | Delete
* @param WP_Query $query The WP_Query instance.
[3352] Fix | Delete
*/
[3353] Fix | Delete
$this->request = apply_filters( 'posts_request_ids', $this->request, $this );
[3354] Fix | Delete
[3355] Fix | Delete
$post_ids = $wpdb->get_col( $this->request );
[3356] Fix | Delete
[3357] Fix | Delete
if ( $post_ids ) {
[3358] Fix | Delete
$this->posts = $post_ids;
[3359] Fix | Delete
$this->set_found_posts( $q, $limits );
[3360] Fix | Delete
_prime_post_caches( $post_ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] );
[3361] Fix | Delete
} else {
[3362] Fix | Delete
$this->posts = array();
[3363] Fix | Delete
}
[3364] Fix | Delete
} else {
[3365] Fix | Delete
$this->posts = $wpdb->get_results( $this->request );
[3366] Fix | Delete
$this->set_found_posts( $q, $limits );
[3367] Fix | Delete
}
[3368] Fix | Delete
}
[3369] Fix | Delete
[3370] Fix | Delete
// Convert to WP_Post objects.
[3371] Fix | Delete
if ( $this->posts ) {
[3372] Fix | Delete
/** @var WP_Post[] */
[3373] Fix | Delete
$this->posts = array_map( 'get_post', $this->posts );
[3374] Fix | Delete
}
[3375] Fix | Delete
[3376] Fix | Delete
$unfiltered_posts = $this->posts;
[3377] Fix | Delete
[3378] Fix | Delete
if ( $q['cache_results'] && $id_query_is_cacheable && ! $cache_found ) {
[3379] Fix | Delete
$post_ids = wp_list_pluck( $this->posts, 'ID' );
[3380] Fix | Delete
[3381] Fix | Delete
$cache_value = array(
[3382] Fix | Delete
'posts' => $post_ids,
[3383] Fix | Delete
'found_posts' => $this->found_posts,
[3384] Fix | Delete
'max_num_pages' => $this->max_num_pages,
[3385] Fix | Delete
);
[3386] Fix | Delete
[3387] Fix | Delete
wp_cache_set( $cache_key, $cache_value, 'post-queries' );
[3388] Fix | Delete
}
[3389] Fix | Delete
[3390] Fix | Delete
if ( ! $q['suppress_filters'] ) {
[3391] Fix | Delete
/**
[3392] Fix | Delete
* Filters the raw post results array, prior to status checks.
[3393] Fix | Delete
*
[3394] Fix | Delete
* @since 2.3.0
[3395] Fix | Delete
*
[3396] Fix | Delete
* @param WP_Post[] $posts Array of post objects.
[3397] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3398] Fix | Delete
*/
[3399] Fix | Delete
$this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
[3400] Fix | Delete
}
[3401] Fix | Delete
[3402] Fix | Delete
if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
[3403] Fix | Delete
/** This filter is documented in wp-includes/query.php */
[3404] Fix | Delete
$cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
[3405] Fix | Delete
[3406] Fix | Delete
/** This filter is documented in wp-includes/query.php */
[3407] Fix | Delete
$cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
[3408] Fix | Delete
[3409] Fix | Delete
/** This filter is documented in wp-includes/query.php */
[3410] Fix | Delete
$cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
[3411] Fix | Delete
$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
[3412] Fix | Delete
[3413] Fix | Delete
/** This filter is documented in wp-includes/query.php */
[3414] Fix | Delete
$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
[3415] Fix | Delete
$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
[3416] Fix | Delete
[3417] Fix | Delete
/** This filter is documented in wp-includes/query.php */
[3418] Fix | Delete
$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
[3419] Fix | Delete
[3420] Fix | Delete
$comments_request = "SELECT {$wpdb->comments}.comment_ID FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
[3421] Fix | Delete
[3422] Fix | Delete
$comment_key = md5( $comments_request );
[3423] Fix | Delete
$comment_last_changed = wp_cache_get_last_changed( 'comment' );
[3424] Fix | Delete
[3425] Fix | Delete
$comment_cache_key = "comment_feed:$comment_key:$comment_last_changed";
[3426] Fix | Delete
$comment_ids = wp_cache_get( $comment_cache_key, 'comment-queries' );
[3427] Fix | Delete
if ( false === $comment_ids ) {
[3428] Fix | Delete
$comment_ids = $wpdb->get_col( $comments_request );
[3429] Fix | Delete
wp_cache_add( $comment_cache_key, $comment_ids, 'comment-queries' );
[3430] Fix | Delete
}
[3431] Fix | Delete
_prime_comment_caches( $comment_ids );
[3432] Fix | Delete
[3433] Fix | Delete
// Convert to WP_Comment.
[3434] Fix | Delete
/** @var WP_Comment[] */
[3435] Fix | Delete
$this->comments = array_map( 'get_comment', $comment_ids );
[3436] Fix | Delete
$this->comment_count = count( $this->comments );
[3437] Fix | Delete
}
[3438] Fix | Delete
[3439] Fix | Delete
// Check post status to determine if post should be displayed.
[3440] Fix | Delete
if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) {
[3441] Fix | Delete
$status = get_post_status( $this->posts[0] );
[3442] Fix | Delete
[3443] Fix | Delete
if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) {
[3444] Fix | Delete
$this->is_page = false;
[3445] Fix | Delete
$this->is_single = true;
[3446] Fix | Delete
$this->is_attachment = true;
[3447] Fix | Delete
}
[3448] Fix | Delete
[3449] Fix | Delete
// If the post_status was specifically requested, let it pass through.
[3450] Fix | Delete
if ( ! in_array( $status, $q_status, true ) ) {
[3451] Fix | Delete
$post_status_obj = get_post_status_object( $status );
[3452] Fix | Delete
[3453] Fix | Delete
if ( $post_status_obj && ! $post_status_obj->public ) {
[3454] Fix | Delete
if ( ! is_user_logged_in() ) {
[3455] Fix | Delete
// User must be logged in to view unpublished posts.
[3456] Fix | Delete
$this->posts = array();
[3457] Fix | Delete
} else {
[3458] Fix | Delete
if ( $post_status_obj->protected ) {
[3459] Fix | Delete
// User must have edit permissions on the draft to preview.
[3460] Fix | Delete
if ( ! current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
[3461] Fix | Delete
$this->posts = array();
[3462] Fix | Delete
} else {
[3463] Fix | Delete
$this->is_preview = true;
[3464] Fix | Delete
if ( 'future' !== $status ) {
[3465] Fix | Delete
$this->posts[0]->post_date = current_time( 'mysql' );
[3466] Fix | Delete
}
[3467] Fix | Delete
}
[3468] Fix | Delete
} elseif ( $post_status_obj->private ) {
[3469] Fix | Delete
if ( ! current_user_can( $read_cap, $this->posts[0]->ID ) ) {
[3470] Fix | Delete
$this->posts = array();
[3471] Fix | Delete
}
[3472] Fix | Delete
} else {
[3473] Fix | Delete
$this->posts = array();
[3474] Fix | Delete
}
[3475] Fix | Delete
}
[3476] Fix | Delete
} elseif ( ! $post_status_obj ) {
[3477] Fix | Delete
// Post status is not registered, assume it's not public.
[3478] Fix | Delete
if ( ! current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
[3479] Fix | Delete
$this->posts = array();
[3480] Fix | Delete
}
[3481] Fix | Delete
}
[3482] Fix | Delete
}
[3483] Fix | Delete
[3484] Fix | Delete
if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
[3485] Fix | Delete
/**
[3486] Fix | Delete
* Filters the single post for preview mode.
[3487] Fix | Delete
*
[3488] Fix | Delete
* @since 2.7.0
[3489] Fix | Delete
*
[3490] Fix | Delete
* @param WP_Post $post_preview The Post object.
[3491] Fix | Delete
* @param WP_Query $query The WP_Query instance (passed by reference).
[3492] Fix | Delete
*/
[3493] Fix | Delete
$this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) );
[3494] Fix | Delete
}
[3495] Fix | Delete
}
[3496] Fix | Delete
[3497] Fix | Delete
// Put sticky posts at the top of the posts array.
[3498] Fix | Delete
$sticky_posts = get_option( 'sticky_posts' );
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function