Skip to content

Instantly share code, notes, and snippets.

View sc0ttkclark's full-sized avatar
🍕
Working hard reviewing and deploying code

Scott Kingsley Clark sc0ttkclark

🍕
Working hard reviewing and deploying code
View GitHub Profile
@nb
nb / bootstrap-sample.php
Created August 5, 2012 19:27
Sample plugin tests config files
<?php
define( 'WP_TESTS_PATH', '<Enter the path to your unit-tests checkout>' );
$GLOBALS['wp_tests_options'] = array(
'active_plugins' => array( '<plugindir/<plugin>.php' ),
);
require rtrim( WP_TESTS_PATH, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . 'bootstrap.php';
@wesbos
wesbos / gist:3744393
Created September 18, 2012 17:15
Use latest version of jquery in wordpress
/* pop me into your functions.php */
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://code.jquery.com/jquery-git.js"), false, '1.8.2');
wp_enqueue_script('jquery');
@raybrownco
raybrownco / wp-pods-vs-ee.php
Created March 13, 2011 16:57
This file is a comparison between WordPress/Pods and ExpressionEngine. It shows the syntax required to display a list of three featured books on a site's homepage.
<!-- Featuring three books on a site's homepage -->
<!-- The Pods/WordPress way -->
<ul id="featured-books">
<?php
$book = new Pod('book');
$params = array(
'where'=>'t.show_on_homepage = 1',
@benfavre
benfavre / pods2.x_gravityforms_helper.php
Last active December 10, 2015 05:58 — forked from anonymous/gravityforms.php
Pods 2.0 Gravity Forms input helper. Use a text or code field.
<?php
wp_enqueue_style( 'pods-select2' );
wp_enqueue_script( 'pods-select2' );
$attributes = array();
$attributes[ 'tabindex' ] = 2;
$pick_limit = (int) pods_var( 'pick_limit', $options, 0 );
$name .= '[]';
$attributes[ 'multiple' ] = 'multiple';
if ( !is_array( $options[ 'data' ] ) && false !== $options[ 'data' ] && 0 < strlen( $options[ 'data' ] ) )
<script type="text/html" id="tmpl-soliloquy-attachment-fields">
<label class="setting" data-setting="soliloquy_link">
<div><# console.log(data) #></div>
<span><?php echo Tgmsp_Strings::get_instance()->strings['image_link']; ?></span>
<input type="text" value="{{ data.soliloquy_link }}" />
</label>
</script>
<?php
/*
* Plugin Name: Hacky Taxonomy Archives
* Description: Don't use this on a live site, plz. Proof of concept for Aaron Holbrook.
* Author: Andrew Nacin
*/
add_action( 'template_redirect', function() {
global $wp_rewrite;
$taxonomy = 'fruits';
@jtsternberg
jtsternberg / expand_code.php
Created October 2, 2013 14:38
A `print_r` or `var_dump` replacement that expands the variable into valid PHP code. (for copy/pasting back into the project, etc)
<?php
/**
* A `print_r` or `var_dump` replacement that expands the variable into valid PHP code.
* @uses var_export
* @param array|object $array_or_object $variable to expand/view
* @param boolean $echo Whether to return or display the data
* @return string Variable representation that is valid PHP code.
*/
function expand_code( $array_or_object, $echo = true ) {
@sc0ttkclark
sc0ttkclark / wp-db-_insert_replace_helper.php
Created December 5, 2013 21:16
Add bulk insert/replace capability to wpdb::insert / wpdb::replace without adding unnecessary overhead for normal single inserts
<?php
/**
* Helper function for insert and replace.
*
* Runs an insert or replace query based on $type argument.
*
* @access private
* @since 3.0.0
* @see wpdb::prepare()
* @see wpdb::$field_types
@ericandrewlewis
ericandrewlewis / gist:8290246
Last active January 2, 2016 10:29
WordPress Post Meta ideas
<?php
/**
* Post Meta Box view/controller class.
*
* Extends from a form object base class.
*
* Creates a meta box. Fields can be related to the meta box, but
* all business logic lives within the field object.
*/
<?php
class CWS_Jetpack_Modules {
function __construct() {
add_filter( 'option_jetpack_active_modules', array( $this, 'active_modules' ) );
}
function active_modules( $modules ) {
$allowed_modules = array(
'enhanced-distribution',