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 March 14, 2024 04:47
Personalize content for specific WordPress or LearnDash users using WordPress Shortcode
// Show personalized content to students
add_shortcode( 'sv_personalize', 'nt_student_specific_content' );
function nt_student_specific_content( $atts , $content = null ) {
if( !isset( $atts['values'] ) ) {
return $content;
}
$atts['values'] = preg_replace('/\s*,\s*/', ',', $atts['values']);
@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',
@adeel-raza
adeel-raza / quote.php
Last active November 29, 2023 14:39
Random Quote generator using api.quotable.io in PHP
<?php
function get_random_quotes() {
$api_url = 'https://api.quotable.io/random';
$response = @file_get_contents( $api_url );
$error = error_get_last();
if ( $error ) {
echo 'no quotes available at the moment';
} else {
$quotes_output = json_decode( $response, true );
@adeel-raza
adeel-raza / number_guess.php
Last active November 3, 2023 16:30
PHP based number guessing game
<?php
session_start();
// Check if the target number and attempts are set in the session
if (!isset($_SESSION['target_number'])) {
// Generate a random number between 1 and 10 if it's not set
$_SESSION['target_number'] = rand(1, 10);
$_SESSION['attempts'] = 0;
$_SESSION['previous_attempts'] = array();
}