コード例 #1
0
 /**
  *    _set_CPT_terms
  *
  * @access private
  * @return void
  */
 private function _set_CPT_terms()
 {
     if (empty($this->_CPT_terms)) {
         $terms = EEM_Term::instance()->get_all_CPT_post_tags();
         foreach ($terms as $term) {
             if ($term instanceof EE_Term) {
                 $this->_CPT_terms[$term->slug()] = $term;
             }
         }
     }
 }
コード例 #2
0
 /**
  * Gets all terms for 'espresso_event_categories' we can find
  * @param array $query_params
  * @return EE_Term[]
  */
 public function get_all_event_categories($query_params = array())
 {
     $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
     $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
     return EEM_Term::instance()->get_all($query_params);
 }
コード例 #3
0
 /**
  * get_all_venue_post_tags
  *
  * @return EE_Soft_Delete_Base_Class[]
  */
 public function get_all_venue_post_tags()
 {
     $post_tags = EEM_Term::instance()->get_all(array(array('Term_Taxonomy.taxonomy' => 'post_tag', 'Term_Taxonomy.Venue.post_type' => 'espresso_venues'), 'order_by' => array('name' => 'ASC'), 'force_join' => array('Term_Taxonomy')));
     foreach ($post_tags as $key => $post_tag) {
         $post_tags[$key]->post_type = 'espresso_venues';
     }
     return $post_tags;
     //		return array( 'espresso_venues' => $post_tags );
 }
コード例 #4
0
 /**
  * generates the dropdown selector for event categories
  * typically used as a filter on list tables.
  * @param  integer $current_cat currently selected category
  * @return string               html for dropdown
  */
 public static function generate_event_category_dropdown($current_cat = -1)
 {
     $categories = EEM_Term::instance()->get_all_ee_categories(TRUE);
     $options = array('0' => array('text' => __('All Categories', 'event_espresso'), 'id' => -1));
     //setup categories for dropdown
     foreach ($categories as $category) {
         $options[] = array('text' => $category->get('name'), 'id' => $category->ID());
     }
     return self::select_input('EVT_CAT', $options, $current_cat);
 }
コード例 #5
0
 /**
  * Adds an event category with the specified name and description to the specified
  * $cpt_model_object. Intelligently adds a term if necessary, and adds a term_taxonomy if necessary,
  * and adds an entry in the term_relationship if necessary.
  * @param EE_CPT_Base $cpt_model_object
  * @param string $category_name (used to derive the term slug too)
  * @param string $category_description
  * @param int $parent_term_taxonomy_id
  * @return EE_Term_Taxonomy
  */
 function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null)
 {
     //create term
     require_once EE_MODELS . 'EEM_Term.model.php';
     //first, check for a term by the same name or slug
     $category_slug = sanitize_title($category_name);
     $term = EEM_Term::instance()->get_one(array(array('OR' => array('name' => $category_name, 'slug' => $category_slug))));
     if (!$term) {
         $term = EE_Term::new_instance(array('name' => $category_name, 'slug' => $category_slug));
         $term->save();
     }
     //make sure there's a term-taxonomy entry too
     require_once EE_MODELS . 'EEM_Term_Taxonomy.model.php';
     $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id' => $term->ID(), 'taxonomy' => EE_Event_Category_Taxonomy)));
     /** @var $term_taxonomy EE_Term_Taxonomy */
     if (!$term_taxonomy) {
         $term_taxonomy = EE_Term_Taxonomy::new_instance(array('term_id' => $term->ID(), 'taxonomy' => EE_Event_Category_Taxonomy, 'description' => $category_description, 'count' => 1, 'parent' => $parent_term_taxonomy_id));
         $term_taxonomy->save();
     } else {
         $term_taxonomy->set_count($term_taxonomy->count() + 1);
         $term_taxonomy->save();
     }
     return $this->add_relationship_to($cpt_model_object, $term_taxonomy, 'Term_Taxonomy');
 }
