Skip to content

Instantly share code, notes, and snippets.

View anandkumar's full-sized avatar

Anand Kumar anandkumar

View GitHub Profile
@anandkumar
anandkumar / functions.php
Created January 29, 2014 15:21
EDD Prevent Double Purchase
<?php
// EDD Prevent Double Purchase
function pw_edd_prevent_double_purchase( $valid_data, $post_data ) {
$cart_items = edd_get_cart_contents();
foreach( $cart_items as $item ) {
if( edd_has_user_purchased( get_current_user_id(), $item['id'] ) ) {
edd_set_error( 'double_purchase', __( 'You may not purchase this item again until your subscription expires', 'edd' ) );
}
}
@anandkumar
anandkumar / review-meta-box.php
Created May 15, 2014 11:03
Add support for multiple custom post type - Author hReview Plugin
<?php
// Add meta box to all post_types
// Customised by Anand Kumar @blogsynthesis.com
function ta_mytheme_post_add_box() {
global $wpar_meta_box;
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
add_meta_box($wpar_meta_box['id'], $wpar_meta_box['title'], 'ta_mytheme_post_show_box', $post_type, $wpar_meta_box['context'], $wpar_meta_box['priority']);
Hello World!
@anandkumar
anandkumar / functions.php
Created October 5, 2014 14:30
Remove bbpress breadcrumb
<?php
// Do not add above line.
add_filter('bbp_no_breadcrumb', function($arg) { return true; } );
<?php
// add ie conditional html5 shim to header
function _s_add_ie_html5_shim () {
echo '<!--[if lt IE 9]>';
echo '<script src="' . get_template_directory_uri() . '/js/html5.js"></script>';
echo '<![endif]-->';
}
add_action('wp_head', '_s_add_ie_html5_shim');
@anandkumar
anandkumar / functions.php
Created April 20, 2015 19:10
Hide bbPress forum replies with mesage
<?php
// Do not copy opening php tag
function bb_auth_reply_view( $reply_id ) {
$reply_id = bbp_get_reply_id( $reply_id );
// Check if password is required
if ( post_password_required( $reply_id ) )
return get_the_password_form();
@anandkumar
anandkumar / gist:3863360
Created October 10, 2012 05:37
GoogleTag Manager on Thesis Theme
/**
* Add Add Google Tag Manager script on Thesis Theme Framework
*
* @author Anand Kumar
* @link http://www.blogsynthesis.com/add-google-tag-manager-to-wordpress/#thesis-theme-framework
*
*/
function limit_front_page() {
global $query_string;
@anandkumar
anandkumar / gist:4125748
Created November 21, 2012 16:14
Facebook comments on Genesis Framework based theme
/*** Facebook Comment for Single Posts ***/
add_action('genesis_before_comments', 'facebook_comments');
/*** More info at www.blogsynthesis.com/?p=892 ***/
function facebook_comments() {
if (is_single()) { ?>
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="5" data-width="600"></div>
<?php }
}
<script type="text/javascript">
google_ad_client = "ca-publisher-id",
if (window. innerWidth> = 800) {
google_ad_slot = " ad-unit-1 ";
google_ad_width = 728;
google_ad_height = 90;
} Else if (window.innerWidth <400) {
google_ad_slot = " ad-unit-2 ";
google_ad_width = 300;
google_ad_height = 250;
@anandkumar
anandkumar / functions.php
Created December 15, 2015 05:20
remove pingback - wordpress
<?php
// Do not copy starting php tag
function remove_x_pingback($headers) {
unset($headers['X-Pingback']);
return $headers;
}
add_filter('wp_headers', 'remove_x_pingback');