/** * Render pricing page. * * @author Vova Feldman (@svovaf) * @since 1.0.0 */ function _pricing_page_render() { $this->_logger->entrance(); $vars = array('slug' => $this->_slug); if ('true' === fs_request_get('checkout', false)) { fs_require_once_template('checkout.php', $vars); } else { fs_require_once_template('pricing.php', $vars); } }
/** * @package Freemius * @copyright Copyright (c) 2015, Freemius, Inc. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License * @since 1.0.3 */ if (!defined('ABSPATH')) { exit; } $slug = $VARS['slug']; /** * @var Freemius */ $fs = freemius($slug); $open_addon_slug = fs_request_get('slug'); $open_addon = false; /** * @var FS_Plugin[] */ $addons = $fs->get_addons(); ?> <div id="fs_addons" class="wrap"> <h2><?php printf(__fs('add-ons-for-x', $slug), $fs->get_plugin_name()); ?> </h2> <div id="poststuff"> <?php if (!is_array($addons) || 0 == count($addons)) {
private function _handle_account_edits() { $properties = array('site_secret_key', 'site_id', 'site_public_key'); foreach ($properties as $p) { if (fs_request_is_action('update_' . $p)) { check_admin_referer('update_' . $p); $this->_logger->log('update_' . $p); $site_property = substr($p, strlen('site_')); $site_property_value = fs_request_get('fs_' . $p . '_' . $this->_slug, ''); $this->get_site()->{$site_property} = $site_property_value; // Store account after modification. $this->_store_site(); do_action('fs_account_property_edit_' . $this->_slug, 'site', $site_property, $site_property_value); // Anonymous functions are only available since PHP 5.3 add_action('all_admin_notices', array('Freemius', '_account_details_updated_message')); break; } } }
fs_enqueue_local_script('fs-postmessage', 'postmessage.js'); /** * @var array $VARS */ $slug = $VARS['slug']; $fs = freemius($slug); $timestamp = time(); $context_params = array('plugin_id' => $fs->get_id(), 'plugin_public_key' => $fs->get_public_key(), 'plugin_version' => $fs->get_plugin_version()); // Get site context secure params. if ($fs->is_registered()) { $context_params = array_merge($context_params, FS_Security::instance()->get_context_params($fs->get_site(), $timestamp, 'upgrade')); } if ($fs->is_payments_sandbox()) { $context_params['sandbox'] = FS_Security::instance()->get_secure_token($fs->get_plugin(), $timestamp, 'checkout'); } $query_params = array_merge($context_params, $_GET, array('next' => $fs->_get_sync_license_url(false, false), 'plugin_version' => $fs->get_plugin_version(), 'billing_cycle' => fs_request_get('billing_cycle', WP_FS__PERIOD_ANNUALLY))); ?> <div id="fs_pricing" class="wrap" style="margin: 0 0 -65px -20px;"> <div id="iframe"></div> <form action="" method="POST"> <input type="hidden" name="user_id"/> <input type="hidden" name="user_email"/> <input type="hidden" name="site_id"/> <input type="hidden" name="public_key"/> <input type="hidden" name="secret_key"/> <input type="hidden" name="action" value="account"/> </form> <script type="text/javascript"> (function ($, undef) {
wp_enqueue_script('jquery'); wp_enqueue_script('json2'); fs_enqueue_local_script('postmessage', 'nojquery.ba-postmessage.min.js'); fs_enqueue_local_script('fs-postmessage', 'postmessage.js'); $slug = $VARS['slug']; $fs = freemius($slug); $timestamp = time(); $context_params = array('plugin_id' => $fs->get_id(), 'plugin_public_key' => $fs->get_public_key(), 'plugin_version' => $fs->get_plugin_version()); // Get site context secure params. if ($fs->is_registered()) { $context_params = array_merge($context_params, FS_Security::instance()->get_context_params($fs->get_site(), $timestamp, 'upgrade')); } if ($fs->is_payments_sandbox()) { $context_params['sandbox'] = FS_Security::instance()->get_secure_token($fs->get_plugin(), $timestamp, 'checkout'); } $query_params = array_merge($context_params, $_GET, array('next' => $fs->_get_admin_page_url('account', array('fs_action' => $slug . '_sync_license')), 'plugin_version' => $fs->get_plugin_version(), 'billing_cycle' => fs_request_get('billing_cycle', WP_FS__PERIOD_ANNUALLY))); ?> <div id="fs_pricing" class="wrap" style="margin: 0 0 -65px -20px;"> <div id="iframe"></div> <form action="" method="POST"> <input type="hidden" name="user_id"/> <input type="hidden" name="user_email"/> <input type="hidden" name="site_id"/> <input type="hidden" name="public_key"/> <input type="hidden" name="secret_key"/> <input type="hidden" name="action" value="account"/> </form> <script type="text/javascript"> (function ($, undef) {
?> ', charset : '<?php echo get_bloginfo('charset'); ?> ', return_url : '<?php echo $return_url; ?> ', account_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array('fs_action' => 'sync_user')), 'sync_user'); ?> ', activation_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url('', array('fs_action' => $slug . '_activate_new', 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()))), $slug . '_activate_new'); ?> ' }, iframe[0]); }); FS.PostMessage.receiveOnce('get_dimensions', function (data) { console.debug('receiveOnce', 'get_dimensions'); FS.PostMessage.post('dimensions', { height : $(document.body).height(), scrollTop: $(document).scrollTop() }, iframe[0]); }); }); })(jQuery);
public function _update_account() { if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') { return; } $properties = array('user_id', 'site_secret_key', 'site_id', 'site_public_key'); foreach ($properties as $p) { if (rw_request_is_action('update_' . $p)) { check_admin_referer('update_' . $p); $value = fs_request_get('rw_' . $p); switch ($p) { case 'site_id': $this->account->update_site_id($value); break; case 'site_public_key': $this->account->update_site_public_key($value); break; case 'site_secret_key': $this->account->update_site_secret_key($value); break; case 'user_id': $this->account->update_site_secret_key($value); break; default: return; } break; } } }
/** * Generate add-on plugin information. * * @author Vova Feldman (@svovaf) * @since 1.0.6 * * @param array $data * @param string $action * @param object|null $args * * @return array|null */ function _get_addon_info_filter($data, $action = '', $args = null) { $this->_logger->entrance(); $parent_plugin_id = fs_request_get('parent_plugin_id', false); if ($this->_fs->get_id() != $parent_plugin_id || 'plugin_information' !== $action || !isset($args->slug)) { return $data; } // Find add-on by slug. $selected_addon = $this->_fs->get_addon_by_slug($args->slug); if (false === $selected_addon) { return $data; } if (!isset($selected_addon->info)) { // Setup some default info. $selected_addon->info = new stdClass(); $selected_addon->info->selling_point_0 = 'Selling Point 1'; $selected_addon->info->selling_point_1 = 'Selling Point 2'; $selected_addon->info->selling_point_2 = 'Selling Point 3'; $selected_addon->info->description = '<p>Tell your users all about your add-on</p>'; } fs_enqueue_local_style('fs_addons', '/admin/add-ons.css'); $data = $args; $is_free = true; // Load add-on pricing. $has_pricing = false; $has_features = false; $plans = false; $plans_result = $this->_fs->get_api_site_or_plugin_scope()->get("/addons/{$selected_addon->id}/plans.json"); if (!isset($plans_result->error)) { $plans = $plans_result->plans; if (is_array($plans)) { for ($i = 0, $len = count($plans); $i < $len; $i++) { $plans[$i] = new FS_Plugin_Plan($plans[$i]); $plan = $plans[$i]; $pricing_result = $this->_fs->get_api_site_or_plugin_scope()->get("/addons/{$selected_addon->id}/plans/{$plan->id}/pricing.json"); if (!isset($pricing_result->error)) { // Update plan's pricing. $plan->pricing = $pricing_result->pricing; if (is_array($plan->pricing) && !empty($plan->pricing)) { $is_free = false; foreach ($plan->pricing as &$pricing) { $pricing = new FS_Pricing($pricing); } } $has_pricing = true; } $features_result = $this->_fs->get_api_site_or_plugin_scope()->get("/addons/{$selected_addon->id}/plans/{$plan->id}/features.json"); if (!isset($features_result->error) && is_array($features_result->features) && 0 < count($features_result->features)) { // Update plan's pricing. $plan->features = $features_result->features; $has_features = true; } } } } // Fetch latest version from Freemius. $latest = $this->_fs->_fetch_latest_version($selected_addon->id); if (!$is_free) { // If paid add-on, then it's not on wordpress.org $is_wordpress_org = false; } else { // If no versions found, then assume it's a .org plugin. $is_wordpress_org = false === $latest; } if ($is_wordpress_org) { $repo_data = FS_Plugin_Updater::_fetch_plugin_info_from_repository('plugin_information', (object) array('slug' => $selected_addon->slug, 'is_ssl' => is_ssl(), 'fields' => array('banners' => true, 'reviews' => true, 'downloaded' => false, 'active_installs' => true))); if (!empty($repo_data)) { $data = $repo_data; $data->wp_org_missing = false; } else { // Couldn't find plugin on .org. $is_wordpress_org = false; // Plugin is missing, not on Freemius nor WP.org. $data->wp_org_missing = true; } } if (!$is_wordpress_org) { $data->checkout_link = $this->_fs->checkout_url(); $data->fs_missing = false === $latest; if ($is_free) { $data->download_link = $this->_fs->_get_latest_download_local_url($selected_addon->id); } } if (!$is_wordpress_org) { // Fetch as much as possible info from local files. $plugin_local_data = $this->_fs->get_plugin_data(); $data->name = $selected_addon->title; $data->author = $plugin_local_data['Author']; $view_vars = array('plugin' => $selected_addon); $data->sections = array('description' => fs_get_template('/plugin-info/description.php', $view_vars)); if (!empty($selected_addon->info->banner_url)) { $data->banners = array('low' => $selected_addon->info->banner_url); } if (!empty($selected_addon->info->screenshots)) { $view_vars = array('screenshots' => $selected_addon->info->screenshots, 'plugin' => $selected_addon); $data->sections['screenshots'] = fs_get_template('/plugin-info/screenshots.php', $view_vars); } if (is_object($latest)) { $data->version = $latest->version; $data->last_updated = !is_null($latest->updated) ? $latest->updated : $latest->created; $data->requires = $latest->requires_platform_version; $data->tested = $latest->tested_up_to_version; } else { // Add dummy version. $data->version = '1.0.0'; // Add message to developer to deploy the plugin through Freemius. } } if ($has_pricing) { // Add plans to data. $data->plans = $plans; if ($has_features) { $view_vars = array('plans' => $plans, 'plugin' => $selected_addon); $data->sections['features'] = fs_get_template('/plugin-info/features.php', $view_vars); } } $data->is_paid = !$is_free; $data->external = !$is_wordpress_org; return $data; }
</form> <script type="text/javascript"> (function($){ $(function(){ var // Keep track of the iframe height. iframe_height = 800, base_url = '<?php echo WP_FS__ADDRESS; ?> ', // Pass the parent page URL into the Iframe in a meaningful way (this URL could be // passed via query string or hard coded into the child page, it depends on your needs). src = base_url + '/signup/?<?php echo http_build_query(array('plugin_slug' => $fs->get_slug(), 'plugin_id' => $fs->get_id(), 'plugin_public_key' => $fs->get_public_key(), 'plugin_version' => $fs->get_plugin_version(), 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons", 'password_reset' => fs_request_get('password_reset', ''))); ?> #' + encodeURIComponent(document.location.href); FS.PostMessage.init(base_url); // Append the Iframe into the DOM. var iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>') .load(function(){ var address = document.location.href, pos = address.indexOf('/wp-admin'); address = address.substring(0, pos); FS.PostMessage.post('wp_account', { users: [<?php
$is_freemium = $fs->is_freemium(); $fs->_enqueue_connect_essentials(); $current_user = Freemius::_get_current_wp_user(); $first_name = $current_user->user_firstname; if (empty($first_name)) { $first_name = $current_user->nickname; } $site_url = get_site_url(); $protocol_pos = strpos($site_url, '://'); if (false !== $protocol_pos) { $site_url = substr($site_url, $protocol_pos + 3); } $freemius_site_url = $fs->has_paid_plan() ? 'https://freemius.com/wordpress/' : 'https://freemius.com/wordpress/usage-tracking/'; $freemius_site_url .= '?' . http_build_query(array('id' => $fs->get_id(), 'slug' => $slug)); $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="1">freemius.com</a>'; $error = fs_request_get('error'); $require_license_key = $is_premium_only || $is_freemium && $is_premium_code && fs_request_get_bool('require_license', true); if ($is_pending_activation) { $require_license_key = false; } if ($require_license_key) { $fs->_require_license_activation_dialog(); } ?> <div id="fs_connect" class="wrap<?php if (!$fs->is_enable_anonymous() || $is_pending_activation || $require_license_key) { echo ' fs-anonymous-disabled'; } ?> ">