protected function create_post(array $record) { $venue = $this->build_venue_array($record); $id = TribeEventsAPI::createVenue($venue); TribeEventsAPI::updateVenue($id, $venue); return $id; }
/** * Saves the event venue information passed via an event */ private static function saveEventVenue($data, $post = null, $post_status = 'publish') { if (isset($data['VenueID']) && $data['VenueID'] > 0) { if (count($data) == 1) { // Only an ID was passed and we should do nothing. return $data['VenueID']; } else { return TribeEventsAPI::updateVenue($data['VenueID'], $data); } } else { return TribeEventsAPI::createVenue($data, $post_status); } }
public function save_venue_data($postID = null, $post = null) { global $_POST; // don't do anything on autosave or auto-draft either or massupdates // Or inline saves, or data being posted without a venue Or // finally, called from the save_post action, but on save_posts that // are not venue posts if (wp_is_post_autosave($postID) || $post->post_status == 'auto-draft' || isset($_GET['bulk_edit']) || isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save' || isset($_POST['venue']) && !$_POST['venue'] || $post->post_type != self::VENUE_POST_TYPE && $postID) { return; } if (!current_user_can('edit_tribe_venues')) { return; } //There is a possibility to get stuck in an infinite loop. //That would be bad. remove_action('save_post', array($this, 'save_venue_data'), 16, 2); if (!isset($_POST['post_title']) || !$_POST['post_title']) { $_POST['post_title'] = "Unnamed Venue"; } $_POST['venue']['Venue'] = $_POST['post_title']; $data = stripslashes_deep($_POST['venue']); $venue_id = TribeEventsAPI::updateVenue($postID, $data); return $venue_id; }
/** * Saves the event venue information passed via an event * * @param array $data The venue data. * @param WP_Post $post The venue object. * @param string $post_status The intended post status. * * @return mixed. */ private static function saveEventVenue($data, $post = null, $post_status = 'publish') { if (isset($data['VenueID']) && $data['VenueID'] > 0) { if (count($data) == 1) { // Only an ID was passed and we should do nothing. return $data['VenueID']; } else { $show_map = get_post_meta($data['VenueID'], '_VenueShowMap', true); $show_map_link = get_post_meta($data['VenueID'], '_VenueShowMapLink', true); $data['ShowMap'] = $show_map ? $show_map : 'false'; $data['ShowMapLink'] = $show_map_link ? $show_map_link : 'false'; TribeEventsAPI::updateVenue($data['VenueID'], $data); return $data['VenueID']; } } else { return TribeEventsAPI::createVenue($data, $post_status); } }
/** * Make sure the venue meta gets saved * * @param int $postID The venue id. * @param WP_Post $post The post object. * @return null|void */ public function save_venue_data($postID = null, $post = null) { global $current_screen; if (!empty($current_screen) && $current_screen->id == 'tribe_venue') { // single venue page $_POST['Venue'] = isset($_POST['venue']) ? stripslashes_deep($_POST['venue']) : null; } // Don't save the venue meta if there wasn't one submitted if (empty($_POST['Venue'])) { return; } // @TODO move this to the API function if (!current_user_can('edit_tribe_venues')) { return; } $data = stripslashes_deep($_POST['Venue']); TribeEventsAPI::updateVenue($postID, $data); }
protected function update_post($post_id, array $record) { $venue = $this->build_venue_array($record); TribeEventsAPI::updateVenue($post_id, $venue); }
/** * Make sure the venue meta gets saved * * @param int $postID The venue id. * @param WP_Post $post The post object. * * @return null|void */ public function save_venue_data($postID = null, $post = null) { // was a venue submitted from the single venue post editor? if (empty($_POST['post_ID']) || $_POST['post_ID'] != $postID || empty($_POST['venue'])) { return; } // is the current user allowed to edit this venue? if (!current_user_can('edit_tribe_venue', $postID)) { return; } $data = stripslashes_deep($_POST['venue']); TribeEventsAPI::updateVenue($postID, $data); }
/** * Update a Venue * * @param int $postId ID of the Venue to be modified. * @param array $args Args for updating the post. See {@link tribe_create_venue()} for more info. * @return int ID of the Venue that was created. False if update failed. * @link http://codex.wordpress.org/Function_Reference/wp_update_post * @see wp_update_post() * @see tribe_create_venue() * @category Venue Functions */ function tribe_update_venue($postId, $args) { $postId = TribeEventsAPI::updateVenue($postId, $args); return $postId; }
/** * If you are saving a new venue separate from an event. * * @param int $postID The venue id. * @param WP_Post $post The post object. * @return null|void */ public function save_venue_data($postID = null, $post = null) { global $_POST; //There is a possibility to get stuck in an infinite loop. //That would be bad. remove_action('save_post', array($this, 'save_venue_data'), 16, 2); if (!isset($_POST['venue'])) { $_POST['venue'] = null; } // don't do anything on autosave or auto-draft either or massupdates // Or inline saves, or data being posted without a venue Or // finally, called from the save_post action, but on save_posts that // are not venue posts if ($post->post_type != self::VENUE_POST_TYPE && $postID && (wp_is_post_autosave($postID) || in_array($post->post_status, array('auto-draft', 'draft')) || isset($_GET['bulk_edit']) || !$_POST['venue'] || isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save')) { return; } if (!current_user_can('edit_tribe_venues')) { return; } $data = $_POST['venue']; if (empty($data['Venue'])) { if (!empty($_POST['post_title'])) { $data['Venue'] = $_POST['post_title']; } else { $data['Venue'] = __('Unnamed Venue', 'tribe-events-calendar'); } } $data = stripslashes_deep($data); $venue_id = TribeEventsAPI::updateVenue($postID, $data); /** * Put our hook back * @link http://codex.wordpress.org/Plugin_API/Action_Reference/save_post#Avoiding_infinite_loops */ add_action('save_post', array($this, 'save_venue_data'), 16, 2); // return $venue_id; }
protected function update_post($post_id, array $record) { $this->hack_to_remove_broken_filters(); $venue = $this->build_venue_array($record); TribeEventsAPI::updateVenue($post_id, $venue); }
/** * Convert Venue data * * @param string $post */ private static function convertVenue($post) { $venue = array(); foreach (self::$legacyVenueTags as $tag) { $strippedTag = str_replace('_Event', '', $tag); $meta = get_post_meta($post->ID, $tag, true); $venue[$strippedTag] = $meta; delete_post_meta($post->ID, $tag); } if ($venue['Country'] == 'United States') { $venue['StateProvince'] = get_post_meta($post->ID, '_EventState', true); } else { $venue['StateProvince'] = get_post_meta($post->ID, '_EventProvince', true); } $unique_venue = $venue['Venue'] . $venue['Address'] . $venue['StateProvince']; if ($unique_venue && trim($unique_venue) != "") { if (!isset(self::$curVenues[$unique_venue])) { self::$curVenues[$unique_venue] = TribeEventsAPI::createVenue($venue); } else { TribeEventsAPI::updateVenue(self::$curVenues[$unique_venue], $venue); } update_post_meta($post->ID, '_EventVenueID', self::$curVenues[$unique_venue]); } }
/** * Main form for events. * * @param int $tribe_venue_id The event's venue ID. * @return string The form. * @author Nick Ciske * @since 1.0 */ public function doVenueForm($tribe_venue_id) { $output = ''; add_filter('tribe-post-origin', array($this, 'filterPostOrigin')); if (empty($tribe_venue_id)) { $output .= '<p>' . __('Venue not found.', 'tribe-events-community') . '</p>'; return $output; } if (!class_exists('TribeEventsPro')) { return __('This feature is not currently enabled.', 'tribe-events-community'); } if (!is_user_logged_in()) { return $this->login_form(__('Please log in to edit this venue', 'tribe-events-community')); } if (!current_user_can('edit_post', $tribe_venue_id)) { $output .= '<p>' . __('You do not have permission to edit this venue.', 'tribe-events-community') . '</p>'; return $output; } $this->loadScripts = true; $output .= '<div id="tribe-community-events" class="form venue">'; if (isset($_POST['community-event']) && $_POST['community-event'] && check_admin_referer('ecp_venue_submission')) { if (isset($_POST['post_title']) && $_POST['post_title']) { require_once 'tribe-community-events-submission-scrubber.php'; require_once 'tribe-community-events-venue-submission-scrubber.php'; $_POST['ID'] = $tribe_venue_id; $scrubber = new TribeCommunityEvents_VenueSubmissionScrubber($_POST); $_POST = $scrubber->scrub(); remove_action('save_post_' . TribeEvents::VENUE_POST_TYPE, array(TribeEvents::instance(), 'save_venue_data'), 16, 2); wp_update_post(array('post_title' => $_POST['post_title'], 'ID' => $tribe_venue_id, 'post_content' => $_POST['post_content'])); TribeEventsAPI::updateVenue($tribe_venue_id, $_POST['venue']); $this->enqueueOutputMessage(__('Venue updated.', 'tribe-events-community')); /* // how it should work, but updateVenue does not return a boolean if ( TribeEventsAPI::updateVenue($tribe_venue_id, $_POST) ) { $this->enqueueOutputMessage( __("Venue updated.",'tribe-events-community') ); }else{ $this->enqueueOutputMessage( __("There was a problem saving your venue, please try again.",'tribe-events-community'), 'error' ); } */ } else { $this->enqueueOutputMessage(__('Venue name cannot be blank.', 'tribe-events-community'), 'error'); } } else { if (isset($_POST['community-event'])) { $this->enqueueOutputMessage(__('There was a problem updating your venue, please try again.', 'tribe-events-community'), 'error'); } } global $post; $post = get_post(intval($tribe_venue_id)); ob_start(); include TribeEventsTemplates::getTemplateHierarchy('community/edit-venue'); $output .= ob_get_clean(); wp_reset_query(); $output .= '</div>'; remove_filter('tribe-post-origin', array($this, 'filterPostOrigin')); return $output; }