Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
🎅
The best way to spread Christmas cheer is singing loud for all to hear.

Luke Cavanagh lukecav

🎅
The best way to spread Christmas cheer is singing loud for all to hear.
View GitHub Profile
@wp-seopress
wp-seopress / filter-the-request-to-generate-a-meta-title-with-ai.php
Last active July 25, 2023 08:29
Filter the request to generate a meta title with AI
add_filter('seopress_ai_openai_meta_title', 'sp_ai_openai_meta_title', 10, 2);
function sp_ai_openai_meta_title($prompt, $post_id) {
//$content = get_post_field('post_content', $post_id);
//$content = esc_attr(stripslashes_deep(wp_filter_nohtml_kses(wp_strip_all_tags(strip_shortcodes($content)))));
//$content = wp_trim_words( $content, 500 );
$language = 'fr_FR'; //example with French locale, replace with your own language code
$prompt = 'Generate, in this language ' . $language . ', an engaging SEO title metadata in one sentence of sixty characters maximum for this article: ' . $content;
return $prompt;
@thesephist
thesephist / options.oak
Created November 14, 2022 22:09
Collection of useful Stable Diffusion prompt modifiers
{ name: 'Lighting', options: [
'golden hour, warm glow'
'blue hour, twilight, ISO12000'
'midday, direct lighting, overhead sunlight'
'overcast, whitebox, flat lighting, diffuse'
'dreamlike diffuse ethereal lighting'
'dramatic lighting, dramatic shadows, illumination'
'studio lighting, professional lighting, well-lit'
'flash photography'
'low-key lighting, dimly lit'
@cdils
cdils / wpmdbpro-cli-remote-backup-script.sh
Last active October 25, 2022 19:21 — forked from JRGould/wpmdbpro-cli-remote-backup-script.sh
WP Migrate DB Pro CLI Backup Script
#!/bin/bash
#
# Declare SITES as an associative array
declare -A SITES
# Format: SITES[WPMDB profile number]=backup_filename_base
SITES[1]=remote_backup_com
#SITES[2]=another_site_to_backup
#SITES[3]=my_other_blog
## These variables will be specific to the WordPress
@saqibsarwar
saqibsarwar / attached_pdf_to_downloadable_file.php
Created September 7, 2022 18:02
Download Monitor and WP ALL Import - Attach PDF files to download CPT to make them downloadable.
<?php
// Start preparing an array to insert Download Monitor's Download Version (which is a CPT with Download as parent post).
$dlm_download_version = array(
'post_title' => 'Download #' . $download_id . ' File Version',
'post_type' => 'dlm_download_version',
'post_status' => 'publish',
'post_parent' => $download_id,
'post_author' => $attachment->post_author,
);
@aidik
aidik / Query
Last active January 24, 2022 17:20 — forked from lukecav/Query
Improved MySQL/Maria script to get all WooCommerce orders including more metadata and better data types
SELECT `p`.`id` AS `order_id`,
Cast(`p`.`post_date` AS datetime) AS `order_date`,
SUBSTRING(`p`.`post_status`, 4) AS `order_status`,
Max(CASE WHEN `pm`.`meta_key` = '_billing_email' AND `p`.`id` = `pm`.`post_id` THEN `pm`.`meta_value` end) AS `billing_email`,
Max(CASE WHEN `pm`.`meta_key` = '_billing_first_name' AND `p`.`id` = `pm`.`post_id` THEN `pm`.`meta_value` end) AS `_billing_first_name`,
Max(CASE WHEN `pm`.`meta_key` = '_billing_last_name' AND `p`.`id` = `pm`.`post_id` THEN `pm`.`meta_value` end) AS `_billing_last_name`,
Max(CASE WHEN `pm`.`meta_key` = '_billing_company' AND `p`.`id` = `pm`.`post_id` THEN `pm`.`meta_value` end) AS `_billing_company`,
Max(CASE WHEN `pm`.`meta_key` = '_billing_address_1' AND `p`.`id` = `pm`.`post_id` THEN `pm`.`meta_value` end)
@mkkeck
mkkeck / class-editor-social-link.php
Last active October 15, 2024 13:41
Patched WordPress block `core/social-link` to allow theme developers to register own social services
@NickGreen
NickGreen / cart_total_notice.php
Last active November 2, 2021 16:33
Add cart and checkout notices if total less than $25
<?php
add_action( 'woocommerce_before_cart_table', 'free_shipping_notice' );
add_action( 'woocommerce_checkout_before_customer_details', 'free_shipping_notice' );
function free_shipping_notice() {
if ( 25 > WC()->cart->get_total() ) {
echo '<div style="color: #e08e79;">All orders over $25 ship free</div>';
}
}
<?php
/**
* Plugin Name: Fix woocommerce admin analytics performance issue
* Plugin URI:
* Description:
* Version: 1.0.0
* Author:
* Author URI:
* License: MIT
<?php
/*
Migrate from WP User Avatar to Simple Local Avatars
Allows sites to easily move away from the WP User Avatar plugin and switch to Simple Local Avatars instead.
Run by invoking with WP CLI like so:
`wp eval-file migrate-wp-user-avatar.php`
Author: Philip John
@NickGreen
NickGreen / prod_cat_email.php
Last active November 2, 2021 16:32
Add Product Category to email subject WooCommerce
<?php
add_filter( 'woocommerce_email_subject_new_order', 'customizing_new_order_subject', 10, 2 );
function customizing_new_order_subject( $formated_subject, $order ) {
$email = WC()->mailer->get_emails()['WC_Email_New_Order'];
$subject = $email->get_option( 'subject', $email->get_default_subject() );
$product_categories = array();
foreach ( $order->get_items() as $item ) {
$product_categories[] = implode( ', ', wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) ) );