Skip to content

Instantly share code, notes, and snippets.

View chrisjangl's full-sized avatar

Chris Jangl chrisjangl

  • Wine Enthusiast, Digitally Cultured
  • NY
  • 07:54 (UTC -04:00)
View GitHub Profile
@chrisjangl
chrisjangl / find_page_template.sql
Created May 17, 2019 15:03
WordPress: SQL query to find all pages that use a certain page template. Can use WP CLI to run this query without have to log into cPanel/phpMyAdmin. Need to replace <wp_prefix_> & <page-template.php> to match your setup.
SELECT * FROM `<wp_prefix_>postmeta` WHERE `meta_key` LIKE '_wp_page_template' AND `meta_value` LIKE '<page-tempate.php>'
@chrisjangl
chrisjangl / deletePlugins.sh
Created June 21, 2023 17:38
WordPress plugin management
for plugin in $(wp --allow-root plugin list --update=available --status=inactive --field=name);
do
TITLE=$(wp --allow-root plugin get $plugin --field=title)
# look into how we can mark the date here. Maybe also only output final result
rm -r wp-content/plugins/$plugin/* && rmdir wp-content/plugins/$plugin
git add -A wp-content/plugins/$plugin
git commit -m "$(printf "delete plugin: $TITLE")"
echo "$TITLE -> $VERSION" >> ./reports/deleted-plugins.txt
done;
@chrisjangl
chrisjangl / getEnabledIngredients.js
Created June 14, 2023 23:47
[WP Pizza] Lists the enabled ingredients in an ingredient group when on the WP Pizza Ingredients page, Custom Groups tab
// set this to the ID of the group
var group = document.querySelector('#wppizza_addingredients-custom-group-96'),
// setting this as a variable in case it changes in the future
ingredientClass = 'wppizza_addingredients_ingrcg_sortable';
// find the ingredients that are enabled for this group
group.querySelectorAll('input[type="checkbox"]:checked').forEach(function(ingredient) {
// find the label for the ingredient
var label = ingredient.parentElement.innerText;
@chrisjangl
chrisjangl / enableIngredients.js
Created June 14, 2023 23:22
[WP Pizza] Enable all ingredients in a specific meal size when on the WP Pizza Ingredients page, Ingredients tab
// get a node list of all the ingredients on the page
var ingredients = document.querySelectorAll('.wppizza_ingr_option.wppizza_option');
// and then loop through each one, setting the meal size
ingredients.forEach(function(ingredient){
ingredient.querySelector('input[type="checkbox"]').checked=true;
})
@chrisjangl
chrisjangl / scrape-FSA-deductions.js
Last active December 22, 2022 13:56
Scrape the FSA contributions deducted from each paycheck in a given year. Must be on the pay stubs list and have selected a year. Custom built for pay stubs in PayCom.
// get all rows that we're interested in (each represent 1 paycheck)
let rows = document.getElementById('check-listings-table').querySelectorAll('tbody tr[role="row"]');
// instantiate the array we'll use for all contributions
var contributions = [];
// loop over each row
for (var i = 0; i < rows.length; i++) {
// we never actually use this...
let row = rows[i];
@chrisjangl
chrisjangl / setMealSize.js
Created September 17, 2022 12:23
[WP Pizza] Change all ingredients to a specific meal size when on the WP Pizza Ingredients page, Ingredients tab
// set this to the ID of the meal size
var mealSize = "";
// get a node list of all the ingredients on the page
var ingredients = document.querySelectorAll('.wppizza_ingr_option.wppizza_option');
// and then loop through each one, setting the meal size
ingredients.forEach(function(ingredient){
let dropdown = ingredient.querySelector('select.ingredients');
dropdown.value = mealSize;
@chrisjangl
chrisjangl / updateWordPressPlugins.sh
Last active July 13, 2022 12:13
WP CLI script to update active plugins, and commit each update individually. 99% percent stolen from https://markjaquith.wordpress.com/2018/02/12/updating-plugins-using-git-and-wp-cli/, (ever so slightly) adapted to my own personal workflow
for plugin in $(wp plugin list --update=available --status=active --field=name);
do
TITLE=$(wp plugin get $plugin --field=title)
wp plugin update $plugin &&
VERSION=$(wp plugin get $plugin --field=version)
git add -A wp-content/plugins/$plugin &&
git commit -m "$(printf "update plugin: $TITLE to $VERSION")"
echo "$TITLE -> $VERSION" >> updated.txt
done;
@chrisjangl
chrisjangl / createStripeInvoice.sh
Created April 11, 2022 19:24
First attempts to create a Stripe invoice using the Stripe CLI
INVOICE_ID=""
CUSTOMER_ID=""
FOOTER=""
DESCRIPTION=""
stripe invoices create --customer=${CUSTOMER_ID} --days-until-due=1 --footer=\"${FOOTER}\" --collection-method=\"send_invoice\" -d \"metadata[invoice]\"=${ID} --description="${DESCRIPTION}"
@chrisjangl
chrisjangl / toggl_daily_report.php
Created January 12, 2022 04:25
List the projects and items worked on today (by default) for a given workspace in Toggl.
<?php
/**
* some config variables
*/
/**
* User Agent value
*
* app name or email address
*
@chrisjangl
chrisjangl / wp_version_report.sh
Created November 24, 2021 12:32
Working from a list of WordPress sites on a shared hosting environment (sites.txt), create a report of each sites WordPress version.
# prints a report of the WP version
i=1
touch version.txt
COUNT=$(wc -l sites.txt)
for SITE in $(cat sites.txt)
do
cd $SITE
echo "Working on $SITE ($i of $COUNT)..."
echo "## $SITE" >> ../version.txt
url=$(wp option get siteurl)