Skip to content

Instantly share code, notes, and snippets.

@dd32
dd32 / live-coding-example.php
Created November 20, 2017 04:03
Gutenberg giphy live demo plugin
<?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',
<?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' ) );
}
<?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 ) ) {
<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 / block-cookies.py
Last active July 21, 2019 03:42
A Trac plugin to block anonymous cookies being sent
"""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.
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 / php56-php8-pollyfill.diff
Last active April 30, 2020 11:55
Example of altering the Symfony PHP8.0 polyfill to be parsable under PHP 5.6
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
<?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.
<?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;
@dd32
dd32 / fatal-error-handler.php
Last active January 13, 2023 00:52
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 …
<?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'.