Skip to content

Instantly share code, notes, and snippets.

View mahmoodchowdhury's full-sized avatar

Mahmood Chowdhury mahmoodchowdhury

View GitHub Profile
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "https://your-react-frontend.com"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
</IfModule>
query {
posts {
nodes {
id
title
date
excerpt
featuredImage {
node {
sourceUrl
@mahmoodchowdhury
mahmoodchowdhury / react-fetch-date.js
Last active May 9, 2026 01:51
Fetch Data using Fetch API or Axios in React Application
import { useEffect, useState } from 'react';
function Posts() {
const [posts, setPosts] = useState([]);
useEffect(() => {
fetch('https://your-site.com/wp-json/wp/v2/posts')
.then(res => res.json())
.then(data => setPosts(data));
}, []);
jQuery(document).ready(function($) {
// Check if the hidden field for referral source exists
var referralSourceField = $('input[name="referral_source"]');
if (referralSourceField.length > 0) {
// Populate the hidden field with the referral source value
referralSourceField.val(referralSourceData.referralSource);
}
});
<?php
/*
Plugin Name: Referral Source Tracker
Description: Tracks the original referral source of a lead and adds it to form submissions.
Version: 1.1
Author: Mahmood Chowdhury
*/
// Hook to initialize tracking on page load
add_action('wp', 'referral_source_tracker_init');