Ryan Kanner (@CodeProKid)
Hi Ryan,
Todd from marketing left the company today, and he's after our clients!!! Can we please disable his login for all of our sites?
From: boss@company.com
Subject: 911 Disable Todd's Login!
# wp-cli.yml
@site1:
path: testsite1.dev
@site2:
path: testsite2.dev
@site3:
ssh: rkanner@testsite3.dev
user: rkanner
path: ../../var/www/html/testsite3.dev
@site4:
ssh: rkanner@testsite4.dev
user: rkanner
path: ../../var/www/html/testsite4.dev
Hi Ryan,
We are ready to get started with development for XYZ company, could you get all of the environments for them created?
From: pm@company.com
Subject: Environment Creation
echo "Starting WordPress Installation"
# Download Core
wp core download
# Create wp-config
wp core config --dbname=$1
# Create the database
wp db create
# Run the installer
wp core install --url=$2 --title="My sweet WP Site"
# Create a user for yourself
wp user create test test@test.com --role=administrator
# Set the site admin to a contributor
wp user set-role 1 contributor
echo "Opening Admin"
open http://$2/wp-admin
# wp-cli.yml
core config:
dbuser: root
dbpass: password
dbhost: localhost
core install:
admin_email: dummy@mydumbsite.com
admin_user: defsnotadmin
Hi Ryan,
We haven't gotten any new invoices into our system in the last 2 hours. Can you check to see if the cron job is stuck again?
From: client@company.com
Subject: Cron Job Stuck
# Regenerate all thumbnails
wp media regenerate
# Delete expired transients
wp transient delete --expired
# Delete all transients
wp transient delete --all
# List of scheduled cron events
wp cron event list
# Run all cron events in queue
wp cron event run --due-now
# Flush rewrite rules
wp rewrite flush
# List of rewrites
wp rewrite list --format=csv
# Flush the cache
wp cache flush
Hi Ryan,
I have attached a spreadsheet of a few tags we would like to import into our site before launch. If you could have these imported by the end of the day, that would be great.
From: client@company.com
Subject: Tag list attached
$tag_importer = function( $args ) {
$tags = new \WP_CLI\Iterators\CSV( $args[0] );
foreach ( $tags as $tag ) {
wp_insert_term( $tag['level_1'], 'post_tag' );
WP_CLI::success(
sprintf( 'Added new tag: %s', $tag['level_1'] )
);
}
};
WP_CLI::add_command( 'import-tags', $tag_importer );
Hi Ryan,
I was making a couple of small edits in the backend of our site today, and I think I got a little carried away. It no longer looks like the live site at all. Can you reset it for me today? Thanks.
From: client@company.com
Subject: Staging site messed up!!!!!!!!!!!!!!!
#/bin/bash
# Figure out what needs to be search & replaced
PROD_URL="$(wp @prod option get home)"
STAGE_URL="$(wp @stage option get home)"
echo "Exporting production database"
wp @prod search-replace $PROD_URL $STAGE_URL --export=db.sql
echo "Importing prod database to staging"
wp @stage db import db.sql
# Replace some production only data
echo "Clearing production API keys"
wp @stage option update prod_api_key xxxxxxx
# wp-cli.local.yml
@prod:
ssh: ubuntu@mysite.com:2222
user: ubuntu
path: ../var/www/html/mysite.com
@stage:
ssh: ubuntu@stage.mysite.com:2222
user: ubuntu
path: ../var/www/html/stage.mysite.com
We would like to add a new "Books" post type to the site to display our book collection. We would also like a few taxonomies to filter the books by: Year Published, Genre, Author, and Publisher.
Task: Add Books post type and 3 new Taxonomies
Due Date: EOD Tomorrow
## Scaffold a new theme based off of _s
wp scaffold _s my-sweet-theme --theme_name="My Sweet Theme"
## Scaffold a new plugin
wp scaffold plugin my-sweet-plugin --plugin_name="My Sweet Plugin"
## Scaffold a new Gutenblock
wp scaffold block my-sweet-block --title="My Sweet Block" --theme
## Scaffold test framework for an existing plugin
wp scaffold plugin-tests plugin-without-tests
wp comment delete $(wp comment list --status=spam --format=ids) --force
Success: Deleted comment 11.
Success: Deleted comment 10.
Success: Deleted comment 9.
Success: Deleted comment 8.
Success: Deleted comment 7.
wp user create codeprokid test@test.com --role=administrator --user_pass=pass
Success: Created user 2.
wp post generate --count=100 --post_type=resource
Generating posts 100% [=============================] 0:01 / 0:04
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_DEBUG_DISPLAY true --raw
wp config set SCRIPT_DEBUG true --raw
wp config set SAVEQUERIES true --raw
Success: Added the constant 'WP_DEBUG' to the 'wp-config.php' file with the raw value 'true'.
wp user reset-password $(wp user list --format=ids)
Reset password for user1.
Reset password for user2.
Reset password for user3.
Reset password for user4.
wp term recount $(wp taxonomy list --field=name)
Success: Updated category term count.
Success: Updated post_tag term count.
Success: Updated nav_menu term count.
Success: Updated link_category term count.
Success: Updated post_format term count.
Ryan Kanner (@CodeProKid)