Skip to content

Instantly share code, notes, and snippets.

View mehrshaddarzi's full-sized avatar

Mehrshad Darzi mehrshaddarzi

View GitHub Profile
@mehrshaddarzi
mehrshaddarzi / new_gist_file.php
Last active June 19, 2020 06:53
Add support for the "display_name" search column in WP_User_Query
<?php
add_filter( 'user_search_columns', 'filter_function_name', 10, 3 );
function filter_function_name( $search_columns, $search, $wp_user_query ) {
$search_columns[] = 'user_url';
return $search_columns;
}
//Where 'filter_function_name' is the function WordPress should call when filter is run. Note that the filter function must return an value after it is finished processing or the search terms will be empty.
//filter_function_name should be unique function name. It cannot match any other function name already declared.
@mehrshaddarzi
mehrshaddarzi / wp-cli.md
Last active May 21, 2020 04:44
wp-cli start

install in windows

Download wp-cli.phar

create foler wp-cli in drive c

create file wp.bat an push this data

@ECHO OFF
@mehrshaddarzi
mehrshaddarzi / admin-menu.php
Last active April 29, 2025 19:31
debug get all list menu in admin wordpress
<?php
/*
Check class Adctie Menu Admin
//is_open => wp-has-current-submenu wp-menu-open
//is_open for menu who not submenu => current
//is_close => wp-not-current-submenu menu-top
//if for post Type li => id="menu-posts-{post_type_name}"
//if for taxonomy => id="toplevel_page_edit-tags-taxonomy-{taxonomy}-post_type-{posttype}"
*/
@mehrshaddarzi
mehrshaddarzi / gist:1ead62a22ec7a54aa6c2e19c3cd5398e
Last active August 24, 2017 21:21 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@mehrshaddarzi
mehrshaddarzi / GitHub-Forking.md
Created August 24, 2017 20:38 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@mehrshaddarzi
mehrshaddarzi / gist:b6adf5c8e772121cd6f258327816ae09
Created August 27, 2017 06:49 — forked from Kevinlearynet/gist:b4203d09e7a8d605725e
Faster admin-ajax.php for WordPress AJAX actions
<?php
define('DOING_AJAX', true);
if ( ! isset( $_POST['action'] ) )
die('-1');
require_once('../../../../wp-load.php');
// headers for JSON
header('Content-Type: application/json');
@mehrshaddarzi
mehrshaddarzi / gist:fb558aacf31435ee8de75ae142bba0ea
Created August 29, 2017 06:41 — forked from bueltge/gist:757903
This WordPress Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
<?php
/*
Plugin Name: HowTo Plugin
Plugin URI:
Description: This Plugin demonstrates how you can build your own plugin pages using the WordPress provided draggable metaboxes, requires WordPress 2.7 version, supports WordPress 2.8 changed boxing layout engine
Author: Heiko, Frank
Author URI: http://bueltge.de
Version: 0.1
License:
@mehrshaddarzi
mehrshaddarzi / gist:89b6b5e55920f61fb587349c8679c988
Created August 29, 2017 06:45 — forked from turtlepod/gist:5203512
Settings Class with Metabox
<?php
/* Prevent loading this file directly and/or if the class is already defined */
if ( ! defined( 'ABSPATH' ) || class_exists( 'MYFX_Settings_Class' ) )
return;
/**
* Settings with Meta Boxes
* Helper class to easily create settings page for plugin or theme with Meta Box API.
*
@mehrshaddarzi
mehrshaddarzi / composer.json
Last active August 24, 2019 05:15
Easy Create Start Composer.json
//only use package
{
"require": {
"geoip2/geoip2": "^2.7.0",
"s1lentium/iptools": "^1.1.0",
"donatj/phpuseragentparser": "^0.9.0",
"whichbrowser/parser": "2.0.37",
"erusev/parsedown": "^1.6"
},
"config": {
@mehrshaddarzi
mehrshaddarzi / Remove SEO-plugin HTML comments.php
Created September 17, 2017 06:09 — forked from llgruff/Remove SEO-plugin HTML comments.php
Remove [All in One SEO Pack] or [Yoast SEO] HTML Comments in WordPress (for functions.php)
<?php
/**
* Remove [All in One SEO Pack] HTML Comments
* @link //gist.github.com/llgruff/a7ab776167aa0ed307ec445df54e5fdb
*/
if (defined('AIOSEOP_VERSION')) {
add_action('get_header', function() {
ob_start(
function($o) {
return preg_replace('/\n?<.*?One SEO Pack.*?>/mi','',$o);