Skip to content

Instantly share code, notes, and snippets.

@marco-s
marco-s / gist:3005294
Created June 27, 2012 16:40 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@marco-s
marco-s / mobile.php
Created June 25, 2012 01:43 — forked from itsananderson/mobile.php
Switch between two themes, depending on what domain is used to access a site
<?php
/*
* This solution assumes you've already set up your site so that the site domain is
* your "normal" (non-mobile) domain, and your theme is your non-mobile theme.
*
* In short, what it does it check to see if the site is being accessed through the
* mobile domain. If it is, the mobile theme is used instead of the normal theme, and
* all links point to the mobile domain (so navigatiion doesn't take visitors to the
* regular domain.
# custom login link
RewriteRule ^login$ http://localhost/whitelabel/wp-login.php [NC,L]
@marco-s
marco-s / gist:2151833
Created March 21, 2012 19:37 — forked from jdevalk/gist:1918689
Turn a spiderable list of links into a dropdown + a go button with jQuery
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
// Inspiration partly from: http://stackoverflow.com/questions/1897129
jQuery(document).ready(function($) {
$('ul.dropdown').each(function(){
var list = $(this);
var select = $(document.createElement('select'))
.attr('id',$(this).attr('id'))
@marco-s
marco-s / gist:2151809
Created March 21, 2012 19:35 — forked from jdevalk/gist:1565059
oembed function to use content_width appropriately
<?php
function yoast_oembed_dataparse( $html, $data, $url ) {
global $content_width;
preg_match( '/width="(\d+)"/', $html, $matches );
$width = $matches[1];
preg_match( '/height="(\d+)"/', $html, $matches );
$height = $matches[1];
$aspect_ratio = $width / $height;
@marco-s
marco-s / wordstream-api-class.php
Created March 21, 2012 19:35 — forked from jdevalk/wordstream-api-class.php
WordStream API interface class for WordPress
<?php
/**
* Class containing all the functionality to get data from the WordStream API
*
* @link http://api.wordstream.com/doc/introduction
*
* @author Joost de Valk <[email protected]>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
@marco-s
marco-s / gist:2151785
Created March 21, 2012 19:33 — forked from jdevalk/gist:1347575
Function to move searches for non-post post-types / taxonomies to their respective archives.
<?php
function yoast_change_template( $template ) {
global $wp_query;
if ( !isset($wp_query->query_vars['taxonomy']) )
return $template;
$taxonomy = get_taxonomy( $wp_query->query_vars['taxonomy'] );
if ( is_search() && count( $taxonomy->object_type ) > 0 && !in_array( 'post', array_values($taxonomy->object_type) ) ) {
set_query_var('post_type', $taxonomy->object_type[0]);
$newtemplate = get_archive_template();
@marco-s
marco-s / image-shortcode.php
Created March 13, 2012 18:29 — forked from kovshenin/image-shortcode.php
Image shortcode for WordPress
<?php
/**
* Image shortcode callback
*
* Enables the [kovshenin_image] shortcode, pseudo-TimThumb but creates resized and cropped image files
* from existing media library entries. Usage:
* [kovshenin_image src="http://example.org/wp-content/uploads/2012/03/image.png" width="100" height="100"]
*
* @uses image_make_intermediate_size
*/
@marco-s
marco-s / install-phpunit.sh
Created February 13, 2012 22:47 — forked from scribu/install-phpunit.sh
PHPUnit install script on Ubuntu
#!/bin/bash
sudo apt-get install php-pear
sudo pear upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
@marco-s
marco-s / test-list-tables.php
Created February 13, 2012 22:47 — forked from scribu/test-list-tables.php
WP Admin List Tables hooks
<?php
//////////////////
// Screens
//////////////////
// Posts
foreach ( array(
'posts', 'pages', 'recipe_posts',
'edit-post', 'edit-page', 'edit-recipe',