Skip to content

Commit

Permalink
Merge pull request #87 from UCF/hf-header-fix
Browse files Browse the repository at this point in the history
UCF Header Fix
  • Loading branch information
jmbarne3 authored Mar 5, 2024
2 parents f93ba25 + 0870270 commit 70e1b84
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion includes/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ function add_meta_tags() {
add_filter( 'emoji_svg_url', '__return_false' );


/**
* Replaces the ucf-header bar ID with the correct
* ID needed for the script to work correctly.
*
* @author Jim Barnes
* @since v1.5.0
*
* @param string $tag The script tag being filtered
* @param string $handle The handle of the header script
* @param string $src The source of the script
*/
function ucfhb_script_handle( $tag, $handle, $src ) {
if ( false !== strpos( $src, 'universityheader.ucf.edu' ) ) {
$tag = str_replace( "{$handle}-js", 'ucfhb-script', $tag );
}

return $tag;
}

if ( version_compare( $wp_version, '6.3.0', '>=' ) ) {
add_filter( 'script_loader_tag', 'ucfhb_script_handle', 10, 3 );
}

/**
* Adds ID attribute to UCF Header script.
**/
Expand All @@ -84,7 +107,9 @@ function add_id_to_ucfhb( $url ) {
return $url;
}

add_filter( 'clean_url', 'add_id_to_ucfhb', 10, 1 );
if ( version_compare( $wp_version, '6.3.0', '<' ) ) {
add_filter( 'clean_url', 'add_id_to_ucfhb', 10, 1 );
}


/**
Expand Down

0 comments on commit 70e1b84

Please sign in to comment.