$30 off During Our Annual Pro Sale. View Details »

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.

Mark Wilkinson

April 26, 2014
Tweet

More Decks by Mark Wilkinson

Other Decks in Technology

Transcript

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

    View Slide

  2. About Me
    Freelance WordPress Developer
    Secondary School Teacher of ICT - used to lead
    the ICT department until moving more towards
    WordPress

    View Slide

  3. pixeljunction.co.uk
    compass-design.co.uk
    edupress.co.uk

    View Slide

  4. The Problem
    Why change the WordPress Admin?

    View Slide

  5. View Slide

  6. View Slide

  7. Solutions

    View Slide

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

    View Slide

  9. Menus

    View Slide

  10. Top Level

    View Slide

  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 );

    View Slide

  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 );

    View Slide

  13. Sub Level

    View Slide

  14. remove_submenu_page( $menu_slug, $submenu_slug );

    View Slide

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

    View Slide

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

    View Slide

  17. Metaboxes

    View Slide

  18. View Slide

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

    View Slide

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

    View Slide

  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');

    View Slide

  22. Widgets

    View Slide

  23. View Slide

  24. unregister_widget( $widget_class );

    View Slide

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

    View Slide

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

    View Slide

  27. Improve / Enhance
    What WordPress already gives us
    2

    View Slide

  28. Additional
    Metaboxes

    View Slide

  29. View Slide

  30. register_post_type( 'wpmark_slide',
    array(
    'labels' => $wpmark_slide_labels,
    'public' => true,
    'menu_position' => 90,
    'supports' => array(
    'title',
    'thumbnail'
    ),
    )
    );

    View Slide

  31. Change a Meta Box

    View Slide

  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' );

    View Slide

  33. Add Meta Box

    View Slide

  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' );

    View Slide

  35. Fill Meta Box with Some Content

    View Slide

  36. function wpmark_metabox_html( $post ) {
    /* use nonce for verification */
    wp_nonce_field( plugin_basename( __FILE__ ), 'wpmark_nonce_name' );
    ?>




    Slide Link URL



    Enter a URL above for the slide link.




    }

    View Slide

  37. Save Meta Box Data

    View Slide

  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' );

    View Slide

  39. View Slide

  40. Login Page
    Logo

    View Slide

  41. View Slide

  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 '
    <br/>.login h1 a {<br/>background-image: url('.get_stylesheet_directory_uri() . '/images/login-logo.png);<br/>background-size: ' . $wpmark_sizes[ 'width' ] . 'px' . ' ' . $wpmark_sizes[ 'height' ] . 'px;<br/>height: ' . $wpmark_sizes[ 'height' ] . 'px;<br/>width: ' . $wpmark_sizes[ 'width' ] . 'px;<br/>}<br/>';
    !
    } // end if login logo present in theme
    !
    }
    !
    add_action( 'login_head', 'wpmark_login_logo' );

    View Slide

  43. Add Menu
    Pages

    View Slide

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

    View Slide

  45. View Slide

  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' );

    View Slide

  47. function wpmark_site_options_content() {
    ?>

    Site Options Page

    }

    View Slide

  48. View Slide

  49. Provide Help
    Support client right in the dashboard
    3

    View Slide

  50. “What happens in terms of help after my site
    goes live?”
    “Can I call you if this go wrong and I get
    stuck?”

    View Slide

  51. View Slide

  52. View Slide

  53. Remember
    WordPress is our tool, NOT our
    solution. Make it work best for your
    clients.

    View Slide

  54. View Slide

  55. ???
    Questions
    &
    thanks for listening

    View Slide