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: class-wp-comment-query.php
private function set_found_comments() {
[1000] Fix | Delete
global $wpdb;
[1001] Fix | Delete
[1002] Fix | Delete
if ( $this->query_vars['number'] && ! $this->query_vars['no_found_rows'] ) {
[1003] Fix | Delete
/**
[1004] Fix | Delete
* Filters the query used to retrieve found comment count.
[1005] Fix | Delete
*
[1006] Fix | Delete
* @since 4.4.0
[1007] Fix | Delete
*
[1008] Fix | Delete
* @param string $found_comments_query SQL query. Default 'SELECT FOUND_ROWS()'.
[1009] Fix | Delete
* @param WP_Comment_Query $comment_query The `WP_Comment_Query` instance.
[1010] Fix | Delete
*/
[1011] Fix | Delete
$found_comments_query = apply_filters( 'found_comments_query', 'SELECT FOUND_ROWS()', $this );
[1012] Fix | Delete
[1013] Fix | Delete
$this->found_comments = (int) $wpdb->get_var( $found_comments_query );
[1014] Fix | Delete
}
[1015] Fix | Delete
}
[1016] Fix | Delete
[1017] Fix | Delete
/**
[1018] Fix | Delete
* Fetch descendants for located comments.
[1019] Fix | Delete
*
[1020] Fix | Delete
* Instead of calling `get_children()` separately on each child comment, we do a single set of queries to fetch
[1021] Fix | Delete
* the descendant trees for all matched top-level comments.
[1022] Fix | Delete
*
[1023] Fix | Delete
* @since 4.4.0
[1024] Fix | Delete
*
[1025] Fix | Delete
* @param WP_Comment[] $comments Array of top-level comments whose descendants should be filled in.
[1026] Fix | Delete
* @return array
[1027] Fix | Delete
*/
[1028] Fix | Delete
protected function fill_descendants( $comments ) {
[1029] Fix | Delete
$levels = array(
[1030] Fix | Delete
0 => wp_list_pluck( $comments, 'comment_ID' ),
[1031] Fix | Delete
);
[1032] Fix | Delete
[1033] Fix | Delete
$key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
[1034] Fix | Delete
$last_changed = wp_cache_get_last_changed( 'comment' );
[1035] Fix | Delete
[1036] Fix | Delete
// Fetch an entire level of the descendant tree at a time.
[1037] Fix | Delete
$level = 0;
[1038] Fix | Delete
$exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' );
[1039] Fix | Delete
do {
[1040] Fix | Delete
// Parent-child relationships may be cached. Only query for those that are not.
[1041] Fix | Delete
$child_ids = array();
[1042] Fix | Delete
$uncached_parent_ids = array();
[1043] Fix | Delete
$_parent_ids = $levels[ $level ];
[1044] Fix | Delete
if ( $_parent_ids ) {
[1045] Fix | Delete
$cache_keys = array();
[1046] Fix | Delete
foreach ( $_parent_ids as $parent_id ) {
[1047] Fix | Delete
$cache_keys[ $parent_id ] = "get_comment_child_ids:$parent_id:$key:$last_changed";
[1048] Fix | Delete
}
[1049] Fix | Delete
$cache_data = wp_cache_get_multiple( array_values( $cache_keys ), 'comment-queries' );
[1050] Fix | Delete
foreach ( $_parent_ids as $parent_id ) {
[1051] Fix | Delete
$parent_child_ids = $cache_data[ $cache_keys[ $parent_id ] ];
[1052] Fix | Delete
if ( false !== $parent_child_ids ) {
[1053] Fix | Delete
$child_ids = array_merge( $child_ids, $parent_child_ids );
[1054] Fix | Delete
} else {
[1055] Fix | Delete
$uncached_parent_ids[] = $parent_id;
[1056] Fix | Delete
}
[1057] Fix | Delete
}
[1058] Fix | Delete
}
[1059] Fix | Delete
[1060] Fix | Delete
if ( $uncached_parent_ids ) {
[1061] Fix | Delete
// Fetch this level of comments.
[1062] Fix | Delete
$parent_query_args = $this->query_vars;
[1063] Fix | Delete
foreach ( $exclude_keys as $exclude_key ) {
[1064] Fix | Delete
$parent_query_args[ $exclude_key ] = '';
[1065] Fix | Delete
}
[1066] Fix | Delete
$parent_query_args['parent__in'] = $uncached_parent_ids;
[1067] Fix | Delete
$parent_query_args['no_found_rows'] = true;
[1068] Fix | Delete
$parent_query_args['hierarchical'] = false;
[1069] Fix | Delete
$parent_query_args['offset'] = 0;
[1070] Fix | Delete
$parent_query_args['number'] = 0;
[1071] Fix | Delete
[1072] Fix | Delete
$level_comments = get_comments( $parent_query_args );
[1073] Fix | Delete
[1074] Fix | Delete
// Cache parent-child relationships.
[1075] Fix | Delete
$parent_map = array_fill_keys( $uncached_parent_ids, array() );
[1076] Fix | Delete
foreach ( $level_comments as $level_comment ) {
[1077] Fix | Delete
$parent_map[ $level_comment->comment_parent ][] = $level_comment->comment_ID;
[1078] Fix | Delete
$child_ids[] = $level_comment->comment_ID;
[1079] Fix | Delete
}
[1080] Fix | Delete
[1081] Fix | Delete
$data = array();
[1082] Fix | Delete
foreach ( $parent_map as $parent_id => $children ) {
[1083] Fix | Delete
$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
[1084] Fix | Delete
$data[ $cache_key ] = $children;
[1085] Fix | Delete
}
[1086] Fix | Delete
wp_cache_set_multiple( $data, 'comment-queries' );
[1087] Fix | Delete
}
[1088] Fix | Delete
[1089] Fix | Delete
++$level;
[1090] Fix | Delete
$levels[ $level ] = $child_ids;
[1091] Fix | Delete
} while ( $child_ids );
[1092] Fix | Delete
[1093] Fix | Delete
// Prime comment caches for non-top-level comments.
[1094] Fix | Delete
$descendant_ids = array();
[1095] Fix | Delete
for ( $i = 1, $c = count( $levels ); $i < $c; $i++ ) {
[1096] Fix | Delete
$descendant_ids = array_merge( $descendant_ids, $levels[ $i ] );
[1097] Fix | Delete
}
[1098] Fix | Delete
[1099] Fix | Delete
_prime_comment_caches( $descendant_ids, $this->query_vars['update_comment_meta_cache'] );
[1100] Fix | Delete
[1101] Fix | Delete
// Assemble a flat array of all comments + descendants.
[1102] Fix | Delete
$all_comments = $comments;
[1103] Fix | Delete
foreach ( $descendant_ids as $descendant_id ) {
[1104] Fix | Delete
$all_comments[] = get_comment( $descendant_id );
[1105] Fix | Delete
}
[1106] Fix | Delete
[1107] Fix | Delete
// If a threaded representation was requested, build the tree.
[1108] Fix | Delete
if ( 'threaded' === $this->query_vars['hierarchical'] ) {
[1109] Fix | Delete
$threaded_comments = array();
[1110] Fix | Delete
$ref = array();
[1111] Fix | Delete
foreach ( $all_comments as $k => $c ) {
[1112] Fix | Delete
$_c = get_comment( $c->comment_ID );
[1113] Fix | Delete
[1114] Fix | Delete
// If the comment isn't in the reference array, it goes in the top level of the thread.
[1115] Fix | Delete
if ( ! isset( $ref[ $c->comment_parent ] ) ) {
[1116] Fix | Delete
$threaded_comments[ $_c->comment_ID ] = $_c;
[1117] Fix | Delete
$ref[ $_c->comment_ID ] = $threaded_comments[ $_c->comment_ID ];
[1118] Fix | Delete
[1119] Fix | Delete
// Otherwise, set it as a child of its parent.
[1120] Fix | Delete
} else {
[1121] Fix | Delete
[1122] Fix | Delete
$ref[ $_c->comment_parent ]->add_child( $_c );
[1123] Fix | Delete
$ref[ $_c->comment_ID ] = $ref[ $_c->comment_parent ]->get_child( $_c->comment_ID );
[1124] Fix | Delete
}
[1125] Fix | Delete
}
[1126] Fix | Delete
[1127] Fix | Delete
// Set the 'populated_children' flag, to ensure additional database queries aren't run.
[1128] Fix | Delete
foreach ( $ref as $_ref ) {
[1129] Fix | Delete
$_ref->populated_children( true );
[1130] Fix | Delete
}
[1131] Fix | Delete
[1132] Fix | Delete
$comments = $threaded_comments;
[1133] Fix | Delete
} else {
[1134] Fix | Delete
$comments = $all_comments;
[1135] Fix | Delete
}
[1136] Fix | Delete
[1137] Fix | Delete
return $comments;
[1138] Fix | Delete
}
[1139] Fix | Delete
[1140] Fix | Delete
/**
[1141] Fix | Delete
* Used internally to generate an SQL string for searching across multiple columns.
[1142] Fix | Delete
*
[1143] Fix | Delete
* @since 3.1.0
[1144] Fix | Delete
*
[1145] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[1146] Fix | Delete
*
[1147] Fix | Delete
* @param string $search Search string.
[1148] Fix | Delete
* @param string[] $columns Array of columns to search.
[1149] Fix | Delete
* @return string Search SQL.
[1150] Fix | Delete
*/
[1151] Fix | Delete
protected function get_search_sql( $search, $columns ) {
[1152] Fix | Delete
global $wpdb;
[1153] Fix | Delete
[1154] Fix | Delete
$like = '%' . $wpdb->esc_like( $search ) . '%';
[1155] Fix | Delete
[1156] Fix | Delete
$searches = array();
[1157] Fix | Delete
foreach ( $columns as $column ) {
[1158] Fix | Delete
$searches[] = $wpdb->prepare( "$column LIKE %s", $like );
[1159] Fix | Delete
}
[1160] Fix | Delete
[1161] Fix | Delete
return ' AND (' . implode( ' OR ', $searches ) . ')';
[1162] Fix | Delete
}
[1163] Fix | Delete
[1164] Fix | Delete
/**
[1165] Fix | Delete
* Parse and sanitize 'orderby' keys passed to the comment query.
[1166] Fix | Delete
*
[1167] Fix | Delete
* @since 4.2.0
[1168] Fix | Delete
*
[1169] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[1170] Fix | Delete
*
[1171] Fix | Delete
* @param string $orderby Alias for the field to order by.
[1172] Fix | Delete
* @return string|false Value to used in the ORDER clause. False otherwise.
[1173] Fix | Delete
*/
[1174] Fix | Delete
protected function parse_orderby( $orderby ) {
[1175] Fix | Delete
global $wpdb;
[1176] Fix | Delete
[1177] Fix | Delete
$allowed_keys = array(
[1178] Fix | Delete
'comment_agent',
[1179] Fix | Delete
'comment_approved',
[1180] Fix | Delete
'comment_author',
[1181] Fix | Delete
'comment_author_email',
[1182] Fix | Delete
'comment_author_IP',
[1183] Fix | Delete
'comment_author_url',
[1184] Fix | Delete
'comment_content',
[1185] Fix | Delete
'comment_date',
[1186] Fix | Delete
'comment_date_gmt',
[1187] Fix | Delete
'comment_ID',
[1188] Fix | Delete
'comment_karma',
[1189] Fix | Delete
'comment_parent',
[1190] Fix | Delete
'comment_post_ID',
[1191] Fix | Delete
'comment_type',
[1192] Fix | Delete
'user_id',
[1193] Fix | Delete
);
[1194] Fix | Delete
[1195] Fix | Delete
if ( ! empty( $this->query_vars['meta_key'] ) ) {
[1196] Fix | Delete
$allowed_keys[] = $this->query_vars['meta_key'];
[1197] Fix | Delete
$allowed_keys[] = 'meta_value';
[1198] Fix | Delete
$allowed_keys[] = 'meta_value_num';
[1199] Fix | Delete
}
[1200] Fix | Delete
[1201] Fix | Delete
$meta_query_clauses = $this->meta_query->get_clauses();
[1202] Fix | Delete
if ( $meta_query_clauses ) {
[1203] Fix | Delete
$allowed_keys = array_merge( $allowed_keys, array_keys( $meta_query_clauses ) );
[1204] Fix | Delete
}
[1205] Fix | Delete
[1206] Fix | Delete
$parsed = false;
[1207] Fix | Delete
if ( $this->query_vars['meta_key'] === $orderby || 'meta_value' === $orderby ) {
[1208] Fix | Delete
$parsed = "$wpdb->commentmeta.meta_value";
[1209] Fix | Delete
} elseif ( 'meta_value_num' === $orderby ) {
[1210] Fix | Delete
$parsed = "$wpdb->commentmeta.meta_value+0";
[1211] Fix | Delete
} elseif ( 'comment__in' === $orderby ) {
[1212] Fix | Delete
$comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) );
[1213] Fix | Delete
$parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )";
[1214] Fix | Delete
} elseif ( in_array( $orderby, $allowed_keys, true ) ) {
[1215] Fix | Delete
[1216] Fix | Delete
if ( isset( $meta_query_clauses[ $orderby ] ) ) {
[1217] Fix | Delete
$meta_clause = $meta_query_clauses[ $orderby ];
[1218] Fix | Delete
$parsed = sprintf( 'CAST(%s.meta_value AS %s)', esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) );
[1219] Fix | Delete
} else {
[1220] Fix | Delete
$parsed = "$wpdb->comments.$orderby";
[1221] Fix | Delete
}
[1222] Fix | Delete
}
[1223] Fix | Delete
[1224] Fix | Delete
return $parsed;
[1225] Fix | Delete
}
[1226] Fix | Delete
[1227] Fix | Delete
/**
[1228] Fix | Delete
* Parse an 'order' query variable and cast it to ASC or DESC as necessary.
[1229] Fix | Delete
*
[1230] Fix | Delete
* @since 4.2.0
[1231] Fix | Delete
*
[1232] Fix | Delete
* @param string $order The 'order' query variable.
[1233] Fix | Delete
* @return string The sanitized 'order' query variable.
[1234] Fix | Delete
*/
[1235] Fix | Delete
protected function parse_order( $order ) {
[1236] Fix | Delete
if ( ! is_string( $order ) || empty( $order ) ) {
[1237] Fix | Delete
return 'DESC';
[1238] Fix | Delete
}
[1239] Fix | Delete
[1240] Fix | Delete
if ( 'ASC' === strtoupper( $order ) ) {
[1241] Fix | Delete
return 'ASC';
[1242] Fix | Delete
} else {
[1243] Fix | Delete
return 'DESC';
[1244] Fix | Delete
}
[1245] Fix | Delete
}
[1246] Fix | Delete
}
[1247] Fix | Delete
[1248] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function