| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Popup for Elementor |
| 4 |
* Plugin URI: https://www.popupforelementor.com |
| 5 |
* Description: Create powerful, fully customizable popups directly in Elementor Free — includes click, delay, load, and exit-intent triggers, animations, and smart visibility controls to boost user engagement. |
| 6 |
* Version: 1.6.6 |
| 7 |
* Author: Veelo |
| 8 |
* Author URI: https://www.veelo.es |
| 9 |
* Text Domain: popup-for-elementor |
| 10 |
* Domain Path: /languages |
| 11 |
* License: GPLv2 or later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Requires at least: 6.6 |
| 14 |
* Requires PHP: 7.4 |
| 15 |
* Requires Plugins: elementor |
| 16 |
* Tested up to: 7.0 |
| 17 |
*/ |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
// Exit if accessed directly |
| 22 |
if (!defined('ABSPATH')) { |
| 23 |
exit; |
| 24 |
} |
| 25 |
|
| 26 |
register_activation_hook(__FILE__, function () { |
| 27 |
update_option('popupfe_redirect_on_activation', true); |
| 28 |
}); |
| 29 |
|
| 30 |
|
| 31 |
// Check if Elementor is active |
| 32 |
if (!did_action('elementor/loaded')) { |
| 33 |
add_action('admin_notices', function () { |
| 34 |
echo '<div class="error"><p>Popup for Elementor requires Elementor to be installed and active.</p></div>'; |
| 35 |
}); |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
// Define constants |
| 40 |
define('POPUPFE_PATH', plugin_dir_path(__FILE__)); |
| 41 |
define('POPUPFE_URL', plugin_dir_url(__FILE__)); |
| 42 |
|
| 43 |
// Include necessary files |
| 44 |
require_once POPUPFE_PATH . 'includes/admin-page.php'; |
| 45 |
require_once POPUPFE_PATH . 'includes/popup-handler.php'; |
| 46 |
require_once POPUPFE_PATH . 'includes/styles.php'; |
| 47 |
|
| 48 |
add_action('plugins_loaded', function () { |
| 49 |
$mo_path = dirname(plugin_basename(__FILE__)) . '/languages/'; |
| 50 |
}); |
| 51 |
|
| 52 |
add_action('wp_enqueue_scripts', 'popupfe_enqueue_popup_scripts'); |
| 53 |
|
| 54 |
function popupfe_enqueue_popup_scripts() |
| 55 |
{ |
| 56 |
wp_localize_script('popup-widget-js', 'PopupForElementorConfig', [ |
| 57 |
'ajaxUrl' => admin_url('admin-ajax.php'), |
| 58 |
]); |
| 59 |
} |
| 60 |
|
| 61 |
add_action('wp_enqueue_scripts', function () { |
| 62 |
wp_enqueue_style( |
| 63 |
'animate-css', |
| 64 |
plugin_dir_url(__FILE__) . 'library/animate.min.css', |
| 65 |
[], |
| 66 |
'4.1.1' |
| 67 |
); |
| 68 |
}); |
| 69 |
add_action('elementor/editor/before_enqueue_scripts', function() { |
| 70 |
wp_enqueue_script( |
| 71 |
'popup-editor-block-js', |
| 72 |
plugin_dir_url(__FILE__) . 'assets/popup-widget-block.js', |
| 73 |
['jquery'], |
| 74 |
'1.0', |
| 75 |
true |
| 76 |
); |
| 77 |
}); |
| 78 |
add_action('elementor/widgets/register', function ($widgets_manager) { |
| 79 |
if (class_exists('\Elementor\Widget_Base')) { |
| 80 |
require_once POPUPFE_PATH . 'includes/editor-options.php'; |
| 81 |
$widgets_manager->register(new Popupfe_Popup_Widget()); |
| 82 |
} |
| 83 |
}); |
| 84 |
|
| 85 |
add_action('admin_menu', function () { |
| 86 |
add_menu_page( |
| 87 |
'Popup for Elementor', |
| 88 |
'Popup for Elementor', |
| 89 |
'manage_options', |
| 90 |
'popupfe_for_elementor', |
| 91 |
'popupfe_render_admin_page', |
| 92 |
'dashicons-welcome-view-site', |
| 93 |
58 |
| 94 |
); |
| 95 |
}); |
| 96 |
|