Archives: Snippets
WPEX Tetris REST Meta Integration
if(!function_exists(‘wpex_register_universal_media_meta’)){ function wpex_register_universal_media_meta(){ $media_meta_fields=array( ‘universal_local_image_attachment_ids’, ‘universal_local_audio_attachment_ids’, ‘universal_local_video_attachment_ids’, ); $post_types=get_post_types(array(‘public’=>true)); foreach($post_types as $post_type){ if(post_type_supports($post_type,’post-formats’)){ foreach($media_meta_fields as $meta_key){ if(!registered_meta_key_exists(‘post’,$meta_key,$post_type)){ register_post_meta($post_type,$meta_key,array( ‘type’=>’array’, ‘single’=>true, ‘default’=>array(), ‘show_in_rest’=>array( ‘schema’=>array( ‘type’=>’array’, ‘items’=>array(‘type’=>’integer’), ), ), ‘sanitize_callback’=>function($value){ return is_array($value)?array_map(‘absint’,$value):array(); }, ‘auth_callback’=>function($allowed,$meta_key,$post_id,$user_id,$cap,$caps){ return current_user_can(‘edit_post’,$post_id); }, )); } } } }…Continue reading
Dynamic Category Mautic Forms.
GTM
Show a Notice When an Event Has Ended
/** * Show a notice on the single event page once the event is over. * * Recurring events use the end of the SERIES, not the end of the first * occurrence. The end column describes only the first…Continue reading
Automatically Trash Past Events
/** * Move past events to the trash on a daily schedule. * * Sites that have run for years accumulate thousands of finished events. They * stay in every admin view and every query, and past a few hundred…Continue reading
Add Your Own Custom Fields to Events
/** * Add your own fields to the event editor and show them on the event page. * * Sugar Calendar has no custom-fields UI. This adds one: edit the array in * sc_snippets_custom_event_fields() and each entry becomes a field…Continue reading
Add a Get Directions Link to Venue Pages
/** * Add custom content before or after the venue details wrapper. * * `sc_venue_details_before` fires outside and above the * .sc-venue-details container. * * `sc_venue_details_after` fires below the container and is * where related events are rendered by default…Continue reading
Custom Field Order on Venue Pages
/** * Replace the default venue details renderer with a custom layout. * * The default sc_venue_details() function has a hardcoded field order * (address, city, state, country, postal code, phone, website, map, content). * Unlike speakers, there is no…Continue reading
Show the Venue Photo Above the Venue Details
/** * Display the venue featured image above the venue details. * * The venue rendering has no built-in featured image output. * This hooks into `sc_venue_details` at priority 5 (the default * sc_venue_details() function runs at priority 10) to…Continue reading