private static function _init()
 {
     if (!class_exists('RatingWidget')) {
         require_once WP_RW__PLUGIN_LIB_DIR . 'sdk/ratingwidget.php';
     }
     self::$_options = FS_Option_Manager::get_manager(WP_RW__OPTIONS, true);
     self::$_cache = FS_Option_Manager::get_manager('rw_api_cache', true);
     self::$_clock_diff = self::$_options->get_option('api_clock_diff', 0);
     RatingWidget::SetClockDiff(self::$_clock_diff);
     if (self::$_options->get_option('api_force_http', false)) {
         RatingWidget::SetHttp();
     }
 }
Beispiel #2
0
 private static function _init()
 {
     if (isset(self::$_options)) {
         return;
     }
     if (!class_exists('Freemius_Api')) {
         require_once WP_FS__DIR_SDK . '/Freemius.php';
     }
     self::$_options = FS_Option_Manager::get_manager(WP_FS__OPTIONS_OPTION_NAME, true);
     self::$_cache = FS_Cache_Manager::get_manager(WP_FS__API_CACHE_OPTION_NAME);
     self::$_clock_diff = self::$_options->get_option('api_clock_diff', 0);
     Freemius_Api::SetClockDiff(self::$_clock_diff);
     if (self::$_options->get_option('api_force_http', false)) {
         Freemius_Api::SetHttp();
     }
 }
 /**
  * @todo   TEST IF IT WORKS!!!
  *
  * Include plugins for automatic updates based on stored settings.
  *
  * @see    http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated/131404#131404
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.4
  *
  * @param bool   $update Whether to update (not used for plugins)
  * @param object $item   The plugin's info
  *
  * @return bool
  */
 static function _include_plugins_in_auto_update($update, $item)
 {
     // Before version 3.8.2 the $item was the file name of the plugin,
     // while in 3.8.2 statistics were added (https://core.trac.wordpress.org/changeset/27905).
     $by_slug = (int) str_replace('.', '', get_bloginfo('version')) >= 382;
     if (!isset(self::$_auto_updated_plugins)) {
         $plugins = self::$_accounts->get_option('plugins', array());
         $identifiers = array();
         foreach ($plugins as $p) {
             /**
              * @var FS_Plugin $p
              */
             if (isset($p->auto_update) && $p->auto_update) {
                 $identifiers[] = $by_slug ? $p->slug : plugin_basename($p->file);
             }
         }
         self::$_auto_updated_plugins = $identifiers;
     }
     if (in_array($by_slug ? $item->slug : $item, self::$_auto_updated_plugins)) {
         return true;
     }
     // Pass update decision to next filters
     return $update;
 }
 private function _store_account()
 {
     $this->_store_site(false);
     $this->_store_user(false);
     self::$_accounts->store();
 }
 /**
  * Migration from account options stored in FS accounts object back to RW options object.
  *
  * @author Vova Feldman (@svovaf)
  * @since  2.6.3
  *
  * @param FS_Option_Manager $fs_options
  * @param string            $basename
  */
 private function migrate_from_fs_options($fs_options, $basename)
 {
     // Load site information.
     $sites = $fs_options->get_option('sites');
     $site = $sites[$basename];
     // Load user information.
     $users = $fs_options->get_option('users');
     $user = $users[$site->user_id];
     // Update account information.
     $this->set($site->id, $site->public_key, $site->secret_key, $user->id, $user->email);
     // Remove RW account from FS object.
     unset($sites[$basename]);
     unset($users[$site->user_id]);
     $fs_options->set_option('sites', $sites);
     $fs_options->set_option('users', $users);
     $fs_options->store();
 }
 protected function get_option_manager()
 {
     return FS_Option_Manager::get_manager(WP_FS__ACCOUNTS_OPTION_NAME, true);
 }
<?php

/**
 * @package     Freemius
 * @copyright   Copyright (c) 2015, Freemius, Inc.
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       1.1.7.3
 */
