Skip to content

Instantly share code, notes, and snippets.

View klihelp's full-sized avatar
🎯
Focusing on life and money farm

klihelp

🎯
Focusing on life and money farm
View GitHub Profile
@woogist
woogist / gist:6267983
Created August 19, 2013 11:06
WooCommerce - Display checkout custom field on the order edition page
/**
* Display field value on the order edition page
**/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('My Field').':</strong> ' . $order->order_custom_fields['My Field'][0] . '</p>';
}
@webaware
webaware / gist:6260468
Last active October 28, 2024 06:19
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@webaware
webaware / add-to-cart.php
Last active October 9, 2024 00:33 — forked from mikejolley/functions.php
WooCommerce purchase page add-to-cart with quantity and AJAX, by customising the add-to-cart template in the WooCommerce loop. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* Loop Add to Cart -- with quantity and AJAX
* requires associated JavaScript file qty-add-to-cart.js
*
* @link http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
* @link https://gist.github.com/mikejolley/2793710/
*/
// add this file to folder "woocommerce/loop" inside theme
@jxnblk
jxnblk / .htaccess
Last active March 12, 2023 12:25
.htaccess for using AngularJS's in HTML5 mode on Media Temple
Options +FollowSymLinks
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>
{% extends "layout.html" %}
{% block canonical %}{{ url }}{{ page.url }}{% endblock %}
{% block title %}{{ page.title }}{% endblock %}
{% block meta %}
{{ super() }}
{% if page.metadata.keywords %}<meta name="keywords" content="{{ page.metadata.keywords }}">{% endif %}
{% endblock %}
{% block content %}
<div class="row">
<div class="twelve columns">
@mmohiudd
mmohiudd / csv_parser.php
Last active October 7, 2018 21:23
Basic CSV parse function
function getCSVData($file){
$info = pathinfo($file);
$fp = @fopen($file, "r");
$data = array();
$line = fgets($fp, 4096); // read the first line, headers
// use /[ "\']+/ to remove white spaces as well
$fields = preg_replace('/[ "\']+/', '', explode(",", trim($line)));
@paulirish
paulirish / performance.now()-polyfill.js
Last active December 11, 2024 09:06
performance.now() polyfill (aka perf.now())
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill
// github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
@gerbenvandijk
gerbenvandijk / Mark parent navigation active when on custom post type single page
Last active July 16, 2024 16:53
Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Get post ID, if nothing found set to NULL
$id = ( isset( $post->ID ) ? get_the_ID() : NULL );
@Davidlab
Davidlab / Justified Image Grid tag cloud widget
Last active December 14, 2015 19:08
Justified Image Grid Nextgen tags widget. Paste this in your functions.php with https://gist.github.com/Davidlab/5130772 (also creates shortcode, but includes needed function for tags widget). Within this snippet you will see an area where you need to include the page name or ID of your gallery page. This is to allow the widget to only load on t…
class justified_tagcloud_widget extends WP_Widget {
/** constructor */
function justified_tagcloud_widget() {
$widget_ops = array(
'description' => 'Display\'s a Tag Cloud based on Nextgen, used by Justified Image Grid '
);
parent::WP_Widget(false, $name = 'Justified Image Grid Tag Cloud', $widget_ops);
}
@Davidlab
Davidlab / Justified Image Grid Nexgen tags shortcode
Last active December 14, 2015 18:39
Justified Image Grid Nexgen Tags. Paste this into your themes functions.php and use shortcode [justified_ngg_tagcloud]
function justified_tag_cloud($args ='', $template = '') {
global $nggRewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag'
);
$args = wp_parse_args( $args, $defaults );