Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'wp_enqueue_scripts', function() {
- if ( is_page_template( 'custom-map_24hours.php' ) ) {
- wp_enqueue_script( 'leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.js', [], '1.6.0', true );
- wp_enqueue_script( 'list_24hours', get_parent_theme_file_uri( 'js/list_24hours.js' ), ['jquery', 'leaflet'], '1.0', true );
- $locations = [];
- $query = new WP_Query( [
- 'post_type' => 'action',
- ] );
- foreach ( $query->posts as $post ) {
- // pick only 24 hours actions
- if ( rwmb_get_value('calendar', '', $post->ID) == '24hours') {
- $location = rwmb_get_value( 'action-location', '', $post->ID );
- // $location['title'] = $post->post_title;
- $location['title'] = rwmb_get_value( 'action-title', '', $post->ID );
- $location['address'] = rwmb_get_value( 'action-address', '', $post->ID );
- $location['icon'] = rwmb_get_value( 'action-icon', '', $post->ID );
- $location['description'] = rwmb_get_value( 'action-description', '', $post->ID );
- $location['start'] = rwmb_get_value( 'action-start-date', '', $post->ID );
- $location['end'] = rwmb_get_value( 'action-end-date', '', $post->ID );
- $location['link'] = rwmb_get_value( 'action-url', '', $post->ID );
- $location['calendar'] = rwmb_get_value( 'calendar', '', $post->ID );
- $location['mediaembed'] = rwmb_get_value( 'mediaembed', '', $post->ID );
- $locations[] = $location;
- }
- }
- wp_localize_script( 'list_24hours', 'Locations', $locations );
- }
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement