Skip to content

Instantly share code, notes, and snippets.

View steppohub's full-sized avatar

Steppo steppohub

View GitHub Profile
@steppohub
steppohub / admin bar
Last active August 29, 2015 14:06
Hide Admin Bar stuff
// remove help thingo
add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
$screen->remove_help_tabs();
return $old_help;
}
// remove other admin stuff
@steppohub
steppohub / Remove menus
Last active August 29, 2015 14:06
remove menus (like comments)
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
@steppohub
steppohub / embed sizes change default
Created September 19, 2014 05:26
Embed size - change default
// change default auto embed size
add_filter('embed_defaults','aa99_embed_defaults');
function aa99_embed_defaults($defaults) {
$defaults['width']=416;
return $defaults;
}
// disable default dashboard widgets
function disable_default_dashboard_widgets() {
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
remove_meta_box('dashboard_activity', 'dashboard', 'normal');
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
@steppohub
steppohub / Hide pages from non-admins
Last active August 29, 2015 14:06
Hide pages from non administrators
// hide specific pages from the All pages list, choose ids manually!
add_action( 'pre_get_posts' ,'exclude_this_page' );
function exclude_this_page( $query ) {
if( !is_admin() )
return $query;
global $pagenow;
if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
@steppohub
steppohub / target-debug WP menu items
Last active August 29, 2015 14:07
Awesome snippet for debugging WP menu items (mainly to hide them etc)
add_action('admin_init', 'wpse_136058_debug_admin_menu');
function wpse_136058_debug_admin_menu() {
echo '<pre>'.print_r($GLOBALS['menu'], true).'</pre>';
} // function wpse_136058_debug_admin_menu
@steppohub
steppohub / editor-hide
Created November 3, 2014 01:52
Hide Editor on specific pages
<?php
/**
* Hide editor on specific pages.
*
*/
function hide_editor() {
global $pagenow;
if( !( 'post.php' == $pagenow ) ) return;
@steppohub
steppohub / rename posts
Last active August 29, 2015 14:09
Re-name posts to something different
function revcon_change_post_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Books';
$submenu['edit.php'][5][0] = 'Books';
$submenu['edit.php'][10][0] = 'Add Books';
$submenu['edit.php'][16][0] = 'Books Tags';
echo '';
}
function revcon_change_post_object() {
@steppohub
steppohub / add new custom post type
Last active August 29, 2015 14:09
Add new custom post type
function my_custom_post_product() {
$labels = array(
'name' => _x( 'Products', 'post type general name' ),
'singular_name' => _x( 'Product', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Product' ),
'edit_item' => __( 'Edit Product' ),
'new_item' => __( 'New Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
@steppohub
steppohub / add custom taxonomy for custom post type
Created November 13, 2014 00:15
Add custom taxonomy for a custom post type
function my_taxonomies_news() {
$labels = array(
'name' => _x( 'News Categories', 'taxonomy general name' ),
'singular_name' => _x( 'News Category', 'taxonomy singular name' ),
'search_items' => __( 'Search News Categories' ),
'all_items' => __( 'All News Categories' ),
'parent_item' => __( 'Parent News Category' ),
'parent_item_colon' => __( 'Parent News Category:' ),
'edit_item' => __( 'Edit News Category' ),
'update_item' => __( 'Update News Category' ),