Skip to content

Instantly share code, notes, and snippets.

@gboone
gboone / wp-cli-notes.md
Created March 4, 2014 22:55
WP-CLI notes
  • Will install a plugin from a url: wp plugin install https://github.com/gboone/simple-open-graph/archive/master.zip --activate
  • GitHub will make a different zip file for every branch, tag, or even commit, observe! https://github.com/gboone/open-graph-control/archive/4c4611a9c35f269d5d5dab7b6a8fc6697e0a5341.zip
  • Thus wp plugin install https://github.com/gboone/open-graph-control/archive/4c4611a9c35f269d5d5dab7b6a8fc6697e0a5341.zip --activate will install and activate the plugin at that specific commit
@gboone
gboone / maybe_flush.php
Last active December 21, 2015 10:49
Tired of hitting the Save Permalinks button every time you register a post type in WordPress? Try this function: it grabs the cached rewrite rules, checks for a target (could be anything, but let's say it's a post type with an archive) and flushes the rules if the rewrite rule isn't present.
<?php
function maybe_flush_rewrite_rules($target) {
$rules = get_option( 'rewrite_rules' );
if ( $rules[ $target . '/?$' ] != 'index.php?post_type=' . $target ) {
flush_rewrite_rules( $hard = true );
}
}