| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Show upgrading notifications for EOI |
| 5 |
* |
| 6 |
*/ |
| 7 |
class EasyOptInsUpgrade { |
| 8 |
|
| 9 |
private $settings; |
| 10 |
|
| 11 |
private $submenu_link; |
| 12 |
private $sidebar_link; |
| 13 |
private $review_link; |
| 14 |
private $support_link; |
| 15 |
private $editor_link; |
| 16 |
|
| 17 |
public function __construct( $settings=null ) { |
| 18 |
|
| 19 |
global $pagenow; |
| 20 |
$this->settings = $settings; |
| 21 |
|
| 22 |
if ( $this->has_provider( 'aweber' ) ) { |
| 23 |
$this->submenu_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=wp%2Bsubmenu&utm_source=Optin%2BCat%2BFree%2BAweber&utm_medium=plugin'; |
| 24 |
$this->sidebar_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=sidebar%2Bad&utm_source=Optin%2BCat%2BFree%2BAweber&utm_medium=plugin'; |
| 25 |
$this->editor_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=editor%2Bad&utm_source=Optin%2BCat%2BFree%2BAweber&utm_medium=plugin'; |
| 26 |
$this->review_link = 'https://wordpress.org/support/view/plugin-reviews/aweber-wp#postform'; |
| 27 |
$this->support_link = 'https://wordpress.org/support/plugin/aweber-wp'; |
| 28 |
|
| 29 |
} elseif ( $this->has_provider( 'campaignmonitor' ) ) { |
| 30 |
$this->submenu_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=wp%2Bsubmenu&utm_source=Optin%2BCat%2BFree%2BCampaign%2BMonitor&utm_medium=plugin'; |
| 31 |
$this->sidebar_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=sidebar%2Bad&utm_source=Optin%2BCat%2BFree%2BCampaign%2BMonitor&utm_medium=plugin'; |
| 32 |
$this->editor_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=editor%2Bad&utm_source=Optin%2BCat%2BFree%2BCampaign%2BMonitor&utm_medium=plugin'; |
| 33 |
$this->review_link = 'https://wordpress.org/support/view/plugin-reviews/campaign-monitor-wp#postform'; |
| 34 |
$this->support_link = 'https://wordpress.org/support/plugin/campaign-monitor-wp'; |
| 35 |
|
| 36 |
} elseif ( $this->has_provider( 'getresponse' ) ) { |
| 37 |
$this->submenu_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=wp%2Bsubmenu&utm_source=Optin%2BCat%2BFree%2BGetResponse&utm_medium=plugin'; |
| 38 |
$this->sidebar_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=sidebar%2Bad&utm_source=Optin%2BCat%2BFree%2BGetResponse&utm_medium=plugin'; |
| 39 |
$this->editor_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=editor%2Bad&utm_source=Optin%2BCat%2BFree%2BGetResponse&utm_medium=plugin'; |
| 40 |
$this->review_link = 'https://wordpress.org/support/view/plugin-reviews/getresponse#postform'; |
| 41 |
$this->support_link = 'https://wordpress.org/support/plugin/getresponse'; |
| 42 |
|
| 43 |
} elseif ( $this->has_provider( 'mailchimp' ) ) { |
| 44 |
$this->submenu_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=wp%2Bsubmenu&utm_source=Optin%2BCat%2BFree%2BMailChimp&utm_medium=plugin'; |
| 45 |
$this->sidebar_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=sidebar%2Bad&utm_source=Optin%2BCat%2BFree%2BMailChimp&utm_medium=plugin'; |
| 46 |
$this->editor_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=editor%2Bad&utm_source=Optin%2BCat%2BFree%2BMailChimp&utm_medium=plugin'; |
| 47 |
$this->review_link = 'https://wordpress.org/support/view/plugin-reviews/mailchimp-wp#postform'; |
| 48 |
$this->support_link = 'https://wordpress.org/support/plugin/mailchimp-wp'; |
| 49 |
} else { |
| 50 |
$this->submenu_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=wp%2Bsubmenu&utm_source=Optin%2BCat%2BFree&utm_medium=plugin'; |
| 51 |
$this->sidebar_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=sidebar%2Bad&utm_source=Optin%2BCat%2BFree&utm_medium=plugin'; |
| 52 |
$this->editor_link = 'https://fatcatapps.com/optincat/upgrade/?utm_campaign=editor%2Bad&utm_source=Optin%2BCat%2BFree&utm_medium=plugin'; |
| 53 |
$this->review_link = 'https://wordpress.org/support/view/plugin-reviews/mailchimp-wp#postform'; |
| 54 |
$this->support_link = 'https://wordpress.org/support/plugin/mailchimp-wp'; |
| 55 |
} |
| 56 |
|
| 57 |
add_action( 'admin_menu', array( $this, 'fca_eoi_upgrade_to_premium_menu' )); |
| 58 |
add_action( 'admin_footer', array( $this, 'admin_footer' ) ); |
| 59 |
add_filter( 'admin_footer_text', array( $this, 'show_upgrade_encouragement' ) ); |
| 60 |
add_action( 'admin_notices', array( $this, 'show_quick_links' ) ); |
| 61 |
} |
| 62 |
|
| 63 |
private function has_provider( $provider ) { |
| 64 |
return in_array( $provider, array_keys( $this->settings['providers'] ) ); |
| 65 |
} |
| 66 |
|
| 67 |
function admin_footer() { |
| 68 |
$this->fca_eoi_upgrade_to_premium_menu_js(); |
| 69 |
$this->show_upgrade_bar(); |
| 70 |
} |
| 71 |
|
| 72 |
function show_quick_links() { |
| 73 |
if ( ! $this->is_in_eoi_page() ) { |
| 74 |
return; |
| 75 |
} |
| 76 |
echo '<div class="notice notice-info is-dismissible">'; |
| 77 |
echo '<p><strong>Quick Links:</strong> <a href="'. esc_url( $this->support_link ) .'" target="_blank">Problems? Get help here</a>. | <a href="'. esc_url( $this->review_link ) .'" target="_blank"> Like this plugin? Please leave a review</a>.</p>'; |
| 78 |
echo '</div>'; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
function show_upgrade_encouragement( $text ) { |
| 83 |
if ( ! $this->is_in_eoi_page() ) { |
| 84 |
return $text; |
| 85 |
} |
| 86 |
|
| 87 |
$message = "<span style='font-style: italic;'>| Thank you for using <a href='$this->sidebar_link' target='_blank'>Optin Cat</a>. " . |
| 88 |
"Wanna grow your list faster? Check out <a href='$this->sidebar_link' target='_blank'>Optin Cat Premium</a>. " . |
| 89 |
"Love it or get your money back. </span>"; |
| 90 |
|
| 91 |
return $text . $message; |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
function show_upgrade_bar() { |
| 96 |
if ( ! $this->is_in_eoi_page() ) { |
| 97 |
return; |
| 98 |
} |
| 99 |
|
| 100 |
?> |
| 101 |
<style> |
| 102 |
.fca_eoi_upgrade_bar { |
| 103 |
padding: 12px; |
| 104 |
background-color: #FCF8E3; |
| 105 |
width: 100%; |
| 106 |
} |
| 107 |
|
| 108 |
.fca_eoi_upgrade_bar.top_border { |
| 109 |
border-top: 1px solid #ccc; |
| 110 |
width: auto; |
| 111 |
} |
| 112 |
|
| 113 |
.fca_eoi_upgrade_bar.fca_eoi_upgrade_bar_inner { |
| 114 |
border-top: 1px solid #e5e5e5; |
| 115 |
margin: 0 0 -12px -12px; |
| 116 |
margin-top: 10px; |
| 117 |
} |
| 118 |
|
| 119 |
.fca_eoi_upgrade_bar.fca_eoi_upgrade_bar_page { |
| 120 |
border: 1px solid #e5e5e5; |
| 121 |
margin: 12px 12px 12px 0; |
| 122 |
} |
| 123 |
|
| 124 |
.fca_eoi_upgrade_bar a { |
| 125 |
font-size: 14px; |
| 126 |
font-weight: bold; |
| 127 |
} |
| 128 |
|
| 129 |
.fca_eoi_upgrade_sidebar { |
| 130 |
float: right; |
| 131 |
margin-right: 22px; |
| 132 |
margin-top: 11px; |
| 133 |
width: 270px; |
| 134 |
} |
| 135 |
|
| 136 |
.fca_eoi_upgrade_sidebar .fca_eoi_centered { |
| 137 |
text-align: center; |
| 138 |
} |
| 139 |
|
| 140 |
.fca_eoi_upgrade_sidebar .button-large { |
| 141 |
font-size: 17px; |
| 142 |
line-height: 30px; |
| 143 |
height: 32px; |
| 144 |
} |
| 145 |
|
| 146 |
.fca_eoi_upgrade_sidebar .last-blurb { |
| 147 |
font-size: 17px; |
| 148 |
} |
| 149 |
|
| 150 |
#wpbody-content.fca_eoi_upgrade_sidebar_present { |
| 151 |
width: calc( 100% - 300px ); |
| 152 |
} |
| 153 |
</style> |
| 154 |
|
| 155 |
<div class="sidebar-container metabox-holder fca_eoi_upgrade_sidebar" id="fca_eoi_upgrade_sidebar" style="display: none"> |
| 156 |
<div class="postbox"> |
| 157 |
<h3 class="wp-ui-primary"><span>Get More Email Subscribers</span></h3> |
| 158 |
<div class="inside"> |
| 159 |
<div class="main"> |
| 160 |
<p class="last-blurb fca_eoi_centered"> |
| 161 |
Optin Cat Premium Boosts Conversions |
| 162 |
</p> |
| 163 |
<p>Optin Cat Premium comes with <em>everything you need</em> to grow your email list.</p> |
| 164 |
<ul> |
| 165 |
<li><div class="dashicons dashicons-yes"></div> 4 Brand New Optin Types</li> |
| 166 |
<li><div class="dashicons dashicons-yes"></div> Tons of Layout & Design Options</li> |
| 167 |
<li><div class="dashicons dashicons-yes"></div> Smart Optin Targeting</li> |
| 168 |
<li><div class="dashicons dashicons-yes"></div> Content Upgrades</li> |
| 169 |
<li><div class="dashicons dashicons-yes"></div> Exit Intervention Popups</li> |
| 170 |
<li><div class="dashicons dashicons-yes"></div> Attention Grabbing Effects</li> |
| 171 |
<li><div class="dashicons dashicons-yes"></div> And much more …</li> |
| 172 |
</ul> |
| 173 |
|
| 174 |
<div class="fca_eoi_centered"> |
| 175 |
<a href="<?php echo esc_url( $this->sidebar_link ) ?>" class="button-primary button-large" target="_blank"> |
| 176 |
Upgrade to Premium > |
| 177 |
</a> |
| 178 |
</div> |
| 179 |
</div> |
| 180 |
</div> |
| 181 |
</div> |
| 182 |
</div> |
| 183 |
|
| 184 |
<?php |
| 185 |
|
| 186 |
$template = '<div class="__class__"><a href="' . $this->editor_link . '" target="_blank">__text__ >></a></div>'; |
| 187 |
|
| 188 |
$script = empty( $_SERVER['SCRIPT_NAME'] ) ? '' : basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ); |
| 189 |
if ( $script == 'post.php' || $script == 'post-new.php' ) { ?> |
| 190 |
<script> |
| 191 |
jQuery(document).ready( function($) { |
| 192 |
var layouts_message = <?php echo wp_json_encode( str_replace( |
| 193 |
array( '__class__', '__text__' ), |
| 194 |
array( 'fca_eoi_upgrade_bar top_border', 'Upgrade to Premium to get more powerful optins (optin bar, slide in, comment checkbox, 2-step optin) and tons of design options.' ), |
| 195 |
$template |
| 196 |
) ) ?>; |
| 197 |
|
| 198 |
$( '.fca_eoi_accordion_tab' ).last().next().after( layouts_message ); |
| 199 |
|
| 200 |
layouts_message = <?php echo wp_json_encode( str_replace( |
| 201 |
array( '__class__', '__text__' ), |
| 202 |
array( 'fca_eoi_upgrade_bar', 'Upgrade to Premium for more layouts & design options' ), |
| 203 |
$template |
| 204 |
) ) ?>; |
| 205 |
|
| 206 |
$( '#fca_eoi_form_preview' ).next().after( layouts_message ); |
| 207 |
|
| 208 |
$( '#fca_eoi_publish_lightbox_mode_two_step_optin' ).after( <?php echo wp_json_encode( str_replace( |
| 209 |
array( '__class__', '__text__' ), |
| 210 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Want smart optin targeting, exit intervention popups or two-step optins? Upgrade to Premium' ), |
| 211 |
$template |
| 212 |
) ) ?> ); |
| 213 |
|
| 214 |
|
| 215 |
var $power_ups_span = $( '.hndle span:contains("Power Ups")' ); |
| 216 |
if ( $power_ups_span && $power_ups_span.length > 0 ) { |
| 217 |
$power_ups_span.parent().next( '.inside' ).append( <?php echo wp_json_encode( '<br/>' . str_replace( |
| 218 |
array( '__class__', '__text__' ), |
| 219 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Upgrade to Premium and get access to the Optin Bait Delivery Powerup' ), |
| 220 |
$template |
| 221 |
) ) ?> ); |
| 222 |
} |
| 223 |
|
| 224 |
var publication_message = <?php echo wp_json_encode( str_replace( |
| 225 |
array( '__class__', '__text__' ), |
| 226 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Get more opt-ins and happier users with our advanced rule builder. Upgrade to Premium >>' ), |
| 227 |
$template |
| 228 |
) ) ?>; |
| 229 |
|
| 230 |
$( '#fca_eoi_publish_lightbox' ).children().last().after( publication_message ); |
| 231 |
|
| 232 |
} ); |
| 233 |
</script> |
| 234 |
<?php } |
| 235 |
|
| 236 |
elseif ( $script == 'edit.php' && ( empty( $_REQUEST['page'] ) || $_REQUEST['page'] == 'eoi_powerups' ) ) { ?> |
| 237 |
<script> |
| 238 |
jQuery( function( $ ) { |
| 239 |
$( '#wpbody-content' ).addClass( 'fca_eoi_upgrade_sidebar_present' ).before( $( '#fca_eoi_upgrade_sidebar' ).show() ); |
| 240 |
} ); |
| 241 |
</script> |
| 242 |
<?php } |
| 243 |
} |
| 244 |
|
| 245 |
function fca_eoi_upgrade_to_premium_menu() { |
| 246 |
|
| 247 |
$page_hook = add_submenu_page( 'edit.php?post_type=easy-opt-ins', 'Upgrade to Premium', 'Upgrade to Premium', 'manage_options', 'eoi_premium_upgrade', array( $this, 'fca_eoi_upgrade_to_premium' )); |
| 248 |
add_action( 'load-' . $page_hook , array( $this, 'fca_eoi_upgrade_to_premium_redirect' )); |
| 249 |
} |
| 250 |
|
| 251 |
function fca_eoi_upgrade_to_premium_redirect() { |
| 252 |
|
| 253 |
wp_redirect( $this->submenu_link, 301 ); |
| 254 |
exit(); |
| 255 |
} |
| 256 |
|
| 257 |
function fca_eoi_upgrade_to_premium_menu_js() |
| 258 |
{ |
| 259 |
?> |
| 260 |
<script type="text/javascript"> |
| 261 |
jQuery(document).ready(function ($) { |
| 262 |
$('a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"]').on('click', function () { |
| 263 |
$(this).attr('target', '_blank'); |
| 264 |
}); |
| 265 |
}); |
| 266 |
</script> |
| 267 |
<style> |
| 268 |
a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"] { |
| 269 |
color: #ee6800 !important; |
| 270 |
} |
| 271 |
a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"]:hover { |
| 272 |
color: #C65700 !important; |
| 273 |
} |
| 274 |
.eoi-changelogs { |
| 275 |
background: #f1f1f1; |
| 276 |
} |
| 277 |
.eoi-changelogs-content { |
| 278 |
margin: 20px 10px; |
| 279 |
background: #fff; |
| 280 |
} |
| 281 |
|
| 282 |
</style> |
| 283 |
<?php |
| 284 |
} |
| 285 |
|
| 286 |
function is_in_eoi_page() { |
| 287 |
return ( ! empty( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] == 'easy-opt-ins' ) || |
| 288 |
( ! empty( $GLOBALS['post'] ) && $GLOBALS['post']->post_type == 'easy-opt-ins' ); |
| 289 |
} |
| 290 |
} |