Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/feedback readme #68

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor/
/features/bootstrap/test_exports/
/wordpress/
readme.txt
readme.txt
65 changes: 28 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
# WP-CLI for Advanced Custom Fields
# WP-CLI for Advanced Custom Fields


### Description
## 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
## Installation


### Requirements
### Requirements

* Advanced Custom Fields 5 Pro plugin
* `wp-cli` http://wp-cli.org/
* wp-cli http://wp-cli.org/


### How to install
### How to install

Install WP-CLI as described on [http://wp-cli.org/](http://wp-cli.org/ "WP-CLI")
Install WP-CLI as described on [their website](http://wp-cli.org/ "WP-CLI")

Using composer:
```
composer require wpackagist-plugin/advanced-custom-fields-wpcli
```

By GIT clone in plugins directory:
Clone this repo to your plugins directory
```
git clone https://github.com/hoppinger/advanced-custom-fields-wpcli.git
```

WordPress plugin installation:
Download zip and put the files in the plugins directory.

* Activate this plugin in the plugin menu or using:
* Activate this plugin in the plugin menu or by using:
```
wp plugin activate advanced-custom-fields-wpcli
```

Go the wordpress directory in your terminal and run:
Go the wordpress directory in your terminal and try out to:
```
wp acf
```
Expand All @@ -50,65 +41,65 @@ If you would like to disable this behaviour you can remove the `acf_wpcli_regist
remove_action('plugins_loaded', 'acf_wpcli_register_groups');
```

## Commands
## Commands

This project adds the `acf` command to `wp-cli` with the following subcommands:


### Help
### Help
```
wp acf
```
Prints the help overview and can be used as a default test to see if the plugin is working.



### Export

Export a field-group to a json file in the directory set by a filter.
### Export
```
wp acf export
```
Export a field-group to a json file in the directory set by a filter. You want to export all field-groups all at once you can use:

You want to export all field-groups all at once you can use:
If you want to export all field-groups all at once you can use:
```
wp acf export --all
```


### Import
### Import
```
wp acf import
```
Import all or specific fields from a option menu,


### Clean
### Clean
```
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**

## Filters
## Filters


### acfwpcli_fieldgroup_paths
### acfwpcli_fieldgroup_paths

The acfwpcli_fieldgroup_paths gives you the ability to add more paths where ACF-CLI should load/export from/to.
You should always add at least one path to this filter.


**Example:**
```
add_filter( 'acfwpcli_fieldgroup_paths', 'add_plugin_path' );

public function add_plugin_path( $paths ) {
$paths['my_plugin'] = MY_PLUGIN_ROOT . '/lib/field-groups/';
return $paths;
}
````
```

## Unit testing
## Unit testing

To test changes to the plugin you can use unit testing. Start by making sure all the necessary dependencies are installed, if not run:
```
Expand Down Expand Up @@ -137,26 +128,26 @@ vendor/bin/behat features/testname.feature

If you need a different test you can create your own by added it to the features in the features folder.

## Upgrade Notice
## Upgrade Notice


### 3.0
### 3.0
* Make sure you import all your custom fields before updating.
* Make sure you are you using ACF5, ACF4 is not supported.
* Update the plugin
* Add the filter to your project (See Filters)
* Export you fields
* Remove unnecessary files like your old import directory, php files and json files.

## Changelog
## Changelog


### 3.0
### 3.0
* Bugfix: Import no longer created duplicates
* Add unit testing with behat and PHPUnit


### 2.0
### 2.0
* Removed uniqid feature (no longer needed).
* Bugfix: database fieldgroups are now prefered over exported fieldgroups.
* Cleaned up legacy xml import/export libraries.
Expand Down
20 changes: 19 additions & 1 deletion bin/generate_readme.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php
require_once('vendor/wpreadme2markdown/wpreadme2markdown/src/Converter.php');

$wp_readme_parts = array('pluginInformation', 'description', 'installation', 'filters', 'command', 'upgradeNotice');
$wp_readme_parts = array(
'pluginInformation',
'description',
'installation',
'filters',
'command',
'upgradeNotice',
'changelog'
);

$github_readme_parts = array(
'description',
Expand All @@ -16,9 +24,18 @@
$wordpress_readme = combine_parts($wp_readme_parts);
$github_readme = txt_to_md(combine_parts($github_readme_parts));

$github_readme = replace_codeblocks($github_readme);

create_readme("readme.txt", $wordpress_readme);
create_readme("readme.md", $github_readme);

function replace_codeblocks($readme) {
$readme = str_replace('<pre><code>', '```', $readme);
$readme = str_replace('</code></pre>', '```', $readme);

return $readme;
}

function combine_parts($parts) {
$output = '';

Expand All @@ -35,4 +52,5 @@ function txt_to_md($readme) {

function create_readme($filename, $content) {
file_put_contents ( $filename , $content );
echo "{$filename} created! \n";
}
116 changes: 0 additions & 116 deletions readme.txt

This file was deleted.

26 changes: 12 additions & 14 deletions readme/command.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@
This project adds the `acf` command to `wp-cli` with the following subcommands:

= Help =
```
<pre><code>
wp acf
```
</code></pre>
Prints the help overview and can be used as a default test to see if the plugin is working.


= Export =

Export a field-group to a json file in the directory set by a filter.
```
<pre><code>
wp acf export
```
</code></pre>
Export a field-group to a json file in the directory set by a filter. You want to export all field-groups all at once you can use:

You want to export all field-groups all at once you can use:
```
If you want to export all field-groups all at once you can use:
<pre><code>
wp acf export --all
```
</code></pre>

= Import =
```
<pre><code>
wp acf import
```
</code></pre>
Import all or specific fields from a option menu,

= Clean =
```
<pre><code>
wp acf clean
```
</code></pre>
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**
2 changes: 1 addition & 1 deletion readme/description.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=== WP-CLI for Advanced Custom Fields ===

= Description =
== 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.
Expand Down
Loading