Skip to content

Instantly share code, notes, and snippets.

View MrImranJaved's full-sized avatar
🙂
Open For Opportunity

Imran Javed MrImranJaved

🙂
Open For Opportunity
View GitHub Profile
@MrImranJaved
MrImranJaved / gravity-forms-strip-email-from-name-back-ticks.php
Last active February 1, 2022 14:15 — forked from DevinWalker/gravity-forms-strip-email-from-name-quotes.php
For some odd reason Gravity Forms includes quotes in the "From" sender name. This is inconsistent with other mail senders so this removes the quotes in the "From Name" email headers.
/**
* Remove back ticks in Gravity Forms Email Headers
*
* For some odd reason Gravity Forms includes quotes in the "From" sender name. This is inconsistent with other mail senders so this removes the quotes.
*
* @param $email
* @param $message_format
* @param $notification
*
* @return mixed
<?php // do not copy this line
if( ! function_exists( 'ij_child_custom_woocommerce_states' ) ) {
function ij_child_custom_woocommerce_states( $states ) {
$states['LK'] = array(
'PU' => __( 'Punjab', 'woocommerce' ),
'BOL' => __( 'Bolichistan', 'woocommerce' ),
'SND' => __( 'Sindh', 'woocommerce' ),
'KPK' => __( 'Khyber Pakhtunkhowa', 'woocommerce' ),
@MrImranJaved
MrImranJaved / WooCommerce_hooks.php
Last active February 1, 2022 14:23 — forked from alexpani/woo_hooks.php
Gli Hook per WooCommerce
<?php
/** WooCommerce Template Hooks ********************************************************/
/**
* Sale flashes
*/
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
-- phpMyAdmin SQL Dump
-- version 4.8.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Jun 07, 2019 at 07:58 AM
-- Server version: 5.7.25
-- PHP Version: 7.3.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@MrImranJaved
MrImranJaved / update-image-meta.php
Created April 21, 2022 09:08 — forked from EricBusch/update-image-meta.php
Update the attached image's description, caption & alt text with values from the product. [datafeedr][dfrps]
<?php
/**
* Update the attached image's description, caption &
* alt text with values from the product when the image is imported.
*
* @param integer $attachment_id Attachment ID of imported image.
* @param Dfrps_Image_Importer $image_importer
*/
function mycode_update_image_meta( $attachment_id, $image_importer ) {
@MrImranJaved
MrImranJaved / functions.php
Created June 9, 2022 20:29 — forked from vishalbasnet23/functions.php
User Registration Front End WordPress with Ajax
<?php
add_action('wp_ajax_register_user_front_end', 'register_user_front_end', 0);
add_action('wp_ajax_nopriv_register_user_front_end', 'register_user_front_end');
function register_user_front_end() {
$new_user_name = stripcslashes($_POST['new_user_name']);
$new_user_email = stripcslashes($_POST['new_user_email']);
$new_user_password = $_POST['new_user_password'];
$user_nice_name = strtolower($_POST['new_user_email']);
$user_data = array(
'user_login' => $new_user_name,

create wordpress custom widget

add this code to you function.php file

create the custom widget class

frist create a custom widget class that extend the default wordpress widget class this code is from the official wordpress code reference

class My_Widget extends WP_Widget {

	/**
	 * Sets up the widgets name etc
@MrImranJaved
MrImranJaved / widget-tut.php
Created December 5, 2023 12:00 — forked from chrisguitarguy/widget-tut.php
An example of how to build your own WordPress widget
<?php
/*
Plugin Name: PMG Widget Tututorial
Plugin URI: http://pmg.co/category/wordpress
Description: How to create WordPress Widgets.
Version: 1.0
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: GPL2
*/
<?php
// function to display the social media sharing links:
function bim_add_social_sharing_links(){
$html ='<div class="row chart-utils" style="margin: 20px 0 0 0; justify-content: start; gap: 20px;">
<a target="blank" onclick="facebooksharing();" class="facebook"><i class=" fa fa-facebook facebook" style="color: #2980b9;"></i></a>
<a target="blank" onclick="twittersharing();" class="twitter"><svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512"><path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"></path></svg></a>
<a target="blank" onclick="redditsharing();" class="reddit"><i class=" fa fa-reddit reddit" style="color: #c0392b;"></i></a>
<a target="blank" onclick="linkedsharing();" class="linkedin"><i class=" fa fa-linkedin linkedin" style="color: #1e90ff;"></i></a>
@MrImranJaved
MrImranJaved / wooCommerce-add-on-product-with-minimum Quantity.php
Last active May 12, 2025 07:18
a solution to implement an add-on product that only appears when a customer orders a minimum quantity of the main product. This uses WooCommerce hooks and doesn't require a plugin
<?php
/**
* Add conditional add-on product option when minimum quantity is met
*/
function add_conditional_addon_product() {
global $product;
// Only run for specific product IDs (adjust as needed)
$target_product_ids = array(123); // Replace with your main product ID