|
|
@ -2,19 +2,13 @@ |
|
|
|
|
|
|
|
|
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>; |
|
|
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>; |
|
|
|
|
|
|
|
|
class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor) { %>extends \Core\Component <% } %>{ |
|
|
class <%= blockClassModel %>_Component extends \Core\Component { |
|
|
const VERSION = '<%= version %>'; |
|
|
const VERSION = '<%= version %>'; |
|
|
public $block_project = '<%= ownerFilename %>'; |
|
|
public $block_project = '<%= ownerFilename %>'; |
|
|
public $block_name = '<%= blockFilename %>'; |
|
|
public $block_name = '<%= blockFilename %>'; |
|
|
public $hook_prefix = 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>'; |
|
|
public $hook_prefix = 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>'; |
|
|
|
|
|
|
|
|
<% if (!isComponentManager && !isElementor) { %>public function __construct() { |
|
|
function register_assets(): void { |
|
|
parent::__construct(); |
|
|
|
|
|
// add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ] ); |
|
|
|
|
|
add_action( 'after_setup_theme', [ $this, 'register_assets' ] ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
<% } %>function register_assets(): void { |
|
|
|
|
|
$base_path = plugin_dir_url( __FILE__ ); // In Plugins |
|
|
$base_path = plugin_dir_url( __FILE__ ); // In Plugins |
|
|
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/'; // In Theme |
|
|
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/'; // In Theme |
|
|
|
|
|
|
|
|
@ -22,12 +16,14 @@ class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor) |
|
|
wp_register_style( 'block-<%= blockFilename %>', $base_path . 'templates/styles/<%= blockFilename %>.min.css', $style_deps, self::VERSION ); |
|
|
wp_register_style( 'block-<%= blockFilename %>', $base_path . 'templates/styles/<%= blockFilename %>.min.css', $style_deps, self::VERSION ); |
|
|
|
|
|
|
|
|
$script_deps = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::script_deps', [ 'assets-script' ] ); |
|
|
$script_deps = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::script_deps', [ 'assets-script' ] ); |
|
|
wp_register_script( 'block-<%= blockFilename %>', $base_path . 'templates/scripts/<%= blockFilename %>.min.js', $script_deps, self::VERSION, true );<% if (!isElementor) { %> |
|
|
wp_register_script( 'block-<%= blockFilename %>', $base_path . 'templates/scripts/<%= blockFilename %>.min.js', $script_deps, self::VERSION, true ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function prepare_for_print() { |
|
|
if ( ! is_admin() ) { |
|
|
if ( ! is_admin() ) { |
|
|
wp_enqueue_style( 'block-<%= blockFilename %>' ); |
|
|
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 { |
|
|
@ -38,7 +34,7 @@ class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor) |
|
|
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( $args, self::class ); |
|
|
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( $args, self::class ); |
|
|
|
|
|
|
|
|
return apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::content', $output ); |
|
|
return apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::content', $output ); |
|
|
}<% if (isElementor) { %> |
|
|
} |
|
|
|
|
|
|
|
|
function register_custom_logic(): void { |
|
|
function register_custom_logic(): void { |
|
|
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_elementor_widget' ] ); |
|
|
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_elementor_widget' ] ); |
|
|
@ -47,9 +43,25 @@ class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor) |
|
|
function register_elementor_widget( $widgets_manager ): void { |
|
|
function register_elementor_widget( $widgets_manager ): void { |
|
|
require_once "helpers/<%= blockClassModel %>_Elementor_Widget.php"; |
|
|
require_once "helpers/<%= blockClassModel %>_Elementor_Widget.php"; |
|
|
$widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() ); |
|
|
$widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() ); |
|
|
}<% } %> |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function register_acf_block() { |
|
|
|
|
|
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [ |
|
|
|
|
|
'style_assets' => [ |
|
|
|
|
|
[ |
|
|
|
|
|
'name' => 'block-<%= blockFilename %>', |
|
|
|
|
|
'url' => $this->get_assets_path_url( 'templates/styles/<%= blockFilename %>.min.css' ), |
|
|
|
|
|
] |
|
|
|
|
|
], |
|
|
|
|
|
'script_assets' => [ |
|
|
|
|
|
[ |
|
|
|
|
|
'name' => 'block-<%= blockFilename %>', |
|
|
|
|
|
'url' => $this->get_assets_path_url( 'templates/scripts/<%= blockFilename %>.min.js' ), |
|
|
|
|
|
] |
|
|
|
|
|
] |
|
|
|
|
|
] ); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
<% if (isComponentManager) { %><%= blockClassModel %>_Component::get_instance();<% } else { |
|
|
<%= blockClassModel %>_Component::get_instance(); |
|
|
%>new <%= blockClassModel %>_Component();<% } %> |
|
|
// new <%= blockClassModel %>_Component(); |
|
|
|