Skip to content

Instantly share code, notes, and snippets.

@stephenh1988
stephenh1988 / inspect_hooks.php
Created March 29, 2012 15:08 — forked from franz-josef-kaiser/inspect_hooks.php
Inspect hooks in WP by adding &debug=true&hook=my_hook_name to the request URl
<?php
/**
* Plugin Name: Hook Debug Output
* Plugin URI: http://unserkaiser.com
* Description: Debug Hooked filter callback functions with adding <code>?debug=secret&hook=your_hook_name</code> to the URl
* Version: 0.1
* Author: Stephen Harris, Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Prevent loading this file directly - Busted!
@stephenh1988
stephenh1988 / wp-user-registration-query.php
Created May 8, 2012 10:01
Get all users registered between two dates
<?php
/*
* Get all users registered after $start and before $end (dates in yyyy-mm-dd format)
*
* Based on my answer to this question: http://wordpress.stackexchange.com/questions/51485/how-can-i-query-all-users-who-registered-today/51492#51492
*
* @param (string) $start - start date in yyyy-mm-dd format
* @param (string) $end - end date in yyyy-mm-dd format
*/
@stephenh1988
stephenh1988 / previous-next-sibling.php
Created June 7, 2012 10:19
Get's the next/previous page (or hierarchical cpt) with the same parent as the current post.
<?php
/*
* Gets IDs of the previous and next siblings (pages with the same parent as current post).
* Then uses wpse5422_display_prev_next to display links to them
* Must be used inside the loop.
*
* This is my solution to: http://wordpress.stackexchange.com/a/54463/9364
*/
function wpse5422_the_page_siblings(){
$post_id = get_the_ID();
@stephenh1988
stephenh1988 / frontend-publish.php
Created June 13, 2012 13:53
Provides a function to add a 'publish' link to posts for use on the front end
<?php
/*
* Provides a function to add a 'publish' link to posts.
* Use sh_frontend_publish() to display the link
*
*/
function sh_frontend_publish(){
$post_id = get_the_ID();
if( 'draft' == get_post_status($post_id) && current_user_can('edit_post',$post_id) && current_user_can('publish_posts') ){
@stephenh1988
stephenh1988 / toolbar-hooks.php
Created June 19, 2012 17:13 — forked from thefuxia/toolbar-hooks.php
T5 Toolbar hooks: Adds a toolbar item with the current page hooks.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Toolbar hooks
* Description: Adds a toolbar item with the current page hooks.
* Version: 2012.06.19
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
@stephenh1988
stephenh1988 / SH-Which-Template-Is-This.php
Created June 22, 2012 12:38
Prints in the footer the template being used for that page
<?php
/**
* Plugin Name: SH Which Template Is This
* Description: Prints in the footer the template being used for that page.
* Author: Stephen Harris contact@stephenharris.info
* Author URI: http://stephenharris.info
* License: GPL
* License URI: http://www.gnu.org/copyleft/gpl.html
*/
class SH_Which_Template_Is_This{
@stephenh1988
stephenh1988 / sh_get_plugins_by_author.php
Created July 2, 2012 16:55
Function to retrieve an array of (WordPress hosted) plug-ins by a particular author, given by their WordPress repository username
<?php
/**
* Function to retrieve an array of (WordPress hosted) plug-ins by a particular author, given by their WordPress repository username.
*
* For information on using the WordPress API see the wptuts tutorial: (link to follow)
*
*
* @param author - WordPress username
* @param fields - which fields (plug-in details) to return. See tutorial for details.
*/
@stephenh1988
stephenh1988 / lang_change_button.php
Created July 7, 2012 11:51 — forked from franz-josef-kaiser/lang_change_button.md
Change the language by the click of a button (link in the admin bar).
<?php
! defined( 'ABSPATH' ) AND exit;
/*
Plugin Name: User Language Switcher
Plugin URI: http://example.com
Description: Change the language per user, by the click of a button
Author: Stephen Harris
Author URI: http://example.com
Contributors: Franz Josef Kaiser
Version: 0.2
@stephenh1988
stephenh1988 / venue-page.php
Created October 16, 2012 22:34
A page template that lists venues with Event Organiser
<?php
/**
* Template Name: Venue Archive
* Description: A page template that lists venues with Event Organiser. Just a simple example of what
* you can do.
* @link http://www.stephenharris.info/2012/taxonomy-archives-and-venue-pages-in-event-organiser/ Related Tutorial
*
* You can add this to your theme and then create a page, selecting it as the page template. The 'content' you enter is ignored, but you could edit this to include that too.
*/
@stephenh1988
stephenh1988 / widget-calendar-link.php
Created November 22, 2012 23:23
Replaces a link on the widget calendar with one that points to the a category for one of the events running on that date.