mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore.git
synced 2026-04-20 17:25:46 +08:00
65 lines
2.7 KiB
Bash
Executable file
65 lines
2.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Load configuration
|
|
root_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; root_path=${root_path%app*}
|
|
source ${root_path}lib/arguments
|
|
|
|
# Generate local WordPress site to store site info
|
|
cd $root_path
|
|
mkdir data
|
|
cd data
|
|
wp core download
|
|
wp config create --dbname=captaincore_cli --dbuser=root --dbpass=$local_wp_db_pw
|
|
wp db create
|
|
wp core install --url=https://captaincore_cli.test --admin_user=captaincore_cli --admin_email=support@captaincore.io --title="CaptainCore CLI"
|
|
wp option update timezone_string America/New_York
|
|
wp option update blog_public 0
|
|
wp scaffold _s captaincore-cli --theme_name="CaptainCore CLI" --author="CaptainCore" --author_uri=https://captaincore.io --activate
|
|
wp scaffold post-type captcore_website --label=Website --textdomain=captaincore --theme=captaincore-cli
|
|
echo "require get_template_directory() . '/post-types/captcore_website.php';" >> wp-content/themes/captaincore-cli/functions.php
|
|
|
|
# Append custom search filter
|
|
cat << "EOF" >> wp-content/themes/captaincore-cli/functions.php
|
|
|
|
// Append custom search filter when using `meta_or_title` in query. Credit to https://wordpress.stackexchange.com/questions/78649/using-meta-query-meta-query-with-a-search-query-s
|
|
add_action( 'pre_get_posts', function( $q ) {
|
|
if ( $title = $q->get( 'meta_or_title' ) ) {
|
|
add_filter( 'get_meta_sql', function( $sql ) use ( $title ) {
|
|
global $wpdb;
|
|
|
|
// Only run once:
|
|
static $nr = 0;
|
|
if ( 0 != $nr++ ) {
|
|
return $sql;
|
|
}
|
|
|
|
// Modified WHERE
|
|
$sql['where'] = sprintf(
|
|
' AND ( %s OR %s ) ',
|
|
$wpdb->prepare( "{$wpdb->posts}.post_title like '%%%s%%'", $title ),
|
|
mb_substr( $sql['where'], 5, mb_strlen( $sql['where'] ) )
|
|
);
|
|
|
|
return $sql;
|
|
});
|
|
}
|
|
});
|
|
|
|
EOF
|
|
wp plugin install wp-force-login --activate
|
|
wp plugin delete hello-dolly
|
|
git clone git@github.com:CaptainCore/captaincore.git wp-content/plugins/captaincore
|
|
cd wp-content/plugins/captaincore
|
|
git submodule update --init
|
|
wp plugin activate captaincore
|
|
|
|
## DB import
|
|
#captaincore ssh <site> --command="wp db export --skip-plugins --skip-themes --add-drop-table - > wp-content/mysql.sql"
|
|
#captaincore download <site> wp-content/mysql.sql
|
|
#
|
|
#wp db import mysql.sql
|
|
#
|
|
### House cleaning notes. Sync db from CaptainCore Server then purge the following
|
|
#wp post delete $(wp post list --post_type='captcore_contact,captcore_domain,captcore_changelog,captcore_process,captcore_processlog,captcore_server,captcore_snapshot,captcore_quicksave,page,shop_order,product_variation,product,shop_order_refund,bnfw_notification,amn_smtp,testimonialacf,acf-field,acf-field-group,amn_mi-lite,attachment,log_emails_log,shop_subscription,tribe_events,wysijap' --format=ids) --force
|
|
#wp db query 'DELETE FROM wp_postmeta WHERE meta_key LIKE "\_%";'
|
|
#wp db size --size_format=mb
|