예제 #1
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;
         }
     }
 }
예제 #2
0
 public function render()
 {
     printf('<div class="puc-debug-bar-panel" id="puc-debug-bar-panel_%1$s" data-slug="%1$s" data-nonce="%2$s">', esc_attr($this->updateChecker->slug), esc_attr(wp_create_nonce('puc-ajax')));
     $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
     echo '<h3>Configuration</h3>';
     echo '<table class="puc-debug-data">';
     $this->row('Plugin file', htmlentities($this->updateChecker->pluginFile));
     $this->row('Slug', htmlentities($this->updateChecker->slug));
     $this->row('DB option', htmlentities($this->updateChecker->optionName));
     $requestInfoButton = function_exists('get_submit_button') ? get_submit_button('Request Info', 'secondary', 'puc-request-info-button', false) : '';
     $this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $responseBox);
     if ($this->updateChecker->checkPeriod > 0) {
         $this->row('Automatic checks', 'Every ' . $this->updateChecker->checkPeriod . ' hours');
     } else {
         $this->row('Automatic checks', 'Disabled');
     }
     if (isset($this->updateChecker->throttleRedundantChecks)) {
         if ($this->updateChecker->throttleRedundantChecks && $this->updateChecker->checkPeriod > 0) {
             $this->row('Throttling', sprintf('Enabled. If an update is already available, check for updates every %1$d hours instead of every %2$d hours.', $this->updateChecker->throttledCheckPeriod, $this->updateChecker->checkPeriod));
         } else {
             $this->row('Throttling', 'Disabled');
         }
     }
     echo '</table>';
     echo '<h3>Status</h3>';
     echo '<table class="puc-debug-data">';
     $state = $this->updateChecker->getUpdateState();
     $checkNowButton = function_exists('get_submit_button') ? get_submit_button('Check Now', 'secondary', 'puc-check-now-button', false) : '';
     if (isset($state, $state->lastCheck)) {
         $this->row('Last check', $this->formatTimeWithDelta($state->lastCheck) . ' ' . $checkNowButton . $responseBox);
     } else {
         $this->row('Last check', 'Never');
     }
     $nextCheck = wp_next_scheduled($this->updateChecker->getCronHookName());
     $this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck));
     if (isset($state, $state->checkedVersion)) {
         $this->row('Checked version', htmlentities($state->checkedVersion));
         $this->row('Cached update', $state->update);
     }
     $this->row('Update checker class', htmlentities(get_class($this->updateChecker)));
     echo '</table>';
     $update = $this->updateChecker->getUpdate();
     if ($update !== null) {
         echo '<h3>An Update Is Available</h3>';
         echo '<table class="puc-debug-data">';
         $fields = array('version', 'download_url', 'slug', 'homepage', 'upgrade_notice');
         foreach ($fields as $field) {
             $this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->{$field}));
         }
         echo '</table>';
     } else {
         echo '<h3>No updates currently available</h3>';
     }
     echo '</div>';
 }
