Skip to content

Instantly share code, notes, and snippets.

View tonykwon's full-sized avatar
💭
😃

Tony Kwon tonykwon

💭
😃
View GitHub Profile
@tonykwon
tonykwon / gist:2777679
Created May 23, 2012 20:44
Media Categories Plugin - Slow Query Fix
<?php
///
// Functions Called From Init
///
public function CheckForTermOrderColumn()
{
global $wpdb;
@tonykwon
tonykwon / gist:6215404
Last active December 20, 2015 23:49
Disabling Jetpack sharing_display
add_action( 'plugins_loaded', 'jetpack_sharedaddy' );
function jetpack_sharedaddy() {
if ( class_exists( 'Jetpack' ) &&
method_exists( 'Jetpack', 'get_active_modules' ) &&
in_array( 'sharedaddy', Jetpack::get_active_modules() ) ) {
/*
* we need to control where sharedaddy modules show up
*/
@tonykwon
tonykwon / gist:6225163
Last active December 21, 2015 01:08
WP_DEBUG tweaks - wp-config.php
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);
@tonykwon
tonykwon / gist:6312113
Last active December 21, 2015 13:19
Hiding non-published post menu items from WordPress Menu - for post_type page and post
add_filter( 'wp_get_nav_menu_items', 'hide_non_published_menu_items', 10, 3 );
function hide_non_published_menu_items( $items, $menu, $args ) {
if ( $items ) {
foreach( $items as $k => $item ) {
// use $item->post_type if you want to apply this to custom post types
switch( $item->object ) {
case 'page':
case 'post':
@tonykwon
tonykwon / gist:7790503
Created December 4, 2013 16:23
Extracting iframes from html content
<?php
// $buffer contains the HTML generated
$extracted = array();
$pattern = "#<iframe[^>]+>.*?</iframe>#is";
preg_match_all($pattern, $buffer, $matches);
if ( $matches ) {
@tonykwon
tonykwon / gist:8910261
Created February 10, 2014 04:13
MySQL - Row size too large - BLOB prefix of 768 bytes is stored inline
-- Error Message: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
--
-- our table name that has this issue is XYZ
--
SET GLOBAL innodb_file_format=Barracuda;
SET GLOBAL innodb_file_per_table=ON;
ALTER TABLE XYZ ROW_FORMAT=COMPRESSED;
@tonykwon
tonykwon / gist:ba091c75060d8a0f1507
Created July 24, 2014 15:38
S3 List and Put Only
{
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::{YOUR-BUCKET-NAME-WITHOUT-BRACES}/*"]
},
{
"Effect": "Allow",
"Action": [ "s3:ListAllMyBuckets", "s3:PutObject" ],
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '[$time_local] $remote_addr - $remote_user - $server_name to: $upstream_addr: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time status $status bytes $body_bytes_sent';
#Uncomment to debug rewrite rules
### Keybase proof
I hereby claim:
* I am tonykwon on github.
* I am tonykwon (https://keybase.io/tonykwon) on keybase.
* I have a public key whose fingerprint is 3201 DB4F 8210 4CF0 B74E 5712 B1D3 5CAB 31F1 4372
To claim this, I am signing this object:
@tonykwon
tonykwon / gist:2cf8ff3339c527016792
Created September 11, 2014 21:50
Remove WordPress SEO settings from User Profile Page
# global
global $wpseo_admin;
# this removes when editing 'YOUR PROFILE'
remove_action( 'show_user_profile', array( $wpseo_admin, 'user_profile' ) );
# this removes when editing 'EDIT PROFILE'
remove_action( 'edit_user_profile', array( $wpseo_admin, 'user_profile' ) );