ANON_WP_VIEWPOSTTYPE::define_trigger()


Source Source

File: src/integrations/wp/triggers/anon-wp-viewposttype.php

	public function define_trigger() {
		$trigger = array(
			'author'              => Automator()->get_author_name( $this->trigger_code ),
			'support_link'        => Automator()->get_author_support_link( $this->trigger_code, 'integration/wordpress-core/' ),
			'integration'         => self::$integration,
			'code'                => $this->trigger_code,
			/* translators: Logged-in trigger - WordPress */
			'sentence'            => sprintf( esc_attr__( 'A {{specific type of post:%1$s}} is viewed', 'uncanny-automator' ), $this->trigger_meta ),
			/* translators: Logged-in trigger - WordPress */
			'select_option_name'  => esc_attr__( 'A {{specific type of post}} is viewed', 'uncanny-automator' ),
			'action'              => 'template_redirect',
			'priority'            => 90,
			'accepted_args'       => 1,
			'type'                => 'anonymous',
			'validation_function' => array( $this, 'view_post_type' ),
			// very last call in WP, we need to make sure they viewed the post and didn't skip before is was fully viewable
			'options'             => [
				Automator()->helpers->recipe->wp->options->all_wp_post_types( null, $this->trigger_meta,
					array(
						'relevant_tokens' => array(
							'WPPOST'      => __( 'Post title', 'uncanny-automator' ),
							'WPPOST_ID'   => __( 'Post ID', 'uncanny-automator' ),
							'WPPOST_URL'  => __( 'Post URL', 'uncanny-automator' ),
							'WPPOSTTYPES' => __( 'Post type', 'uncanny-automator' ),
						)
					) ),
			],
		);

		Automator()->register->trigger( $trigger );

		return;
	}