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-.../public
File: class-tbp-public.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* The public-facing functionality of the plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* @link https://themify.me/
[4] Fix | Delete
* @since 1.0.0
[5] Fix | Delete
*
[6] Fix | Delete
* @package Tbp
[7] Fix | Delete
* @subpackage Tbp/public
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* The public-facing functionality of the plugin.
[12] Fix | Delete
*
[13] Fix | Delete
* Defines the plugin name, version, and two examples hooks for how to
[14] Fix | Delete
* enqueue the public-facing stylesheet and JavaScript.
[15] Fix | Delete
*
[16] Fix | Delete
* @package Tbp
[17] Fix | Delete
* @subpackage Tbp/public
[18] Fix | Delete
* @author Themify <themify@themify.me>
[19] Fix | Delete
*/
[20] Fix | Delete
class Tbp_Public {
[21] Fix | Delete
[22] Fix | Delete
private static $_locations = array();
[23] Fix | Delete
private static $taxonomies = array();
[24] Fix | Delete
public static $is_page = false;
[25] Fix | Delete
public static $is_archive = false;
[26] Fix | Delete
public static $is_single = false;
[27] Fix | Delete
public static $is_singular = false;
[28] Fix | Delete
public static $is_404 = false;
[29] Fix | Delete
public static $is_front_page = false;
[30] Fix | Delete
public static $is_home = false;
[31] Fix | Delete
public static $is_attachemnt = false;
[32] Fix | Delete
public static $is_search = false;
[33] Fix | Delete
public static $is_category = false;
[34] Fix | Delete
public static $is_tag = false;
[35] Fix | Delete
public static $is_author = false;
[36] Fix | Delete
public static $is_date = false;
[37] Fix | Delete
public static $is_tax = false;
[38] Fix | Delete
public static $is_post_type_archive = false;
[39] Fix | Delete
private static $currentQuery = null;
[40] Fix | Delete
private static $originalFile = null;
[41] Fix | Delete
public static $isTemplatePage = false;
[42] Fix | Delete
public static $hasShopTemplate = false;
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Initialize the class and set its properties.
[46] Fix | Delete
*
[47] Fix | Delete
* @since 1.0.0
[48] Fix | Delete
* @param string $plugin_name The name of the plugin.
[49] Fix | Delete
* @param string $version The version of this plugin.
[50] Fix | Delete
*/
[51] Fix | Delete
public static function run() {
[52] Fix | Delete
add_action('themify_builder_setup_modules',array(__CLASS__,'init'));
[53] Fix | Delete
add_action('pre_get_posts', array(__CLASS__, 'set_archive_per_page'));
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
public static function init(){
[57] Fix | Delete
add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'),9);
[58] Fix | Delete
add_action('template_include', array(__CLASS__, 'template_include'), 15);
[59] Fix | Delete
add_action('tbp_render_the_content', array(__CLASS__, 'render_content_page'));
[60] Fix | Delete
add_action('template_redirect', array(__CLASS__, 'set_rules'));
[61] Fix | Delete
if (themify_is_woocommerce_active()) {
[62] Fix | Delete
// Adding cart icon and shopdock markup to the woocommerce fragments
[63] Fix | Delete
add_filter('woocommerce_add_to_cart_fragments', array(__CLASS__, 'tbp_add_to_cart_fragments'));
[64] Fix | Delete
}
[65] Fix | Delete
if(Themify_Builder_Model::is_frontend_editor_page()){
[66] Fix | Delete
add_filter('themify_module_categories', array('Tbp_Utils', 'module_categories'));
[67] Fix | Delete
add_filter('themify_builder_ajax_front_vars', array('Tbp_Utils', 'localize_predesigned_templates'));
[68] Fix | Delete
add_filter('themify_load_predesigned_templates', array('Tbp_Utils', 'load_predesigned_templates'), 10);
[69] Fix | Delete
add_filter('themify_builder_admin_bar_is_available', array(__CLASS__, 'is_available'));
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
add_action( 'themify_builder_frontend_enqueue', array( 'Tbp_Utils', 'load_tbp_active' ) );
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Register the JavaScript for the public-facing side of the site.
[77] Fix | Delete
*
[78] Fix | Delete
* @since 1.0.0
[79] Fix | Delete
*/
[80] Fix | Delete
public static function enqueue_scripts() {
[81] Fix | Delete
$plugin_name = Tbp::get_plugin_name();
[82] Fix | Delete
$v = Tbp::get_version();
[83] Fix | Delete
wp_register_script( $plugin_name, themify_enque(TBP_URL . 'public/js/tbp-script.js'), array('themify-main-script'), $v, true );
[84] Fix | Delete
[85] Fix | Delete
$isActive=Themify_Builder_Model::is_front_builder_activate();
[86] Fix | Delete
if($isActive===false && empty(self::$_locations)){
[87] Fix | Delete
return;
[88] Fix | Delete
}
[89] Fix | Delete
/**
[90] Fix | Delete
* This function is provided for demonstration purposes only.
[91] Fix | Delete
*
[92] Fix | Delete
* An instance of this class should be passed to the run() function
[93] Fix | Delete
* defined in Tbp_Loader as all of the hooks are defined
[94] Fix | Delete
* in that particular class.
[95] Fix | Delete
*
[96] Fix | Delete
* The Tbp_Loader will then create the relationship
[97] Fix | Delete
* between the defined hooks and the functions defined in this
[98] Fix | Delete
* class.
[99] Fix | Delete
*/
[100] Fix | Delete
Tbp_Utils::loadCssModules($plugin_name, TBP_URL . 'public/css/tbp-style.css', $v);
[101] Fix | Delete
[102] Fix | Delete
if (themify_is_woocommerce_active()) {
[103] Fix | Delete
Tbp_Utils::loadCssModules($plugin_name . '-woo', TBP_URL . 'public/css/wc/tbp-woocommerce.css', $v);
[104] Fix | Delete
}
[105] Fix | Delete
foreach(self::$_locations as $loc){
[106] Fix | Delete
Themify_Builder_Stylesheet::enqueue_stylesheet(false,$loc);
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
public static function get_header($name) {
[111] Fix | Delete
remove_action('get_header', array(__CLASS__, 'get_header'),1,1);
[112] Fix | Delete
?><!DOCTYPE html>
[113] Fix | Delete
<html <?php language_attributes(); ?>>
[114] Fix | Delete
<head>
[115] Fix | Delete
<meta charset="<?php bloginfo('charset'); ?>">
[116] Fix | Delete
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
[117] Fix | Delete
<?php if (!current_theme_supports('title-tag')) : ?>
[118] Fix | Delete
<title>
[119] Fix | Delete
<?php echo wp_get_document_title(); ?>
[120] Fix | Delete
</title>
[121] Fix | Delete
<?php endif; ?>
[122] Fix | Delete
<?php wp_head(); ?>
[123] Fix | Delete
</head>
[124] Fix | Delete
<body <?php body_class(); ?>>
[125] Fix | Delete
<?php
[126] Fix | Delete
themify_body_start();
[127] Fix | Delete
if ( function_exists( 'wp_body_open' ) ) {
[128] Fix | Delete
wp_body_open();
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
themify_header_before();
[132] Fix | Delete
themify_header_start();
[133] Fix | Delete
[134] Fix | Delete
self::render_location('header');
[135] Fix | Delete
[136] Fix | Delete
themify_header_end();
[137] Fix | Delete
themify_header_after();
[138] Fix | Delete
themify_layout_before();
[139] Fix | Delete
[140] Fix | Delete
remove_all_actions('wp_head');
[141] Fix | Delete
$templates = array();
[142] Fix | Delete
$name = (string) $name;
[143] Fix | Delete
if ('' !== $name) {
[144] Fix | Delete
$templates[] = "header-{$name}.php";
[145] Fix | Delete
}
[146] Fix | Delete
$templates[] = 'header.php';
[147] Fix | Delete
ob_start();
[148] Fix | Delete
locate_template($templates, true);
[149] Fix | Delete
ob_get_clean();
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
public static function get_footer($name) {
[153] Fix | Delete
remove_action('get_footer', array(__CLASS__, 'get_footer'),1,1);
[154] Fix | Delete
[155] Fix | Delete
themify_layout_after();
[156] Fix | Delete
themify_footer_before();
[157] Fix | Delete
themify_footer_start();
[158] Fix | Delete
[159] Fix | Delete
self::render_location('footer');
[160] Fix | Delete
[161] Fix | Delete
themify_footer_end();
[162] Fix | Delete
themify_footer_after();
[163] Fix | Delete
[164] Fix | Delete
wp_footer();
[165] Fix | Delete
themify_body_end();
[166] Fix | Delete
?>
[167] Fix | Delete
</body>
[168] Fix | Delete
</html>
[169] Fix | Delete
<?php
[170] Fix | Delete
remove_all_actions('wp_footer');
[171] Fix | Delete
$templates = array();
[172] Fix | Delete
$name = (string) $name;
[173] Fix | Delete
if ('' !== $name) {
[174] Fix | Delete
$templates[] = "footer-{$name}.php";
[175] Fix | Delete
}
[176] Fix | Delete
$templates[] = 'footer.php';
[177] Fix | Delete
ob_start();
[178] Fix | Delete
locate_template($templates, true);
[179] Fix | Delete
ob_get_clean();
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
private static function render_template($post_id, $location) {
[183] Fix | Delete
if ( $template = get_post( $post_id ) ) {
[184] Fix | Delete
[185] Fix | Delete
global $ThemifyBuilder;
[186] Fix | Delete
$tag = $location === 'header' || $location === 'footer' ? $location : 'main';
[187] Fix | Delete
$id = $tag === 'main' ? 'content' : $location;
[188] Fix | Delete
$classes = array( 'tbp_template' );
[189] Fix | Delete
$single_product_hook=false;
[190] Fix | Delete
if ( $location === 'product_single' ) {
[191] Fix | Delete
$classes[] = 'product';
[192] Fix | Delete
$the_query = Tbp_Utils::get_wc_actual_query();
[193] Fix | Delete
global $product;
[194] Fix | Delete
if ($the_query !== null && $the_query->have_posts() && is_object($product)) {
[195] Fix | Delete
remove_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );
[196] Fix | Delete
do_action( 'woocommerce_before_single_product' );
[197] Fix | Delete
$single_product_hook=true;
[198] Fix | Delete
wp_reset_postdata();
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
$isLoop = $ThemifyBuilder->in_the_loop === true;
[203] Fix | Delete
$ThemifyBuilder->in_the_loop = true;
[204] Fix | Delete
[205] Fix | Delete
do_action('tbp_before_render_builder', $post_id, $location);
[206] Fix | Delete
$title = $template->post_title;
[207] Fix | Delete
if($location==='archive' || $location==='product_archive'){
[208] Fix | Delete
Tbp_Utils::disable_ptb_loop();
[209] Fix | Delete
}
[210] Fix | Delete
echo sprintf('<!-- Builder Pro Template Start: %s -->', $title), '<' . $tag . ' id="tbp_' . $id . '" class="' . join( ' ', $classes ) . '">',
[211] Fix | Delete
$ThemifyBuilder->get_builder_output( $post_id ),
[212] Fix | Delete
sprintf('<!-- Builder Pro Template End: %s -->', $title), '</' . $tag . '>';
[213] Fix | Delete
do_action('tbp_after_render_builder', $post_id, $location);
[214] Fix | Delete
[215] Fix | Delete
$ThemifyBuilder->in_the_loop = $isLoop;
[216] Fix | Delete
if ($single_product_hook === true) {
[217] Fix | Delete
do_action( 'woocommerce_after_single_product' );
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
public static function render_location($location) {
[223] Fix | Delete
if (isset(self::$_locations[$location])) {
[224] Fix | Delete
self::render_template(self::$_locations[$location], $location);
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
private static function collect_display_conditions() {
[229] Fix | Delete
$conditions = array();
[230] Fix | Delete
$activeTheme=Tbp::get_active_theme();
[231] Fix | Delete
if (!empty($activeTheme)) {
[232] Fix | Delete
$args = array(
[233] Fix | Delete
'post_type' => Tbp_Templates::$post_type,
[234] Fix | Delete
'posts_per_page' => 50,
[235] Fix | Delete
'order' => 'ASC',
[236] Fix | Delete
'ptb_disable'=>true,
[237] Fix | Delete
'nopaging' => true,
[238] Fix | Delete
'no_found_rows'=>true,
[239] Fix | Delete
'ignore_sticky_posts'=>true,
[240] Fix | Delete
'meta_query' => array(
[241] Fix | Delete
array(
[242] Fix | Delete
'key' => 'tbp_associated_theme',
[243] Fix | Delete
'value' => $activeTheme->post_name,
[244] Fix | Delete
)
[245] Fix | Delete
)
[246] Fix | Delete
);
[247] Fix | Delete
$templates = get_posts($args);
[248] Fix | Delete
if ($templates) {
[249] Fix | Delete
foreach ($templates as $template) {
[250] Fix | Delete
$condition = Tbp_Utils::get_template_conditions($template->ID);
[251] Fix | Delete
[252] Fix | Delete
if ($condition) {
[253] Fix | Delete
$list_conditions = array();
[254] Fix | Delete
foreach ($condition as $c) {
[255] Fix | Delete
$list_conditions[$c['type']][] = $c;
[256] Fix | Delete
}
[257] Fix | Delete
[258] Fix | Delete
$conditions[$template->ID] = $list_conditions;
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
return $conditions;
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
private static function set_condition_tags() {
[267] Fix | Delete
[268] Fix | Delete
[269] Fix | Delete
self::$is_404 = is_404();
[270] Fix | Delete
if (self::$is_404 === false) {
[271] Fix | Delete
[272] Fix | Delete
self::$is_page = is_page();
[273] Fix | Delete
self::$is_attachemnt = self::$is_page === false && is_attachment();
[274] Fix | Delete
self::$is_single = self::$is_page === false && self::$is_attachemnt === false && is_single();
[275] Fix | Delete
self::$is_singular = self::$is_page === true || self::$is_attachemnt === true || self::$is_single === true;
[276] Fix | Delete
[277] Fix | Delete
if (self::$is_singular === false) {
[278] Fix | Delete
[279] Fix | Delete
self::$is_home = is_home();
[280] Fix | Delete
[281] Fix | Delete
if (self::$is_home === false) {
[282] Fix | Delete
[283] Fix | Delete
self::$is_category = is_category();
[284] Fix | Delete
[285] Fix | Delete
if (self::$is_category === false) {
[286] Fix | Delete
[287] Fix | Delete
self::$is_tag = is_tag();
[288] Fix | Delete
[289] Fix | Delete
if (self::$is_tag === false) {
[290] Fix | Delete
[291] Fix | Delete
self::$is_tax = is_tax();
[292] Fix | Delete
[293] Fix | Delete
if (self::$is_tax === false) {
[294] Fix | Delete
[295] Fix | Delete
self::$is_search = is_search();
[296] Fix | Delete
[297] Fix | Delete
if (self::$is_search === false) {
[298] Fix | Delete
[299] Fix | Delete
self::$is_author = is_author();
[300] Fix | Delete
[301] Fix | Delete
if (self::$is_author === false) {
[302] Fix | Delete
[303] Fix | Delete
self::$is_post_type_archive = is_post_type_archive();
[304] Fix | Delete
[305] Fix | Delete
if (self::$is_post_type_archive === false) {
[306] Fix | Delete
[307] Fix | Delete
self::$is_date = is_date();
[308] Fix | Delete
}
[309] Fix | Delete
}
[310] Fix | Delete
}
[311] Fix | Delete
}
[312] Fix | Delete
}
[313] Fix | Delete
}
[314] Fix | Delete
}
[315] Fix | Delete
self::$is_archive = self::$is_category === true || self::$is_tag === true || self::$is_tax === true || self::$is_home === true || self::$is_author === true || self::$is_date === true || self::$is_search === true || self::$is_post_type_archive === true || is_archive();
[316] Fix | Delete
} else {
[317] Fix | Delete
self::$isTemplatePage = is_singular(Tbp_Templates::$post_type);
[318] Fix | Delete
self::$is_front_page = self::$is_page === true && is_front_page();
[319] Fix | Delete
}
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
if ( self::$is_author ) {
[323] Fix | Delete
// on author archives, the query object returns empty until template_redirect
[324] Fix | Delete
add_action( 'template_redirect', array( __CLASS__, 'cache_query_object' ), 1 );
[325] Fix | Delete
} else {
[326] Fix | Delete
self::cache_query_object();
[327] Fix | Delete
}
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
/**
[331] Fix | Delete
* Cache the global query object
[332] Fix | Delete
*
[333] Fix | Delete
* Hooked to "template_redirect"
[334] Fix | Delete
*/
[335] Fix | Delete
public static function cache_query_object() {
[336] Fix | Delete
self::$currentQuery = get_queried_object();
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
/**
[340] Fix | Delete
* Get $currentQuery prop
[341] Fix | Delete
*
[342] Fix | Delete
* @return mixed
[343] Fix | Delete
*/
[344] Fix | Delete
public static function get_current_query() {
[345] Fix | Delete
return self::$currentQuery;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
private static function checking_display_rules() {
[349] Fix | Delete
if (!empty(self::$_locations) || (self::$is_archive===false && self::$is_page===false && is_singular('tglobal_style'))) {
[350] Fix | Delete
return;
[351] Fix | Delete
}
[352] Fix | Delete
self::set_condition_tags();
[353] Fix | Delete
[354] Fix | Delete
if (self::$isTemplatePage === true) {
[355] Fix | Delete
$id=get_the_ID();
[356] Fix | Delete
$template_type = get_post_meta($id, 'tbp_template_type', true);
[357] Fix | Delete
if ($template_type) {
[358] Fix | Delete
self::$_locations[$template_type] = $id;
[359] Fix | Delete
}
[360] Fix | Delete
if(($template_type==='product_single' || $template_type==='product_archive') && themify_is_woocommerce_active()){
[361] Fix | Delete
add_filter('themify_builder_body_class', array(__CLASS__,'add_wc_to_body'));
[362] Fix | Delete
}
[363] Fix | Delete
}
[364] Fix | Delete
else{
[365] Fix | Delete
$is_multilingual = Tbp_Utils::is_multilingual();
[366] Fix | Delete
$conditions = self::collect_display_conditions();
[367] Fix | Delete
// Cached the taxonomy lists
[368] Fix | Delete
$tax = Tbp_Utils::get_taxonomies();
[369] Fix | Delete
foreach ($tax as $slug => $v) {
[370] Fix | Delete
self::$taxonomies[$slug] = true;
[371] Fix | Delete
}
[372] Fix | Delete
$currentPostType = ! empty( self::$currentQuery->post_type ) ? self::$currentQuery->post_type : null;
[373] Fix | Delete
if ( self::$is_404 === true || self::$is_page === true ) {
[374] Fix | Delete
$currentPostType = 'page';
[375] Fix | Delete
}
[376] Fix | Delete
elseif(self::$is_archive===true && empty($currentPostType)){
[377] Fix | Delete
if(self::$is_category === true || self::$is_tag === true || self::$is_tax === true){
[378] Fix | Delete
$tax = self::$currentQuery===null?false:get_taxonomy(self::$currentQuery->taxonomy);
[379] Fix | Delete
if($tax===false){// WP doesn't recognized 404 page when taxonomy/term doesn't exist
[380] Fix | Delete
self::$is_404=true;
[381] Fix | Delete
$currentPostType='page';
[382] Fix | Delete
self::$is_archive=self::$is_category=self::$is_tag=self::$is_tax=false;
[383] Fix | Delete
}
[384] Fix | Delete
else{
[385] Fix | Delete
$currentPostType=$tax->object_type;
[386] Fix | Delete
}
[387] Fix | Delete
}
[388] Fix | Delete
elseif(self::$is_post_type_archive===true){
[389] Fix | Delete
$currentPostType = self::$currentQuery->name;
[390] Fix | Delete
}
[391] Fix | Delete
else{
[392] Fix | Delete
$currentPostType = 'post';
[393] Fix | Delete
}
[394] Fix | Delete
} else if ( self::$is_home === true && ! self::$is_front_page ) { // Posts Page
[395] Fix | Delete
$currentPostType = 'post';
[396] Fix | Delete
}
[397] Fix | Delete
unset($tax);
[398] Fix | Delete
$isArray = is_array($currentPostType);
[399] Fix | Delete
foreach ($conditions as $id => $condition_type) {
[400] Fix | Delete
$translated_template = false;
[401] Fix | Delete
if ( $is_multilingual ) {
[402] Fix | Delete
$translated_template = Tbp_Utils::get_translated_object_id( $id, 'tbp_template' );
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
if (isset($condition_type['exclude']) || isset($condition_type['include'])) {
[406] Fix | Delete
$location = get_post_meta($id, 'tbp_template_type', true);
[407] Fix | Delete
if((self::$is_archive===false && ($location==='archive' || $location==='product_archive')) || (self::$is_singular===false && ($location==='single' || $location==='product_single')) || ($location==='page' && self::$is_page===false && self::$is_404===false)){
[408] Fix | Delete
continue;
[409] Fix | Delete
}
[410] Fix | Delete
// Include conditions
[411] Fix | Delete
if (isset($condition_type['include'])) {
[412] Fix | Delete
foreach ($condition_type['include'] as $condition) {
[413] Fix | Delete
$post_type = Tbp_Utils::get_post_type( $location, $condition );
[414] Fix | Delete
if ( $post_type === 'any' || ( ( $isArray === true && self::check_intersect( $currentPostType, $post_type ) === true ) || ( $isArray === false && in_array( $currentPostType, $post_type, true ) ) ) ) {
[415] Fix | Delete
$view = self::get_condition_settings($id, $location, $condition);
[416] Fix | Delete
if ( $is_multilingual ) {
[417] Fix | Delete
if ( ! empty( $translated_template ) && 'publish' === get_post_status( $translated_template ) ) {
[418] Fix | Delete
$id = $translated_template;
[419] Fix | Delete
}
[420] Fix | Delete
/* always translate the template assignments; without translation,
[421] Fix | Delete
* the original template is applied and used on all languages.
[422] Fix | Delete
*/
[423] Fix | Delete
$view = self::translate_view( $view );
[424] Fix | Delete
}
[425] Fix | Delete
if ( $view !== false ) {
[426] Fix | Delete
// check if template is assigned to the current context, returns the priority of the template
[427] Fix | Delete
$priority = self::is_current_view( $view );
[428] Fix | Delete
if ( $priority ) {
[429] Fix | Delete
self::$_locations[ $location ][ $priority ][ $id ] = $id;
[430] Fix | Delete
}
[431] Fix | Delete
}
[432] Fix | Delete
}
[433] Fix | Delete
}
[434] Fix | Delete
unset($condition_type['include']);
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
// Exclude conditions
[438] Fix | Delete
if (isset($condition_type['exclude'])) {
[439] Fix | Delete
foreach ($condition_type['exclude'] as $condition) {
[440] Fix | Delete
$post_type = Tbp_Utils::get_post_type($location, $condition);
[441] Fix | Delete
if($post_type==='any' || (($isArray===true && self::check_intersect($currentPostType,$post_type)===true)|| ($isArray===false && in_array($currentPostType,$post_type,true)))){
[442] Fix | Delete
$view = self::get_condition_settings($id, $location, $condition);
[443] Fix | Delete
[444] Fix | Delete
if ( $is_multilingual ) {
[445] Fix | Delete
if ( ! empty( $translated_template ) && 'publish' === get_post_status( $translated_template ) ) {
[446] Fix | Delete
$id = $translated_template;
[447] Fix | Delete
}
[448] Fix | Delete
$view = self::translate_view( $view );
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
if ( $view !== false ) {
[452] Fix | Delete
if ( self::is_current_view( $view ) ) {
[453] Fix | Delete
// Exclude condition applies. Disable the template.
[454] Fix | Delete
if ( ! empty( self::$_locations[ $location ] ) && is_array( self::$_locations[ $location ] ) ) {
[455] Fix | Delete
foreach ( self::$_locations[ $location ] as $priority => $templates ) {
[456] Fix | Delete
unset( self::$_locations[ $location ][ $priority ][ $id ] );
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
break;
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
}
[463] Fix | Delete
}
[464] Fix | Delete
unset( $condition_type['exclude'] );
[465] Fix | Delete
}
[466] Fix | Delete
}
[467] Fix | Delete
}
[468] Fix | Delete
unset($conditions);
[469] Fix | Delete
// clean up empty elements
[470] Fix | Delete
self::$_locations = Tbp_Utils::array_filter_recursive( self::$_locations );
[471] Fix | Delete
[472] Fix | Delete
// for each location, set the template with the highest priority as active
[473] Fix | Delete
if ( ! empty( self::$_locations ) ) {
[474] Fix | Delete
foreach (self::$_locations as $location => $templates ) {
[475] Fix | Delete
$highest_priority = max( array_keys( $templates ) );
[476] Fix | Delete
self::$_locations[ $location ] = reset( $templates[ $highest_priority ] );
[477] Fix | Delete
}
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
if(isset(self::$_locations['product_archive'])){
[482] Fix | Delete
unset(self::$_locations['archive']);
[483] Fix | Delete
}
[484] Fix | Delete
if(isset(self::$_locations['product_single']) || isset(self::$_locations['page'])){
[485] Fix | Delete
unset(self::$_locations['single']);
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
self::set_location();
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
private static function get_condition_settings($id, $location, $condition) {
[492] Fix | Delete
$query = isset($condition['query']) ? $condition['query'] : '';
[493] Fix | Delete
$detail = $condition['detail'];
[494] Fix | Delete
$general = $condition['general'];
[495] Fix | Delete
if ($location === 'header' || $location === 'footer') {
[496] Fix | Delete
$location = $general;
[497] Fix | Delete
$data = $query;
[498] Fix | Delete
} else {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function