Skip to content

Instantly share code, notes, and snippets.

View ivankristianto's full-sized avatar

Ivan Kristianto ivankristianto

View GitHub Profile
@ivankristianto
ivankristianto / xclip_to_clipboard
Created March 15, 2015 02:57
Copy to id_rsa.pub to clipboard
xclip -sel clip < ~/.ssh/id_rsa.pub
@ivankristianto
ivankristianto / check_php_codesniffer
Last active August 29, 2015 14:16
Check code PHP code with Codesniffer and use WordPress standard
ivan@ivan:~/missions/wptest/src/wp-content/themes/calibrefx$ sudo phpcs --standard=WordPress $(find . -name '*.php')
ivan@ivan:~/missions/wptest/src/wp-content/themes/calibrefx$ phpcbf --standard=WordPress comments.php
Setup PHP code sniffer with WordPress standard
http://subharanjan.com/setup-php-codesniffer-along-wordpress-coding-standards-windows-xampp/
ivan@ivan:/usr/share/php/PHP/CodeSniffer/Standards/WordPress$
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@ivankristianto
ivankristianto / settings_hook.php
Created April 25, 2014 05:29
Calibrefx Concept Settings Hook
<?php
calibrefx_add_meta_group('themeoption-settings', 'breadcrumb', __('Breadcrumb', 'calibrefx'));
calibrefx_add_meta_group('themeoption-settings', 'content-archive', __('Content Archives', 'calibrefx'));
calibrefx_add_meta_group('themeoption-settings', 'comments', __('Comments', 'calibrefx'));
calibrefx_add_meta_option(
'breadcrumb', // group id
'gplus_profile', // field id and option name
__('Google Plus Profile'), // Label
array(
@ivankristianto
ivankristianto / wp-submenu.php
Created January 17, 2014 10:55
WordPress show submenu based on active parent menu
<?php
// add hook
add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 );
// filter_hook function to react on sub_menu flag
function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) {
if ( isset( $args->sub_menu ) ) {
$root_id = 0;
@ivankristianto
ivankristianto / delete-file.sh
Created January 16, 2014 01:10
Delete all thumbs.db in Linux
find sip-design/ -iname 'thumbs.db' -exec rm -rfv {} +
@ivankristianto
ivankristianto / resumeable-file-download.php
Created December 17, 2013 05:53
Resumeable File Download With PHP
function serve_file_resumable ($file, $contenttype = 'application/octet-stream') {
// Avoid sending unexpected errors to the client - we should be serving a file,
// we don't want to corrupt the data we send
@error_reporting(0);
// Make sure the files exists, otherwise we are wasting our time
if (!file_exists($file)) {
header("HTTP/1.1 404 Not Found");
exit;
@ivankristianto
ivankristianto / wp-cli.sh
Created October 15, 2013 10:16
WP CLi command list
wp core install --url=url --title=site-title [--admin_name=username] --admin_email=email --admin_password=password
wp core [download|config|install|install_network|version|update|update_db]
wp db [create|drop|optimize|repair|connect|cli|query|export|import]
wp eval-file
wp eval
wp export [validate_arguments]
wp generate [posts|users]
wp home
wp option [add|update|delete|get]
@ivankristianto
ivankristianto / apachebenchmarking
Created October 7, 2013 17:54
Testing with apache benchmarking
/usr/local/apache/bin/ab -t 30 -c 5 http://www.seputarukm.com/
@ivankristianto
ivankristianto / gist-wp-embed-url
Created September 22, 2013 01:57
This snippet code is to show gist snippet into the WordPress content with just pasting the URL into post content
wp_embed_register_handler( 'gist', '#https://gist\.github\.com/(.+?)/(.+?)($|&)#i', 'wp_embed_handler_gist' );
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s/%2$s.js"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);