Skip to content

Instantly share code, notes, and snippets.

View hide-gdpr-banner-on-mshots.php
<?php
add_filter( 'cli_show_cookie_bar_only_on_selected_pages', 'hide_banner_on_mshots' );
function hide_banner_on_mshots( $html ) {
if ( false !== strpos( $_SERVER['HTTP_USER_AGENT'], 'mShots' ) ) {
$html = '';
}
return $html;
View cache-downloads-w-org.php
<?php
/**
* Plugin Name: Redirect WordPress.org downloads through a local caching proxy.
*/
/**
* PLEASE NOTE:
* - Please only cache downloads for a short period of time, ZIPs may change even though the URL doesn't.
* - This will cause download counts to not be counted on WordPress.org.
* - downloads.wordpress.org serves: Plugins, Themes, Translations, and Core Update packages, amongst other things.
@dd32
dd32 / php56-php8-pollyfill.diff
Last active Apr 30, 2020
Example of altering the Symfony PHP8.0 polyfill to be parsable under PHP 5.6
View php56-php8-pollyfill.diff
diff --git a/src/Php80/Php80.php b/src/Php80/Php80.php
index ba74359..bc2533c 100644
--- a/src/Php80/Php80.php
+++ b/src/Php80/Php80.php
@@ -20,12 +20,12 @@ namespace Symfony\Polyfill\Php80;
*/
final class Php80
{
- public static function fdiv(float $dividend, float $divisor): float
+ public static function fdiv(float $dividend, float $divisor) //: float
View post-WordCamp video email
Subject: Let's get those WordCamp sessions on WordPress.tv
Hi ,
Hope you had a great WordCamp and everything went well with your video efforts.
@dd32
dd32 / block-cookies.py
Last active Jul 21, 2019
A Trac plugin to block anonymous cookies being sent
View block-cookies.py
"""WordPress.org: Block Anonymous Cookies."""
import re
from trac.core import Component, implements
from trac.web.api import IRequestFilter
from trac.web.session import Session, PURGE_AGE
class WPOrgBlockAnonymousCookies(Component):
"""Prevents Trac from setting cookies for unauthenticated requests.
View blank output (including new lines before and after)
<h4>WordPress Chat Plugin</h4>
<p>LiveChat – WP live chat plugin for WordPress is a WordPress chat plugin you can use to quickly and easily <strong>add live chat support to your WordPress website</strong>. It allows for instant communication with on-site visitors and customers and enables prompt resolution to their questions or concerns.</p>
<p>With a fully functional WordPress chat plugin, not only <strong>you can increase your sales</strong> - as it’s the quickest way to remove buyer objections – but it also allows you to <strong>build stronger customer relationships</strong>.</p>
<p>https://www.youtube.com/watch?v=dKUdE-JKhZI</p>
<h4>Feature-Rich WordPress Live Chat Plugin</h4>
@dd32
dd32 / fatal-error-handler.php
Last active Apr 28, 2021
A quick WordPress 5.1 shutdown handler to disable the plugin/theme pausing features. Install as wp-content/fatal-error-handler.php. This is needed during development, and on sites which have sensitive plugins enabled which must never be deactivated. You should also consider adding a wp-content/php-error.php template. UPDATE: This is replaced by …
View fatal-error-handler.php
<?php
// UPDATE: This can be replaced by `define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );` in `wp-config.php`.
// See https://core.trac.wordpress.org/changeset/44674
/**
* Shutdown handler to disable WordPress 5.1's plugin/theme pausing features.
*/
class dd32_Fatal_Error_Handler extends WP_Fatal_Error_Handler {
// Do not store errors, this disables the ability for plugins/themes to be marked 'paused'.
View 4.9.3 hotfixes
<?php
// If you're a host, and you have a plugin installed on every site,
// either of the below hotfixes will allow WordPress 4.9.3 to update to 4.9.4.
// Option 1:
// Fix the dependancies before the fatal is encountered:
add_action( 'set_site_transient_update_core', function( $val ) {
global $wp_version;
if ( wp_doing_cron() && '4.9.3' == $wp_version && !empty( $val->updates ) ) {
View cron-example-plugin.php
<?php
/*
* Plugin Name: Cron Example for https://core.trac.wordpress.org/ticket/42660
*/
class Cron_example_42660 {
function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'cron_single_event', array( $this, 'cron_callback' ) );
}
@dd32
dd32 / live-coding-example.php
Created Nov 20, 2017
Gutenberg giphy live demo plugin
View live-coding-example.php
<?php
// mu-plugin for stepping through https://github.com/obenland/giphy-block/
// has some dynamic modifications to avoid JS errors / use a better gif
class LiveDemo {
static $steps = array(
'425c485' => '0: Boilerplate',
'c98c358' => '1: Register a block',