Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Amp Up Your Admin

197 views

Published on

Want to give the WordPress admin area some professional polish? Want to make it super easy for your clients to locate and work with their most critical data? How about making it super easy for your client to contact you? This talk will provide theme developers with ideas to do just that along with the PHP code snippets to make it a reality. Take the WordPress admin experience to the next level!

Published in: Internet
  • Very nice tips on this. In case you need help on any kind of academic writing visit website ⇒ www.HelpWriting.net ⇐ and place your order
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Amp Up Your Admin

  1. 1. Amanda Giles @AmandaGilesNH amandagiles.com/ampup Mar 25, 2017
  2. 2. *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
  3. 3. *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!!!
  4. 4. 1. Logo Image 2. Logo Link 3. Logo ALT text 4. Background Color 5. Button Color
  5. 5. //Custom CSS for login page function 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 url function login_url() { return home_url(); } // Change the alt text on the logo to show your site’s name function login_title() { return get_option('blogname'); } // calling it only on the login page add_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/
  6. 6. Go from this: To this:
  7. 7. // Custom Backend Footer function 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:amanda@amandagiles.com">email me</a>. <span> <?php } // adding it to the admin area add_filter('admin_footer_text', 'custom_admin_footer'); From Bones theme by Eddie Machado - http://themble.com/bones/
  8. 8. // 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);
  9. 9. // 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' );
  10. 10. // 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' );
  11. 11. // Apply styles to content editor to make it match the site function 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' );
  12. 12. // 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' );
  13. 13. /* * Adding new TinyMCE styles to editor * https://codex.wordpress.org/TinyMCE_Custom_Styles */ // Callback function to insert 'styleselect' into the $buttons array function 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');
  14. 14. // 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 settings array( '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
  15. 15. //Add widget to dashboard page function 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; }
  16. 16. //Add Links to Admin Bar function 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' );
  17. 17. // Add a page to WP Menu function 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 page function admin_help_page_function() { //Can be anything you want! }
  18. 18. Amanda Giles amandagiles.com/ampup @AmandaGilesNH Heart Graphic from http://halfblog.net/2012/02/12/wordpress-users-wales-meet-up-wednesday-29th-february/heartpress/

×