| @@ -1,177 +1,112 @@ | ||
| 1 | -<?php | |
| 2 | - /** | |
| 3 | - * @package Freemius | |
| 4 | - * @copyright Copyright (c) 2015, Freemius, Inc. | |
| 5 | - * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | - * @since 1.0.3 | |
| 7 | - */ | |
| 8 | - | |
| 9 | - /** | |
| 10 | - * Note for WordPress.org Theme/Plugin reviewer: | |
| 11 | - * Freemius is an SDK for plugin and theme developers. Since the core | |
| 12 | - * of the SDK is relevant both for plugins and themes, for obvious reasons, | |
| 13 | - * we only develop and maintain one code base. | |
| 14 | - * | |
| 15 | - * This code (and page) will not run for wp.org themes (only plugins). | |
| 16 | - * | |
| 17 | - * In addition, this page loads an i-frame. We intentionally named it 'frame' | |
| 18 | - * so it will pass the "Theme Check" that is looking for the string "i" . "frame". | |
| 19 | - * | |
| 20 | - * UPDATE: | |
| 21 | - * After ongoing conversations with the WordPress.org TRT we received | |
| 22 | - * an official approval for including i-frames in the theme's WP Admin setting's | |
| 23 | - * page tab (the SDK will never add any i-frames on the sitefront). i-frames | |
| 24 | - * were never against the guidelines, but we wanted to get the team's blessings | |
| 25 | - * before we move forward. For the record, I got the final approval from | |
| 26 | - * Ulrich Pogson (@grapplerulrich), a team lead at the TRT during WordCamp | |
| 27 | - * Europe 2017 (June 16th, 2017). | |
| 28 | - * | |
| 29 | - * If you have any questions or need clarifications, please don't hesitate | |
| 30 | - * pinging me on slack, my username is @svovaf. | |
| 31 | - * | |
| 32 | - * @author Vova Feldman (@svovaf) | |
| 33 | - * @since 1.2.2 | |
| 34 | - */ | |
| 35 | - | |
| 36 | - if ( ! defined( 'ABSPATH' ) ) { | |
| 37 | - exit; | |
| 38 | - } | |
| 39 | - | |
| 40 | - wp_enqueue_script( 'jquery' ); | |
| 41 | - wp_enqueue_script( 'json2' ); | |
| 42 | - fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' ); | |
| 43 | - fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' ); | |
| 44 | - fs_enqueue_local_style( 'fs_common', '/admin/common.css' ); | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * @var array $VARS | |
| 48 | - * @var Freemius $fs | |
| 49 | - */ | |
| 50 | - $fs = freemius( $VARS['id'] ); | |
| 51 | - $slug = $fs->get_slug(); | |
| 52 | - $timestamp = time(); | |
| 53 | - | |
| 54 | - $context_params = array( | |
| 55 | - 'plugin_id' => $fs->get_id(), | |
| 56 | - 'plugin_public_key' => $fs->get_public_key(), | |
| 57 | - 'plugin_version' => $fs->get_plugin_version(), | |
| 58 | - ); | |
| 59 | - | |
| 60 | - $bundle_id = $fs->get_bundle_id(); | |
| 61 | - if ( ! is_null( $bundle_id ) ) { | |
| 62 | - $context_params['bundle_id'] = $bundle_id; | |
| 63 | - } | |
| 64 | - | |
| 65 | - // Get site context secure params. | |
| 66 | - if ( $fs->is_registered() ) { | |
| 67 | - $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params( | |
| 68 | - $fs->get_site(), | |
| 69 | - $timestamp, | |
| 70 | - 'upgrade' | |
| 71 | - ) ); | |
| 72 | - } else { | |
| 73 | - $context_params['home_url'] = home_url(); | |
| 74 | - } | |
| 75 | - | |
| 76 | - if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.) | |
| 77 | - { | |
| 78 | - $context_params['sandbox'] = FS_Security::instance()->get_secure_token( | |
| 79 | - $fs->get_plugin(), | |
| 80 | - $timestamp, | |
| 81 | - 'checkout' | |
| 82 | - ); | |
| 83 | - } | |
| 84 | - | |
| 85 | - $query_params = array_merge( $context_params, $_GET, array( | |
| 86 | - 'next' => $fs->_get_sync_license_url( false, false ), | |
| 87 | - 'plugin_version' => $fs->get_plugin_version(), | |
| 88 | - // Billing cycle. | |
| 89 | - 'billing_cycle' => fs_request_get( 'billing_cycle', WP_FS__PERIOD_ANNUALLY ), | |
| 90 | - 'is_network_admin' => fs_is_network_admin() ? 'true' : 'false', | |
| 91 | - 'currency' => $fs->apply_filters( 'default_currency', 'usd' ), | |
| 92 | - ) ); | |
| 93 | - | |
| 94 | - if ( ! $fs->is_registered() ) { | |
| 95 | - $template_data = array( | |
| 96 | - 'id' => $fs->get_id(), | |
| 97 | - ); | |
| 98 | - fs_require_template( 'forms/trial-start.php', $template_data); | |
| 99 | - } | |
| 100 | - | |
| 101 | - $view_params = array( | |
| 102 | - 'id' => $VARS['id'], | |
| 103 | - 'page' => strtolower( $fs->get_text_x_inline( 'Pricing', 'noun', 'pricing' ) ), | |
| 104 | - ); | |
| 105 | - fs_require_once_template('secure-https-header.php', $view_params); | |
| 106 | - | |
| 107 | - $has_tabs = $fs->_add_tabs_before_content(); | |
| 108 | - | |
| 109 | - if ( $has_tabs ) { | |
| 110 | - $query_params['tabs'] = 'true'; | |
| 111 | - } | |
| 112 | -?> | |
| 113 | - <div id="fs_pricing" class="wrap fs-section fs-full-size-wrapper"> | |
| 114 | - <div id="fs_frame"></div> | |
| 115 | - <form action="" method="POST"> | |
| 116 | - <input type="hidden" name="user_id"/> | |
| 117 | - <input type="hidden" name="user_email"/> | |
| 118 | - <input type="hidden" name="site_id"/> | |
| 119 | - <input type="hidden" name="public_key"/> | |
| 120 | - <input type="hidden" name="secret_key"/> | |
| 121 | - <input type="hidden" name="action" value="account"/> | |
| 122 | - </form> | |
| 123 | - | |
| 124 | - <script type="text/javascript"> | |
| 125 | - (function ($, undef) { | |
| 126 | - $(function () { | |
| 127 | - var | |
| 128 | - // Keep track of the i-frame height. | |
| 129 | - frame_height = 800, | |
| 130 | - base_url = '<?php echo WP_FS__ADDRESS ?>', | |
| 131 | - // Pass the parent page URL into the i-frame in a meaningful way (this URL could be | |
| 132 | - // passed via query string or hard coded into the child page, it depends on your needs). | |
| 133 | - src = base_url + '/pricing/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href), | |
| 134 | - | |
| 135 | - // Append the I-frame into the DOM. | |
| 136 | - frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>') | |
| 137 | - .appendTo('#fs_frame'); | |
| 138 | - | |
| 139 | - FS.PostMessage.init(base_url, [frame[0]]); | |
| 140 | - | |
| 141 | - FS.PostMessage.receive('height', function (data) { | |
| 142 | - var h = data.height; | |
| 143 | - if (!isNaN(h) && h > 0 && h != frame_height) { | |
| 144 | - frame_height = h; | |
| 145 | - frame.height(frame_height + 'px'); | |
| 146 | - | |
| 147 | - FS.PostMessage.postScroll(frame[0]); | |
| 148 | - } | |
| 149 | - }); | |
| 150 | - | |
| 151 | - FS.PostMessage.receive('get_dimensions', function (data) { | |
| 152 | - FS.PostMessage.post('dimensions', { | |
| 153 | - height : $(document.body).height(), | |
| 154 | - scrollTop: $(document).scrollTop() | |
| 155 | - }, frame[0]); | |
| 156 | - }); | |
| 157 | - | |
| 158 | - FS.PostMessage.receive('start_trial', function (data) { | |
| 159 | - openTrialConfirmationModal(data); | |
| 160 | - }); | |
| 161 | - }); | |
| 162 | - })(jQuery); | |
| 163 | - </script> | |
| 164 | - </div> | |
| 165 | -<?php | |
| 166 | - if ( $has_tabs ) { | |
| 167 | - $fs->_add_tabs_after_content(); | |
| 168 | - } | |
| 169 | - | |
| 170 | - $params = array( | |
| 171 | - 'page' => 'pricing', | |
| 172 | - 'module_id' => $fs->get_id(), | |
| 173 | - 'module_type' => $fs->get_module_type(), | |
| 174 | - 'module_slug' => $slug, | |
| 175 | - 'module_version' => $fs->get_plugin_version(), | |
| 176 | - ); | |
| 177 | - fs_require_template( 'powered-by.php', $params ); | |
| 1 | +<?php | |
| 2 | + /** | |
| 3 | + * @package Freemius | |
| 4 | + * @copyright Copyright (c) 2015, Freemius, Inc. | |
| 5 | + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | + * @since 1.0.3 | |
| 7 | + */ | |
| 8 | + | |
| 9 | + if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; | |
| 11 | + } | |
| 12 | + | |
| 13 | + wp_enqueue_script( 'jquery' ); | |
| 14 | + fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.js' ); | |
| 15 | + fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' ); | |
| 16 | + fs_enqueue_local_style( 'fs_common', '/admin/common.css' ); | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * @var array $VARS | |
| 20 | + * @var Freemius $fs | |
| 21 | + */ | |
| 22 | + $fs = freemius( $VARS['id'] ); | |
| 23 | + $slug = $fs->get_slug(); | |
| 24 | + $timestamp = time(); | |
| 25 | + | |
| 26 | + $context_params = array( | |
| 27 | + 'plugin_id' => $fs->get_id(), | |
| 28 | + 'plugin_public_key' => $fs->get_public_key(), | |
| 29 | + 'plugin_version' => $fs->get_plugin_version(), | |
| 30 | + ); | |
| 31 | + | |
| 32 | + $bundle_id = $fs->get_bundle_id(); | |
| 33 | + if ( ! is_null( $bundle_id ) ) { | |
| 34 | + $context_params['bundle_id'] = $bundle_id; | |
| 35 | + } | |
| 36 | + | |
| 37 | + // Get site context secure params. | |
| 38 | + if ( $fs->is_registered() ) { | |
| 39 | + $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params( | |
| 40 | + $fs->get_site(), | |
| 41 | + $timestamp, | |
| 42 | + 'upgrade' | |
| 43 | + ) ); | |
| 44 | + } else { | |
| 45 | + $context_params['home_url'] = home_url(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.) | |
| 49 | + { | |
| 50 | + $context_params['sandbox'] = FS_Security::instance()->get_secure_token( | |
| 51 | + $fs->get_plugin(), | |
| 52 | + $timestamp, | |
| 53 | + 'checkout' | |
| 54 | + ); | |
| 55 | + } | |
| 56 | + | |
| 57 | + $query_params = array_merge( $context_params, $_GET, array( | |
| 58 | + 'next' => $fs->_get_sync_license_url( false, false ), | |
| 59 | + 'plugin_version' => $fs->get_plugin_version(), | |
| 60 | + // Billing cycle. | |
| 61 | + 'billing_cycle' => fs_request_get( 'billing_cycle', WP_FS__PERIOD_ANNUALLY ), | |
| 62 | + 'is_network_admin' => fs_is_network_admin() ? 'true' : 'false', | |
| 63 | + 'currency' => $fs->apply_filters( 'default_currency', 'usd' ), | |
| 64 | + 'discounts_model' => $fs->apply_filters( 'pricing/discounts_model', 'absolute' ), | |
| 65 | + ) ); | |
| 66 | + | |
| 67 | + $pricing_js_url = fs_asset_url( $fs->get_pricing_js_path() ); | |
| 68 | + | |
| 69 | + wp_enqueue_script( 'freemius-pricing', $pricing_js_url ); | |
| 70 | + | |
| 71 | + $pricing_css_path = $fs->apply_filters( 'pricing/css_path', null ); | |
| 72 | + if ( is_string( $pricing_css_path ) ) { | |
| 73 | + wp_enqueue_style( 'freemius-pricing', fs_asset_url( $pricing_css_path ) ); | |
| 74 | + } | |
| 75 | + | |
| 76 | + $has_tabs = $fs->_add_tabs_before_content(); | |
| 77 | + | |
| 78 | + if ( $has_tabs ) { | |
| 79 | + $query_params['tabs'] = 'true'; | |
| 80 | + } | |
| 81 | +?> | |
| 82 | + <div id="fs_pricing" class="wrap fs-section fs-full-size-wrapper"> | |
| 83 | + <div id="fs_pricing_wrapper" data-public-url="<?php echo trailingslashit( dirname( $pricing_js_url ) ) ?>"></div> | |
| 84 | + <?php | |
| 85 | + $pricing_config = array_merge( array( | |
| 86 | + 'contact_url' => $fs->contact_url(), | |
| 87 | + 'is_production' => ( defined( 'WP_FS__IS_PRODUCTION_MODE' ) ? WP_FS__IS_PRODUCTION_MODE : null ), | |
| 88 | + 'menu_slug' => $fs->get_menu_slug(), | |
| 89 | + 'mode' => 'dashboard', | |
| 90 | + 'fs_wp_endpoint_url' => WP_FS__ADDRESS, | |
| 91 | + 'request_handler_url' => admin_url( | |
| 92 | + 'admin-ajax.php?' . http_build_query( array( | |
| 93 | + 'module_id' => $fs->get_id(), | |
| 94 | + 'action' => $fs->get_ajax_action( 'pricing_ajax_action' ), | |
| 95 | + 'security' => $fs->get_ajax_security( 'pricing_ajax_action' ) | |
| 96 | + ) ) | |
| 97 | + ), | |
| 98 | + 'selector' => '#fs_pricing_wrapper', | |
| 99 | + 'unique_affix' => $fs->get_unique_affix(), | |
| 100 | + 'show_annual_in_monthly' => $fs->apply_filters( 'pricing/show_annual_in_monthly', true ), | |
| 101 | + 'license' => $fs->has_active_valid_license() ? $fs->_get_license() : null, | |
| 102 | + 'plugin_icon' => $fs->get_local_icon_url(), | |
| 103 | + 'disable_single_package' => $fs->apply_filters( 'pricing/disable_single_package', false ), | |
| 104 | + ), $query_params ); | |
| 105 | + | |
| 106 | + wp_add_inline_script( 'freemius-pricing', 'Freemius.pricing.new( ' . json_encode( $pricing_config ) . ' )' ); | |
| 107 | + ?> | |
| 108 | + </div> | |
| 109 | +<?php | |
| 110 | + if ( $has_tabs ) { | |
| 111 | + $fs->_add_tabs_after_content(); | |
| 112 | + } | |