| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Show upgrading notifications for EOI |
| 5 |
* |
| 6 |
*/ |
| 7 |
class EasyOptInsUpgrade { |
| 8 |
|
| 9 |
private $settings; |
| 10 |
private $fca_maketing_page_left_menu; |
| 11 |
private $fca_maketing_page_top_ad; |
| 12 |
|
| 13 |
public function __construct( $settings=null ) { |
| 14 |
|
| 15 |
global $pagenow; |
| 16 |
$this->settings = $settings; |
| 17 |
|
| 18 |
$this->fca_maketing_page_left_menu = 'https://fatcatapps.com/optincat?utm_campaign=wp%2Bsubmenu&utm_source=Optin%2BCat%2BFree&utm_medium=plugin'; |
| 19 |
$this->fca_maketing_page_top_ad = 'https://fatcatapps.com/optincat?utm_campaign=plugin%2Btop%2Bad&utm_source=Optin%2BCat%2BFree&utm_medium=plugin'; |
| 20 |
|
| 21 |
add_action( 'admin_menu', array( $this, 'fca_eoi_upgrade_to_premium_menu' )); |
| 22 |
add_action( 'admin_footer', array( $this, 'admin_footer' ) ); |
| 23 |
} |
| 24 |
|
| 25 |
function admin_footer() { |
| 26 |
$this->fca_eoi_upgrade_to_premium_menu_js(); |
| 27 |
$this->show_upgrade_encouragement(); |
| 28 |
$this->show_upgrade_bar(); |
| 29 |
} |
| 30 |
|
| 31 |
function show_upgrade_encouragement() { |
| 32 |
if ( ! $this->is_in_eoi_page() ) { |
| 33 |
return; |
| 34 |
} |
| 35 |
|
| 36 |
$message = |
| 37 |
'<div>' . |
| 38 |
'Thanks for using Optin Cat. Do you like this plugin? ' . |
| 39 |
'<a href="' . $this->fca_maketing_page_top_ad . '" target="_blank">Optin Cat Premium</a> ' . |
| 40 |
'comes with even more features that help you grow your list. Love it or get your money back. ' . |
| 41 |
'<a href="' . $this->fca_maketing_page_top_ad . '" target="_blank">Learn more here</a>.' . |
| 42 |
'</div>'; |
| 43 |
|
| 44 |
?> |
| 45 |
<script> |
| 46 |
jQuery( function( $ ) { |
| 47 |
$( '#wpbody-content' ).append( <?php echo json_encode( $message ) ?> ); |
| 48 |
} ); |
| 49 |
</script> |
| 50 |
<?php |
| 51 |
} |
| 52 |
|
| 53 |
function show_upgrade_bar() { |
| 54 |
if ( ! $this->is_in_eoi_page() ) { |
| 55 |
return; |
| 56 |
} |
| 57 |
|
| 58 |
$is_mailchimp = in_array( 'mailchimp', array_keys( $this->settings[ 'providers' ] ) ); |
| 59 |
|
| 60 |
?> |
| 61 |
<style> |
| 62 |
.fca_eoi_upgrade_bar { |
| 63 |
padding: 12px; |
| 64 |
background-color: #FCF8E3; |
| 65 |
} |
| 66 |
|
| 67 |
.fca_eoi_upgrade_bar.fca_eoi_upgrade_bar_inner { |
| 68 |
border-top: 1px solid #e5e5e5; |
| 69 |
margin: 0 0 -12px -12px; |
| 70 |
} |
| 71 |
|
| 72 |
.fca_eoi_upgrade_bar.fca_eoi_upgrade_bar_page { |
| 73 |
border: 1px solid #e5e5e5; |
| 74 |
margin: 12px 12px 12px 0; |
| 75 |
} |
| 76 |
|
| 77 |
.fca_eoi_upgrade_bar a { |
| 78 |
font-size: 14px; |
| 79 |
font-weight: bold; |
| 80 |
} |
| 81 |
|
| 82 |
.fca_eoi_upgrade_sidebar { |
| 83 |
float: right; |
| 84 |
margin-right: 22px; |
| 85 |
margin-top: 11px; |
| 86 |
width: 270px; |
| 87 |
} |
| 88 |
|
| 89 |
.fca_eoi_upgrade_sidebar .fca_eoi_centered { |
| 90 |
text-align: center; |
| 91 |
} |
| 92 |
|
| 93 |
.fca_eoi_upgrade_sidebar .button-large { |
| 94 |
font-size: 17px; |
| 95 |
line-height: 30px; |
| 96 |
height: 32px; |
| 97 |
} |
| 98 |
|
| 99 |
.fca_eoi_upgrade_sidebar .last-blurb { |
| 100 |
font-size: 17px; |
| 101 |
} |
| 102 |
|
| 103 |
#wpbody-content.fca_eoi_upgrade_sidebar_present { |
| 104 |
width: calc( 100% - 300px ); |
| 105 |
} |
| 106 |
</style> |
| 107 |
|
| 108 |
<div class="sidebar-container metabox-holder fca_eoi_upgrade_sidebar" id="fca_eoi_upgrade_sidebar" style="display: none"> |
| 109 |
<div class="postbox"> |
| 110 |
<h3 class="wp-ui-primary"><span>Wanna Grow Your List?</span></h3> |
| 111 |
<div class="inside"> |
| 112 |
<div class="main"> |
| 113 |
<p class="last-blurb fca_eoi_centered"> |
| 114 |
Optin Cat Premium Boosts Conversions |
| 115 |
</p> |
| 116 |
|
| 117 |
<ul> |
| 118 |
<li><div class="dashicons dashicons-yes"></div> Mobile-friendly Popups</li> |
| 119 |
<li><div class="dashicons dashicons-yes"></div> Smart Popup Targeting</li> |
| 120 |
<li><div class="dashicons dashicons-yes"></div> More Layouts</li> |
| 121 |
<li><div class="dashicons dashicons-yes"></div> Two-Step Optins</li> |
| 122 |
<li><div class="dashicons dashicons-yes"></div> Content Upgrades</li> |
| 123 |
<li><div class="dashicons dashicons-yes"></div> Exit Intervention</li> |
| 124 |
<li><div class="dashicons dashicons-yes"></div> Priority Email Support</li> |
| 125 |
<?php if ( $is_mailchimp ): ?> |
| 126 |
<li><div class="dashicons dashicons-yes"></div> Mailchimp Single Optin</li> |
| 127 |
<?php endif ?> |
| 128 |
<li><div class="dashicons dashicons-yes"></div> And much more …</li> |
| 129 |
</ul> |
| 130 |
|
| 131 |
<div class="fca_eoi_centered"> |
| 132 |
<a href="<?php echo $this->fca_maketing_page_top_ad ?>" class="button-primary button-large" target="_blank"> |
| 133 |
Upgrade to Premium |
| 134 |
</a> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
</div> |
| 139 |
</div> |
| 140 |
|
| 141 |
<?php |
| 142 |
|
| 143 |
$template = '<div class="__class__"><a href="' . $this->fca_maketing_page_top_ad . '" target="_blank">__text__ >></a></div>'; |
| 144 |
|
| 145 |
$script = basename( $_SERVER['SCRIPT_NAME'] ); |
| 146 |
if ( $script == 'post.php' || $script == 'post-new.php' ) { ?> |
| 147 |
<script> |
| 148 |
jQuery( function( $ ) { |
| 149 |
var layouts_message = <?php echo json_encode( str_replace( |
| 150 |
array( '__class__', '__text__' ), |
| 151 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Upgrade to Premium for more layouts & design options' ), |
| 152 |
$template |
| 153 |
) ) ?>; |
| 154 |
|
| 155 |
$( '#fca_eoi_layout_select' ).before( layouts_message ); |
| 156 |
$( '#fca_eoi_settings' ).after( '<br class="clear"/>' + layouts_message ); |
| 157 |
|
| 158 |
$( '#fca_eoi_publish_lightbox_mode_two_step_optin' ).after( <?php echo json_encode( str_replace( |
| 159 |
array( '__class__', '__text__' ), |
| 160 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Want smart popup targeting, mobile popups, exit intervention or two-step optins? Upgrade to Premium' ), |
| 161 |
$template |
| 162 |
) ) ?> ); |
| 163 |
|
| 164 |
<?php if ( in_array( 'mailchimp', array_keys( $this->settings['providers'] ) ) ): ?> |
| 165 |
$( '#fca_eoi_fieldset_form_mailchimp_integration' ).append( <?php echo json_encode( str_replace( |
| 166 |
array( '__class__', '__text__' ), |
| 167 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Want to set up MailChimp Single Optin? Upgrade to Premium' ), |
| 168 |
$template |
| 169 |
) ) ?> ); |
| 170 |
<?php endif ?> |
| 171 |
|
| 172 |
var $power_ups_span = $( '.hndle span:contains("Power Ups")' ); |
| 173 |
if ( $power_ups_span && $power_ups_span.length > 0 ) { |
| 174 |
$power_ups_span.parent().next( '.inside' ).append( <?php echo json_encode( '<br/>' . str_replace( |
| 175 |
array( '__class__', '__text__' ), |
| 176 |
array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Upgrade to Premium and get access to the Offers Powerup' ), |
| 177 |
$template |
| 178 |
) ) ?> ); |
| 179 |
} |
| 180 |
} ); |
| 181 |
</script> |
| 182 |
<?php } |
| 183 |
|
| 184 |
elseif ( $script == 'edit.php' && ( empty( $_REQUEST['page'] ) || $_REQUEST['page'] == 'eoi_powerups' ) ) { ?> |
| 185 |
<script> |
| 186 |
jQuery( function( $ ) { |
| 187 |
$( '#wpbody-content' ).addClass( 'fca_eoi_upgrade_sidebar_present' ).before( $( '#fca_eoi_upgrade_sidebar' ).show() ); |
| 188 |
} ); |
| 189 |
</script> |
| 190 |
<?php } |
| 191 |
} |
| 192 |
|
| 193 |
function fca_eoi_upgrade_to_premium_menu() { |
| 194 |
|
| 195 |
$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' )); |
| 196 |
add_action( 'load-' . $page_hook , array( $this, 'fca_eoi_upgrade_to_premium_redirect' )); |
| 197 |
} |
| 198 |
|
| 199 |
function fca_eoi_upgrade_to_premium_redirect() { |
| 200 |
|
| 201 |
wp_redirect( $this->fca_maketing_page_left_menu, 301 ); |
| 202 |
exit(); |
| 203 |
} |
| 204 |
|
| 205 |
function fca_eoi_upgrade_to_premium_menu_js() |
| 206 |
{ |
| 207 |
?> |
| 208 |
<script type="text/javascript"> |
| 209 |
jQuery(document).ready(function ($) { |
| 210 |
$('a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"]').on('click', function () { |
| 211 |
$(this).attr('target', '_blank'); |
| 212 |
}); |
| 213 |
}); |
| 214 |
</script> |
| 215 |
<style> |
| 216 |
a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"] { |
| 217 |
color: #ee6800 !important; |
| 218 |
} |
| 219 |
a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"]:hover { |
| 220 |
color: #C65700 !important; |
| 221 |
} |
| 222 |
.eoi-changelogs { |
| 223 |
background: #f1f1f1; |
| 224 |
} |
| 225 |
.eoi-changelogs-content { |
| 226 |
margin: 20px 10px; |
| 227 |
background: #fff; |
| 228 |
} |
| 229 |
|
| 230 |
</style> |
| 231 |
<?php |
| 232 |
} |
| 233 |
|
| 234 |
function is_in_eoi_page() { |
| 235 |
return ( ! empty( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] == 'easy-opt-ins' ) || |
| 236 |
( ! empty( $GLOBALS['post'] ) && $GLOBALS['post']->post_type == 'easy-opt-ins' ); |
| 237 |
} |
| 238 |
} |