tribe = Tribe__Events__Main::instance(); $this->linked_posts = Tribe__Events__Linked_Posts::instance(); $this->post_type = $post_type; $this->singular_name = $this->linked_posts->linked_post_types[ $this->post_type ]['singular_name']; $this->singular_name_lowercase = $this->linked_posts->linked_post_types[ $this->post_type ]['singular_name_lowercase']; $this->get_event( $event ); add_action( 'wp', array( $this, 'sticky_form_data' ), 50 ); // Later than events-admin.js itself is enqueued } /** * Work with the specifed event object or else use a placeholder if we are in * the middle of creating a new event. * * @param null $event */ protected function get_event( $event = null ) { if ( is_null( $event ) ) { $event = $GLOBALS['post']; } if ( is_numeric( $event ) ) { $event = WP_Post::get_instance( $event ); } if ( $event instanceof stdClass || is_array( $event ) ) { $event = new WP_Post( (object) $event ); } if ( ! $event instanceof WP_Post ) { $event = new WP_Post( (object) array( 'ID' => 0 ) ); } $this->event = $event; } /** * Render the organizer chooser section for the events meta box * */ public function render() { $this->render_dropdowns(); $this->render_add_post_button(); /** * Make this Template filterable, used for Community Facing templates * * @var string $file_path */ include apply_filters( 'tribe_events_multiple_linked_post_template', $this->tribe->pluginPath . 'src/admin-views/linked-post-meta-box.php' ); } /** * displays the saved organizer dropdown in the event metabox * Used to be a PRO only feature, but as of 3.0, it is part of Core. * */ public function render_dropdowns() { $post_id = $this->event->ID; $current_linked_posts = get_post_meta( $post_id, $this->linked_posts->get_meta_key( $this->post_type ), false ); if ( $this->use_default_post( $current_linked_posts ) ) { /** * Filters the default selected post for the linked post * * @param array $default Default post array * @param string $post_type Linked post post type */ $current_linked_posts = apply_filters( 'tribe_events_linked_post_default', array(), $this->post_type ); } /** * Filters the default selected post for the linked post * * @param array $current_linked_posts Array of currently linked posts * @param string $post_type Linked post post type */ $current_linked_posts = (array) apply_filters( 'tribe_display_event_linked_post_dropdown_id', $current_linked_posts, $this->post_type ); /* if the user can't create organizers, then remove any empty values from the $current_organizers array. This prevents the automatic selection of an organizer every time the event is edited. */ $linked_post_pto = get_post_type_object( $this->post_type ); if ( ! current_user_can( $linked_post_pto->cap->create_posts ) ) { $current_linked_posts = array_filter( $current_linked_posts ); } ?>maybe_parse_candidate_linked_posts( $current_linked_posts ); $i = 0; $num_records = count( $current_linked_posts ); do { echo '
'; $this->single_post_dropdown( isset( $current_linked_posts[ $i ] ) ? $current_linked_posts[ $i ] : 0 ); echo ''; $i++; } while ( $i < $num_records ); } /** * Render a single row of the organizers table * * @param int $organizer_id * */ protected function single_post_dropdown( $linked_post_id ) { $linked_post_type_container = $this->linked_posts->get_post_type_container( $this->post_type ); $linked_post_type_id_field = $this->linked_posts->get_post_type_id_field_index( $this->post_type ); ?>