Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*****************************************
- * WordPress Admin Customization Snippets
- *
- * These are several snippets that can be used to customise your WordPress Admin Dashboard
- * by removing specific elements/items from it and even adding custom ones.
- *
- * These can be added to a plugin or theme's functions.php file and customised as needed.
- * I HIGHLY recommend renaming the functions with more unique names to lessen the potential
- * for name collisions with other plugins/themes.
- */
- /**
- * Remove WP Admin Menu Panels
- *
- * This hides complete groups from the admin menu, such as 'Links', 'Media', 'Pages', etc.
- * The sections are still accessible by typing in the direct URL, but they are removed
- * from the menu itself.
- *
- * @link http://sixrevisions.com/wordpress/how-to-customize-the-wordpress-admin-area/
- * @param void
- * @return void
- */
- function remove_menu_items()
- {
- global $menu;
- // The menu items to hide
- $restricted = array( __('Links'), __('Comments'), __('Media'),
- __('Plugins'), __('Tools'), __('Users'),
- __('Settings'), __('Appearance'), __('Pages'), __('Posts')
- );
- // Move array pointer to the end of the array and loop backwards
- end($menu);
- while( prev($menu) )
- {
- $value = explode(' ',$menu[key($menu)][0]);
- if( in_array($value[0] != NULL?$value[0]:"" , $restricted) )
- unset( $menu[key($menu)] );
- }
- }
- add_action('admin_menu', 'remove_menu_items');
- /**
- * Remove WP Admin Dashboard Widgets
- *
- * This removes the various widgets from the admin dashboard so un-needed dashboard items
- * can be hidden to decrease clutter.
- *
- * @link http://sixrevisions.com/wordpress/how-to-customize-the-wordpress-admin-area/
- * @param void
- * @return void
- */
- function remove_dashboard_widgets()
- {
- global$wp_meta_boxes;
- // All of these will strip most dashboards of ALL widgets. Comment out the ones needed...
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
- unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
- unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
- }
- add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
- /**
- * Custom WP Dashboard Widget Contents
- *
- * This adds the contents for a custom dashboard widget and called by
- * add_your_dashboard_widget().
- *
- * @link http://wp-snippets.com/82/add-a-dashboard-widget/
- * @param void
- * @return void
- */
- function your_dashboard_widget() { ?>
- <h3>Hello WordPress user!</h3>
- <p>Fill this with HTML or PHP.<br>
- Just imagine all the stuff you can put here!</p>
- <p>The possibilities are endless and that's no joke!</p>
- <?php
- }
- /**
- * Add Custom WP Dashboard Widget
- *
- * This will add a custom dashboard widget to WordPress, allowing for customized dashboard
- * contents.
- *
- * @uses your_dashboard_widget() Calls function to add contents for custom widget.
- * @link http://wp-snippets.com/82/add-a-dashboard-widget/
- * @param void
- * @return void
- */
- function add_your_dashboard_widget() {
- wp_add_dashboard_widget( 'your_dashboard_widget', __( 'Widget Title!' ), 'your_dashboard_widget' );
- }
- add_action('wp_dashboard_setup', 'add_your_dashboard_widget' );
- /**
- * Add Custom Help Page
- *
- * Adds custom help contents to the 'Help' tab in WordPress's admin area.
- * This will be added to whichever pages it is hooked to.
- *
- * By using this function to hook the contextual_help hook, we limit the custom
- * help contents from being added to EVERY page.
- * If you want it to show on every page's help dropdown, just add the filter hook in
- * this function directly below the custom_page_help() function.
- *
- * @link http://wp-snippets.com/98/edit-the-help-dropdown/
- * @uses custom_page_help() Calls function to render the custom help contents.
- * @param void
- * @return void
- */
- function add_custom_help_page() {
- //the contextual help filter
- add_filter('contextual_help','custom_page_help');
- }
- /**
- * Custom Help Page Contents
- *
- * This renders the custom help contents. If the parameter $help is not echoed,
- * then the existing help contents will be excluded in the help dropdown.
- *
- * @link http://wp-snippets.com/98/edit-the-help-dropdown/
- * @param string $help The existing help contents
- * @return void
- */
- function custom_page_help($help) {
- // Keep the existing help copy - comment the following line to exclude existing help contents.
- echo $help;
- // Add the new help contents
- echo "<h5>Custom Features</h5>";
- echo "<p>Content placed above the more divider will appear in column 1. Content placed ".
- "below the divider will appear in column 2.</p>";
- }
- // Specify a specific page to hook to like so: 'load-<specific page>.php'
- add_action('load-my-sites.php','add_custom_help_page');
- add_action('load-index.php','add_custom_help_page');
- /**
- * Replace the Admin Footer Text
- *
- * Overrides the admin footer text with your own custom text.
- *
- * @link http://wp-snippets.com/59/change-footer-text-in-wp-admin/
- * @param void
- * @return void
- */
- function remove_footer_admin () {
- echo 'My footer text. Thank you <a href="http://wordpress.org">WordPress</a> for giving me this filter.';
- }
- add_filter('admin_footer_text', 'remove_footer_admin');
- /**
- * Hide Update Notifications in WordPress
- *
- * @link http://wp-snippets.com/79/disable-wordpress-update/
- */
- add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
- /**
- * Change the WP Version in Footer
- *
- * You can hide the version all together, replace it with something else, or spoof the
- * version to show as something else.
- *
- * @link http://wp-snippets.com/701/change-version-in-wp-admin-footer/
- * @param void
- * @return void
- */
- function change_footer_version() {
- return 'Version 120.0.0';
- }
- add_filter( 'update_footer', 'change_footer_version', 9999 );
- /**
- * Hide WP Admin Screen Options tab
- *
- * This will hide the 'Screen Options' tab at the top-right in the WordPress admin area.
- *
- * @param void
- * @return bool false Keeps WordPress from rendering the Screen Options tab
- */
- function hide_screen_options() {
- return false;
- }
- add_filter('screen_options_show_screen', 'hide_screen_options');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement