You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.7 KiB
46 lines
1.7 KiB
<?php
|
|
|
|
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>;
|
|
|
|
class <%= blockClassModel %>_Component {
|
|
|
|
public function __construct() {
|
|
// add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ] );
|
|
add_action( 'after_setup_theme', [ $this, 'register_assets' ] );
|
|
}
|
|
|
|
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
|
|
|
|
wp_register_style( '<%= blockFilename %>',
|
|
get_template_directory_uri() . '/components/partials/<%= blockFilename %>/templates/styles/<%= blockFilename %>.min.css',
|
|
[ 'style-wp' ],
|
|
$version
|
|
);
|
|
wp_enqueue_style( '<%= blockFilename %>' );
|
|
|
|
wp_register_script( 'script-<%= blockFilename %>',
|
|
get_template_directory_uri() . '/components/partials/<%= blockFilename %>/templates/scripts/<%= blockFilename %>.min.js',
|
|
[ 'jquery', 'swiper' ],
|
|
$version,
|
|
true
|
|
);
|
|
wp_enqueue_script( 'script-<%= blockFilename %>' );
|
|
}
|
|
|
|
public function render( $args = [] ): void {
|
|
$args = array_merge( [], Helpers\<%= blockClassModel %>_Defaults::default_args( $args ), $args);
|
|
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( $args, self::class );
|
|
|
|
echo apply_filters( 'the_content', wpautop( $output ) );
|
|
}
|
|
|
|
<% if (isElementor) { %>function register_elementor_widget( $widgets_manager ): void {
|
|
require_once "helpers/<%= blockClassModel %>_Elementor_Widget.php";
|
|
$widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() );
|
|
}<% } %>
|
|
|
|
}
|
|
|
|
// ( new <%= blockClassModel %>_Component() ); // Initialization
|
|
|