Skip to content

Instantly share code, notes, and snippets.

View fikrirasyid's full-sized avatar
💭
writing commit messages

Fikri Rasyid fikrirasyid

💭
writing commit messages
View GitHub Profile
@fikrirasyid
fikrirasyid / removing-all-actions-from-hook
Created August 28, 2014 15:38
Removing All Actions From Hook
/**
* Unhook all action with some exception on wp_head and wp_footer
*/
function fr_unhook_wp_head_footer(){
global $wp_filter; // Where all the hooks and their actions are stored
// Actions that should not be removed from the wp_head hook
$wp_head_whitelist = array( 'wp_enqueue_scripts', 'wp_print_styles', 'wp_print_head_scripts' );
// Unhook actions from wp_head
@fikrirasyid
fikrirasyid / gist:10739e0241bfffeeaa91
Created September 2, 2014 00:10
WordPress: Use Custom Template From Plugins
/**
* Route single page to custom template
*
* @return string of path
*/
function fr_route_template( $single_template ){
// Put any conditional tag here. This one assumes you want to serve custom template for CPT titled "newsletter"'s single page
if( is_singular( 'newsletter' ) ){
@fikrirasyid
fikrirasyid / Randomizing WP_Query's Posts Order
Created October 5, 2014 10:21
Randomizing WP_Query's Posts Order
/**
* Assuming you want 8 latest posts and excluding sticky posts
*/
$posts_args = array(
'ignore_sticky_posts' => true,
'posts_per_page' => 8
);
$posts = new WP_Query( $posts_args );
@fikrirasyid
fikrirasyid / gist:5116160
Created March 8, 2013 12:30
Meta box theme 27
/*
* --------------------------------------------------------------------------------------------------------------------------------
* CUSTOM META BOXES FOR EASIER CONTENT EDITING
* --------------------------------------------------------------------------------------------------------------------------------
*/
add_action( 'add_meta_boxes', 'wp_meta_boxes_add' );
function wp_meta_boxes_add(){
// Custom Meta Boxes for post-type post
add_meta_box( 'binus-meta-boxes', 'BINUS Meta Information', 'wp_meta_boxes', 'post', 'normal', 'high' );
}
@fikrirasyid
fikrirasyid / gist:6c5fdaf5f094779938f0
Created April 27, 2015 10:43
EDITED - Gruntfile.js for making .zip file for WordPress theme
'use strict';
module.exports = function(grunt){
// load all tasks
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
makepot: {
target: {
@fikrirasyid
fikrirasyid / gist:95c12103753f9f2352ca
Last active August 29, 2015 14:19
Gruntfile.js for making .zip file for Patio theme
'use strict';
module.exports = function(grunt){
// load all tasks
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
makepot: {
target: {
@fikrirasyid
fikrirasyid / gist:83e67de47feeb8fc8ba6
Created March 12, 2015 02:15
Ajaxifying Comment - Send Comment as AJAX Call
jQuery(document).ready(function($){
/**
* Ajaxify Comment Submission
* Assuming that comment form's ID is #commentform. Adjust it as you see fit
*/
$('body').on('submit', '#commentform', function(e){
// Stop the default form behavior
e.preventDefault();
var commentform = $(this);
@fikrirasyid
fikrirasyid / gist:d9e83deb4e73fa964d72
Created March 12, 2015 02:14
Ajaxifying Comment - Add "submitting comment" message:
/**
* Adding processing message at comment form
* Use inline style so we don't need to load more file
*/
function simple_ajax_comment_form_mod( $settings ){
printf( '<div id="submitting-comment" style="padding: 15px 20px; text-align: center; display: none;">%s</div>', __( 'Submitting comment...' ) );
}
add_action( 'comment_form', 'simple_ajax_comment_form_mod' );
@fikrirasyid
fikrirasyid / gist:7242efb1b8359d23f619
Last active August 29, 2015 14:16
Ajaxifying Comment - Load Javascript script & its Javascript params
/**
* Load the script
* Most of the time, the script will be used at is_singular(). Make this pluggable tho, just in case the single page is displayed as overlay on other page
*/
function simple_ajax_comment_script(){
if( apply_filters( 'simple_ajax_comment_is_used', is_singular() ) ){
/**
* Load the js script
*/
wp_enqueue_script( 'simple-ajax-comment-script', plugin_dir_url( __FILE__ ) . 'js/simple-ajax-comment.js' , array( 'jquery', 'jquery-form' ), '1.0.0' );
@fikrirasyid
fikrirasyid / SassMeister-input.scss
Created February 8, 2015 00:28
Generated by SassMeister.com.
// ----
// Sass (v3.4.11)
// Compass (v1.0.3)
// ----
$color: #F44336;
$darken: darken( $color, 10% );
$lighten: lighten( $color, 10% );
.box{