Skip to content

Instantly share code, notes, and snippets.

@DeanMarkTaylor
DeanMarkTaylor / post-menu-private-message-button.js
Last active August 29, 2015 14:15
Discourse - Add "Private Message" Post Button
// Show Private Message button (for specific categories)
// NOTE: In order for the button to display you need to 'message' to the post_menu site setting.
(function (require, Discourse, I18n, Em) {
var Button = require('discourse/views/post-menu').Button;
Discourse.PostMenuView.reopen({
buttonForMessage: function (post) {
// NOTE: just set whiteListedCategories to null / empty array to make buttons visible everywhere.
var whiteListedCategories = [37, 71, 72, 73, 74, 75, 76, 77, 78],
currentUser = Discourse.User.current();
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@thenbrent
thenbrent / subscription-sync.php
Last active August 26, 2021 08:22
Example code to sync a subscription to a specific date. All the good parts are thanks to @peterwilsoncc, all the bad parts are my own. This is not intended to be a complete and working snippet. Instead, treat it as a guide to what needs to be changed for syncing a payment date.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Date Sync
* Plugin URI:
* Description: Sets the start date of a subscription to September 13, 2013
* Author: Peter Wilson
* Author URI: http://peterwilson.cc/
* Version: 1.0.0
*/
@sergejmueller
sergejmueller / .htaccess
Last active January 12, 2024 20:58
Apache: Detecting WebP support with Header Vary Accept
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
@DeanMarkTaylor
DeanMarkTaylor / domain_mapping.php - fix-php-notices-warnings.patch
Created April 8, 2013 23:34
WordPress MU Domain Mapping - 0.5.4.3 - Patch - Fix PHP notices and warnings
Index: domain_mapping.php
===================================================================
--- domain_mapping.php (revision 694026)
+++ domain_mapping.php (working copy)
@@ -370,7 +370,7 @@
exit;
break;
}
- } elseif( $_GET[ 'action' ] == 'delete' ) {
+ } elseif ( isset( $_GET['action'] ) && $_GET['action'] == 'delete' ) {
@DeanMarkTaylor
DeanMarkTaylor / domain_mapping.php - fix-theme-customize.patch
Created April 8, 2013 23:33
WordPress MU Domain Mapping - 0.5.4.3 - Patch - Fix for theme preview not working
Index: domain_mapping.php
===================================================================
--- domain_mapping.php (revision 694026)
+++ domain_mapping.php (working copy)
@@ -695,7 +695,7 @@
return;
// don't redirect theme customizer (WP 3.4)
- if ( isset( $_POST['customize'] ) && isset( $_POST['theme'] ) && $_POST['customize'] == 'on' )
+ if ( isset( $_POST['wp_customize'], $_POST['theme'] ) && $_POST['wp_customize'] == 'on' )
@brettz9
brettz9 / html5-dataset.js
Last active April 29, 2023 14:58
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License
@thefuxia
thefuxia / plugin-class-demo.php
Last active April 11, 2024 13:50
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Fuxia Scholz
* License: GPL
* Text Domain: plugin_unique_name
* Domain Path: /languages
@thefuxia
thefuxia / autohook-usage-example.php
Created January 18, 2012 07:11
T5_Autohook Plugin
<?php # -*- coding: utf-8 -*-
declare( encoding = 'UTF-8' );
class Autohook_Demo
{
public static function init()
{
new self;
}
@Rarst
Rarst / deprecated.md
Last active February 21, 2023 11:21
WordPress coding standards configuration for PhpStorm

Now Native

PhpStorm now bundles WordPress coding style natively, starting from version 8.

  1. Go to Project Settings > Code Style > PHP.
  2. Select Set From... (top right of window) > Predefined Style > WordPress.

No longer need to muck with this import! :)