Skip to content

Instantly share code, notes, and snippets.

@verygoodplugins
verygoodplugins / queryWooCommerce.py
Last active February 6, 2024 12:28
Python script for querying the WooCommerce REST API using ChatGPT
import openai
import requests
import re
import json
openai.api_key = "X"
# Define WooCommerce credentials.
site_url = "https://yoursite.com/"
@JoryHogeveen
JoryHogeveen / polylang-elementor-assets-url.php
Last active November 13, 2023 11:13
WP MU Plugin: Polylang multidomain Elementor assets URL
<?php
/**
* MU plugin. Need to be used together with regular plugin.
*
* Plugin Name: Polylang Elementor Cross Domain Assets URL
* Description: Fixes cross origin domain issues with Elementor and Polylang
* Version: 1.0
* Author: Jory Hogeveen
* Author URI: http://www.keraweb.nl/
*/
@kingkool68
kingkool68 / use-remote-media.php
Last active March 24, 2024 11:37
Check if a local file exists in the WordPress media library and if it doesn't exist, replace the URL with a different URL. Helpful when working with a local site that doesn't have all of the media downloaded as the production site. See https://localwp.com/community/t/proxying-requests-to-wp-content-uploads-to-a-production-site/15701
<?php
// Put this in wp-config.php and replace https://example.com/ with the URL of the production site.
define( 'RH_USE_REMOTE_MEDIA_URL', 'https://example.com/' );
// Put the rest of this in functions.php or a custom plugin or somewhere else.
if ( defined( 'RH_USE_REMOTE_MEDIA_URL' ) && ! empty( RH_USE_REMOTE_MEDIA_URL ) ) {
add_filter( 'wp_get_attachment_image_src', 'filter_wp_get_attachment_image_src' );
add_filter( 'wp_calculate_image_srcset', 'filter_wp_calculate_image_srcset' );
add_filter( 'wp_get_attachment_url', 'filter_wp_get_attachment_url' );
}
@joemaller
joemaller / README.md
Last active May 14, 2024 04:08
Fix term counts so wp-admin Taxonomy listings show the correct number of items for the selected post_type.

Fixing post counts for WordPress taxonomies

The problem

For WordPress sites using Custom Post Types, Taxonomy admin listings show cumulative term-assignment totals for all post_types instead of counts specific to the selected post_type. Since Taxonomy listings are always attached to a single post_type, totals for shared taxonomies don't make sense.

The Goal

Fix term counts so wp-admin Taxonomy listings show the correct number of items for the selected post_type.

@reillysiemens
reillysiemens / signing-vbox-kernel-modules.md
Last active May 30, 2024 16:26
Signing VirtualBox Kernel Modules

Signing VirtualBox Kernel Modules

These are the steps I followed enable VirtualBox on my laptop without disabling UEFI Secure Boot. They're nearly identical to the process described on [Øyvind Stegard's blog][blog], save for a few key details. The images here are borrowed from the [Systemtap UEFI Secure Boot Wiki][systemtap].

  1. Install the VirtualBox package (this might be different for your platform).
    src='https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo'
find ./ -type f -name '*.jpg' -exec sh -c 'cwebp -q 75 $1 -o "${1%.png}.webp"' _ {} \;
@tankbar
tankbar / functions.php
Created December 14, 2017 10:50
WooCommerce - Add GTIN/EAN meta field for product and product variations
/**
* Adding Custom GTIN Meta Field
* Save meta data to DB
*/
// add GTIN input field
add_action('woocommerce_product_options_inventory_product_data','woocom_simple_product_gtin_field', 10, 1 );
function woocom_simple_product_gtin_field(){
global $woocommerce, $post;
$product = new WC_Product(get_the_ID());
echo '<div id="gtin_attr" class="options_group">';
@hakib
hakib / admin.py
Created December 9, 2017 08:37
Django Admin InputFilter
# common/admin.py
class InputFilter(admin.SimpleListFilter):
template = 'admin/input_filter.html'
def lookups(self, request, model_admin):
# Dummy, required to show the filter.
return ((),)
def choices(self, changelist):
(function() {
tinymce.PluginManager.add('app', function(editor, url) {
editor.addButton('app', {
title: 'App',
icon: 'app icon-example',
type: 'menubutton',
menu: [
{
text: 'Shortcodes',
menu: [
<?php
namespace App;
use function \Sober\Intervention\intervention;
if (function_exists('Sober\Intervention\intervention')) {
// Add Welcome Dashboard
intervention('add-dashboard-item', [
'Welcome',