Add Elementor event loop preset library and separate releases
This commit is contained in:
76
addons/eventlabs-loop-builder/eventlabs-loop-builder.php
Normal file
76
addons/eventlabs-loop-builder/eventlabs-loop-builder.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: eventLabs Loop Builder
|
||||
* Description: Design reusable Elementor event cards and display eventLabs events in grids, lists, and carousels.
|
||||
* Version: 0.2.0
|
||||
* Requires at least: 6.9
|
||||
* Requires PHP: 8.1
|
||||
* Requires Plugins: burn-events, elementor
|
||||
* Author: hostLabs
|
||||
* Update URI: https://git.labs.casa/josh/eventLabs/src/branch/main/addons/eventlabs-loop-builder
|
||||
* Text Domain: eventlabs-loop-builder
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace EventLabs\LoopBuilder;
|
||||
|
||||
use BurnEvents\Events;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
const VERSION = '0.2.0';
|
||||
const FILE = __FILE__;
|
||||
const ASSET = 'eventlabs-loop-builder';
|
||||
const CORE_MINIMUM = '0.5.8';
|
||||
const ELEMENTOR_MINIMUM = '3.27.0';
|
||||
|
||||
add_action( 'plugins_loaded', static function (): void {
|
||||
$core_ready = defined( 'BURN_EVENTS_VERSION' ) && version_compare( BURN_EVENTS_VERSION, CORE_MINIMUM, '>=' ) && class_exists( Events::class );
|
||||
$elementor_ready = defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, ELEMENTOR_MINIMUM, '>=' ) && did_action( 'elementor/loaded' );
|
||||
if ( ! $core_ready || ! $elementor_ready ) {
|
||||
add_action( 'admin_notices', static function (): void {
|
||||
if ( current_user_can( 'activate_plugins' ) ) {
|
||||
printf(
|
||||
'<div class="notice notice-warning"><p>%s</p></div>',
|
||||
esc_html( sprintf(
|
||||
/* translators: 1: minimum eventLabs version; 2: minimum Elementor version */
|
||||
__( 'eventLabs Loop Builder requires eventLabs %1$s or later and Elementor %2$s or later. Activate or update both plugins to use the builder.', 'eventlabs-loop-builder' ),
|
||||
CORE_MINIMUM,
|
||||
ELEMENTOR_MINIMUM
|
||||
) )
|
||||
);
|
||||
}
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/includes/class-card.php';
|
||||
require_once __DIR__ . '/includes/class-presets.php';
|
||||
require_once __DIR__ . '/includes/class-query.php';
|
||||
require_once __DIR__ . '/includes/class-templates.php';
|
||||
require_once __DIR__ . '/includes/class-library.php';
|
||||
|
||||
Templates::register();
|
||||
Library::register();
|
||||
|
||||
add_action( 'init', static function (): void {
|
||||
wp_register_style( ASSET, plugins_url( 'assets/loop.css', FILE ), [], VERSION );
|
||||
wp_register_style( ASSET . '-presets', plugins_url( 'assets/presets.css', FILE ), [ ASSET ], VERSION );
|
||||
wp_register_script( ASSET, plugins_url( 'assets/loop.js', FILE ), [ 'elementor-frontend' ], VERSION, [ 'in_footer' => true, 'strategy' => 'defer' ] );
|
||||
} );
|
||||
|
||||
add_action( 'elementor/widgets/register', static function ( \Elementor\Widgets_Manager $widgets ): void {
|
||||
require_once __DIR__ . '/includes/class-widgets.php';
|
||||
$widgets->register( new Loop_Widget() );
|
||||
$widgets->register( new Field_Widget() );
|
||||
} );
|
||||
|
||||
add_action( 'elementor/dynamic_tags/register', static function ( \Elementor\Core\DynamicTags\Manager $tags ): void {
|
||||
require_once __DIR__ . '/includes/class-tags.php';
|
||||
$tags->register_group( ASSET, [ 'title' => __( 'eventLabs Event Loop', 'eventlabs-loop-builder' ) ] );
|
||||
$tags->register( new Field_Tag() );
|
||||
$tags->register( new Link_Tag() );
|
||||
$tags->register( new Image_Tag() );
|
||||
} );
|
||||
}, 20 );
|
||||
Reference in New Issue
Block a user