sjrsmile
1/4/2017 - 3:48 PM

CORE functions list

CORE functions list

<?php
/* -----------------------------------------------------------------------
/* menu
/* -------------------------------------------------------------------- */
register_nav_menus(array(
	'primary' => __('Primary Menu', 'developer' ),
	'footerabout' => __('Footer Menu', 'developer' ),
	'copyrightmenu' => __('Copyright Menu', 'developer'),
	));
/* -----------------------------------------------------------------------
/* Load in admin styling sheets
/* -------------------------------------------------------------------- */
function load_admin_style() { wp_enqueue_style('admin_css', get_template_directory_uri() . '/css/admin.css', false ); }
function my_theme_add_editor_styles() { add_editor_style('css/backend_editor.css'); }
add_action('init', 'my_theme_add_editor_styles');
add_action('admin_enqueue_scripts', 'load_admin_style');
/* -----------------------------------------------------------------------
/* Enable thumbnail support
/* -------------------------------------------------------------------- */
add_theme_support('post-thumbnails'); // 0 height means no cropping to height
add_image_size('tiny', 20, 0);
update_option('thumbnail_size_w', 300);	update_option('thumbnail_size_h', 0);
update_option('medium_size_w', 768);		update_option('medium_size_h', 0);
update_option('large_size_w', 9999);		update_option('large_size_h', 0);
/* -----------------------------------------------------------------------
/* Change login screen
/* -------------------------------------------------------------------- */
// Change login logo link URL
function change_login_page_url( $url ) { $link_url = home_url(); return $link_url; }
add_filter('login_headerurl', 'change_login_page_url');
// Change logo login link title
function change_wp_login_title() { return get_option('blogname'); }
add_filter('login_headertitle', 'change_wp_login_title');
// remove stylesheet from login page
function deregister_login_stylesheet() {
	wp_deregister_style('login'); // removes login stylesheet
}
add_action('login_init', 'deregister_login_stylesheet', 100 );
// add header to login sheet
function add_header_to_login() { get_header(); }
add_action('login_head', 'add_header_to_login');
// add footer to login sheet
function add_footer_to_login() { get_footer(); }
add_action('login_footer', 'add_footer_to_login');
// Obscure login
function wpfme_login_obscure(){ return '<strong>Sorry</strong>: You have entered something incorrectly.';}
add_filter('login_errors', 'wpfme_login_obscure');
/* -----------------------------------------------------------------------
/* Allows children in wordpress menu and dropdown arrow
/* for both main menu and sidebar
/* -------------------------------------------------------------------- */
class SH_Arrow_Walker_Nav_Menu extends Walker_Nav_Menu {
	function start_lvl(&$output, $depth = 0, $args = array() ) {
		$indent = str_repeat("\t", $depth);
		if('primary' == $args->theme_location){
			$output .='<img class="menu_child_arrow" src="'.get_stylesheet_directory_uri().'/img/arrow/down-black.png" alt="Open the sub menu" width="16" height="10">';
		}
		$output .= "$indent<ul class=\"sub_menu\">";
	}
}
/* -----------------------------------------------------------------------
/* check the current post for the existence of a shortcode
/* -------------------------------------------------------------------- */
function has_this_got_a_shortcode($shortcode = '') {
	$post_to_check = get_post(get_the_ID());
	$found = false;
	if (!$shortcode) {
		return $found;
	}
	if ( stripos($post_to_check->post_content, '[' . $shortcode) !== false ) {
		$found = true;
	}
	return $found;
}
/* -----------------------------------------------------------------------
/* Remove bums from header
/* -------------------------------------------------------------------- */
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
/* -----------------------------------------------------------------------
/* Remove WordPress REST and JSON from header
/* -------------------------------------------------------------------- */
remove_action('wp_head','rest_output_link_wp_head');
remove_action('wp_head','wp_oembed_add_discovery_links');
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
/* -----------------------------------------------------------------------
/* Remove emoji from header
/* -------------------------------------------------------------------- */
function disable_emojis() {
	remove_action('wp_head', 'print_emoji_detection_script', 7 );
	remove_action('admin_print_scripts', 'print_emoji_detection_script');
	remove_action('wp_print_styles', 'print_emoji_styles');
	remove_action('admin_print_styles', 'print_emoji_styles');
	remove_filter('the_content_feed', 'wp_staticize_emoji');
	remove_filter('comment_text_rss', 'wp_staticize_emoji');
	remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
}
add_action('init', 'disable_emojis');

