Wp_Helpers::all_posts( string $label = null, string $option_code = 'WPPOST',  $any_option = true )


Parameters Parameters

$label

(string) (Optional)

Default value: null

$option_code

(string) (Optional)

Default value: 'WPPOST'


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/wp/helpers/wp-helpers.php

	public function all_posts( $label = null, $option_code = 'WPPOST', $any_option = true ) {
		if ( ! $this->load_options ) {


			return Automator()->helpers->recipe->build_default_options_array( $label, $option_code );
		}

		if ( ! $label ) {
			/* translators: Noun */
			$label = esc_attr__( 'Post', 'uncanny-automator' );
		}

		$args = array(
			'posts_per_page' => 999,
			'orderby'        => 'title',
			'order'          => 'DESC',
			'post_type'      => 'post',
			'post_status'    => 'publish',
		);


		$all_posts = Automator()->helpers->recipe->options->wp_query( $args, $any_option, esc_attr__( 'Any post', 'uncanny-automator' ) );

		$option = array(
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'options'         => $all_posts,
			'relevant_tokens' => array(
				$option_code          => esc_attr__( 'Post title', 'uncanny-automator' ),
				$option_code . '_ID'  => esc_attr__( 'Post ID', 'uncanny-automator' ),
				$option_code . '_URL' => esc_attr__( 'Post URL', 'uncanny-automator' ),
			),
		);

		return apply_filters( 'uap_option_all_posts', $option );
	}