Skip to content

Instantly share code, notes, and snippets.

@seancojr
seancojr / new_gist_file_0
Created March 12, 2014 20:13
How to set the default image size in WordPress galleries From http://www.wprecipes.com/how-to-set-the-default-image-size-in-wordpress-galleries The desired size can be changed on line 5.
remove_shortcode('gallery');
add_shortcode('gallery', 'custom_size_gallery');
function custom_size_gallery($attr) {
$attr['size'] = 'medium';
return gallery_shortcode($attr);
}
@seancojr
seancojr / backup-scheduler.php
Created April 5, 2014 01:35 — forked from pento/backup-scheduler.php
Backup scheduler for WordPress Automatic Updates
<?php
function my_backup_scheduler( $event ) {
// 'wp_maybe_auto_update' is the cron hook for the auto update process
if ( 'wp_maybe_auto_update' !== $event['hook'] )
return;
wp_schedule_single_event( $event['timestamp'] - 5 * MINUTE_IN_SECONDS, 'my_backup' );
}
add_filter( 'schedule_event', 'my_backup_scheduler', 10, 1 );
<?php
add_filter( 'wp-tiles-data', 'fixed_page_tiles', 10, 4 );
function fixed_page_tiles( $data, $posts, $colors, $tiles_obj ) {
$pages = get_pages();
foreach ( $pages as $page ) {
$position = get_post_meta( $page->ID, 'tile-position', true );
if ( empty ( $position ) || ! is_numeric ( $position ) )
continue;
/* Allow shortcodes that are contained within the [nextpage] shortcodes to be processed */
return do_shortcode( $html );
} else {
return do_shortcode( $content );
@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/
*/