Skip to content

Instantly share code, notes, and snippets.

View ivankristianto's full-sized avatar

Ivan Kristianto ivankristianto

View GitHub Profile
@ivankristianto
ivankristianto / sam-ajax.php
Created April 4, 2015 14:44
sam-ajax security fixed
<?php
/**
* Author: minimus
* Date: 24.10.13
* Time: 12:14
*/
define('DOING_AJAX', true);
if (!isset( $_POST['action'])) die('-1');
@ivankristianto
ivankristianto / scrollable_fixed_sidebar
Last active August 29, 2015 14:17
Scrollable and Fixed Sidebar
jQuery(document).ready(function($){
var $body, $window, $sidebar, adminbarOffset, headerHeight, top = false,
bottom = false, windowWidth, windowHeight, lastWindowPos = 0,
topOffset = 0, bodyHeight, sidebarHeight, sidebarWidth, resizeTimer;
// Sidebar scrolling.
function resize() {
windowWidth = $window.width();
windowHeight = $window.height();
bodyHeight = $body.height();
@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]