Yoast\WP\SEO\Integrations\Admin
Link_Count_Columns_Integration::build_sort_query_pieces() protected Yoast 1.0
Builds the pieces for a sorting query.
{} Это метод класса: Link_Count_Columns_Integration{}
Хуков нет.
Возвращает
Массив. Modified Query pieces.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->build_sort_query_pieces( $pieces, $query, $field );
- $pieces(массив) (обязательный)
- Array of Query pieces.
- $query(WP_Query) (обязательный)
- The Query on which to apply.
- $field(строка) (обязательный)
- The field in the table to JOIN on.
Код Link_Count_Columns_Integration::build_sort_query_pieces() Link Count Columns Integration::build sort query pieces Yoast 15.6.2
protected function build_sort_query_pieces( $pieces, $query, $field ) {
// We only want our code to run in the main WP query.
if ( ! $query->is_main_query() ) {
return $pieces;
}
// Get the order query variable - ASC or DESC.
$order = \strtoupper( $query->get( 'order' ) );
// Make sure the order setting qualifies. If not, set default as ASC.
if ( ! \in_array( $order, [ 'ASC', 'DESC' ], true ) ) {
$order = 'ASC';
}
$table = Model::get_table_name( 'Indexable' );
$pieces['join'] .= " LEFT JOIN $table AS yoast_indexable ON yoast_indexable.object_id = {$this->wpdb->posts}.ID AND yoast_indexable.object_type = 'post' ";
$pieces['orderby'] = "yoast_indexable.$field $order, FIELD( {$this->wpdb->posts}.post_status, 'publish' ) $order, {$pieces['orderby']}";
return $pieces;
}