コード例 #6
0
    /**
     * Gets the HTML for the calendar filters area
     * @param array $ee_calendar_js_options mess of options which will eb passed onto js
     * which we might want in here. (But using the config object directly might be nice,
     * because it's well-defined... however, unfortunately settings in it might be overridden
     * by shortcode attributes, which you can access in this array, if you know their key)
     * @return string
     */
    private function _get_filter_html($ee_calendar_js_options = array())
    {
        $output_filter = '';
        if (!$ee_calendar_js_options['widget']) {
            // Query for Select box filters
            $ee_terms = EEM_Term::instance()->get_all(array('order_by' => array('name' => 'ASC'), array('Term_Taxonomy.taxonomy' => 'espresso_event_categories')));
            $venues = EEM_Venue::instance()->get_all(array('order_by' => array('VNU_name' => 'ASC')));
            if (!empty($venues) || !empty($ee_terms)) {
                ob_start();
                //Category legend
                if ($this->config()->display->enable_category_legend) {
                    echo '
			<div id="espresso-category-legend">
				<p class="smaller-text lt-grey-txt">' . __('Click to select a category:', 'event_espresso') . '</p>
				<ul id="ee-category-legend-ul">';
                    foreach ($ee_terms as $ee_term) {
                        if ($ee_term instanceof EE_Term) {
                            /*@var $ee_term EE_Term */
                            $catcode = $ee_term->ID();
                            $bg = $ee_term->get_extra_meta('background_color', TRUE, $this->config()->display->event_background);
                            $fontcolor = $ee_term->get_extra_meta('text_color', TRUE, $this->config()->display->event_text_color);
                            $use_bg = $ee_term->get_extra_meta('use_color_picker', TRUE);
                            $caturl = esc_url(add_query_arg('event_category_id', $ee_term->slug()));
                            if ($use_bg) {
                                echo '
							<li id="ee-category-legend-li-' . $catcode . '" class="has-sub" style="background: ' . $bg . ';">
								<span class="ee-category"><a href="' . $caturl . '" style="color: ' . $fontcolor . ';">' . $ee_term->name() . '</a></span>
							</li>';
                            } else {
                                echo '
							<li id="ee-category-li-' . $catcode . '" class="has-sub" style="background: #f3f3f3;" >
								<span class="ee-category"><a href="' . $caturl . '">' . $ee_term->name() . '</a></span>
							</li>';
                            }
                        }
                    }
                    echo '</ul>
				</div>
				<div class="clear"></div>
				';
                }
                //Filter dropdowns
                if ($this->config()->display->enable_calendar_filters) {
                    ?>
				<!-- select box filters -->
				<div class="ee-filter-form">
				<form name="filter-calendar-form" id="filter-calendar-form" method="post" action="">
				<?php 
                    if (!empty($ee_terms)) {
                        ?>
					<label for="ee-category-submit"></label>
					<select id="ee-category-submit" class="submit-this ee-category-select" name="event_category_id">
					<option id="option" class="ee_select" value=""><?php 
                        echo __('Select a Category', 'event_espresso');
                        ?>
</option>
					<option class="ee_filter_show_all" value=""><?php 
                        echo __('Show All', 'event_espresso');
                        ?>
</option>
					<?php 
                        foreach ($ee_terms as $term) {
                            if ($term instanceof EE_Term) {
                                $selected = in_array($ee_calendar_js_options['event_category_id'], array($term->slug(), $term->ID())) ? 'selected="selected"' : '';
                                echo '<option ' . $selected . ' value="' . $term->slug() . '">' . $term->name() . '</option>';
                            }
                        }
                        ?>
					</select>
				<?php 
                    }
                    ?>

				<?php 
                    if (!empty($venues)) {
                        ?>
					<label for="ee-venue-submit"></label>
					<select id="ee-venue-submit" class="submit-this ee-venue-select" name="event_venue_id">
					<option class="ee_select" value=""><?php 
                        echo __('Select a Venue', 'event_espresso');
                        ?>
</option>
					<option class="ee_filter_show_all" value=""><?php 
                        echo __('Show All', 'event_espresso');
                        ?>
</option>
					<?php 
                        foreach ($venues as $venue) {
                            if ($venue instanceof EE_Venue && $venue->status() == 'publish') {
                                $selected = in_array($ee_calendar_js_options['event_venue_id'], array($venue->identifier(), $venue->ID())) ? ' selected="selected"' : '';
                                echo '<option' . $selected . ' value="' . $venue->identifier() . '">' . stripslashes($venue->name()) . '</option>';
                            }
                        }
                        ?>
					</select>
				<?php 
                    }
                    ?>
				</form>
				</div>
				<?php 
                }
                $output_filter = ob_get_contents();
                ob_end_clean();
            }
        }
        return $output_filter;
    }
 protected function _save_calendar_color_settings($redirection_query_args)
 {
     $CAT_ID = isset($redirection_query_args['EVT_CAT_ID']) ? $redirection_query_args['EVT_CAT_ID'] : NULL;
     if ($CAT_ID) {
         $category = EEM_Term::instance()->get_one_by_ID($CAT_ID);
         $category->update_extra_meta('use_color_picker', intval($this->_req_data['use-color-picker-for-calendar']));
         $category->update_extra_meta('background_color', wp_strip_all_tags($this->_req_data['category-background-color-for-calendar']));
         $category->update_extra_meta('text_color', wp_strip_all_tags($this->_req_data['category-text-color-for-calendar']));
     }
 }
コード例 #8
0
 function test_get_all__caps__delete__venue_and_event_caps()
 {
     global $current_user;
     $current_user = $this->factory->user->create_and_get();
     $current_user->add_cap('ee_delete_venue_category');
     $current_user->add_cap('ee_delete_event_category');
     $venue_and_event_cats = EEM_Term::instance()->get_all(array('caps' => EEM_Base::caps_delete, 'order_by' => array('term_id' => 'ASC'), array('Term_Taxonomy.taxonomy' => array('IN', array('espresso_event_categories', 'espresso_venue_categories')))));
     $this->assertEEModelObjectsEquals($this->event_term, reset($venue_and_event_cats));
     $this->assertEEModelObjectsEquals($this->venue_term, next($venue_and_event_cats));
     $this->assertEquals(2, count($venue_and_event_cats));
 }