-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-wp-core
executable file
·112 lines (81 loc) · 3.21 KB
/
get-wp-core
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
SCRIPT_DIR="$(cd "${0%/*}"; pwd)"
source "$SCRIPT_DIR/config" || exit 1
CACHE=/tmp
WP_VERSION='4.7.3'
WP_LANGUAGES=(de_DE de_DE_formal)
WP_VERSION_MAJOR_MINOR=${WP_VERSION%%.*}.$(minor=${WP_VERSION#*.} && printf ${minor%%.*})
download_and_check() {
url="${1}"
name="${url##*/}"
path="$CACHE/$name"
if [ ! -f "$path" ]; then
echo "Downloading ${name}"
curl --progress-bar --location "$url" -o "$path" || exit 1
else
echo "Already downloaded: $path"
fi
echo "Extracting $name"
unzip -q -o "$path" -d "$CACHE" || exit 1
}
rm -rf "$CACHE/wordpress" || exit 1
# WordPress Core
for WP_LANGUAGE in ${WP_LANGUAGES[*]}; do
download_and_check "https://de.wordpress.org/wordpress-$WP_VERSION-$WP_LANGUAGE.zip"
done
# Plugins
if ! hash msgfmt &>/dev/null; then
brew install gettext || exit 1
export PATH="$(brew --prefix)/opt/gettext/bin:$PATH"
fi
for plugin in \
language-fallback@1.0.3 \
mailgun@1.5.8.2 \
redirection@2.5 \
regenerate-thumbnails@2.2.6 \
underconstruction@1.18 \
woocommerce@2.6.14 \
wp-optimize@2.1.1
do
plugin_version="${plugin##*@}"
plugin_version_major_minor="${plugin_version%%.*}.$(minor="${plugin_version#*.}" && echo "${minor%%.*}")"
plugin="${plugin%@*}"
download_and_check "https://downloads.wordpress.org/plugin/$plugin.$plugin_version.zip"
for WP_LANGUAGE in ${WP_LANGUAGES[*]}; do
for version in "${plugin_version_major_minor}" "${plugin_version}"; do
file="$CACHE/wordpress/wp-content/languages/plugins/$plugin-$WP_LANGUAGE"
url="https://i18n.trac.wordpress.org/export/latest/plugins/$plugin/$version/$WP_LANGUAGE/${file##*/}.po"
if curl --silent "$url" --head --fail --output /dev/null; then
echo "Downloading '$WP_LANGUAGE' translation for $plugin"
curl --progress-bar --location "$url" -o "$file.po" || exit 1
msgfmt "$file.po" -o "$file.mo" || exit 1
fi
done
language="${WP_LANGUAGE%%_*}"
lang_version='default'
if [[ $WP_LANGUAGE == *"formal" ]]; then
lang_version='formal'
fi
url="https://translate.wordpress.org/projects/wp-plugins/$plugin/dev/$language/$lang_version/export-translations?filters%5Bstatus%5D=current_or_waiting_or_fuzzy_or_untranslated&format=mo"
file="$CACHE/wordpress/wp-content/languages/plugins/$plugin-$WP_LANGUAGE"
if curl --silent "$url" --head --fail --output /dev/null; then
echo "Downloading '$WP_LANGUAGE' translation for $plugin"
curl --progress-bar --location "$url" -o "$file.mo" || exit 1
fi
done
rsync --archive "$CACHE/$plugin/" "$CACHE/wordpress/wp-content/plugins/$plugin" \
--exclude '/license.txt' \
--exclude '/readme.txt' || exit 1
done
rsync --delete-excluded --archive "$CACHE/wordpress/" "$WP_CORE_DIR" \
--exclude 'license.txt' \
--exclude 'liesmich.html' \
--exclude 'readme.html' \
--exclude 'wp-config-sample.php' \
--exclude 'wp-content/plugins/hello.php' \
--exclude 'wp-content/plugins/akismet' \
--exclude 'wp-content/languages/plugins/akismet*' \
--exclude 'wp-content/themes/twenty*' \
--exclude 'wp-content/languages/themes/twenty*' \
--exclude 'wp-content/plugins/wp-optimize/index.htm' \
--exclude 'wp-content/plugins/redirection/locale/redirection-de_DE.*' || exit 1