Skip to content

Instantly share code, notes, and snippets.

@JackNUMBER
JackNUMBER / gist:9893411
Created March 31, 2014 14:22
[Wordpress] Test image size
<?
$thumb = get_post_thumbnail_id();
$path = wp_get_attachment_image_src($thumb);
$dimensions = getimagesize($path[0]);
$size = 300;
if ($dimensions[1] < $size) echo 'Larger than ' . $size . 'px';
@JackNUMBER
JackNUMBER / gist:9893749
Created March 31, 2014 14:35
[Wordpress] Disable updates check
<?
/* In functions.php */
// Disable Wordpress update check
add_filter('pre_site_transient_update_core', create_function('$a', "return null;"));
wp_clear_scheduled_hook('wp_version_check');
// Disable theme update check
remove_action('load-update-core.php', 'wp_update_themes');
@JackNUMBER
JackNUMBER / gist:ecddc4529b8939017987
Created August 12, 2014 20:23
[Wordpress] List categories in a taxonomy
<?
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false
);
$categories = get_terms('taxonomy_name', $args);
@JackNUMBER
JackNUMBER / gist:d422f391177b3f20682b
Last active August 29, 2015 14:05
[Wordpress] Display current template file
<?php
/* in function.php */
// For debugging - display current template file
add_action('wp_head', 'show_template');
function show_template() {
global $template;
print_r($template);
}
@JackNUMBER
JackNUMBER / gist:6ce25d0d43a5ff6fb8ce
Last active August 29, 2015 14:06
[Wordpress] SVG upload
<?php
/* add this to functions.php */
// allow SVG uploads
function allow_svg_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'allow_svg_mime_types');
@JackNUMBER
JackNUMBER / gist:4f510f6b04b34ac123dd
Last active August 29, 2015 14:06
[Wordpress] Avoid auto <p>
<?
/* add this in functions.php */
// avoid auto <p>
remove_filter('the_content', 'wpautop');
@JackNUMBER
JackNUMBER / gist:0846f746eedb78428712
Created September 8, 2014 14:50
[Wordpress] Clean the head
<?
/* add this in functions.php */
// remove elements from head
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
@JackNUMBER
JackNUMBER / gist:0f67aa3a2b53986752f6
Last active August 29, 2015 14:06
[Wordpress] Change revision parameters
<?
/* add one of this lines in WP-config.php (before Auth key) */
/** Define revision number */
define('WP_POST_REVISIONS', 10);
/** Disabled revision */
define('WP_POST_REVISIONS', false);
@JackNUMBER
JackNUMBER / gist:5525715305c8443a9d5e
Last active August 29, 2015 14:06
[Wordpress] Auto-empty trash
<?
/* add one of this lines in WP-config.php (before Auth key) */
// Define number of days old to empty trash
define('EMPTY_TRASH_DAYS', 3);
@JackNUMBER
JackNUMBER / gist:60b4001228fd5c02229c
Created June 20, 2015 13:29
[Wordpress] Remove emoji/emoticons external script
<?
/* in functions.php*/
// remove emoticons external script
remove_action('wp_head', 'print_emoji_detection_script', 7);
// remove completely CSS/JS scripts (new emoticons are always enabled)
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');