Advertisement
feminista2

code added to functions.php

Apr 24th, 2020
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. add_action( 'wp_enqueue_scripts', function() {
  2.     if ( is_page_template( 'custom-map_24hours.php' ) ) {
  3.         wp_enqueue_style( 'leaflet', 'https://unpkg.com/leaflet@1.6.0/dist/leaflet.css', [], '1.6.0' );
  4.         wp_enqueue_script( 'leaflet', 'https://unpkg.com/leaflet@1.6.0/dist/leaflet.js', [], '1.6.0', true );
  5.  
  6.         wp_enqueue_script( 'list_24hours', get_parent_theme_file_uri( 'js/list_24hours.js' ), ['jquery', 'leaflet'], '1.0', true );
  7.  
  8.         $locations = [];
  9.         $query = new WP_Query( [
  10.             'post_type' => 'action',
  11.         ] );
  12.         foreach ( $query->posts as $post ) {
  13. // pick only 24 hours actions
  14.             if ( rwmb_get_value('calendar', '', $post->ID) == '24hours') {
  15.  
  16.             $location            = rwmb_get_value( 'action-location', '', $post->ID );
  17. //            $location['title']   = $post->post_title;        
  18.             $location['title']   = rwmb_get_value( 'action-title', '', $post->ID );
  19.             $location['address'] = rwmb_get_value( 'action-address', '', $post->ID );
  20.             $location['icon']    = rwmb_get_value( 'action-icon', '', $post->ID );
  21.             $location['description']    = rwmb_get_value( 'action-description', '', $post->ID );
  22.             $location['start']    = rwmb_get_value( 'action-start-date', '', $post->ID );
  23.             $location['end']    = rwmb_get_value( 'action-end-date', '', $post->ID );
  24.             $location['link']    = rwmb_get_value( 'action-url', '', $post->ID );
  25.             $location['calendar']    = rwmb_get_value( 'calendar', '', $post->ID );
  26.             $location['mediaembed']     = rwmb_get_value( 'mediaembed', '', $post->ID );
  27.             $locations[]         = $location;
  28.         }
  29.         }
  30.         wp_localize_script( 'list_24hours', 'Locations', $locations );
  31.     }
  32. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement