acf-build #6
@@ -1,5 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
// Blocks Initialization.
|
||||
function initBlock(blockName = '', selector = '', cb) {
|
||||
document.querySelectorAll(selector).forEach((el) => cb(el));
|
||||
}
|
||||
|
||||
// Scrollbars / Frame resizes notifications.
|
||||
(function () {
|
||||
let height;
|
||||
|
||||
@@ -2,18 +2,16 @@
|
||||
|
||||
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 {
|
||||
|
||||
public function get_content( $args = [] ): string {
|
||||
$args = array_merge( Helpers\<%= blockClassModel %>_Defaults::default_args(), $args );
|
||||
$args = Helpers\<%= blockClassModel %>_API::prepare_args( $args );
|
||||
$default_args = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::default_args', [] ); // Not really practical.
|
||||
|
||||
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( array_merge( [], $args ), self::class );
|
||||
//return apply_filters( 'the_content', $output );
|
||||
return $output;
|
||||
$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 {
|
||||
@@ -37,22 +35,18 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
||||
|
||||
<% } %><% if (include_acf_block) { %> function register_acf_block() {
|
||||
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [
|
||||
'enqueue_assets' => function () {
|
||||
wp_enqueue_style( 'block-<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['assets-style'], get_blocks_version() );<% if (include_script) { %>
|
||||
wp_enqueue_script( 'block-<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version(), true );<% } %>
|
||||
},
|
||||
'default' => Helpers\<%= blockClassModel %>_Defaults::default_args(),
|
||||
'supports' => [
|
||||
//'jsx' => true,
|
||||
'color' => [
|
||||
'background' => true,
|
||||
'text' => true,
|
||||
],
|
||||
'spacing' => [
|
||||
'margin' => [ 'top', 'bottom' ],
|
||||
'padding' => [ 'top', 'bottom' ]
|
||||
],
|
||||
]
|
||||
'style_assets' => [
|
||||
[
|
||||
'name' => '<%= blockFilename %>',
|
||||
'url' => plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ),
|
||||
]
|
||||
],
|
||||
'script_assets' => [
|
||||
[
|
||||
'name' => '<%= blockFilename %>',
|
||||
'url' => plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ),
|
||||
]
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
@@ -67,13 +67,13 @@ export async function buildWordPress(blockName, isBlock = false, isElementor = f
|
||||
json: await readJSONFile(path.join(projectPath, 'data', 'default.json'), "utf8"),
|
||||
});
|
||||
|
||||
await createFiles(Object.assign({}, data, {defaultData: phpDataObject}), [{
|
||||
from: `templates/helpers/Template_Defaults.php`,
|
||||
to: `helpers/${data.blockClassModel}_Defaults.php`,
|
||||
}], {
|
||||
pathDist: distPath,
|
||||
generatorsPath: path.join(__dirname),
|
||||
});
|
||||
// await createFiles(Object.assign({}, data, {defaultData: phpDataObject}), [{
|
||||
// from: `templates/helpers/Template_Defaults.php`,
|
||||
// to: `helpers/${data.blockClassModel}_Defaults.php`,
|
||||
// }], {
|
||||
// pathDist: distPath,
|
||||
// generatorsPath: path.join(__dirname),
|
||||
// });
|
||||
|
||||
if (isElementor) {
|
||||
await createFiles(data, [{
|
||||
@@ -94,13 +94,13 @@ export async function buildWordPress(blockName, isBlock = false, isElementor = f
|
||||
generatorsPath: path.join(__dirname)
|
||||
});
|
||||
|
||||
await createFiles(data, [{
|
||||
from: `templates/helpers/Template_API.php`,
|
||||
to: `helpers/${data.blockClassModel}_API.php`,
|
||||
}], {
|
||||
pathDist: distPath,
|
||||
generatorsPath: path.join(__dirname)
|
||||
});
|
||||
// await createFiles(data, [{
|
||||
// from: `templates/helpers/Template_API.php`,
|
||||
// to: `helpers/${data.blockClassModel}_API.php`,
|
||||
// }], {
|
||||
// pathDist: distPath,
|
||||
// generatorsPath: path.join(__dirname)
|
||||
// });
|
||||
} else {
|
||||
await createFiles(data, [{
|
||||
from: `templates/Template_Basic_Component.php`,
|
||||
|
||||
Reference in New Issue
Block a user