admin.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /*
  3. This file handles the admin area and functions.
  4. You can use this file to make changes to the
  5. dashboard. Updates to this page are coming soon.
  6. It's turned off by default, but you can call it
  7. via the functions file.
  8. Developed by: Eddie Machado
  9. URL: http://themble.com/bones/
  10. Special Thanks for code & inspiration to:
  11. @jackmcconnell - http://www.voltronik.co.uk/
  12. Digging into WP - http://digwp.com/2010/10/customize-wordpress-dashboard/
  13. - removing some default WordPress dashboard widgets
  14. - an example custom dashboard widget
  15. - adding custom login css
  16. - changing text in footer of admin
  17. */
  18. /************* DASHBOARD WIDGETS *****************/
  19. // disable default dashboard widgets
  20. function disable_default_dashboard_widgets() {
  21. // remove_meta_box( 'dashboard_right_now', 'dashboard', 'core' ); // Right Now Widget
  22. remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'core' ); // Comments Widget
  23. remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'core' ); // Incoming Links Widget
  24. remove_meta_box( 'dashboard_plugins', 'dashboard', 'core' ); // Plugins Widget
  25. // remove_meta_box('dashboard_quick_press', 'dashboard', 'core' ); // Quick Press Widget
  26. remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'core' ); // Recent Drafts Widget
  27. remove_meta_box( 'dashboard_primary', 'dashboard', 'core' ); //
  28. remove_meta_box( 'dashboard_secondary', 'dashboard', 'core' ); //
  29. // removing plugin dashboard boxes
  30. remove_meta_box( 'yoast_db_widget', 'dashboard', 'normal' ); // Yoast's SEO Plugin Widget
  31. /*
  32. have more plugin widgets you'd like to remove?
  33. share them with us so we can get a list of
  34. the most commonly used. :D
  35. https://github.com/eddiemachado/bones/issues
  36. */
  37. }
  38. /*
  39. Now let's talk about adding your own custom Dashboard widget.
  40. Sometimes you want to show clients feeds relative to their
  41. site's content. For example, the NBA.com feed for a sports
  42. site. Here is an example Dashboard Widget that displays recent
  43. entries from an RSS Feed.
  44. For more information on creating Dashboard Widgets, view:
  45. http://digwp.com/2010/10/customize-wordpress-dashboard/
  46. */
  47. // RSS Dashboard Widget
  48. function bones_rss_dashboard_widget() {
  49. if ( function_exists( 'fetch_feed' ) ) {
  50. // include_once( ABSPATH . WPINC . '/feed.php' ); // include the required file
  51. $feed = fetch_feed( 'http://themble.com/feed/rss/' ); // specify the source feed
  52. $limit = $feed->get_item_quantity(7); // specify number of items
  53. $items = $feed->get_items(0, $limit); // create an array of items
  54. }
  55. if ($limit == 0) echo '<div>The RSS Feed is either empty or unavailable.</div>'; // fallback message
  56. else foreach ($items as $item) { ?>
  57. <h4 style="margin-bottom: 0;">
  58. <a href="<?php echo $item->get_permalink(); ?>" title="<?php echo mysql2date( __( 'j F Y @ g:i a', 'bonestheme' ), $item->get_date( 'Y-m-d H:i:s' ) ); ?>" target="_blank">
  59. <?php echo $item->get_title(); ?>
  60. </a>
  61. </h4>
  62. <p style="margin-top: 0.5em;">
  63. <?php echo substr($item->get_description(), 0, 200); ?>
  64. </p>
  65. <?php }
  66. }
  67. // calling all custom dashboard widgets
  68. function bones_custom_dashboard_widgets() {
  69. wp_add_dashboard_widget( 'bones_rss_dashboard_widget', __( 'Recently on Themble (Customize on admin.php)', 'bonestheme' ), 'bones_rss_dashboard_widget' );
  70. /*
  71. Be sure to drop any other created Dashboard Widgets
  72. in this function and they will all load.
  73. */
  74. }
  75. // removing the dashboard widgets
  76. add_action( 'admin_menu', 'disable_default_dashboard_widgets' );
  77. // adding any custom widgets
  78. add_action( 'wp_dashboard_setup', 'bones_custom_dashboard_widgets' );
  79. /************* CUSTOM LOGIN PAGE *****************/
  80. // calling your own login css so you can style it
  81. //Updated to proper 'enqueue' method
  82. //http://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts
  83. function bones_login_css() {
  84. wp_enqueue_style( 'bones_login_css', get_template_directory_uri() . '/library/css/login.css', false );
  85. }
  86. // changing the logo link from wordpress.org to your site
  87. function bones_login_url() { return home_url(); }
  88. // changing the alt text on the logo to show your site name
  89. function bones_login_title() { return get_option( 'blogname' ); }
  90. // calling it only on the login page
  91. add_action( 'login_enqueue_scripts', 'bones_login_css', 10 );
  92. add_filter( 'login_headerurl', 'bones_login_url' );
  93. add_filter( 'login_headertitle', 'bones_login_title' );
  94. /************* CUSTOMIZE ADMIN *******************/
  95. /*
  96. I don't really recommend editing the admin too much
  97. as things may get funky if WordPress updates. Here
  98. are a few funtions which you can choose to use if
  99. you like.
  100. */
  101. // Custom Backend Footer
  102. function bones_custom_admin_footer() {
  103. _e( '<span id="footer-thankyou">Developed by <a href="http://yoursite.com" target="_blank">Your Site Name</a></span>. Built using <a href="http://themble.com/bones" target="_blank">Bones</a>.', 'bonestheme' );
  104. }
  105. // adding it to the admin area
  106. add_filter( 'admin_footer_text', 'bones_custom_admin_footer' );
  107. ?>