wordpress-popup
Last commit date
assets
1 month ago
free
1 month ago
inc
1 month ago
languages
1 month ago
lib
5 months ago
vendor
1 month ago
views
1 month ago
humans.txt
2 years ago
license.txt
5 years ago
popover.php
1 month ago
readme.txt
1 month ago
uninstall.php
5 months ago
popover.php
250 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Hustle plugin. |
| 4 | * |
| 5 | * @link http://wpmudev.com/projects/hustle/ |
| 6 | * @since 1.0.0 |
| 7 | * @package Hustle |
| 8 | * |
| 9 | * @wordpress-plugin |
| 10 | * Plugin Name: Hustle |
| 11 | * Plugin URI: https://wordpress.org/plugins/wordpress-popup/ |
| 12 | * Description: Start collecting email addresses and quickly grow your mailing list with big bold pop-ups, slide-ins, widgets, or in post opt-in forms. |
| 13 | * Version: 7.8.13.1 |
| 14 | * Author: WPMU DEV |
| 15 | * Author URI: https://wpmudev.com |
| 16 | * Tested up to: 7.0 |
| 17 | * Requires at least: 6.4 |
| 18 | * Requires PHP: 7.4 |
| 19 | * Text Domain: hustle |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | // +----------------------------------------------------------------------+ |
| 24 | // | Copyright Incsub (http://incsub.com/) | |
| 25 | // +----------------------------------------------------------------------+ |
| 26 | // | This program is free software; you can redistribute it and/or modify | |
| 27 | // | it under the terms of the GNU General Public License, version 2, as | |
| 28 | // | published by the Free Software Foundation. | |
| 29 | // | | |
| 30 | // | This program is distributed in the hope that it will be useful, | |
| 31 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 32 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 33 | // | GNU General Public License for more details. | |
| 34 | // | | |
| 35 | // | You should have received a copy of the GNU General Public License | |
| 36 | // | along with this program; if not, write to the Free Software | |
| 37 | // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, | |
| 38 | // | MA 02110-1301 USA | |
| 39 | // +----------------------------------------------------------------------+ |
| 40 | |
| 41 | if ( ! defined( 'HUSTLE_MIN_PHP_VERSION' ) ) { |
| 42 | define( 'HUSTLE_MIN_PHP_VERSION', '7.4' ); |
| 43 | } |
| 44 | |
| 45 | if ( ! defined( 'HUSTLE_BASE_FILE' ) ) { |
| 46 | define( 'HUSTLE_BASE_FILE', __FILE__ ); |
| 47 | } |
| 48 | |
| 49 | if ( ! function_exists( 'hustle_insecure_php_version_notice' ) ) { |
| 50 | /** |
| 51 | * Display admin notice, if the site is using unsupported PHP version. |
| 52 | */ |
| 53 | function hustle_insecure_php_version_notice() { |
| 54 | |
| 55 | ?> |
| 56 | <div class="notice notice-error"> |
| 57 | <p> |
| 58 | <?php |
| 59 | printf( |
| 60 | wp_kses( /* translators: %1$s - URL to an article about our hosting benefits. */ |
| 61 | __( 'Your site is running an outdated version of PHP that is no longer supported or receiving security updates. Please update PHP to at least version %1$s at your current hosting provider in order to activate Hustle, or consider switching to <a href="%2$s" target="_blank" rel="noopener noreferrer">WPMU DEV Hosting</a>.', 'hustle' ), |
| 62 | array( |
| 63 | 'a' => array( |
| 64 | 'href' => array(), |
| 65 | 'target' => array(), |
| 66 | 'rel' => array(), |
| 67 | ), |
| 68 | 'strong' => array(), |
| 69 | ) |
| 70 | ), |
| 71 | esc_html( HUSTLE_MIN_PHP_VERSION ), |
| 72 | 'https://wpmudev.com/hosting/' |
| 73 | ); |
| 74 | ?> |
| 75 | </p> |
| 76 | </div> |
| 77 | |
| 78 | <?php |
| 79 | |
| 80 | // In case this is on plugin activation. |
| 81 | if ( isset( $_GET['activate'] ) ) { //phpcs:ignore |
| 82 | unset( $_GET['activate'] ); //phpcs:ignore |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Display admin notice and prevent plugin code execution, if the server is |
| 89 | * using old/insecure PHP version. |
| 90 | */ |
| 91 | if ( version_compare( phpversion(), HUSTLE_MIN_PHP_VERSION, '<' ) ) { |
| 92 | add_action( 'admin_notices', 'hustle_insecure_php_version_notice' ); |
| 93 | |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | |
| 98 | add_action( 'activated_plugin', 'hustle_activated', 10, 2 ); |
| 99 | |
| 100 | if ( ! function_exists( 'hustle_activated' ) ) { |
| 101 | |
| 102 | /** |
| 103 | * Handles the deactivation of the free version if "pro" is active, and activation flags. |
| 104 | * |
| 105 | * @since unknown |
| 106 | * |
| 107 | * @param string $plugin Path to the plugin file relative to the plugins directory. |
| 108 | * @param bool $network_activation Whether to enable the plugin for all sites in the network or just the current site. |
| 109 | */ |
| 110 | function hustle_activated( $plugin, $network_activation ) { |
| 111 | |
| 112 | if ( is_plugin_active( 'hustle/opt-in.php' ) && is_plugin_active( 'wordpress-popup/popover.php' ) ) { |
| 113 | |
| 114 | // deactivate free version. |
| 115 | deactivate_plugins( 'wordpress-popup/popover.php' ); |
| 116 | |
| 117 | if ( 'hustle/opt-in.php' === $plugin ) { |
| 118 | // Store in database about free version deactivated, in order to show a notice on page load. |
| 119 | update_site_option( 'hustle_free_deactivated', 1 ); |
| 120 | } elseif ( 'wordpress-popup/popover.php' === $plugin ) { |
| 121 | // Store in database about free version being activated even pro is already active. |
| 122 | update_site_option( 'hustle_free_activated', 1 ); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | // Require autoloader. |
| 129 | if ( ! class_exists( 'ComposerAutoloaderInitd45a15be3ceca75ee1c0c2f87d2b07c1' ) ) { |
| 130 | require_once __DIR__ . '/vendor/autoload.php'; |
| 131 | } |
| 132 | |
| 133 | if ( ! defined( 'HUSTLE_SUI_VERSION' ) ) { |
| 134 | define( 'HUSTLE_SUI_VERSION', '2.12.25' ); |
| 135 | } |
| 136 | |
| 137 | if ( ! class_exists( 'Opt_In' ) ) { |
| 138 | require_once __DIR__ . '/inc/class-opt-in.php'; |
| 139 | } |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | if ( ! class_exists( 'WordPress_Popup_Module_Admin' ) ) { |
| 145 | require_once __DIR__ . '/free/inc/class-wordpress-popup-module-admin.php'; |
| 146 | |
| 147 | if ( ! function_exists( 'wordpress_popup_module_admin_init' ) ) { |
| 148 | |
| 149 | /** |
| 150 | * Instantiate WordPress_Popup_Module_Admin |
| 151 | * |
| 152 | * @since unknown |
| 153 | */ |
| 154 | function wordpress_popup_module_admin_init() { |
| 155 | new WordPress_Popup_Module_Admin(); |
| 156 | } |
| 157 | |
| 158 | add_action( 'after_setup_theme', 'wordpress_popup_module_admin_init', 5 ); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | |
| 163 | if ( ! function_exists( 'hustle_init' ) ) { |
| 164 | |
| 165 | /** |
| 166 | * Instantiate Opt_In |
| 167 | */ |
| 168 | function hustle_init() { |
| 169 | new Opt_In(); |
| 170 | } |
| 171 | |
| 172 | add_action( 'after_setup_theme', 'hustle_init' ); |
| 173 | } |
| 174 | |
| 175 | if ( ! function_exists( 'hustle_activation' ) ) { |
| 176 | |
| 177 | /** |
| 178 | * Handle tables creating if needed. |
| 179 | * |
| 180 | * @since unknown |
| 181 | */ |
| 182 | function hustle_activation() { |
| 183 | |
| 184 | if ( ! class_exists( 'Hustle_Db' ) ) { |
| 185 | require_once trailingslashit( __DIR__ ) . 'inc/hustle-db.php'; |
| 186 | } |
| 187 | update_option( 'hustle_activated_flag', 1 ); |
| 188 | |
| 189 | Hustle_Db::maybe_create_tables( true ); |
| 190 | |
| 191 | /** |
| 192 | * Add Hustle's custom capabilities. |
| 193 | * |
| 194 | * @since 4.0.1 |
| 195 | */ |
| 196 | $hustle_capabilities = array( |
| 197 | 'hustle_menu', |
| 198 | 'hustle_edit_module', |
| 199 | 'hustle_create', |
| 200 | 'hustle_edit_integrations', |
| 201 | 'hustle_access_emails', |
| 202 | 'hustle_edit_settings', |
| 203 | 'hustle_analytics', |
| 204 | ); |
| 205 | |
| 206 | $admin = get_role( 'administrator' ); |
| 207 | |
| 208 | if ( $admin ) { |
| 209 | // If there's an "administrator" role. |
| 210 | foreach ( $hustle_capabilities as $cap ) { |
| 211 | $admin->add_cap( $cap ); |
| 212 | } |
| 213 | } else { |
| 214 | // If there's no "administrator". |
| 215 | $roles = get_editable_roles(); |
| 216 | |
| 217 | foreach ( $roles as $role_name => $data ) { |
| 218 | |
| 219 | // Add the capabilities to anyone who can manage options. This was the checked capability in 3.x. |
| 220 | if ( isset( $data['capabilities']['manage_options'] ) && $data['capabilities']['manage_options'] ) { |
| 221 | |
| 222 | $role = get_role( $role_name ); |
| 223 | foreach ( $hustle_capabilities as $cap ) { |
| 224 | if ( $role ) { |
| 225 | $role->add_cap( $cap ); |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | register_activation_hook( __FILE__, 'hustle_activation' ); |
| 234 | |
| 235 | |
| 236 | if ( ! function_exists( 'hustle_deactivation' ) ) { |
| 237 | /** |
| 238 | * On deactivation hook |
| 239 | * |
| 240 | * @since 4.2.0 |
| 241 | */ |
| 242 | function hustle_deactivation() { |
| 243 | // Remove the cron for data protection cleanup. |
| 244 | wp_clear_scheduled_hook( 'hustle_general_data_protection_cleanup' ); |
| 245 | wp_clear_scheduled_hook( 'hustle_background_conversion_log_cron' ); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | register_deactivation_hook( __FILE__, 'hustle_deactivation' ); |
| 250 |