Anton | натяжка страницы test1
This commit is contained in:
@@ -204,3 +204,73 @@ if ( ! function_exists( 'twentytwentyfour_pattern_categories' ) ) :
|
||||
endif;
|
||||
|
||||
add_action( 'init', 'twentytwentyfour_pattern_categories' );
|
||||
|
||||
/**
|
||||
* Use a standalone PHP template for the page slug "test1".
|
||||
*
|
||||
* @since Twenty Twenty-Four 1.0
|
||||
*
|
||||
* @param string $template Resolved template path.
|
||||
* @return string
|
||||
*/
|
||||
function twentytwentyfour_test1_template( $template ) {
|
||||
if ( ! is_page( 'test1' ) ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
$custom_template = get_theme_file_path( 'page-test1.php' );
|
||||
|
||||
if ( file_exists( $custom_template ) ) {
|
||||
return $custom_template;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
add_filter( 'template_include', 'twentytwentyfour_test1_template' );
|
||||
|
||||
/**
|
||||
* Enqueue standalone landing assets for the page slug "test1".
|
||||
*
|
||||
* @since Twenty Twenty-Four 1.0
|
||||
* @return void
|
||||
*/
|
||||
function twentytwentyfour_test1_assets() {
|
||||
if ( ! is_page( 'test1' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css_file = ABSPATH . 'index3.css';
|
||||
$js_file = ABSPATH . 'index3.js';
|
||||
|
||||
wp_dequeue_style( 'global-styles' );
|
||||
wp_dequeue_style( 'wp-block-library' );
|
||||
wp_dequeue_style( 'wp-block-library-theme' );
|
||||
wp_dequeue_style( 'classic-theme-styles' );
|
||||
|
||||
wp_enqueue_style(
|
||||
'twentytwentyfour-test1-fonts',
|
||||
'https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700;800&display=swap',
|
||||
array(),
|
||||
null
|
||||
);
|
||||
|
||||
if ( file_exists( $css_file ) ) {
|
||||
wp_enqueue_style(
|
||||
'twentytwentyfour-test1-style',
|
||||
home_url( '/index3.css' ),
|
||||
array( 'twentytwentyfour-test1-fonts' ),
|
||||
(string) filemtime( $css_file )
|
||||
);
|
||||
}
|
||||
|
||||
if ( file_exists( $js_file ) ) {
|
||||
wp_enqueue_script(
|
||||
'twentytwentyfour-test1-script',
|
||||
home_url( '/index3.js' ),
|
||||
array(),
|
||||
(string) filemtime( $js_file ),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'twentytwentyfour_test1_assets', 100 );
|
||||
|
||||
36
wp-content/themes/twentytwentyfour/page-test1.php
Normal file
36
wp-content/themes/twentytwentyfour/page-test1.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Standalone landing template for the page slug "test1".
|
||||
*
|
||||
* @package Twenty_Twenty_Four
|
||||
* @since Twenty Twenty-Four 1.0
|
||||
*/
|
||||
|
||||
$landing_file = ABSPATH . 'index3.html';
|
||||
$landing_html = file_exists( $landing_file ) ? file_get_contents( $landing_file ) : false;
|
||||
?><!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
<body <?php body_class( 'test1-landing-page' ); ?>>
|
||||
<?php wp_body_open(); ?>
|
||||
<?php
|
||||
if ( $landing_html && preg_match( '/<body[^>]*>(.*)<\/body>/is', $landing_html, $matches ) ) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $matches[1];
|
||||
} else {
|
||||
?>
|
||||
<main class="site-main" role="main">
|
||||
<div style="padding:48px 16px;max-width:1180px;margin:0 auto;">
|
||||
<p>Не удалось загрузить шаблон страницы `index3.html`.</p>
|
||||
</div>
|
||||
</main>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php wp_footer(); ?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user