Amanda Giles
@AmandaGilesNH
amandagiles.com/ampup
Mar 25, 2017
*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
*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!!!
1. Logo Image
2. Logo Link
3. Logo ALT text
4. Background Color
5. Button Color
//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/
Go from this:
To this:
// 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/
// 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);
// 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' );
// 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' );
// 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' );
// 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' );
/*
* 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');
// 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
//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;
}
//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' );
// 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!
}
Amanda Giles
amandagiles.com/ampup
@AmandaGilesNH
Heart Graphic from
http://halfblog.net/2012/02/12/wordpress-users-wales-meet-up-wednesday-29th-february/heartpress/

Amp Up Your Admin

  • 1.
  • 2.
    *From NH *Independent ITConsultant 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.
    *Make your clientfeel 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!!!
  • 6.
    1. Logo Image 2.Logo Link 3. Logo ALT text 4. Background Color 5. Button Color
  • 7.
    //Custom CSS forlogin 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/
  • 8.
  • 9.
    // Custom BackendFooter 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/
  • 12.
    // Adds newcolumn 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);
  • 13.
    // 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' );
  • 15.
    // Adds afilter 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' );
  • 17.
    // Apply stylesto 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' );
  • 18.
    // Add GoogleFonts 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' );
  • 20.
    /* * Adding newTinyMCE 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');
  • 21.
    // Callback functionto 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
  • 25.
    //Add widget todashboard 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; }
  • 27.
    //Add Links toAdmin 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' );
  • 29.
    // Add apage 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! }
  • 30.
    Amanda Giles amandagiles.com/ampup @AmandaGilesNH Heart Graphicfrom http://halfblog.net/2012/02/12/wordpress-users-wales-meet-up-wednesday-29th-february/heartpress/