コード例 #1
0
 /**
  *
  * @param type $props_n_values
  * @return EE_Person
  */
 public static function new_instance($props_n_values = array())
 {
     $classname = __CLASS__;
     $has_object = parent::_check_for_object($props_n_values, $classname);
     $obj = $has_object ? $has_object : new self($props_n_values);
     return $obj;
 }
コード例 #2
0
 /**
  * add in any global scripts for cpt routes
  * @return void
  */
 public function load_global_scripts_styles()
 {
     parent::load_global_scripts_styles();
     if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
         //setup custom post status object for localize script but only if we've got a cpt object
         $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
         if (!empty($statuses)) {
             //get ALL statuses!
             $statuses = $this->_cpt_model_obj->get_all_post_statuses();
             //setup object
             $ee_cpt_statuses = array();
             foreach ($statuses as $status => $label) {
                 $ee_cpt_statuses[$status] = array('label' => $label, 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label));
             }
             wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
         }
     }
 }
コード例 #3
0
 /**
  * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL insert/updates
  * @param  int    $post_id ID of post being updated
  * @param  WP_Post $post    Post object from WP
  * @param  bool   $update  Whether this is an update or a new save.
  * @return void
  */
 public function insert_update($post_id, $post, $update)
 {
     //make sure that if this is a revision OR trash action that we don't do any updates!
     if (isset($this->_req_data['action']) && ($this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash')) {
         return;
     }
     $this->_set_model_object($post_id, true);
     //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
     if ($update && (!$this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id)) {
         return;
     }
     //check for autosave and update our req_data property accordingly.
     /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
     			foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
     
     				foreach ( (array) $values as $key => $value ) {
     					$this->_req_data[$key] = $value;
     				}
     			}
     
     		}/**/
     //TODO reactivate after autosave is implemented in 4.2
     //take care of updating any selected page_template IF this cpt supports it.
     if ($this->_supports_page_templates($post->post_type) && !empty($this->_req_data['page_template'])) {
         $post->page_template = $this->_req_data['page_template'];
         $page_templates = wp_get_theme()->get_page_templates($post);
         if ('default' != $this->_req_data['page_template'] && !isset($page_templates[$this->_req_data['page_template']])) {
             EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         } else {
             update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
         }
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     //TODO we'll remove this after reimplementing autosave in 4.2
     $this->_insert_update_cpt_item($post_id, $post);
 }
コード例 #4
0
 /**
  * Gets the URL for viewing this event on the front-end. Overrides parent
  * to check for an external URL first
  * @return string
  */
 public function get_permalink()
 {
     if ($this->external_url()) {
         return $this->external_url();
     } else {
         return parent::get_permalink();
     }
 }
コード例 #5
0
 /**
  *
  * @param array $props_n_values  incoming values
  * @param string $timezone  incoming timezone (if not set the timezone set for the website will be
  *                          		used.)
  * @param array $date_formats  incoming date_formats in an array where the first value is the
  *                             		    date_format and the second value is the time format
  * @return EE_Attendee
  */
 public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
 {
     $has_object = parent::_check_for_object($props_n_values, __CLASS__);
     return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
 }
コード例 #6
0
 /**
  *
  * @param array $props_n_values
  * @return EE_Venue
  */
 public static function new_instance($props_n_values = array())
 {
     $has_object = parent::_check_for_object($props_n_values, __CLASS__);
     return $has_object ? $has_object : new self($props_n_values);
 }