Files
Testing/blog/wp-content/themes/Avada-child/functions.php
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

75 lines
2.7 KiB
PHP

<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
function chld_thm_cfg_locale_css( $uri ){
if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( 'avada-stylesheet' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );
if ( !function_exists( 'child_theme_configurator_css' ) ):
function child_theme_configurator_css() {
wp_enqueue_style( 'chld_thm_cfg_child', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css', array( 'chld_thm_cfg_parent' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css', 10 );
// END ENQUEUE PARENT ACTION
//custom header sticky
add_action('wp_footer', 'header_sticky_function');
function header_sticky_function(){
?>
<!--Sticky header-->
<script>
window.onscroll = function() {myFunction()};
// Get the header sticky
var header_sticky = document.getElementById( "nav-bar-sticky" );
var adminbar = document.getElementById("wpadminbar");
// Get the offset bottom position of the header
var header_bottom = document.querySelector('header').offsetHeight;
// Add the sticky class to the header sticky element when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if ( window.pageYOffset > header_bottom ) {
header_sticky.classList.add( "hfe-sticky" );
if(adminbar)
header_sticky.style.top=""+adminbar.offsetHeight+"px";
} else {
setTimeout(function(){
header_sticky.classList.remove( "hfe-sticky" );
header_sticky.style.top="0px";
}, 100);
}
}
</script>
<?php
}
add_filter( 'avada_load_more_posts_name', 'change_text_lmp',10,1);
function change_text_lmp($load_more_text) {
if (!is_search())
return 'Find More';
else
return $load_more_text;
}
function defer_parsing_of_js( $url ) {
if ( is_user_logged_in() ) return $url; //don't break WP Admin
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return str_replace( ' src', ' defer src', $url );
}
add_filter( 'script_loader_tag', 'defer_parsing_of_js', 10 );