'array', 'items' => array( 'type' => 'integer' ), ); } /** * Gets the default value for a newly created condition of this type. * * @return mixed */ public function default_value() { return array(); } /** * Evaluates the condition against the given context. * * @param Context $context Request context value object. * @param string $operator Operator identifier. * @param mixed $value Configured value. * @return bool */ public function evaluate( Context $context, string $operator, $value ): bool { // Scalars only: intval() of a non-empty nested array is 1, which would match post 1. $ids = array_filter( array_map( 'intval', array_filter( is_array( $value ) ? $value : array( $value ), 'is_scalar' ) ) ); if ( 0 === $context->post_id ) { // No singular post context: 'is' cannot match; 'is_not' always holds. return 'is_not' === $operator; } $match = in_array( $context->post_id, $ids, true ); return 'is_not' === $operator ? ! $match : $match; } }