amp up your admin

30
Amp Up Your Admin Amanda Giles @AmandaGilesNH amandagiles.com/ampup Mar 25, 2017

Upload: amanda-giles

Post on 05-Apr-2017

62 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Amp Up Your Admin

Amp Up Your Admin

Amanda Giles@AmandaGilesNH

amandagiles.com/ampupMar 25, 2017

Page 2: Amp Up Your Admin

Who Am I?*From NH

*Independent IT Consultant for over 10 years

*Using WordPress since 2009

*Speaking at WordCamps since 2014

*WordPress Theme Developer

*Founded the Seacoast NH

WordPress Meetup in 2011

*Founded Spark Development in 2016

*Kettlebeller

*Poetess

*Epic Sneezes

Page 3: Amp Up Your Admin

Amp Up? Huh?*Make your client feel welcome (i.e. brand the site)*Make help and contact info easily accessible*Give them access to more data*Give them a better content editing experience*Give them access to more information!!!

Page 4: Amp Up Your Admin

Make Your Client Feel Welcome

Page 5: Amp Up Your Admin
Page 6: Amp Up Your Admin

1. Logo Image2. Logo Link3. Logo ALT text

4. Background Color5. Button Color

Page 7: Amp Up Your Admin

Make Your Client Feel Welcome

//Custom CSS for login pagefunction login_css() {

wp_enqueue_style('login-page',

get_template_directory_uri() . '/css/login.css', false );

}

// Change logo link from wordpress.org to your site’s urlfunction login_url() { return home_url(); }

// Change the alt text on the logo to show your site’s namefunction login_title() { return get_option('blogname'); }

// calling it only on the login pageadd_action( 'login_enqueue_scripts', 'login_css', 10 );add_filter( 'login_headerurl', 'login_url');add_filter( 'login_headertitle', 'login_title');

From Bones theme by Eddie Machado - http://themble.com/bones/

Page 8: Amp Up Your Admin

Go from this:

To this:

Promote Yourself / Contact Info

Page 9: Amp Up Your Admin

Promote Yourself / Contact Info

// Custom Backend Footerfunction custom_admin_footer() { ?>

<span id="footer-thankyou">Developed by <a href="http://amandagiles.com" target="_blank">Amanda Giles</a>. For help with this site, please <a href="mailto:[email protected]">email me</a>.<span>

<?php }

// adding it to the admin areaadd_filter('admin_footer_text', 'custom_admin_footer');

From Bones theme by Eddie Machado - http://themble.com/bones/

Page 10: Amp Up Your Admin

Add information to Admin lists

Page 11: Amp Up Your Admin

Add information to Admin lists

Page 12: Amp Up Your Admin

Add information to Admin lists// Adds new column headers to 'movies' post type

function movies_add_new_columns($columns) { //Remove irrelevant columns unset($columns['author']); unset($columns['comments']); unset($columns['date']); $columns['release'] = 'Release Date';return $columns;}add_filter('manage_edit-movies_columns', 'movies_add_new_columns');

// Adds content to new columns for 'movies' post type function movies_manage_columns($column_name, $id) {global $post;switch ($column_name) {case 'release':echo get_post_meta( $post->ID , 'release-year' , true );break;} }add_action('manage_movies_posts_custom_column', 'movies_manage_columns', 10, 2);

Page 13: Amp Up Your Admin

Make that information sortable// Make new 'movies' columns sortable

function movies_columns_sortable($columns) {

$custom = array(

'release' => 'release',

);

return wp_parse_args($custom, $columns);

}

add_filter('manage_edit-movies_sortable_columns', 'movies_columns_sortable');

// Handle ordering for 'movies' columns function movies_columns_orderby( $vars ) {

if ( isset( $vars['orderby'] ) ) {

if ( 'release' == $vars['release'] )

$vars = array_merge( $vars, array(

'orderby' => 'meta_value_num', 'meta_key' => 'release-year') );

}

return $vars;

}

add_filter( 'request', 'movies_columns_orderby' );

Page 14: Amp Up Your Admin

Add a Taxonomy Filter

Page 15: Amp Up Your Admin

Add a Taxonomy Filter// Adds a filter in the Admin list pages on taxonomy for easier locating function movie_genre_filter_admin_content() {

global $typenow;

if( $typenow == "movies") { $taxonomies = array('genre'); }

if (isset($taxonomies)) {

foreach ($taxonomies as $tax_slug) {

$tax_obj = get_taxonomy($tax_slug);

$tax_name = $tax_obj->labels->name;

$terms = get_terms($tax_slug);

echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";

echo "<option value=''>Show All $tax_name</option>";

foreach ($terms as $term) {

$label = (isset($_GET[$tax_slug])) ? $_GET[$tax_slug] : '';

echo '<option value='. $term->slug,

$label == $term->slug ? ' selected="selected"' : '','>' .

$term->name .'</option>';

}

}

}

}

