injectDependency();
}
if ( $this->is_compatible() ) {
add_action( 'elementor/init', [ $this, 'init' ] );
if (defined('ASEPRO_DIR_FILE')) {
if (!class_exists(AdvancedSliderPro\Services\AdvancedSliderWidgetPro::class)) {
require_once(ASEPRO_DIR_PATH.'Services/slider-widget.php');
}
}
}
}
/**
* Initialize the plugin
*
* Load the plugin only after Elementor (and other plugins) are loaded.
* Load the files required to run the plugin.
*
* Fired by `plugins_loaded` action hook.
*
* @since 2.0.1
*
* @access public
*/
public function init() {
include('load.php');
$this->loadTextDomain();
if ( is_admin() ) {
$this->adminHooks();
}
// Add Plugin actions
add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
add_action('elementor/frontend/after_enqueue_styles', function() {
wp_enqueue_style( 'ase-swiper-css', plugin_dir_url( __FILE__ ). 'assets/css/ase-slider.css', array(), ASE_PLUGIN_VERSION);
});
add_action('elementor/editor/after_enqueue_styles', function() {
wp_enqueue_style( 'ase-editor-css', plugin_dir_url( __FILE__ ). 'assets/css/ase-editor.css', array(), ASE_PLUGIN_VERSION);
});
// after_enqueue_scripts
add_action('elementor/frontend/after_enqueue_scripts', function() {
wp_enqueue_script( 'ase-swiper-js', plugin_dir_url( __FILE__ ). 'assets/js/ase-slider.js', array('jquery'), ASE_PLUGIN_VERSION, false);
wp_localize_script('ase-swiper-js', 'aseSwiperVar', array(
'has_pro' => defined('ADVANCED_SLIDER_PRO')
));
});
}
public function adminHooks() {
add_action( 'admin_enqueue_scripts', array($this, 'enqueueScripts') );
if (defined('ADVANCED_SLIDER_PRO')) {
add_action('wp_ajax_ase_pro_lincese_ajax_actions', function() {
$licenseController = new AdvancedSliderPro\Classes\LicenseController();
$licenseController->handleAjaxCalls();
});
}
add_action('wp_ajax_ase_pro_setup_addons', function() {
$setupController = new AdvancedSliderLite\Classes\SetupController();
$setupController->handleAjaxCalls();
});
if (defined('ELEMENTOR_VERSION')) {
add_action('admin_init', [new AdvancedSliderLite\Classes\AdminPageHandler(), 'initialLoad']);
}
add_filter( 'plugin_action_links_'.ASE_PLUGIN_FILE_PATH, [$this, 'asePluginAction'], 10, 1 );
add_action( 'admin_notices', [$this, 'ase_admin_Notice'] );
add_action( 'admin_init', [$this, 'ase_notice_dismissed'] );
}
/**
* Notify the user about the Advanced Pricing Table dependency and instructs to install it.
*/
protected function injectDependency()
{
add_action('admin_notices', function () {
$pluginInfo = $this->getInstallationDetails();
$class = 'notice notice-error';
$install_url_text = 'Click Here to Install the Plugin';
if ($pluginInfo->action == 'activate') {
$install_url_text = 'Click Here to Activate the Plugin';
}
$message = 'Advanced Slider For Elementor Add-On Requires Elementor Base Plugin, ' . $install_url_text . '';
printf('
', esc_attr($class), wp_kses_post($message));
});
}
/**
* Get the Advanced Pricing Table plugin installation information e.g. the URL to install.
*
* @return \stdClass $activation
*/
protected function getInstallationDetails()
{
$activation = (object)[
'action' => 'install',
'url' => ''
];
$allPlugins = get_plugins();
if (isset($allPlugins['elementor/elementor.php'])) {
$url = wp_nonce_url(
self_admin_url('plugins.php?action=activate&plugin=elementor/elementor.php'),
'activate-plugin_elementor/elementor.php'
);
$activation->action = 'activate';
} else {
$api = (object)[
'slug' => 'elementor'
];
$url = wp_nonce_url(
self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug),
'install-plugin_' . $api->slug
);
}
$activation->url = $url;
return $activation;
}
public function asePluginAction($links) {
$newLink = [
'' .esc_html__('Settings', 'advanced-slider-for-elementor'). ''
];
if (!defined('ADVANCED_SLIDER_PRO')) {
$goPro = wp_kses_post('' .esc_html__('Go Pro', 'advanced-slider-for-elementor'). '');
array_push($newLink, $goPro);
}
return array_merge($links, $newLink);
}
public function ase_admin_Notice() {
$screen = get_current_screen();
$user_id = get_current_user_id();
$nonce = wp_create_nonce('ase_dismiss_notice_nonce');
// Ensure user meta exists
if (!get_user_meta($user_id, 'ase-notice-dismissed', true)) {
add_user_meta($user_id, 'ase-notice-dismissed', 'active');
}
// Show notice only on specific screens
if ($screen && in_array($screen->id, ['dashboard', 'plugins'], true)) {
if (get_user_meta($user_id, 'ase-notice-dismissed', true) === 'active') {
?>
=' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
return false;
}
// Check for required PHP version
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
return false;
}
return true;
}
public static function enqueueScripts()
{
wp_enqueue_style( 'ase-admin-css', ASE_PLUGIN_URL.'assets/css/ase-admin.css', array(), ASE_PLUGIN_VERSION);
wp_enqueue_script( 'ase-admin-js', ASE_PLUGIN_URL.'assets/js/ase-admin.js', array('jquery'), ASE_PLUGIN_VERSION, true);
wp_localize_script('ase-admin-js', 'aseProVar', [
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'has_pro' => defined('ADVANCED_SLIDER_PRO'),
'nonce' => wp_create_nonce('ase_nonce')
]);
}
/**
* Init Widgets
*
* Include widgets files and register them
*
* @since 2.0.1
*
* @access public
*/
public function init_widgets() {
// Include Widget files
require_once( __DIR__ . '/widgets/slider-widget.php' );
// Register widget
\Elementor\Plugin::instance()->widgets_manager->register( new AdvancedSliderLite\Widgets\AdvancedSliderLiteWidget() );
}
public function loadTextDomain()
{
load_plugin_textdomain('advanced-slider-for-elementor', false, basename(dirname(__FILE__)) . '/languages');
}
/**
* Admin notice
*
* Warning when the site doesn't have Elementor installed or activated.
*
* @since 2.0.1
*
* @access public
*/
public function admin_notice_missing_main_plugin() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin name 2: Elementor */
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'advanced-slider-for-elementor' ),
'' . esc_html__( 'Advanced Slider for Elementor', 'advanced-slider-for-elementor' ) . '',
'' . esc_html__( 'Elementor', 'advanced-slider-for-elementor' ) . ''
);
printf( '', wp_kses_post($message) );
}
/**
* Admin notice
*
* Warning when the site doesn't have a minimum required Elementor version.
*
* @since 2.0.1
*
* @access public
*/
public function admin_notice_minimum_elementor_version() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'advanced-slider-for-elementor' ),
'' . esc_html__( 'Advanced Slider for Elementor', 'advanced-slider-for-elementor' ) . '',
'' . esc_html__( 'Elementor', 'advanced-slider-for-elementor' ) . '',
self::MINIMUM_ELEMENTOR_VERSION
);
printf( '', wp_kses_post($message) );
}
/**
* Admin notice
*
* Warning when the site doesn't have a minimum required PHP version.
*
* @since 2.0.1
*
* @access public
*/
public function admin_notice_minimum_php_version() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin name 2: PHP 3: Required PHP version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'advanced-slider-for-elementor' ),
'' . esc_html__( 'Advanced Slider for Elementor', 'advanced-slider-for-elementor' ) . '',
'' . esc_html__( 'PHP', 'advanced-slider-for-elementor' ) . '',
self::MINIMUM_PHP_VERSION
);
printf( '', wp_kses_post($message));
}
}
ASESliderLite::instance();
function aseDeactivatePlugin() {
$user_id = get_current_user_id();
update_user_meta($user_id, 'ase-notice-dismissed', 'active');
}
register_deactivation_hook( __FILE__, 'aseDeactivatePlugin' );