Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Admin Customisations for a 1-page WordPress web...

Admin Customisations for a 1-page WordPress website.

Sometimes we build WordPress sites that are just 1 pagers. These are quite popular at the moment. We spend a lot of time, making the front end experience exciting, with features such a parallax scrolling etc. However we often neglect the admin leaving it as the default experience. In this talk I outline how I have removed a lot of the bloated admin interface which is not needed for a 1 page WordPress site making the editor experience much better.

Mark Wilkinson

November 22, 2015
Tweet

More Decks by Mark Wilkinson

Other Decks in Programming

Transcript

  1. THE GOAL Everything editable from one screen Remove the admin

    clutter Still allow full access for some users
  2. 1 Edit Post/Page Edit Screen function wpaop_remove_editor_on_pages() { remove_post_type_support( 'page',

    'editor' ); remove_post_type_support( 'page', 'page-attributes' ); remove_post_type_support( 'page', 'title' ); } add_action( 'admin_init', 'wpaop_remove_editor_on_pages' );
  3. 3 Remove Top Level Menus function wpaop_remove_admin_menus( $menus ) {

    $menus[] = 'edit.php'; $menus[] = 'edit.php?post_type=page'; $menus[] = 'themes.php'; $menus[] = 'wpbasis_dashboard'; return $menus; } add_filter( 'wpbasis_remove_admin_menus', 'wpaop_remove_admin_menus' );
  4. 4 Add Top Level Menus Content – Post edit screen

    for home page Menus – move from Appearance to top level menu
  5. 4 Remove Top Level Menus function wpaop_add_admin_pages() { if( wpbasis_is_wpbasis_user()

    ) { return; } add_menu_page( Content’,'Content’,'edit_posts’,'post.php? post=2&action=edit’, '’, 'dashicons-admin-page’, 9 ); add_menu_page( Menus’,’Menus’,'edit_posts’,’nav-menus.php’, '’, 'dashicons-menu’, 61 ); } add_action( 'admin_menu', 'wpaop_add_admin_pages' );
  6. 5 Edit Capabilities function wpaop_caps( $caps ) { $caps[ 'edit_pages'

    ] = array( 'name' => 'edit_pages', 'action' => false, ); return $caps; } add_filter( 'wpbasis_user_capabilities', 'wpaop_caps' );
  7. 6 Correct the Admin Bar function wpaop_admin_bar_admin_url() { if( is_admin()

    ) { return home_url( '/' ); } else { $home_id = get_option( 'page_on_front', 2 ); /* return the new login redirect location */ return admin_url( 'post.php?post=' . absint( $home_id ) . '&action=edit' ); } } add_filter( 'wpbasis_admin_bar_site_admin_link_url', 'wpaop_admin_bar_admin_url' );
  8. 7 Redirect on Successful Login function wpaop_login_redirect( $redirect_to, $request, $user

    ) { $home_id = get_option( 'page_on_front', 2 ); return admin_url( 'post.php?post=' . absint( $home_id ) . '&action=edit' ); } add_filter( 'login_redirect', ‘wpaop_login_redirect', 10, 3 );