/**
  * @param array $args
  */
 public function __construct($args = array())
 {
     $defaults = array('api_url' => null, 'api_provider' => null, 'product_slug' => null, 'option_name' => null, 'license_scope' => self::LICENSE_SCOPE_SITE, 'check_period' => null, 'store_license_key' => false, 'update_checker' => null, 'token_history_size' => 0);
     $args = array_merge($defaults, $args);
     if (isset($args['api_provider'])) {
         $this->api = $args['api_provider'];
     } else {
         $this->api = new Wslm_LicenseManagerApi($args['api_url']);
     }
     $this->productSlug = $args['product_slug'];
     $this->optionName = $args['option_name'];
     $this->licenseScope = $args['license_scope'];
     $this->tokenHistorySize = $args['token_history_size'];
     if ($args['update_checker'] !== null) {
         $this->updateChecker = $args['update_checker'];
     }
     if ($this->updateChecker !== null) {
         if ($this->productSlug === null) {
             $this->productSlug = $this->updateChecker->slug;
         }
         $this->updateChecker->addQueryArgFilter(array($this, 'filterUpdateChecks'));
         $this->updateChecker->addResultFilter(array($this, 'refreshLicenseFromPluginInfo'));
         //Add license data to update download URL, or remove the URL if we don't have a license.
         $downloadFilter = array($this, 'filterUpdateDownloadUrl');
         $this->updateChecker->addFilter('request_info_result', $downloadFilter, 20);
         $this->updateChecker->addFilter('pre_inject_update', $downloadFilter);
         $this->updateChecker->addFilter('pre_inject_info', $downloadFilter);
     }
     if (empty($this->optionName)) {
         $this->optionName = 'wsh_license_manager-' . $this->productSlug;
     }
     $this->load();
     //Set up the periodic update checks
     $this->cronHook = 'check_license_updates-' . $this->getProductSlug();
     $this->checkPeriod = $args['check_period'];
     if ($this->checkPeriod > 0 && $this->shouldCheckForUpdates()) {
         //Trigger the check via Cron
         add_filter('cron_schedules', array($this, 'addCustomSchedule'));
         if (!wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING')) {
             $scheduleName = 'every' . $this->checkPeriod . 'hours';
             wp_schedule_event(time(), $scheduleName, $this->cronHook);
         }
         add_action($this->cronHook, array($this, 'checkForLicenseUpdates'));
     } else {
         //Periodic checks are disabled.
         wp_clear_scheduled_hook($this->cronHook);
     }
 }
Пример #2
0
 public function __construct($slug, $url)
 {
     $this->slug = $slug;
     $this->url = $url;
     # This needs to exact match PluginUpdateChecker's view
     $this->plugin_file = plugin_basename($this->slug . '/' . $this->slug . '.php');
     add_action('updraftplus_restore_db_pre', array($this, 'updraftplus_restore_db_pre'));
     add_action('updraftplus_restored_db_is_migration', array($this, 'updraftplus_restored_db_is_migration'));
     add_action('updraftplus_showrawinfo', array($this, 'updraftplus_showrawinfo'));
     add_action(is_multisite() && class_exists('UpdraftPlusAddOn_MultiSite') ? 'network_admin_menu' : 'admin_menu', array($this, 'admin_menu'));
     add_action('wp_ajax_udaddons_claimaddon', array($this, 'ajax_udaddons_claimaddon'));
     if (class_exists('UpdraftPlusAddons')) {
         return;
     }
     # Prevent updates from wordpress.org showing in all circumstances. Run with lower than default priority, to allow later processes to add something.
     add_filter('site_transient_update_plugins', array($this, 'site_transient_update_plugins'), 9);
     // Over-ride update mechanism for the plugin
     if (is_readable(UDADDONS2_DIR . '/plugin-updates/plugin-update-checker.php')) {
         require_once UDADDONS2_DIR . '/plugin-updates/plugin-update-checker.php';
         $options = $this->get_option(UDADDONS2_SLUG . '_options');
         $email = isset($options['email']) ? $options['email'] : '';
         if ($email) {
             add_filter('puc_check_now-' . $this->slug, array($this, 'puc_check_now'), 10, 3);
             add_filter('puc_retain_fields-' . $this->slug, array($this, 'puc_retain_fields'));
             add_filter('puc_request_info_options-' . $this->slug, array($this, 'puc_request_info_options'));
             $plug_updatechecker = new PluginUpdateChecker($this->url . "/plugin-info/", WP_PLUGIN_DIR . '/' . $this->slug . '/' . $this->slug . '.php', $this->slug, 24);
             $plug_updatechecker->addQueryArgFilter(array($this, 'updater_queryargs_plugin'));
             if ($this->debug) {
                 $plug_updatechecker->debugMode = true;
             }
             $this->plug_updatechecker = $plug_updatechecker;
         }
     }
 }
Пример #3
0
define('URE_PLUGIN_FILE', basename(__FILE__));
define('URE_PLUGIN_FULL_PATH', __FILE__);
if (!class_exists('Garvs_WP_Lib')) {
    require_once URE_PLUGIN_DIR . 'includes/class-garvs-wp-lib.php';
}
require_once URE_PLUGIN_DIR . 'includes/class-ure-lib.php';
require_once URE_PLUGIN_DIR . 'includes/pro/class-ure-lib-pro.php';
// check PHP version
$ure_required_php_version = '5.2.4';
$exit_msg = sprintf('User Role Editor requires PHP %s or newer.', $ure_required_php_version) . '<a href="http://wordpress.org/about/requirements/"> ' . 'Please update!' . '</a>';
URE_Lib_Pro::check_version(PHP_VERSION, $ure_required_php_version, $exit_msg, __FILE__);
// check WP version
$ure_required_wp_version = '3.5';
$exit_msg = sprintf('User Role Editor requires WordPress %s or newer.', $ure_required_wp_version) . '<a href="http://codex.wordpress.org/Upgrading_WordPress"> ' . 'Please update!' . '</a>';
URE_Lib_Pro::check_version(get_bloginfo('version'), $ure_required_wp_version, $exit_msg, __FILE__);
require_once URE_PLUGIN_DIR . 'includes/define-constants.php';
require_once URE_PLUGIN_DIR . 'includes/misc-support-stuff.php';
require_once URE_PLUGIN_DIR . 'includes/class-ure-screen-help.php';
require_once URE_PLUGIN_DIR . 'includes/pro/class-ure-screen-help-pro.php';
require_once URE_PLUGIN_DIR . 'includes/class-user-role-editor.php';
require_once URE_PLUGIN_DIR . 'includes/pro/class-user-role-editor-pro.php';
require_once URE_PLUGIN_DIR . 'includes/pro/class-export-import.php';
$ure_lib = new URE_Lib_Pro('user_role_editor');
$user_role_editor = new User_Role_Editor_Pro($ure_lib);
$GLOBALS['user_role_editor'] = $user_role_editor;
if (is_admin()) {
    require_once URE_PLUGIN_DIR . 'includes/pro/plugin-update-checker.php';
    $ure_update_checker = new PluginUpdateChecker('https://www.role-editor.com/update?action=get_metadata&slug=user-role-editor-pro', __FILE__);
    //Add the license key to query arguments.
    $ure_update_checker->addQueryArgFilter(array($user_role_editor, 'filter_update_checks'));
}