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 / index.html
Created August 6, 2018 14:54
Jump menu with active class and smooth scroll
<link href='https://fonts.googleapis.com/css?family=Lato:100,400,700' rel='stylesheet' type='text/css'>
<nav class="navigation" id="mainNav">
<a class="navigation__link" href="#1">Section 1</a>
<a class="navigation__link" href="#2">Section 2</a>
<a class="navigation__link" href="#3">Section 3</a>
<a class="navigation__link" href="#4">Section 4</a>
<a class="navigation__link" href="#5">Section 5</a>
<a class="navigation__link" href="#6">Section 6</a>
<a class="navigation__link" href="#7">Section 7</a>
@kartick14
kartick14 / index.html
Created August 3, 2018 14:09
jQuery: check if element is visible on screen
<div class="container">
<div class="text text-1">
Lorem ipsum <span></span>
</div>
<div class="text text-2">
Lorem ipsum <span></span>
</div>
</div>
@kartick14
kartick14 / google-map-custom.html
Created July 18, 2018 14:10
This example displays a marker with custom color map
https://console.developers.google.com/apis/credentials?project=luca-project-210509
**Add height on map id is must
<!DOCTYPE html>
<html>
<head>
<title>Styled Maps - Night Mode</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
@kartick14
kartick14 / index.html
Created July 17, 2018 06:22
How to change the default message of the required field in the popover of form-control in bootstrap?
<input class="form-control" type="email" required="" placeholder="username"
oninvalid="this.setCustomValidity('Please Enter valid email')"
oninput="setCustomValidity('')"></input>
<!-- Ref site: https://stackoverflow.com/questions/24391078/how-to-change-the-default-message-of-the-required-field-in-the-popover-of-form-c/24392931 -->
@kartick14
kartick14 / function.php
Created July 2, 2018 09:49
Wordpress login restriction depends on user role.
<?php add_filter( 'wp_authenticate_user', 'restrict_login', 10, 2 );
function restrict_login( $user, $password ) {
if ( is_wp_error( $user ) ) {
return $user;
}
$roles = array('administrator','subscriber');
//$roles[] = 'administrator';
if (array_reduce( $roles, function ( $allowed, $role ) use ( $user ) {
return $allowed || user_can( $user, $role );
@kartick14
kartick14 / shopify-filter.liquid
Created June 22, 2018 10:16
Shopify filter section with AND condition
<div id="sidebarColumn" class="col-md-3">
<!-- <div id="sidebar" class="sidebar selection-sec"> -->
<div class="selection-sec">
<div class="selection-sec-inner">
<div class="shape-sec">
<h5>Select a Shape</h5>
<ul class="more">
{% assign file_extension = 'png' %}
{% if collection.handle == 'all' %}
{% for tag in collection.all_tags %}
// 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()) {
$('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);
}
@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';
@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" => "",