Skip to content

Instantly share code, notes, and snippets.

@westonruter
Created November 9, 2017 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/a38db7bd13a8d58695a66453570338de to your computer and use it in GitHub Desktop.
Save westonruter/a38db7bd13a8d58695a66453570338de to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
set -x
wp db export /tmp/$(date "+%Y%m%dT%H%M%S").sql
wp db reset --yes
wp core install --url=http://src.wordpress-develop.dev/ --title="WordPress Develop" --admin_user=admin --admin_password=admin --admin_email=weston@xwp.co --skip-email
wp cache flush
wp --user=1 eval '
require_once( ABSPATH . "/wp-includes/class-wp-customize-manager.php" );
global $wp_customize;
$wp_customize = new WP_Customize_Manager();
do_action( 'customize_register', $wp_customize );
$wp_customize->import_theme_starter_content();
$wp_customize->set_post_value( "blogname", "Test Customization Drafts" );
$r = $wp_customize->save_changeset_post( array( "status" => "publish" ) );
if ( is_wp_error( $r ) ) {
WP_CLI::error( $r->get_error_message() );
}
WP_CLI::success( "Starter content published." );
'
changeset_post_id=$(wp --user=1 eval '
require_once( ABSPATH . "/wp-includes/class-wp-customize-manager.php" );
global $wp_customize;
$wp_customize = new WP_Customize_Manager();
do_action( 'customize_register', $wp_customize );
$autodraft = $wp_customize->nav_menus->insert_auto_draft_post( array(
"post_title" => "Former Customization Draft",
"post_name" => "former-customization-draft",
"post_type" => "page",
) );
$wp_customize->set_post_value( "nav_menus_created_posts", array( $autodraft->ID ) );
$wp_customize->set_post_value( "blogname", "Test Customization Drafts Published" );
$r = $wp_customize->save_changeset_post( array(
"status" => "draft",
) );
if ( is_wp_error( $r ) ) {
WP_CLI::error( $r->get_error_message() );
}
fwrite( STDERR, "Scheduled post." );
echo $wp_customize->changeset_post_id();
')
echo ""
echo ""
echo ""
echo ""
echo "# PUBLISHING CHANGESET"
wp eval "wp_publish_post( $changeset_post_id );"
#wp cron event list
wp post list --post_type=customize_changeset,any --post_status=any,auto-draft,trash
echo "Success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment