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