protected function loadFieldValues()
    {
        // TODO: Move to else statement on a higher version
        // Load serialized fields values
        $meta = get_post_meta($this->ID, $this->fieldsMetaID, true);

        if( is_array($meta) ) {
            foreach( $this->fields->toArray() as $name => $field ) {
                $fieldName = sanitize_title($name);
                if( isset( $meta[$fieldName] ) ) {
                    $this->fields($name)->setValue($meta[$fieldName]);
                }
            }
        }

        if( true !== $this->serializeDataStorage ) {
            foreach( $this->fields->toArray() as $id => $field ) {
                $fieldID    = $this->fieldsPrefix . sanitize_title($id);
                $fieldName  = sanitize_title($id);
                $fieldValue = get_post_meta($this->ID, $fieldID, true); // Supports switching serializedDataStorage value
                $fieldValue = ( empty( $fieldValue ) ? ( isset( $meta[$fieldName] ) ? $meta[$fieldName] : '' ) : $fieldValue );
                $this->fields($id)->setValue($fieldValue);
            }
        }

        return $this;
    }
protected function loadFieldValues()
    {
        // TODO: Move to else statement on a higher version
        // Load serialized fields values
        $meta = get_post_meta($this->ID, $this->fieldsMetaID, true);

        if( is_array($meta) ) {
            foreach( $this->fields->toArray() as $name => $field ) {
                $fieldName = sanitize_title($name);
                if( isset( $meta[$fieldName] ) ) {
                    $this->fields($name)->setValue($meta[$fieldName]);
                }
            }
        }

        if( true !== $this->serializeDataStorage ) {
            foreach( $this->fields->toArray() as $id => $field ) {
                $fieldID    = $this->fieldsPrefix . sanitize_title($id);
                $fieldName  = sanitize_title($id);
                $fieldValue = get_post_meta($this->ID, $fieldID, true); // Supports switching serializedDataStorage value
                $fieldValue = ( empty( $fieldValue ) ? ( isset( $meta[$fieldName] ) ? $meta[$fieldName] : '' ) : $fieldValue );
                $this->fields($id)->setValue($fieldValue);
            }
        }

        return $this;
    }
protected function loadFieldValues ( ) { // TODO: Move to else statement on a higher version // Load serialized fields values $ meta = get_post_meta ( $ this -> ID , $ this -> fieldsMetaID , true ) ; if ( is_array ( $ meta ) ) { foreach ( $ this -> fields -> toArray ( ) as $ name => $ field ) { $ fieldName = sanitize_title ( $ name ) ; if ( isset ( $ meta [ $ fieldName ] ) ) { $ this -> fields ( $ name ) -> setValue ( $ meta [ $ fieldName ] ) ; } } } if ( true !== $ this -> serializeDataStorage ) { foreach ( $ this -> fields -> toArray ( ) as $ id => $ field ) { $ fieldID = $ this -> fieldsPrefix . sanitize_title ( $ id ) ; $ fieldName = sanitize_title ( $ id ) ; $ fieldValue = get_post_meta ( $ this -> ID , $ fieldID , true ) ; // Supports switching serializedDataStorage value $ fieldValue = ( empty ( $ fieldValue ) ? ( isset ( $ meta [ $ fieldName ] ) ? $ meta [ $ fieldName ] : '' ) : $ fieldValue ) ; $ this -> fields ( $ id ) -> setValue ( $ fieldValue ) ; } } return $ this ; }
Load on constructor
Load on constructor