Skip to content

Instantly share code, notes, and snippets.

@wycks
wycks / gist:2906513
Created June 10, 2012 16:32 — forked from GaryJones/gist:1517555
Display some widgets from a sidebar in random order
<?php
add_filter( 'sidebars_widgets', 'gmj_shuffle_widgets' );
/**
* Shuffle ranges of widgets within a sidebar.
*
* Hat-tip to {@link http://gmj.to/op} for the original idea.
*
* @uses gmj_do_shuffle_widgets() Does the actual array manipulation.
*
@wycks
wycks / htaccess cache and stuff
Last active March 26, 2022 20:48
Boilerplate .htaccess from Paul Irish with WordPress added
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@wycks
wycks / image-loop.php
Created November 1, 2012 02:25
Image loop fallback that grabs the first image attached to post if there is no featured image.
<?php
$attachments = get_children(
array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' => 'image',
'post_parent' => get_the_ID(),
'post_status' => null,
'post_type' => 'attachment'
@wycks
wycks / placekitten.php
Created November 29, 2012 17:58 — forked from thefuxia/placekitten.php
WordPress Plugin for kitten placeholders. Defines an action and a shortcode.
<?php
/*
Plugin Name: Placekitten
Description: Shortcode [placekitten w=100 h=300 g=1 alt=kitten] and action.
Version: 1.0
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL
*/
@wycks
wycks / gist:4231143
Created December 7, 2012 06:14
The worst wordpress the_content filter ever created
<?php
function phonetic_fools($content){
$pieces = str_split($content);
foreach ($pieces as $piece => $noise) {
$fools = metaphone($noise);
$str = strtolower($fools);
<?php
/*
Plugin Name: Kill Trackbacks
Plugin URI: http://pmg.co/category/wordpress
Description: Kill all trackbacks on WordPress
Version: 1.0
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
*/
@wycks
wycks / Monokai-PhpStorm-Base.xml
Last active December 10, 2015 06:08
Monokai theme for PhpStorm that fits closer to the sublime2 soda dark version.
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Monokai-Custom" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="16" />
<option name="EDITOR_FONT_NAME" value="Consolas" />
<colors>
<option name="CARET_COLOR" value="f8f8f0" />
<option name="CARET_ROW_COLOR" value="3e3d32" />
<option name="CONSOLE_BACKGROUND_KEY" value="272822" />
<option name="GUTTER_BACKGROUND" value="272822" />
<?php
/**
* Plugin Name: (#81791) Dump cURL Request & Response
* Author: Franz Josef Kaiser
*/
add_action( 'plugins_loaded', array( 'WPSE81791_cURL', 'init' ) );
class WPSE81791_cURL
{
protected static $instance;
@wycks
wycks / image_optimize-wordpress.php
Last active December 16, 2020 01:48
Remove WordPress full size images from being inserted into a post + option to and add max size to to prevent users from inserting massive images.
<?php
/**
*
* This removes the ability to add the FULL image size into a post, it does not alter or delete the image
* Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
*
* For now we have to do it this way to make the labels translatable, see trac ref below.
*
* If your theme has $content_width GLOBAL make sure and remove it
@wycks
wycks / caching-plugins-benchmark.md
Last active December 14, 2015 00:48
Apache bench tests on WordPress

Data

###Test One low concurrency

Complete requests: 100  
Concurrency Level: 5 
HTML transferred: 1805700 bytes 

Slowest to fastest