yan-k
1/14/2016 - 2:16 PM

WordPress Snippets

WordPress Snippets

// Post thumbnails support
add_theme_support('post-thumbnails');

// Menu support
add_theme_support('menus');
<?php 
// Post editor styling
add_theme_support('editor-style');

// Post formats support
add_theme_support( 'post-formats', array( 'aside', 'gallery','link','image','quote','status','video','audio','chat' ) );

// Clean up header elements
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');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);

// remove adminbar
remove_action( 'init', 'wp_admin_bar_init' );
add_action( 'show_admin_bar', '__return_false' );

// Permalinks with ÆØÅæøå (and other special characters)
if ( !function_exists('sanitize_title_dk') )
{
	$translate_language = 'da';
	$translate_system = array();
	function sanitize_title_dk($title)
	{
		global $translate_language, $translate_system;
		if (!mb_check_encoding($title, 'ASCII'))
	{
		//$title = utf8_decode($title);
		$translate_system[] = array ( "æ" => "ae", "ø" => "oe", "å" => "aa", "Æ" => "ae", "Ø" => "oe", "Å" => "aa"  );
		foreach ($translate_system as $system)
		{
		$title = strtr($title, $system);
		};
	};
	return $title;
	};
add_filter('sanitize_title', 'sanitize_title_dk', 0);
};

// add feed links to header
if (function_exists('automatic_feed_links')) {
	automatic_feed_links();
} else {
	return;
}

// enable threaded comments
function enable_threaded_comments(){
	if (!is_admin()) {
		if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
			wp_enqueue_script('comment-reply');
		}
}
add_action('get_header', 'enable_threaded_comments');