ACF_Location_Post_Status{}ACF 1.0

Хуков нет.

Использование

$ACF_Location_Post_Status = new ACF_Location_Post_Status();
// use class methods

Методы

  1. public get_values( $rule )
  2. public initialize()
  3. public match( $rule, $screen, $field_group )

Код ACF_Location_Post_Status{} ACF 6.0.4

class ACF_Location_Post_Status extends ACF_Location {

	/**
	 * Initializes props.
	 *
	 * @date    5/03/2014
	 * @since   5.0.0
	 *
	 * @param   void
	 * @return  void
	 */
	public function initialize() {
		$this->name        = 'post_status';
		$this->label       = __( 'Post Status', 'acf' );
		$this->category    = 'post';
		$this->object_type = 'post';
	}

	/**
	 * Matches the provided rule against the screen args returning a bool result.
	 *
	 * @date    9/4/20
	 * @since   5.9.0
	 *
	 * @param   array $rule The location rule.
	 * @param   array $screen The screen args.
	 * @param   array $field_group The field group settings.
	 * @return  bool
	 */
	public function match( $rule, $screen, $field_group ) {

		// Check screen args.
		if ( isset( $screen['post_status'] ) ) {
			$post_status = $screen['post_status'];
		} elseif ( isset( $screen['post_id'] ) ) {
			$post_status = get_post_status( $screen['post_id'] );
		} else {
			return false;
		}

		 // Treat "auto-draft" as "draft".
		if ( $post_status === 'auto-draft' ) {
			$post_status = 'draft';
		}

		// Compare rule against $post_status.
		return $this->compare_to_rule( $post_status, $rule );
	}

	/**
	 * Returns an array of possible values for this rule type.
	 *
	 * @date    9/4/20
	 * @since   5.9.0
	 *
	 * @param   array $rule A location rule.
	 * @return  array
	 */
	public function get_values( $rule ) {
		global $wp_post_statuses;

		// Append to choices.
		$choices = array();
		if ( $wp_post_statuses ) {
			foreach ( $wp_post_statuses as $status ) {
				$choices[ $status->name ] = $status->label;
			}
		}
		return $choices;
	}
}