is_compatible() ) return false;
//Classic elementor addon shortcodes
add_action( 'init', array( $this, 'init_addons' ), 20 );
// Elementor init
add_action('elementor/init', [ $this, 'add_hooks' ]);
// Plugin ajax calls
$this->aiea_ajax_calls();
// Templates library
$this->load_library_templates();
//Load text domain
$this->load_domain();
// Modules
$this->aiea_modules();
}
public function is_compatible(){
// Check if Elementor installed and activated
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
return false;
}
// Check for required Elementor version
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
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;
}
/**
* Admin notice
*
* Warning when the site doesn't have Elementor installed or activated.
*
* @since 1.0.0
*
* @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.', 'ai-addons' ),
'' . esc_html__( 'AI Addons', 'ai-addons' ) . '',
'' . esc_html__( 'Elementor', 'ai-addons' ) . ''
);
printf( '
', $message );
}
/**
* Admin notice
*
* Warning when the site doesn't have a minimum required Elementor version.
*
* @since 1.0.0
*
* @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.', 'ai-addons' ),
'' . esc_html__( 'AI Addons', 'ai-addons' ) . '',
'' . esc_html__( 'Elementor', 'ai-addons' ) . '',
self::MINIMUM_ELEMENTOR_VERSION
);
printf( '', $message );
}
/**
* Admin notice
*
* Warning when the site doesn't have a minimum required PHP version.
*
* @since 1.0.0
*
* @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.', 'ai-addons' ),
'' . esc_html__( 'AI Addons', 'ai-addons' ) . '',
'' . esc_html__( 'PHP', 'ai-addons' ) . '',
self::MINIMUM_PHP_VERSION
);
printf( '', $message );
}
public function add_hooks(){
require_once ( AIEA_DIR . 'includes/modules/section.php' );
}
public function aiea_ajax_calls(){
// AIEA ajax calls
require_once ( AIEA_DIR . 'includes/class.ai-ajax-calls.php' );
}
public function load_library_templates(){
// AIEA ajax calls
require_once ( AIEA_DIR . 'core/admin/ai-templates-library.php' );
}
/**
* Load plugin translated strings using text domain
* @since 2.6.8
* @access public
* @return void
*/
public function load_domain() {
load_plugin_textdomain( 'ai-addons', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Load required file for addons integration
* @return void
*/
public function init_addons() {
require_once ( AIEA_DIR . 'includes/ai-gateway.php' );
}
/**
* set default options
* @return void
*/
public function on_activation() {
require_once ( AIEA_DIR . 'core/admin/ai-default.php' );
}
/**
* Register cpt
* @return void
*/
function aiea_modules() {
require_once ( AIEA_DIR . 'core/modules.php' );
}
/**
* Creates and returns an instance of the class
* @since 2.6.8
* @access public
* return object
*/
public static function get_instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
}
}
//Create/Call AI Addons
AIEA_Init::get_instance();