Skip to content

Instantly share code, notes, and snippets.

@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
@evansolomon
evansolomon / nginx.conf
Created April 1, 2012 09:25
nginx config file
user www-data;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
@jchristopher
jchristopher / functions.php
Created July 23, 2015 09:51
Have SearchWP perform searches in WooThemes' Sensei
<?php
// SearchWP/Sensei compat
function searchwp_sensei_compat() {
if ( is_post_type_archive() && is_search() ) {
add_filter( 'searchwp_outside_main_query', '__return_true' );
}
}
add_action( 'parse_query', 'searchwp_sensei_compat' );
@mikejolley
mikejolley / functions.php
Created September 29, 2015 07:41
WooCommerce - Disable the non-admin access to dashboard feature
<?php
// Add the below line to your theme functions.php file
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
@ideag
ideag / edwinfrontpage.php
Last active November 19, 2015 22:15
A snippet to allow a CPT post to be selected as the Front Page in WordPress.
<?php
/*
Plugin Name: EdwinFrontPage
Plugin URI: https://gist.github.com/ideag/f97d513e84b523bd2dac
Description: Enable CPT posts to be set as front page. Usage: EdwinFrontPage::init( 'your_custom_post_type' ); Should be run on 'init' hook.
Author: Arūnas Liuiza
Version: 0.1.0
Author URI: http://arunas.co/
*/
@thomasgriffin
thomasgriffin / gist:4368038
Created December 24, 2012 06:22
This is the way you should send content to the TinyMCE Editor in WP 3.5.
// This replaces the old window.send_to_editor function.
wp.media.editor.insert('your_content_goes_here');
@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;
@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.
*
<?php
class CWS_Jetpack_Modules {
function __construct() {
add_filter( 'option_jetpack_active_modules', array( $this, 'active_modules' ) );
}
function active_modules( $modules ) {
$allowed_modules = array(
'enhanced-distribution',