Add scripts/styling to the page only on frontend side. (not in admin panel).
This commit is contained in:
@@ -15,11 +15,13 @@ class <%= blockClassModel %>_Component <% if (isComponentManager) { %>extends \C
|
|||||||
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/'; // In Theme
|
// $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_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_register_script( 'block-<%= blockFilename %>', $base_path . 'templates/scripts/<%= blockFilename %>.min.js', [ 'assets-script' ], self::VERSION, true );
|
||||||
|
|
||||||
|
if ( ! is_admin() ) {
|
||||||
|
wp_enqueue_style( 'block-<%= blockFilename %>' );
|
||||||
wp_enqueue_script( 'block-<%= blockFilename %>' );
|
wp_enqueue_script( 'block-<%= blockFilename %>' );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function get_content( $args = [] ): string {
|
public function get_content( $args = [] ): string {
|
||||||
$default_args = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::default_args', [] ); // Not really practical.
|
$default_args = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::default_args', [] ); // Not really practical.
|
||||||
|
|||||||
Reference in New Issue
Block a user