Advertisement
Beee

pull events

Mar 29th, 2022
1,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. // get all events
  2. $event_data = $this->get_content( $endpoint, $after );
  3.  
  4. // single event (make into array)
  5. if ( $event_id && isset( $event_data[ 'activity' ] ) ) {
  6.     $event_data[ 'activities' ][] = $event_data[ 'activity' ];
  7. }
  8. // all events (incl. single)
  9. if ( isset( $event_data[ 'activities' ] ) && ! empty( $event_data[ 'activities' ] ) ) {
  10.     foreach( $event_data[ 'activities' ] as $event ) {
  11.         if ( isset( $event[ 'activityID' ] ) && 'Oefenruimte' != $event[ 'title' ] ) {
  12.             $endpoint          = $this->determine_endpoint( $event[ 'activityID' ] );
  13.             $single_event_data = $this->get_content( $endpoint );
  14.  
  15.             if ( isset( $single_event_data[ 'activity' ] ) ) {
  16.                 $event_values         = $single_event_data[ 'activity' ];
  17.                 $description_endpoint = $this->determine_endpoint( $event[ 'activityID' ], 'information' );
  18.                 $description_data     = $this->get_content( $description_endpoint );
  19.                 $image_endpoint       = $this->determine_endpoint( $event[ 'activityID' ], 'images' );
  20.                 $image_data           = $this->get_content( $image_endpoint );
  21.  
  22.                 if ( isset( $description_data[ 'info' ][ 'shorttext' ] ) ) {
  23.                     $event_values[ 'shorttext' ] = $description_data[ 'info' ][ 'shorttext' ];
  24.                 }
  25.  
  26.                 if ( isset( $description_data[ 'info' ][ 'longtext' ] ) ) {
  27.                     $event_values[ 'longtext' ] = wp_kses( $description_data[ 'info' ][ 'longtext' ], 'data' );
  28.                 }
  29.  
  30.                 if ( isset( $image_data[ 'images' ] ) ) {
  31.                     $event_values[ 'images' ] = $image_data[ 'images' ];
  32.                 }
  33.                 $all_event_data[] = $event_values;
  34.             }
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement