/includes/eoi-upgrade.php

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