/** * save the settings * * @since 2.0.5 * @author jkudish * @return void */ public function save() { // some hooks do_action('tribe_settings_save'); do_action('tribe_settings_save_tab_' . $this->currentTab); // we'll need this later $parent_options = array(); /** * loop through each validated option and either * save it as is or figure out its parent option ID * (in that case, it's a serialized option array and * will be saved in the next loop) */ if (!empty($this->validated)) { foreach ($this->validated as $field_id => $validated_field) { // get the value and filter it $value = $validated_field->value; $value = apply_filters('tribe_settings_save_field_value', $value, $field_id, $validated_field); // figure out the parent option [could be set to false] and filter it $parent_option = isset($validated_field->field['parent_option']) ? $validated_field->field['parent_option'] : TribeEvents::OPTIONNAME; $parent_option = apply_filters('tribe_settings_save_field_parent_option', $parent_option, $field_id); // some hooks do_action('tribe_settings_save_field', $field_id, $value, $validated_field); do_action('tribe_settings_save_field_' . $field_id, $value, $validated_field); if (!$parent_option) { // if no parent option, then just save the option update_option($field_id, $value); } else { // set the parent option $parent_options[$parent_option][$field_id] = $value; } } } /** * loop through parent option arrays * and save them * NOTE: in the case of the main option Tribe Options, * this will save using the TribeEvents:setOptions method. */ foreach ($parent_options as $option_id => $new_options) { // get the old options $old_options = (array) get_option($option_id); // set the options by parsing old + new and filter that $options = apply_filters('tribe_settings_save_option_array', wp_parse_args($new_options, $old_options), $option_id); if ($option_id == TribeEvents::OPTIONNAME) { // save using the TribeEvents method TribeEvents::setOptions($options); } else { // save using regular WP method update_option($option_id, $options); } } do_action('tribe_settings_after_save'); do_action('tribe_settings_after_save_' . $this->currentTab); remove_action('shutdown', array($this, 'deleteOptions')); add_option('tribe_settings_sent_data', $_POST); add_option('tribe_settings_errors', $this->errors); add_option('tribe_settings_major_error', $this->major_error); wp_redirect(add_query_arg(array('saved' => true), $this->url)); exit; }
/** * enforce saving on additional fields tab * @author jkudish * @since 2.0.5 * @return void */ public function force_save_meta() { $options = TribeEvents::getOptions(); $options = self::save_meta_options($options); $options = TribeEvents::setOptions($options); }
public function displayMetaboxCustomFields() { // 'disable_metabox_custom_fields' $show_box = tribe_get_option('disable_metabox_custom_fields'); if ($show_box == 'show') { return true; } if ($show_box == 'hide') { remove_post_type_support(TribeEvents::POSTTYPE, 'custom-fields'); return false; } if (empty($show_box)) { global $wpdb; $meta_keys = $wpdb->get_results("select distinct pm.meta_key from {$wpdb->postmeta} pm\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id\r\n\t\t\t\t\t\t\t\t\t\tWHERE p.post_type = '" . TribeEvents::POSTTYPE . "'\r\n\t\t\t\t\t\t\t\t\t\tAND pm.meta_key NOT LIKE '_wp_%'\r\n\t\t\t\t\t\t\t\t\t\tAND pm.meta_key NOT IN (\r\n\t\t\t\t\t\t\t\t\t\t\t'_edit_last',\r\n\t\t\t\t\t\t\t\t\t\t\t'_edit_lock',\r\n\t\t\t\t\t\t\t\t\t\t\t'_thumbnail_id',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventConference', \r\n\t\t\t\t\t\t\t\t\t\t\t'_EventAllDay', \r\n\t\t\t\t\t\t\t\t\t\t\t'_EventHideFromUpcoming', \r\n\t\t\t\t\t\t\t\t\t\t\t'_EventAuditTrail',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventOrigin',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventShowMap',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventVenueID',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventShowMapLink',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventCost',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventOrganizerID',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventRecurrence',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventStartDate',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventEndDate',\r\n\t\t\t\t\t\t\t\t\t\t\t'_EventDuration',\r\n\t\t\t\t\t\t\t\t\t\t\t'_FacebookID')"); if (empty($meta_keys)) { remove_post_type_support(TribeEvents::POSTTYPE, 'custom-fields'); // update_option('disable_metabox_custom_fields','hide'); $options['disable_metabox_custom_fields'] = 'hide'; $r = false; } else { // update_option('disable_metabox_custom_fields','true'); $options['disable_metabox_custom_fields'] = 'show'; $r = true; } TribeEvents::setOptions($options); return $r; } }