123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <?php
- /***********************************************************
- ###################### Child Theme #########################
- ************************************************************/
- //add_action( 'wp_enqueue_scripts', 'twenty_five_enqueue_styles' );
- function twenty_five_enqueue_styles() {
- wp_enqueue_style( '2025-style', get_parent_theme_file_uri( 'style.css' ));
- }
- add_action( 'wp_enqueue_scripts', 'srh25_enqueue_styles' );
- function srh25_enqueue_styles() {
- wp_enqueue_style( 'srh-style', get_stylesheet_uri() );
- }
- /***********************************************************
- ###################### Admin Clean #########################
- ************************************************************/
- add_filter('gettext', 'srh25_change_howdy', 10, 3);
- function srh25_change_howdy($translated, $text, $domain) {
- if (false !== strpos($translated, 'Howdy,'))
- return str_replace('Howdy,', '', $translated);
- return $translated;
- }
- add_filter( 'gettext', 'srh25_change_howdy_text_email', 10, 2 );
- function srh25_change_howdy_text_email( $translation, $original ) {
- if( 'Howdy, %1$s' == $original )
- $translation = '%1$s';
- return $translation;
- }
- add_filter( 'show_admin_bar', '__return_false' );
- add_action( 'admin_bar_menu', 'srh25_admin_bar', 999 );
- function srh25_admin_bar( $wp_admin_bar ) {
- //$wp_admin_bar->remove_menu('my-account');
- //$wp_admin_bar->remove_menu( 'edit' );
- //$wp_admin_bar->remove_menu('site-name');
- $wp_admin_bar->remove_node('wp-logo');
- $wp_admin_bar->remove_node('themes');
- $wp_admin_bar->remove_node('widgets');
- $wp_admin_bar->remove_node('menus');
- $wp_admin_bar->remove_node('new-media');
- $wp_admin_bar->remove_menu('edit-profile');
- $wp_admin_bar->remove_menu('comments');
- $wp_admin_bar->remove_menu('about');
- $wp_admin_bar->remove_menu('wporg');
- $wp_admin_bar->remove_menu('documentation');
- $wp_admin_bar->remove_menu('support-forums');
- $wp_admin_bar->remove_menu('feedback');
- $wp_admin_bar->remove_menu('customize');
- $wp_admin_bar->remove_menu('view-site');
- $wp_admin_bar->remove_menu('updates');
- $wp_admin_bar->remove_menu('comments');
- $wp_admin_bar->remove_menu('new-content');
- $wp_admin_bar->remove_menu('view');
- }
- add_action( 'admin_init', 'srh25_remove_dashboard_meta' );
- function srh25_remove_dashboard_meta() {
- remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
- remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
- }
- add_action( 'admin_head-profile.php', 'srh25_remove_admin_color' );
- function srh25_remove_admin_color() {
- remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
- }
- add_filter('admin_footer_text', 'srh25_remove_admin_footer_text', 1000);
- function srh25_remove_admin_footer_text(){return '';}
- add_filter('update_footer', 'srh25_remove_admin_footer_upgrade', 1000);
- function srh25_remove_admin_footer_upgrade(){return '';}
- /***********************************************************
- ###################### Log In/Out ##########################
- ************************************************************/
- add_filter( 'login_headerurl', 'srh25_login_logo_url' );
- function srh25_login_logo_url() {
- return home_url();
- }
- add_filter( 'login_headertext', 'srh25_login_url_title' );
- function srh25_login_url_title() {
- return 'SRH Physicians';
- }
- add_action( 'login_enqueue_scripts', 'srh25_login_logo' );
- function srh25_login_logo() { ?>
- <style type="text/css">
- .login h1 a {
- background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/img/disc.png) !important;
- padding-bottom: 30px;
- }
- .wp-core-ui .button-primary {
- background: #4FB54F;
- border-color: #027643;
- }
- .login .message {
- border-left: 4px solid #027643;
- }
- .login form .forgetmenot label {
- display:none;
- }
- .login #backtoblog a {
- display:none;
- }
- </style>
- <?php }
- /***********************************************************
- ####################### Allow SVG ##########################
- ************************************************************/
- add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
- global $wp_version;
- if ( $wp_version !== '4.7.1' ) {
- return $data;
- }
- $filetype = wp_check_filetype( $filename, $mimes );
- return [
- 'ext' => $filetype['ext'],
- 'type' => $filetype['type'],
- 'proper_filename' => $data['proper_filename']
- ];
- }, 10, 4 );
- add_action( 'admin_head', 'fix_svg' );
- function cc_mime_types( $mimes ){
- $mimes['svg'] = 'image/svg+xml';
- return $mimes;
- }
- add_filter( 'upload_mimes', 'cc_mime_types' );
- function fix_svg() {
- echo '<style type="text/css">
- .attachment-266x266, .thumbnail img {
- width: 100% !important;
- height: auto !important;
- }
- </style>';
- }
-
- /***********************************************************
- #################### Edit Page Link ########################
- ************************************************************/
- function add_edit_link() {
- ob_start();
- 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' );
- return ob_get_clean();
- }
- add_action( 'init', 'add_edit_link_shortcode' );
- function add_edit_link_shortcode() {
- add_shortcode( 'edit-link', 'add_edit_link' );
- }
- /***********************************************************
- ################ Auto-Hide Navigation ######################
- ************************************************************/
- // Enqueue the auto-hide navigation JavaScript
- add_action( 'wp_enqueue_scripts', 'srh25_enqueue_navigation_script' );
- function srh25_enqueue_navigation_script() {
- // Option 1: Use separate JavaScript file (commented out for debugging)
- /*
- wp_enqueue_script(
- 'srh25-auto-hide-nav',
- get_stylesheet_directory_uri() . '/js/auto-hide-nav.js',
- array(),
- '1.0.1',
- true
- );
- */
-
- // Option 2: Inline script (active for better compatibility)
- wp_enqueue_script( 'jquery' );
-
- $navigation_script = "
- jQuery(document).ready(function($) {
- console.log('Auto-hide navigation: jQuery script loaded');
-
- let lastScrollTop = 0;
- let scrollThreshold = 100;
-
- // Find header with multiple selectors
- let header = $('header').first();
- if (header.length === 0) {
- header = $('.wp-site-header, .wp-block-template-part[data-area=\"header\"], [class*=\"header\"]').first();
- }
-
- let body = $('body');
- let headerHeight = 0;
-
- console.log('Header element found:', header.length > 0 ? header[0] : 'None');
-
- if (header.length === 0) {
- console.warn('No header element found for auto-hide navigation');
- return;
- }
-
- // Add identifying class
- header.addClass('srh-auto-hide-header');
-
- function calculateHeaderHeight() {
- headerHeight = header.outerHeight() || 80;
- document.documentElement.style.setProperty('--header-height', headerHeight + 'px');
- console.log('Header height calculated:', headerHeight);
- }
-
- calculateHeaderHeight();
- $(window).on('resize', calculateHeaderHeight);
-
- $(window).on('scroll', function() {
- let scrollTop = $(this).scrollTop();
-
- if (scrollTop > 50) {
- body.addClass('header-offset');
- header.addClass('header-scrolled');
- } else {
- body.removeClass('header-offset');
- header.removeClass('header-scrolled');
- }
-
- if (scrollTop > scrollThreshold) {
- if (scrollTop > lastScrollTop) {
- // Scrolling down - hide header
- header.removeClass('header-visible').addClass('header-hidden');
- } else {
- // Scrolling up - show header
- header.removeClass('header-hidden').addClass('header-visible');
- }
- } else {
- // Near top - always show header
- header.removeClass('header-hidden header-visible');
- }
-
- lastScrollTop = scrollTop;
- });
-
- $(document).on('mousemove', function(e) {
- if (e.clientY < 100 && $(window).scrollTop() > scrollThreshold) {
- header.removeClass('header-hidden').addClass('header-visible');
- }
- });
-
- $('a[href^=\"#\"]').on('click', function(e) {
- let target = $(this.getAttribute('href'));
- if (target.length) {
- e.preventDefault();
- $('html, body').animate({
- scrollTop: target.offset().top - headerHeight
- }, 600);
- }
- });
-
- $(document).on('keydown', function(e) {
- if (e.key === 'Tab' || e.key === 'Escape') {
- header.removeClass('header-hidden').addClass('header-visible');
- }
- });
-
- header.find('a, button, input, textarea, select').on('focus', function() {
- header.removeClass('header-hidden').addClass('header-visible');
- });
-
- console.log('Auto-hide navigation: Initialization complete');
- });
- ";
-
- wp_add_inline_script( 'jquery', $navigation_script );
- }
- // Add CSS custom properties support for older browsers
- add_action( 'wp_head', 'srh25_navigation_css_vars' );
- function srh25_navigation_css_vars() {
- ?>
- <script>
- // CSS custom properties fallback
- if (!window.CSS || !CSS.supports('color', 'var(--fake-var)')) {
- document.documentElement.style.setProperty = document.documentElement.style.setProperty || function(property, value, priority) {
- this[property] = value;
- };
- }
- </script>
- <?php
- }
|