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
/home/sportsfe.../httpdocs/wp-conte.../plugins/themify-.../includes
File: class-tbp-dynamic-query.php
<?php
[0] Fix | Delete
[1] Fix | Delete
final class Tbp_Dynamic_Query {
[2] Fix | Delete
[3] Fix | Delete
private static $field_name = 'tbpdq';
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
public static function run() {
[7] Fix | Delete
add_action( 'themify_builder_module_render_vars', array( __CLASS__, 'themify_builder_module_render_vars' ) );
[8] Fix | Delete
add_filter( 'themify_builder_ajax_admin_vars', array( __CLASS__, 'themify_builder_ajax_vars' ) );
[9] Fix | Delete
add_filter( 'themify_builder_ajax_front_vars', array( __CLASS__, 'themify_builder_ajax_vars' ) );
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
public static function themify_builder_ajax_vars( $vars ) {
[13] Fix | Delete
$vars['DynamicQuery'] = array(
[14] Fix | Delete
'input' => array(
[15] Fix | Delete
'id' => self::$field_name,
[16] Fix | Delete
'type' => 'toggle_switch',
[17] Fix | Delete
'label' => __('Dynamic Query', 'tbp'),
[18] Fix | Delete
'options' => array(
[19] Fix | Delete
'off' => array( 'value' => 'dis', 'name' => 'off' ),
[20] Fix | Delete
'on' => array( 'value' => 'en', 'name' => 'on' ),
[21] Fix | Delete
),
[22] Fix | Delete
'help' => __( 'Use this on Builder Pro archive template only. The archive view (category or tag pages) will use this module to display the posts.', 'tbp' ),
[23] Fix | Delete
),
[24] Fix | Delete
);
[25] Fix | Delete
[26] Fix | Delete
return $vars;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Runs just before a module is rendered, enable Dynamic Query if applicable
[31] Fix | Delete
*
[32] Fix | Delete
* @return array
[33] Fix | Delete
*/
[34] Fix | Delete
public static function themify_builder_module_render_vars( $vars ) {
[35] Fix | Delete
/**
[36] Fix | Delete
* Reset the "pre_get_posts" filter
[37] Fix | Delete
* This is to ensure that filter is applied only once and does not affect other modules.
[38] Fix | Delete
*/
[39] Fix | Delete
remove_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
[40] Fix | Delete
[41] Fix | Delete
if ( isset( $vars['mod_settings'][ self::$field_name ] ) && $vars['mod_settings'][ self::$field_name ] === 'on' && ( is_archive() || is_home() ) ) {
[42] Fix | Delete
add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
return $vars;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Replace all the query vars of the current query with global $wp_query
[50] Fix | Delete
*
[51] Fix | Delete
*/
[52] Fix | Delete
public static function pre_get_posts( $query ) {
[53] Fix | Delete
global $wp_query;
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* In case this is the last module in the page and there are other queries running
[57] Fix | Delete
* after this, reset "pre_get_posts" again to ensure this filter runs only once.
[58] Fix | Delete
*/
[59] Fix | Delete
remove_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ) );
[60] Fix | Delete
[61] Fix | Delete
$query->query_vars = $wp_query->query_vars;
[62] Fix | Delete
if ( isset( $query->query['posts_per_page'] ) ) {
[63] Fix | Delete
$query->query_vars['posts_per_page'] = $query->query['posts_per_page'];
[64] Fix | Delete
}
[65] Fix | Delete
if ( isset( $query->query['offset'] ) ) {
[66] Fix | Delete
$query->query_vars['offset'] = $query->query['offset'];
[67] Fix | Delete
}
[68] Fix | Delete
if ( isset( $query->query['paged'] ) ) {
[69] Fix | Delete
$query->query_vars['paged'] = $query->query['paged'];
[70] Fix | Delete
}
[71] Fix | Delete
if ( ! $wp_query->is_home() ) {
[72] Fix | Delete
$query->query_vars['ignore_sticky_posts'] = 1;
[73] Fix | Delete
}
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function