operators(); return isset( $operators[0] ) ? (string) $operators[0] : ''; } /** * Gets the JSON-schema-like description of the value field for the UI. * * @return array */ public function value_schema(): array { return array(); } /** * Gets the default value for a newly created condition of this type. * * @return mixed */ public function default_value() { return null; } /** * Validates a value against this condition's schema. * * @param mixed $value Value to validate. * @return bool */ public function is_valid_value( $value ): bool { return true; } /** * Normalises a stored list value (or a lone scalar) to a list of strings. * * Non-scalar entries (e.g. a nested array in hand-edited markup) are * dropped rather than cast, so a malformed value never raises an * "Array to string conversion" warning or becomes the literal "Array". * * @param mixed $value Stored value. * @return string[] */ protected function string_list( $value ): array { $items = is_array( $value ) ? $value : array( $value ); return array_values( array_map( 'strval', array_filter( $items, 'is_scalar' ) ) ); } }