Skip to content

Instantly share code, notes, and snippets.

@bekarice
bekarice / edd-share-buttons-after-title.php
Last active August 29, 2015 14:12
Adds JP sharing buttons after the EDD download title
/**
* Adds sharing buttons after the download title
* Tutorial: http://www.sellwithwp.com/add-social-sharing-buttons-to-easy-digital-downloads/
**/
function add_edd_share_buttons() {
if ( function_exists( 'sharing_display' ) ) {
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
echo sharing_display();
}
@bekarice
bekarice / edd-share-buttons-before-pricing.php
Last active August 29, 2015 14:12
Adds JP sharing buttons before EDD download pricing / purchase button
/**
* Adds sharing buttons before pricing options (variable) or purchase button (simple)
* Tutorial: http://www.sellwithwp.com/add-social-sharing-buttons-to-easy-digital-downloads/
**/
function add_edd_share_buttons() {
global $post;
if ( is_singular( 'download' ) && function_exists( 'sharing_display' ) ) {
@bekarice
bekarice / edd-share-buttons-after-image.php
Last active August 29, 2015 14:12
Adds JP sharing buttons after image (if set) or title
/**
* Adds sharing buttons after featured image (if set) or after title (if not)
* Tutorial: http://www.sellwithwp.com/add-social-sharing-buttons-to-easy-digital-downloads/
**/
function add_edd_share_buttons() {
if ( is_singular( 'download' ) && function_exists( 'sharing_display' ) ) {
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
@bekarice
bekarice / edd-share-buttons-before-purchase.php
Last active August 29, 2015 14:12
Adds JP sharing buttons before the EDD purchase button on single download pages
/**
* Adds sharing buttons before purchase button
* Tutorial: http://www.sellwithwp.com/add-social-sharing-buttons-to-easy-digital-downloads/
**/
function add_edd_share_buttons() {
if ( function_exists( 'sharing_display' ) && is_singular( 'download' ) ) {
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
echo sharing_display();
}
@bekarice
bekarice / exclude-categories-rp4wp.php
Last active August 29, 2015 14:13
Exclude categories from Related Posts for WordPress
/**
* Removes RP4WP display when a post is in a certain category
**/
function br_disable_rp4wp_category( $content ) {
if ( in_category( 'excluded-category-slug' ) ) {
add_filter( 'rp4wp_append_content', '__return_false');
}
return $content;
@bekarice
bekarice / wc-memberships-member-product-notice.php
Created August 31, 2015 07:08
Dev Docs Example: WooCommerce Memberships product notice for non-members
<?php
// Display a top notice to non-members for members-only products
function sv_members_only_product_notice() {
if ( ! function_exists( 'wc_memberships' ) ) {
return;
}
$user_id = get_current_user_id();
@bekarice
bekarice / patch-wpml-wc-rest-api-issue.php
Created February 19, 2015 22:06
Forces WPML language settings to stop breaking the WooCommerce REST API
function wpml_wc_api_home_url( $url, $path, $orig_scheme, $blog_id ) {
global $sitepress;
if ( isset( $sitepress ) && 0 === strpos( $path, 'wc-api/' ) ) {
$url = $sitepress->convert_url( str_replace( $path, '', $url ), $sitepress->get_default_language() );
$url = untrailingslashit( $url ) . '/' . ltrim( $path, '/' );
}
return $url;
@bekarice
bekarice / wc-memberships-delayed-content-message.php
Last active September 16, 2015 18:11
Dev Docs Example: WooCommerce Memberships Filter Delayed Content Message
<?php
// Change the delayed content message for the "Projects" post type
function sv_filter_content_delayed_message( $message, $post_id, $access_time ) {
if ( 'project' === get_post_type( $post_id ) ) {
$message = 'This project is part of your membership, but not yet! You will gain access on {date}';
}
return $message;
}
add_filter( 'wc_memberships_get_content_delayed_message', 'sv_filter_content_delayed_message', 10, 3 );
@bekarice
bekarice / wc-freshbooks-change-payment-type.php
Created September 25, 2015 19:05
Changes the way payment types from WooCommerce FreshBooks are shown in FreshBooks
<?php
// Changes PayPal Digital Goods to "PayPal" in FreshBooks
// Can be used with any payment method ID
function wc_freshbooks_payment_type( $type, $payment_method ) {
if ( 'paypal_digital_goods' === $payment_method ) {
$type = 'PayPal';
}
@bekarice
bekarice / wc-braintree.css
Created November 6, 2015 21:33
WooCommerce Braintree Storefront Theme CSS
/* Improve Braintree checkout form */
#wc_braintree_paypal_container {
height: 55px;
}
#payment .payment_methods li #wc_braintree_paypal_container img {
max-height: 5em;
}
#wc_braintree_paypal_container .paypal-button.paypal-style-checkout {