functions.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /***********************************************************
  3. ###################### Child Theme #########################
  4. ************************************************************/
  5. add_action( 'wp_enqueue_scripts', 'twenty_five_enqueue_styles' );
  6. function twenty_five_enqueue_styles() {
  7. wp_enqueue_style(
  8. '2025-style',
  9. get_parent_theme_file_uri( 'style.css' )
  10. );
  11. }
  12. /***********************************************************
  13. ###################### Admin Clean #########################
  14. ************************************************************/
  15. add_filter('gettext', 'srh25_change_howdy', 10, 3);
  16. function srh25_change_howdy($translated, $text, $domain) {
  17. if (false !== strpos($translated, 'Howdy,'))
  18. return str_replace('Howdy,', '', $translated);
  19. return $translated;
  20. }
  21. add_filter( 'gettext', 'srh25_change_howdy_text_email', 10, 2 );
  22. function srh25_change_howdy_text_email( $translation, $original ) {
  23. if( 'Howdy, %1$s' == $original )
  24. $translation = '%1$s';
  25. return $translation;
  26. }
  27. add_filter( 'show_admin_bar', '__return_false' );
  28. add_action( 'admin_bar_menu', 'srh25_admin_bar', 999 );
  29. function srh25_admin_bar( $wp_admin_bar ) {
  30. //$wp_admin_bar->remove_menu('my-account');
  31. //$wp_admin_bar->remove_menu( 'edit' );
  32. //$wp_admin_bar->remove_menu('site-name');
  33. $wp_admin_bar->remove_node('wp-logo');
  34. $wp_admin_bar->remove_node('themes');
  35. $wp_admin_bar->remove_node('widgets');
  36. $wp_admin_bar->remove_node('menus');
  37. $wp_admin_bar->remove_node('new-media');
  38. $wp_admin_bar->remove_menu('edit-profile');
  39. $wp_admin_bar->remove_menu('comments');
  40. $wp_admin_bar->remove_menu('about');
  41. $wp_admin_bar->remove_menu('wporg');
  42. $wp_admin_bar->remove_menu('documentation');
  43. $wp_admin_bar->remove_menu('support-forums');
  44. $wp_admin_bar->remove_menu('feedback');
  45. $wp_admin_bar->remove_menu('customize');
  46. $wp_admin_bar->remove_menu('view-site');
  47. $wp_admin_bar->remove_menu('updates');
  48. $wp_admin_bar->remove_menu('comments');
  49. $wp_admin_bar->remove_menu('new-content');
  50. $wp_admin_bar->remove_menu('view');
  51. }
  52. add_action( 'admin_init', 'srh25_remove_dashboard_meta' );
  53. function srh25_remove_dashboard_meta() {
  54. remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
  55. remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
  56. remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
  57. remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
  58. remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
  59. remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
  60. }
  61. add_action( 'admin_head-profile.php', 'srh25_remove_admin_color' );
  62. function srh25_remove_admin_color() {
  63. remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
  64. }
  65. add_filter('admin_footer_text', 'srh25_remove_admin_footer_text', 1000);
  66. function srh25_remove_admin_footer_text(){return '';}
  67. add_filter('update_footer', 'srh25_remove_admin_footer_upgrade', 1000);
  68. function srh25_remove_admin_footer_upgrade(){return '';}
  69. /***********************************************************
  70. ###################### Log In/Out ##########################
  71. ************************************************************/
  72. add_filter( 'login_headerurl', 'srh25_login_logo_url' );
  73. function srh25_login_logo_url() {
  74. return home_url();
  75. }
  76. add_filter( 'login_headertext', 'srh25_login_url_title' );
  77. function srh25_login_url_title() {
  78. return 'SRH Physicians';
  79. }
  80. add_action( 'login_enqueue_scripts', 'srh25_login_logo' );
  81. function srh25_login_logo() { ?>
  82. <style type="text/css">
  83. .login h1 a {
  84. background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/img/disc.png) !important;
  85. padding-bottom: 30px;
  86. }
  87. .wp-core-ui .button-primary {
  88. background: #4FB54F;
  89. border-color: #027643;
  90. }
  91. .login .message {
  92. border-left: 4px solid #027643;
  93. }
  94. .login form .forgetmenot label {
  95. display:none;
  96. }
  97. .login #backtoblog a {
  98. display:none;
  99. }
  100. </style>
  101. <?php }
  102. /***********************************************************
  103. ####################### Allow SVG ##########################
  104. ************************************************************/
  105. add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
  106. global $wp_version;
  107. if ( $wp_version !== '4.7.1' ) {
  108. return $data;
  109. }
  110. $filetype = wp_check_filetype( $filename, $mimes );
  111. return [
  112. 'ext' => $filetype['ext'],
  113. 'type' => $filetype['type'],
  114. 'proper_filename' => $data['proper_filename']
  115. ];
  116. }, 10, 4 );
  117. add_action( 'admin_head', 'fix_svg' );
  118. function cc_mime_types( $mimes ){
  119. $mimes['svg'] = 'image/svg+xml';
  120. return $mimes;
  121. }
  122. add_filter( 'upload_mimes', 'cc_mime_types' );
  123. function fix_svg() {
  124. echo '<style type="text/css">
  125. .attachment-266x266, .thumbnail img {
  126. width: 100% !important;
  127. height: auto !important;
  128. }
  129. </style>';
  130. }
  131. /***********************************************************
  132. #################### Edit Page Link ########################
  133. ************************************************************/
  134. function add_edit_link() {
  135. ob_start();
  136. edit_post_link( __( 'Edit Page', 'textdomain' ), '<div class="wp-block-button">', '</div>', null, 'wp-block-button__link has-accent-2-background-color has-background wp-element-button' );
  137. return ob_get_clean();
  138. }
  139. add_action( 'init', 'add_edit_link_shortcode' );
  140. function add_edit_link_shortcode() {
  141. add_shortcode( 'edit-link', 'add_edit_link' );
  142. }