Skip to content

Instantly share code, notes, and snippets.

@8lane
8lane / gist:9491082
Created March 11, 2014 17:45
ipb3 add to <head>
{parse addtohead="<meta name='robots' content='noindex' />", type="raw"}
@8lane
8lane / functions.php
Created March 31, 2014 10:46
Limit number of cross sells items on cart page in WooCommerce
add_filter('woocommerce_cross_sells_total', 'cartCrossSellTotal');
function cartCrossSellTotal($total) {
$total = '3';
return $total;
}
@8lane
8lane / Woocommerce - change paypal icon
Last active August 29, 2015 14:03 — forked from simonlk/Woocommerce - change paypal icon
Woocommerce - change stripe icon
// Change the WooThemes stripe plugin icon
add_filter('wc_stripe_icon', 'custom_woocommerce_paypal_icon');
function custom_woocommerce_paypal_icon( $url ) {
$url = get_bloginfo('template_url')."/assets/img/payment-icons.png";
return $url;
}
@8lane
8lane / gist:0698fcd9a762072b8815
Created July 13, 2014 15:48
Display total count of products in WooCommerce
$total_products = count( get_posts( array('post_type' => 'product', 'post_status' => 'publish', 'fields' => 'ids', 'posts_per_page' => '-1') ) );;
@8lane
8lane / gist:d0222d81362f4ea1fa2d
Created July 14, 2014 10:28
Get total amount of customers in WooCommerce
function totalCustomers() {
global $wpdb;
$result = $wpdb->get_row("
SELECT SUM(pm.meta_value) AS total_sales
FROM $wpdb->posts AS p
LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id AND pm.meta_key = 'total_sales')
WHERE p.post_type = 'product'
");
@8lane
8lane / gist:185b13aa521d349cfd1c
Created July 14, 2014 10:30
Get total amount of tickets from WooThemes SupportPress theme
function totalTickets() {
global $wpdb;
$wpdb->set_blog_id(2);
$wpdb->set_prefix($wpdb->base_prefix);
$countTickets = count( get_posts( array('post_type'=>'ticket','nopaging' => true)));
$wpdb->set_blog_id(1);
@8lane
8lane / gist:2c7a66bb8553c784158d
Created August 21, 2014 17:34
Lazy Load CSS Background Images
$(window).load(function(){
$('.lazyload').each(function() {
var lazy = $(this);
var src = lazy.attr('data-src');
lazy.css('background-image', 'url("'+src+'")');
});
});
@8lane
8lane / gist:3d75f1883525cbe540a3
Last active August 29, 2015 14:05
Set/Read a cookie with Javascript in xenForo forum software
var cookieExpiry = new Date(new Date().getTime() + 365 * 86400000); // 1 year from now
$.setCookie('Name','Value',cookieExpiry);
$.getCookie('Name');
@8lane
8lane / gist:36500183599a3cfe0686
Created September 5, 2014 23:09
Wordpress Easy Digital Downloads - Get Download tags in PHP
<?php echo get_the_term_list( get_the_ID(), 'download_tag', 'Tags: ', ', ', '') ?>
@8lane
8lane / forum_only
Last active August 29, 2015 14:09
Xenthemes Boilerplate Hero Message Forum Only
<!-- :: Xenthemes Message :: -->
<xen:if is="{$contentTemplate} == 'forum_list'">
<xen:if is="!{$visitor.user_id} && @xt_message_guest == 1">
<xen:include template="xt_message_guest" />
</xen:if>
<xen:if is="{$visitor.user_id} && @xt_message_member == 1">
<xen:include template="xt_message_member" />
</xen:if>
</xen:if>