Skip to content

Instantly share code, notes, and snippets.

View pierrerocket's full-sized avatar

Pierre Balian pierrerocket

  • Rocket55
  • Minneapolis USA
View GitHub Profile
@pierrerocket
pierrerocket / debug-meta-keys-function.php
Created October 5, 2024 07:54
print all post meta keys for current page site wide if in debug mode with query string.
/**
* Display all meta keys for the current post if the 'debug_meta' query string is set
* and the site is in debug mode.
*
* This function is intended to be used on single post pages. It retrieves all meta keys for the
* current post and displays them inside a `<div>` element if the 'debug_meta' parameter is present
* in the URL and WP_DEBUG is set to true. The meta keys are outputted in a readable format for debugging purposes.
*
* @return void
*/
@pierrerocket
pierrerocket / wp-cli-remove-spam-users-identical-first-last-name.php
Created October 2, 2024 19:45
WP Cli Command - Remove Spam Users with Identical First and Last Names
if ( defined( 'WP_CLI' ) && WP_CLI ) {
/**
* Class User_Cleanup_Command
*
* Custom WP-CLI command to clean up users by comparing their first and last names.
*/
class User_Cleanup_Command {
/**
* Executes the user cleanup command.
*
@pierrerocket
pierrerocket / wordpress-migrate-terms-from-taxonomy-to-taxonomy.php
Created September 13, 2024 15:24
Migrate Wordpress Terms and Tags from one taxonomy to another.
/**
* WP-CLI command to move terms associated with a specific custom post type from one taxonomy to another.
*
* Usage: wp move-terms --source=old_taxonomy --target=new_taxonomy --post_type=my_custom_post_type
*/
/**
* Moves terms from one taxonomy to another for a specific custom post type.
*
* ## OPTIONS
@pierrerocket
pierrerocket / wp-categories-to-tags-cli.php
Created September 13, 2024 15:22
WP CLI to Migrate Categories to Tags and set a category for Posts.
// It's pretty common to be working on sites where clients used categories all wrong and you want to migrate those to tags.
// I wrote this for a site with a lot of posts and I didnt want to risk it failing.
if (defined('WP_CLI') && WP_CLI) {
class Migrate_Categories_To_Tags_Command {
/**
* Migrate categories to tags, clear existing tags, and update posts.
*
* ## EXAMPLES
@pierrerocket
pierrerocket / new_gist_file_0
Created February 1, 2017 21:48
this calls the flex templates in my page.php file
<!--start of flex-->
<?php
if ( have_rows( 'flexible_content' ) ) :
while ( have_rows( 'flexible_content' ) ) : the_row();
if ( 'info_left_quicklinks_right' === get_row_layout() ) :
get_template_part( 'flex-parts/flex', 'caption-w-buttons' );
@pierrerocket
pierrerocket / 0_reuse_code.js
Last active December 21, 2016 18:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pierrerocket
pierrerocket / terminal-log
Last active January 21, 2017 23:16
This is my terminal log from that weird problem I had with Vagrant.
Last login: Mon Dec 19 23:03:45 on ttys000
✔ ~
23:04 $ pwd
/Users/XXXXXXXX
✔ ~
23:04 $ ls
Applications Library VirtualBox VMs
Creative Cloud Files Movies bin
Desktop Music vagrant-local
Documents Pictures wpcs