Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
obiPlabon / gist:218d0b744d78cabe3d26
Created February 8, 2016 08:26 — forked from bitfade/gist:4460948
WordPress 3.5 media upload api example
var workflow = wp.media({
title: 'Select the images',
// use multiple: false to disable multiple selection
multiple: 'add',
button: {
text: 'Add selected images'
},
library: {
type: 'image'
}
@obiPlabon
obiPlabon / i18n.php
Created March 3, 2016 10:15
WordPress I18N Functions
<?php
__
_e
_ex
esc_attr__
esc_attr_e
esc_attr_x
esc_html__
esc_html_e
esc_html_x
@obiPlabon
obiPlabon / gist:b3adc3d871b1913b8572f49bcb2d1c86
Created April 7, 2016 12:46
regular expresstion to find out __ and _e but not esc_html__ or esc_attr_e etc...
[^\w]_[_|e]\(
<?php
/*
Register Fonts
*/
function studio_fonts_url() {
$font_url = '';
/*
Translators: If there are characters in your language that are not supported
by chosen font(s), translate this to 'off'. Do not translate into your own language.
@obiPlabon
obiPlabon / gist:32f8d6f8ed29b0054ea95a9f844ba08b
Created August 8, 2016 07:24 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@obiPlabon
obiPlabon / mb-register.php
Last active August 9, 2016 09:02
Snippet to register WordPress metabox
<?php
function wp_class_register_mb() {
add_meta_box(
'wpclass-mb', // unique id
esc_html__( 'WP Class Metabox', 'text-domain' ), // metabox title
'wp_class_mb_cb', // metabox callback
array('post','page'), // screen name [string|array]
'side', // context
'high' // priority
);
@obiPlabon
obiPlabon / dom-utility.js
Last active September 4, 2016 07:27
Helpful DOM utility functions in venilla JS
// Code written by Me and
// doc written by Zafree [http://github.com/zafree] vai :D
// Get Siblings
// It is a simple function to get all child from parent
// Feel free to use it like a Pro
@obiPlabon
obiPlabon / pmg-rewrite.php
Created December 3, 2016 09:41 — forked from chrisguitarguy/pmg-rewrite.php
WordPress rewrite tutorial
<?php
/*
Plugin Name: Rewrite Rule Tutorials
*/
add_action( 'init', 'pmg_rewrite_add_rewrites' );
function pmg_rewrite_add_rewrites()
{
add_rewrite_endpoint( 'json', EP_PERMALINK );
add_rewrite_rule(
<!-- START header.php -->
<!DOCTYPE html>
<html>
<head>
<!-- Other head stuff lives here -->
<?php wp_head(); ?>
</head>
<body>
<?php
if ( is_page_template( 'special-page-template-name.php' ) ) :