Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@blickwert
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blickwert/22531758a2ed593fe4dd to your computer and use it in GitHub Desktop.
Save blickwert/22531758a2ed593fe4dd to your computer and use it in GitHub Desktop.
Wordpress functionality
// activate statify for editor
add_action('admin_init', 'add_theme_caps');
function add_theme_caps() {
$role = get_role('editor');
$role->add_cap('edit_dashboard');
}
// wp_list_pages - add a haschildren class to parent
add_filter( 'page_css_class', 'add_parent_class', 10, 4 );
function add_parent_class( $css_class, $page, $depth, $args ) {
if ( ! empty( $args['has_children'] ) )
$css_class[] = 'has_children';
return $css_class;
}
// 2.7 add current class to wp_list_categories on single posts
add_filter('wp_list_categories','style_current_cat_single_post');
function style_current_cat_single_post($output) {
if( is_single() ) :
global $post;
foreach ( get_the_category($post->ID) as $cat ) {
$cats[] = $cat->term_id;
}
foreach($cats as $value) {
if(preg_match('#item-' . $value . '">#', $output)) {
$output = str_replace('item-' . $value . '">', 'item-' . $value . ' current-cat">', $output);
}
}
endif;
return $output;
}
// 2.9 deactivate Contractform7 JS & CSS
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
// hide WordPress Update Notification for notadmins
add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );
function hide_update_notice_to_all_but_admin_users() {
if (!current_user_can('update_core')) {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
function remove_dashboard_widgets(){
global $wp_meta_boxes;
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
}
// 2.5 remove metaboxes from admin
add_action( 'admin_menu', 'my_remove_meta_boxes' );
function my_remove_meta_boxes() {
remove_meta_box('postexcerpt', 'post', 'normal');
remove_meta_box('trackbacksdiv', 'post', 'normal');
remove_meta_box('slugdiv', 'post', 'normal'); remove_meta_box('slugdiv', 'page', 'normal');
remove_meta_box('authordiv', 'post', 'normal'); remove_meta_box('authordiv', 'page', 'normal');
remove_meta_box('revisionsdiv', 'post', 'normal'); remove_meta_box('revisionsdiv', 'page', 'normal');
// remove_meta_box('postcustom', 'post', 'normal'); remove_meta_box('postcustom', 'page', 'normal');
}
// 2.4 Remove Metatags
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'framework');
// 2.1 theme support
add_theme_support( 'post-thumbnails' ); // Pages only
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment