Skip to content

Instantly share code, notes, and snippets.

View emzo's full-sized avatar

Emyr Thomas emzo

View GitHub Profile
@ericmann
ericmann / gist:5949377
Last active December 19, 2015 11:39
Pseudo-singleton for WordPress.
<?php
class Example {
public function __construct() {
$this->instantiate();
}
public function instantiate() {
static $instance = null;
@bigdawggi
bigdawggi / mailtrap-filter.php
Last active June 3, 2019 19:11
Mailtrap filter for WordPress
/**
* Routes all email from WP installation to specific Mailtrap
* account inbox.
*
* All you need to do is change the "Username" and "Password"
* settings to the appropriate box in Mailtrap. Then all
* mail **should** be routed to that box. Exceptions would
* be other functionality that overwrite the wp_mail() functions
* and may not use this filter, or other filters that change
* this behavior after we set it, or millions of other things.
@rosshanney
rosshanney / gce-load-polylang-on-ajax.php
Created August 10, 2013 20:31
Ensure that Polylang plugin is loaded on Ajax request, to ensure calendar output is translated
<?php
/*
Plugin name: GCE Load Polylang on Ajax requests
*/
function gce_load_polylang_on_ajax() {
?>
<script type="text/javascript">
if (typeof jQuery != 'undefined') {
jQuery.ajaxSetup({
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active March 20, 2025 17:17
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@thomasgriffin
thomasgriffin / gist:7944588
Created December 13, 2013 13:56
Here is a surefire way to hook into save_post if you need to save stuff. In my case, it is for custom metaboxes.
<?php
/**
* Callback for saving values from metaboxes.
*
* @since 1.0.0
*
* @param int $post_id The current post ID.
* @param object $post The current post object.
*/
function tgm_save_meta_boxes( $post_id, $post ) {
@thomasgriffin
thomasgriffin / gist:8012662
Last active December 31, 2015 16:19
REMOVE ALL THE METABOXES FROM ALL THE THINGS. WARNING: THIS THING IS VERY AGGRESSIVE.
<?php
add_action( 'add_meta_boxes', 'tgm_remove_all_the_metaboxes', 100 );
/**
* Removes all metaboxes except the ones I WANT ON MY POST TYPE. RAGE.
*
* This assumes a specific post type. In my case, it is 'envira'.
* This function is very aggressive and removes every single metabox minus
* the needed submitdiv metabox (which allows you to publish something) and
* the metaboxes that I register with my plugin.
*
@franz-josef-kaiser
franz-josef-kaiser / disable_metabox_order.php
Last active August 29, 2015 13:56
WordPress plugin that temporarily disables the user defined order (user settings). The plugin is targeted at developers. Often it's annoying when you add a meta box to the admin UI and can't be sure if it's in the right position because you might have already moved it around and added a user setting. The plugin can be reused to temporarily overr…
<?php
namespace WCM;
/**
* Plugin Name: (WCM) Meta Box Order Debug
* Description: Temporarily overrides the MetaBox-order by dismissing the user setting.
* Author: Franz Josef Kaiser
* Author URI: https://unserkaiser.com
* Version: 1.0
@jchristopher
jchristopher / gist:9331899
Last active September 9, 2017 01:48
Integrate SearchWP and Jetpack Infinite Scroll
<?php
// Jetpack infinite scroll does it's own WP_Query, so we need to hijack it at runtime
function searchwp_infinite_scroll_query_args( $query_args ) {
if( class_exists( 'SearchWPSearch' ) ) {
$query = get_search_query();
if( empty( $query ) ) {
if( isset( $_GET['query_args']['s'] ) ) {
$query = sanitize_text_field( $_GET['query_args']['s'] );
}
@NateWr
NateWr / imager-for-wp.php
Created March 12, 2014 01:07
Integrate Imager.js with WordPress
<?php
/**
* Integrate Imager.js with WordPress
*
* Imager.js is BBC's solution for serving responsive and retina images, without
* the double payload issues that affect other solutions. For more information:
*
* https://github.com/BBC-News/Imager.js/
*
* This collection of functions modifies the output of WordPress's
@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;