コード例 #1
0
    /**
     * 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);
        }
        ?>
<script type="text/template" id="tmpl-tribe-select-<?php 
        echo esc_attr($this->post_type);
        ?>
"><?php 
        $this->single_post_dropdown(0);
        ?>
</script><?php 
        $current_linked_posts = $this->maybe_parse_candidate_linked_posts($current_linked_posts);
        $i = 0;
        $num_records = count($current_linked_posts);
        do {
            echo '<tbody>';
            $this->single_post_dropdown(isset($current_linked_posts[$i]) ? $current_linked_posts[$i] : 0);
            echo '</tbody>';
            $i++;
        } while ($i < $num_records);
    }