Tribe__Tickets_Plus__Meta::save_meta( int $unused_post_id, Tribe__Tickets__Ticket_Object $ticket, array $data )

Saves meta configuration on a ticket


Parameters

$unused_post_id

(int) (Required) ID of parent "event" post

$ticket

(Tribe__Tickets__Ticket_Object) (Required) Ticket object

$data

(array) (Required) Post data that was submitted


Top ↑

Source

File: src/Tribe/Meta.php

	public function save_meta( $unused_post_id, $ticket, $data ) {
		// Bail if we are not saving ticket input data.
		if ( ! isset( $data['tribe-tickets-input'] ) ) {
			return false;
		}

		$data['tribe-tickets-input'] = array_filter( $data['tribe-tickets-input'] );

		if ( empty( $data['tribe-tickets-input'] ) ) {
			$meta = array();
		} else {
			$meta = $this->build_field_array( $ticket->ID, $data );
		}

		// this is for the meta fields configuration associated with the "product" post type
		update_post_meta( $ticket->ID, self::META_KEY, $meta );

		if ( ! $meta ) {
			// no meta? Do not enable meta on the ticket.
			delete_post_meta( $ticket->ID, self::ENABLE_META_KEY );

			return;
		}

		// if there is some meta enable meta for the ticket
		update_post_meta( $ticket->ID, self::ENABLE_META_KEY, 'yes' );

		// Save templates too
		if ( isset( $data['tribe-tickets-save-fieldset'] ) ) {
			$fieldset = wp_insert_post( array(
				'post_type'   => Tribe__Tickets_Plus__Meta__Fieldset::POSTTYPE,
				'post_title'  => empty( $data['tribe-tickets-saved-fieldset-name'] ) ? null : $data['tribe-tickets-saved-fieldset-name'],
				'post_status' => 'publish',
			) );

			// This is for the meta fields template
			update_post_meta( $fieldset, Tribe__Tickets_Plus__Meta__Fieldset::META_KEY, $meta );
		}

	}

Top ↑

Changelog

Changelog
Version Description
4.1 Introduced.