Skip to content

Instantly share code, notes, and snippets.

View zainaali's full-sized avatar

Zain Ali zainaali

  • Lahore Punjab, Pakistan
View GitHub Profile
@zainaali
zainaali / solar.html
Created December 11, 2023 08:12
Google Solar API JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Maps Autocomplete</title>
<style>
body{
background: #1a202c;
color:white;
@zainaali
zainaali / cursor.html
Created September 15, 2023 10:48
Add color dot cursor instead of default cursor
<!-- Put this html code after <body> tag -->
<div class="mouse-cursor cursor-outer"></div>
<div class="mouse-cursor cursor-inner"></div>
<!--Put this js code in footer -->
<script>
jQuery(document).ready(function($) {
function mousecursor() {
@zainaali
zainaali / gist:d7b0354ddbc240129f8c6b8cc3b9549c
Created November 5, 2021 11:17
Dynamically populate a Contact Form 7 dropdown list form db and add custom validation
add this shortcode in contact from
[select upcoming-gigs data:gigs]
add this code in functions.php
<?php
add_filter('wpcf7_form_tag_data_option', function($n, $options, $args) {
global $wpdb;
$result = $wpdb->get_results("SELECT DATE_FORMAT(termin, '%d.%m.%Y') as termin FROM einweihungen where termin >= CURDATE() ORDER BY einweihungen.termin ASC;");
$optionsarr = array();
@zainaali
zainaali / gist:9fd03ffe0f6738c8a74fb4ba7d3b9db4
Created September 10, 2021 09:32
change product quantity based on variation selection
add_action('wp_footer', 'method');
function method()
{
global $post;
//get_product id
$product = get_product( $post->ID );
//if Product is variable add a message
if(is_product() && $product->is_type( 'variable' ) ){
@zainaali
zainaali / gist:8168093a302d9e9858807832f81ba20b
Created August 16, 2021 06:43
Scroll within a div with jQuery animate() function
function scrollingdiv(parentid, id){
$("#"+parentid).animate({scrollTop: $("#"+id).position().top}, 800, 'swing');
}
@zainaali
zainaali / gist:5136e11f00a0f7dccfe2e1c047b5dba8
Created April 5, 2021 12:51
set alt tag and title of product images to product's name, category, subcategories' name, vendor's name
add_filter( 'martfury_image_alt_text', 'ct_martfury_image_alt_text' );
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes( $attr, $attachment ){
$product_id = get_the_ID();
$vendor_id = get_post_field( 'post_author', $product_id );
// Get the WP_User object (the vendor) from author ID
$vendor = new WP_User($vendor_id);
$vendor_name = $vendor->display_name;
// var_dump($product_cat);exit;
@zainaali
zainaali / custom.js
Last active February 19, 2021 09:43
Hide header on specific slide of Revolution Slider
<script>
var revapi = jQuery(document).ready(function() {
jQuery('#rev_slider_2_3').show().revolution({
waitForInit: true,
/* SLIDER SETTINGS CONTINUED */
});
});
// only start the slider once the entire window has loaded
revapi.on('revolution.slide.onchange', function(event, data) {
var get_id1 = data.currentslide[0]['id'];
@zainaali
zainaali / functions.php
Created October 21, 2020 11:26
Create a Stripe Customer with Gravity Forms Stripe Product Feed
add_filter( 'gform_stripe_customer_id', function ( $customer_id, $feed, $entry, $form ) {
if ( rgars( $feed, 'meta/transactionType' ) == 'product' && rgars( $feed, 'meta/feedName' ) == 'Create Customer and Payment' ) {
$customer_meta = array();
$metadata_field = rgars( $feed, 'meta/metaData' );
foreach ($metadata_field as $metadata) {
if ($metadata['custom_key'] == 'Email') {
$email_field = $metadata['value'];
}
@zainaali
zainaali / distance.js
Created September 30, 2020 09:52
calculate distance between tow lat lon
// Passed to function: :::
//::: lat1, lon1 = Latitude and Longitude of point 1 (in decimal degrees) :::
//::: lat2, lon2 = Latitude and Longitude of point 2 (in decimal degrees) :::
//::: unit = the unit you desire for results :::
//::: where: 'M' is statute miles (default) :::
//::: 'K' is kilometers :::
//::: 'N' is nautical miles
function distance(lat1, lon1, lat2, lon2, unit) {
if ((lat1 == lat2) && (lon1 == lon2)) {
@zainaali
zainaali / related-products-by-tag.liquid
Last active February 19, 2021 09:44
manual recommendation products tag based shopify