No Description

Extend.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. /********************************************
  3. * Copyright (c) 2020, Code Atlantic LLC
  4. *******************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit;
  7. }
  8. /**
  9. * Class PUM_Admin_Extend
  10. */
  11. class PUM_Admin_Extend {
  12. /**
  13. * Return array of Popup Maker extensions.
  14. *
  15. * @return array|mixed|object
  16. */
  17. public static function available_extensions() {
  18. $json_data = file_get_contents( Popup_Maker::$DIR . 'includes/extension-list.json' );
  19. return json_decode( $json_data, true );
  20. }
  21. /**
  22. * Support Page
  23. *
  24. * Renders the support page contents.
  25. */
  26. public static function page() {
  27. ?>
  28. <div class="wrap">
  29. <h1><?php _e( 'Upgrade', 'popup-maker' ) ?></h1>
  30. <?php PUM_Upsell::display_addon_tabs(); ?>
  31. <article class="upgrade-wrapper">
  32. <section class="upgrade-wrapper-hero">
  33. <h2>Drive Even More Opt-Ins and Sales With Our Premium Features</h2>
  34. <p>Our premium plans give you more:</p>
  35. <ul>
  36. <li>Triggers - Scroll, Exit-intent, Add-to-cart, and more</li>
  37. <li>Integrations - MailChimp, WooCommerce, and more</li>
  38. <li>Conditions - Show popups to visitors from a certain site, from search engines, using certain browsers, who has viewed X pages, and more </li>
  39. <li>And much more!</li>
  40. </ul>
  41. <a href="https://wppopupmaker.com/pricing/?utm_campaign=upsell&utm_medium=plugin&utm_source=plugin-extension-page&utm_content=hero-cta" class="button button-primary" target="_blank" rel="noreferrer noopener">View pricing</a>
  42. </section>
  43. <section class="upgrade-wrapper-features">
  44. <h2>Our Most Popular Premium Features</h2>
  45. <?php self::render_extension_list(); ?>
  46. <a href="https://wppopupmaker.com/extensions/?utm_campaign=upsell&utm_medium=plugin&utm_source=plugin-extension-page&utm_content=browse-all-bottom" class="button-primary" title="<?php _e( 'See All Premium Features', 'popup-maker' ); ?>" target="_blank" rel="noreferrer noopener"><?php _e( 'See All Premium Features', 'popup-maker' ); ?></a>
  47. </section>
  48. </article>
  49. </div>
  50. <?php
  51. }
  52. /**
  53. * Render extension tab extensions list.
  54. */
  55. public static function render_extension_list() {
  56. // Set a new campaign for tracking purposes
  57. $campaign = 'PUMExtensionsPage';
  58. $extensions = self::available_extensions();
  59. ?>
  60. <ul class="extensions-available">
  61. <?php
  62. // $plugins = get_plugins();
  63. // $installed_plugins = array();
  64. // foreach ( $plugins as $key => $plugin ) {
  65. // $is_active = is_plugin_active( $key );
  66. // $installed_plugin = array(
  67. // 'is_active' => $is_active,
  68. // );
  69. // $installerUrl = add_query_arg( array(
  70. // 'action' => 'activate',
  71. // 'plugin' => $key,
  72. // 'em' => 1,
  73. // ), network_admin_url( 'plugins.php' ) //admin_url('update.php')
  74. // );
  75. // $installed_plugin["activation_url"] = $is_active ? "" : wp_nonce_url( $installerUrl, 'activate-plugin_' . $key );
  76. //
  77. //
  78. // $installerUrl = add_query_arg( array(
  79. // 'action' => 'deactivate',
  80. // 'plugin' => $key,
  81. // 'em' => 1,
  82. // ), network_admin_url( 'plugins.php' ) //admin_url('update.php')
  83. // );
  84. // $installed_plugin["deactivation_url"] = ! $is_active ? "" : wp_nonce_url( $installerUrl, 'deactivate-plugin_' . $key );
  85. // $installed_plugins[ $key ] = $installed_plugin;
  86. // }
  87. $existing_extension_images = self::extensions_with_local_image();
  88. if ( ! empty( $extensions ) ) {
  89. shuffle( $extensions );
  90. foreach ( $extensions as $key => $ext ) {
  91. unset( $extensions[ $key ] );
  92. $extensions[ $ext['slug'] ] = $ext;
  93. }
  94. $i = 0;
  95. foreach ( $extensions as $extension ) : ?>
  96. <li class="available-extension-inner <?php echo esc_attr( $extension['slug'] ); ?>">
  97. <h3>
  98. <a target="_blank" href="<?php echo esc_url( $extension['homepage'] ); ?>?utm_source=plugin-extension-page&utm_medium=plugin&utm_campaign=upsell&utm_content=<?php echo esc_attr( urlencode( str_replace( ' ', '+', $extension['name'] ) ) ); ?>-<?php echo esc_attr( $i ); ?>">
  99. <?php echo esc_html( $extension['name'] ) ?>
  100. </a>
  101. </h3>
  102. <?php $image = in_array( $extension['slug'], $existing_extension_images ) ? POPMAKE_URL . '/assets/images/extensions/' . $extension['slug'] . '.png' : $extension['image']; ?>
  103. <img class="extension-thumbnail" src="<?php echo esc_attr( $image ) ?>" />
  104. <p><?php echo esc_html( $extension['excerpt'] ); ?></p>
  105. <span class="action-links">
  106. <a class="button" target="_blank" href="<?php echo esc_url( $extension['homepage'] ); ?>?utm_source=plugin-extension-page&utm_medium=plugin&utm_campaign=upsell&utm_content=<?php echo esc_attr( urlencode( str_replace( ' ', '+', $extension['name'] ) ) ); ?>-<?php echo esc_attr( $i ); ?>"><?php _e( 'Learn more', 'popup-maker' ); ?></a>
  107. </span>
  108. <!-- --><?php
  109. //
  110. // if ( ! empty( $extension->download_link ) && ! isset( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ] ) ) {
  111. // $installerUrl = add_query_arg( array(
  112. // 'action' => 'install-plugin',
  113. // 'plugin' => $extension->slug,
  114. // 'edd_sample_plugin' => 1,
  115. // ), network_admin_url( 'update.php' ) //admin_url('update.php')
  116. // );
  117. // $installerUrl = wp_nonce_url( $installerUrl, 'install-plugin_' . $extension->slug ) ?>
  118. <!-- <span class="action-links">-->
  119. <!-- --><?php
  120. // printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installerUrl ), __( 'Install' ) ); ?>
  121. <!-- </span>-->
  122. <!-- --><?php
  123. // } elseif ( isset( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]['is_active'] ) ) {
  124. // ?>
  125. <!-- <span class="action-links">-->
  126. <!-- --><?php
  127. // if ( ! $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]['is_active'] ) {
  128. // printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]["activation_url"] ), __( 'Activate' ) );
  129. //
  130. // } else {
  131. // printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]["deactivation_url"] ), __( 'Deactivate' ) );
  132. // } ?>
  133. <!-- </span>-->
  134. <!-- --><?php
  135. // } else {
  136. // ?>
  137. <!-- <span class="action-links"><a class="button" target="_blank" href="--><?php //esc_attr_e( $extension->homepage ); ?><!--">--><?php //_e( 'Get It Now' ); ?><!--</a></span>-->
  138. <!-- --><?php
  139. // }
  140. // ?>
  141. </li>
  142. <?php
  143. $i ++;
  144. endforeach;
  145. } ?>
  146. </ul>
  147. <?php
  148. }
  149. /**
  150. * @return array
  151. */
  152. public static function extensions_with_local_image() {
  153. return apply_filters( 'pum_extensions_with_local_image', array(
  154. 'core-extensions-bundle',
  155. 'aweber-integration',
  156. 'mailchimp-integration',
  157. 'remote-content',
  158. 'scroll-triggered-popups',
  159. 'popup-analytics',
  160. 'forced-interaction',
  161. 'age-verification-modals',
  162. 'advanced-theme-builder',
  163. 'exit-intent-popups',
  164. 'ajax-login-modals',
  165. 'advanced-targeting-conditions',
  166. 'secure-idle-user-logout',
  167. 'terms-conditions-popups',
  168. 'videos',
  169. 'edd-pro',
  170. 'woocommerce-pro',
  171. 'geotargeting',
  172. 'scheduling',
  173. ) );
  174. }
  175. }