if (!defined('ABSPATH')) {
    exit;
}
$fs_options = FS_Option_Manager::get_manager(WP_FS__ACCOUNTS_OPTION_NAME, true);
$plugins = $fs_options->get_option('plugins');
$scheduled_crons = array();
if (is_array($plugins) && 0 < count($plugins)) {
    foreach ($plugins as $slug => $data) {
        $fs = freemius($slug);
        $next_execution = $fs->next_sync_cron();
        $last_execution = $fs->last_sync_cron();
        if (false !== $next_execution) {
            $scheduled_crons[$slug][] = array('name' => $fs->get_plugin_name(), 'slug' => $slug, 'type' => 'sync_cron', 'last' => $last_execution, 'next' => $next_execution);
        }
        $next_install_execution = $fs->next_install_sync();
        $last_install_execution = $fs->last_install_sync();
        if (false !== $next_install_execution || false !== $last_install_execution) {
            $scheduled_crons[$slug][] = array('name' => $fs->get_plugin_name(), 'slug' => $slug, 'type' => 'install_sync', 'last' => $last_install_execution, 'next' => $next_install_execution);
        }
    }
}
?>
<h1><?php 
 /**
  * Clear API cache.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.9
  */
 static function clear_cache()
 {
     self::$_cache = FS_Option_Manager::get_manager(WP_FS__API_CACHE_OPTION_NAME, true);
     self::$_cache->clear(true);
 }
 public function delete_account_and_settings()
 {
     $this->_options->delete();
 }
 /**
  * Purge cached item.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.1.6
  *
  * @param string $key
  */
 function purge($key)
 {
     $this->_logger->entrance('key = ' . $key);
     $this->_options->unset_option($key, true);
 }
 function store()
 {
     $this->_options->store();
 }
 /**
  * Load account information from RatingWidget to Freemius.
  * It's a migration method that should be only executed once.
  * @return array
  */
 function rw_fs_load_external_account()
 {
     $options = FS_Option_Manager::get_manager(WP_RW__OPTIONS, true);
     $site_public_key = $options->get_option(WP_RW__DB_OPTION_SITE_PUBLIC_KEY, false);
     $site_id = $options->get_option(WP_RW__DB_OPTION_SITE_ID, false);
     $owner_id = $options->get_option(WP_RW__DB_OPTION_OWNER_ID, false);
     $owner_email = $options->get_option(WP_RW__DB_OPTION_OWNER_EMAIL, false);
     $update = false;
     if (!defined('WP_RW__SITE_PUBLIC_KEY')) {
         define('WP_RW__SITE_PUBLIC_KEY', $site_public_key);
         define('WP_RW__SITE_ID', $site_id);
         define('WP_RW__OWNER_ID', $owner_id);
         define('WP_RW__OWNER_EMAIL', $owner_email);
     } else {
         if (is_string(WP_RW__SITE_PUBLIC_KEY) && WP_RW__SITE_PUBLIC_KEY !== $site_public_key) {
             // Override user key.
             $options->set_option(WP_RW__DB_OPTION_SITE_PUBLIC_KEY, WP_RW__SITE_PUBLIC_KEY);
             $options->set_option(WP_RW__DB_OPTION_SITE_ID, WP_RW__SITE_ID);
             if (defined('WP_RW__OWNER_ID')) {
                 $options->set_option(WP_RW__DB_OPTION_OWNER_ID, WP_RW__OWNER_ID);
             }
             if (defined('WP_RW__OWNER_EMAIL')) {
                 $options->set_option(WP_RW__DB_OPTION_OWNER_EMAIL, WP_RW__OWNER_EMAIL);
             }
             $update = true;
         }
     }
     $secret_key = $options->get_option(WP_RW__DB_OPTION_SITE_SECRET_KEY, false);
     if (!defined('WP_RW__SITE_SECRET_KEY')) {
         define('WP_RW__SITE_SECRET_KEY', $secret_key);
     } else {
         if (is_string(WP_RW__SITE_SECRET_KEY) && WP_RW__SITE_SECRET_KEY !== $secret_key) {
             // Override user key.
             $options->set_option(WP_RW__DB_OPTION_SITE_SECRET_KEY, WP_RW__SITE_SECRET_KEY);
             $update = true;
         }
     }
     if ($update) {
         $options->store();
     }
     $site = false;
     $user = false;
     if (false !== WP_RW__SITE_PUBLIC_KEY) {
         $site = new FS_Site();
         $site->id = $options->get_option(WP_RW__DB_OPTION_SITE_ID);
         $site->public_key = $options->get_option(WP_RW__DB_OPTION_SITE_PUBLIC_KEY);
         $site->secret_key = $options->get_option(WP_RW__DB_OPTION_SITE_SECRET_KEY);
         $user = new FS_User();
         $user->id = $options->get_option(WP_RW__DB_OPTION_OWNER_ID);
         $user->email = $options->get_option(WP_RW__DB_OPTION_OWNER_EMAIL);
     }
     return array('user' => $user, 'site' => $site);
 }