Skip to content

Instantly share code, notes, and snippets.

@wirtzdan
wirtzdan / magic-list-queries.md
Last active March 5, 2022 17:25
Magic List Queries
  • Recently assigned
    • {{[[query]]: {and: [[TODO]] {not: {or: [[Today]] [[Upcoming]] [[Later]] [[Template]] [[query]]]}}}}}
  • Today
    • {{[[query]]: {and: [[TODO]] [[Today]] {not: {or: [[Template]] [[query]]]}}}}}
  • Upcoming
    • {{[[query]]: {and: [[TODO]] [[Upcoming]] {not: {or: [[Template]] [[query]]]}}}}}
  • Later
    • {{[[query]]: {and: [[TODO]] [[Later]] {not: {or: [[Template]] [[query]]]}}}}}
@mikaelz
mikaelz / delete-all-woocommerce-products.php
Last active April 30, 2024 06:07
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
@eriteric
eriteric / movegfjstofooter.php
Last active October 13, 2021 16:55
Load gravity forms JS in footer
// GF method: http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_init_scripts_footer/
add_filter( 'gform_init_scripts_footer', '__return_true' );
// solution to move remaining JS from https://bjornjohansen.no/load-gravity-forms-js-in-footer
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
$content = 'document.addEventListener( "DOMContentLoaded", function() { ';
return $content;
}
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' );
#!/bin/bash
# (not really -- run these commands by hand & pay attention to the comments)
# Homebrew: The missing package manager for OS X
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Git
brew install git
git config --global --add merge.ff false
@markjaquith
markjaquith / nginx.conf
Last active December 25, 2022 15:55
My WordPress Nginx setup
upstream phpfpm {
server unix:/var/run/php5-fpm.sock;
}
upstream hhvm {
server unix:/var/run/hhvm/hhvm.sock;
}
# SSL
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@BronsonQuick
BronsonQuick / add_tinymce_custom_classes_with_backwards_compatibility.php
Last active August 29, 2015 14:01
Add TinyMCE custom classes to WordPress with backwards compatibility
<?php
Sometimes we want to give clients access to additional styles in TinyMCE. These functions also handle backwards compatibility with WordPress as TinyMCE 3 and TinyMCE 4 handle this differently
function sennza_mce_buttons( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'sennza_mce_buttons' );
function sennza_mce_before_init( $init_array ) {
@adamcapriola
adamcapriola / page_discourse-sso.php
Last active March 24, 2020 14:21
WordPress Page Template for SSO with Discourse
<?php
/**
* Template Name: Discourse SSO
* Author: Adam Capriola
* Version: 1.1
* Author URI: https://meta.discourse.org/users/AdamCapriola/activity
* Adapted From: https://github.com/ArmedGuy/discourse_sso_php
* Uses: https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045
*
*/
@ddebernardy
ddebernardy / WP-SubdirInstall-Fixes.php
Last active October 21, 2016 13:34
SubdirInstall component for WordPress
<?php
namespace Mesoconcepts\WordPress\Plugin\BugFixes\Component;
use Mesoconcepts\WordPress\Bridge\Component\WordPressInterface;
use Mesoconcepts\WordPress\Bridge\DependencyInjection\EagerLoadedInterface;
use Mesoconcepts\WordPress\Bridge\DependencyInjection\EventSubscriberInterface;
/**
* Subdir install fixes -- part of MIT-licensed `mesoconcepts/mc-bug-fixes` plugin
*
<?php
/**
* Plugin Name: Static Templates
*
* If most of your site content is in .php template files, and you're tired of
* creating new pages, assigning them page templates, creating page templates
* then doing it all over again on production, this plugin is for you.
*
* Examples:
*