/** * @deprecated Old sign-up page callback. */ public function SignUpPageLoad() { if ($this->fs->is_registered()) { return; } if ('post' === strtolower($_SERVER['REQUEST_METHOD']) && isset($_POST['action']) && 'account' === $_POST['action']) { $this->SetOption(WP_RW__DB_OPTION_OWNER_ID, $_POST['user_id']); $this->SetOption(WP_RW__DB_OPTION_OWNER_EMAIL, $_POST['user_email']); $this->SetOption(WP_RW__DB_OPTION_SITE_ID, $_POST['site_id']); $this->SetOption(WP_RW__DB_OPTION_SITE_PUBLIC_KEY, $_POST['public_key']); $this->SetOption(WP_RW__DB_OPTION_SITE_SECRET_KEY, $_POST['secret_key']); $this->SetOption(WP_RW__DB_OPTION_TRACKING, isset($_POST['tracking']) && '1' == $_POST['tracking']); $this->_options->store(); // Reload the page with the keys. rw_admin_redirect(); } }
/** * Dynamic initiator, originally created to support initiation * with parent_id for add-ons. * * @author Vova Feldman (@svovaf) * @since 1.0.6 * * @param array $plugin_info * * @throws Freemius_Exception */ function dynamic_init(array $plugin_info) { $this->_logger->entrance(); $this->parse_settings($plugin_info); if ($this->should_stop_execution()) { return; } if (!$this->is_registered()) { if ($this->is_anonymous()) { // If user skipped, no need to test connectivity. $this->_has_api_connection = true; $this->_is_on = true; } else { if (!$this->has_api_connectivity()) { if ($this->_admin_notices->has_sticky('failed_connect_api_first') || $this->_admin_notices->has_sticky('failed_connect_api')) { if (!$this->_enable_anonymous) { // If anonymous mode is disabled, add firewall admin-notice message. add_action('admin_footer', array('Freemius', '_add_firewall_issues_javascript')); $this->add_ajax_action('resolve_firewall_issues', array(&$this, '_email_about_firewall_issue')); $this->add_ajax_action('retry_connectivity_test', array(&$this, '_retry_connectivity_test')); } } return; } else { $this->_admin_notices->remove_sticky(array('failed_connect_api_first', 'failed_connect_api')); if ($this->_anonymous_mode) { // Simulate anonymous mode. $this->_is_anonymous = true; } } } // Check if Freemius is on for the current plugin. // This MUST be executed after all the plugin variables has been loaded. if (!$this->is_on()) { return; } } if ($this->has_api_connectivity()) { if ($this->is_cron()) { $this->hook_callback_to_sync_cron(); } else { if ($this->is_user_in_admin()) { /** * Schedule daily data sync cron if: * * 1. User opted-in (for tracking). * 2. If skipped, but later upgraded (opted-in via upgrade). * * @author Vova Feldman (@svovaf) * @since 1.1.7.3 * */ if ($this->is_registered()) { if (!$this->is_sync_cron_on()) { $this->schedule_sync_cron(); } } /** * Check if requested for manual blocking background sync. */ if (fs_request_has('background_sync')) { $this->run_manual_sync(); } } } } if ($this->is_registered()) { $this->hook_callback_to_install_sync(); } if ($this->is_addon()) { if ($this->is_parent_plugin_installed()) { // Link to parent FS. $this->_parent = self::get_instance_by_id($this->_plugin->parent_plugin_id); // Get parent plugin reference. $this->_parent_plugin = $this->_parent->get_plugin(); } } if ($this->is_user_in_admin()) { global $pagenow; if ('plugins.php' === $pagenow) { $this->hook_plugin_action_links(); } if ($this->is_addon()) { if (!$this->is_parent_plugin_installed()) { $parent_name = $this->get_option($plugin_info, 'parent_name', null); if (isset($plugin_info['parent'])) { $parent_name = $this->get_option($plugin_info['parent'], 'name', null); } $this->_admin_notices->add(!empty($parent_name) ? sprintf(__fs('addon-x-cannot-run-without-y', $this->_slug), $this->get_plugin_name(), $parent_name) : sprintf(__fs('addon-x-cannot-run-without-parent', $this->_slug), $this->get_plugin_name()), __fs('oops', $this->_slug) . '...', 'error'); return; } else { if ($this->_parent->is_registered() && !$this->is_registered()) { // If parent plugin activated, automatically install add-on for the user. $this->_activate_addon_account($this->_parent); } // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic. if ($this->is_premium()) { // Remove add-on download admin-notice. $this->_parent->_admin_notices->remove_sticky(array('addon_plan_upgraded_' . $this->_slug, 'no_addon_license_' . $this->_slug)); } $this->deactivate_premium_only_addon_without_license(); } } else { add_action('admin_init', array(&$this, '_admin_init_action')); if ($this->has_addons() && 'plugin-information' === fs_request_get('tab', false) && $this->get_id() == fs_request_get('parent_plugin_id', false)) { require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php'; new FS_Plugin_Info_Dialog($this); } } if ($this->is_premium()) { new FS_Plugin_Updater($this); } // if ( $this->is_registered() || // $this->is_anonymous() || // $this->is_pending_activation() // ) { // $this->_init_admin(); // } } $this->do_action('initiated'); if ($this->_storage->prev_is_premium !== $this->_plugin->is_premium) { if (isset($this->_storage->prev_is_premium)) { $this->apply_filters('after_code_type_change', $this->_plugin->is_premium); } else { // Set for code type for the first time. $this->_storage->prev_is_premium = $this->_plugin->is_premium; } } if (!$this->is_addon()) { if ($this->is_registered()) { // Fix for upgrade from versions < 1.0.9. if (!isset($this->_storage->activation_timestamp)) { $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME; } $this->do_action('after_init_plugin_registered'); } else { if ($this->is_anonymous()) { $this->do_action('after_init_plugin_anonymous'); } else { if ($this->is_pending_activation()) { $this->do_action('after_init_plugin_pending_activations'); } } } } else { if ($this->is_registered()) { $this->do_action('after_init_addon_registered'); } else { if ($this->is_anonymous()) { $this->do_action('after_init_addon_anonymous'); } else { if ($this->is_pending_activation()) { $this->do_action('after_init_addon_pending_activations'); } } } } // Add license activation link and AJAX request handler. if ($this->has_paid_plan()) { global $pagenow; if ('plugins.php' === $pagenow) { /** * @since 1.2.0 Add license action link only on plugins page. */ $this->_add_license_action_link(); $this->_require_license_activation_dialog(); } if ($this->is_ajax_action(array('activate_license', 'resend_license_key'))) { // Hook license activation and resend AJAX callbacks. $this->_require_license_activation_dialog(); } } }
/** * Dynamic initiator, originally created to support initiation * with parent_id for add-ons. * * @author Vova Feldman (@svovaf) * @since 1.0.6 * * @param array $plugin_info * * @throws Freemius_Exception */ function dynamic_init(array $plugin_info) { $this->_logger->entrance(); $id = $this->_get_numeric_option($plugin_info, 'id', false); $public_key = $this->_get_option($plugin_info, 'public_key', false); $secret_key = $this->_get_option($plugin_info, 'secret_key', null); $parent_id = $this->_get_numeric_option($plugin_info, 'parent_id', null); $parent_name = $this->_get_option($plugin_info, 'parent_name', null); if (isset($plugin_info['parent'])) { $parent_id = $this->_get_numeric_option($plugin_info['parent'], 'id', null); // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null ); // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null ); $parent_name = $this->_get_option($plugin_info['parent'], 'name', null); } if (false === $id) { throw new Freemius_Exception('Plugin id parameter is not set.'); } if (false === $public_key) { throw new Freemius_Exception('Plugin public_key parameter is not set.'); } $plugin = $this->_plugin instanceof FS_Plugin ? $this->_plugin : new FS_Plugin(); $plugin->update(array('id' => $id, 'public_key' => $public_key, 'slug' => $this->_slug, 'parent_plugin_id' => $parent_id, 'version' => $this->get_plugin_version(), 'title' => $this->get_plugin_name(), 'file' => $this->_free_plugin_basename, 'is_premium' => $this->_get_bool_option($plugin_info, 'is_premium', true), 'is_live' => $this->_get_bool_option($plugin_info, 'is_live', true))); if ($plugin->is_updated()) { // Update plugin details. $this->_plugin = FS_Plugin_Manager::instance($this->_slug)->store($plugin); } $this->_plugin->secret_key = $secret_key; if (!isset($plugin_info['menu'])) { // Back compatibility to 1.1.2 $plugin_info['menu'] = array('slug' => isset($plugin_info['menu_slug']) ? $plugin_info['menu_slug'] : $this->_slug); } $this->_menu = FS_Admin_Menu_Manager::instance($this->_slug); $this->_menu->init($plugin_info['menu'], $this->is_addon()); $this->_has_addons = $this->_get_bool_option($plugin_info, 'has_addons', false); $this->_has_paid_plans = $this->_get_bool_option($plugin_info, 'has_paid_plans', true); $this->_is_org_compliant = $this->_get_bool_option($plugin_info, 'is_org_compliant', true); $this->_enable_anonymous = $this->_get_bool_option($plugin_info, 'enable_anonymous', true); $this->_permissions = $this->_get_option($plugin_info, 'permissions', array()); if (!$this->is_registered()) { if (!$this->has_api_connectivity()) { if (is_admin() && $this->_admin_notices->has_sticky('failed_connect_api')) { if (!$this->_enable_anonymous) { // If anonymous mode is disabled, add firewall admin-notice message. add_action('admin_footer', array('Freemius', '_add_firewall_issues_javascript')); add_action("wp_ajax_{$this->_slug}_resolve_firewall_issues", array(&$this, '_email_about_firewall_issue')); } } return; } // Check if Freemius is on for the current plugin. // This MUST be executed after all the plugin variables has been loaded. if (!$this->is_on()) { return; } } if (false === $this->_background_sync()) { // If background sync wasn't executed, // and if the plugin declared it has add-ons but // no add-ons found in the local data, then try to sync add-ons. if ($this->_has_addons && !$this->is_addon() && false === $this->get_addons()) { $this->_sync_addons(); } } if ($this->is_addon()) { if ($this->is_parent_plugin_installed()) { // Link to parent FS. $this->_parent = self::get_instance_by_id($parent_id); // Get parent plugin reference. $this->_parent_plugin = $this->_parent->get_plugin(); } } if (is_admin()) { global $pagenow; if ('plugins.php' === $pagenow) { $this->hook_plugin_action_links(); } if ($this->is_addon()) { if (!$this->is_parent_plugin_installed()) { $this->_admin_notices->add(is_string($parent_name) ? sprintf(__fs('addon-cannot-run-without-x', $this->_slug), $this->get_plugin_name(), $parent_name) : sprintf(__fs('addon-x-cannot-run-without-parent', $this->_slug), $this->get_plugin_name()), __fs('oops', $this->_slug) . '...', 'error'); return; } else { if ($this->_parent->is_registered() && !$this->is_registered()) { // If parent plugin activated, automatically install add-on for the user. $this->_activate_addon_account($this->_parent); } // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic. if ($this->is_premium()) { // Remove add-on download admin-notice. $this->_parent->_admin_notices->remove_sticky('addon_plan_upgraded_' . $this->_slug); } } } else { add_action('admin_init', array(&$this, '_admin_init_action')); if ($this->_has_addons() && 'plugin-information' === fs_request_get('tab', false) && $this->get_id() == fs_request_get('parent_plugin_id', false)) { // Remove default plugin information action. remove_all_actions('install_plugins_pre_plugin-information'); require_once WP_FS__DIR_INCLUDES . '/fs-plugin-functions.php'; // Override action with custom plugins function for add-ons. add_action('install_plugins_pre_plugin-information', 'fs_install_plugin_information'); // Override request for plugin information for Add-ons. add_filter('fs_plugins_api', array(&$this, '_get_addon_info_filter'), WP_FS__DEFAULT_PRIORITY, 3); } else { if ($this->is_paying() || $this->_has_addons()) { new FS_Plugin_Updater($this); } } } // if ( $this->is_registered() || // $this->is_anonymous() || // $this->is_pending_activation() // ) { // $this->_init_admin(); // } } $this->do_action('initiated'); if (!$this->is_addon()) { if ($this->is_registered()) { // Fix for upgrade from versions < 1.0.9. if (!isset($this->_storage->activation_timestamp)) { $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME; } if ($this->_storage->prev_is_premium !== $this->_plugin->is_premium) { if (isset($this->_storage->prev_is_premium)) { add_action(is_admin() ? 'admin_init' : 'init', array(&$this, '_plugin_code_type_changed')); } else { // Set for code type for the first time. $this->_storage->prev_is_premium = $this->_plugin->is_premium; } } $this->do_action('after_init_plugin_registered'); } else { if ($this->is_anonymous()) { $this->do_action('after_init_plugin_anonymous'); } else { if ($this->is_pending_activation()) { $this->do_action('after_init_plugin_pending_activations'); } } } } else { if ($this->is_registered()) { $this->do_action('after_init_addon_registered'); } else { if ($this->is_anonymous()) { $this->do_action('after_init_addon_anonymous'); } else { if ($this->is_pending_activation()) { $this->do_action('after_init_addon_pending_activations'); } } } } }