EasyOptInsUpgrade

Show upgrading notifications for EOI.

Defined (1)

The class is defined in the following location(s).

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