Skip to content

Instantly share code, notes, and snippets.

@artboard-studio
artboard-studio / content-single-product.php
Last active December 23, 2015 15:49
WC single products next prev link
<?php previous_post_link('&laquo; %link'); ?>
<?php next_post_link('%link &raquo;'); ?>
@artboard-studio
artboard-studio / tabs-rename-filter.php
Last active December 23, 2015 15:59
renaming woocommerce tabs the right way
<?php
add_filter( 'woocommerce_product_tabs', 'capitalh_rename_tabs', 98 );
function capitalh_rename_tabs( $tabs ) {
if ( isset($tabs['description']) ) {
$tabs['description']['title'] = __( 'New Title', 'une_boutique' ); // Rename the description tab
}
if ( isset($tabs['reviews']) ) {
@artboard-studio
artboard-studio / thumbnail.click.js
Created September 22, 2013 14:45
update woocommerce main product image on thumbnail click
jQuery(document).ready(function($) {
"use strict";
$(document).on('click','.thumbnails .zoom', function(){
var photo_fullsize = $(this).find('img').attr('src').replace('-150x180','');
$('.woocommerce-main-image img').attr('src', photo_fullsize);
return false;
});
});
@artboard-studio
artboard-studio / plugin-activated.php
Created September 27, 2013 14:41
WordPress: if plugin is installed and activated
<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?>
<?php is_plugin_active($plugin) ?>
// example:
<?php
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
If (is_plugin_active('plugin-directory/plugin-file.php')) {
//plugin is activated
}
@artboard-studio
artboard-studio / twitter-feed-shortcode.php
Created October 5, 2013 14:18
Twitter Feed Shortcode
function mb_twitter($atts, $content = null ){
extract(shortcode_atts(array('count'=>'3','user'=>''), $atts));
//Cache user and then return last tweeted items (3 by default)
$via = '<div class="tweet-via"><a href="https://twitter.com/intent/user?screen_name='.$user.'" target="_blank" rel="nofollow">@'.$user.'</a></div>';
return '<div class="twitter-feed"><ul id="twitter_update_list"><li>Twitter feed loading</li></ul>'.$via.'</div><script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name='.$user.'&amp;callback=twitterCallback2&amp;count='.$count.'"></script>';
}
add_shortcode('mb_twitter', 'mb_twitter');
// use this shortcode [mb_tweets count=5 user="OnlineMarket"]
<style>
body { margin: 0; padding: 0}
#container {
position: absolute;
top: 30px; left: 50px;
bottom: 30px; right: 50px;
border: 1px solid #ccc
}
#container > div {
@artboard-studio
artboard-studio / wp_get_user.php
Created November 29, 2013 16:10
Wordpress get user name
<?php
$current_user = wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
* return;
*/
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
@artboard-studio
artboard-studio / sidebar_column_counter.php
Created December 21, 2013 11:07
Sidebar Column Counter
<?php
/**
* Count the number of widgets in a sidebar
* Works for up to ten widgets
* Usage <?php ctm_sidebar_class( 'promo' ); ?> where promo is the name of the sidebar
*/
function ctm_sidebar_class( $sidebar_name ) {
global $sidebars_widgets;
$count = count ($sidebars_widgets[$sidebar_name]);
@artboard-studio
artboard-studio / initials-thumb.css
Last active August 9, 2017 09:16
Initials Thumbnail for WordPress
// Capital Framework Initials Thumbnail
.cfw-initails-thumbnail {
background: #d8d8d8;
color: #333;
width: 45px;
height: 45px;
display: inline-block;
border-radius: 50%;
margin-right: 15px;
@artboard-studio
artboard-studio / stackblur_filter.class.js
Last active June 14, 2019 23:56
Stack blur filter for fabricjs
/**
* Stack blur filter for fabricjs
* Example:
* obj.filters.push(new fabric.Image.filters.StackBlur(6));
* obj.applyFilters(canvas.renderAll.bind(canvas));
*
* Heavily inspired by:
* https://gist.github.com/pierrickouw/2ab679159beee9d80ca6
* http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
* uses stackBlurCanvasRGBA function but could be swapped be stackBlurCanvasRGB