How to use update_checker class

Best Phoronix-test-suite code snippet using update_checker

PluginCore.php

Source:PluginCore.php Github

copy

Full Screen

...71 public $admin_page;72 /**73 * @var \Puc_v4p10_Plugin_UpdateChecker74 */75 private $update_checker;76 /**77 * @var string Repo uri78 */79 private $update_repo_uri;80 /**81 * @var string Repo authentication key82 */83 private $update_auth;84 85 /**86 * @var string Repo branch87 */88 private $update_branch;89 /**90 * Static array of all PluginCore instances91 * Used in PluginCore::get($slug)92 * 93 * @var array[PluginCore] Instances of PluginCore94 */95 static $cores = [];96 /**97 * Retrieve instance of PluginCore by plugin slug.98 * 99 * @param string $slug - Plugin slug100 * @return PluginCore - Instance of specific plugin.101 */102 static public function get( $slug ) {103 return self::$cores[ $slug ] ?? null;104 }105 function __construct( $plugin_file, $options = null ) {106 $this->plugin_file( $plugin_file );107 if ( is_array( $options ) && ! empty( $options ) ) {108 $options = (object) $options;109 $this->title( $options->title ?? null ); // fallback: get title from header plugin_data110 $this->slug( $options->slug ?? null ); // fallback: guess slug from plugin basename111 $this->const( $options->const ?? null ); // fallback: generate const from slug112 if ( isset( $options->activate_cb ) )113 $this->activate_cb( $options->activate_cb );114 if ( isset( $options->deactivate_cb ) )115 $this->deactivate_cb( $options->deactivate_cb );116 if ( isset( $options->uninstall_cb ) )117 $this->uninstall_cb( $options->uninstall_cb );118 if ( isset( $options->upgrade_cb ) )119 $this->upgrade_cb( $options->upgrade_cb );120 if ( isset( $options->action_links ) )121 $this->action_links( $options->action_links );122 if ( isset( $options->admin_page ) )123 $this->admin_page( $options->admin_page ); // creates AdminPage instance124 if ( isset( $options->update_checker ) )125 $this->update_checker( $options->update_checker );126 }127 128 $this->bootstrap();129 }130 /**131 * Bootstrap132 * 133 * Setup url, path, plugin_basename variables134 * Add PluginCore instance to static $cores135 * Define plugin constants (_PATH, _URL, _BASENAME, _FILE etc.)136 * Register activation, deactivation, uninstall, upgrade hooks.137 * Init PUC update checker.138 * 139 * @todo set plugin_dir_path, plugin_basename as accessible public variables (available thru methods atm)140 */141 private function bootstrap() {142 // validate basic variables (in case no options array were given)143 $this->title();144 $this->slug();145 $this->const();146 // set variables147 $this->path();148 $this->url();149 $this->plugin_basename();150 /**151 * Add this PluginCore instance to static list of PluginCore instances (key = slug).152 * @see static function get()153 */154 self::$cores[ $this->slug ] = $this;155 // define constants156 define( $this->const . '_PATH', $this->path );157 define( $this->const . '_DIR', $this->path );158 define( $this->const . '_URL', $this->url );159 define( $this->const . '_BASENAME', $this->plugin_basename );160 define( $this->const . '_PLUGIN_FILE', $this->plugin_file );161 define( $this->const . '_FILE', $this->plugin_file );162 $this->register_hooks();163 $this->add_plugin_action_links();164 if ( $this->update_checker === true ) {165 $this->build_update_checker();166 }167 }168 private function register_hooks() {169 if ( ! empty( $this->activate_cb ) ) // && is_callable() ?170 register_activation_hook( $this->plugin_file, $this->activate_cb );171 172 if ( ! empty( $this->deactivate_cb ) )173 register_deactivation_hook( $this->plugin_file, $this->deactivate_cb );174 if ( ! empty( $this->uninstall_cb ) )175 register_uninstall_hook( $this->plugin_file, $this->uninstall_cb );176 if ( ! empty( $this->upgrade_cb ) )177 add_action( 'upgrader_process_complete', [ $this, 'upgrade_cb_wrapper' ], 10, 2 );178 }179 /**180 * Getter/Setter - title181 * Plugin title.182 * If none provided - plugin header Title will be used.183 * 184 * @param string|null $title185 * @return string $this->title186 */187 public function title( $title = null ) {188 return $this->title ??= esc_html( $title ) ?: $this->plugin_data()['Title'];189 }190 /**191 * Wrapper function for $this->title()192 * 193 * @deprecated194 */195 public function name( $title = null ) {196 _doing_it_wrong( __METHOD__, 'Use PluginCore::title instead.', '0.21' );197 return $this->title( $title );198 }199 /**200 * Getter/Setter - slug201 * Plugin slug.202 * If none provided - plugin file basename will be used203 * 204 * @param string|null $slug205 * @return string $this->slug206 */207 public function slug( $slug = null ) {208 return $this->slug ??= $slug ?: basename( $this->plugin_file, '.php' );209 }210 /**211 * Setter - plugin_file (also Getter - kinda)212 * Plugin file fully qualified path.213 * 214 * @param string $plugin_file - Path to plugin file215 * @return string $this->plugin_file216 */217 public function plugin_file( $plugin_file ) {218 return $this->plugin_file ??= $plugin_file;219 }220 /**221 * GETTER function. NOT a wrapper222 * Might have to rethink this223 * used by test-plugin update_checker224 * 225 * @todo revisit this226 */227 public function file() {228 return $this->plugin_file;229 }230 /**231 * Getter/Setter - plugin data array232 */233 public function plugin_data() {234 return $this->plugin_data ??= get_plugin_data( $this->plugin_file, false);235 }236 /**237 * Getter/Setter - const238 * Prefix of plugin specific defines (PLUGIN_NAME_PATH etc.)239 * If not provided - plugin slug will be uppercase.240 * 241 * @param string|null $const (string should be uppercase)242 * @return string $this->const243 */244 public function const( $const = null ) {245 return $this->const ??= $const ?: str_replace( '-', '_' , strtoupper( $this->slug() ) );246 }247 /**248 * Getter/setter249 */250 public function path() {251 return $this->path ??= plugin_dir_path( $this->plugin_file );252 }253 /**254 * Getter/Setter255 */256 public function url() {257 return $this->url ??= plugin_dir_url( $this->plugin_file );258 }259 /**260 * Getter/Setter261 */262 public function plugin_basename() {263 return $this->plugin_basename ??= plugin_basename( $this->plugin_file );264 }265 /**266 * Setter - Activation callback267 * Callback runs on 'register_activation_hook'268 * PluginCore does not validate. Authors must ensure valid callback.269 * 270 * @param callable $activate_cb - Activation callback271 * 272 * @access private273 */274 private function activate_cb( $activate_cb ) {275 $this->activate_cb = $activate_cb;276 }277 /**278 * Setter - Deactivation callback279 * Callback runs on 'register_deactivation_hook'280 * PluginCore does not validate. Authors must ensure valid callback.281 * 282 * @param callable $deactivate_cb - Deactivation callback.283 * 284 * @access private285 */286 private function deactivate_cb( $deactivate_cb ) {287 $this->deactivate_cb = $deactivate_cb;288 }289 /**290 * Setter - Uninstall callback291 * Callback runs on 'register_uninstall_hook'292 * PluginCore does not validate. Authors must ensure valid callback.293 * 294 * @param callable $uninstall_cb - Uninstall callback.295 * 296 * @access private297 */298 private function uninstall_cb( $uninstall_cb ) {299 $this->uninstall_cb = $uninstall_cb;300 }301 /**302 * Setter - Upgrade callback303 * Callback runs on 'upgrader_process_complete' hook - only for our plugin.304 * Runs inside wrapper function that ensures our plugin was updated. 305 * (@see upgrade_cb_wrapper() below)306 * 307 * PluginCore does not validate. Authors must ensure valid callback.308 * 309 * @param callable $upgrade_cb - Upgrade callback.310 * 311 * @access private312 */313 private function upgrade_cb( $upgrade_cb ) {314 $this->upgrade_cb = $upgrade_cb;315 }316 /**317 * Setter - Plugin action links318 * 319 * Add links to plugin action links on Plugins page.320 * Accepts callable hooked to 'plugin_action_links_{$plugin}'321 * Alternatively accepts array of key => string/HTML tag (eg. [ 'settings' => '<a href="foo" />' ] )322 * Alternatively accepts array of key => [ 'text' => 'My Link', 'href' => 'foo' ]323 * Special case: Settings Page324 * [ 'settings' => [ 'href' => 'menu_page', 'text' => 'Settings' ] ] will generate link to plugin menu page url (@see menu_page_url() )325 * (@see add_plugin_action_links() below)326 * 327 * @since 0.21328 * 329 * @param callable|array $action_links - filter function or custom action links array330 * 331 * @todo perhaps have separate action_links_array + action_links_cb variables332 */333 private function action_links( $action_links ) {334 $this->action_links = $action_links;335 }336 /**337 * Getter/Setter - AdminPage338 * 339 * Construct AdminPage instance for plugin. 340 * 341 * @param array $admin_page - AdminPage settings array342 * 343 * @return AdminPage344 */345 public function admin_page( $admin_page ) {346 if ( ! class_exists( 'WPHelper\AdminPage' ) )347 return;348 // validate349 $admin_page['slug'] ??= $this->slug();350 $admin_page['title'] ??= $this->title();351 $this->admin_page = new AdminPage( $admin_page );352 // validate for older versions of AdminPage353 if ( method_exists( $this->admin_page, 'plugin_core' ) ) {354 $this->admin_page->plugin_core( $this ); // back-reference355 }356 return $this->admin_page;357 }358 /**359 * Setter360 * 361 * Setup info used by Puc_v4_Factory362 * 363 * set $update_checker (bool)364 * set $update_repo_uri (string)365 * set $update_auth (optional)366 * set $update_branch (optional)367 * 368 * @param bool|string|array $update_checker369 */370 private function update_checker( $update_checker ) {371 if ( empty( $update_checker ) ) {372 $this->update_checker = false;373 }374 if ( is_bool( $update_checker ) ) {375 $this->update_checker = $update_checker;376 }377 // option 'update_checker' accepts string - repo uri378 if ( is_string( $update_checker ) ) {379 $this->update_checker = true;380 $this->update_repo_uri = $update_checker;381 }382 // option 'update_checker' accepts array: ['uri'=> , 'auth'=>, 'branch'=> ]383 if ( is_array( $update_checker ) ) {384 $this->update_checker = true;385 if ( isset( $update_checker['uri'] ) ) {386 $this->update_repo_uri = $update_checker['uri'];387 }388 if ( isset( $update_checker['auth'] ) ) {389 $this->update_auth = $update_checker['auth'];390 }391 if ( isset( $update_checker['branch'] ) ) {392 $this->update_branch = $update_checker['branch'];393 }394 }395 // Use plugin header 'UpdateURI' or fallback to 'PluginURI'396 // call plugin_data() to init var plugin_data397 $this->update_repo_uri ??= $this->plugin_data()['UpdateURI'] ?: $this->plugin_data['PluginURI'] ?: null;398 // validate399 // If no repo uri - update checker is disabled.400 if ( empty( $this->update_repo_uri ) ) {401 $this->update_checker = false;402 }403 404 }405 /**406 * Init Puc update checker instance407 * 408 * @uses Puc_v4_Factory::buildUpdateChecker409 */410 private function build_update_checker() {411 412 if ( ! class_exists('Puc_v4_Factory') )413 return;414 $update_checker = Puc_v4_Factory::buildUpdateChecker(415 $this->update_repo_uri,416 $this->plugin_file,417 $this->slug() // using slug()418 );419 //Optional: If you're using a private repository, specify the access token like this:420 if ( isset( $this->update_auth ) )421 $update_checker->setAuthentication( $this->update_auth );422 //Optional: Set the branch that contains the stable release.423 if ( isset( $this->update_branch ) )424 $update_checker->setBranch( $this->update_branch );425 }426 /**427 * upgrade_cb_wrapper428 * 429 * This function only called if upgrade_cb is set (@see register_hooks())430 * This function called on upgrader_process_complete431 * sanity-checks if our plugin was upgraded432 * if so - calls upgrade_cb provided by our plugin433 */434 public function upgrade_cb_wrapper( $upgrader_object, $options ) {435 if(436 $options['action'] == 'update' // has upgrade taken place437 &&438 $options['type'] == 'plugin' // is it a plugin upgrade...

Full Screen

Full Screen

CronWorker.php

Source:CronWorker.php Github

copy

Full Screen

...53 /**54 * Class constructor.55 *56 * @param PoolInterface $cache An instance of cache pool.57 * @param UpdateChecker $update_checker An instance of update checker.58 */59 public function __construct(PoolInterface $cache, UpdateChecker $update_checker = null)60 {61 $this->cache = $cache;62 if (!is_null($update_checker)) {63 $this->updateChecker = $update_checker;64 }65 }66 /**67 * Performs all periodical actions.68 *69 * @return boolean True if all periodical actions are done and false70 * otherwise.71 */72 public function run()73 {74 try {75 set_time_limit(0);76 // Update time of last cron run77 Settings::set('_last_cron_run', time());78 // Remove stale cached items79 $this->cache->purge();80 // Run cron jobs of the core81 calculate_thread_statistics();82 calculate_operator_statistics();83 calculate_page_statistics();84 // Trigger cron event85 $dispatcher = EventDispatcher::getInstance();86 $dispatcher->triggerEvent(Events::CRON_RUN);87 if (Settings::get('autocheckupdates') == '1') {88 // Run the update checker89 $update_checker = $this->getUpdateChecker();90 if (!$update_checker->run()) {91 $this->errors = array_merge(92 $this->errors,93 $update_checker->getErrors()94 );95 return false;96 }97 }98 } catch (\Exception $e) {99 $this->log[] = $e->getMessage();100 return false;101 }102 return true;103 }104 /**105 * Retuns list of all errors that took place during running periodical106 * actions.107 *...

Full Screen

Full Screen

loader.php

Source:loader.php Github

copy

Full Screen

...85 $wpml = new RWMB_WPML();86 $wpml->init();87 // Update.88 $update_option = new RWMB_Update_Option();89 $update_checker = new RWMB_Update_Checker( $update_option );90 $update_checker->init();91 $update_settings = new RWMB_Update_Settings( $update_checker, $update_option );92 $update_settings->init();93 $update_notification = new RWMB_Update_Notification( $update_checker, $update_option );94 $update_notification->init();95 if ( is_admin() ) {96 $about = new RWMB_About( $update_checker );97 $about->init();98 }99 // Public functions.100 require_once RWMB_INC_DIR . 'functions.php';101 }102}...

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$updater = new pts_update_checker();3$updater->check_for_updates();4require_once('pts-core/pts-core.php');5$updater = new pts_update_checker();6$updater->check_for_updates();7require_once('pts-core/pts-core.php');8$updater = new pts_update_checker();9$updater->check_for_updates();10require_once('pts-core/pts-core.php');11$updater = new pts_update_checker();12$updater->check_for_updates();13require_once('pts-core/pts-core.php');14$updater = new pts_update_checker();15$updater->check_for_updates();16require_once('pts-core/pts-core.php');17$updater = new pts_update_checker();18$updater->check_for_updates();19require_once('pts-core/pts-core.php');20$updater = new pts_update_checker();21$updater->check_for_updates();22require_once('pts-core/pts-core.php');23$updater = new pts_update_checker();24$updater->check_for_updates();25require_once('pts-core/pts-core.php');26$updater = new pts_update_checker();27$updater->check_for_updates();28require_once('pts-core/pts-core.php');29$updater = new pts_update_checker();30$updater->check_for_updates();31require_once('pts-core/pts-core.php');32$updater = new pts_update_checker();

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$updater = new pts_update_checker();3$updater->perform_update_check();4require_once('pts-core/pts-core.php');5$updater = new pts_update_checker();6$updater->perform_update_check();7require_once('pts-core/pts-core.php');8$updater = new pts_update_checker();9$updater->perform_update_check();10require_once('pts-core/pts-core.php');11$updater = new pts_update_checker();12$updater->perform_update_check();13require_once('pts-core/pts-core.php');14$updater = new pts_update_checker();15$updater->perform_update_check();16require_once('pts-core/pts-core.php');17$updater = new pts_update_checker();18$updater->perform_update_check();19require_once('pts-core/pts-core.php');20$updater = new pts_update_checker();21$updater->perform_update_check();22require_once('pts-core/pts-core.php');23$updater = new pts_update_checker();24$updater->perform_update_check();25require_once('pts-core/pts-core.php');26$updater = new pts_update_checker();27$updater->perform_update_check();28require_once('pts-core/pts-core.php');29$updater = new pts_update_checker();30$updater->perform_update_check();31require_once('pts-core/pts-core.php');32$updater = new pts_update_checker();33$updater->perform_update_check();34require_once('pts-core/pts-core.php');

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');2$updater = new pts_updater();3$updater->auto_update_check(true);4$updater->auto_update_check(true, true);5require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');6$updater = new pts_updater();7$updater->auto_update_check(true);8$updater->auto_update_check(true, true);9require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');10$updater = new pts_updater();11$updater->auto_update_check(true);12$updater->auto_update_check(true, true);13require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');14$updater = new pts_updater();15$updater->auto_update_check(true);16$updater->auto_update_check(true, true);17require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');18$updater = new pts_updater();19$updater->auto_update_check(true);20$updater->auto_update_check(true, true);21require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');22$updater = new pts_updater();23$updater->auto_update_check(true);24$updater->auto_update_check(true, true);25require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');26$updater = new pts_updater();27$updater->auto_update_check(true);28$updater->auto_update_check(true, true);29require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$test = new pts_test('2');3$test->test_profile->set_test_installation(false);4$test->test_profile->set_test_installation(true);5$test->test_profile->set_test_installation(false);6$test->test_profile->set_test_installation(true);7$test->test_profile->set_test_installation(false);8$test->test_profile->set_test_installation(true);9$test->test_profile->set_test_installation(false);10$test->test_profile->set_test_installation(true);11$test->test_profile->set_test_installation(false);12$test->test_profile->set_test_installation(true);13$test->test_profile->set_test_installation(false);14$test->test_profile->set_test_installation(true);15$test->test_profile->set_test_installation(false);16$test->test_profile->set_test_installation(true);17$test->test_profile->set_test_installation(false);18$test->test_profile->set_test_installation(true);19$test->test_profile->set_test_installation(false);20$test->test_profile->set_test_installation(true);21$test->test_profile->set_test_installation(false);22$test->test_profile->set_test_installation(true);23$test->test_profile->set_test_installation(false);24$test->test_profile->set_test_installation(true);25$test->test_profile->set_test_installation(false);26$test->test_profile->set_test_installation(true);27$test->test_profile->set_test_installation(false);28$test->test_profile->set_test_installation(true);29$test->test_profile->set_test_installation(false);30$test->test_profile->set_test_installation(true);31$test->test_profile->set_test_installation(false);32$test->test_profile->set_test_installation(true);33$test->test_profile->set_test_installation(false);34$test->test_profile->set_test_installation(true);35$test->test_profile->set_test_installation(false);36$test->test_profile->set_test_installation(true);37$test->test_profile->set_test_installation(false);38$test->test_profile->set_test_installation(true);39$test->test_profile->set_test_installation(false);40$test->test_profile->set_test_installation(true);41$test->test_profile->set_test_installation(false);42$test->test_profile->set_test_installation(true);

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('pts-core.php');2$updater = new pts_test_suite_updater();3$updater->auto_update_test_suite();4require_once('pts-core.php');5$updater = new pts_test_suite_updater();6$updater->auto_update_test_suite();7require_once('pts-core.php');8$updater = new pts_test_suite_updater();9$updater->auto_update_test_suite();10require_once('pts-core.php');11$updater = new pts_test_suite_updater();12$updater->auto_update_test_suite();13require_once('pts-core.php');14$updater = new pts_test_suite_updater();15$updater->auto_update_test_suite();16require_once('pts-core.php');17$updater = new pts_test_suite_updater();18$updater->auto_update_test_suite();19require_once('pts-core.php');20$updater = new pts_test_suite_updater();21$updater->auto_update_test_suite();22require_once('pts-core.php');23$updater = new pts_test_suite_updater();24$updater->auto_update_test_suite();25require_once('pts-core.php');

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');2$updater = new pts_updater();3$updater->auto_update_self();4Fatal error: Call to undefined function pts_updater() in /var/www/2.php on line 45Fatal error: Call to undefined function pts_updater() in /var/www/2.php on line 46Fatal error: Call to undefined function pts_updater() in /var/www/2.php on line 4

Full Screen

Full Screen

update_checker

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$test = new pts_test_profile('phpbench');3$test->download_test_profile();4$test->install_dependencies();5$test->install_test_files();6$test->save_to_xml();7require_once('pts-core/pts-core.php');8$test = new pts_test_profile('phpbench');9$test->download_test_profile();10$test->install_dependencies();11$test->install_test_files();12$test->save_to_xml();13require_once('pts-core/pts-core.php');14$test = new pts_test_profile('phpbench');15$test->download_test_profile();16$test->install_dependencies();17$test->install_test_files();18$test->save_to_xml();19require_once('pts-core/pts-core.php');20$test = new pts_test_profile('phpbench');21$test->download_test_profile();22$test->install_dependencies();23$test->install_test_files();24$test->save_to_xml();25require_once('pts-core/pts-core.php');26$test = new pts_test_profile('phpbench');27$test->download_test_profile();28$test->install_dependencies();29$test->install_test_files();30$test->save_to_xml();31require_once('pts-core/pts-core.php');32$test = new pts_test_profile('phpbench');33$test->download_test_profile();34$test->install_dependencies();35$test->install_test_files();36$test->save_to_xml();37require_once('pts-core/pts-core.php');38$test = new pts_test_profile('phpbench');39$test->download_test_profile();40$test->install_dependencies();41$test->install_test_files();42$test->save_to_xml();43require_once('pts-core/pts-core.php');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in update_checker

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful