diff --git a/build.js b/build.js index b656dbf..deb037d 100755 --- a/build.js +++ b/build.js @@ -9,7 +9,7 @@ const {isDev, developmentBlockName} = getConfigs(); const blockName = !isDev && config.has('blockName') ? config.get('blockName') : developmentBlockName; export const PLATFORM_OPTIONS = [{ - name: 'wordpress-blocks', + name: 'wordpress-acf-block', title: 'WordPress AFC Block' }, { name: 'wordpress', diff --git a/platforms/php/build.php b/platforms/php/build.php index 0e2d1d8..bb1d822 100644 --- a/platforms/php/build.php +++ b/platforms/php/build.php @@ -81,7 +81,7 @@ class Component_Builder { $template = file_get_contents( $path ); $phpStr = LightnCandy::compile( $template, [ - 'flags' => Flags::FLAG_NOESCAPE | Flags::FLAG_PARENT | Flags::FLAG_SPVARS | Flags::FLAG_ELSE | Flags::FLAG_JSLENGTH | Flags::FLAG_JSTRUE, + 'flags' => Flags::FLAG_NOESCAPE | Flags::FLAG_PARENT | Flags::FLAG_SPVARS | Flags::FLAG_ELSE | Flags::FLAG_JSLENGTH | Flags::FLAG_JSTRUE | Flags::FLAG_THIS, 'helpers' => $this->custom_handlebars ?? [], ] ); diff --git a/platforms/wordpress/templates/Template_Basic_Component.php b/platforms/wordpress/templates/Template_Basic_Component.php index 620556e..3686f8f 100644 --- a/platforms/wordpress/templates/Template_Basic_Component.php +++ b/platforms/wordpress/templates/Template_Basic_Component.php @@ -3,7 +3,8 @@ namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>; class <%= blockClassModel %>_Component <% if (isComponentManager) { %>extends \Core\Component <% } %>{ - const VERSION = '<%= version %>'; + const VERSION = '<%= version %>';<% if (isComponentManager) { %> + public $hook_prefix = 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>';<% } %> <% if (!isComponentManager) { %>public function __construct() { // add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ] ); @@ -15,10 +16,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 { @@ -39,4 +42,5 @@ class <%= blockClassModel %>_Component <% if (isComponentManager) { %>extends \C } -<%= blockClassModel %>_Component::get_instance(); +<% if (isComponentManager) { %><%= blockClassModel %>_Component::get_instance();<% } else { + %>new <%= blockClassModel %>_Component();<% } %> diff --git a/platforms/wordpress/templates/Template_Component.php b/platforms/wordpress/templates/Template_Component.php index 3e98e8d..14ab8cb 100644 --- a/platforms/wordpress/templates/Template_Component.php +++ b/platforms/wordpress/templates/Template_Component.php @@ -4,6 +4,7 @@ namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>; class <%= blockClassModel %>_Component extends \Core\Component { const VERSION = '<%= version %>'; + public $hook_prefix = 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>'; public function get_content( $args = [] ): string { $default_args = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::default_args', [] ); // Not really practical.