Skip to content

Instantly share code, notes, and snippets.

🎧
Focusing

Hooman Askari human-a

🎧
Focusing
Block or report user

Report or block human-a

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@human-a
human-a / stackblur_filter.class.js
Last active Jun 14, 2019
Stack blur filter for fabricjs
View stackblur_filter.class.js
/**
* 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
@human-a
human-a / initials-thumb.css
Last active Aug 9, 2017
Initials Thumbnail for WordPress
View initials-thumb.css
// Capital Framework Initials Thumbnail
.cfw-initails-thumbnail {
background: #d8d8d8;
color: #333;
width: 45px;
height: 45px;
display: inline-block;
border-radius: 50%;
margin-right: 15px;
View sidebar_column_counter.php
<?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]);
@human-a
human-a / wp_get_user.php
Created Nov 29, 2013
Wordpress get user name
View wp_get_user.php
<?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 />';
View equal-width-columns.html
<style>
body { margin: 0; padding: 0}
#container {
position: absolute;
top: 30px; left: 50px;
bottom: 30px; right: 50px;
border: 1px solid #ccc
}
#container > div {
View twitter-feed-shortcode.php
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"]
@human-a
human-a / plugin-activated.php
Created Sep 27, 2013
WordPress: if plugin is installed and activated
View plugin-activated.php
<?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
}
@human-a
human-a / thumbnail.click.js
Created Sep 22, 2013
update woocommerce main product image on thumbnail click
View thumbnail.click.js
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;
});
});
@human-a
human-a / tabs-rename-filter.php
Last active Dec 23, 2015
renaming woocommerce tabs the right way
View tabs-rename-filter.php
<?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']) ) {
@human-a
human-a / content-single-product.php
Last active Dec 23, 2015
WC single products next prev link
View content-single-product.php
<?php previous_post_link('&laquo; %link'); ?>
<?php next_post_link('%link &raquo;'); ?>
You can’t perform that action at this time.