Skip to content

Instantly share code, notes, and snippets.

View waqashassan98's full-sized avatar

Waqas Hassan waqashassan98

View GitHub Profile
Add a new user to the www-data group
In this example, add a new user called vivek to the www-data group, enter:
sudo useradd -g www-data vivek
### set the password for vivek user ###
sudo passwd vivek
@waqashassan98
waqashassan98 / example-wp-list-table.php
Created February 9, 2021 18:18 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@waqashassan98
waqashassan98 / functions.php
Created November 26, 2020 18:14 — forked from mastef/functions.php
Pods : How to add Custom Admin Table Columns to a Pods ACT
<?php
/*
only important name is the filter name :
pods_admin_ui_PODNAME
if your pods is called "client" then call it
pods_admin_ui_client
you can rename all functions to your liking
*/
add_filter( 'pods_admin_ui_PODNAME', 'custom_admin_table_columns_for_PODNAME' );
@waqashassan98
waqashassan98 / simple-pods-plugin.php
Created November 24, 2020 14:47 — forked from Shelob9/simple-pods-plugin.php
Simple plugin for safely adding code for extending Pods. Instructions: 1) Create a folder in your plugins file. 2) Add this file and a second file, called 'custom-code.php' to it. 3) Add custom code to custom-code.php. 4) Activate plugin. For a complete Pods plugin starter plugin, see: https://github.com/pods-framework/pods-extend
<?php
/*
Plugin Name: Pods Starter Plugin
Version: 0.0.1
License: GPL v2 or later
*/
//note: change 'slug' to your own custom prefix.
add_action( 'plugins_loaded', 'slug_extend_safe_activate');
function slug_extend_safe_activate() {
@waqashassan98
waqashassan98 / Revealing-Module-Pattern.md
Created November 22, 2019 05:56 — forked from zcaceres/Revealing-Module-Pattern.md
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

@waqashassan98
waqashassan98 / gist:cd6e22879f1ee9d7336e8a969a3cac9d
Created May 14, 2019 09:02 — forked from thegdshop/gist:3171026
WooCommerce - Add checkbox field to the checkout
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
@waqashassan98
waqashassan98 / Dynamic-SelectControl.js
Created April 1, 2019 09:29 — forked from rogerlos/Dynamic-SelectControl.js
Allows Gutenberg SelectControl to have its options dynamically populated.
/*
* This is an abbreviated "ES5" script (though it has some ES6 language, just not JSX, or dependencies on npm)
* demonstrating how to get the WordPress "Gutenberg" SelectControl to allow dynamic options.
*
* It probably isn't elegant, but neither am I...I included more context than may be necessary.
*
* (SelectControl pukes on dynamic options because it completely dies, never to be seen again, if it
* is sent an empty options array. This prevents that with a placeholder until your results come back.)
*/
// Get helper functions from global scope
const { registerBlockType } = window.wp.blocks;
const { __ } = window.wp.i18n;
// Use registerBlockType to create a custom block
registerBlockType(
'example-plugin/example-custom-block',
{
// Localize title using wp.i18n.__()
title: __( 'Block Title' ),
<?php
//set up pods::find parameters to limit to 5 items
$param = array(
'limit' => 5,
);
//create pods object
$pods = pods('pod_name', $params );
//check that total values (given limit) returned is greater than zero
if ( $pods->total() > 0 ) {