>backup['taxonomies'][ $taxonomy ]['social']['facebook'], [ 'social', 'facebook', 'general', 'taxonomies', $taxonomy ] ); unset( $this->backup['taxonomies'][ $taxonomy ]['social']['facebook'] ); $this->shouldBackup = true; } } } /** * Restores the dynamic Archives options. * * @since 4.1.3 * * @return void */ protected function restoreArchives() { foreach ( $this->archives as $postType ) { // Restore the archives for Search Appearance. if ( ! empty( $this->backup['archives'][ $postType ]['searchAppearance'] ) ) { $this->restoreOptions( $this->backup['archives'][ $postType ]['searchAppearance'], [ 'searchAppearance', 'archives', $postType ] ); unset( $this->backup['archives'][ $postType ]['searchAppearance'] ); $this->shouldBackup = true; } } } /** * Restores the backuped options. * * @since 4.1.3 * * @param array $backupOptions The options to be restored. * @param array $groups The group that the option should be restored. * @return void */ protected function restoreOptions( $backupOptions, $groups ) { $groupPath = $this->options; foreach ( $groups as $group ) { if ( ! isset( $groupPath[ $group ] ) ) { return false; } $groupPath = $groupPath[ $group ]; } $options = aioseo()->dynamicOptions->noConflict(); foreach ( $backupOptions as $setting => $value ) { // Check if the option exists by checking if the type is defined. $type = ! empty( $groupPath[ $setting ]['type'] ) ? $groupPath[ $setting ]['type'] : ''; if ( ! $type ) { continue; } foreach ( $groups as $group ) { $options = $options->$group; } $options->$setting = $value; } } /** * Maybe backup the options if it has disappeared. * * @since 4.1.3 * * @param array $newOptions An array of options to check. * @return void */ public function maybeBackup( $newOptions ) { $this->maybeBackupPostType( $newOptions ); $this->maybeBackupTaxonomy( $newOptions ); $this->maybeBackupArchives( $newOptions ); } /** * Maybe backup the Post Types. * * @since 4.1.3 * * @param array $newOptions An array of options to check. * @return void */ protected function maybeBackupPostType( $newOptions ) { // Maybe backup the post types for Search Appearance. foreach ( $newOptions['searchAppearance']['postTypes'] as $dynamicPostTypeName => $dynamicPostTypeSettings ) { $found = in_array( $dynamicPostTypeName, $this->postTypes, true ); if ( ! $found ) { $this->backup['postTypes'][ $dynamicPostTypeName ]['searchAppearance'] = $dynamicPostTypeSettings; $this->shouldBackup = true; } } // Maybe backup the post types for Social Networks. foreach ( $newOptions['social']['facebook']['general']['postTypes'] as $dynamicPostTypeName => $dynamicPostTypeSettings ) { $found = in_array( $dynamicPostTypeName, $this->postTypes, true ); if ( ! $found ) { $this->backup['postTypes'][ $dynamicPostTypeName ]['social']['facebook'] = $dynamicPostTypeSettings; $this->shouldBackup = true; } } } /** * Maybe backup the Taxonomies. * * @since 4.1.3 * * @param array $newOptions An array of options to check. * @return void */ protected function maybeBackupTaxonomy( $newOptions ) { // Maybe backup the taxonomies for Search Appearance. foreach ( $newOptions['searchAppearance']['taxonomies'] as $dynamicTaxonomyName => $dynamicTaxonomySettings ) { $found = in_array( $dynamicTaxonomyName, $this->taxonomies, true ); if ( ! $found ) { $this->backup['taxonomies'][ $dynamicTaxonomyName ]['searchAppearance'] = $dynamicTaxonomySettings; $this->shouldBackup = true; } } } /** * Maybe backup the Archives. * * @since 4.1.3 * * @param array $newOptions An array of options to check. * @return void */ protected function maybeBackupArchives( $newOptions ) { // Maybe backup the archives for Search Appearance. foreach ( $newOptions['searchAppearance']['archives'] as $archiveName => $archiveSettings ) { $found = in_array( $archiveName, $this->archives, true ); if ( ! $found ) { $this->backup['archives'][ $archiveName ]['searchAppearance'] = $archiveSettings; $this->shouldBackup = true; } } } }