PHP code example of awesome9 / updates

1. Go to this page and download the library: Download awesome9/updates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

awesome9 / updates example snippets


use Awesome9\Updates\Updates;

class MyPluginUpdates extends Updates {

    /**
     * Define update versions and file paths.
     *
     * @return array<string, string>
     */
    public function get_updates(): array {
        return [
            '1.0.1' => 'updates/update-1.0.1.php',
            '1.0.2' => 'updates/update-1.0.2.php',
        ];
    }

    /**
     * Specify the updates folder path.
     *
     * @return string
     */
    public function get_folder(): string {
        return plugin_dir_path( __FILE__ ) . 'updates/';
    }

    /**
     * Get the current plugin version.
     *
     * @return string
     */
    public function get_version(): string {
        return '1.0.2'; // Replace with your plugin's current version
    }

    /**
     * Define the database option name for storing the plugin version.
     *
     * @return string
     */
    public function get_option_name(): string {
        return 'awesome9_plugin_version';
    }
}

$my_plugin_updates = new MyPluginUpdates();
$my_plugin_updates->hooks();


/**
 * Update routine for version 1.0.1
 *
 * @since 1.0.1
 */

/**
 * Example update function to remove obsolete roles.
 *
 * @since 1.0.1
 * @return void
 */
function awesome9_update_1_0_1_remove_roles() {
	remove_role( 'awesome9_manager' );
	remove_role( 'awesome9_employee' );
}

awesome9_update_1_0_1_remove_roles();

my-plugin/
└── updates/
   ├── update-1.1.0.php
   └── update-1.1.1.php