Tribe__Events__Pro__Editor__Recurrence__Provider::trigger_recurrence_rules( $result,  $server,  $request )

Hook before the response of a endpoint is executed to maybe trigger the recurrence rules, in order to execute a recurrence rule it must follow the following:

  • if $request is valid
  • and has an ID that is of type Events
  • and is part of the valid methods that are used to update / create a new item (PUT/POST)
  • and is not part of an /autosaves request as shouldn’t be trigger on auto saves

The hook does not modify the original response so the response is returned without any modifications on it


Parameters

$result

(Required)

$server

(Required)

$request

(Required)


Top ↑

Return

(mixed)


Top ↑

Source

File: src/Tribe/Editor/Recurrence/Provider.php

	public function trigger_recurrence_rules( $result, $server, $request ) {
		$valid_methods = array( 'POST', 'PUT', 'PATCH' );

		if (
			$request instanceof WP_REST_Request
			&& get_post_type( $request->get_param( 'id' ) ) === Tribe__Events__Main::POSTTYPE
			&& in_array( $request->get_method(), $valid_methods )
			&& false === strpos(   $request->get_route(), '/autosaves' )
		) {
			$this->to_classic_format( $request->get_param( 'id' ) );
		}
		return $result;
	}

Top ↑

Changelog

Changelog
Version Description
4.5 Introduced.