Skip to content

Instantly share code, notes, and snippets.

View mrkkr's full-sized avatar

Marek mrkkr

  • Poland
View GitHub Profile
@dasbairagya
dasbairagya / function.php
Created May 1, 2017 05:18
short code to get the woocommerce recently viewed products
//short code to get the woocommerce recently viewed products
<?php function custom_track_product_view() {
if ( ! is_singular( 'product' ) ) {
return;
}
global $post;
if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) )
$viewed_products = array();
@jaredatch
jaredatch / functions.php
Last active July 3, 2023 23:10
WordPress Search Autocomplete using admin-ajax.php
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@dustyf
dustyf / gist:5862035
Created June 25, 2013 20:26
Woo Commerce Dropdown to filter product tag within an archive page.
<?php
function displayLocationDropdown() {
$html = '';
$html .= '<form class="location-select" method="post">';
$html .= '<select id="location-selector" name="location" class="location">';
$tag = wp_tag_cloud( array(
'format' => 'array',
@renancouto
renancouto / color.lighten.js
Created January 30, 2013 17:58
Method to lighten / darken hex colors using Javascript.
var LightenColor = function(color, percent) {
var num = parseInt(color,16),
amt = Math.round(2.55 * percent),
R = (num >> 16) + amt,
B = (num >> 8 & 0x00FF) + amt,
G = (num & 0x0000FF) + amt;
return (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (B<255?B<1?0:B:255)*0x100 + (G<255?G<1?0:G:255)).toString(16).slice(1);
};
@acarabott
acarabott / gist:4635408
Created January 25, 2013 15:47
Wordpress - Add default menu_order to custom post type, optional terms
<?php
// Add to functions.php
// Make sure your custom post type has 'page-attributes' in its supports array
// Adjust the 'typeN's to your custom post types
// the first type
add_filter( 'wp_insert_post_data', 'set_menu_order', 10, 2 );
function set_menu_order( $data, $postarr ) {
global $post;
$pt = $data['post_type'];