Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_Conditions::generate_post_type_conditions()


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Return Return

(array)


Top ↑

Source Source

File: classes/Conditions.php

	public function generate_post_type_conditions() {
		$conditions = array();
		$post_types = get_post_types( array( 'public' => true ), 'objects' );

		foreach ( $post_types as $name => $post_type ) {

			if ( $name == 'popup' || $name == 'popup_theme' ) {
				continue;
			}

			if ( $post_type->has_archive ) {
				$conditions[ $name . '_index' ] = array(
					'group'    => $post_type->labels->name,
					'name'     => sprintf( _x( '%s Archive', 'condition: post type plural label ie. Posts: All', 'popup-maker' ), $post_type->labels->name ),
					'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
					'priority' => 5,
				);
			}

			$conditions[ $name . '_all' ] = array(
				'group'    => $post_type->labels->name,
				'name'     => sprintf( _x( 'All %s', 'condition: post type plural label ie. Posts: All', 'popup-maker' ), $post_type->labels->name ),
				'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
			);

			$conditions[ $name . '_selected' ] = array(
				'group'    => $post_type->labels->name,
				'name'     => sprintf( _x( '%s: Selected', 'condition: post type plural label ie. Posts: Selected', 'popup-maker' ), $post_type->labels->name ),
				'fields'   => array(
					'selected' => array(
						'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
						'type'        => 'postselect',
						'post_type'   => $name,
						'multiple'    => true,
						'as_array'    => true,
						'std'         => array(),
					),
				),
				'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
			);

			$conditions[ $name . '_ID' ] = array(
				'group'    => $post_type->labels->name,
				'name'     => sprintf( _x( '%s: ID', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
				'fields'   => array(
					'selected' => array(
						'placeholder' => sprintf( _x( '%s IDs: 128, 129', 'condition: post type singular label ie. Posts IDs', 'popup-maker' ), strtolower( $post_type->labels->singular_name ) ),
						'type'        => 'text',
					),
				),
				'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
			);

			if ( is_post_type_hierarchical( $name ) ) {
				$conditions[ $name . '_children' ] = array(
					'group'    => $post_type->labels->name,
					'name'     => sprintf( _x( '%s: Child Of', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
					'fields'   => array(
						'selected' => array(
							'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
							'type'        => 'postselect',
							'post_type'   => $name,
							'multiple'    => true,
							'as_array'    => true,
						),
					),
					'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
				);

				$conditions[ $name . '_ancestors' ] = array(
					'group'    => $post_type->labels->name,
					'name'     => sprintf( _x( '%s: Ancestor Of', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
					'fields'   => array(
						'selected' => array(
							'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
							'type'        => 'postselect',
							'post_type'   => $name,
							'multiple'    => true,
							'as_array'    => true,
						),
					),
					'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
				);

			}


			$templates = wp_get_theme()->get_page_templates();

			if ( $name == 'page' && ! empty( $templates ) ) {
				$conditions[ $name . '_template' ] = array(
					'group'    => $post_type->labels->name,
					'name'     => sprintf( _x( '%s: With Template', 'condition: post type plural label ie. Pages: With Template', 'popup-maker' ), $post_type->labels->name ),
					'fields'   => array(
						'selected' => array(
							'type'     => 'select',
							'select2'  => true,
							'multiple' => true,
							'as_array' => true,
							'options'  => array_merge( array( 'default' => __( 'Default', 'popup-maker' ) ), $templates ),
						),
					),
					'callback' => array( 'PUM_ConditionCallbacks', 'post_type' ),
				);
			}

			$conditions = array_merge( $conditions, $this->generate_post_type_tax_conditions( $name ) );

		}

		return $conditions;
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.