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. margin-top: 10px; 
  105.  
  106. .fca_eoi_upgrade_bar.fca_eoi_upgrade_bar_page { 
  107. border: 1px solid #e5e5e5; 
  108. margin: 12px 12px 12px 0; 
  109.  
  110. .fca_eoi_upgrade_bar a { 
  111. font-size: 14px; 
  112. font-weight: bold; 
  113.  
  114. .fca_eoi_upgrade_sidebar { 
  115. float: right; 
  116. margin-right: 22px; 
  117. margin-top: 11px; 
  118. width: 270px; 
  119.  
  120. .fca_eoi_upgrade_sidebar .fca_eoi_centered { 
  121. text-align: center; 
  122.  
  123. .fca_eoi_upgrade_sidebar .button-large { 
  124. font-size: 17px; 
  125. line-height: 30px; 
  126. height: 32px; 
  127.  
  128. .fca_eoi_upgrade_sidebar .last-blurb { 
  129. font-size: 17px; 
  130.  
  131. #wpbody-content.fca_eoi_upgrade_sidebar_present { 
  132. width: calc( 100% - 300px ); 
  133. </style> 
  134.  
  135. <div class="sidebar-container metabox-holder fca_eoi_upgrade_sidebar" id="fca_eoi_upgrade_sidebar" style="display: none"> 
  136. <div class="postbox"> 
  137. <h3 class="wp-ui-primary"><span>Get More Email Subscribers</span></h3> 
  138. <div class="inside"> 
  139. <div class="main"> 
  140. <p class="last-blurb fca_eoi_centered"> 
  141. Optin Cat Premium Boosts Conversions 
  142. </p> 
  143. <p>Optin Cat Premium comes with <em>everything you need</em> to grow your email list.</p> 
  144. <ul> 
  145. <li><div class="dashicons dashicons-yes"></div> 4 Brand New Optin Types</li> 
  146. <li><div class="dashicons dashicons-yes"></div> Tons of Layout & Design Options</li> 
  147. <li><div class="dashicons dashicons-yes"></div> Smart Optin Targeting</li> 
  148. <li><div class="dashicons dashicons-yes"></div> Content Upgrades</li> 
  149. <li><div class="dashicons dashicons-yes"></div> Exit Intervention Popups</li> 
  150. <li><div class="dashicons dashicons-yes"></div> Attention Grabbing Effects</li> 
  151. <?php if ( $is_mailchimp ): ?> 
  152. <li><div class="dashicons dashicons-yes"></div> Mailchimp Single Optin</li> 
  153. <?php endif ?> 
  154. <li><div class="dashicons dashicons-yes"></div> And much more …</li> 
  155. </ul> 
  156.  
  157. <div class="fca_eoi_centered"> 
  158. <a href="<?php echo $this->sidebar_link ?>" class="button-primary button-large" target="_blank"> 
  159. Upgrade to Premium > 
  160. </a> 
  161. </div> 
  162. </div> 
  163. </div> 
  164. </div> 
  165. </div> 
  166.  
  167. <?php 
  168.  
  169. $template = '<div class="__class__"><a href="' . $this->editor_link . '" target="_blank">__text__ >></a></div>'; 
  170.  
  171. $script = basename( $_SERVER['SCRIPT_NAME'] ); 
  172. if ( $script == 'post.php' || $script == 'post-new.php' ) { ?> 
  173. <script> 
  174. jQuery(document).ready( function($) { 
  175. var layouts_message = <?php echo json_encode( str_replace( 
  176. array( '__class__', '__text__' ),  
  177. 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.' ),  
  178. $template 
  179. ) ) ?>; 
  180.  
  181. $( '.fca_eoi_accordion_tab' ).last().next().after( layouts_message ); 
  182.  
  183. layouts_message = <?php echo json_encode( str_replace( 
  184. array( '__class__', '__text__' ),  
  185. array( 'fca_eoi_upgrade_bar', 'Upgrade to Premium for more layouts & design options' ),  
  186. $template 
  187. ) ) ?>; 
  188.  
  189. $( '#fca_eoi_form_preview' ).next().after( layouts_message ); 
  190.  
  191. $( '#fca_eoi_publish_lightbox_mode_two_step_optin' ).after( <?php echo json_encode( str_replace( 
  192. array( '__class__', '__text__' ),  
  193. array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Want smart optin targeting, exit intervention popups or two-step optins? Upgrade to Premium' ),  
  194. $template 
  195. ) ) ?> ); 
  196.  
  197. <?php if ( in_array( 'mailchimp', array_keys( $this->settings['providers'] ) ) ): ?> 
  198. $( '#fca_eoi_fieldset_form_mailchimp_integration' ).append( <?php echo json_encode( str_replace( 
  199. array( '__class__', '__text__' ),  
  200. array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Want to set up MailChimp Single Optin? Upgrade to Premium' ),  
  201. $template 
  202. ) ) ?> ); 
  203. <?php endif ?> 
  204.  
  205. var $power_ups_span = $( '.hndle span:contains("Power Ups")' ); 
  206. if ( $power_ups_span && $power_ups_span.length > 0 ) { 
  207. $power_ups_span.parent().next( '.inside' ).append( <?php echo json_encode( '<br/>' . str_replace( 
  208. array( '__class__', '__text__' ),  
  209. array( 'fca_eoi_upgrade_bar fca_eoi_upgrade_bar_inner', 'Upgrade to Premium and get access to the Optin Bait Delivery Powerup' ),  
  210. $template 
  211. ) ) ?> ); 
  212.  
  213. var publication_message = <?php echo json_encode( str_replace( 
  214. array( '__class__', '__text__' ),  
  215. 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 >>' ),  
  216. $template 
  217. ) ) ?>; 
  218.  
  219. $( '#fca_eoi_publish_lightbox' ).children().last().after( publication_message ); 
  220.  
  221. } ); 
  222. </script> 
  223. <?php } 
  224.  
  225. elseif ( $script == 'edit.php' && ( empty( $_REQUEST['page'] ) || $_REQUEST['page'] == 'eoi_powerups' ) ) { ?> 
  226. <script> 
  227. jQuery( function( $ ) { 
  228. $( '#wpbody-content' ).addClass( 'fca_eoi_upgrade_sidebar_present' ).before( $( '#fca_eoi_upgrade_sidebar' ).show() ); 
  229. } ); 
  230. </script> 
  231. <?php } 
  232.  
  233. function fca_eoi_upgrade_to_premium_menu() { 
  234.  
  235. $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' )); 
  236. add_action( 'load-' . $page_hook , array( $this, 'fca_eoi_upgrade_to_premium_redirect' )); 
  237.  
  238. function fca_eoi_upgrade_to_premium_redirect() { 
  239.  
  240. wp_redirect( $this->submenu_link, 301 ); 
  241. exit(); 
  242.  
  243. function fca_eoi_upgrade_to_premium_menu_js() 
  244. ?> 
  245. <script type="text/javascript"> 
  246. jQuery(document).ready(function ($) { 
  247. $('a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"]').on('click', function () { 
  248. $(this).attr('target', '_blank'); 
  249. }); 
  250. }); 
  251. </script> 
  252. <style> 
  253. a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"] { 
  254. color: #ee6800 !important; 
  255. a[href="edit.php?post_type=easy-opt-ins&page=eoi_premium_upgrade"]:hover { 
  256. color: #C65700 !important; 
  257. .eoi-changelogs { 
  258. background: #f1f1f1; 
  259. .eoi-changelogs-content { 
  260. margin: 20px 10px; 
  261. background: #fff; 
  262.  
  263. </style> 
  264. <?php  
  265.  
  266. function is_in_eoi_page() { 
  267. return ( ! empty( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] == 'easy-opt-ins' ) || 
  268. ( ! empty( $GLOBALS['post'] ) && $GLOBALS['post']->post_type == 'easy-opt-ins' );