Skip to content

Instantly share code, notes, and snippets.

View hmowais's full-sized avatar
🎯
Focusing

HM Owais hmowais

🎯
Focusing
  • Karachi, Pakistan
View GitHub Profile
@hmowais
hmowais / script.js
Created August 9, 2024 17:38
Custom Map with Popup and Hover in Webflow
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script src="https://leafletjs.com/examples/choropleth/us-states.js"></script> <!-- US States GeoJSON -->
<script src="https://unpkg.com/leaflet-ajax/dist/leaflet.ajax.min.js"></script> <!-- For loading external GeoJSON -->
<script>
document.addEventListener("DOMContentLoaded", function() {
var map = L.map('map', {
center: [37.8, -96],
zoom: 5,
minZoom: 5,
@hmowais
hmowais / functions.php
Created July 26, 2024 13:51
Post Sync to other website with REST API
<?php
// Website 1
/* API for Post Sync */
function send_post_to_campus($post_id) {
if (wp_is_post_revision($post_id)) {
error_log('Skipping post revision ID: ' . $post_id);
return;
@hmowais
hmowais / body
Created July 22, 2024 16:03
Custom Map with Popup in Webflow
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script src="https://leafletjs.com/examples/choropleth/us-states.js"></script> <!-- US States GeoJSON -->
<script src="https://unpkg.com/leaflet-ajax/dist/leaflet.ajax.min.js"></script> <!-- For loading external GeoJSON -->
<script>
$(".get-my-src").each(function() {
var src = $(this).attr("src");
var customHrefWrapper = "<a href='" + src + "' target='_blank'></a>";
@hmowais
hmowais / functions.php
Created July 16, 2024 12:10
Add to Calender for WordPress Shortcode
<?php
/* Event Add to Calendar Shortcode */
// Shortcode function to display Events
function display_events() {
ob_start();
// Get the current post ID
$current_post_id = get_the_ID();
@hmowais
hmowais / jquery.js
Last active July 5, 2024 15:17
US Map with Jquery HTML, CSS
jQuery(document).ready(function ($) {
var $detailsBox = $('#details-box');
var $detailsImg = $('#details-img');
// var $detailsName = $('#details-name');
// var $detailsText = $('#details-text');
// var $detailsLink = $('#details-link');
$(document).on('mouseover', 'path', function (e) {
var imgSrc = $(this).data('img'); // Fetching data-img attribute from hovered path
// var textContent = $(this).data('name'); // Fetching data-text attribute from hovered path
@hmowais
hmowais / custom.liquid
Created April 25, 2024 16:11
Get Menu list in shopify code
<div class="sidebar-menu">
<h2>Categories</h2>
<ul class="footer-menu-list">
{% for link in linklists.collection-menu.links %}
<li class="custom-menu-item {{ link.title }}"><a href="{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
<li class="vieW_more"><a href="/collections/all">View More</a></li>
</ul>
</div>
@hmowais
hmowais / functions.php
Last active February 21, 2024 06:44
Get User Role Field in Woocommerce Product
<?php
// Add meta box to Products post type
function add_product_user_role_meta_box() {
add_meta_box(
'product_user_role_meta_box',
'User Role',
'render_product_user_role_meta_box',
'product',
'side',
@hmowais
hmowais / custom.js
Created November 8, 2023 14:17
Add Class in Section on Scroll
jQuery( document ).ready(function($) {
var sections = $('.animateiT'),
nav = $('.jump-left'),
nav_height = nav.outerHeight();
$(window).on('scroll', function() {
var cur_pos = $(this).scrollTop();
sections.each(function() {
var top = $(this).offset().top - 300;
var bottom = top + $(this).outerHeight();
if (cur_pos >= top && cur_pos <= bottom) {
@hmowais
hmowais / functions.php
Created January 17, 2023 11:22
Plugins and Themes Updates OFF
<?php
// Update OFF
// Remove WP Updates
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
//add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
@hmowais
hmowais / functions.php
Created November 24, 2022 19:49
Redirect to specific after form submit
<?php
/* redirect after form submit */
add_action('template_redirect', function() {
// ID of the redirect page
if (!is_page(2904)) {
return;
}
// coming from the checkout, so all is fine