Skip to content

Instantly share code, notes, and snippets.

View kosinix's full-sized avatar

Kosinix kosinix

  • Philippines
View GitHub Profile
@kosinix
kosinix / cycle2-pager-hide.js
Last active December 19, 2015 16:09
Hide cycle2 pager when there is only 1 slide. Ignores sentinel slide.
var slides = $('.slideshow .slides').children('.slide').length; //Change css selectors accordingly
if(slides <= 1) {
$('.slideshow .pager').hide();
}
@kosinix
kosinix / unregister-post-type.php
Last active December 19, 2015 21:08
There's not currently an unregister_post_type function in WP, but it's quite simple to do with the code provided by Nacin on WordPress Trac:
<?php
if ( ! function_exists( 'unregister_post_type' ) ) :
function unregister_post_type( $post_type ) {
global $wp_post_types;
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
return true;
}
return false;
}
@kosinix
kosinix / get-taxonomy-tree.php
Last active December 19, 2015 21:19
Get taxonomy terms in hierarchichal format in WP
<?php
function get_taxonomy_tree($taxonomy, $parent=0){
$args = array(
'hide_empty'=>false,
'parent'=>$parent
);
$terms = get_terms( $taxonomy, $args );
if($terms){
@kosinix
kosinix / gist:6028573
Created July 18, 2013 11:25
WordPress minimum MySQL privileges. Src: http://stackoverflow.com/a/13771856
ALTER
CREATE
CREATE TEMPORARY TABLES
DELETE
DROP
INDEX
INSERT
LOCK TABLES
SELECT
UPDATE
@kosinix
kosinix / gist:6203439
Created August 11, 2013 04:52
aspect ratio formula
aspect ratio = width / height
eg. 960 / 600 = 1.6:1
height = width / aspect ratio
width = height * aspect ratio
@kosinix
kosinix / gist:6230805
Created August 14, 2013 12:56
Reset positions of metaboxes in admin after dragging them around
In you PhpMyAdmin query for: (if you have a different database prefix, change that in the query, also change the user_id to yours)
SELECT *
FROM `wp_usermeta`
WHERE `user_id` =1
AND `meta_key` LIKE 'meta-box%'
Than delete those values and you will get the original order back. If you only want to change the menu order back for a page than only delete "meta-box-order_page".
/**
* @author Rob W <gwnRob@gmail.com>
* @website http://stackoverflow.com/a/7513356/938089
* @version 20120724
* @description Executes function on a framed YouTube video (see website link)
* For a full list of possible functions, see:
* https://developers.google.com/youtube/js_api_reference
* @param String frame_id The id of (the div containing) the frame
* @param String func Desired function to call, eg. "playVideo"
* (Function) Function to call when the player is ready.
@kosinix
kosinix / responsive-js-debounced.js
Created September 28, 2013 01:37
Using debounce on window resize to perform responsive javascript actions
jQuery(document).ready(function($){
on_resize(function() {
var w = $(window).width();
if(w>=740){ //740-x
jQuery('.main-nav').show();
} else if (w<740){ //0-739
jQuery('.main-nav').hide();
@kosinix
kosinix / gist:7210201
Created October 29, 2013 07:04
php.ini settings ideal for development
max_execution_time = 300
max_input_time = 300
max_input_vars = 2000
memory_limit = 256M