Update build of ACF blocks.
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>;
|
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>;
|
||||||
|
|
||||||
|
include_once __DIR__ . "/helpers/<%= blockClassModel %>_Defaults.php";
|
||||||
|
include_once __DIR__ . "/helpers/<%= blockClassModel %>_API.php";
|
||||||
|
|
||||||
class <%= blockClassModel %>_Component extends \Core\Component {
|
class <%= blockClassModel %>_Component extends \Core\Component {
|
||||||
|
|
||||||
public function get_content( $args = [] ): string {
|
public function get_content( $args = [] ): string {
|
||||||
@@ -9,7 +12,7 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
|||||||
$args = Helpers\<%= blockClassModel %>_API::prepare_args( $args );
|
$args = Helpers\<%= blockClassModel %>_API::prepare_args( $args );
|
||||||
|
|
||||||
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( array_merge( [], $args ), self::class );
|
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( array_merge( [], $args ), self::class );
|
||||||
return apply_filters( 'the_content', wpautop( $output ) );
|
return apply_filters( 'the_content', $output );
|
||||||
}
|
}
|
||||||
|
|
||||||
<% if (!include_acf_block && !include_native_gutenberg_block) { %>function register_assets(): void {
|
<% if (!include_acf_block && !include_native_gutenberg_block) { %>function register_assets(): void {
|
||||||
@@ -17,8 +20,8 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
|||||||
// $version = \Core\Global_Functions::get_current_version_number(); // In Theme
|
// $version = \Core\Global_Functions::get_current_version_number(); // In Theme
|
||||||
|
|
||||||
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/';
|
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/';
|
||||||
wp_enqueue_style( '<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['wp-block-library'], get_blocks_version() );<% if (include_script) { %>
|
wp_enqueue_style( '<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['assets-style'], get_blocks_version() );<% if (include_script) { %>
|
||||||
wp_enqueue_script( '<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version() );<% } %>
|
wp_enqueue_script( '<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version(), true );<% } %>
|
||||||
|
|
||||||
wp_enqueue_script( 'script-<%= blockFilename %>' );
|
wp_enqueue_script( 'script-<%= blockFilename %>' );
|
||||||
}<% } %>
|
}<% } %>
|
||||||
@@ -34,8 +37,8 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
|||||||
<% } %><% if (include_acf_block) { %> function register_acf_block() {
|
<% } %><% if (include_acf_block) { %> function register_acf_block() {
|
||||||
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [
|
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [
|
||||||
'enqueue_assets' => function () {
|
'enqueue_assets' => function () {
|
||||||
wp_enqueue_style( '<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['wp-block-library'], get_blocks_version() );<% if (include_script) { %>
|
wp_enqueue_style( '<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['assets-style'], get_blocks_version() );<% if (include_script) { %>
|
||||||
wp_enqueue_script( '<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version() );<% } %>
|
wp_enqueue_script( '<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version(), true );<% } %>
|
||||||
},
|
},
|
||||||
'default' => Helpers\<%= blockClassModel %>_Defaults::default_args(),
|
'default' => Helpers\<%= blockClassModel %>_Defaults::default_args(),
|
||||||
'supports' => [
|
'supports' => [
|
||||||
@@ -68,3 +71,5 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
|||||||
}<% } %>
|
}<% } %>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<%= blockClassModel %>_Component::get_instance();
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export async function buildWordPress(blockName, isBlock = false, isElementor = f
|
|||||||
await mkdir(path.join(distPath, 'templates'), {recursive: true})
|
await mkdir(path.join(distPath, 'templates'), {recursive: true})
|
||||||
|
|
||||||
const blockFilePath = path.join(projectPath, 'block.json');
|
const blockFilePath = path.join(projectPath, 'block.json');
|
||||||
await copyFile(blockFilePath, path.join(distPath, 'block.json'));
|
|
||||||
|
|
||||||
let data = await readJSONFile(blockFilePath);
|
let data = await readJSONFile(blockFilePath);
|
||||||
Object.assign(data, getBlockName(data.name));
|
Object.assign(data, getBlockName(data.name));
|
||||||
@@ -41,6 +40,8 @@ export async function buildWordPress(blockName, isBlock = false, isElementor = f
|
|||||||
isElementor,
|
isElementor,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await copyFile(blockFilePath, path.join(distPath, data.blockFilename + '.block.json'));
|
||||||
|
|
||||||
const backPath = modulesPath ? modulesPath.split('/').map(() => '..').join('/') : '';
|
const backPath = modulesPath ? modulesPath.split('/').map(() => '..').join('/') : '';
|
||||||
|
|
||||||
const phpGeneratorPath = path.join(modulesPath, 'platforms', 'php');
|
const phpGeneratorPath = path.join(modulesPath, 'platforms', 'php');
|
||||||
|
|||||||
Reference in New Issue
Block a user