| 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.6.3 |
| 8 |
Author URI: https://fatcatapps.com/ |
| 9 |
*/ |
| 10 |
|
| 11 |
// define( 'FCA_EOI_DEBUG', true ); |
| 12 |
|
| 13 |
if ( ! function_exists( 'is_admin' ) ) { |
| 14 |
exit(); |
| 15 |
} |
| 16 |
|
| 17 |
require 'includes/skelet/skelet.php'; |
| 18 |
|
| 19 |
define( 'FCA_EOI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 20 |
define( 'FCA_EOI_PLUGIN_FILE', __FILE__ ); |
| 21 |
define( 'FCA_EOI_PLUGIN_URL', plugins_url( '', __FILE__ ) ); |
| 22 |
define( 'FCA_EOI_EDITION', 'getresponse' ); |
| 23 |
|
| 24 |
|
| 25 |
if( ! defined ( 'FCA_EOI_DEBUG' ) ) { |
| 26 |
define( 'FCA_EOI_DEBUG', false ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Include and instantiate Mobile Detect |
| 31 |
*/ |
| 32 |
if ( ! class_exists ( 'Mobile_Detect' ) ) { |
| 33 |
require FCA_EOI_PLUGIN_DIR . 'includes/classes/Mobile-Detect/Mobile_Detect.php'; |
| 34 |
} |
| 35 |
|
| 36 |
if( ! class_exists( 'DhEasyOptIns' ) ) { |
| 37 |
class DhEasyOptIns { |
| 38 |
|
| 39 |
var $ver = '1.6.3'; |
| 40 |
var $distro = ''; |
| 41 |
var $shortcode = 'optin-cat'; |
| 42 |
var $shortcode_aliases = array( |
| 43 |
'easy-opt-in', |
| 44 |
'optincat', |
| 45 |
'opt-in-cat', |
| 46 |
); |
| 47 |
var $settings; |
| 48 |
var $provider = ''; |
| 49 |
var $providers = array(); |
| 50 |
|
| 51 |
function __construct() { |
| 52 |
|
| 53 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-post-types.php'; |
| 54 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-layout.php'; |
| 55 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-shortcode.php'; |
| 56 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-widget.php'; |
| 57 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-pointer.php'; |
| 58 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-tour-pointer.php'; |
| 59 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-activity.php'; |
| 60 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-functions.php'; |
| 61 |
|
| 62 |
global $fca_eoi_shortcodes; |
| 63 |
|
| 64 |
|
| 65 |
// Settings |
| 66 |
$this->settings['shortcode'] = $this->shortcode; |
| 67 |
$this->settings['shortcode_aliases'] = $this->shortcode_aliases; |
| 68 |
$this->settings['version'] = $this->ver; |
| 69 |
$this->settings['provider'] = $this->provider; |
| 70 |
|
| 71 |
// Load all providers |
| 72 |
foreach ( glob( FCA_EOI_PLUGIN_DIR . 'providers/*', GLOB_ONLYDIR ) as $provider_path ) { |
| 73 |
$provider_id = basename( $provider_path ); |
| 74 |
require_once "$provider_path/provider.php"; |
| 75 |
$this->settings[ 'providers' ][ $provider_id ] = call_user_func( "provider_$provider_id" ); |
| 76 |
} |
| 77 |
|
| 78 |
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && ! empty( $_POST['paf_submit'] ) ) { |
| 79 |
$options_before = get_option('paf'); |
| 80 |
$options_after = empty( $_POST['paf'] ) ? array() : $_POST['paf']; |
| 81 |
$options_changed = true; |
| 82 |
} else { |
| 83 |
$options_changed = false; |
| 84 |
} |
| 85 |
|
| 86 |
// Load all powerups |
| 87 |
foreach ( glob( FCA_EOI_PLUGIN_DIR . 'powerups/*', GLOB_ONLYDIR ) as $powerup_path ) { |
| 88 |
$powerup_id = basename( $powerup_path ); |
| 89 |
$powerup_id = preg_replace('/(\d+)_/', '', $powerup_id); |
| 90 |
|
| 91 |
require_once "$powerup_path/powerup.php"; |
| 92 |
$function_name = "powerup_$powerup_id"; |
| 93 |
$this->settings[ 'powerups' ][ $powerup_id ] = call_user_func( $function_name, $this->settings ); |
| 94 |
|
| 95 |
$option_name = 'eoi_' . $function_name; |
| 96 |
if ( $options_changed ) { |
| 97 |
$hook_function_name = null; |
| 98 |
|
| 99 |
if ( empty( $options_before[ $option_name ] ) && ! empty( $options_after[ $option_name ] ) ) { |
| 100 |
$hook_function_name = $function_name . '_on_activate'; |
| 101 |
} else if ( ! empty( $options_before[ $option_name ] ) && empty( $options_after[ $option_name ] ) ) { |
| 102 |
$hook_function_name = $function_name . '_on_deactivate'; |
| 103 |
} |
| 104 |
|
| 105 |
if ( ! empty( $hook_function_name ) && function_exists( $hook_function_name ) ) { |
| 106 |
call_user_func( $hook_function_name, $this->settings ); |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
paf_pages( array( 'eoi_powerups' => array( |
| 112 |
'title' => __( 'Power Ups Settings' ), |
| 113 |
'menu_title' => __( 'Power Ups' ), |
| 114 |
'parent' => 'edit.php?post_type=easy-opt-ins', |
| 115 |
) ) ); |
| 116 |
|
| 117 |
// Add provider to settings |
| 118 |
$providers_available = array_keys( $this->settings[ 'providers' ] ); |
| 119 |
|
| 120 |
//set current post type to setting array |
| 121 |
$this->settings[ 'post_type' ] = get_post_type(); |
| 122 |
|
| 123 |
// If there is only one provider, use it |
| 124 |
if( 1 == count( $providers_available ) ) { |
| 125 |
$this->provider = $this->settings[ 'provider' ] = $providers_available[ 0 ]; |
| 126 |
} |
| 127 |
|
| 128 |
// Distributions |
| 129 |
if( 1 == count( $providers_available ) ) { |
| 130 |
$this->distro = 'free'; |
| 131 |
$this->settings['distribution'] = 'free'; |
| 132 |
} else { |
| 133 |
$this->distro = 'premium'; |
| 134 |
$this->settings['distribution'] = 'premium'; |
| 135 |
} |
| 136 |
|
| 137 |
// Include provider helper class(es) |
| 138 |
foreach ( $providers_available as $provider ) { |
| 139 |
require_once FCA_EOI_PLUGIN_DIR . "providers/$provider/functions.php"; |
| 140 |
} |
| 141 |
|
| 142 |
// Load extensions |
| 143 |
$post_types = new EasyOptInsPostTypes($this->settings); |
| 144 |
$fca_eoi_shortcodes = new EasyOptInsShortcodes($this->settings); |
| 145 |
$widget = new EasyOptInsWidgetHelper($this->settings); |
| 146 |
EasyOptInsActivity::get_instance()->settings = $this->settings; |
| 147 |
|
| 148 |
// Load subscribing banner for free users |
| 149 |
if( 1 == count( $providers_available ) ) { |
| 150 |
$pointer = new EasyOptInsPointer( $this->settings ); |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
//load EasyOptIns Upgrade notifications |
| 155 |
if( count( $providers_available ) === 1 ) { |
| 156 |
require plugin_dir_path( __FILE__ ) . 'includes/eoi-upgrade.php'; |
| 157 |
new EasyOptInsUpgrade( $this->settings ); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
function get_current_post_type() { |
| 162 |
|
| 163 |
global $post, $typenow, $current_screen; |
| 164 |
|
| 165 |
if ( $post && $post->post_type ) { |
| 166 |
return $post->post_type; |
| 167 |
} elseif( $typenow ) { |
| 168 |
return $typenow; |
| 169 |
} elseif( $current_screen && $current_screen->post_type ) { |
| 170 |
return $current_screen->post_type; |
| 171 |
} elseif( isset( $_REQUEST['post_type'] ) ) { |
| 172 |
return sanitize_key( $_REQUEST['post_type'] ); |
| 173 |
} elseif ( isset( $_REQUEST['post'] ) && $_REQUEST['post'] ) { |
| 174 |
$id = $_REQUEST['post']; |
| 175 |
$post_obj = get_post( $id ); |
| 176 |
if( $post_obj ) { |
| 177 |
return $post_obj->post_type; |
| 178 |
} |
| 179 |
} |
| 180 |
return null; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 188 |
|
| 189 |
if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
| 190 |
function fca_eoi_fail_activation( $message ) { |
| 191 |
wp_die( sprintf( |
| 192 |
'<h2>%s</h2><p>%s</p><p><a class="button button-large" href="%s">%s</a></p>' |
| 193 |
, __( 'Ooops!' ) |
| 194 |
, __( $message ) |
| 195 |
, admin_url( 'plugins.php' ) |
| 196 |
, __( 'Go to plugins page' ) |
| 197 |
) ); |
| 198 |
} |
| 199 |
|
| 200 |
function fca_eoi_activation() { |
| 201 |
$plugins = get_plugins(); |
| 202 |
|
| 203 |
// Fail to activate the plugin if other Optin Cat plugins are already active |
| 204 |
foreach ( $plugins as $file => $plugin ) { |
| 205 |
if ( stripos( $plugin['PluginURI'], 'fatcatapps.com/optincat' ) !== false && is_plugin_active( $file ) ) { |
| 206 |
$current_plugin = $plugins[ plugin_basename( __FILE__ ) ]; |
| 207 |
fca_eoi_fail_activation( |
| 208 |
'Only one Optin Cat plugin can be active at a time, but you already have ' . |
| 209 |
htmlspecialchars( $plugin['Name'] ) . ' active. ' . |
| 210 |
'Please deactivate it before activating ' . |
| 211 |
htmlspecialchars( $current_plugin['Name'] ) . '.' ); |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
// Fail to activate the plugin if the providers or layouts directories are empty |
| 216 |
$providers = glob( FCA_EOI_PLUGIN_DIR . 'providers/*', GLOB_ONLYDIR ); |
| 217 |
$layouts = glob( FCA_EOI_PLUGIN_DIR . 'layouts/*', GLOB_ONLYDIR ); |
| 218 |
|
| 219 |
if ( empty( $providers ) || empty( $layouts ) ) { |
| 220 |
fca_eoi_fail_activation( 'Something went wrong. Please delete the plugin and install it again.' ); |
| 221 |
} |
| 222 |
|
| 223 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-functions.php'; |
| 224 |
|
| 225 |
//convert everyone to new CSS if they are on OLD |
| 226 |
fca_eoi_migrate_css(); |
| 227 |
//convert everyone to new Post Meta Format if they are on OLD |
| 228 |
fca_eoi_convert_post_meta(); |
| 229 |
|
| 230 |
//check for users of custom form, otherwise that feature is disabled |
| 231 |
$opt = get_option ( 'fca_eoi_allow_customform', '' ); |
| 232 |
if ( empty ( $opt ) ) { |
| 233 |
fca_eoi_set_custom_form_depreciation(); |
| 234 |
} |
| 235 |
|
| 236 |
// If everything went well, continue with the activation setup |
| 237 |
require FCA_EOI_PLUGIN_DIR . 'includes/eoi-activity.php'; |
| 238 |
EasyOptInsActivity::get_instance()->setup(); |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
} |
| 243 |
|
| 244 |
// If the plugin is not yet active, check for any obstacles in activation |
| 245 |
register_activation_hook( __FILE__, 'fca_eoi_activation' ); |
| 246 |
return; |
| 247 |
} |
| 248 |
|
| 249 |
$dh_easy_opt_ins_plugin = new DhEasyOptIns(); |
| 250 |
|