/**
  *  The class singleton constructor.
  *
  * @return Tribe__Tickets__Cache__Central
  */
 public static function instance()
 {
     if (empty(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Returns a list of posts that could be possible homes for a ticket
  * type, given the constraints in optional array $request (if not set,
  * looks in $_POST for the corresponding values):
  *
  * - 'post_type': string or array of post types
  * - 'search_term': string used for searching posts to narrow the field
  *
  * @param array|null $request post parameters (or looks at $_POST if not set)
  *
  * @return array
  */
 protected function get_possible_matches(array $request = null)
 {
     // Take the params from $request if set, else look at $_POST
     $params = wp_parse_args(is_null($request) ? $_POST : $request, array('post_type' => array(), 'search_terms' => '', 'ignore' => ''));
     // The post_type argument should be an array (of all possible types, if not specified)
     $post_types = array_filter((array) $params['post_type']);
     if (empty($post_types) || 'all' === $params['post_type']) {
         $post_types = array_keys($this->get_post_types_list());
     }
     /**
      * Controls the number of posts returned when searching for posts that
      * can serve as ticket hosts.
      *
      * @param int $limit
      */
     $limit = (int) apply_filters('tribe_tickets_find_ticket_type_host_posts_limit', 100);
     $ignore_ids = is_numeric($params['ignore']) ? array(absint($params['ignore'])) : array();
     $cache = Tribe__Tickets__Cache__Central::instance()->get_cache();
     $posts_without_ticket_types = $cache->posts_without_ticket_types();
     return $this->format_post_list(get_posts(array('post_type' => $post_types, 'posts_per_page' => $limit, 'eventDisplay' => 'custom', 'orderby' => 'title', 'order' => 'ASC', 's' => $params['search_terms'], 'post__not_in' => array_merge($ignore_ids, $posts_without_ticket_types))));
 }
Example #3
0
 /**
  * set up hooks for this class
  */
 public function hooks()
 {
     add_action('init', array($this, 'init'));
     add_action('add_meta_boxes', array('Tribe__Tickets__Metabox', 'maybe_add_meta_box'));
     add_action('admin_enqueue_scripts', array('Tribe__Tickets__Metabox', 'add_admin_scripts'));
     add_filter('tribe_post_types', array($this, 'inject_post_types'));
     // Setup Help Tab texting
     add_action('tribe_help_pre_get_sections', array($this, 'add_help_section_support_content'));
     add_action('tribe_help_pre_get_sections', array($this, 'add_help_section_featured_content'));
     add_action('tribe_help_pre_get_sections', array($this, 'add_help_section_extra_content'));
     add_filter('tribe_support_registered_template_systems', array($this, 'add_template_updates_check'));
     add_action('plugins_loaded', array('Tribe__Support', 'getInstance'));
     add_action('tribe_events_single_event_after_the_meta', array($this, 'add_linking_archor'), 5);
     // Hook to oembeds
     add_action('tribe_events_embed_after_the_cost_value', array($this, 'inject_buy_button_into_oembed'));
     add_action('embed_head', array($this, 'embed_head'));
     // Attendee screen enhancements
     add_action('tribe_events_tickets_attendees_event_details_top', array($this, 'setup_attendance_totals'), 20);
     // CSV Import options
     if (class_exists('Tribe__Events__Main')) {
         add_filter('tribe_events_import_options_rows', array(Tribe__Tickets__CSV_Importer__Rows::instance(), 'filter_import_options_rows'));
         add_filter('tribe_aggregator_csv_post_types', array(Tribe__Tickets__CSV_Importer__Rows::instance(), 'filter_csv_post_types'));
         add_filter('tribe_aggregator_csv_column_mapping', array(Tribe__Tickets__CSV_Importer__Column_Names::instance(), 'filter_rsvp_column_mapping'));
         add_filter('tribe_event_import_rsvp_tickets_column_names', array(Tribe__Tickets__CSV_Importer__Column_Names::instance(), 'filter_rsvp_column_names'));
         add_filter('tribe_events_import_rsvp_tickets_importer', array('Tribe__Tickets__CSV_Importer__RSVP_Importer', 'instance'), 10, 2);
         add_action('tribe_tickets_ticket_deleted', array('Tribe__Tickets__Attendance', 'delete_attendees_caches'));
         /**
          * Hooking to "rsvp" to fetch an importer to fetch Column names is deprecated
          *
          * These are kept in place during the transition from the old CSV importer to the new importer
          * driven by Event Aggregator. We should remove these hooks when the old CSV interface gets
          * retired completely.
          *
          * @todo remove these two hooks when the old CSV interface is retired, maybe 5.0?
          */
         add_filter('tribe_events_import_rsvp_importer', array('Tribe__Tickets__CSV_Importer__RSVP_Importer', 'instance'), 10, 2);
         add_filter('tribe_event_import_rsvp_column_names', array(Tribe__Tickets__CSV_Importer__Column_Names::instance(), 'filter_rsvp_column_names'));
     }
     // Caching
     Tribe__Tickets__Cache__Central::instance()->hook();
 }