7 changed files with 43 additions and 170 deletions
@ -1,62 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>; |
|||
|
|||
class <%= blockClassModel %>_Component extends \Core\Component { |
|||
const VERSION = '<%= version %>'; |
|||
public $block_project = '<%= ownerFilename %>'; |
|||
public $block_name = '<%= blockFilename %>'; |
|||
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. |
|||
|
|||
$args = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::prepare_args', array_merge( $default_args, $args ) ); |
|||
|
|||
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( $args, self::class ); |
|||
|
|||
return apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::content', $output ); |
|||
} |
|||
<% if (!include_acf_block && !include_native_gutenberg_block) { %>function register_assets(): void { |
|||
$version = get_plugin_data( __DIR__ . "/../../scytale-custom-blocks.php" )['Version']; // In Plugins |
|||
// $version = \Core\Global_Functions::get_current_version_number(); // In Theme |
|||
|
|||
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/'; |
|||
wp_enqueue_style( 'block-<%= blockFilename %>', $this->get_assets_path_url( 'templates/styles/<%= blockFilename %>.min.css' ), ['assets-style'], self::VERSION );<% if (include_script) { %> |
|||
wp_enqueue_script( 'block-<%= blockFilename %>', $this->get_assets_path_url( 'templates/scripts/<%= blockFilename %>.min.js' ), ['assets-script'], self::VERSION, true );<% } %> |
|||
|
|||
wp_enqueue_script( 'script-block-<%= blockFilename %>' ); |
|||
}<% } %> |
|||
<% if (include_acf_block) { %> function register_acf_block() { |
|||
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [ |
|||
'style_assets' => [ |
|||
[ |
|||
'name' => '<%= blockFilename %>', |
|||
'url' => $this->get_assets_path_url( 'templates/styles/<%= blockFilename %>.min.css' ), |
|||
] |
|||
], |
|||
'script_assets' => [ |
|||
[ |
|||
'name' => '<%= blockFilename %>', |
|||
'url' => $this->get_assets_path_url( 'templates/scripts/<%= blockFilename %>.min.js' ), |
|||
] |
|||
] |
|||
] ); |
|||
} |
|||
<% } %><% if (include_native_gutenberg_block) { %> function register_native_gutenberg_block() { |
|||
register_block_type( __DIR__ . '/templates/gutenberg-block/block.json' );<% if (include_script) { %> |
|||
|
|||
add_action( 'wp_enqueue_scripts', function () { |
|||
$asset_file_front = include( plugin_dir_path( __FILE__ ) . '/templates/gutenberg-block/build/front.asset.php' ); |
|||
wp_enqueue_script( |
|||
'gutenberg-<%= blockFilename %>-scripts-front', |
|||
$this->get_assets_path_url( 'templates/gutenberg-block/build/front.js' ), |
|||
$asset_file_front['dependencies'], |
|||
$asset_file_front['version'], |
|||
true |
|||
); |
|||
} );<% } %> |
|||
}<% } %> |
|||
} |
|||
|
|||
<%= blockClassModel %>_Component::get_instance(); |
|||
@ -1,14 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>\Helpers; |
|||
|
|||
class <%= blockClassModel %>_API { |
|||
|
|||
static function prepare_args( $args = [] ) { |
|||
|
|||
// $args = array_merge( [], $args ); |
|||
|
|||
return $args; |
|||
} |
|||
|
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>\Helpers; |
|||
|
|||
/** |
|||
* Component's default args. |
|||
*/ |
|||
|
|||
class <%= blockClassModel %>_Defaults { |
|||
public static function default_args(): array { |
|||
$args = <%- defaultData %>; |
|||
|
|||
// $args['base_url'] = \Core\Global_Functions::get_file_url( __DIR__ . '/../templates/' ); |
|||
|
|||
return $args; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue