コード例 #1
0
 /**
  * Updates information on the "View version x.x details" page with custom data.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.0.4
  *
  * @uses   FS_Api
  *
  * @param object $data
  * @param string $action
  * @param mixed  $args
  *
  * @return object
  */
 function plugins_api_filter($data, $action = '', $args = null)
 {
     $this->_logger->entrance();
     if ('plugin_information' !== $action || !isset($args->slug)) {
         return $data;
     }
     $addon = false;
     $is_addon = false;
     if ($this->_fs->get_slug() !== $args->slug) {
         $addon = $this->_fs->get_addon_by_slug($args->slug);
         if (!is_object($addon)) {
             return $data;
         }
         $is_addon = true;
     }
     $plugin_in_repo = false;
     if (!$is_addon) {
         // Try to fetch info from .org repository.
         $data = self::_fetch_plugin_info_from_repository($action, $args);
         $plugin_in_repo = false !== $data;
     }
     if (!$plugin_in_repo) {
         $data = $args;
         // Fetch as much as possible info from local files.
         $plugin_local_data = $this->_fs->get_plugin_data();
         $data->name = $plugin_local_data['Name'];
         $data->author = $plugin_local_data['Author'];
         $data->sections = array('description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.');
         // @todo Store extra plugin info on Freemius or parse readme.txt markup.
         /*$info = $this->_fs->get_api_site_scope()->call('/information.json');
         
         if ( !isset($info->error) ) {
         	$data = $info;
         }*/
     }
     // Get plugin's newest update.
     $new_version = $this->_fs->_fetch_latest_version($is_addon ? $addon->id : false);
     if ($is_addon) {
         $data->name = $addon->title . ' ' . __fs('addon', $this->_fs->get_slug());
         $data->slug = $addon->slug;
         $data->url = WP_FS__ADDRESS;
         $data->package = $new_version->url;
     }
     if (!$plugin_in_repo) {
         $data->last_updated = !is_null($new_version->updated) ? $new_version->updated : $new_version->created;
         $data->requires = $new_version->requires_platform_version;
         $data->tested = $new_version->tested_up_to_version;
     }
     $data->version = $new_version->version;
     $data->download_link = $new_version->url;
     return $data;
 }
コード例 #2
0
 /**
  * @author Vova Feldman (@svovaf)
  * @since  1.1.7
  *
  * @param object              $api
  * @param FS_Plugin_Plan|null $plan
  *
  * @return string
  */
 private function get_plugin_cta($api, $plan = null)
 {
     if (current_user_can('install_plugins') || current_user_can('update_plugins')) {
         if (!empty($api->checkout_link) && isset($api->plans) && 0 < is_array($api->plans)) {
             if (is_null($plan)) {
                 $plan = $api->plans[0];
             }
             return ' <a class="button button-primary right" href="' . $this->_fs->addon_checkout_url($plan->plugin_id, $plan->pricing[0]->id, $this->get_billing_cycle($plan), $plan->has_trial()) . '" target="_parent">' . (!$plan->has_trial() ? __fs('purchase', $api->slug) : sprintf(__fs('start-free-x', $api->slug), $this->get_trial_period($plan))) . '</a>';
             // @todo Add Cart concept.
             //			echo ' <a class="button right" href="' . $status['url'] . '" target="_parent">' . __( 'Add to Cart' ) . '</a>';
         } else {
             if (!empty($api->download_link)) {
                 $status = install_plugin_install_status($api);
                 // Hosted on WordPress.org.
                 switch ($status['status']) {
                     case 'install':
                         if ($api->external && $this->_fs->is_org_repo_compliant() || !$this->_fs->is_premium()) {
                             /**
                              * Add-on hosted on Freemius, not yet installed, and core
                              * plugin is wordpress.org compliant. Therefore, require a download
                              * since installing external plugins is not allowed by the wp.org guidelines.
                              */
                             return ' <a class="button button-primary right" href="' . esc_url($api->download_link) . '" target="_blank">' . __fs('download-latest', $api->slug) . '</a>';
                         } else {
                             if ($status['url']) {
                                 return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
                             }
                         }
                         break;
                     case 'update_available':
                         if ($status['url']) {
                             return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') . '</a>';
                         }
                         break;
                     case 'newer_installed':
                         return '<a class="button button-primary right disabled">' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
                         break;
                     case 'latest_installed':
                         return '<a class="button button-primary right disabled">' . __('Latest Version Installed') . '</a>';
                         break;
                 }
             }
         }
     }
     return '';
 }
