public function matches($expectedvalue) {

        $multiple = $this->field->hasAttribute('multiple');

        // Same implementation as the parent if it is a single select.
        if (!$multiple) {
            $cleanexpectedvalue = trim($expectedvalue);
            $selectedtext = trim($this->get_selected_options());
            $selectedvalue = trim($this->get_selected_options(false));
            if ($cleanexpectedvalue != $selectedvalue && $cleanexpectedvalue != $selectedtext) {
                return false;
            }
            return true;
        }

        // We are dealing with a multi-select.

        // Unescape + trim all options and flip it to have the expected values as keys.
        $expectedoptions = $this->get_unescaped_options($expectedvalue);

        // Get currently selected option's texts.
        $texts = $this->get_selected_options(true);
        $selectedoptiontexts = $this->get_unescaped_options($texts);

        // Get currently selected option's values.
        $values = $this->get_selected_options(false);
        $selectedoptionvalues = $this->get_unescaped_options($values);

        // We check against string-ordered lists of options.
        if ($expectedoptions !== $selectedoptiontexts &&
                $expectedoptions !== $selectedoptionvalues) {
            return false;
        }

        return true;
    }
public function matches($expectedvalue) {

        $multiple = $this->field->hasAttribute('multiple');

        // Same implementation as the parent if it is a single select.
        if (!$multiple) {
            $cleanexpectedvalue = trim($expectedvalue);
            $selectedtext = trim($this->get_selected_options());
            $selectedvalue = trim($this->get_selected_options(false));
            if ($cleanexpectedvalue != $selectedvalue && $cleanexpectedvalue != $selectedtext) {
                return false;
            }
            return true;
        }

        // We are dealing with a multi-select.

        // Unescape + trim all options and flip it to have the expected values as keys.
        $expectedoptions = $this->get_unescaped_options($expectedvalue);

        // Get currently selected option's texts.
        $texts = $this->get_selected_options(true);
        $selectedoptiontexts = $this->get_unescaped_options($texts);

        // Get currently selected option's values.
        $values = $this->get_selected_options(false);
        $selectedoptionvalues = $this->get_unescaped_options($values);

        // We check against string-ordered lists of options.
        if ($expectedoptions !== $selectedoptiontexts &&
                $expectedoptions !== $selectedoptionvalues) {
            return false;
        }

        return true;
    }
public function matches ( $ expectedvalue ) { $ multiple = $ this -> field -> hasAttribute ( 'multiple' ) ; // Same implementation as the parent if it is a single select. if ( ! $ multiple ) { $ cleanexpectedvalue = trim ( $ expectedvalue ) ; $ selectedtext = trim ( $ this -> get_selected_options ( ) ) ; $ selectedvalue = trim ( $ this -> get_selected_options ( false ) ) ; if ( $ cleanexpectedvalue != $ selectedvalue && $ cleanexpectedvalue != $ selectedtext ) { return false ; } return true ; } // We are dealing with a multi-select. // Unescape + trim all options and flip it to have the expected values as keys. $ expectedoptions = $ this -> get_unescaped_options ( $ expectedvalue ) ; // Get currently selected option's texts. $ texts = $ this -> get_selected_options ( true ) ; $ selectedoptiontexts = $ this -> get_unescaped_options ( $ texts ) ; // Get currently selected option's values. $ values = $ this -> get_selected_options ( false ) ; $ selectedoptionvalues = $ this -> get_unescaped_options ( $ values ) ; // We check against string-ordered lists of options. if ( $ expectedoptions !== $ selectedoptiontexts && $ expectedoptions !== $ selectedoptionvalues ) { return false ; } return true ; }
Returns whether the provided argument matches the current value.

@param mixed $expectedvalue
@return bool
Returns whether the provided argument matches the current value .