Skip to content

Instantly share code, notes, and snippets.

View mustardBees's full-sized avatar

Phil Wylie mustardBees

View GitHub Profile
wp user generate --format=ids --count=10 | xargs -d ' ' -I % bash -c 'wp user update % --user_registered="2020-04-02 14:35:02" && wp user meta add % verification_token randomstring1234'
wp user generate --format=ids --count=10 | xargs -d ' ' -I % wp user meta add % verification_token randomstring1234
wp user generate --count=10
@mustardBees
mustardBees / functions.php
Last active January 14, 2024 21:52
Add text with a link after the LearnDash login modal heading.
<?php
/**
* Add text with a link after the LearnDash login modal heading.
*/
function kanuka_add_text_after_login_modal_heading() {
?>
<div class="my-custom-text">
<p>This is some additional text. <a href="https://example.com">Click here</a> for more information.</p>
</div>
<?php
<?php
/**
* Write a log entry.
*
* Helper function to write a log entry with a given title, category, and any
* log data. Relies on the Maintenance Functionality mu-plugin being present.
*
* Usage:
*
* kanuka_log( 'Data Import', 'import', array(
@mustardBees
mustardBees / functions.php
Last active May 3, 2023 14:15
Generate a phone link with an aria-label for accessibility.
<?php
/**
* Generate a phone link with an aria-label for accessibility.
*
* @link https://link.from.pw/3HElEp9
*
* @param string $phone The phone number to format.
* @param string $class Optional. The CSS class name to add to the link.
*
* @return string The formatted telephone link.
<?php
/**
* Enable email-based 2FA by default.
*
* We configure MailHog to catch outbound mail on our local/staging
* environments. To avoid unnecessary hassle, we have disabled our default
* email-based 2FA on local/staging environments.
*
* @link https://link.from.pw/3P7cH9u
* @author pjv
<?php
/**
* Enable email-based 2FA by default.
*
* @author pjv
* @link https://link.from.pw/3P7cH9u
*
* @param $providers
* @param $user_id
* @return mixed
@mustardBees
mustardBees / post_types.sql
Created October 26, 2022 08:15
WordPress SQL query to return a count of each post type.
SELECT
post_type,
count(*)
FROM
wp_posts
GROUP BY
post_type
HAVING
count(*)
ORDER BY
@mustardBees
mustardBees / delete_products.sh
Created October 18, 2022 15:37
WooCommerce WP-CLI/WC-CLI script to delete all products.
#!/bin/bash
# Save script, run chmod +x on it, then...
# Usage: ./delete_products.sh [user_id]
ARGS="$@"
COUNT=$(wp wc product list --user=$1 --format=count)
BATCHES=$(bc <<< "$COUNT/100+1")
echo "Deleting $COUNT products in $BATCHES batches (via user ID $1)"