| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: CartPops |
| 5 |
* Description: Beautiful, responsive, and conversion optimized add to cart popup for WooCommerce. |
| 6 |
* Plugin URI: https://cartpops.com |
| 7 |
* Author: CartPops.com |
| 8 |
* Version: 1.5.45 |
| 9 |
* Author URI: https://cartpops.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash |
| 10 |
* Text Domain: cartpops |
| 11 |
* Domain Path: /languages |
| 12 |
* Requires Plugins: woocommerce |
| 13 |
* Requires PHP: 7.4 |
| 14 |
* WC requires at least: 6.0 |
| 15 |
* WC tested up to: 10.7.0 |
| 16 |
* |
| 17 |
* CartPops is free software: you can redistribute it and/or modify |
| 18 |
* it under the terms of the GNU General Public License as published by |
| 19 |
* the Free Software Foundation, either version 3 of the License, or |
| 20 |
* any later version. |
| 21 |
* |
| 22 |
* CartPops is distributed in the hope that it will be useful, |
| 23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
* GNU General Public License for more details. |
| 26 |
* |
| 27 |
*/ |
| 28 |
// If this file is called directly, abort. |
| 29 |
if ( !defined( 'WPINC' ) ) { |
| 30 |
die; |
| 31 |
} |
| 32 |
if ( !defined( 'CARTPOPS_VERSION' ) ) { |
| 33 |
define( 'CARTPOPS_VERSION', '1.5.45' ); |
| 34 |
} |
| 35 |
if ( !defined( 'CARTPOPS_PREFIX' ) ) { |
| 36 |
define( 'CARTPOPS_PREFIX', 'cartpops' ); |
| 37 |
} |
| 38 |
if ( !defined( 'CARTPOPS_URL' ) ) { |
| 39 |
define( 'CARTPOPS_URL', plugins_url( '/', __FILE__ ) ); |
| 40 |
} |
| 41 |
if ( !defined( 'CARTPOPS_PATH' ) ) { |
| 42 |
define( 'CARTPOPS_PATH', plugin_dir_path( __FILE__ ) ); |
| 43 |
} |
| 44 |
if ( !defined( 'CARTPOPS_DOCS' ) ) { |
| 45 |
define( 'CARTPOPS_DOCS', 'https://cartpops.com/docs/' ); |
| 46 |
} |
| 47 |
if ( !defined( 'CARTPOPS_FILE' ) ) { |
| 48 |
define( 'CARTPOPS_FILE', plugin_basename( __FILE__ ) ); |
| 49 |
} |
| 50 |
if ( !defined( 'CARTPOPS_ABSPATH' ) ) { |
| 51 |
define( 'CARTPOPS_ABSPATH', dirname( CARTPOPS_FILE ) . '/' ); |
| 52 |
} |
| 53 |
if ( !defined( 'CARTPOPS_TEMPLATE_DEBUG_MODE' ) ) { |
| 54 |
define( 'CARTPOPS_TEMPLATE_DEBUG_MODE', false ); |
| 55 |
} |
| 56 |
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
| 57 |
/** |
| 58 |
* Cartpops does not use any `custom_order_tables` features, but we need to declare compatibility. |
| 59 |
*/ |
| 60 |
add_action( 'before_woocommerce_init', function () { |
| 61 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 62 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 63 |
} |
| 64 |
} ); |
| 65 |
if ( function_exists( 'fs_cartpops' ) ) { |
| 66 |
fs_cartpops()->set_basename( false, __FILE__ ); |
| 67 |
} else { |
| 68 |
/** |
| 69 |
* Will stop plugin from loading if PHP version is below #. |
| 70 |
* |
| 71 |
* @author CartPops <help@cartpops.com> |
| 72 |
*/ |
| 73 |
function cartpops_cant_activate_msg() { |
| 74 |
?> |
| 75 |
<div class="notice notice-error is-dismissible checkout-wc"> |
| 76 |
<?php |
| 77 |
// Use plain English text instead of translation functions to avoid early loading |
| 78 |
echo 'Oh no! WooCommerce is required to use CartPops.'; |
| 79 |
?> |
| 80 |
<p> |
| 81 |
<?php |
| 82 |
// Use plain English text instead of translation functions to avoid early loading |
| 83 |
echo 'To prevent fatal errors, we have loaded CartPops into safe mode.'; |
| 84 |
?> |
| 85 |
</p> |
| 86 |
<p class="button-container"> |
| 87 |
<?php |
| 88 |
printf( |
| 89 |
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
| 90 |
esc_url( CARTPOPS_DOCS ), |
| 91 |
'View troubleshooting docs', |
| 92 |
/* translators: Accessibility text. */ |
| 93 |
'(opens in a new tab)' |
| 94 |
); |
| 95 |
?> |
| 96 |
</p> |
| 97 |
</div> |
| 98 |
<?php |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Check if CartPops can activate. If not, will stop plugin from loading to prevent fatal errors. |
| 103 |
* |
| 104 |
* @return bool |
| 105 |
*/ |
| 106 |
function cartpops_can_activate() { |
| 107 |
$can_activate = true; |
| 108 |
if ( !function_exists( 'is_plugin_active_for_network' ) ) { |
| 109 |
require_once ABSPATH . '/wp-admin/includes/plugin.php'; |
| 110 |
} |
| 111 |
if ( is_multisite() ) { |
| 112 |
// This plugin is network activated (WooCommerce must be network activated). |
| 113 |
if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { |
| 114 |
$can_activate = ( is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ? true : false ); |
| 115 |
// Locally activated (WooCommerce can be network or locally activated). |
| 116 |
} else { |
| 117 |
$can_activate = ( is_plugin_active( 'woocommerce/woocommerce.php' ) ? true : false ); |
| 118 |
} |
| 119 |
} else { |
| 120 |
$can_activate = ( is_plugin_active( 'woocommerce/woocommerce.php' ) ? true : false ); |
| 121 |
} |
| 122 |
if ( false === $can_activate ) { |
| 123 |
return false; |
| 124 |
} else { |
| 125 |
return true; |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
if ( cartpops_can_activate() ) { |
| 130 |
if ( !function_exists( 'fs_cartpops' ) ) { |
| 131 |
/** |
| 132 |
* Freemius SDK access function |
| 133 |
*/ |
| 134 |
function fs_cartpops() { |
| 135 |
global $fs_cartpops; |
| 136 |
if ( !isset( $fs_cartpops ) ) { |
| 137 |
// Include Freemius SDK. |
| 138 |
$fs_cartpops = fs_dynamic_init( array( |
| 139 |
'id' => '7061', |
| 140 |
'slug' => 'cartpops', |
| 141 |
'premium_slug' => 'cartpops-pro', |
| 142 |
'type' => 'plugin', |
| 143 |
'public_key' => 'pk_f71eea687152e554f27b743874cd0', |
| 144 |
'is_premium' => false, |
| 145 |
'premium_suffix' => 'Pro', |
| 146 |
'has_addons' => false, |
| 147 |
'has_paid_plans' => true, |
| 148 |
'trial' => array( |
| 149 |
'days' => 14, |
| 150 |
'is_require_payment' => true, |
| 151 |
), |
| 152 |
'has_affiliation' => 'selected', |
| 153 |
'menu' => array( |
| 154 |
'slug' => 'cartpops_settings', |
| 155 |
'contact' => false, |
| 156 |
'support' => false, |
| 157 |
), |
| 158 |
'is_live' => true, |
| 159 |
'is_org_compliant' => true, |
| 160 |
) ); |
| 161 |
} |
| 162 |
return $fs_cartpops; |
| 163 |
} |
| 164 |
|
| 165 |
// Init Freemius. |
| 166 |
fs_cartpops(); |
| 167 |
// Signal that SDK was initiated. |
| 168 |
do_action( 'fs_cartpops_loaded' ); |
| 169 |
} |
| 170 |
/** |
| 171 |
* The code that runs during plugin activation. |
| 172 |
* This action is documented in includes/class-cartpops-activator.php |
| 173 |
*/ |
| 174 |
function activate_cartpops() { |
| 175 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-cartpops-activator.php'; |
| 176 |
CartPops_Activator::activate(); |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* The code that runs during plugin deactivation. |
| 181 |
* This action is documented in includes/class-cartpops-deactivator.php |
| 182 |
*/ |
| 183 |
function deactivate_cartpops() { |
| 184 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-cartpops-deactivator.php'; |
| 185 |
CartPops_Deactivator::deactivate(); |
| 186 |
} |
| 187 |
|
| 188 |
register_activation_hook( __FILE__, 'activate_cartpops' ); |
| 189 |
register_deactivation_hook( __FILE__, 'deactivate_cartpops' ); |
| 190 |
/** |
| 191 |
* The core plugin class that is used to define internationalization, |
| 192 |
* admin-specific hooks, and public-facing site hooks. |
| 193 |
*/ |
| 194 |
require plugin_dir_path( __FILE__ ) . 'includes/class-cartpops.php'; |
| 195 |
/** |
| 196 |
* Begins execution of the plugin. |
| 197 |
* |
| 198 |
* Since everything within the plugin is registered via hooks, |
| 199 |
* then kicking off the plugin from this point in the file does |
| 200 |
* not affect the page life cycle. |
| 201 |
* |
| 202 |
* @since 1.0.0 |
| 203 |
*/ |
| 204 |
function run_cartpops() { |
| 205 |
$plugin = new CartPops(); |
| 206 |
$plugin->run(); |
| 207 |
} |
| 208 |
|
| 209 |
add_action( 'init', 'run_cartpops' ); |
| 210 |
} else { |
| 211 |
add_action( 'admin_notices', 'cartpops_cant_activate_msg' ); |
| 212 |
} |
| 213 |
// cartpops_can_activate() |
| 214 |
} |