Skip to content

Instantly share code, notes, and snippets.

@seancojr
seancojr / fix-ssl-siteurl.php
Created April 4, 2012 11:42
Fixes SSL incompatibility in a WordPress site
<?php
/*
Plugin Name: Add Support for HTTPS
Plugin URI: http://www.sitepoint.com/crimes-against-wordpress/
Description: Fixes SSL incompatibility in a WordPress site
Version: 1.0
Author: Andrew Tetlaw
Author URI: http://awesomebutuseless.com/
License: GPL2
*/
@seancojr
seancojr / README.md
Created April 5, 2012 13:06
Automatically enable plugins in new WordPress Multisite blogs

There are three options (that I know of) for automatically enabling a plugin in new sites.

  1. Move the plugin from wp-content/plugins/ to wp-content/mu-plugins/ (MU = Must Use). But then it cannot be deactivated for any site.

  2. Click Network Activate instead of Activate to enable it for all sites. I didn't want to use this though because I didn't want to affect existing sites. Also I couldn't work out how to deactivate it for some sites (although I've read this should be possible).

  3. Write a plugin (in wp-content/mu-plugins/) with a hook that activates the plugin at creation time. This way it only affects new blogs, can be deactivated easily, and I can also set the default configuration at the same time.

@seancojr
seancojr / gist:2342245
Created April 9, 2012 08:04 — forked from buhrmi/gist:1344659
Sublime Text 2 Git Annotation Colors
<dict>
<key>name</key>
<string>Git Modified Line</string>
<key>scope</key>
<string>git.changes.x</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#272852</string>
</dict>
@seancojr
seancojr / always-login.php
Created April 9, 2012 15:05 — forked from jkudish/always-login.php
Always logged in with WordPress
<?php
/**
* keeps a user always logged in
* don't use this on a production site, ever!
*/
add_action('init', 'auto_login');
add_action('admin_init', 'auto_login');
function auto_login() {
@seancojr
seancojr / gist:2348192
Created April 10, 2012 03:44 — forked from bueltge/gist:1595155
Add custom post type to AddQuicktag plugin for use the plugin on custom post types
<?php
/**
* Plugin Name: Use AddQuicktag on my CPT
* Plugin URI: http://bueltge.de/
* Description: Add custom post type 'my_custom_post_type' to AddQuicktag plugin
* Author: Frank Bültge
* Version: 0.0.1
* Licence: GPLv3
* Author URI: http://bueltge.de
*/
@seancojr
seancojr / disable-plugins-when-doing-local-dev.php
Created April 15, 2012 11:51 — forked from markjaquith/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
<?php
/**
* @package JCK_Quick_Jump Modified
* @version 1.3
*/
/*
Plugin Name: Admin Quick Jump Modified
@seancojr
seancojr / gist:2439902
Created April 21, 2012 22:03 — forked from Viper007Bond/gist:1903147
Modify post_types searched
<?php
add_action( 'pre_get_posts', 'localtv_posts_and_pages_for_search' );
function localtv_posts_and_pages_for_search( $query ) {
if ( $query->is_main_query() && $query->is_search() )
$query->set( 'post_type', array( 'post', 'page' ) );
}
@seancojr
seancojr / gist:2439913
Created April 21, 2012 22:07 — forked from Viper007Bond/gist:1325696
Limit results to post meta via URL
<?php
add_action( 'pre_get_posts', 'oomskaap_price_range_limiter' );
function oomskaap_price_range_limiter( $query ) {
// Only do something if both the start and end values are set in the URL
if ( empty( $_GET['pricestart'] ) || empty( $_GET['priceend'] ) )
return;
// Only modify the main query
@seancojr
seancojr / gist:2439915
Created April 21, 2012 22:08 — forked from Viper007Bond/gist:1297669
Determining if modifying the main query or not in WordPress
<?php
# See bigdawggi's comment below for a good combined example
// Pre-3.3
function cf_google_search_kill_wp_search( $where, $query ) {
global $wp_the_query;
if( ! is_admin() && $query->is_search() && $query === $wp_the_query ) {
$where = ' AND 1=0';