256 lines
10 KiB
PHP
256 lines
10 KiB
PHP
<?php
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit; // Exit if accessed directly.
|
|
}
|
|
|
|
final class Attesa_Extra_Elementor_Extensions {
|
|
private static $_instance;
|
|
|
|
/**
|
|
* Plugin instance
|
|
*
|
|
* @since 1.0.0
|
|
* @return Plugin
|
|
*/
|
|
public static function instance() {
|
|
|
|
if ( is_null( self::$_instance ) ) {
|
|
self::$_instance = new self();
|
|
}
|
|
return self::$_instance;
|
|
|
|
}
|
|
|
|
public function __clone() {
|
|
// Cloning instances of the class is forbidden
|
|
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'attesa-extra' ), '1.0.0' );
|
|
}
|
|
|
|
public function __wakeup() {
|
|
// Unserializing instances of the class is forbidden
|
|
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'attesa-extra' ), '1.0.0' );
|
|
}
|
|
|
|
/**
|
|
* Widget constructor.
|
|
*
|
|
*
|
|
* @since 1.0.0
|
|
* @access public
|
|
*/
|
|
public function __construct() {
|
|
add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_elementor_widgets' ) );
|
|
add_action( 'elementor/elements/categories_registered', array( $this, 'register_elementor_widget_categories' ) );
|
|
add_action( 'elementor/frontend/after_register_scripts', array( $this, 'widget_scripts' ) );
|
|
add_action( 'elementor/frontend/after_register_styles', array( $this, 'widget_styles' ) );
|
|
add_action( 'elementor/preview/enqueue_scripts', array( $this, 'widget_scripts_preview' ) );
|
|
add_action( 'elementor/preview/enqueue_styles', array( $this, 'widget_style_preview' ) );
|
|
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_style' ) );
|
|
if ( !class_exists( 'Attesa_pro' ) ) {
|
|
add_action( 'elementor/frontend/after_enqueue_scripts', array( $this, 'enqueue_editor_scripts_promotional' ) );
|
|
add_filter( 'elementor/editor/localize_settings', array( $this, 'promote_pro_addons' ) );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Registers widgets in Elementor
|
|
*
|
|
*
|
|
* @since 1.0.0
|
|
* @access public
|
|
*/
|
|
public function register_elementor_widgets() {
|
|
require_once AE_PATH . '/elementor/widgets/navigation-menu.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Navigation_Menu() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/site-logo.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Site_Logo() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/site-social-buttons.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Site_Social_Buttons() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/posts-carousel.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Posts_Carousel() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/divider.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Divider() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/heading-typewriter.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Heading_Typewriter() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/alert-message.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Alert_Message() );
|
|
|
|
require_once AE_PATH . '/elementor/widgets/double-button.php';
|
|
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Attesa_Extra_Double_Button() );
|
|
}
|
|
|
|
public function register_elementor_widget_categories() {
|
|
\Elementor\Plugin::instance()->elements_manager->add_category(
|
|
'attesa-elements',
|
|
array(
|
|
'title' => __( 'Attesa Theme Addons', 'attesa-extra' ),
|
|
'icon' => 'fa fa-plug',
|
|
),
|
|
1 );
|
|
}
|
|
|
|
public function widget_scripts() {
|
|
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
|
wp_register_script('typed', plugins_url('elementor/js/typed'.$min.'.js',dirname(__FILE__)), array('jquery'),'1.1.4',true);
|
|
wp_register_script('awp-alert', plugins_url('elementor/js/alert'.$min.'.js',dirname(__FILE__)), array('jquery'),ATTESA_EXTRA_PLUGIN_VERSION,true);
|
|
}
|
|
|
|
public function widget_scripts_preview() {
|
|
wp_enqueue_script( 'typed' );
|
|
wp_enqueue_script( 'awp-alert' );
|
|
}
|
|
|
|
public function widget_styles() {
|
|
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
|
wp_register_style( 'awp-double-button', plugins_url( '/elementor/css/double-button'.$min.'.css', dirname(__FILE__)), array(), ATTESA_EXTRA_PLUGIN_VERSION);
|
|
}
|
|
|
|
public function widget_style_preview() {
|
|
wp_enqueue_style( 'awp-elementor-editor', plugins_url( 'elementor/css/fix-preview.min.css',dirname(__FILE__)), array(), ATTESA_EXTRA_PLUGIN_VERSION );
|
|
wp_enqueue_style( 'awp-double-button' );
|
|
}
|
|
|
|
public function editor_style() {
|
|
wp_enqueue_style( 'awp-elementor-editor', plugins_url( 'elementor/css/editor.min.css',dirname(__FILE__)), array(), ATTESA_EXTRA_PLUGIN_VERSION );
|
|
}
|
|
|
|
public function enqueue_editor_scripts_promotional() {
|
|
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
|
|
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
|
wp_enqueue_script( 'awp-promotion', plugins_url('elementor/js/promotion'.$min.'.js',dirname(__FILE__)), array('jquery'), ATTESA_EXTRA_PLUGIN_VERSION, true );
|
|
$attesa_extra_array_promotion = array(
|
|
'conversionString' => esc_html__( 'Upgrade to Attesa PRO', 'attesa-extra' ),
|
|
);
|
|
wp_localize_script( 'awp-promotion', 'AttesaExtraElementorPromotion', $attesa_extra_array_promotion );
|
|
}
|
|
}
|
|
|
|
public function promote_pro_addons($config) {
|
|
$promotion_widgets = [];
|
|
|
|
if (isset($config['promotionWidgets'])) {
|
|
$promotion_widgets = $config['promotionWidgets'];
|
|
}
|
|
|
|
$combine_array = array_merge($promotion_widgets, [
|
|
[
|
|
'name' => 'attesa-pro-scroll-to-next-section',
|
|
'title' => __('Scroll to next section', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-arrow-down',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-tilt-effect',
|
|
'title' => __('Tilt Effect', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-clone',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-posts-carousel-pro',
|
|
'title' => __('Posts Carousel', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-post-slider',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-pricing-table',
|
|
'title' => __('Pricing Table', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-price-table',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-image-hotspots',
|
|
'title' => __('Image Hotspots', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-image-hotspot',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-onepage-navigation',
|
|
'title' => __('Onepage Navigation', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-navigation-vertical',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-stylize-every-word',
|
|
'title' => __('Stylize every word', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-text-area',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-price-list',
|
|
'title' => __('Price List', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-price-list',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-filterable-gallery',
|
|
'title' => __('Filterable Gallery', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-gallery-masonry',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-page-scroll-progress',
|
|
'title' => __('Page Scroll Progress', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-scroll',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-image-compare',
|
|
'title' => __('Image Compare', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-image-before-after',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-offcanvas',
|
|
'title' => __('Offcanvas', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-column',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-step-by-step',
|
|
'title' => __('Step by step', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-h-align-right',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-ajax-search',
|
|
'title' => __('Ajax Search', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-site-search',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-content-timeline',
|
|
'title' => __('Content Timeline', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-time-line',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-content-behind-background',
|
|
'title' => __('Content behind background', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-navigator',
|
|
'categories' => '["attesa-elements"]',
|
|
],
|
|
[
|
|
'name' => 'attesa-pro-switch',
|
|
'title' => __('Switch', 'attesa-extra'),
|
|
'icon' => 'awp-pro-addons awp-icon eicon-dual-button',
|
|
'categories' => '["attesa-elements"]',
|
|
]
|
|
]);
|
|
|
|
$config['promotionWidgets'] = $combine_array;
|
|
|
|
return $config;
|
|
}
|
|
|
|
}
|
|
function attesa_extra_elementor_widgets() {
|
|
return Attesa_Extra_Elementor_Extensions::instance();
|
|
}
|
|
|
|
attesa_extra_elementor_widgets(); |