Tribe__Tickets__Metabox::ajax_panels()

Refreshes panels after ajax calls that change data


Return

(string) html content of the panels


Top ↑

Source

File: src/Tribe/Metabox.php

	public function ajax_panels() {
		$post_id = absint( tribe_get_request_var( 'post_id', 0 ) );

		// Didn't get a post id to work with - bail
		if ( ! $post_id ) {
			wp_send_json_error( esc_html__( 'Invalid Post ID', 'event-tickets' ) );
		}

		// Overwrites for a few templates that use get_the_ID() and get_post()
		global $post;

		$post = get_post( $post_id );
		$data = wp_parse_args( tribe_get_request_var( array( 'data' ), array() ), array() );
		$notice = tribe_get_request_var( 'tribe-notice', false );

		$data = Tribe__Utils__Array::get( $data, array( 'tribe-tickets' ), null );

		// Save if the info was passed
		if ( ! empty( $data ) ) {
			tribe( 'tickets.handler' )->save_order( $post->ID, isset( $data['list'] ) ? $data['list'] : null );
			tribe( 'tickets.handler' )->save_form_settings( $post->ID, isset( $data['settings'] ) ? $data['settings'] : null );
		}

		$return = $this->get_panels( $post );
		$return['notice'] = $this->notice( $notice );

		/**
		 * Allows filtering the data by other plugins/ecommerce solutions©
		 *
		 * @since 4.6
		 *
		 * @param array the return data
		 * @param int the post/event id
		 */
		$return = apply_filters( 'tribe_tickets_ajax_refresh_tables', $return, $post->ID );

		wp_send_json_success( $return );
	}

Top ↑

Changelog

Changelog
Version Description
4.6.2 Introduced.