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

fullPage.js

// Add custom scripts function add_custom_script_fullpage_js() { wp_register_script( ‘fullpage’, ‘https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/4.0.29/fullpage.min.js’, array(), ‘4.0.29’, false ); wp_enqueue_script( ‘fullpage’ ); } add_action( ‘wp_enqueue_scripts’, ‘add_custom_script_fullpage_js’ );Continue reading

Untitled Snippet

function cwpai_parse_and_add_attributes( $atts ) { $atts = shortcode_atts( array( ‘entry_id’ => 0, ), $atts, ‘cwpai_parse_words’ ); if (empty($atts[‘entry_id’])) { return ”; } $entry = FrmEntry::getOne($atts[‘entry_id’]); if (!$entry) { return ”; } $user_input = $entry->metas[‘user_input’]; $user_input = strip_tags($user_input); $words = array_map(‘trim’,…Continue reading

Search and replace text strings

function replace_multiple_texts_on_the_fly($content) { // Array of text pairs to find and replace $text_pairs = array( ‘wp_code_guarantee_days’ => ’60’, ‘wp_code_dagen_garantie’ => ’60’, // Add more pairs as needed ); foreach ($text_pairs as $old_text => $new_text) { // Use str_replace for simple…Continue reading

Display the Last Updated Date

$u_time = get_the_time( ‘U’ ); $u_modified_time = get_the_modified_time( ‘U’ ); // Only display modified date if 24hrs have passed since the post was published. if ( $u_modified_time >= $u_time + 86400 ) { $updated_date = get_the_modified_time( ‘F jS, Y’ );…Continue reading