Skip to content

Instantly share code, notes, and snippets.

View thomasgriffin's full-sized avatar
👋

Thomas Griffin thomasgriffin

👋
View GitHub Profile
if ( version_compare( PARENT_THEME_VERSION, '1.7.9', '>' ) ) {
include_once( CHILD_DIR . '/lib/admin/admin.php' );
include_once( CHILD_DIR . '/lib/admin/front.php' );
include_once( CHILD_DIR . '/lib/widgets/radio-latest-news-widget.php' );
}
<form method="post" class="wl_add_item">
<input type="hidden" name="wl_add_quantity" value="1" />
<input type="hidden" name="wl_add_post_id" value="107" />
<input type="image" title="Increase quantity" src="http://npp-dev.se/hagabergs/wp-content/plugins/wishlist/add.png" value="submit" />
</form>
<form method="post" class="wl_remove_item">
<input type="hidden" name="wl_remove_quantity" value="1" />
<input type="hidden" name="wl_remove_post_id" value="107" />
<input type="image" title="Decrease quantity" src="http://npp-dev.se/hagabergs/wp-content/plugins/wishlist/remove.png" value="submit" />
<?php
add_action( 'wp_ajax_myajax-submit', 'tgm_process_ajax' );
add_action( 'wp_ajax_nopriv_myajax-submit', 'tgm_process_ajax' );
function tgm_process_ajax() {
$data = array(
'quantity' => $_POST['wl_quantity'],
'post_id' => $_POST['wl_post_id']
);
<?php
add_action( 'wp_ajax_myajax-submit', 'tgm_process_ajax' );
add_action( 'wp_ajax_nopriv_myajax-submit', 'tgm_process_ajax' );
function tgm_process_ajax() {
$data = array(
'quantity' => $_POST['wl_quantity'],
'post_id' => $_POST['wl_post_id']
);
jQuery(document).ready(function($) {
$('.wl_add_item, .wl_remove_item').submit(function(e) {
e.preventDefault();
/** Determine if we are adding or removing items and build variables from there */
var current_object = $(this); // Get the current object - we will use it when appending stuff
var action_type = $(this).attr('class');
if ( 'wl_add_item' == action_type ) {
var process_this = 'add';
var quantity = $(this).find('input[name="wl_add_quantity"]').val();
$terms = wp_get_object_terms( $post->ID, 'sermon-series' );
$args = array(
'post_type' => 'sermons',
'posts_per_page' => 2,
'tax_query' => array(
array(
'taxonomy' => 'sermon-series',
'field' => 'id',
'terms' => $terms[0]->term_id
)
social_tools: '<div class="pp_social"><div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div>',
<?php
global $current_screen;
if ( 'YOUR POST TYPE HERE' == $current_screen->post_type && 'post' == $current_screen->base )
// Do something here
$('.theme-hover .thumb').on({
mouseenter: function() {
$(this).parent().parent().find('.preview-image').show();
},
mouseleave: function () {
$(this).parent().parent().find('.preview-image').hide();
}
});
<?php
/** Store oEmbed results in a transient */
if ( false === ( $tweets = get_site_transient( 'tgm_get_tweets' ) ) {
$tweets = wp_oembed_get( $url, $args );
if ( ! $tweets ) // wp_oembed_get returns false on failure
$tweets = *get your old tweets from here*;
set_site_transient( 'tgm_get_tweets', $tweets, 60*60*24 );
}