Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions advanced-custom-fields-wpcli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 33 additions & 1 deletion lib/acfwpcli/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

/**
Expand Down Expand Up @@ -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
*
Expand Down
13 changes: 11 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
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 =

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 =
Expand Down Expand Up @@ -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 =
Expand Down
3 changes: 3 additions & 0 deletions readme/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions readme/command.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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).