Skip to content
View gist:0c4aeaec7d730b248dd6
# generating a list of 50 post permalinks
for pid in $(wp post list --field=ID --posts_per_page=50); do wp eval "echo get_the_permalink( $pid ).\"\n\"; "; done > url.txt
# posts and pages
for pid in $(wp post list --field=ID --posts_per_page=50 --post_type=post,page); do wp eval "echo get_the_permalink( $pid ).\"\n\"; "; done > url.txt
# random sample
for pid in $(wp post list --field=ID --posts_per_page=50 --post_type=post,page --orderby=rand); do wp eval "echo get_the_permalink( $pid ).\"\n\"; "; done > url.txt
View fix-failed-checksums.sh
#!/bin/bash
vers=$(wp core version)
for f in $(wp core verify-checksums --no-color 2>&1 >/dev/null | cut -d: -f3)
do
if [[ `curl -Is http://core.svn.wordpress.org/tags/$vers/$f | grep "200 OK"` ]]
then
echo "Fetching $f"
curl -so $f http://core.svn.wordpress.org/tags/$vers/$f
View domain-change.php
<?php
function tmp_change_home_url( $homeurl ) {
$old = 'example.com';
$new = 'newsite.com';
if ( strpos( $homeurl, $old ) !== false ) {
$homeurl = str_replace( $old, $new, $homeurl );
}
return $homeurl;
View nginx.conf
# this goes in the http{} block
# remove any $no_cache "sets" from individual site confs (e.g. ` set $no_cache 0;`)
# 0 means we cache
# any other value will negate it
#check cookie for certain logged-in-type values, if found set 1
map $http_cookie $no_cookie_cache {
default 0;
"~comment_author_|wordpress_(?!test_cookie)|wp-postpass_" 1;
View rand.php
<?php
// testing how often a number in a given range will appear over many iterations
$max = 10; // how big of a range? ( 1 thru $max )
$iterations = 100000; // how many iterations
// set up an array for keeping tally
$totals = array_fill( 1, $max, 0 );
for ( $i = 1; $i <= $iterations; $i++ ) {
$totals[ rand( 1, $max ) ]++;
View argtest.sh
#!/bin/bash
# argtest.sh
#
# bash positional args and quoting
greenon='\033[0;92m';
coloroff='\033[0m'
###### #######
## ## ## ## ##
View gist:de6ac5f80e89297fcb8f
WP_CLI::run_command( array( 'search-replace', 'old', 'new' ), array( 'network' => true ) );
View content.txt
Lorem ipsum
[shortcode]
<ul>
<li>foo</li>
<li>bar</li>
</ul>
[/shortcode]
Lorem ipsum
View cli-media-fix.php
<?php
if ( ! defined( 'WP_CLI' ) ) return;
/**
* Media Fix
*/
class Media_Fix extends WP_CLI_Command {
/**
Something went wrong with that request. Please try again.