Skip to content

Instantly share code, notes, and snippets.

var isIE = /*@cc_on!@*/false || !!document.documentMode, // Internet Explorer 6-11
isEdge = !isIE && !!window.StyleMedia; // Edge 20+
if(isIE || isEdge) {
// do something...
}
@jnicol
jnicol / functions.php
Last active August 29, 2015 14:17
WordPress: Customize the number of posts displayed per Custom Post Type
/**
* Customize number of posts displayed per Custom Post Type
*
* @see https://mondaybynoon.com/wordpress-posts-per-page-per-custom-post-type/
*/
function custom_posts_per_page($query) {
if(!is_admin()) {
switch ($query->query_vars['post_type']) {
case 'name_of_cpt1':
$query->query_vars['posts_per_page'] = -1;
@jnicol
jnicol / functions.php
Last active January 7, 2019 10:31
Sanitize WordPress filenames on upload
/**
* WordPress allows UTF8 characters such as copyright symbol in filenames but these break in Safari
*
* @see https://wordpress.org/support/topic/uploaded-image-with-accents-in-name-image-dont-show-in-safari-6 for original function
* @see https://core.trac.wordpress.org/ticket/22363 for progress on fixing this bug
*
* #wordpress
*/
function sanitize_filename_on_upload($filename) {
$ext = end(explode('.',$filename));