admin.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. global $wp_meta_boxes;
  22. // unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); // Right Now Widget
  23. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']); // Activity Widget
  24. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); // Comments Widget
  25. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); // Incoming Links Widget
  26. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); // Plugins Widget
  27. // unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); // Quick Press Widget
  28. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); // Recent Drafts Widget
  29. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); //
  30. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); //
  31. // remove plugin dashboard boxes
  32. unset($wp_meta_boxes['dashboard']['normal']['core']['yoast_db_widget']); // Yoast's SEO Plugin Widget
  33. unset($wp_meta_boxes['dashboard']['normal']['core']['rg_forms_dashboard']); // Gravity Forms Plugin Widget
  34. unset($wp_meta_boxes['dashboard']['normal']['core']['bbp-dashboard-right-now']); // bbPress Plugin Widget
  35. /*
  36. have more plugin widgets you'd like to remove?
  37. share them with us so we can get a list of
  38. the most commonly used. :D
  39. https://github.com/eddiemachado/bones/issues
  40. */
  41. }
  42. /*
  43. Now let's talk about adding your own custom Dashboard widget.
  44. Sometimes you want to show clients feeds relative to their
  45. site's content. For example, the NBA.com feed for a sports
  46. site. Here is an example Dashboard Widget that displays recent
  47. entries from an RSS Feed.
  48. For more information on creating Dashboard Widgets, view:
  49. http://digwp.com/2010/10/customize-wordpress-dashboard/
  50. */
  51. // RSS Dashboard Widget
  52. function bones_rss_dashboard_widget() {
  53. if ( function_exists( 'fetch_feed' ) ) {
  54. // include_once( ABSPATH . WPINC . '/feed.php' ); // include the required file
  55. $feed = fetch_feed( 'http://feeds.feedburner.com/wpcandy' ); // specify the source feed
  56. if (is_wp_error($feed)) {
  57. $limit = 0;
  58. $items = 0;
  59. } else {
  60. $limit = $feed->get_item_quantity(7); // specify number of items
  61. $items = $feed->get_items(0, $limit); // create an array of items
  62. }
  63. }
  64. if ($limit == 0) echo '<div>The RSS Feed is either empty or unavailable.</div>'; // fallback message
  65. else foreach ($items as $item) { ?>
  66. <h4 style="margin-bottom: 0;">
  67. <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">
  68. <?php echo $item->get_title(); ?>
  69. </a>
  70. </h4>
  71. <p style="margin-top: 0.5em;">
  72. <?php echo substr($item->get_description(), 0, 200); ?>
  73. </p>
  74. <?php }
  75. }
  76. // calling all custom dashboard widgets
  77. function bones_custom_dashboard_widgets() {
  78. wp_add_dashboard_widget( 'bones_rss_dashboard_widget', __( 'Recently on Themble (Customize on admin.php)', 'bonestheme' ), 'bones_rss_dashboard_widget' );
  79. /*
  80. Be sure to drop any other created Dashboard Widgets
  81. in this function and they will all load.
  82. */
  83. }
  84. // removing the dashboard widgets
  85. add_action( 'wp_dashboard_setup', 'disable_default_dashboard_widgets' );
  86. // adding any custom widgets
  87. add_action( 'wp_dashboard_setup', 'bones_custom_dashboard_widgets' );
  88. /************* CUSTOM LOGIN PAGE *****************/
  89. // calling your own login css so you can style it
  90. //Updated to proper 'enqueue' method
  91. //http://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts
  92. function bones_login_css() {
  93. wp_enqueue_style( 'bones_login_css', get_template_directory_uri() . '/library/css/login.css', false );
  94. }
  95. // changing the logo link from wordpress.org to your site
  96. function bones_login_url() { return home_url(); }
  97. // changing the alt text on the logo to show your site name
  98. function bones_login_title() { return get_option( 'blogname' ); }
  99. // calling it only on the login page
  100. add_action( 'login_enqueue_scripts', 'bones_login_css', 10 );
  101. add_filter( 'login_headerurl', 'bones_login_url' );
  102. add_filter( 'login_headertitle', 'bones_login_title' );
  103. /************* CUSTOMIZE ADMIN *******************/
  104. /*
  105. I don't really recommend editing the admin too much
  106. as things may get funky if WordPress updates. Here
  107. are a few funtions which you can choose to use if
  108. you like.
  109. */
  110. // Custom Backend Footer
  111. function bones_custom_admin_footer() {
  112. _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' );
  113. }
  114. // adding it to the admin area
  115. add_filter( 'admin_footer_text', 'bones_custom_admin_footer' );
  116. ?>