Browse Source

Merge branch 'master' into project-path-feat

test-gpt-generated
Roman Axelrod 3 years ago
parent
commit
c627c873f9
  1. 2
      build.js
  2. 2
      platforms/php/build.php
  3. 12
      platforms/wordpress/templates/Template_Basic_Component.php
  4. 1
      platforms/wordpress/templates/Template_Component.php

2
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',

2
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 ?? [],
]
);

12
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,11 +16,13 @@ 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 );
if ( ! is_admin() ) {
wp_enqueue_style( 'block-<%= blockFilename %>' );
wp_enqueue_script( 'block-<%= blockFilename %>' );
}
}
public function get_content( $args = [] ): string {
$default_args = apply_filters( 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>::default_args', [] ); // Not really practical.
@ -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();<% } %>

1
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.

Loading…
Cancel
Save