Skip to content

Instantly share code, notes, and snippets.

View adeel-raza's full-sized avatar

Adeel adeel-raza

View GitHub Profile
@adeel-raza
adeel-raza / functions.php
Last active June 26, 2024 22:34
Get ACF custom field value for the current logged in WordPress user
/**
* Shortcode to get ACF field value for the current user.
*
* This shortcode retrieves the value of an Advanced Custom Fields (ACF) field
* for the currently logged-in user.
*
* Usage:
* [acf_custom_field field_name="your_acf_field_name"]
*
* The field_name attribute corresponds to the ACF field name.
@adeel-raza
adeel-raza / csldapi.php
Last active July 31, 2024 14:06
Custom Endpoints to Fetch Learndash Courses and Users Information for a LD Group
<?php
/**
* Plugin Name: Custom LD Rest API
* Plugin URI: https://elearningevolve.com/
* Description: Provides custom REST API endpoints utilizing LearnDash
* Version: 1.0.0
* Author: eLearning evolve
* Author URI: https://elearningevolve.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@adeel-raza
adeel-raza / query.sql
Last active August 8, 2024 10:14
Delete all users on a WordPress site who haven't logged in for one year
-- Step 1: Delete from wp_usermeta
DELETE FROM wp_usermeta
WHERE user_id IN (
SELECT ID
FROM wp_users
WHERE ID IN (
SELECT user_id
FROM wp_usermeta
WHERE meta_key = 'last_login'
AND FROM_UNIXTIME(meta_value) < DATE_SUB(NOW(), INTERVAL 1 YEAR)
@adeel-raza
adeel-raza / functions.php
Last active January 29, 2025 09:25
Snippet to automatically mark LearnDash Lessons and Topics as complete when the user clicks "Next Lesson" or "Next Topic," eliminating the need to manually click "Mark Complete."
/**
* Handle the AJAX request to mark a LearnDash topic or lesson as complete.
*
* @return void
*/
function custom_evolve_handle_ld_mark_topic_complete() {
// Verify the nonce for security.
check_ajax_referer( 'ld_complete_nonce', 'nonce' );
// Get and sanitize input data.
@adeel-raza
adeel-raza / functions.php
Created June 6, 2026 08:24
WordPress staging site admin bar indicator — orange background + staging label
// Enqueue custom CSS for the admin bar if on a staging site
function eevolve_custom_admin_bar_css() {
if ( strpos( get_site_url(), 'staging' ) !== false ) {
wp_register_style( 'eevolve-admin-bar-css', false );
wp_enqueue_style( 'eevolve-admin-bar-css' );
wp_add_inline_style(
'eevolve-admin-bar-css',
'
#wpadminbar { background-color: #cc8400; }
#wp-admin-bar-woocommerce-site-visibility-badge { display: none; }
@adeel-raza
adeel-raza / wp_fix.py
Created August 1, 2026 10:43
Fix the unformated code via local Ollama model and give a clean repsonse to be used in live env
import subprocess, requests, re, sys, os
OLLAMA_URL = "http://localhost:11434/api/generate"
MODEL = "default"
MAX_RETRIES = 5
SYSTEM_RULES = """You are a senior WordPress plugin developer doing a code review and cleanup.
You will be given an existing PHP file. Rewrite it to meet these standards while preserving
its original functionality and intent: