Skip to content

Instantly share code, notes, and snippets.

Avatar

Unaib Amir unaibamir

  • Islamabad
View GitHub Profile
@unaibamir
unaibamir / functions.php
Created Sep 20, 2021
learndash gradebook issue
View functions.php
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 Jul 12, 2021
JS add negative points field on quiz builder question field and get value via AJAX.
View functions.php
<?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 Apr 4, 2021
A WP CLI addon script to install & configure WordPress in few seconds
View wpi
#!/bin/bash
echo "================================================================="
echo "Awesome WordPress Installer!!"
echo "================================================================="
# download WordPress core files
wp core download
View 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 Jul 15, 2020
lmsninjas custom post types
View functions.php
/*
* Register Products CPT
*/
if ( ! function_exists('register_cpt_products') ) {
// Register Custom Post Type
function register_cpt_products() {
$labels = array(
'name' => _x( 'Products','wooninjas' ),
View task-controller.php
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Task extends CI_Controller
{
public function __construct()
{
parent::__construct();
View task-alert.php
<?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;
View get course users total numbers shortcode
<?php
/**
* Shortcode get course total users number
*
* @since 2.1.0
*
* @param array $atts shortcode attributes
* @return string course total users number
*/
View php regexr
$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
)
View gist:dc87c19a666ba120801a7806f455feb5
add_action( "wp_head", "_wn_no_cache" );
function _wn_no_cache() {
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Pragma: no-cache"); // HTTP/1.0
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
}