-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from grueneschweiz/dev
0.17.0
- Loading branch information
Showing
36 changed files
with
6,601 additions
and
5,409 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
mkdir export | ||
|
||
urls=( $(wp site list --field=url) ) | ||
domains=( $( wp site list --field=domain ) ) | ||
paths=( $( wp site list --field=path | sed 's/\///g' ) ) | ||
post_types="post page attachment" | ||
|
||
for i in "${!domains[@]}" | ||
do | ||
site="${domains[$i]}_${paths[$i]}" | ||
url="${urls[i]}" | ||
for type in ${post_types[*]} | ||
do | ||
wp --url="$url" export --post_type="$type" --dir="./export" --filename_format="${site}.${type}.xml" | ||
done | ||
done | ||
|
||
echo "SUCCESS: exported all ${post_types[*]} into ./export" |
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,110 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
usage() | ||
{ | ||
echo "This command will import posts, pages and attachments of the given sites (site_slugs)." | ||
echo "" | ||
echo "Usage: import [ -h ] network_url site_slugs..." | ||
echo " -h This screen" | ||
echo " network_url The base url of the WPMU network. With trailing slash!" | ||
echo " site_slugs The slugs of the site where the content should be imported" | ||
echo "" | ||
echo "The files with the content to import must be placed in ./import and stick to the" | ||
echo 'following naming convention: ${site_slug}.${post_type}.xml' | ||
echo "Example: ./import/lausanne.attachment.xml" | ||
echo "" | ||
echo "The command must be executed from the WordPress' base directory." | ||
exit 2 | ||
} | ||
|
||
import_attachments() { | ||
local file="$1" # wxr import file | ||
local url="$2" # site url (multisite) | ||
|
||
for i in {1..10} | ||
do | ||
echo "importing attachments. attempt $i" | ||
if wp --url="$url" import --authors=skip "$file"; then | ||
echo "SUCCESS: imported all attachments" | ||
i=0 | ||
break | ||
fi | ||
done | ||
|
||
if [ $i -ge 10 ]; then | ||
echo "ERROR importing attachments" | ||
exit 1 | ||
fi | ||
} | ||
|
||
import_post_type() { | ||
local post_type="$1" | ||
local file="$2" # wxr import file | ||
local url="$3" # site url (multisite) | ||
|
||
if [ ! -f "$file" ]; then | ||
echo "ERROR: Import file could not be found. Looking for: $file" | ||
echo "Call $0 -h for more information" | ||
exit 1 | ||
fi | ||
|
||
if [[ $post_type == "attachment" ]]; then | ||
import_attachments "$file" "$url" | ||
else | ||
wp --url="$url" import --authors=skip "$file" | ||
fi | ||
} | ||
|
||
|
||
migrate_post_content() { | ||
local url="$1" | ||
if wp --url="$url" eval-file "wp-content/themes/les-verts/lib/admin/import-handler.php"; then | ||
echo "Migration completed" | ||
else | ||
echo "ERROR migrating content." | ||
exit 1 | ||
fi | ||
} | ||
|
||
|
||
while getopts 'h' opt | ||
do | ||
case "$opt" in | ||
"h") usage; exit 1 ;; | ||
*) usage; exit 1 ;; | ||
esac | ||
done | ||
|
||
if [ -z "$1" ] || [ -z "$2" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
base_url="$1" | ||
shift 1 | ||
sites=( "$@" ) | ||
|
||
post_types=(post page attachment) | ||
|
||
for site in ${sites[*]} | ||
do | ||
echo | ||
echo "Start importing $site..." | ||
|
||
url="${base_url}${site}" | ||
|
||
for post_type in ${post_types[*]} | ||
do | ||
file="./import/${site}.${post_type}.xml" | ||
echo "Importing $post_type for $site from $file..." | ||
import_post_type "$post_type" "$file" "$url" | ||
done | ||
|
||
echo "Migrating post content..." | ||
migrate_post_content "$url" | ||
done | ||
|
||
echo "SUCCESS. All done. Don't forget to remove the import files!" | ||
|
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
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
43 changes: 43 additions & 0 deletions
43
wordpress/wp-content/themes/les-verts/acf-json/group_5fa587aac61ec.json
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,43 @@ | ||
{ | ||
"key": "group_5fa587aac61ec", | ||
"title": "(Category) Author", | ||
"fields": [ | ||
{ | ||
"key": "field_5fa587ab352a8", | ||
"label": "Show author", | ||
"name": "has_author", | ||
"type": "true_false", | ||
"instructions": "Show the author for all posts of this category?", | ||
"required": 0, | ||
"conditional_logic": 0, | ||
"wrapper": { | ||
"width": "", | ||
"class": "", | ||
"id": "" | ||
}, | ||
"message": "", | ||
"default_value": 0, | ||
"ui": 1, | ||
"ui_on_text": "", | ||
"ui_off_text": "" | ||
} | ||
], | ||
"location": [ | ||
[ | ||
{ | ||
"param": "taxonomy", | ||
"operator": "==", | ||
"value": "category" | ||
} | ||
] | ||
], | ||
"menu_order": 0, | ||
"position": "normal", | ||
"style": "default", | ||
"label_placement": "top", | ||
"instruction_placement": "label", | ||
"hide_on_screen": "", | ||
"active": true, | ||
"description": "", | ||
"modified": 1604683888 | ||
} |
Oops, something went wrong.