Skip to content

Instantly share code, notes, and snippets.

View kartick14's full-sized avatar
🎯
Focusing

Kartick Karmakar kartick14

🎯
Focusing
  • kolkata, India
View GitHub Profile
@kartick14
kartick14 / wp-query-ref.php
Created February 13, 2018 05:43 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@kartick14
kartick14 / index.html
Created March 20, 2018 14:54
Track HTML5 Video life
<video src="video.ogv" id="myVideo">
video not supported
</video>
<script type='text/javascript'>
document.getElementById('myVideo').addEventListener('ended',myHandler,false);
function myHandler(e) {
// What you want to do after the event
}
</script>
@kartick14
kartick14 / function.js
Created April 19, 2018 08:20
Use event delegation for dynamically created elements: When element create after ajax success
$(document).on("click", '.mylink', function(event) {
alert("new link clicked!");
});
@kartick14
kartick14 / cart.liquid
Last active July 27, 2023 13:19
Apply discount code from cart page in shopify
<div class="discountcodefield">
<label for="discount">Discount Code:</label>
<input autocomplete="off" type="hidden" name="discount" class="discount_code" />
<input autocomplete="off" type="text" name="discount_code" class="discount_code_field" />
<input type="button" name="apply_discount_code" class="btn discount_code_btn" value="Apply"/>
</div>
<div class="cart__savings discount_apply_code">
</div>
@kartick14
kartick14 / cart.liquid
Created April 23, 2018 12:43
Product details for wholesaler with each variant added to cart
<div class="page-width" data-section-id="{{ section.id }}" data-section-type="cart-template">
{% if cart.item_count > 0 %}
<div class="section-header text-center">
<h1>{{ 'cart.general.title' | t }}</h1>
</div>
<form action="/cart" method="post" novalidate class="cart">
{% if customer.tags contains 'wholesaler' %}
{% for custag in customer.tags %}
@kartick14
kartick14 / function.php
Created April 30, 2018 09:42
Enable/Disable Payment Gateway for a Specific User Role
/**
* @snippet Enable Payment Gateway for a Specific User Role | WooCommerce
*/
function custom_paypal_enable_manager( $available_gateways ) {
global $woocommerce;
if ( isset( $available_gateways['paypal'] ) && !current_user_can('shop_manager') ) {
unset( $available_gateways['paypal'] );
}
return $available_gateways;
@kartick14
kartick14 / functions.php
Created May 4, 2018 07:53
ADD AND SORT CUSTOM COLUMN IN USERS ADMIN PAGE
<?php
//add additional columns to the users.php admin page
add_filter('manage_users_columns', 'project_add_user_id_column');
function project_add_user_id_column($columns) {
$columns['church'] = 'Church name';
// unset($columns['pmpro_membership_level']); //For remove a column
/*$columns = array(
"cb" => "",
@kartick14
kartick14 / function.php
Last active May 8, 2018 14:20
Creating a cycle() function in PHP
<?php
// Take from http://baylorrae.com/creating-a-cycle-function-in-php
function cycle($first_value, $values = '*') {
// keeps up with all counters
static $count = array();
// get all arguments passed
$values = func_get_args();
// set the default name to use
$name = 'default';
$('a[href^="#"]').on('click', function(event) {
var target = $(this.getAttribute('href'));
if( target.length ) {
event.preventDefault();
$('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);
}
// Goes in theme.liquid
{% if template contains 'contact' %}
{{ 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' | script_tag }}
<script type="text/javascript">
$(document).ready(function() {
var n1 = Math.round(Math.random() * 10 + 1);
var n2 = Math.round(Math.random() * 10 + 1);
$("#question").val(n1 + " + " + n2);
$(".contact-form").submit(function (e) {
if (eval($("#question").val()) != $("#answer").val()) {