Skip to content

Instantly share code, notes, and snippets.

View ericandrewlewis's full-sized avatar

Eric Lewis ericandrewlewis

View GitHub Profile
@ericandrewlewis
ericandrewlewis / gist:4047805
Created November 9, 2012 19:49
Retrieve total times an activity has been logged
$total = count( get_posts( array(
'post_type' => 'mvp-card',
'posts_per_page' => - 1,
'suppress_filters' => false,
'connected_direction' => 'from',
'connected_type' => 'activity-to-mvp-card',
'connected_items' => $activity_id
) ) );
add_action( 'init', 'baja_check_search_box' );
function baja_check_search_box() {
if ( empty( $_POST['search_box'] ) )
return;
wp_redirect( site_url( '$_POST['region'] . '/' . $_POST['post-type'] ) );
die;
}
$(document).ready(function() {
$('a').click( function() {
if ( $.attr(this, 'href').indexOf( '#' ) != 0 )
return;
var scrollTo = $( $.attr(this, 'href') ).offset().top;
scrollTo -= $( '.site-header-container' ).height();
$('html, body').animate({
scrollTop: scrollTo
}, 500);
return false;
function pank_wp_reset_postdata( $query ) {
if ( !is_a($query, 'WP_Query' ) )
return false;
if ( !empty($query->post) ) {
$GLOBALS['post'] = $query->post;
setup_postdata($query->post);
}
}
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'subscription_order_payment_onhold_order_status', 10, 2 );
/**
* Catch new subscription orders, and put the order on-hold by default.
*/
function subscription_order_payment_onhold_order_status( $order_status, $order_id ) {
$order = new WC_Order( $order_id );
if ( 'processing' != $order_status || ( 'on-hold' != $order->status && 'pending' != $order->status && 'failed' != $order->status ) )
if ( file_exists( $medium ) )
/**
* File to delete
*
* @since 2.8.0
*/
@unlink( apply_filters( 'wp_delete_file', $medium ) );
egrep -R -l '(do_action|apply_filters)' * | subl
o wp-activate.php
o wp-admin/admin-ajax.php
o wp-admin/admin-footer.php
o wp-admin/admin-header.php
o wp-admin/admin-post.php
o wp-admin/admin.php
o wp-admin/async-upload.php
o wp-admin/comment.php
<!--[if lte IE 9]>
// ie stylesheet
<!--[endif]>
<!--[if !lte IE 9]>
// regular stylesheet
<!--[endif]>
<?php
add_action( 'parse_query', 'maybe_parse_query_for_find_posts' );
function maybe_parse_query_for_find_posts( $query ) {
if ( empty( $_REQUEST['action'] ) || $_REQUEST['action'] != 'find_posts' )
return;
$query->set( 'order', 'something else' );
}
# Leave a comment on this post with the file(s)* you’re about to edit (check the comments first to make sure it’s not already being edited)
# <a href="core.trac.wordpress.org/newticket">Create a new ticket on trac</a> for the file. Follow the format for the title "Hooks documentation in path/to/file.php". Assign the ticket to the "Inline Docs" component
# Edit fervently and make a patch quickly
# Rinse and repeat!