| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: GetResponse Forms by Optin Cat |
| 4 |
Plugin URI: https://fatcatapps.com/optincat |
| 5 |
Description: The GetResponse Optin Cat WordPress Lets You Convert More Blog Viisots Into Email Subscribers. Set It Up In 2 Minutes. |
| 6 |
Author: Fatcat Apps |
| 7 |
Version: 1.3.6 |
| 8 |
Author URI: https://fatcatapps.com/ |
| 9 |
*/ |
| 10 |
|
| 11 |
// define( 'FCA_EOI_DEBUG', true ); |
| 12 |
if ( ! function_exists( 'is_admin' ) ) { |
| 13 |
exit(); |
| 14 |
} |
| 15 |
|
| 16 |
require 'includes/skelet/skelet.php'; |
| 17 |
|
| 18 |
define( 'FCA_EOI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 19 |
define( 'FCA_EOI_PLUGIN_FILE', __FILE__ ); |
| 20 |
define( 'FCA_EOI_PLUGIN_URL', plugins_url( '', __FILE__ ) ); |
| 21 |
|
| 22 |
if( ! defined ( 'FCA_EOI_DEBUG' ) ) { |
| 23 |
define( 'FCA_EOI_DEBUG', false ); |
| 24 |
} |
| 25 |
if ( FCA_EOI_DEBUG && ! class_exists ( 'Kint' ) ) { |
| 26 |
require FCA_EOI_PLUGIN_DIR . 'includes/classes/kint/Kint.class.php'; |
| 27 |
} |
| 28 |
if ( ! class_exists ( 'Mustache_Engine' ) ) { |
| 29 |
require FCA_EOI_PLUGIN_DIR . 'includes/classes/Mustache/Autoloader.php'; |
| 30 |
Mustache_Autoloader::register(); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Include scssphp |
| 35 |
* |
| 36 |
* Latest version requires PHP 5.3 |
| 37 |
* Version 0.0.15 works with PHP 5.2 |
| 38 |
* We detect PHP > 5.3 by checking the constant __DIR__ |
| 39 |
*/ |
| 40 |
if ( ! class_exists ( 'scssc' ) ) { |
| 41 |
if( defined( '__DIR__' ) ) { |
| 42 |
require FCA_EOI_PLUGIN_DIR . 'includes/classes/scssphp/scss.inc.php'; |
| 43 |
} else { |
| 44 |
require FCA_EOI_PLUGIN_DIR . 'includes/classes/scssphp-0.0.15/scss.inc.php'; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Include and instanciate Mobile Detect |
| 50 |
*/ |
| 51 |
if ( ! class_exists ( 'Mobile_Detect' ) ) { |
| 52 |
require FCA_EOI_PLUGIN_DIR . 'includes/classes/Mobile-Detect/Mobile_Detect.php'; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
if( ! class_exists( 'DhEasyOptIns' ) ) { |
| 57 |
class DhEasyOptIns { |
| 58 |
|
| 59 |
var $ver = '1.3.6'; |
| 60 |
var $distro = ''; |
| 61 |
var $shortcode = 'optin-cat'; |
| 62 |
var $shortcode_aliases = array( |
| 63 |
'easy-opt-in', |
| 64 |
'optincat', |
| 65 |
'opt-in-cat', |
| 66 |
); |
| 67 |
var $settings; |
| 68 |
var $provider = ''; |
| 69 |
var $providers = array(); |
| 70 |
|
| 71 |
function __construct() { |
| 72 |
|
| 73 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-error-handler.php'; |
| 74 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-post-types.php'; |
| 75 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-settings.php'; |
| 76 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-layout.php'; |
| 77 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-shortcode.php'; |
| 78 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-widget.php'; |
| 79 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-pointer.php'; |
| 80 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-tour-pointer.php'; |
| 81 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-activity.php'; |
| 82 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-init.php'; |
| 83 |
require FCA_EOI_PLUGIN_DIR . 'includes/compatibility-mode/eoi-compatibility-mode.php'; |
| 84 |
|
| 85 |
global $fca_eoi_shortcodes; |
| 86 |
|
| 87 |
$post_type = $this->get_current_post_type(); |
| 88 |
$eoi_settings = get_option('easy_opt_in_settings'); |
| 89 |
|
| 90 |
// Settings |
| 91 |
$this->settings(); |
| 92 |
|
| 93 |
// Add provider to settings |
| 94 |
$providers_available = array_keys( $this->settings[ 'providers' ] ); |
| 95 |
|
| 96 |
//set current post type to setting array |
| 97 |
$this->settings[ 'post_type' ] = $post_type; |
| 98 |
|
| 99 |
// If there is only one provider, use it |
| 100 |
if( 1 == count( $providers_available ) ) { |
| 101 |
$this->provider = $this->settings[ 'provider' ] = $providers_available[ 0 ]; |
| 102 |
} |
| 103 |
|
| 104 |
// Distributions |
| 105 |
if( 1 == count( $providers_available ) ) { |
| 106 |
$this->distro = 'free'; |
| 107 |
$this->settings['distribution'] = 'free'; |
| 108 |
} else { |
| 109 |
$this->distro = 'premium'; |
| 110 |
$this->settings['distribution'] = 'premium'; |
| 111 |
} |
| 112 |
|
| 113 |
// Add options that are stored in DB if any |
| 114 |
$this->settings[ 'eoi_settings' ] = $eoi_settings; |
| 115 |
|
| 116 |
// Include provider helper class(es) |
| 117 |
foreach ( $providers_available as $provider ) { |
| 118 |
require $this->settings[ 'plugin_dir' ] . "providers/$provider/functions.php"; |
| 119 |
} |
| 120 |
|
| 121 |
// Load extensions |
| 122 |
$post_types = new EasyOptInsPostTypes($this->settings); |
| 123 |
$fca_eoi_shortcodes = new EasyOptInsShortcodes($this->settings); |
| 124 |
$widget = new EasyOptInsWidgetHelper($this->settings); |
| 125 |
EasyOptInsActivity::get_instance()->settings = $this->settings; |
| 126 |
EasyOptInsInit::get_instance()->setup(); |
| 127 |
|
| 128 |
// Load subscribing banner for free users |
| 129 |
if( 1 == count( $providers_available ) ) { |
| 130 |
$pointer = new EasyOptInsPointer( $this->settings ); |
| 131 |
} |
| 132 |
|
| 133 |
//Load tour pointer |
| 134 |
//$tour_pointer = new EOITourPointer($this->settings ); |
| 135 |
|
| 136 |
//load compatibility-mode |
| 137 |
new EasyOptInsCompatibilityMode( $this->settings ); |
| 138 |
|
| 139 |
//load EasyOptIns Upgrade notifications |
| 140 |
if( count( $providers_available ) === 1 ) { |
| 141 |
require plugin_dir_path( __FILE__ ) . 'includes/eoi-upgrade.php'; |
| 142 |
new EasyOptInsUpgrade( $this->settings ); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
function get_current_post_type() { |
| 147 |
|
| 148 |
global $post, $typenow, $current_screen; |
| 149 |
|
| 150 |
if ( $post && $post->post_type ) { |
| 151 |
return $post->post_type; |
| 152 |
} elseif( $typenow ) { |
| 153 |
return $typenow; |
| 154 |
} elseif( $current_screen && $current_screen->post_type ) { |
| 155 |
return $current_screen->post_type; |
| 156 |
} elseif( isset( $_REQUEST['post_type'] ) ) { |
| 157 |
return sanitize_key( $_REQUEST['post_type'] ); |
| 158 |
} elseif ( isset( $_REQUEST['post'] ) && $_REQUEST['post'] ) { |
| 159 |
$id = $_REQUEST['post']; |
| 160 |
$post_obj = get_post( $id ); |
| 161 |
if( $post_obj ) { |
| 162 |
return $post_obj->post_type; |
| 163 |
} |
| 164 |
} |
| 165 |
return null; |
| 166 |
} |
| 167 |
|
| 168 |
function settings() { |
| 169 |
$this->settings['plugin_dir'] = FCA_EOI_PLUGIN_DIR; |
| 170 |
$this->settings['plugin_url'] = FCA_EOI_PLUGIN_URL; |
| 171 |
$this->settings['shortcode'] = $this->shortcode; |
| 172 |
$this->settings['shortcode_aliases'] = $this->shortcode_aliases; |
| 173 |
$this->settings['version'] = $this->ver; |
| 174 |
$this->settings['provider'] = $this->provider; |
| 175 |
|
| 176 |
// Load all providers |
| 177 |
foreach ( glob( $this->settings[ 'plugin_dir' ] . 'providers/*', GLOB_ONLYDIR ) as $provider_path ) { |
| 178 |
$provider_id = basename( $provider_path ); |
| 179 |
require_once "$provider_path/provider.php"; |
| 180 |
$this->settings[ 'providers' ][ $provider_id ] = call_user_func( "provider_$provider_id" ); |
| 181 |
} |
| 182 |
|
| 183 |
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && ! empty( $_POST['paf_submit'] ) ) { |
| 184 |
$options_before = get_option('paf'); |
| 185 |
$options_after = empty( $_POST['paf'] ) ? array() : $_POST['paf']; |
| 186 |
$options_changed = true; |
| 187 |
} else { |
| 188 |
$options_changed = false; |
| 189 |
} |
| 190 |
|
| 191 |
// Load all powerups |
| 192 |
foreach ( glob( $this->settings[ 'plugin_dir' ] . 'powerups/*', GLOB_ONLYDIR ) as $powerup_path ) { |
| 193 |
$powerup_id = basename( $powerup_path ); |
| 194 |
$powerup_id = preg_replace('/(\d+)_/', '', $powerup_id); |
| 195 |
|
| 196 |
require_once "$powerup_path/powerup.php"; |
| 197 |
$function_name = "powerup_$powerup_id"; |
| 198 |
$this->settings[ 'powerups' ][ $powerup_id ] = call_user_func( $function_name, $this->settings ); |
| 199 |
|
| 200 |
$option_name = 'eoi_' . $function_name; |
| 201 |
if ( $options_changed ) { |
| 202 |
$hook_function_name = null; |
| 203 |
|
| 204 |
if ( empty( $options_before[ $option_name ] ) && ! empty( $options_after[ $option_name ] ) ) { |
| 205 |
$hook_function_name = $function_name . '_on_activate'; |
| 206 |
} else if ( ! empty( $options_before[ $option_name ] ) && empty( $options_after[ $option_name ] ) ) { |
| 207 |
$hook_function_name = $function_name . '_on_deactivate'; |
| 208 |
} |
| 209 |
|
| 210 |
if ( ! empty( $hook_function_name ) && function_exists( $hook_function_name ) ) { |
| 211 |
call_user_func( $hook_function_name, $this->settings ); |
| 212 |
} |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
paf_pages( array( 'eoi_powerups' => array( |
| 217 |
'title' => __( 'Power Ups Settings' ), |
| 218 |
'menu_title' => __( 'Power Ups' ), |
| 219 |
'parent' => 'edit.php?post_type=easy-opt-ins', |
| 220 |
) ) ); |
| 221 |
|
| 222 |
$this->settings['error_text'] = array( |
| 223 |
'field_required' => 'Error: This field is required.', |
| 224 |
'invalid_email' => "Error: Please enter a valid email address. For example \"max@domain.com\"." |
| 225 |
); |
| 226 |
} |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 231 |
|
| 232 |
if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
| 233 |
function fca_eoi_fail_activation( $message ) { |
| 234 |
wp_die( sprintf( |
| 235 |
'<h2>%s</h2><p>%s</p><p><a class="button button-large" href="%s">%s</a></p>' |
| 236 |
, __( 'Ooops!' ) |
| 237 |
, __( $message ) |
| 238 |
, admin_url( 'plugins.php' ) |
| 239 |
, __( 'Go to plugins page' ) |
| 240 |
) ); |
| 241 |
} |
| 242 |
|
| 243 |
function fca_eoi_activation() { |
| 244 |
$plugins = get_plugins(); |
| 245 |
|
| 246 |
// Fail to activate the plugin if other Optin Cat plugins are already active |
| 247 |
foreach ( $plugins as $file => $plugin ) { |
| 248 |
if ( stripos( $plugin['PluginURI'], 'fatcatapps.com/optincat' ) !== false && is_plugin_active( $file ) ) { |
| 249 |
$current_plugin = $plugins[ plugin_basename( __FILE__ ) ]; |
| 250 |
fca_eoi_fail_activation( |
| 251 |
'Only one Optin Cat plugin can be active at a time, but you already have ' . |
| 252 |
htmlspecialchars( $plugin['Name'] ) . ' active. ' . |
| 253 |
'Please deactivate it before activating ' . |
| 254 |
htmlspecialchars( $current_plugin['Name'] ) . '.' ); |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
// Fail to activate the plugin if the providers or layouts directories are empty |
| 259 |
$providers = glob( FCA_EOI_PLUGIN_DIR . 'providers/*', GLOB_ONLYDIR ); |
| 260 |
$layouts = glob( FCA_EOI_PLUGIN_DIR . 'layouts/*', GLOB_ONLYDIR ); |
| 261 |
|
| 262 |
if ( empty( $providers ) || empty( $layouts ) ) { |
| 263 |
fca_eoi_fail_activation( 'Something went wrong. Please delete the plugin and install it again.' ); |
| 264 |
} |
| 265 |
|
| 266 |
// If everything went well, continue with the activation setup |
| 267 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-activity.php'; |
| 268 |
EasyOptInsActivity::get_instance()->setup(); |
| 269 |
|
| 270 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-init.php'; |
| 271 |
EasyOptInsInit::get_instance()->on_activate(); |
| 272 |
} |
| 273 |
|
| 274 |
// If the plugin is not yet active, check for any obstacles in activation |
| 275 |
register_activation_hook( __FILE__, 'fca_eoi_activation' ); |
| 276 |
return; |
| 277 |
} |
| 278 |
|
| 279 |
$dh_easy_opt_ins_plugin = new DhEasyOptIns(); |
| 280 |
|