/* -----------------------------------------------------------------------
/* Check if single category page templates single-[cat slug].php
/* -------------------------------------------------------------------- */
add_filter('single_template', create_function(
	'$the_template',
	'foreach( (array) get_the_category() as $cat ) {
		if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
			return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
		return $the_template;' )
);
/* -----------------------------------------------------------------------
/* Theme support
/* -------------------------------------------------------------------- */
add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) );
/* -----------------------------------------------------------------------
/* Move SEO box to bottom
/* -------------------------------------------------------------------- */
add_filter('wpseo_metabox_prio', function() { return 'low';});
/* -----------------------------------------------------------------------
/* Add to WordPress - Made By
/* -------------------------------------------------------------------- */
function remove_footer_admin () {
	echo 'Site by <a href="http://readysalted.co.uk/">Readysalted</a>.</p>';
}
add_filter('admin_footer_text', 'remove_footer_admin');
function remove_wp_version_strings( $src ) {
	global $wp_version;
	parse_str(parse_url($src, PHP_URL_QUERY), $query);
	if ( !empty($query['ver']) && $query['ver'] === $wp_version ) {
		$src = remove_query_arg('ver', $src);
	}
	return $src;
}
function no_more_footer_version() {
	remove_filter('update_footer', 'core_update_footer');

}
add_action('admin_menu', 'no_more_footer_version');
add_filter('script_loader_src', 'remove_wp_version_strings');
add_filter('style_loader_src', 'remove_wp_version_strings');
/* -----------------------------------------------------------------------
/* Remove height, width and p tag from images in Editor
/* -------------------------------------------------------------------- */
function filter_ptags_on_images($content){ return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); }
function remove_width_attribute( $html ) { $html = preg_replace('/(width|height)="\d*"\s/', "", $html ); return $html; }
add_filter('the_content', 'filter_ptags_on_images');
add_filter('post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter('image_send_to_editor', 'remove_width_attribute', 10 );
/* -----------------------------------------------------------------------
/* Remove default link from media images
/* -------------------------------------------------------------------- */
function wpb_imagelink_setup() {
	$image_set = get_option('image_default_link_type');

	if ($image_set !== 'none') {
		update_option('image_default_link_type', 'none');
	}
}
add_action('admin_init', 'wpb_imagelink_setup', 10);
/* -----------------------------------------------------------------------
/* Remove dashboard queries
/* -------------------------------------------------------------------- */
function remove_dashboard_widgets(){
remove_meta_box('dashboard_right_now', 'dashboard', 'normal');				// Right Now
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');	// Recent Comments
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');		// Incoming Links
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');					// Plugins
remove_meta_box('dashboard_quick_press', 'dashboard', 'side');				// Quick Press
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');			// Recent Drafts
remove_meta_box('dashboard_primary', 'dashboard', 'side');						// WordPress blog
remove_meta_box('dashboard_secondary', 'dashboard', 'side');					// Other WordPress News
remove_meta_box('dashboard_activity', 'dashboard', 'normal');					// Activity of site
remove_meta_box('wpseo-dashboard-overview', 'dashboard', 'normal');		// SEO
remove_meta_box('vfbp-dashboard', 'dashboard', 'normal');							// vfb-pro
// use 'dashboard-network' as the second parameter to remove widgets from a network dashboard.
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
?>