Improves child theme detection for when in customizer
This commit is contained in:
parent
19e7352a28
commit
e24b10afff
|
@ -3,6 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* Adds Tainacan repository and term items list to settings on customizer.
|
* Adds Tainacan repository and term items list to settings on customizer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_panel') ) {
|
if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_panel') ) {
|
||||||
function tainacan_blocksy_add_repository_and_terms_items_options_panel($options) {
|
function tainacan_blocksy_add_repository_and_terms_items_options_panel($options) {
|
||||||
|
|
||||||
|
@ -23,7 +24,6 @@ if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_p
|
||||||
TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archives/tainacan-terms-items.php',
|
TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archives/tainacan-terms-items.php',
|
||||||
[], false
|
[], false
|
||||||
);
|
);
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ if ( !function_exists('tainacan_blocksy_archive_templates_redirects') ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('template_redirect', 'tainacan_blocksy_archive_templates_redirects');
|
add_action('template_redirect', 'tainacan_blocksy_archive_templates_redirects', 2, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses Template redirect for setting the proper template to items
|
* Uses Template redirect for setting the proper template to items
|
||||||
|
|
|
@ -1,22 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks is the current activate theme is blocksy
|
* Checks if the current activate theme is either blocksy, a child theme of blocksy or one of them in a customizer preview
|
||||||
*/
|
*/
|
||||||
if ( !function_exists('tainacan_blocksy_is_blocksy_activated') ) {
|
if ( !function_exists('tainacan_blocksy_is_blocksy_activated') ) {
|
||||||
function tainacan_blocksy_is_blocksy_activated() {
|
function tainacan_blocksy_is_blocksy_activated() {
|
||||||
$theme = wp_get_theme();
|
$theme = wp_get_theme();
|
||||||
$is_correct_theme = strpos( $theme->get_stylesheet(), 'blocksy' ) !== false;
|
$is_correct_theme = strpos( $theme->get_stylesheet(), 'blocksy' ) !== false;
|
||||||
|
|
||||||
$is_child_theme_of_blocksy = FALSE;
|
$is_child_theme_of_blocksy = false;
|
||||||
if ($theme->parent() !== false)
|
if ($theme->parent() !== false)
|
||||||
$is_child_theme_of_blocksy = strpos( $theme->get_template(), 'blocksy' ) !== false;
|
$is_child_theme_of_blocksy = strpos( $theme->get_template(), 'blocksy' ) !== false;
|
||||||
|
|
||||||
$another_theme_in_preview = false;
|
if ( isset($_SERVER['REQUEST_URI']) && strpos( $_SERVER['REQUEST_URI'], 'customize' ) !== false ) {
|
||||||
if ( (isset( $_REQUEST['theme'] ) && strpos( strtolower( $_REQUEST['theme'] ), 'blocksy' ) === false || isset( $_REQUEST['customize_theme'] ) && strpos( strtolower( $_REQUEST['customize_theme'] ), 'blocksy' ) === false) && strpos( $_SERVER['REQUEST_URI'], 'customize' ) !== false ) {
|
$preview_theme_slug = isset( $_REQUEST['theme'] ) ? strtolower($_REQUEST['theme']) : ( isset( $_REQUEST['customize_theme'] ) ? strtolower($_REQUEST['customize_theme']) : '');
|
||||||
$another_theme_in_preview = true;
|
|
||||||
|
$preview_theme = wp_get_theme($preview_theme_slug);
|
||||||
|
$is_correct_theme = strpos( $preview_theme->get_stylesheet(), 'blocksy' ) !== false;
|
||||||
|
|
||||||
|
$is_child_theme_of_blocksy = false;
|
||||||
|
if ($preview_theme->parent() !== false)
|
||||||
|
$is_child_theme_of_blocksy = strpos( $preview_theme->get_template(), 'blocksy' ) !== false;
|
||||||
}
|
}
|
||||||
return ($is_correct_theme || $is_child_theme_of_blocksy) && !$another_theme_in_preview;
|
|
||||||
|
return $is_correct_theme || $is_child_theme_of_blocksy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue