generated from 10up/plugin-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store language in metadata (#316)
* feat: add language meta field * feat: show language meta in admin columns * chore(docs): add readme for convert-language
- Loading branch information
Ned Zimmerman
authored
Mar 11, 2020
1 parent
0eebd9f
commit ab499a8
Showing
5 changed files
with
247 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
# Convert Metadata from Custom Metaboxes 2 to Advanced Custom Fields | ||
# Conversion Scripts | ||
|
||
## Convert Metadata from Custom Metaboxes 2 to Advanced Custom Fields | ||
|
||
To convert your resource library's metadata from Custom Metaboxes 2 to Advanced Custom Fields, run the following command from the WordPress root using [wp-cli](https://wp-cli.org): | ||
|
||
```bash | ||
wp eval-file wp-content/plugins/coop-library-framework/bin/convert-meta.php` | ||
wp eval-file wp-content/plugins/coop-library-framework/bin/convert-meta.php | ||
``` | ||
|
||
In order to see the updated metadata on the resource library front-end, you'll need to update to the [1.0.0-alpha.2](https://github.com/platform-coop-toolkit/coop-library/milestones/1.0.0-alpha.2) version of the Co-op Library theme. | ||
|
||
## Convert Resource Language from Polylang to Advanced Custom Fields | ||
|
||
To convert your resources' language from a Polylang language to a metadata field managed through Advanced Custom Fields, run the following command from the WordPress root using [wp-cli](https://wp-cli.org): | ||
|
||
```bash | ||
wp eval-file wp-content/plugins/coop-library-framework/bin/convert-language.php | ||
``` | ||
|
||
In order to see the updated language on the resource library front-end, you'll need to update to the [1.0.0-alpha.2](https://github.com/platform-coop-toolkit/coop-library/milestones/1.0.0-alpha.2) version of the Co-op Library theme. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* Convert languages from Polylang taxonomy to new (1.0.0-alpha.3) format. | ||
* | ||
* @package CoopLibraryFramework | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
$resources = get_posts( | ||
[ | ||
'fields' => 'ids', | ||
'posts_per_page' => -1, | ||
'post_type' => 'lc_resource', | ||
'post_status' => 'all', | ||
'lang' => '', | ||
] | ||
); | ||
|
||
foreach ( $resources as $post_id ) { | ||
update_post_meta( $post_id, 'language', pll_get_post_language( $post_id ) ); | ||
update_post_meta( $post_id, '_language', 'field_5e62c939ddcb6' ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.