Tribe__Events__Venue::update( int $venue_id, array $data )
Updates an venue
Contents
Parameters
- $venue_id
-
(int) (Required) The venue ID to update.
- $data
-
(array) (Required) The venue data.
Return
(int) The updated venue post ID
Source
File: src/Tribe/Venue.php
public function update( $venue_id, $data ) { /** * Filters the ID of the venue before the class updates it. * * If a non `null` value is returned that will be returned and the venue update process will bail. * * @param mixed $check Whether the venue update process should proceed or not. * @param int $venue_id The post ID of the venue that should be updated * @param array $data The data provided to update the venue. * * @since 4.6 */ $check = apply_filters( 'tribe_events_tribe_venue_update', null, $venue_id, $data ); if ( null !== $check ) { return $check; } $data = new Tribe__Data( $data, '' ); unset( $data['VenueID'] ); $args = array_filter( array( 'ID' => $venue_id, 'post_title' => Tribe__Utils__Array::get( $data, 'post_title', $data['Venue'] ), 'post_content' => Tribe__Utils__Array::get( $data, 'post_content', $data['Description'] ), 'post_excerpt' => Tribe__Utils__Array::get( $data, 'post_excerpt', $data['Excerpt'] ), 'post_author' => $data['post_author'], 'post_date' => $data['post_date'], 'post_date_gmt' => $data['post_date_gmt'], 'post_status' => $data['post_status'], ) ); if ( count( $args ) > 1 ) { $post_type = Tribe__Events__Main::VENUE_POST_TYPE; $tag = "save_post_{$post_type}"; remove_action( $tag, array( tribe( 'tec.main' ), 'save_venue_data' ), 16 ); wp_update_post( $args ); add_action( $tag, array( tribe( 'tec.main' ), 'save_venue_data' ), 16, 2 ); } if ( isset( $data['ShowMap'] ) && ! tribe_is_truthy( $data['ShowMap'] ) ) { $data['ShowMap'] = 'false'; } else { $data['ShowMap'] = true; } if ( isset( $data['ShowMapLink'] ) && ! tribe_is_truthy( $data['ShowMapLink'] ) ) { $data['ShowMapLink'] = 'false'; } else { $data['ShowMapLink'] = true; } $post_fields = array_merge( Tribe__Duplicate__Post::$post_table_columns, array( 'Venue', 'Description', 'Excerpt', ) ); $meta = array_diff_key( $data->to_array(), array_combine( $post_fields, $post_fields ) ); $this->save_meta( $venue_id, $meta ); /** * Fires immediately after a venue has been updated. * * @param int $venue_id The updated venue post ID. * @param array $data The data used to update the venue. */ do_action( 'tribe_events_venue_updated', $venue_id, $data->to_array() ); return $venue_id; }