예제 #3
0
 /**
  * Request plugin info and output it.
  */
 public function ajaxRequestInfo()
 {
     if ($_POST['slug'] !== $this->updateChecker->slug) {
         return;
     }
     $this->preAjaxReqest();
     $info = $this->updateChecker->requestInfo();
     if ($info !== null) {
         echo 'Successfully retrieved plugin info from the metadata URL:';
         echo '<pre>', htmlentities(print_r($info, true)), '</pre>';
     } else {
         echo 'Failed to retrieve plugin info from the metadata URL.';
     }
     exit;
 }
 private function displayCurrentUpdate()
 {
     $update = $this->updateChecker->getUpdate();
     if ($update !== null) {
         echo '<h3>An Update Is Available</h3>';
         echo '<table class="puc-debug-data">';
         $fields = array('version', 'download_url', 'slug', 'homepage', 'upgrade_notice');
         foreach ($fields as $field) {
             $this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->{$field}));
         }
         echo '</table>';
     } else {
         echo '<h3>No updates currently available</h3>';
     }
 }
 /**
  * Abort update if the user doesn't have a valid key or the key has expired (not eligible for updates).
  *
  * @param bool|WP_Error $result
  * @param string $package Update download URL. Typically points to a .zip file.
  * @param WP_Upgrader $upgrader
  * @return bool|WP_Error
  */
 function authorizePluginUpdate($result, $package, $upgrader)
 {
     //Sanity check.
     if (!isset($upgrader, $upgrader->skin)) {
         return $result;
     }
     $license = $this->licenseManager->getLicense();
     if ($license->isValid() || !$this->updateChecker->isPluginBeingUpgraded($upgrader)) {
         return $result;
     }
     if ($license->getStatus() === 'expired') {
         //Reload the license in case the user just renewed and is retrying the update.
         $this->licenseManager->checkForLicenseUpdates();
         $license = $this->licenseManager->getLicense();
         if ($license->isValid()) {
             return $result;
         }
     }
     $status = $license->getStatus();
     $messages = array('no_license_yet' => "Please enter your license key to enable plugin updates.", 'expired' => sprintf('Your access to %s updates has expired. Please renew your license.', apply_filters('wslm_product_name-' . $this->slug, $this->slug)));
     $result = new WP_Error('wslm_update_not_available', isset($messages[$status]) ? $messages[$status] : 'Update not available. Please (re)enter your license key.', '[' . $status . ']');
     //This bit is important. At least in WP 4.3, the return value will be lost or replaced with a generic
     //"download failed" error unless you also set it on the upgrader skin.
     $upgrader->skin->set_result($result);
     return $result;
 }
 /**
  * @param Wslm_LicenseManagerApiResponse $result
  * @param string|null $licenseKey
  * @param string|null $siteToken
  * @return Wslm_ProductLicense|WP_Error
  */
 private function processActivationResponse($result, $licenseKey = null, $siteToken = null)
 {
     if ($result->success()) {
         //Success! Lets save our license data.
         $this->license = $this->createLicenseObject($result->response->license);
         $this->siteToken = isset($result->response->site_token) ? $result->response->site_token : $siteToken;
         $this->licenseKey = $this->storeLicenseKey ? $licenseKey : null;
         if (!isset($this->license['site_url']) && !empty($this->siteToken)) {
             $this->license['site_url'] = $this->getSiteUrl();
         }
         if ($this->tokenHistorySize > 0 && !empty($this->siteToken)) {
             //Add this token+site combination to the bottom of the list.
             $this->tokenHistory = isset($this->tokenHistory) ? $this->tokenHistory : array();
             unset($this->tokenHistory[$this->siteToken]);
             $this->tokenHistory[$this->siteToken] = $this->getSiteUrl();
         }
         do_action('wslm_license_activated-' . $this->productSlug, $this->license);
         $this->save();
         //Now that we have a valid license, an update might be available. Clear the cache.
         if ($this->updateChecker !== null) {
             $this->updateChecker->resetUpdateState();
         }
         return $this->license;
     } else {
         $error = $result->asWpError();
         if (isset($result->response->license)) {
             $error->add_data($this->createLicenseObject($result->response->license), 'license');
         }
         return $error;
     }
 }
예제 #7
0
 /**
  * @param $licenseKey
  * @return Wslm_ProductLicense|WP_Error
  */
 public function licenseThisSite($licenseKey)
 {
     $result = $this->api->licenseSite($this->productSlug, $licenseKey, $this->getSiteUrl());
     if ($result->success()) {
         //Success! Lets save our license data.
         $this->license = $this->createLicenseObject($result->response->license);
         $this->siteToken = $result->response->site_token;
         $this->licenseKey = $licenseKey;
         $this->save();
         //Now that we have a valid license, an update might be available. Clear the cache.
         if ($this->updateChecker !== null) {
             $this->updateChecker->resetUpdateState();
         }
         return $this->license;
     } else {
         $error = $result->asWpError();
         if (isset($result->response->license)) {
             $error->add_data($this->createLicenseObject($result->response->license), 'license');
         }
         return $error;
     }
 }
예제 #8
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'));
}
예제 #9
0
 function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '')
 {
     parent::__construct($metadataUrl, $pluginFile, $slug, $checkPeriod, $optionName);
 }