$path ) { if ( array_key_exists( $flatKey, $legacy ) ) { $options = $this->setPath( $options, $path, $legacy[ $flatKey ] ); } } $internal = []; foreach ( SettingsMap::INTERNAL as $flatKey => $path ) { if ( array_key_exists( $flatKey, $legacy ) ) { $internal = $this->setPath( $internal, $path, $legacy[ $flatKey ] ); } } $redundant = get_option( self::LEGACY_REDUNDANT_OPTION, [] ); if ( ! empty( $redundant ) && is_array( $redundant ) ) { $internal = $this->setPath( $internal, 'internal.redundantAddons', $redundant ); } if ( ! empty( $options ) ) { aioseo404To301()->options->sanitizeAndSave( $options ); } if ( ! empty( $internal ) ) { aioseo404To301()->internalOptions->sanitizeAndSave( $internal ); } } aioseo404To301()->internalOptions->sanitizeAndSave( [ 'internal' => [ 'settingsMigrated' => true ] ] ); } /** * Whether the flat option has already been folded in. * * @since 4.0.4 * * @return bool */ public function verify() { return (bool) aioseo404To301()->internalOptions->internal->settingsMigrated; } /** * Writes a value into a nested array at a dot-delimited path. * * @since 4.0.4 * * @param array $target The array to write into. * @param string $path Dot-delimited path. * @param mixed $value The value to set. * @return array The array with the value set. */ private function setPath( $target, $path, $value ) { $keys = explode( '.', $path ); $pointer = &$target; foreach ( $keys as $key ) { if ( ! isset( $pointer[ $key ] ) || ! is_array( $pointer[ $key ] ) ) { $pointer[ $key ] = []; } $pointer = &$pointer[ $key ]; } $pointer = $value; return $target; } }