$selector, 'render' => function () use ($args) { if ( isset($args['prefix']) && strpos($args['prefix'], 'product') !== false ) { echo blocksy_replace_current_template(); return; } if (have_posts()) { the_post(); } echo blocksy_single_content(); } ], $args); } function blocksy_replace_current_template() { $tag_templates = [ 'is_embed' => 'get_embed_template', 'is_404' => 'get_404_template', 'is_search' => 'get_search_template', 'is_front_page' => 'get_front_page_template', 'is_home' => 'get_home_template', 'is_privacy_policy' => 'get_privacy_policy_template', 'is_post_type_archive' => 'get_post_type_archive_template', 'is_tax' => 'get_taxonomy_template', 'is_attachment' => 'get_attachment_template', 'is_single' => 'get_single_template', 'is_page' => 'get_page_template', 'is_singular' => 'get_singular_template', 'is_category' => 'get_category_template', 'is_tag' => 'get_tag_template', 'is_author' => 'get_author_template', 'is_date' => 'get_date_template', 'is_archive' => 'get_archive_template', ]; $template = false; foreach ($tag_templates as $tag => $template_getter) { if (call_user_func($tag)) { $template = call_user_func($template_getter); } if ($template) { break; } } if (! $template) { $template = get_index_template(); } $template = apply_filters('template_include', $template); $theme_directory = get_template_directory(); if ( class_exists('Tribe__Events__Main') && ( tribe_is_event() || is_singular('tribe_event_series') || is_singular('tribe_organizer') || tribe_is_venue() ) ) { $actual_prefix = 'tribe_events_single'; } if ( class_exists('Tribe__Events__Main') && ( tribe_is_events_home() || tribe_is_showing_all() || is_tax('tec_venue_category') || is_archive('tribe_events') ) ) { $actual_prefix = 'tribe_events_archive'; } if ( is_singular() && strpos($template, $theme_directory) !== false && ( ! is_singular('courses') && function_exists('tutor_course_enrolled_lead_info') || ! function_exists('tutor_course_enrolled_lead_info') ) && ( class_exists('Tribe__Events__Main') && ! ( tribe_is_events_home() || tribe_is_showing_all() || is_tax('tec_venue_category') || is_archive('tribe_events') || tribe_is_event() || is_singular('tribe_event_series') || is_singular('tribe_organizer') || tribe_is_venue() ) || ! class_exists('Tribe__Events__Main') ) ) { ob_start(); echo '
'; blocksy_before_current_template(); get_template_part('template-parts/single'); blocksy_after_current_template(); echo '
'; return ob_get_clean(); } if ( strpos($template, $theme_directory) !== false && ( basename($template) === 'index.php' ) ) { ob_start(); echo '
'; blocksy_before_current_template(); get_template_part('template-parts/archive'); blocksy_after_current_template(); echo '
'; return ob_get_clean(); } if ($template) { ob_start(); $level = ob_get_level(); include $template; while (ob_get_level() > $level + 1) { ob_end_clean(); } $content = ob_get_clean(); preg_match('/
/s', $content, $result); $without_header = preg_split('/
/s', $content)[1]; $without_footer = preg_split( '/
'; } return ''; } add_filter('customize_dynamic_partial_class', function ($class, $id, $args ) { return 'Blocksy_WP_Customize_Partial'; }, 10, 3); class Blocksy_WP_Customize_Partial extends WP_Customize_Partial { public $loader_selector; public function __construct( WP_Customize_Selective_Refresh $component, $id, $args = array() ) { parent::__construct($component, $id, $args); if (isset($args['loader_selector'])) { $this->loader_selector = $args['loader_selector']; } } public function json () { $json = parent::json(); if ($this->loader_selector) { $json['loader_selector'] = $this->loader_selector; } return $json; } }