Skip to content

Instantly share code, notes, and snippets.

View unaibamir's full-sized avatar

Unaib Amir unaibamir

View GitHub Profile
@unaibamir
unaibamir / avia-login-auth0.js
Created June 12, 2023 13:06
Auth0 login script
async function lookupEmailFromWP(wpUrl, nationalRegisterId) {
const axios = require('axios');
const url = `${wpUrl}/wp-json/avia/v1/user/ssn?ssn=${nationalRegisterId}`;
const response = await axios.get(url);
const data = response.data;
if (Array.isArray(data) && data.length === 1) return data[0].user_email;
else return null
}
@unaibamir
unaibamir / functions.php
Created September 20, 2021 16:04
learndash gradebook issue
function test_redirect($query)
{
if( is_user_logged_in() ) {
$userid = get_current_user_id();
$user = wp_get_current_user();
$original_id = $user->data->ID;
$roles = ( array ) $user->roles;
}
@unaibamir
unaibamir / functions.php
Created July 12, 2021 11:07
JS add negative points field on quiz builder question field and get value via AJAX.
<?php
function admin_footer_script_tes() {
?>
<script type="text/javascript">
jQuery(function($){
$(document).on( 'click', 'button.ld-node-header__points-form-toggle.ld-button-reset', function( e ){
$(".ld-node-header__points-form .ld-question-points")
.before( '<input type="number" min="0" name="points_neg" class="ld-question-points points_neg" value="1"> Negative Points' );
@unaibamir
unaibamir / wpi
Last active April 4, 2021 00:33
A WP CLI addon script to install & configure WordPress in few seconds
#!/bin/bash
echo "================================================================="
echo "Awesome WordPress Installer!!"
echo "================================================================="
# download WordPress core files
wp core download
@unaibamir
unaibamir / ld-wp-editor-field.php
Created September 4, 2020 23:20
ld-wp-editor-field.php
add_filter( "learndash_settings_fields", "custom_learndash_settings_fields", 99, 2 );
function custom_learndash_settings_fields( $fields, $metabox_key ) {
if( $metabox_key = "learndash-course-display-content-settings" ) {
$fields['course_materials_2'] = array(
'label' => 'Testing',
'name' => 'course_materials_2',
'type' => 'wpeditor',
'value' => $fields['course_materials_2'],
'default' => '',
'placeholder' => esc_html__( 'Add a list of needed documents or URLs. This field supports HTML.', 'learndash' ),
@unaibamir
unaibamir / functions.php
Created July 15, 2020 18:07
lmsninjas custom post types
/*
* Register Products CPT
*/
if ( ! function_exists('register_cpt_products') ) {
// Register Custom Post Type
function register_cpt_products() {
$labels = array(
'name' => _x( 'Products','wooninjas' ),
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Task extends CI_Controller
{
public function __construct()
{
parent::__construct();
<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!-- Main panel is starting from here -->
<div class="panel-header panel-header-sm">
</div>
<style>
.card label {
font-size: unset;
margin-bottom: 0;
<?php
/**
* Shortcode get course total users number
*
* @since 2.1.0
*
* @param array $atts shortcode attributes
* @return string course total users number
*/
$output = array(
0 => {value1 test {some text test} abc ksa dgsd}{value2 sadasdasdasd {some text more} xyz test unaib}
1 => value1 test
2 => some text test
3 => abc ksa dgsd
4 => value2 sadasdasdasd
5 => some text more
6 => xyz test unaib
)