Skip to content

Instantly share code, notes, and snippets.

View kirandash's full-sized avatar

Kiran kirandash

View GitHub Profile
@kirandash
kirandash / custom_navwalker.php
Created March 17, 2017 07:07
Split WordPress menu or wp_nav_menu in 2 columns
<?php
class SplitMenuWalker extends Walker_Nav_Menu {
var $current_menu = null;
var $break_point = null;
var $displayed = 0;
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
@kirandash
kirandash / scripts.js
Created March 13, 2017 10:16
Slick on Initialize set the images and text in it to visible.
$('#fleet-gallery').on('init', function(event, slick){
//Solves the issue of repeating lightbox items on loop
$('.slick-cloned').removeAttr("data-lightbox");
$('#fleet-gallery img').css('visibility','visible');
});
@kirandash
kirandash / functions.php
Last active February 19, 2017 07:09
Remove current_page_parent from posts page link in WordPress nav menu
<?php
function wpdev_nav_classes( $classes, $item ) {
if( ( is_post_type_archive( 'fleet' ) || is_singular( 'fleet' ) )
&& $item->title == 'Blog' ){
$classes = array_diff( $classes, array( 'current_page_parent' ) );
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'wpdev_nav_classes', 10, 2 );
?>
@kirandash
kirandash / Fileupload.php
Created December 8, 2016 10:56
WordPress File Upload using wp_handle_upload - change wordpress upload directory and change file name
require_once(ABSPATH.'wp-admin/includes/file.php');
$uploadedfile = $_FILES['csvtoimport'];
add_filter( 'upload_dir', 'wpse_183245_upload_dir' );
function wpse_183245_upload_dir( $dirs ) {
$dirs['subdir'] = '/upload';
$dirs['path'] = $dirs['basedir'] . '/upload';
@kirandash
kirandash / scroll.js
Created November 23, 2016 11:39
detect scroll up or down jquery for fixed height
/* SCROLL */
//Firefox
$(window).bind('DOMMouseScroll', function(e){
if(e.originalEvent.detail > 0) {
//scroll down
zoomOutTimeline.to(screenToTilt, 10, {scale: 0});
}else {
//scroll up
zoomOutTimeline.to(screenToTilt, 10, {scale: 0});
}
@kirandash
kirandash / Quantity - custom - woocommerce
Last active July 17, 2020 14:56
Ajax add to cart with quantity is working only once for my woocommerce website - Solution
YouTube Channel: BG Web Agency: https://www.youtube.com/channel/UC5meqZ4An3SU4-1Wd_sX1Vw
// HTML
<div class="quantity">
<input type="number" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( $max_value ); ?>" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" />
<span class="inputIcon" data-type="plus"><i class="fa fa-caret-up"></i></span>
<span class="inputIcon" data-type="minus"><i class="fa fa-caret-down"></i></span>
</div>
@kirandash
kirandash / functions.php
Created September 27, 2016 09:06
Indexing manage_posts_custom_column. This code will add an Index value to each post which is determined by $wp_query->current_post, the number of posts per page, and the current page being viewed.
<?php
add_filter( 'manage_posts_columns', 'wpse240648_manage_posts_columns_index');
function wpse240648_manage_posts_columns_index($columns) {
$columns['index'] = __( 'Index', 'your-text-domain' );
return $columns;
}
add_action( 'manage_posts_custom_column', 'wpse240648_manage_posts_custom_column_index', 10, 3 );
function wpse240648_manage_posts_custom_column_index( $column, $post_id ) {
@kirandash
kirandash / functions.php
Created September 7, 2016 08:59
Fix Gravity Form Tabindex Conflicts
/**
* Fix Gravity Form Tabindex Conflicts
*/
add_filter( 'gform_tabindex', 'gform_tabindexer', 10, 2 );
function gform_tabindexer( $tab_index, $form = false ) {
$starting_index = 1000; // if you need a higher tabindex, update this number
if( $form )
add_filter( 'gform_tabindex_' . $form['id'], 'gform_tabindexer' );
return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index;
}
@kirandash
kirandash / functions.php
Created September 7, 2016 08:29
custom logo
<?php
// Add theme support for custom logo as it is required for WordPress 4.5 onwards
add_theme_support( 'custom-logo', array(
'width' => 367,
'height' => 92,
'flex-width' => true,
'flex-height' => true
)
);
@kirandash
kirandash / WooCommerce - add text after price
Last active September 6, 2016 08:01 — forked from jameskoster/functions.php
WooCommerce - add text after price
functions.php
/**
* WooCommerce - add symbol after price
*/
add_filter( 'woocommerce_get_price_html', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message' ); // added
add_filter( 'woocommerce_cart_subtotal', 'kd_custom_price_message' ); // added
add_filter( 'woocommerce_cart_total', 'kd_custom_price_message' ); // added