-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathplugin-update-checker.sample
34 lines (28 loc) · 1.27 KB
/
plugin-update-checker.sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
Plu gin Name: My Plugin
Plu gin URI: https://example.com/my-plugin
Des cription: This is my awesome plugin!
Ver sion: 1.0
Aut hor: My Name
Aut hor URI: https://example.com/
Lic ense: GPL2
*/
// Include the Plugin Update Checker library
require_once( 'plugin-update-checker/plugin-update-checker.php' );
// Set the update checker URL to your GitHub repository's releases page
$my_plugin_update_checker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/yourusername/yourpluginname/releases',
__FILE__,
'my-plugin'
);
// Optional: Set the update checker parameters
$my_plugin_update_checker->setBranch('stable'); // Set the branch (stable, beta, dev)
$my_plugin_update_checker->setAuthentication('username', 'password'); // Set basic authentication credentials
// Optional: Enable debug mode to see update checker debug information
// $my_plugin_update_checker->debugMode(true);
// Schedule the update checker to run daily
add_action( 'wp_ajax_my_plugin_check_for_updates', array( $my_plugin_update_checker, 'checkForUpdates' ) );
add_action( 'wp_ajax_nopriv_my_plugin_check_for_updates', array( $my_plugin_update_checker, 'checkForUpdates' ) );
if ( ! wp_next_scheduled( 'my_plugin_check_for_updates' ) ) {
wp_schedule_event( time(), 'daily', 'my_plugin_check_for_updates' );
}