Skip to content

Instantly share code, notes, and snippets.

@mindctrl
mindctrl / update-transient-flusher.php
Created February 5, 2015 01:43
Force WordPress to check for plugin and theme updates on every page load. Obviously used for testing. Do not use this full time as it will slow your site down.
<?php
/*
Plugin Name: Updates Transient Flusher
Description: Deletes the update_themes and update_plugins transients. Forces WordPress to check for plugin and theme updates on every page load. FOR TESTING ONLY.
*/
function jp_delete_update_transients() {
delete_transient( 'update_themes' );
delete_transient( 'update_plugins' );
#!/bin/bash
# Created by Sindre Sorhus
# Magically retrieves a GitHub users email even though it's not publicly shown
[ "$1" = "" ] && echo "usage: $0 <GitHub username> [<repo>]" && exit 1
[ "$2" = "" ] && repo=`curl "https://api.github.com/users/$1/repos?type=owner&sort=updated" -s | sed -En 's|"name": "(.+)",|\1|p' | tr -d ' ' | head -n 1` || repo=$2
curl "https://api.github.com/repos/$1/$repo/commits" -s | sed -En 's|"(email\|name)": "(.+)",?|\2|p' | tr -s ' ' | paste - - | sort -u -k 1,1
@mindctrl
mindctrl / edd-remove-billing-details.php
Created May 13, 2015 13:30
Easy Digital Downloads - Remove billing details section on the checkout screen.
/**
* Removes the billing details section on the checkout screen.
*/
function jp_disable_billing_details() {
remove_action( 'edd_after_cc_fields', 'edd_default_cc_address_fields' );
}
add_action( 'init', 'jp_disable_billing_details' );
@mindctrl
mindctrl / enqueue-react-devtools-script.php
Last active May 23, 2022 14:28
Using React Dev Tools (react-devtools) with WordPress and Safari
<?php
// This loads the react-devtools script in wp-admin when using Safari.
add_action( 'admin_enqueue_scripts', function() {
if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'Safari' ) !== false ) {
?>
<script src="http://localhost:8097"></script>
<?php
}
} );
@mindctrl
mindctrl / wp_human_time_diff.php
Created May 7, 2016 13:53 — forked from BinaryMoon/wp_human_time_diff.php
Human Time Difference Function for WordPress
<?php
/**
* Display the post time in a human readable format
*
* @return string
*/
function carmack_human_time_diff() {
$post_time = get_the_time( 'U' );
$time_now = date( 'U' );
@mindctrl
mindctrl / commercial-client.php
Created November 7, 2018 00:09 — forked from pento/commercial-client.php
Sample Commercial Plugin update server and client
<?php
/*
* Plugin Name: Commercial Client
* Plugin URI: http://pento.net/
* Description: A sample client plugin for showing updates for non-WordPress.org plugins
* Author: pento
* Version: 0.1
* Author URI: http://pento.net/
* License: GPL2+
*/
@mindctrl
mindctrl / setup-phpunit.sh
Created January 29, 2019 15:48 — forked from keesiemeijer/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, git, subversion, composer, curl and wget
#
# The $WP_CORE_DIR and $WP_TESTS_DIR environment variables are added to the ~/.bashrc file
#
function simple_plugin_updater( $update_plugins, $transient_name ) {
$plugin = json_decode(
json_encode(
array(
'new_version' => 89,
'stable_version' => 89,
'name' => 'My Fake Plugin',
'slug' => 'my-fake-plugin.php',
'url' => 'https://myfakeplugin.com',
@mindctrl
mindctrl / rcp-custom-post-restriction-messages.php
Created October 1, 2016 03:00
Custom post / page restriction messages in Restrict Content Pro
/**
* This plugin adds support for custom restriction messages per post.
* If a custom message exists, it is used in place of the ones defined
* in the RCP settings under Restrict > Settings > General.
*/
/**
* Displays the custom message metabox on the post edit screen.
*/
function jp_rcp_post_level_restriction_message_metabox() {
@mindctrl
mindctrl / fes-set-audio-post-format.php
Last active October 17, 2017 20:47
Easy Digital Downloads - Frontend Submissions: Automatically set post format to audio/video/gallery
<?php
// Sets the post format to audio on product submissions made in Frontend Submissions.
function jp_set_audio_post_format( $post_id ) {
set_post_format( $post_id, 'audio' );
}
add_action( 'fes_submit_submission_form_bottom', 'jp_set_audio_post_format' );