コード例 #3
0
 public function GetRatingDataByRatingID($pRatingID, $pAccuracy = false)
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence('GetRatingDataByRatingID', $params);
     }
     // API only supported in the Professional plan, so no reason to make calls that will return errors.
     if (!$this->fs->is_plan_or_trial('professional') || !$this->is_api_supported()) {
         return false;
     }
     $rating = rwapi()->get('/ratings/' . $pRatingID . '.json?is_external=true&fields=id,approved_count,avg_rate', false, WP_RW__CACHE_TIMEOUT_RICH_SNIPPETS);
     if (isset($rating->error)) {
         return false;
     }
     $avg_rate = (double) $rating->avg_rate;
     $votes = (int) $rating->approved_count;
     $rate = $votes * $avg_rate;
     if (is_numeric($pAccuracy)) {
         $pAccuracy = (int) $pAccuracy;
         $avg_rate = (double) sprintf("%.{$pAccuracy}f", $avg_rate);
         $rate = (double) sprintf("%.{$pAccuracy}f", $rate);
     }
     return array('votes' => $votes, 'totalRate' => $rate, 'rate' => $avg_rate);
 }
コード例 #4
0
 /**
  * @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;
 }
コード例 #5
0
ファイル: start.php プロジェクト: gigabyte1977/kanban
 /**
  * @param array [string]string $plugin
  *
  * @return Freemius
  * @throws Freemius_Exception
  */
 function fs_dynamic_init($plugin)
 {
     $fs = Freemius::instance($plugin['slug']);
     $fs->dynamic_init($plugin);
     return $fs;
 }
コード例 #6
0
 private static function _load_required_static()
 {
     if (self::$_statics_loaded) {
         return;
     }
     self::$_static_logger = FS_Logger::get_logger(WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK);
     self::$_static_logger->entrance();
     self::$_accounts = FS_Option_Manager::get_manager(WP_FS__ACCOUNTS_OPTION_NAME, true);
     self::$_statics_loaded = true;
 }
コード例 #7
0
ファイル: connect.php プロジェクト: mmarj/CF7Customizer
		<?php 
if ($fs->enable_anonymous()) {
    ?>
			<a href="<?php 
    echo wp_nonce_url($fs->_get_admin_page_url('', array('fs_action' => $slug . '_skip_activation')), $slug . '_skip_activation');
    ?>
"
			   class="button button-secondary" tabindex="2"><?php 
    _efs('skip');
    ?>
</a>
		<?php 
}
?>
		<?php 
$fs_user = Freemius::_get_user_by_email($current_user->user_email);
?>
		<?php 
if (is_object($fs_user)) {
    ?>
			<form action="" method="POST">
				<input type="hidden" name="fs_action" value="<?php 
    echo $slug;
    ?>
_activate_existing">
				<?php 
    wp_nonce_field('activate_existing_' . $fs->get_public_key());
    ?>
				<button class="button button-primary" tabindex="1"
				        type="submit"><?php 
    _efs('opt-in-connect');
コード例 #8
0
    public function _freemius_custom_connect_message($message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link)
    {
        return sprintf(__('<b>Please help us improve %1$s!</b><br>
		     	If you opt-in, some data about your usage of <b>%1$s</b> will be sent to %2$s.
		     	If you skip this, that\'s okay! <b>%1$s</b> will still work just fine.', 'aryo-activity-log'), $this->freemius->get_plugin_name(), $freemius_link);
    }
コード例 #9
0
 /**
  * @param array<string,string> $module Plugin or Theme details.
  *
  * @return Freemius
  * @throws Freemius_Exception
  */
 function fs_dynamic_init($module)
 {
     $fs = Freemius::instance($module['slug'], true);
     $fs->dynamic_init($module);
     return $fs;
 }
コード例 #10
0
ファイル: start.php プロジェクト: AlexOreshkevich/velomode.by
 /**
  * @return Freemius
  */
 function fs($slug)
 {
     return Freemius::instance($slug);
 }