admin.php 4.7 KB

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