Skip to content

Instantly share code, notes, and snippets.

View ravinderk's full-sized avatar

Ravinder Kumar ravinderk

View GitHub Profile
@BFTrick
BFTrick / shopping-redirect.php
Last active June 21, 2019 21:40
Change the Continue Shopping link on the WooCommerce Cart page
<?php
/**
* Return the permalink of the shop page for the continue shopping redirect filter
*
* @param string $return_to
* @return string
*/
function my_woocommerce_continue_shopping_redirect( $return_to ) {
return get_permalink( wc_get_page_id( 'shop' ) );
}
@kasparsd
kasparsd / href-domain-menu-item.php
Created January 21, 2014 15:31
Add destination domain as sanitized CSS class to every WordPress menu item
<?php
add_filter( 'nav_menu_css_class', 'menu_item_href_css_class', 10, 2 );
function menu_item_href_css_class( $classes, $item ) {
$url_domain = parse_url( $item->url, PHP_URL_HOST );
if ( $url_domain )
$classes[] = 'link-' . sanitize_title( $url_domain );
@benjaminniess
benjaminniess / default-wp-pagenavi-structure.html
Last active July 10, 2021 13:37
The default WP Pagenavi structure
<div class="wp-pagenavi-holder">
<div class="wp-pagenavi">
<span class="pages">Page 1 sur 13</span>
<a class="previouspostslink" href="#"><span>Précédent</span></a>
<span class="current">1</span>
<a class="page larger" href="#">2</a>
<a class="page larger" href="#">3</a>
<span class="extend">...</span>
<a class="page larger" href="#">8</a>
<a class="nextpostslink" href="#"><span>Suivant</span></a>
class CsvFileIterator implements \Iterator{
protected $in;
protected $fp;
protected $index;
protected $current;
public function __construct($in, $options = array()) {
$this->in = $in;
$this->options = array_merge(array(
'column_separator' => ','
), $options);
@rossdylan
rossdylan / scrolling.html
Created October 2, 2013 21:29
scrolling barchart with chart.js
<!doctype html>
<html>
<head>
<script src="Chart.js"></script>
</head>
<body>
<canvas id="canvas" height="450" width="1000"></canvas>
<script>
var data = {
labels: ["","","","","","","","","","","","","","","","","","","",""],
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@johnbillion
johnbillion / gist:5225514
Last active May 29, 2019 12:56
Post Meta Revisions
<?php
/*
Plugin Name: Post Meta Revisions
Description: Revisions for the 'foo' post meta field
Version: 1.0
Author: John Blackbourn
Plugin URI: http://lud.icro.us/post-meta-revisions-wordpress
*/
@wpscholar
wpscholar / functions.php
Last active March 1, 2021 13:26
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@thefuxia
thefuxia / t5-wp-load-order.php
Created November 11, 2012 14:31
T5 WP Load Order
<?php
/**
* Plugin Name: T5 WP Load Order
* Description: Hooks into every action and creates a list of available variables, constants, functions, classes and files.
* Plugin URI:
* Version: 2012.11.05
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT