Skip to content

Instantly share code, notes, and snippets.

View Kenshino's full-sized avatar

Jon Ang Kenshino

View GitHub Profile
@Kenshino
Kenshino / email_order.php
Last active April 8, 2016 05:41 — forked from mikejolley/gist:1965842
version of email_order_items_table for use outside of the class
<?php
$return = '';
foreach( $order->get_items() as $item ) :
$_product = $order->get_product_from_item( $item );
$file = $sku = $variation = $image = '';
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $_product->id ), 'thumbnail');
function wingz_exhibitor_filter(){
global $wp_query;
$tax_query = array( 'relation' => 'AND' );
if ( isset( $_GET['s'] ) ):
$search = sanitize_text_field( $_GET['s'] );
else:
$search = '';
endif;
if ( isset( $_GET['exhibitor_type'] ) && $_GET['exhibitor_type'] != '' ):
@Kenshino
Kenshino / Related Posts Shortcode
Last active December 2, 2017 19:42
Related Posts Shortcode
@Kenshino
Kenshino / gist:81136b4e179359dec328
Last active August 29, 2015 14:18
Video replacement for Featured Image
<?php
add_action( 'woocommerce_product_options_general_product_data', 'catalog_add_video_field' );
add_action( 'woocommerce_process_product_meta', 'catalog_save_video_url' , 10, 2 );
add_filter( 'woocommerce_single_product_image_html', 'catalog_set_featured_video' , 20 );
function catalog_add_video_field() {
echo '<div class="options_group">';
<?php
/*
* Plugin Auto Updates Whitelist
* Allows Forced Updates for listed Plugin Slugs
*/
function pb_auto_update_whitelist_plugins( $update, $item ) {
// Array of plugin slugs to whitelist
$plugins = array (
'jetpack',
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
@Kenshino
Kenshino / gist:1f3d7943a1bc46ead5f4
Created September 29, 2014 16:23
page sub menu functions
function get_top_parent_page_id() {
global $post;
// Check if page is a child page (any level)
if ($post->ancestors) {
// Grab the ID of top-level page from the tree
return end($post->ancestors);
} else {
// Page is the top level, so use it's own id
return $post->ID;
}
@Kenshino
Kenshino / gist:9cf053d4845e7696ff59
Created August 22, 2014 03:06
Unset product post type from categories
function unset_preorder_terms( $product ) {
if ( is_object( $product ) )
$product = $product->id;
$terms = wp_get_post_terms($product, 'product_cat');
$term_ids = array();
foreach ( $terms as $term ){
if ( strpos($term->slug, 'pre-order') === false ){
$term_ids[] = $term->term_id;
}
jQuery(document).ready(function ($) {
// Set the original handler, since we override Core, we need to fall back to core if we're not doing stuff our selves
var _custom_media = true,
_orig_wp_media_insert = wp.media.editor.insert;
// Any input field wit hthe class 'theme_custom_media' will trigger our custom behavior
$(".theme_custom_media").click(function (e) {
var button = $(this);
var id = button.attr('id').replace('_button', '');
<?php
/**
* Class My_Shortcode
*/
class My_Shortcode {
/**
* The shortcode attributes
*