=' ) ) {
add_action( 'admin_notices', 'elementor_extras_fail_load_out_of_date' );
add_action( 'admin_init', 'elementor_extras_deactivate' );
return;
}
// Check Elementor Pro version required
if ( is_elementor_pro_active() ) {
if ( ! version_compare( ELEMENTOR_PRO_VERSION, ELEMENTOR_EXTRAS_ELEMENTOR_PRO_VERSION_REQUIRED, '>=' ) ) {
add_action( 'admin_notices', 'elementor_pro_extras_fail_load_out_of_date', 9999 );
add_action( 'admin_init', 'elementor_extras_deactivate' );
return;
}
}
// Check for required PHP version
if ( version_compare( PHP_VERSION, ELEMENTOR_EXTRAS_PHP_VERSION_REQUIRED, '<' ) ) {
add_action( 'admin_notices', 'elementor_extras_php_fail' );
add_action( 'admin_init', 'elementor_extras_deactivate' );
return;
}
// Check for recommended PHP version
if ( version_compare( PHP_VERSION, ELEMENTOR_EXTRAS_PHP_VERSION_RECOMMENDED, '<' ) ) {
add_action( 'admin_notices', 'elementor_extras_php_notice' );
}
add_action( 'admin_init', 'elementor_extras_updater' );
// add_action( 'admin_init', 'elementor_extras_info_redirect' );
// Includes
elementor_extras_include( 'admin/settings-api.php' );
elementor_extras_include( 'includes/licensing.php' );
elementor_extras_include( 'includes/plugin.php' );
// Settings
if( is_admin() ) {
elementor_extras_include( 'admin/settings-page.php' );
elementor_extras_include( 'admin/settings.php' );
}
}
add_action( 'plugins_loaded', 'elementor_extras_load' );
add_action( 'activate_plugin', 'elementor_extras_before_activation' , 10, 2);
register_activation_hook( ELEMENTOR_EXTRAS__FILE__, 'elementor_extras_activate' );
/**
* Runs code upon activation
*
* @since 1.1.3
*/
function elementor_extras_activate() {
add_option( 'elementor_extras_do_activation_redirect', true );
}
/**
* Deactivates the plugin
*
* @since 0.1.0
*/
function elementor_extras_deactivate() {
deactivate_plugins( ELEMENTOR_EXTRAS_PLUGIN_BASE );
}
/**
* Redirects to info page
*
* @since 1.1.3
*/
function elementor_extras_info_redirect( ) {
if ( get_option( 'elementor_extras_do_activation_redirect', false ) ) {
delete_option( 'elementor_extras_do_activation_redirect' );
if ( ! isset( $_GET['activate-multi'] ) && version_compare( ELEMENTOR_EXTRAS_VERSION, get_option( '_elementor_extras_was_activated_version' ), '>' ) ) {
update_option( '_elementor_extras_was_activated_version', ELEMENTOR_EXTRAS_VERSION );
exit ( wp_redirect("admin.php?page=ee-settings-info") );
}
}
}
/**
* Wrapper for including files
*
* @since 1.1.3
*/
function elementor_extras_include( $file ) {
$path = elementor_extras_get_path( $file );
if ( file_exists( $path ) ) {
include_once( $path );
}
}
/**
* Returns the path to a file relative to our plugin
*
* @since 1.1.3
*/
function elementor_extras_get_path( $path ) {
return ELEMENTOR_EXTRAS_PATH . $path;
}
/**
* Wrapper for including admin views
*
* @since 1.1.3
*/
function elementor_extras_get_view( $path = '', $args = array() ) {
if( substr( $path, -4 ) !== '.php' ) {
$path = elementor_extras_get_path( "admin/views/{$path}.php" );
}
if( file_exists( $path ) ) {
extract( $args );
include( $path );
}
}
/**
* Handles admin notice for non-active
* Elementor plugin situations
*
* @since 0.1.0
*/
function elementor_extras_fail_load() {
$class = 'notice notice-error';
$message = sprintf( __( 'You need %1$sElementor%2$s for %1$sExtras%2$s to work.', 'elementor-extras' ), '', '' );
$plugin = 'elementor/elementor.php';
if ( _is_elementor_installed() ) {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$message = sprintf( __( 'You need to activate %1$sElementor%2$s for %1$sExtras%2$s to work.', 'elementor-extras' ), '', '' );
$action_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
$button_label = __( 'Activate Elementor', 'elementor-extras' );
} else {
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}
$action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
$button_label = __( 'Install Elementor', 'elementor-extras' );
}
$button = '
' . $button_label . '
';
printf( '', esc_attr( $class ), $message, $button );
}
/**
* Handles admin notice for outdated Elementor version
*
* @since 0.1.0
*/
function elementor_extras_fail_load_out_of_date() {
$class = 'notice notice-error';
$message = __( 'This version of Extras requires at least Elementor version ' . ELEMENTOR_EXTRAS_ELEMENTOR_VERSION_REQUIRED . '. Please update Elementor and re-activate Extras, or revert Extras version ' . ELEMENTOR_EXTRAS_PREVIOUS_STABLE_VERSION . '.', 'elementor-extras' );
printf( '', esc_attr( $class ), esc_html( $message ) );
}
/**
* Handles admin notice for outdated Elementor Pro version
*
* @since 1.1.2
*/
function elementor_pro_extras_fail_load_out_of_date() {
$class = 'notice notice-error';
$message = __( 'This version of Extras requires you update Elementor Pro to at least version ' . ELEMENTOR_EXTRAS_ELEMENTOR_PRO_VERSION_REQUIRED . ' to avoid any issues. We\'ve deactivated Extras for now. Please update Elementor Pro and re-activate Extras or revert to Extras version ' . ELEMENTOR_EXTRAS_PREVIOUS_STABLE_VERSION . '.', 'elementor-extras' );
printf( '', esc_attr( $class ), esc_html( $message ) );
}
/**
* Handles admin notice for outdated Elementor Pro version
*
* @since 2.1.7
*/
function elementor_extras_before_activation() {
if ( defined('ELEMENTOR_VERSION') && ! version_compare( ELEMENTOR_VERSION, ELEMENTOR_EXTRAS_ELEMENTOR_VERSION_REQUIRED, '>=' ) ) {
wp_die( __( 'This version of Extras requires at least Elementor version ' . ELEMENTOR_EXTRAS_ELEMENTOR_VERSION_REQUIRED . '. Please update Elementor and re-activate Extras for Elementor or revert to Extras version ' . ELEMENTOR_EXTRAS_PREVIOUS_STABLE_VERSION . '.', 'elementor-extras' ) );
}
if ( is_elementor_pro_active() ) {
if ( defined('ELEMENTOR_PRO_VERSION') && ! version_compare( ELEMENTOR_PRO_VERSION, ELEMENTOR_EXTRAS_ELEMENTOR_PRO_VERSION_REQUIRED, '>=' ) ) {
wp_die( __( 'This version of Extras requires you update Elementor Pro to at least version ' . ELEMENTOR_EXTRAS_ELEMENTOR_PRO_VERSION_REQUIRED . ' to avoid any issues. Please update Elementor Pro and re-activate Extras.', 'elementor-extras' ) );
}
}
}
/**
* Handles admin notice for the disable widgets recommendation
*
* @since 2.0.0
*/
function elementor_extras_disable_widgets_notice() {
if ( ! \ElementorExtras\Dismiss_Notice::is_admin_notice_active( 'ee-disable-widget-notice-forever' ) )
return;
$class = 'notice notice-error is-dismissible';
$message = __( 'Take a moment to disable the Extras widgets and extensions that you don\'t plan on using. This will speed up the load time of the Elementor editor.', 'elementor-extras' );
printf( '', esc_attr( $class ), esc_html( $message ), admin_url( 'admin.php?page=elementor-extras#elementor_extras_widgets' ), __( 'Manage widgets', 'elementor-extras' ) );
}
/**
* Handles admin notice for minimum PHP version required
*
* @since 0.1.0
*/
function elementor_extras_php_fail() {
$class = 'notice notice-error';
$message = __( 'Extras for Elementor needs at least PHP version ' . ELEMENTOR_EXTRAS_PHP_VERSION_REQUIRED .' to work properly. We deactivated the plugin for now.', 'elementor-extras' );
printf( '', esc_attr( $class ), esc_html( $message ) );
if ( isset( $_GET['activate'] ) )
unset( $_GET['activate'] );
}
/**
* Handles admin notice for recommended PHP version
*
* @since 1.8.4
*/
function elementor_extras_php_notice() {
if ( ! \ElementorExtras\Dismiss_Notice::is_admin_notice_active( 'ee-php-recommend-notice-forever' ) )
return;
$class = 'notice notice-warning is-dismissible';
$message = __( 'Extras for Elementor: You are currently running PHP version ' . PHP_VERSION . '. If you experience issues loading the Elementor editor, we recommend upgrading to version ' . ELEMENTOR_EXTRAS_PHP_VERSION_RECOMMENDED .' or above.', 'elementor-extras' );
printf( '', esc_attr( $class ), esc_html( $message ) );
}
/**
* Handles updates
*
* @since 0.1.0
*/
function elementor_extras_updater() {
// Require the updater class
elementor_extras_include( 'includes/updater.php' );
elementor_extras_include( 'admin/settings-api.php' );
$settings = new \ElementorExtras\Settings_API();
$beta = $settings->get_option( 'enable_beta', 'elementor_extras_advanced', false );
// Disable SSL verification
add_filter( 'edd_sl_api_request_verify_ssl', '__return_false' );
// Setup the updater
$license = get_option( ELEMENTOR_EXTRAS_SL_ITEM_ID . '_license_key' );
$args = [
'version' => ELEMENTOR_EXTRAS_VERSION,
'license' => $license,
'item_name' => ELEMENTOR_EXTRAS_SL_ITEM_NAME,
'item_id' => ELEMENTOR_EXTRAS_SL_ITEM_ID,
'author' => 'Namogo',
'beta' => 'yes' === $beta,
];
$updater = new \ElementorExtras\Updater( ELEMENTOR_EXTRAS_STORE_URL, __FILE__, $args );
}
/**
* Check if Elementor Pro is active
*
* @since 1.1.2
*
*/
if ( ! function_exists( 'is_elementor_pro_active' ) ) {
function is_elementor_pro_active() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$plugin = 'elementor-pro/elementor-pro.php';
return is_plugin_active( $plugin ) || function_exists( 'elementor_pro_load_plugin' );
}
}
/**
* Check if WPML String Translation plugin is active
*
* @since 1.8.0
*
*/
if ( ! function_exists( 'is_wpml_string_translation_active' ) ) {
function is_wpml_string_translation_active() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
return is_plugin_active( 'wpml-string-translation/plugin.php' );
}
}
/**
* Check if WooCommerce is active
*
* @since 1.6.0
*
*/
if ( ! function_exists( 'is_woocommerce_active' ) ) {
function is_woocommerce_active() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
return is_plugin_active( 'woocommerce/woocommerce.php' );
}
}
/**
* Check if Elementor Pro is installed
*
* @since 1.1.2
*
* @access public
*/
if ( ! function_exists( '_is_elementor_installed' ) ) {
function _is_elementor_installed() {
$path = 'elementor/elementor.php';
$plugins = get_plugins();
return isset( $plugins[ $path ] );
}
}
require_once plugin_dir_path( __FILE__ ) . 'lib/wp-package-updater/class-wp-package-updater.php';
// /** Enable plugin updates with license check **/
$elementor_extra_updater = new WP_Package_Updater(
'https://api.elementorfa.ir/',
wp_normalize_path( __FILE__ ),
wp_normalize_path( plugin_dir_path( __FILE__ ) )
);