From ddbc713603c8b9a8fcba6564fa4645dabf3206fa Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Sat, 10 Dec 2022 12:59:26 +0200 Subject: [PATCH] Add scripts/styling to the page only on frontend side. (not in admin panel). --- .../wordpress/templates/Template_Basic_Component.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platforms/wordpress/templates/Template_Basic_Component.php b/platforms/wordpress/templates/Template_Basic_Component.php index 3e262c6..ffe2cc2 100644 --- a/platforms/wordpress/templates/Template_Basic_Component.php +++ b/platforms/wordpress/templates/Template_Basic_Component.php @@ -15,10 +15,12 @@ class <%= blockClassModel %>_Component <% if (isComponentManager) { %>extends \C // $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/'; // In Theme wp_register_style( 'block-<%= blockFilename %>', $base_path . 'templates/styles/<%= blockFilename %>.min.css', [ 'assets-style' ], self::VERSION ); - wp_enqueue_style( 'block-<%= blockFilename %>' ); - wp_register_script( 'block-<%= blockFilename %>', $base_path . 'templates/scripts/<%= blockFilename %>.min.js', [ 'assets-script' ], self::VERSION, true ); - wp_enqueue_script( 'block-<%= blockFilename %>' ); + + if ( ! is_admin() ) { + wp_enqueue_style( 'block-<%= blockFilename %>' ); + wp_enqueue_script( 'block-<%= blockFilename %>' ); + } } public function get_content( $args = [] ): string {