fix: page-podgotovka-k-shkole.php CSS/JS never enqueued
- is_page_template() was called at top level of functions.php (before query setup) → always returned false - CSS podgotovka-k-shkole.css and JS never loaded → page unstyled - Moved enqueue into enqueue_template_specific_styles() (hooked to wp_enqueue_scripts) where is_page_template() works correctly - Also moved front-page.css enqueue (same bug) - Also removed stray extra closing brace
This commit is contained in:
parent
7c17536c4f
commit
6a7064209b
@ -1526,7 +1526,49 @@ function enqueue_template_specific_styles() {
|
|||||||
'1.1'
|
'1.1'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PKS: Подготовка к школе — CSS и JS
|
||||||
|
if ( is_page_template('page-podgotovka-k-shkole.php') ) {
|
||||||
|
wp_enqueue_style(
|
||||||
|
'template-pksh-style',
|
||||||
|
get_template_directory_uri() . '/assets/css/podgotovka-k-shkole.css',
|
||||||
|
array(),
|
||||||
|
'2.1.' . filemtime(get_template_directory() . '/assets/css/podgotovka-k-shkole.css')
|
||||||
|
);
|
||||||
|
wp_enqueue_script(
|
||||||
|
'pksh-timer',
|
||||||
|
get_template_directory_uri() . '/assets/js/pksh-timer.js',
|
||||||
|
array(),
|
||||||
|
filemtime( get_template_directory() . '/assets/js/pksh-timer.js' ),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
wp_enqueue_script(
|
||||||
|
'pksh-sticky-cta',
|
||||||
|
get_template_directory_uri() . '/assets/js/pksh-sticky-cta.js',
|
||||||
|
array(),
|
||||||
|
filemtime( get_template_directory() . '/assets/js/pksh-sticky-cta.js' ),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Front page
|
||||||
|
if ( is_page_template('front-page.php') || is_front_page() ) {
|
||||||
|
wp_enqueue_style(
|
||||||
|
'front-page-style',
|
||||||
|
get_template_directory_uri() . '/assets/css/front-page.css',
|
||||||
|
array(),
|
||||||
|
filemtime(get_template_directory() . '/assets/css/front-page.css')
|
||||||
|
);
|
||||||
|
wp_enqueue_script(
|
||||||
|
'front-page-script',
|
||||||
|
get_template_directory_uri() . '/assets/js/front-page.js',
|
||||||
|
array(),
|
||||||
|
filemtime(get_template_directory() . '/assets/js/front-page.js'),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Очистка метабоксов на странице Подготовка к школе — оставить только CF и Yoast
|
// Очистка метабоксов на странице Подготовка к школе — оставить только CF и Yoast
|
||||||
add_action( 'load-post.php', function () {
|
add_action( 'load-post.php', function () {
|
||||||
$post_id = isset( $_GET['post'] ) ? (int) $_GET['post'] : 0;
|
$post_id = isset( $_GET['post'] ) ? (int) $_GET['post'] : 0;
|
||||||
@ -1552,46 +1594,7 @@ add_action( 'load-post.php', function () {
|
|||||||
}, 100 );
|
}, 100 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( is_page_template('page-podgotovka-k-shkole.php') ) {
|
|
||||||
wp_enqueue_style(
|
|
||||||
'template-pksh-style',
|
|
||||||
get_template_directory_uri() . '/assets/css/podgotovka-k-shkole.css',
|
|
||||||
array(),
|
|
||||||
'2.1.' . filemtime(get_template_directory() . '/assets/css/podgotovka-k-shkole.css')
|
|
||||||
);
|
|
||||||
wp_enqueue_script(
|
|
||||||
'pksh-timer',
|
|
||||||
get_template_directory_uri() . '/assets/js/pksh-timer.js',
|
|
||||||
array(),
|
|
||||||
filemtime( get_template_directory() . '/assets/js/pksh-timer.js' ),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
wp_enqueue_script(
|
|
||||||
'pksh-sticky-cta',
|
|
||||||
get_template_directory_uri() . '/assets/js/pksh-sticky-cta.js',
|
|
||||||
array(),
|
|
||||||
filemtime( get_template_directory() . '/assets/js/pksh-sticky-cta.js' ),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if ( is_page_template('front-page.php') || is_front_page() ) {
|
|
||||||
wp_enqueue_style(
|
|
||||||
'front-page-style',
|
|
||||||
get_template_directory_uri() . '/assets/css/front-page.css',
|
|
||||||
array(),
|
|
||||||
filemtime(get_template_directory() . '/assets/css/front-page.css')
|
|
||||||
);
|
|
||||||
wp_enqueue_script(
|
|
||||||
'front-page-script',
|
|
||||||
get_template_directory_uri() . '/assets/js/front-page.js',
|
|
||||||
array(),
|
|
||||||
filemtime(get_template_directory() . '/assets/js/front-page.js'),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_action('wp_enqueue_scripts', 'enqueue_template_specific_styles');
|
add_action('wp_enqueue_scripts', 'enqueue_template_specific_styles');
|
||||||
|
|
||||||
// Удаляем ненужные inline-стили WordPress Block Library — тема кастомная, блоки не используются
|
// Удаляем ненужные inline-стили WordPress Block Library — тема кастомная, блоки не используются
|
||||||
add_action('wp_enqueue_scripts', static function () {
|
add_action('wp_enqueue_scripts', static function () {
|
||||||
wp_dequeue_style('wp-block-library');
|
wp_dequeue_style('wp-block-library');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user