Skip to content

Instantly share code, notes, and snippets.

View thanh4890's full-sized avatar
🏠
Working from home

Thanh Nguyen Dac thanh4890

🏠
Working from home
View GitHub Profile
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'Currency name', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
// Options toggler hanlder
// To turn on/off other options base on toggler selection
function initOptionToggler() {
$(document).delegate('.yk-toggler', 'click', function(){
var toggler_name = $(this).attr("name").replace("option_tree[","").replace("]","");
var toggler_value = $(".yk-toggler[name*="+toggler_name+"]:checked").val();
// Turn off all .yk-toggle-able fields
$(".yk-toggle-able[class*="+toggler_name+"]").parents(".format-settings").slideUp();
@thanh4890
thanh4890 / WordPress: Init Widget
Last active December 18, 2015 13:29
WordPress: Init Widget
/**
* Adds Foo_Widget widget.
*/
class Foo_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
public function __construct() {
$widget_ops = array('classname' => 'foo-widget', 'description' => __('Display Foo_Widget', kopa_get_domain()));
@thanh4890
thanh4890 / WordPress TinyMCE button
Created June 28, 2013 04:17
Register WordPress TinyMCE button
register shortcode in standard way
add js plugin via mce_external_plugins filter
add mce button via mce_button_3 filter
@thanh4890
thanh4890 / Preferences.sublime-settings
Last active December 19, 2015 10:09
Sublime Text User Settings
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Mac Classic.tmTheme",
"font_options": "subpixel_antialias",
"fade_fold_buttons": false,
"font_face": "Consolas",
"font_size": 13.5,
"highlight_line": true,
"highlight_modified_tabs": true,
@thanh4890
thanh4890 / functions-color-helper.php
Last active December 27, 2015 10:49
Some php color helper functions fork from avia framework by Christian "Kriesi" Budschedl
if(!function_exists('avia_backend_get_hex_from_rgb'))
{
/**
* converts an rgb string into a hex value and returns the string
* @param string $r red
* @param string $g green
* @param string $B blue
* @return string returns the converted string
*/
function avia_backend_get_hex_from_rgb($r=FALSE, $g=FALSE, $b=FALSE) {
@thanh4890
thanh4890 / wpfilesystem-demo.php
Created November 7, 2013 08:08
WordPress Filesystem Tutorial
<?php
/*
Plugin Name: Filesystem Tutorial
Description: Demo Plugin for http://ottopress.com/2011/tutorial-using-the-wp_filesystem
Plugin URL: http://ottopress.com/2011/tutorial-using-the-wp_filesystem
Author: otto42
DO NOT USE THIS ON A PRODUCTION SITE. THIS IS DEMONSTRATION CODE ONLY.
*/
@thanh4890
thanh4890 / WordPress Theme Options
Created December 16, 2013 03:22
WordPress theme options
general settings:
logo
favicon
header ticker
enable/disable responsive layout
footer copyright
tracking code
show/hide breadcrumb
enable/disable automatically add home menu item
<a class="button button-small mycolor" href="http://kopatheme.com" target="">Kopatheme</a>
@thanh4890
thanh4890 / forceful-gallery-org
Created January 9, 2014 02:39
Forceful gallery org