Skip to content

Instantly share code, notes, and snippets.

View musamamasood's full-sized avatar
🎯
Focusing

Muhammad Usama Masood musamamasood

🎯
Focusing
View GitHub Profile
@musamamasood
musamamasood / gist:68d77c7786f7aef624e5778edcdfe7f8
Created April 25, 2017 20:11 — forked from billerickson/gist:2047229
Improve performance of WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
@musamamasood
musamamasood / functions.php
Created April 4, 2017 18:12
Plugin To Disabled the Ninja Form Trash Submission after 30 days.
/**
* Solution to disable the auto cleaning of trash submission in Ninja forms.
* http://ryansechrest.com/2013/09/prevent-wordpress-automatically-purging-trash-custom-post-type/
*
* @param $post_id
*/
function do_not_schedule_post_types( $post_id ) {
// array of post_type you don't want to be scheduled
$unscheduled_post_types = array( 'nf_sub');
@musamamasood
musamamasood / gitBash_windows.md
Created March 23, 2017 20:44 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows is bundled with "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on). If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corrisponding directories. Sometimes the windows binary have funny prefixes, so you should rename the exe file to the

function wishlist_refresh(){
if ( isset($_GET['flush']) ){
global $wp;
$current_url = home_url( remove_query_arg('flush', $wp->request) );
if ( wp_redirect( $current_url ) ) {
exit;
}
}
}
add_action('init', 'wihslist_refresh');
@musamamasood
musamamasood / r-debug.php
Created January 19, 2017 21:26 — forked from Rarst/r-debug.php
R Debug (set of dump helpers for debug)
<?php
/*
Plugin Name: R Debug
Description: Set of dump helpers for debug.
Author: Andrey "Rarst" Savchenko
Author URI: http://www.rarst.net/
License: MIT
*/
/**
@musamamasood
musamamasood / function.js
Created January 13, 2017 20:30
Smooth Scrolling
// JavaScript Document
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
@musamamasood
musamamasood / wordpress_export-post-data.php
Created January 4, 2017 18:02 — forked from robinnorth/wordpress_export-post-data.php
WordPress: Simple, configurable script to export post data to a CSV file
<?php
/**
* Export WordPress post data to CSV
* Based on <http://stackoverflow.com/a/3474698> and <http://ran.ge/2009/10/27/howto-create-stream-csv-php/>
*/
/**
*********************************************************************
* Configuration
*********************************************************************
@musamamasood
musamamasood / emtysearch.js
Created December 7, 2016 03:39
jQuery plugin to prevent the empty search.
/**
* Stop empty searches
*
* @author Thomas Scholz http://toscho.de
* @param $ jQuery object
* @return bool|object
*/
(function( $ ) {
$.fn.preventEmptySubmit = function( options ) {
var settings = {
@musamamasood
musamamasood / functions.php
Last active September 28, 2018 04:35
Shortcode to fetch post by post_type
// create shortcode to list all clothes which come in blue
function statesmen_news_shortcode( $atts ) {
$html = '';
// Attributes
$atts = shortcode_atts(
array(
'post_per_page' => '2',
'post_type' => 'post',
'id' => false
),
@musamamasood
musamamasood / functions.php
Last active December 8, 2016 14:39
Helper Functions
/**
* The main logging function
*
* @uses error_log
* @param string $type type of the error. e.g: debug, error, info
* @param string $msg
*/
public static function log( $type = '', $msg = '' ) {
if ( WP_DEBUG == true ) {
$msg = sprintf( "[%s][%s] %s\n", date( 'd.m.Y h:i:s' ), $type, $msg );