Skip to content

Instantly share code, notes, and snippets.

View mehrshaddarzi's full-sized avatar

Mehrshad Darzi mehrshaddarzi

View GitHub Profile
@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 git@github.com: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 / 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);
@mehrshaddarzi
mehrshaddarzi / gist:a7472ebd0f2983f5ef4d523851b82ac4
Created September 17, 2017 09:28 — forked from boonebgorges/gist:2185537
Recursively sort the output of get_categories() in order of parent-child hierarchy
<?php
$categories = get_the_category();
// Assemble a tree of category relationships
// Also re-key the category array for easier
// reference
$category_tree = array();
$keyed_categories = array();
<!DOCTYPE html>
<html>
<body>
<style>
#holder.hover { border: 10px dashed #0c0 !important; }
</style>
<form method="post" action="http://httpbin.org/post" enctype="multipart/form-data">
<input id="name"><br/>
<input id="type"><br/>
<input id="size"><br/>
@mehrshaddarzi
mehrshaddarzi / bootstrap-pagination.php
Last active October 11, 2017 06:22 — forked from ediamin/bootstrap-pagination.php
Bootstrap Pagination for WordPress
// https://www.kevinleary.net/wordpress-pagination-paginate_links/
/*
* custom pagination with bootstrap .pagination class
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
*/
function bootstrap_pagination( $echo = true ) {
global $wp_query;
@mehrshaddarzi
mehrshaddarzi / page-faculty-staff.php
Created November 11, 2017 19:42 — forked from freerangetech/page-faculty-staff.php
Switch to Blog and WP_Query Example
<?php
function smcm_pull_faculty_from_directory() {
//Get the slug of the calling site... array element [3]
$site_slug = explode ("/", get_site_url());
// blog id of the directory
$blog_id = 7;