Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

The Problem Why change the WordPress Admin?

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Solutions

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Menus

Slide 10

Slide 10 text

Top Level

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Sub Level

Slide 14

Slide 14 text

remove_submenu_page( $menu_slug, $submenu_slug );

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Metaboxes

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Widgets

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

unregister_widget( $widget_class );

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Improve / Enhance What WordPress already gives us 2

Slide 28

Slide 28 text

Additional Metaboxes

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

Change a Meta Box

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Add Meta Box

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

Fill Meta Box with Some Content

Slide 36

Slide 36 text

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.

Slide 37

Slide 37 text

Save Meta Box Data

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Login Page Logo

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

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 ' .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; } '; ! } // end if login logo present in theme ! } ! add_action( 'login_head', 'wpmark_login_logo' );

Slide 43

Slide 43 text

Add Menu Pages

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

function wpmark_site_options_content() { ?>

Site Options Page

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Provide Help Support client right in the dashboard 3

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

??? Questions & thanks for listening