A Simpler WordPress Admin for Clients

A Simpler WordPress Admin for Clients

Some tips and tricks for optimising the WordPress admin to make it easier for clients to get the most out of.

31af50af29856a3e6734bdae0a0d68cf?s=128

Mark Wilkinson

April 26, 2014
Tweet

Transcript

  1. A Simpler WordPress Admin for Clients Mark Wilkinson @wpmark |

    markwilkinson.me
  2. About Me Freelance WordPress Developer Secondary School Teacher of ICT

    - used to lead the ICT department until moving more towards WordPress
  3. pixeljunction.co.uk compass-design.co.uk edupress.co.uk

  4. The Problem Why change the WordPress Admin?

  5. None
  6. None
  7. Solutions

  8. Remove Unnecessary Items In a plugin please! 1 https://github.com/pixeljunction/pxlcore

  9. Menus

  10. Top Level

  11. /*************************************************************** * Function wpmark_remove_admin_menus() * Removes admin menus ***************************************************************/ function

    wpmark_remove_admin_menu() { /* remove the menu item */ remove_menu_page( ‘edit-comments.php’ ); ! } ! add_action( 'admin_menu', 'wpmark_remove_admin_menu', 999 );
  12. /*************************************************************** * Function wpmark_remove_admin_menus() * Removes admin menus ***************************************************************/ function

    wpmark_remove_multiple_admin_menus() { ! $wpmark_admin_menus = array( 'edit-comments.php', ‘tools.php', ); /* loop through each menu item to remove */ foreach( $wpmark_admin_menus as $wpmark_admin_menu ) { /* remove the menu item */ remove_menu_page( $wpmark_admin_menu ); } ! } ! add_action( 'admin_menu', 'wpmark_remove_multiple_admin_menus', 999 );
  13. Sub Level

  14. remove_submenu_page( $menu_slug, $submenu_slug );

  15. remove_submenu_page( $menu_slug, $submenu_slug ); remove_submenu_page( 'themes.php', 'customize.php' );

  16. function wpmark_remove_submenu() { remove_submenu_page( 'themes.php', 'customize.php' ); } ! add_action(

    'admin_menu', 'wpmark_remove_submenu', 99 );
  17. Metaboxes

  18. None
  19. remove_meta_box( $id, $page, $context );

  20. remove_meta_box( $id, $page, $context ); remove_meta_box( 'postcustom', 'post', 'normal' );

  21. function wpmark_remove_multiple_metaboxes() { $wpmark_metaboxes = apply_filters( 'wpmark_removed_metaboxes', array( array( 'id'

    => 'postcustom', 'page' => 'post', 'context' => 'normal' ), array( 'id' => 'tagsdiv-post_tag', 'page' => 'post', 'context' => 'side' ), ) ); /* loop through each meta box item to remove */ foreach( $wpmark_metaboxes as $wpmark_metabox ) { /* remove each metabox from the array */ remove_meta_box( $wpmark_metabox[ 'id' ], $wpmark_metabox[ 'page' ] , $wpmark_metabox[ 'context' ] ); } } add_action( 'do_meta_boxes', 'wpmark_remove_multiple_metaboxes');
  22. Widgets

  23. None
  24. unregister_widget( $widget_class );

  25. unregister_widget( $widget_class ); unregister_widget( 'WP_Widget_Calendar' );

  26. function wpmark_remove_calendar_widget() { unregister_widget( 'WP_Widget_Calendar' ); } ! add_action( 'widgets_init',

    'wpmark_remove_calendar_widget' );
  27. Improve / Enhance What WordPress already gives us 2

  28. Additional Metaboxes

  29. None
  30. register_post_type( 'wpmark_slide', array( 'labels' => $wpmark_slide_labels, 'public' => true, 'menu_position'

    => 90, 'supports' => array( 'title', 'thumbnail' ), ) );
  31. Change a Meta Box

  32. function wpmark_slide_metabox_changes() { ! remove_meta_box( 'postimagediv', 'wpmark_slide', 'side' ); !

    add_meta_box( 'postimagediv', __( 'Slide Image' ), 'post_thumbnail_meta_box', 'wpmark_slide', 'advanced', 'low' ); ! } ! add_action( 'do_meta_boxes', 'wpmark_slide_metabox_changes' );
  33. Add Meta Box

  34. function wpmark_add_meta_box() { ! /* add meta box */ add_meta_box(

    'wpmark_slide_info', // meta box id 'Slide Information', // meta box title 'wpmark_metabox_html', // function for html output 'wpmark_slide', // post type to add it to 'normal', // context - part of page to add it to 'default' // priority ); ! } ! add_action( 'add_meta_boxes', ‘wpmark_add_meta_box' );
  35. Fill Meta Box with Some Content

  36. function wpmark_metabox_html( $post ) { /* use nonce for verification

    */ wp_nonce_field( plugin_basename( __FILE__ ), 'wpmark_nonce_name' ); ?> <table class="form-table pxlsld-metabox"> <tbody> <tr> <th style="width: 18%;"> <label for="wpmark_slide_link"><strong>Slide Link URL</strong></label> </th> <td style="width: 78%;"> <input style="width: 95%;" type="text" value="<?php echo esc_attr( get_post_meta( $post- >ID, '_wpmark_slide_link', true ) ); ?>" name="wpmark_slide_link" /> <p class="pxlsld-description">Enter a URL above for the slide link.</p> </td> </tr> </tbody> </table> <?php }
  37. Save Meta Box Data

  38. function wpmark_save_metabox_data( $post_id ) { ! /* check this is

    the correct post type */ if ( 'wpmark_slide' != get_post_type( $post_id ) return; ! /* check if the current user is authorised to do this action */ if( ! current_user_can( 'edit_page', $post_id ) ) return; ! /* secondly we need to check if the user intended to change this value */ if ( ! isset( $_POST[ 'wpmark_nonce_name' ] ) || ! wp_verify_nonce( $_POST[ 'wpmark_nonce_name' ], plugin_basename( __FILE__ ) ) ) return; ! /* santize the user input */ $wpmark_data = sanitize_text_field( $_POST[ 'wpmark_slide_link'] ); ! /* save the post data */ update_post_meta( $post_id, '_wpmark_slide_link', $wpmark_data ); ! } add_action( 'save_post', 'wpmark_save_metabox_data' );
  39. None
  40. Login Page Logo

  41. None
  42. function wpmark_login_logo() { if( file_exists( STYLESHEETPATH . '/images/login-logo.png' ) )

    { $wpmark_sizes = apply_filters( 'wpmark_login_logo_sizes', array( 'width' => '300', 'height' => '100' ) ); ! echo ' <style> .login h1 a { background-image: url('.get_stylesheet_directory_uri() . '/images/login-logo.png); background-size: ' . $wpmark_sizes[ 'width' ] . 'px' . ' ' . $wpmark_sizes[ 'height' ] . 'px; height: ' . $wpmark_sizes[ 'height' ] . 'px; width: ' . $wpmark_sizes[ 'width' ] . 'px; } </style>'; ! } // end if login logo present in theme ! } ! add_action( 'login_head', 'wpmark_login_logo' );
  43. Add Menu Pages

  44. add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );

  45. None
  46. function wpmark_add_site_options_menu() { add_menu_page( 'Site Options', 'Site Options', 'edit_posts', 'wpmark_site_options',

    'wpmark_site_options_content', 'div', 99 ); } ! add_action( 'admin_menu', 'wpmark_add_site_options_menu' );
  47. function wpmark_site_options_content() { ?> <div id="wrap"> <h2>Site Options Page</h2> </div>

    <?php }
  48. None
  49. Provide Help Support client right in the dashboard 3

  50. “What happens in terms of help after my site goes

    live?” “Can I call you if this go wrong and I get stuck?”
  51. None
  52. None
  53. Remember WordPress is our tool, NOT our solution. Make it

    work best for your clients.
  54. None
  55. ??? Questions & thanks for listening