Skip to content

Instantly share code, notes, and snippets.

View zeshanshani's full-sized avatar
🎯
Focusing

Zeshan Ahmed zeshanshani

🎯
Focusing
View GitHub Profile
#!/bin/bash
USER="root"
PASSWORD=""
FILES="/Users/tenold/Backups/MySQL/*"
for f in $FILES
do
echo "Processing $f file..."
@zeshanshani
zeshanshani / dump.sh
Created February 12, 2018 20:39 — forked from andsens/dump.sh
Backup all MySQL databases into separate files
#!/bin/sh
## backup each mysql db into a different file, rather than one big file
## as with --all-databases. This will make restores easier.
## To backup a single database simply add the db name as a parameter (or multiple dbs)
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is
## Create the user and directories
# mkdir -p /var/backups/mysql/databases
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup
## Remember to make the script executable, and unreadable by others
@zeshanshani
zeshanshani / php-rewrite-rule-fix-for-same-slug.php
Last active March 6, 2019 17:52
Fix pagination of page with same slug as of CPT's rewrite slug. This function will fix the same slug conflict of CPT and a static page with pagination.
<?php // Don't copy this line...
/**
* This function will Kill 'blogs/editor' rewrite rules
* to fix the broken pagination issue on this page:
* '/blogs/editor/'
*
* This fix was needed because we add rewrite rules for CPT: editor
* And because '/blogs/editor/' is also a static page, the pagination
* on that page e.g., '/blogs/editor/page/4/' was broken.
<?php // please don't copy this line.
/**
* Get SERP Name
*/
function jiv_get_serp_name() {
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
$serps = array( 'google', 'bing', 'yahoo', 'duckduckgo' );
$referer = $_SERVER['HTTP_REFERER'];
$result = jiv_get_domain_from_url( $referer );
<?php
/**
* Get Full Customer Name from Order ID
*
* Author: Zeshan Ahmed
* Author URI: https://zeshanahmed.com/
*/
function za_full_customer_name( $order_id ) {
@zeshanshani
zeshanshani / html.json
Last active September 21, 2020 12:44
Expand PHP conditionals in HTML in VS Code.
{
// ECHO
"PHP Echo Tag": {
"prefix": "echo",
"body": [
"<?php echo ${1:\\$var}; ?>"
],
"description": "Expand \"echo\" into PHP echo block"
},
@zeshanshani
zeshanshani / acf-widget-title-link.php
Last active November 6, 2017 06:34
Add Link to Widget Title using ACF
@zeshanshani
zeshanshani / random_posts_via_AJAX.php
Created October 27, 2017 19:37
Random Posts via AJAX. Use this function to get the random posts in a AJAX callback handler.
<?php // don't include this line.
/**
* Random Posts
* @param integer $count describe how many random posts you would want to fetch.
* @return string HTML of the returned posts.
*/
function za_random_related_posts( $count = 3 ) {
global $global_exclude_post_ids;
@zeshanshani
zeshanshani / primary_category.php
Created September 19, 2017 09:46 — forked from jawinn/primary_category.php
Display Primary Category (Yoast's WordPress SEO)
<?php
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_category();
$useCatLink = true;
// If post has a category assigned.
if ($category){
$category_display = '';
$category_link = '';
if ( class_exists('WPSEO_Primary_Term') )
A File Icon
AdvancedNewFile
Alignment
All Autocomplete
AutoFileName
Autoprefixer
Boxy Theme
Boxy Theme Addon - Widget Font Size
BracketHighlighter
Color Highlighter