limit_options = $limit; return $this; } /** * Retrieve the field value(s). * * @return array */ public function get_value() { if ( $this->value === false ) { return array(); } $this->load_options(); if ( ! is_array( $this->value ) ) { $this->value = maybe_unserialize( $this->value ); if ( ! is_array( $this->value ) ) { if ( is_null( $this->value ) ) { return array(); } return array( $this->value ); } } return (array) $this->value; } /** * Returns an array that holds the field data, suitable for JSON representation. * This data will be available in the Underscore template and the Backbone Model. * * @param bool $load Should the value be loaded from the database or use the value from the current instance. * @return array */ public function to_json( $load ) { $field_data = parent::to_json( $load ); $this->load_options(); $field_data = array_merge( $field_data, array( 'limit_options' => $this->limit_options, 'options' => $this->parse_options( $this->options ), ) ); return $field_data; } /** * The Underscore template of this field. */ public function template() { ?> <# if (_.isEmpty(options)) { #> <# } else { #>
<# if (!exceed && !last && counter == limit_options) { #> <# } #> <# }) #>