getAsArray( $_baOptions ); if ( ! isset( $_aOptions[ 'unit_default' ] ) ) { // If the subject key is not set, do nothing. return; } // At this point, the user has already saved the options. $_sItemFormat = $this->getElement( $_aOptions, array( 'unit_default', 'item_format' ), '' ); $_aLegacyItemFormats = $this->___getLegacyDefaultItemFormats(); foreach( $_aLegacyItemFormats as $_iIndex => $_sThisItemFormat ) { // Remove line feeds as Windows and Unix handles PHP_EOL differently. $_sThisItemFormat = str_replace( array( "\r", "\n", ), '', $_sThisItemFormat ); $_sItemFormat = str_replace( array( "\r", "\n", ), '', $_sItemFormat ); if ( $_sThisItemFormat !== $_sItemFormat ) { continue; } // If they equal each other, update the option $_aOptions[ 'unit_default' ][ 'item_format' ] = $this->___getNewItemFormat( $_iIndex ); } update_option( AmazonAutoLinks_Registry::$aOptionKeys[ 'main' ], $_aOptions ); } /** * @param string $sOldItemFormat * @param integer $iIndex * @return string */ private function ___getNewItemFormat( $iIndex ) { $_oOption = AmazonAutoLinks_Option::getInstance(); if ( 1 === $iIndex ) { return $_oOption->getDefaultItemFormatConnected(); } return $_oOption->getDefaultItemFormatDisconnected(); } /** * @return array */ private function ___getLegacyDefaultItemFormats() { return array( '%image%' . PHP_EOL . '%image_set%' . PHP_EOL . '%rating%' . PHP_EOL . '%title%' . PHP_EOL . '%description%' . PHP_EOL . '%disclaimer%', // 3.2.0+ '%image%' . PHP_EOL // since the . '%title%' . PHP_EOL . '%description%' . PHP_EOL . '%disclaimer%' // 3.2.0+ ); } }