WP_POSTRECEIVESCOMMENT::load_options()

load_options


Return Return

(void)


Source Source

File: src/integrations/wp/triggers/wp-postreceivescomment.php

	public function load_options() {
		
		Automator()->helpers->recipe->wp->options->load_options = true;

		$all_post_types = Automator()->helpers->recipe->wp->options->all_post_types(
			null,
			'WPPOSTTYPES',
			array(
				'token'        => false,
				'is_ajax'      => true,
				'target_field' => $this->trigger_meta,
				'endpoint'     => 'select_all_post_from_SELECTEDPOSTTYPE',
			)
		);

		// now get regular post types.
		$args = array(
			'public'   => true,
			'_builtin' => true,
		);

		$output         = 'object';
		$operator       = 'and';
		$options        = array();
		$options['- 1'] = __( 'Any post type', 'uncanny-automator' );
		$post_types     = get_post_types( $args, $output, $operator );
		if ( ! empty( $post_types ) ) {
			foreach ( $post_types as $post_type ) {
				$options[ $post_type->name ] = esc_html( $post_type->labels->singular_name );
			}
		}
		$options                   = array_merge( $options, $all_post_types['options'] );
		$all_post_types['options'] = $options;

		$temp = array(
			'options_group' => array(
				$this->trigger_meta => array(
					$all_post_types,
					Automator()->helpers->recipe->field->select_field(
						$this->trigger_meta,
						__( 'Post', 'uncanny-automator' ),
						array(),
						null,
						false,
						false,
						array(
							'POSTTITLE'          => esc_attr__( 'Post title', 'uncanny-automator' ),
							'POSTURL'            => esc_attr__( 'Post URL', 'uncanny-automator' ),
							'POSTAUTHORDN'       => esc_attr__( 'Post author', 'uncanny-automator' ),
							'POSTEXCERPT'        => esc_attr__( 'Post excerpt', 'uncanny-automator' ),
							'POSTCOMMENTCONTENT' => esc_attr__( 'Comment', 'uncanny-automator' ),
							'POSTCOMMENTDATE'    => esc_attr__( 'Comment date', 'uncanny-automator' ),
							'POSTCOMMENTEREMAIL' => esc_attr__( 'Commenter email', 'uncanny-automator' ),
							'POSTCOMMENTERNAME'  => esc_attr__( 'Commenter name', 'uncanny-automator' ),
							'POSTCOMMENTSTATUS'  => esc_attr__( 'Commenter status', 'uncanny-automator' ),
						)
					),
				),
			),
		);

		$temp = Automator()->utilities->keep_order_of_options( $temp );

		return $temp;

	}