Skip to content

Instantly share code, notes, and snippets.

View cinghaman's full-sized avatar
🏠
Working from home

Amanpreet Singh cinghaman

🏠
Working from home
View GitHub Profile
@cinghaman
cinghaman / scripts.liquid
Created May 3, 2023 18:25
checkout tracking scripts
<!------------- SCRIPT ON THEME.LIQUID FILE ------>
<!-- microsoft -->
<script>
(function(w,d,t,r,u)
{
var f,n,i;
w[u]=w[u]||[],f=function()
{
var o={ti:"187033303"};
o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")
@cinghaman
cinghaman / card.php
Created September 8, 2022 09:18
FilterWP and MetaBox
<?php
$speaker_name = rwmb_meta( 'speaker_name' ); // meta fields
$speaker_role = rwmb_meta( 'speaker_role' );
$video_link = rwmb_meta( 'video_link' );
$speaker_talk_title = rwmb_meta( 'speaker_talk_title' );
$images = rwmb_meta( 'speaker_image', array( 'size' => 'full' ) );
?>
<div class="card" data-fancybox href="<?php echo $video_link; ?>" data-width="640" data-height="360">
@cinghaman
cinghaman / functions.php
Created March 16, 2021 12:13
WordPress Add Admin Through PHP
function wp_add_admin() {
$user = 'some_user_name';
$pass = 'some_pass_word'; // password in plain text
$email = 'email_id';
if ( ! username_exists( $user ) && ! email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
@cinghaman
cinghaman / variant.js
Created January 9, 2021 22:57
Shopify Variant on Change Product image
<!---- variants slectionchangejs ---->
{% if product.variants.size > 1 %}
<script>
function selectCallback(variant, selector){
var title=variant.title;
var price = variant.price;
console.log(price);
$("span[data-product-price]").text( Shopify.formatMoney(variant.price,'{{ shop.money_format }}'));
console.log(title);
var media_src = variant.featured_media.id;
@cinghaman
cinghaman / pyscrap.py
Last active June 6, 2020 08:52
Python3 Scrapping of webpage using BeautifulSoup
#scrap website using Python3 and BeautifulSoup
import requests
from bs4 import BeautifulSoup
result = requests.get("https://wiki.com") #add your url
src = result.content
soup = BeautifulSoup(src, 'lxml')
# name the output file to write to local disk
out_filename = "bookmarks_design.csv"
@cinghaman
cinghaman / functions.php
Last active July 13, 2018 16:18
Remove dashicons script for non logged in users - WordPress
// Add it in the end of your functions.php file in the child theme
// Remove dashicons in frontend for unauthenticated users
add_action( 'wp_enqueue_scripts', 'rs_dequeue_dashicons' );
function rs_dequeue_dashicons() {
if ( ! is_user_logged_in() ) {
wp_deregister_style( 'dashicons' );
}
}
@cinghaman
cinghaman / scripts-to-head.php
Created May 23, 2018 13:22
WordPress Plugin Default code
<?php
/**
* Plugin Name: Scripts to Head
* Plugin URI: https://thepartytraveller.com
* Description: Add Scripts to head without any other noise
* Version: 1.0
* Author: Robin
* Author URI: https://thepartytraveller.com
*/
@cinghaman
cinghaman / custom_crumbs.php
Created May 10, 2017 04:50
Modifying WooCommerce Breadcrumbs structure to show home/shop-page/product-name
/**
* Update Breadcrumbs structure
*
*/
/* This function will go inside your child functions.php file of your theme */
function pf_custom_crumbs( $crumbs ) {
$newcrumbs = array();
@cinghaman
cinghaman / social-share.php
Created January 19, 2017 00:51
Create your own social share buttons (use it for WordPress or simple html sites)
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<?php
global $post;
$post_url = get_permalink();
$post_title = str_replace( '', '%20', get_the_title() );
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post ->ID ), 'full' );
//share URL's
$twitter_url = 'https://twitter.com/intent/tweet?text='.$post_title.'&amp;url='.$post_url.'&amp;via=twitter_id';
@cinghaman
cinghaman / js
Last active August 12, 2016 09:28
On MouseOver change text logo with random text
<script>
jQuery(document).ready(function(t) {
var o = t("#logo"),
n = !1,
s = ["make some noise", "make magic happen", "make yourself heard", "make time for you", "make history", "make it count", "make a bold move", "make mama some money", "make me a drank", "make that hotline bling", "make it rain", "make a difference", "make your dreams real", "make your move", "make it outfuckingstanding", "make it outstanding", "make mashed potatoes", "make connections", "make guacamole", "make your art", "make’m want more", "make success inevitable", "make a leap of faith", "make someone laugh", "make silly faces", "make misteaks mistakes often", "make work you love", "make money, change the world", "make dreams come true", "make peace", "make weird art", "make poo jokes", "make a ruckus", "make coffee", "make more art", "make it simple", "make the internet kinder", "make yourself proud", "make time for what matters", "make fart noises", "make memories", "make some magic", "make make-believe", "