Javascript: BMI

/** * ✅ Prefill Form Fields with Default Data (For Testing Only) */ function prefillFormFields() { console.log(“▶️ prefillFormFields() called…”); const ageField = document.getElementById(‘field_age’); const weightField = document.getElementById(‘field_weight’); const weightUnitField = document.getElementById(‘field_weight_unit’); const heightField = document.getElementById(‘field_height’); const heightUnitField = document.getElementById(‘field_height_unit’); const…Continue reading

Remove Unused Javascript

//This has been syncronised 123// function wp_remove_scripts() { // check if user is admina if (current_user_can( ‘update_core’ )) { return; } else { // Check for the page you want to target if ( is_page( ‘homepage’ ) ) { //…Continue reading

Bootstrap 5

// Add custom scripts function add_custom_script_bootstrap5() { wp_register_script( ‘bootstrap5_js’, ‘https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js’, array(), ‘5.3.3’, true ); wp_enqueue_script( ‘bootstrap5_js’ ); wp_register_style( ‘bootstrap5_css’, ‘https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css’, array(), ‘5.3.3’, true ); wp_enqueue_style( ‘bootstrap5_css’ ); wp_register_style( ‘bootstrap5_css_containers’, ‘https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/scss/_containers.scss’, array(), ‘5.3.3’, true ); wp_enqueue_style( ‘bootstrap5_css_containers’ ); } add_action( ‘wp_enqueue_scripts’,…Continue reading

webfontloader.js

// Add custom scripts function add_custom_script_webfont_loader_js() { wp_register_script( ‘webfontloader’, ‘https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js’, array(), ‘1.6.28’, true ); wp_enqueue_script( ‘webfontloader’ ); } add_action( ‘wp_enqueue_scripts’, ‘add_custom_script_webfont_loader_js’ );Continue reading

fontfaceObserver.js

// Detect if web fonts are available function add_custom_script_font_face_observer_js() { wp_register_script( ‘fontface_observer’, ‘https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.3.0/fontfaceobserver.standalone.js’, array(), ‘2.3.0’, true ); wp_enqueue_script( ‘fontface_observer’ ); } add_action( ‘wp_enqueue_scripts’, ‘add_custom_script_font_face_observer_js’ );Continue reading

masonry.js

// Add custom scripts function add_custom_script_masonry_js() { wp_register_script( ‘masonry’, ‘https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js’, array(), ‘4’, true ); wp_enqueue_script( ‘masonry’ ); } add_action( ‘wp_enqueue_scripts’, ‘add_custom_script_masonry_js’ );Continue reading

Smooth Scrolling for Anchor Links

document.addEventListener(‘click’, function(e) { // Check if the clicked element is an anchor with href starting with ‘#’ if (e.target.tagName === ‘A’ && e.target.getAttribute(‘href’) && e.target.getAttribute(‘href’).startsWith(‘#’)) { e.preventDefault(); const targetId = e.target.getAttribute(‘href’).slice(1); // Remove the ‘#’ from the href const targetElement…Continue reading

Automatic CSS/JavaScript Cache Busting

/** * Replace the `ver` query arg with the file’s last modified timestamp * * @param string $src URL to a file * @return string Modified URL to a file */ function filter_cache_busting_file_src( $src = ” ) { global $wp_scripts;…Continue reading