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 / functions.php
Last active June 23, 2024 18:17
Add Custom CSS only to LearnDash pages and not the entire site
function load_custom_css_for_learndash( $hook = '' ) {
// Get the current post type
global $post;
$current_post_type = get_post_type( $post );
// Define the LearnDash post types, including certificates, exams, groups, assignments, and coupons
$learndash_post_types = array( 'sfwd-courses', 'sfwd-lessons', 'sfwd-topic', 'sfwd-quiz', 'sfwd-question', 'sfwd-certificates', 'ld-exam', 'groups', 'sfwd-assignment' );
// Check if the current post type is one of the LearnDash post types
if ( in_array( $current_post_type, $learndash_post_types ) ) {
@adeel-raza
adeel-raza / custom-code-plugin.php
Last active June 6, 2024 21:42
When using Uncanny automator sending a certificate link to user does not open the certificate due to security reasons, this snippet provides a solution for that
<?php
/*
Plugin Name: Custom Code By eLearning evolve
Description: This plugin holds the custom code implemented for this site by eLearning evolve
Version: 1.0
Author: Adeel Raza
Author URI: https://elearningevolve.com/learndash-developer
*/
/**
@adeel-raza
adeel-raza / functions.php
Created March 9, 2024 23:12
Show LearnDash Certificate Link For User By Certificate ID - Custom Shortcode
if ( isset( $_GET['user_id'] ) && $_GET['ld_certificate'] ) {
include_once LEARNDASH_LMS_PLUGIN_DIR . 'includes/ld-convert-post-pdf.php';
learndash_certificate_post_shortcode(
$cert_args = array(
'user_id' => esc_attr(
$_GET['user_id']
),
'cert_id' => esc_attr(
$_GET['ld_certificate']
),
@adeel-raza
adeel-raza / create-meeting-api-zoom-wordpress-plugin.php
Last active January 8, 2024 16:04
Dynamically Create a Meeting in your code with Zoom WordPress Plugin
function create_meeting_with_zoom_wordpress() {
// Place your Zoom user Host ID. Check it from Zoom Meetings -> Zoom Users -> Host ID
$zoom_host_id = 'x3VbIu8mT-m8-gWQNL05pQ';
// Your Meeting Settings
$create_meeting_arr = array(
'userId' => $zoom_host_id,
'meetingTopic' => 'Your_Meeting_Topic',
'start_date' => '2024-01-09 05:00:00', // Set it to a Future date/time for a scheduled meeting
@adeel-raza
adeel-raza / insertion-sort.php
Created December 20, 2023 12:06
Insertion sort contact list with PHP
<!--
Pusedo Code:
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Coding Arena</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous"></script>
@adeel-raza
adeel-raza / functions.php
Last active December 13, 2023 16:02
Uppercase First Name, Last Name or User Login Name on LearnDash LMS Certificates
add_filter( 'learndash_usermeta_shortcode_field_value_display', 'ee_learndash_usermeta_shortcode_field_value_display_callback', 10, 2 );
function ee_learndash_usermeta_shortcode_field_value_display_callback( $value, $attr ) {
global $post;
// Don't apply logic if not on a certificate
if ( isset( $post->post_type ) ) {
$is_certificate_page = $post->post_type;
if ( 'sfwd-certificates' != $is_certificate_page ) {
return $value;
}
}
@adeel-raza
adeel-raza / OOP_movies_inherit_practice.php
Created December 10, 2023 19:47
OOP PHP example to practice inheritence, constructors
<!-- Psudeo Code:
1. Media content class with properties title, release date and a method
to display info about the title and release date
2. Movies should contain genre and display additionally
3. Tv shows should contain num of seasons and display additionally
-->
<?php
class Media_Content {
@adeel-raza
adeel-raza / oop_password_generator.php
Created December 10, 2023 18:18
OOP based password generator in PHP
<?php
class Password_Manager {
private $length;
private $useUppercase;
private $useLowercase;
private $useDigits;
private $useSpecialChars;
private $password;
@adeel-raza
adeel-raza / bubble_sort.php
Created November 29, 2023 14:51
program to sort a list of contacts with Bubble sort
<?php
$contact_info = array(
'Zeeshan ' => ' 03332490820',
'Bilal ' => ' 03332490895',
' Danish ' => ' 03332490673',
'Sami' => ' 03332490165',
'Ahmed' => ' 03332490090',
' Batool ' => ' 03332490554',
'Owais ' => ' 03332490967',
'Ahsan ' => ' 03332490534',