diff --git a/README.md b/README.md index bf33b80..603a003 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,12 @@ Delete all Advanced Custom Fields Records from the database. Do this after you have edited fields-groups from the UI and exported the changes. **Warning: This can not be undone, please use carefully** +### DB update +``` +wp acf update_db +``` +Runs the ACF database update procedure (Required for major updates). + ## Filters @@ -158,6 +164,8 @@ If you need a different test you can create your own by added it to the features ## Changelog +### 3.0.1 +* Add a new command for run the ACF database update procedure ### 3.0 * Bugfix: Import no longer created duplicates diff --git a/advanced-custom-fields-wpcli.php b/advanced-custom-fields-wpcli.php index 608ca19..f0c8d91 100644 --- a/advanced-custom-fields-wpcli.php +++ b/advanced-custom-fields-wpcli.php @@ -2,8 +2,8 @@ /* Plugin Name: Advanced Custom Fields WP-CLI Plugin URI: https://github.com/hoppinger/advanced-custom-fields-wpcli -Description: Manage your ACF field groups in WP-CLI -Version: 3.0.0 +Description: Manage Advanced Custom Fields through WP-CLI +Version: 3.0.1 Author: Hoppinger Author URI: http://www.hoppinger.com/ License: MIT diff --git a/lib/acfwpcli/cli.php b/lib/acfwpcli/cli.php index e7e449d..ffd0857 100644 --- a/lib/acfwpcli/cli.php +++ b/lib/acfwpcli/cli.php @@ -32,7 +32,7 @@ function __construct() { static function help() { WP_CLI::line( 'Welcome to Advanced Custom Fields WPCLI' ); - WP_CLI::line( 'possible subcommands: status, export, import, clean' ); + WP_CLI::line( 'possible subcommands: status, export, import, clean, update_db' ); } /** @@ -120,6 +120,38 @@ function clean( $args, $assoc_args ) { } } + /** + * Runs the ACF database update procedure. + * + * @subcommand update_db + */ + function update_db( $args, $assoc_args ) { + acf_include('includes/admin/install.php'); + + if ( !function_exists('acf_get_db_updates') ) { + WP_CLI::error( "Your version of ACF seems too old." ); + } + + $updates = acf_get_db_updates(); + $message = ''; + + // bail early if no updates + if( empty($updates) ) { + WP_CLI::warning( 'No updates available.' ); + return; + } + + // install updates + foreach( $updates as $version => $callback ) { + $message .= acf()->admin->install->run_update( $callback ); + } + + // updates complete + acf_update_db_version(); + + WP_CLI::success( "The ACF database has been updated, here is the detail: " . $message ); + } + /** * Import ACF field groups from local files to database * diff --git a/readme.txt b/readme.txt index df1c5d9..397c36a 100644 --- a/readme.txt +++ b/readme.txt @@ -2,11 +2,12 @@ Contributors: sebastiaandegeus, marceldillen Tags: WP-CLI, Advanced, Custom Fields, acf Requires at least: 4.5 -Stable tag: 3.0 -Tested up to: 4.6.1 +Stable tag: 3.0.1 +Tested up to: 4.9.4 License: MIT Manage Advanced Custom Fields through WP-CLI + === WP-CLI for Advanced Custom Fields === = Description = @@ -14,6 +15,7 @@ Manage Advanced Custom Fields through WP-CLI WP-CLI for Advanced Custom Fields helps you manage your field-groups through WP-CLI. The reason we started this project is to make life easier for developers working on Wordpress projects using the Advanced Custom Fields Pro plugin. Fields can now easily be imported, exported and shared over SVN, GIT or comparable systems. + == Installation == = Requirements = @@ -105,6 +107,13 @@ wp acf clean Delete all Advanced Custom Fields Records from the database. Do this after you have edited fields-groups from the UI and exported the changes. **Warning: This can not be undone, please use carefully** + += DB update = +``` +wp acf update_db +``` +Runs the ACF database update procedure (Required for major updates). + == Upgrade Notice == = 3.0 = diff --git a/readme/changelog.txt b/readme/changelog.txt index 19a9e3e..d1afa86 100644 --- a/readme/changelog.txt +++ b/readme/changelog.txt @@ -1,5 +1,8 @@ == Changelog == += 3.0.1 = +* Add a new command for run the ACF database update procedure + = 3.0 = * Bugfix: Import no longer created duplicates * Add unit testing with behat and PHPUnit diff --git a/readme/command.txt b/readme/command.txt index 3a21c3d..24183ed 100644 --- a/readme/command.txt +++ b/readme/command.txt @@ -34,3 +34,9 @@ wp acf clean Delete all Advanced Custom Fields Records from the database. Do this after you have edited fields-groups from the UI and exported the changes. **Warning: This can not be undone, please use carefully** + += DB update = +``` +wp acf update_db +``` +Runs the ACF database update procedure (Required for major updates).