Skip to content

Instantly share code, notes, and snippets.

View matgargano's full-sized avatar

Mat Gargano matgargano

View GitHub Profile
@matgargano
matgargano / test-demo-plugin.php
Created September 22, 2014 15:33
Sample Tests for WordPress Unit Test Tutorial
<?php
class Demo_Test extends WP_UnitTestCase {
/**
* @covers Demo_Plugin::init
*/
function test_init() {
$demo_plugin = $this->getMockBuilder( 'Demo_Plugin' )
@matgargano
matgargano / bbpress-forum-only-open.php
Last active August 29, 2015 14:06
bbpress forum posts that are open
<?php
// only query open forum post types on the forum archive page
add_action( 'pre_get_posts', function($query){
if ( ! is_admin()
&& ! $query->is_search()
&& $query->is_main_query()
&& is_post_type_archive('forum')
@matgargano
matgargano / custom-page-template-metabox.php
Created December 9, 2014 15:22
add metabox to a custom page template
<?php
class foo {
public static function init(){
add_action('init', array(__CLASS__, 'team_page_metabox');
}
/**
* Add meta elements if the post type 'page' uses the offering template
@matgargano
matgargano / meta.php
Created January 9, 2015 14:24
Issue updating backbone pane in upload script
<?php
add_action( 'save_post', 'myplugin_save_meta_box_data' );
add_action( 'admin_enqueue_scripts', function () {
wp_enqueue_media();
} );
add_action( 'add_meta_boxes', 'myplugin_add_meta_box' );
<?php
class Incrementer {
private $value = 0;
public function reset() {
$this->value = 0;
rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
<?php
$transient_key = 'brand_slider';
$output = get_transient( $transient_key );
if ( false === $results ) :
$args = array(
'numberposts' => -1,
'post_type' => 'program',
'meta_key' => 'show_in_brand_slider',
Class Offering {
use get;
}
@matgargano
matgargano / _col-xl.less
Created July 1, 2015 21:54
extra large col-xl bootstrap
// XL screen
@screen-xl: 1600px;
@screen-xl-min: @screen-xl;
@screen-xl-hughdesktop: @screen-xl-min;
// So media queries don't overlap when required, provide a maximum
@screen-lg-max: (@screen-xl-min - 1);
//Container sizes
// Large screen / wide desktop
var app = app || {};
(function () {
app.post = Backbone.Model.extend({
defaults: {
ID: null,
status: '(default status)',