Skip to content

Instantly share code, notes, and snippets.

Mohammad Jangda mjangda

Block or report user

Report or block mjangda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mjangda / remove-post-term.php
Created Dec 21, 2011
Remove a given term from the specified post. This function is missing from core WordPress.
View remove-post-term.php
* Remove a given term from the specified post
* Helper function since this functionality doesn't exist in core
function my_remove_post_term( $post_id, $term, $taxonomy ) {
if ( ! is_numeric( $term ) ) {
mjangda /
Last active Feb 24, 2020
How to connect ngrok to your local WordPress environment (props @DanReyLop)

How to develop with Jetpack locally with ngrok

To connect Jetpack in your local installation, you'll need a way for servers to reach your server. That can be done in a number of different ways:

  • You can open your router's ports and use your public IP
  • You can use some kind of Dynamic DNS provider.

But these options fall short of ngrok, which is a "localhost tunnel". It basically allows the Internet to hit a local port on your machine without worrying about ports or IPs.

As long as ngrok is running, Jetpack / will be able to communicate with your local site. This will allow remote modules like Site Search and Manage to work.

mjangda / autosaver.js
Created Mar 3, 2010
How to hook into and pass your plugin data though WordPress Autosave
View autosaver.js
// Must be in an external file or loaded at the end of wp_footer()
jQuery(document).ajaxSend(function(e, x, a) {
var awesome = 1; += '&' + jQuery.param( {is_awesome: awesome} );
mjangda / widget-post-save.js
Created Sep 9, 2010
Hook into the WordPress widget save javascript callback
View widget-post-save.js
jQuery(document).ajaxSuccess(function(e, xhr, settings) {
var widget_id_base = 'mywidget';
if('action=save-widget') != -1 &&'id_base=' + widget_id_base) != -1) {
// do other stuff
mjangda / cli-ms-upgrade.php
Created May 23, 2011
Command Line script to upgrade a WordPress Multisite instance
View cli-ms-upgrade.php
* WordPress Multisite upgrade script
* IMPORTANT: While a simple safeguard has been added to the script,
* you'll want to add another layer that prevents this script from
* being called via the browser.
* Usage:
* 1) Place in the root of your install (or another place, but modify the wp-load.php path to match)
mjangda / dynamic-facebook-comments.js
Last active Jan 6, 2019
Dynamically load Facebook comments on your site (if you already have the FB API running)
View dynamic-facebook-comments.js
jQuery( function( $ ) {
if ( 'undefined' === typeof FB )
if ( $( 'body' ).hasClass( 'single-post' ) || $( 'body' ).hasClass( 'page' ) ) {
var $comments_div = $( '<div/>' );
$comments_div.addClass( 'fb-comments' );
$comments_div.attr( 'data-href', document.location );
$comments_div.appendTo( $( '.primary-content' ) );
mjangda / add-origin.php
Created Jun 20, 2012
Adding additional origins to the WordPress Origin API
View add-origin.php
add_filter( 'allowed_http_origins', 'my_add_origins' );
function my_add_origins( $origins ) {
$origins[] = ''; // this will add to the list of allowed origins when send_origin_headers() is called
return $origins;
mjangda / feedkillah.php
Created Jan 8, 2010
WordPress Plugin: Feed Killah (or, How to disable all feeds on your site)
View feedkillah.php
Plugin Name: Feed Killah!
Plugin URI:
Description: Kills feeds like a mo-fo!
Author: Mohammad Jangda
Version: 0.1
Author URI:
Be nice, and use sort of GPL License, okay?
View html-map.php
add_action( 'init', function() {
$html_map = [
'howdy/world' => 'howdy',
$current_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
if ( in_array( $current_path, array_keys( $html_map ), true ) ) {
$filename = $html_map[ $current_path ];
mjangda / emoji-one.php
Created Nov 24, 2015
Use assets from Emoji One instead of Twitter for your WordPress site.
View emoji-one.php
* Plugin Name: Emoji One
* Description: Use assets from Emoji One ( when displaying emoji.
* Version: 0.1
add_filter( 'emoji_url', '//' );
You can’t perform that action at this time.