/** * Constructor * * Loads options to private static variable. */ public function __construct() { self::$options = get_site_option('github_updater', array()); $this->add_headers(); /* * Calls $this->init() in init hook so other remote upgrader apps like * InfiniteWP, ManageWP, MainWP, and iThemes Sync will load and use all * of GitHub_Updater's methods, especially renaming. */ add_action('init', array(&$this, 'init')); }
/** * Constructor * * Loads options to private static variable. */ public function __construct() { self::$options = get_site_option('github_updater', array()); $this->add_headers(); }
/** * Constructor. * Loads options to private static variable. */ public function __construct() { self::$options = get_site_option('github_updater', array()); $this->add_headers(); /* * Calls in init hook for user capabilities. */ add_action('init', array(&$this, 'init')); add_action('init', array(&$this, 'remote_update')); }
/** * Allows developers to use 'github_updater_token_distribution' hook to set GitHub Access Tokens. * Saves results of filter hook to self::$options. * * Hook requires return of single element array. * $key === repo-name and $value === token * e.g. array( 'repo-name' => 'access_token' ); */ public function token_distribution() { $config = apply_filters('github_updater_token_distribution', array()); if (!empty($config) && 1 === count($config)) { $config = Settings::sanitize($config); self::$options = array_merge(get_site_option('github_updater'), $config); update_site_option('github_updater', self::$options); } }
/** * Allows developers to use 'github_updater_set_options' hook to set access tokens or other settings. * Saves results of filter hook to self::$options. * * Hook requires return of associative element array. * $key === repo-name and $value === token * e.g. array( 'repo-name' => 'access_token' ); * * @TODO Set `Requires WP: 4.6` and only use current filter and apply_filters_deprecated */ public function set_options_filter() { // Single plugin/theme should not be using both hooks. $config = apply_filters('github_updater_set_options', array()); if (empty($config)) { $config = function_exists('apply_filters_deprecated') ? apply_filters_deprecated('github_updater_token_distribution', array(null), '6.1.0', 'github_updater_set_options') : apply_filters('github_updater_token_distribution', array()); } if (!empty($config)) { $config = Settings::sanitize($config); self::$options = array_merge(get_site_option('github_updater'), $config); update_site_option('github_updater', self::$options); } }