tweaks.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. function remove_recent_comments_style() {
  3. global $wp_widget_factory;
  4. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  5. }
  6. add_action( 'widgets_init', 'remove_recent_comments_style' );
  7. function _bml_page_menu_args( $args ) {
  8. $args['show_home'] = true;
  9. return $args;
  10. }
  11. add_filter( 'wp_page_menu_args', '_bml_page_menu_args' );
  12. function _bml_body_classes( $classes ) {
  13. // Adds a class of group-blog to blogs with more than 1 published author
  14. if ( is_multi_author() ) {
  15. $classes[] = 'group-blog';
  16. }
  17. return $classes;
  18. }
  19. add_filter( 'body_class', '_bml_body_classes' );
  20. function _bml_enhanced_image_navigation( $url, $id ) {
  21. if ( ! is_attachment() && ! wp_attachment_is_image( $id ) )
  22. return $url;
  23. $image = get_post( $id );
  24. if ( ! empty( $image->post_parent ) && $image->post_parent != $id )
  25. $url .= '#main';
  26. return $url;
  27. }
  28. add_filter( 'attachment_link', '_bml_enhanced_image_navigation', 10, 2 );
  29. add_action('init', 'bml_head_cleanup');
  30. function bml_head_cleanup() {
  31. remove_action('wp_head', 'feed_links');
  32. remove_action('wp_head', 'feed_links', 2 );
  33. remove_action('wp_head', 'feed_links_extra');
  34. remove_action('wp_head', 'feed_links_extra', 3 );
  35. remove_action('wp_head', 'rsd_link');
  36. remove_action('wp_head', 'wlwmanifest_link');
  37. remove_action('wp_head', 'index_rel_link');
  38. remove_action('wp_head', 'parent_post_rel_link');
  39. remove_action('wp_head', 'start_post_rel_link');
  40. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
  41. remove_action('wp_head', 'wp_generator');
  42. remove_action('wp_head', 'wp_shortlink_wp_head');
  43. remove_action('wp_head', 'rel_canonical');
  44. }
  45. add_action('admin_menu', 'remove_menus');
  46. function remove_menus () {
  47. global $menu;
  48. // $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
  49. $restricted = array();
  50. end ($menu);
  51. while (prev($menu)){
  52. $value = explode(' ',$menu[key($menu)][0]);
  53. if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
  54. }
  55. }
  56. add_action('login_head', 'bml_login_logo');
  57. function bml_login_logo() {
  58. echo '<style type="text/css">
  59. h1 a { background-image:url('.get_bloginfo('template_directory').'/img/login.png) !important; }
  60. </style>';
  61. }
  62. add_action( 'admin_head', 'bml_hide' );
  63. function bml_hide() {
  64. ?>
  65. <style type="text/css" media="screen">
  66. #footer {display:none;}
  67. /* #screen-meta-links {display: none;} */
  68. #wpadminbar {display: none;}
  69. body.admin-bar #wpcontent, body.admin-bar #adminmenu {padding-top:0;}
  70. html.wp-toolbar{padding-top:0;}
  71. #postexcerpt p {display: none;}
  72. </style>
  73. <?php }
  74. add_filter( 'script_loader_src', 'remove_src_version' );
  75. add_filter( 'style_loader_src', 'remove_src_version' );
  76. function remove_src_version ( $src ) {
  77. global $wp_version;
  78. $version_str = '?ver='.$wp_version;
  79. $version_str_offset = strlen( $src ) - strlen( $version_str );
  80. if( substr( $src, $version_str_offset ) == $version_str )
  81. return substr( $src, 0, $version_str_offset );
  82. else
  83. return $src;
  84. }
  85. add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
  86. function remove_dashboard_widgets(){
  87. global$wp_meta_boxes;
  88. unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
  89. //unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
  90. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
  91. //unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
  92. //unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
  93. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
  94. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
  95. unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
  96. }
  97. function bml_rss_output(){
  98. echo '<div class="rss-widget">';
  99. wp_widget_rss_output(array(
  100. 'url' => 'https://cantbuymelove.org/feed/',
  101. 'title' => 'Cant Buy Me Love',
  102. 'items' => 1,
  103. 'show_summary' => 1,
  104. 'show_author' => 0,
  105. 'show_date' => 1
  106. ));
  107. echo "</div>";
  108. }
  109. add_action('wp_dashboard_setup', 'bml_rss_widget');
  110. function bml_rss_widget(){
  111. wp_add_dashboard_widget( 'bml-rss', 'Cantbuymelove', 'bml_rss_output');
  112. }