Skip to content

Instantly share code, notes, and snippets.

@gmazzap
gmazzap / loop.php
Last active August 29, 2015 14:07 — forked from tomjn/loop.php
<?php
array_walk($GLOBALS['wp_query']->posts, function($post, $i, $wp_query) {
$GLOBALS['post'] = $post;
$wp_query->the_post();
// loop code
the_title();
the_content();
@domenic
domenic / .bashrc
Last active September 1, 2015 17:50
.bashrc with GitHub PR function
pr () {
git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 --force
git checkout -b pr/$1 origin/pr/$1
git rebase master
git checkout master
git merge pr/$1 --ff-only
}
@mfields
mfields / gist:1061846
Created July 3, 2011 00:53
Simple Github commit API shortcode for WordPress
<?php
/*
Plugin Name: Mfields Github Shortcode
Plugin URI: null
Description: Display recent commits from a Github repository.
Version: 0.1
Author: Michael Fields
Author URI: http://wordpress.mfields.org/
License: GPLv2 or later
@aaroncampbell
aaroncampbell / expand-admin-menus.php
Created October 12, 2011 15:23
WordPress Expanded Admin Menus
<?php
/**
* Plugin Name:
* Plugin URI: http://xavisys.com/wordpress-plugins/expanded-admin-menus/
* Description: Forces all admin menus to be expanded all the time
* Version: 0.0.1
* Author: Aaron D. Campbell
* Author URI: http://xavisys.com/
*/
@ocean90
ocean90 / scrollback.php
Created November 28, 2011 18:47
WP Editor: Scroll to old position after saving or updating a post
<?php
/**
* Adds a hidden input field for scrolltop value.
*
* @return void
*/
function ds_scrollto_input() {
$position = ! empty( $_GET['scrollto'] ) ? $_GET['scrollto'] : 0;
printf( '<input type="hidden" id="scrollto" name="scrollto" value="%d"/>', esc_attr( $position ) );
@ocean90
ocean90 / fixit.php
Created December 1, 2011 10:25
Fix Debug Bar item in WordPress 3.3
<?php
// See http://wordpress.org/extend/plugins/debug-bar/
remove_action( 'admin_bar_menu', array( 'Debug_Bar', 'admin_bar_menu' ), 1000 );
add_action( 'admin_bar_menu', 'ds_fix_debug_bar_menu', 5 );
function ds_fix_debug_bar_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu( array(
'parent' => 'top-secondary',
'id' => 'debug-bar',
@mikeschinkel
mikeschinkel / sr-file-changed.php
Created January 18, 2012 00:27
File Changed function from Sunrise.
<?php
/**
* Used where you might want to use an activation function but where it's not convenient or possible (like in a theme.)
* Accepts __FILE__ for the a unique key to identify the file.
*
* @param string $file
* @return bool
*
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel/
@tomjn
tomjn / junction-fix.php
Created June 22, 2012 10:15
WP Junction fix
<?php
/*
Plugin Name: Junction fixes for plugins
Plugin URI: http://interconnectit.com/
Description: Junctioning files into the WordPess plug-ins folder causes problems with php 5.3 for plugin_url, this tries to fix it. Place in the wp-content/mu-plugins folder so it loads before all other plugins.
Author: James R Whitehead
Version: 0.0.0.0.0.0.2
Author URI: http://interconnectit.com
*/
@stephenharris
stephenharris / eo-theme-direct.php
Created September 11, 2013 19:01
Register a template location with Event Organiser for your theme
<?php
/**
* Registers the directory "[child-theme-dir]/event-organiser" as a template location for
* Event Organiser. EO will look there when looking for the plug-in template files (e.g. single-event.php, archive-event.php, etc )
*
*/
function mytheme_register_eventorganiser_stack( $stacks ){
//$stacks is an array of (absolute) directory paths. EO will look in the order
//in which they appear in the array
@franz-josef-kaiser
franz-josef-kaiser / jquery_in_viewport.php
Created March 22, 2011 23:21
load jQuery in WordPress only when comments are inside the viewport
<?php
add_action ( 'wp_head', 'add_jquery_when_comments_in_viewport', 11 );
function add_jquery_when_comments_in_viewport()
{
?>
<script type="text/javascript">
/* <![CDATA[ */
function jquery_for_comments_onLoad() {
var element = document.getElementById( "comments" ),
current = document.body.clientHeight+document.body.scrollTop,