add_action( 'restrict_manage_posts', 'movie_genre_filter_admin_content' );

Page 16: Amp Up Your Admin

Style Content Editor

Page 17: Amp Up Your Admin

Style Content Editor

// Apply styles to content editor to make it match the sitefunction add_custom_editor_style() { //Looks for an 'editor-style.css' in your theme folder add_editor_style();

//Or call it with a custom file name if you choose //(helpful especially when keeping css in a subfolder) //add_editor_style('css/my-editor-style.css');}add_action( 'admin_init', 'add_custom_editor_style' );

Page 18: Amp Up Your Admin

Even use Google Fonts!

// Add Google Fonts to the Admin editor function add_google_fonts_admin_editor() {

$font_url = 'https://fonts.googleapis.com/css?family=Dancing+Script:400,700';

//Encode Google Fonts URL if it contains commas add_editor_style( esc_url( $font_url ) );

}

add_action( 'admin_init', 'add_google_fonts_admin_editor' );

Page 19: Amp Up Your Admin

Style Content Editor

Page 20: Amp Up Your Admin

Add custom styles to editor

/* * Adding new TinyMCE styles to editor * https://codex.wordpress.org/TinyMCE_Custom_Styles */

// Callback function to insert 'styleselect' into the $buttons arrayfunction add_tiny_mce_buttons( $buttons ) {array_unshift( $buttons, 'styleselect' );return $buttons;}// Register our callback to the appropriate filter (2 means 2nd row)add_filter('mce_buttons_2', 'add_tiny_mce_buttons');

Page 21: Amp Up Your Admin

Add custom styles to editor// Callback function to filter the Tiny MCE settings

function tiny_mce_add_styles( $init_array ) { // Define the style_formats array$style_formats = array( // Each array child is a format with its own settingsarray( 'title' => 'Blue Title', 'block' => 'div', 'classes' => 'blue-title') ); // Insert the array, JSON ENCODED, into 'style_formats'$init_array['style_formats'] = json_encode( $style_formats );

return $init_array; } add_filter('tiny_mce_before_init','tiny_mce_add_styles' );

More details at: https://codex.wordpress.org/TinyMCE_Custom_Styles

Page 22: Amp Up Your Admin

Add custom styles to editor

Page 23: Amp Up Your Admin

Add custom styles to editor

Page 24: Amp Up Your Admin

Add custom styles to editor

Page 25: Amp Up Your Admin

Add Dashboard Widget//Add widget to dashboard pagefunction add_movies_dashboard_widgets() {

wp_add_dashboard_widget('movies-widget', 'Recent Movies', 'movies_dashboard_widget');

}

add_action('wp_dashboard_setup', 'add_movies_dashboard_widgets');

//Dashboard widget logic (can be anything!)function movies_dashboard_widget() {

$args = array ( 'post_type' => 'movies', 'posts_per_page' => 5 );

$movies = new WP_Query( $args );

if($movies->have_posts()) :

while($movies->have_posts()): $movies->the_post();

echo '<div style="margin-bottom: 10px;">';

$url = home_url() . "/wp-admin/post.php?post=" . get_the_id() . '&action=edit';

echo '<a href="' . $url . '">' . get_the_title() . '</a> - ';

echo get_post_meta( get_the_id(), 'release-year' , true ) . '</div>';

endwhile;

endif;

}

Page 26: Amp Up Your Admin

Add Dashboard Widget

Page 27: Amp Up Your Admin

Add Admin Bar Link

//Add Links to Admin Barfunction movie_admin_bar_link( $wp_admin_bar ) {

//Only add link for Admins if (current_user_can( 'manage_options' )) {

$args = array(

'id' => 'movies-page',

'title' => 'Manage Movies',

'href' => home_url() . '/wp-admin/edit.php?post_type=movies',

'meta' => array( 'class' => 'movies-admin-link' )

);

$wp_admin_bar->add_node( $args );

}

}

add_action( 'admin_bar_menu', 'movie_admin_bar_link' );

Page 28: Amp Up Your Admin

Add Admin Bar Link

Page 29: Amp Up Your Admin

// Add a page to WP Menufunction add_help_admin_pages() { add_menu_page('Page Title', 'Menu Title', 'edit_posts', 'unique-menu-slug', 'admin_help_page_function');} add_action('admin_menu', 'add_help_admin_pages');

//Define content for that pagefunction admin_help_page_function() { //Can be anything you want!}

Add Help Page

Page 30: Amp Up Your Admin

Thank You!

Amanda Giles

amandagiles.com/ampup

@AmandaGilesNH

Heart Graphic from http://halfblog.net/2012/02/12/wordpress-users-wales-meet-up-wednesday-29th-february/

heartpress/