This file contains 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
# Example: loop through all post ids and update the post meta for each post_id to assign the post_date | |
for post_id in $(terminus remote:wp examplesite.environment -- post list --format=ids); do terminus remote:wp examplesite.environment -- post meta update "$post_id" examplemeta_start_date "$(terminus remote:wp examplesite.environment -- post get $post_id --field=post_date)"; done |
This file contains 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
capability="upload_files" | |
wp role list --fields=role --format=csv | tail -n +2 | while IFS= read -r role; do | |
if wp cap list "$role" | grep -q $capability; then | |
echo "$role" | |
fi | |
done |
This file contains 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
# replace "Hello, World!" with appropriate string to search for | |
# replace `post_title` with appropriate column to search for | |
wp site list --fields=url,blog_id | while IFS= read -r line; do | |
url=$(echo "$line" | awk -F'\t' '{print $1}') | |
blog_id=$(echo "$line" | awk -F'\t' '{print $2}') | |
wp post list --field=url --ignore_sticky_posts=1 --orderby=date --order=DESC --post__in=$(wp db query "SELECT ID FROM wp_${blog_id}_posts WHERE post_title LIKE '%Hello, World!%' AND post_status='publish' AND post_type='post'" --skip-column-names --url=${url} | paste -s -d ',' -) --url=${url} | |
done >> log.txt |
This file contains 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
wp site list --field=url | xargs -I % sh -c 'wp plugin is-active wordpress-seo --url=% && echo "Plugin is activated on site %"' |
This file contains 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 | |
// Disable WordPress core attempts to redirect old posts. | |
add_filter( 'old_slug_redirect_post_id', '__return_zero' ); | |
add_filter( 'redirect_canonical', '__return_empty_string' ); |
This file contains 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
<!doctype html> | |
<html class="bg-gray-100"> | |
<head> | |
<title>Checksum Generator</title> | |
<script src="https://cdn.tailwindcss.com"></script> | |
</head> | |
<body> | |
<div | |
class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8" | |
> |
This file contains 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 | |
// List down all the functions assigned to the "the_content" filter hook. | |
function get_the_content_filters() { | |
$filters = array(); | |
ob_start(); | |
the_content(); | |
$output = ob_get_clean(); | |
global $wp_filter; |
This file contains 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
git diff --staged | pbcopy |
This file contains 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 | |
/** | |
* Gets an array of recent post IDs based on the number of posts. | |
* | |
* @param int $num_posts The number of recent posts to retrieve. Defaults to 6. | |
* @param int $expiration_time The expiration time for the cache, in seconds. Defaults to 1 hour. | |
* | |
* @return array An array of recent post IDs. | |
*/ |
This file contains 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 | |
# Prompt the user to enter a postmeta key to search for | |
read -p "Enter the postmeta key to search for: " postmeta_key | |
# Find all posts with the specified postmeta key | |
post_ids=$(wp post list --format=ids) | |
for id in $post_ids | |
do | |
meta_value=$(wp post meta get $id $postmeta_key --format=json) |
NewerOlder