Skip to content

Instantly share code, notes, and snippets.

View eccentricpixel's full-sized avatar

Eccentric Pixel eccentricpixel

View GitHub Profile
@eccentricpixel
eccentricpixel / gist:9a47272425f9c8085b78
Created December 28, 2014 10:05
Here is a fix for equalizer calculating the height of the element before interchange has finished loading the appropriate image. This reinitializes equalizer after the image is set. #foundation
$(document).on('replace', 'img', function() {
$(document).foundation('equalizer', 'reflow');
});
@eccentricpixel
eccentricpixel / gist:464d1ccf36128078f2f3
Created December 28, 2014 07:18
Fix for forcing close action of Foundation 5 reveal modals. The .close-reveal-modal doesn't always work in 5.
// fix for forcing close of foundation modals with close button
$('.close-reveal-modal').on('click tap touchstart', function() {
return $('[data-reveal]').foundation('reveal', 'close');
});
@eccentricpixel
eccentricpixel / gist:e241328a9e3483b6227a
Created December 27, 2014 06:02
Do something when window has stopped resizing; after user has finished dragging window. This is more efficient than just using .resize() which will fire thing incrementally while the user may still be dragging.
var rtime = new Date(1, 1, 2000, 12,00,00);
var timeout = false;
var delta = 200;
$(window).resize(function() {
rtime = new Date();
if (timeout === false) {
timeout = true;
setTimeout(resizeend, delta);
}
@eccentricpixel
eccentricpixel / gist:885aaab3710a38c2a9d1
Last active August 29, 2015 14:11
Custom Pagination for Wordpress
***** for functions.php *****
// custom pagination
function custom_pagination($numpages = '', $pagerange = '', $paged='') {
if (empty($pagerange)) {
$pagerange = 10;
}
@eccentricpixel
eccentricpixel / gist:d7583daf38e7ee69e75a
Last active August 29, 2015 14:11
Efficient way to generate prev and next links for navigation purposes, to traverse between records in a table/pod/post-type. Assumes you are using PODS framework.
============================
/***** a more complex way to get adjacent records based on some parameters *****/
THE CODE
============================
<?php
// grab the id for the current post
$theBookId = get_the_ID();
// grab some related taxonomy to filter by
@eccentricpixel
eccentricpixel / gist:50133b7842b027d9829e
Created December 10, 2014 08:32
Add a column to a custom post type manage screen and make it sortable (replace "book" for your post type and "release_date" for your desired field name). Use switch statement in the ep_get_book_column_values function if you add additional columns in the ep_add_book_columns function.
/* Manipulate the BOOKS ADMIN columns
* ================================================== */
add_filter('manage_edit-book_columns', 'ep_remove_unwanted_columns');
add_filter('manage_edit-book_columns', 'ep_add_book_columns', 5);
add_action('manage_book_posts_custom_column', 'ep_get_book_column_values', 5, 2);
// Remove unwanted columns
function ep_remove_unwanted_columns($defaults){
unset($defaults['author']);
return $defaults;
@eccentricpixel
eccentricpixel / gist:5d0141e1f76f9008a0e3
Created November 22, 2014 10:52
Add tags to media library #WORDPRESS
// apply tags to attachments
function wptp_add_tags_to_attachments() {
register_taxonomy_for_object_type( 'post_tag', 'attachment' );
}
add_action( 'init' , 'wptp_add_tags_to_attachments' );
@eccentricpixel
eccentricpixel / gist:074c6eb749fa49ee6672
Created November 6, 2014 05:38
Since Wordpress continues to be plagued by the problem of stripping tags/html when switching between the visual and text/html tabs in the tinyMCE editor, this snippet added to your theme's functions.php file will disable the visual tab entirely for ALL USERS.
/* Disable visual tab for ALL USERS
* ================================================== */
add_filter('user_can_richedit' , create_function('' , 'return false;') , 50);
@eccentricpixel
eccentricpixel / gist:5c35af7a3912357215e5
Created October 9, 2014 10:30
add custom field as a column in post list and make it sortable.
//Add custom column
add_filter('manage_edit-YOURPOSTTYPENAME_columns', 'my_columns_head');
function my_columns_head($defaults) {
$defaults['YOURCOLUMNNAME'] = 'YOURCOLUMNTITLE';
return $defaults;
}
//Add rows data
add_action( 'manage_YOURPOSTTYPENAME_posts_custom_column' , 'my_custom_column', 10, 2 );
function my_custom_column($column, $post_id ){
switch ( $column ) {
@eccentricpixel
eccentricpixel / gist:c8ac4a7534facb51aa4c
Last active August 29, 2015 14:07
Upgrade of Wordpress' media search function to find matches in the filename which is stored in the GUID column. In the end, a much more user-friendly (client-friendly) experience. Works with modal select windows too (ex: add media buttons).
/* Upgrade the Media search to allow for searching the filename.
* =========================================================== */
add_filter( 'posts_search', 'guid_search_media', 10, 2 );
function guid_search_media( $search, $a_wp_query )
{
global $wpdb, $pagenow;
// Only Admin side && Only Media Library page