This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// loop through all the blog posts and mark the first 4 as featured. | |
i=0; \ | |
c=4; \ | |
for id in $(wp post list --format=ids); \ | |
do let i++; \ | |
if [ "$i" -lt 4 ]; \ | |
then wp post meta update $id featured_post '1'; \ | |
else wp post meta update $id featured_post '0'; \ | |
fi; \ | |
done; \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// insert db that is split into multiple parts | |
for f in /sql/*.sql; \ | |
do wp db import $f; \ | |
done; \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create 25 posts with fake & identical content | |
curl http://loripsum.net/api/5 | \ | |
wp post generate --post_content --count=25 --format=ids | \ | |
xargs -d ' ' -I % wp post meta add % _thumbnail_id \ | |
$(wp media import \ | |
$(wget -O - -q -t 1 http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC | \ | |
json data.images.original.url) --porcelain); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get random images for featured image | |
for id in $(wp post list --format=ids); | |
do wp post meta update $id _thumbnail_id \ | |
$(wp media import \ | |
$(wget -O - -q -t 1 http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC | \ | |
json data.images.original.url) --porcelain); \ | |
done; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//backup site and create a new one with dummy posts | |
wp db export ../backups/now/sql/marcgratch.sql; \ | |
wp db drop; \ | |
mv * ../backups/now/files/; \ | |
wp core download; \ | |
wp config create --prompt; \ | |
wp db create --prompt; \ | |
wp core install --url=marcgratch.test --title=marcgratch.com --admin_user=admin [email protected]; \ | |
curl http://loripsum.net/api/5 | \ | |
wp post generate --post_content --count=25 --format=ids | \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 1. install https://wordpress.org/plugins/gravity-forms-custom-post-types/ | |
* 2. Add the following code | |
* | |
* Now text fields in GF marked as taggable with the additional plugin will work as expected. This code is a bit rough and there is more duplication than I would like... this is a first draft :) | |
* This should work for any text field with a comma separated value, not just the above plugin. | |
* | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Create individual SQL files for each database automatically, | |
# but give me a chance to skip it. These files | |
# are imported automatically during an initial provision if | |
# the databases exist per the import-sql.sh process. | |
echo 'Starting custom vagrant halt...'; | |
mysql -e 'show databases' | \ | |
grep -v -F "information_schema" | \ | |
grep -v -F "performance_schema" | \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var items = []; | |
//build an array of item id's and date the item was logged | |
jQuery.each(jQuery(".redactor-editor > p > small:last-child"), function(){ | |
var date = jQuery(this), | |
item = jQuery(this).parent(); | |
items.push({date: new Date(jQuery(this).text()),ID: jQuery(this).parents('.item').first().data('id')}) | |
}) | |
//yay underscores makes sorting by date easy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Delete all items above a specific ID ... i.e. I import a project time from toggl | |
* which spans multiple months. I only want this months. So I find the first item I need to keep. | |
* All the items above should be deleted. | |
**/ | |
jQuery.each(jQuery('#2623').prevAll(), function(){ | |
jQuery(this).find(jQuery('.time_entry_deletion')).click(); | |
}) | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Remove HTML | |
* Description: batch Remove HTML from post_content | |
* Author: Marc Gratch | |
* Author URI: http://marcgratch.com | |
* Version: 0.1.0 | |
*/ | |
function rh_get_all_ids(){ | |
$args = array ('post_type' => array('post','page'), 'fields' => 'ids', 'posts_per_page' => -1); |