=')) {
add_action('admin_notices', [$this, 'admin_notice_minimum_elementor_version']);
return;
}
// 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;
}
// Load translation
$this->i18n();
// Init Plugin
$this->init();
}
/**
* Initialize the plugin
*
* Load the plugin only after Elementor (and other plugins) are loaded.
* Checks for basic plugin requirements, if one check fail don't continue,
* if all check have passed load the files required to run the plugin.
*
* @since 1.0.0
* @access public
*/
public function init() {
// Load the autoloader
require_once AWKE_PATH . 'includes/class-loader.php';
// Initialize the loader
AWKE_Loader::instance();
}
/**
* 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() {
// Clear activation parameter - this is standard WordPress practice for plugin notices
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
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-widget-kit-for-elementor'),
'' . esc_html__('Advanced Widget Kit', 'advanced-widget-kit-for-elementor') . '',
'' . esc_html__('Elementor', 'advanced-widget-kit-for-elementor') . ''
);
printf('
', wp_kses_post($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() {
// Clear activation parameter - this is standard WordPress practice for plugin notices
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
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-widget-kit-for-elementor'),
'' . esc_html__('Advanced Widget Kit', 'advanced-widget-kit-for-elementor') . '',
'' . esc_html__('Elementor', 'advanced-widget-kit-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 1.0.0
* @access public
*/
public function admin_notice_minimum_php_version() {
// Clear activation parameter - this is standard WordPress practice for plugin notices
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
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-widget-kit-for-elementor'),
'' . esc_html__('Advanced Widget Kit', 'advanced-widget-kit-for-elementor') . '',
'' . esc_html__('PHP', 'advanced-widget-kit-for-elementor') . '',
self::MINIMUM_PHP_VERSION
);
printf('', wp_kses_post($message));
}
}
// Instantiate AWKE_Advanced_Widget_Kit
AWKE_Advanced_Widget_Kit::instance();
// Declare WordPress compatibility
add_action('plugins_loaded', function() {
// Declare compatibility with WordPress 6.6+
if (function_exists('wp_declare_plugin_compatibility')) {
wp_declare_plugin_compatibility('advanced-widget-kit-for-elementor', [
'wordpress' => '6.6',
'php' => '7.4',
'elementor' => '3.23.0'
]);
}
// Alternative compatibility check for older WordPress versions
add_filter('plugin_row_meta', function($plugin_meta, $plugin_file, $plugin_data, $status) {
if ($plugin_file === plugin_basename(__FILE__)) {
$plugin_meta[] = '' . esc_html__('Compatible with WordPress 6.6+', 'advanced-widget-kit-for-elementor') . '';
}
return $plugin_meta;
}, 10, 4);
});