', '>', $tag); // Remove double spaces return str_replace(' ', '', $tag); }, 10, 2); } endif; // Remove WP version from RSS. if ( ! function_exists( 'foundationpress_remove_rss_version' ) ) : function foundationpress_remove_rss_version() { return ''; } endif; // Remove injected CSS for recent comments widget. if ( ! function_exists( 'foundationpress_remove_wp_widget_recent_comments_style' ) ) : function foundationpress_remove_wp_widget_recent_comments_style() { if ( has_filter( 'wp_head', 'wp_widget_recent_comments_style' ) ) { remove_filter( 'wp_head', 'wp_widget_recent_comments_style' ); } } endif; // Remove injected CSS from recent comments widget. if ( ! function_exists( 'foundationpress_remove_recent_comments_style' ) ) : function foundationpress_remove_recent_comments_style() { global $wp_widget_factory; if ( isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ) { remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) ); } } endif; // https://crunchify.com/how-to-clean-up-wordpress-header-section-without-any-plugin/ // Remove query strings from all static resources if ( ! function_exists( 'crunchify_cleanup_query_string' ) ): function crunchify_cleanup_query_string( $src ){ $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', 'crunchify_cleanup_query_string', 15, 1 ); add_filter( 'style_loader_src', 'crunchify_cleanup_query_string', 15, 1 ); endif; // Remove injected CSS and JS from Contact Forms 7. // https://stackoverflow.com/questions/48923540/remove-contact-form-7-css-and-js-unless-contact-form-7-shortcode-is-used-in-the/48926880#48926880 if ( ! function_exists( 'function biofriction_contactform_css_js' ) ) : function biofriction_contactform_css_js() { // global $post; // if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'contact-form-7') ) { // wp_enqueue_script('contact-form-7'); // wp_enqueue_style('contact-form-7'); // // }else{ // wp_dequeue_script( 'contact-form-7' ); // wp_dequeue_style( 'contact-form-7' ); // } // // // https://dannyvankooten.com/only-load-contact-form-7-scripts-when-needed/ // $load_scripts = false; if( is_singular() ) { $post = get_post(); if( has_shortcode($post->post_content, 'contact-form-7') ) { $load_scripts = true; } } if( ! $load_scripts ) { wp_dequeue_script( 'contact-form-7' ); wp_dequeue_style( 'contact-form-7' ); } } add_action( 'wp_enqueue_scripts', 'biofriction_contactform_css_js'); endif;