goryBase && $removeCategoryBase !== $removeCategoryBaseOld ) { aioseo()->options->flushRewriteRules(); } // This is required in order for the Pro options to be refreshed before they save data again. $this->refresh(); } /** * Sanitizes the `emailSummary` option. * * @since 4.7.2 * * @param array $options All options, passed by reference. * @return void */ private function sanitizeEmailSummary( &$options ) { foreach ( ( $options['advanced']['emailSummary']['recipients'] ?? [] ) as $k => &$recipient ) { $recipient['email'] = is_email( $recipient['email'] ); // Remove empty emails. if ( empty( $recipient['email'] ) ) { unset( $options['advanced']['emailSummary']['recipients'][ $k ] ); continue; } // Remove duplicate emails. $emails = array_column( $options['advanced']['emailSummary']['recipients'], 'email' ); $emails = array_count_values( $emails ); if ( $emails[ $recipient['email'] ] > 1 ) { unset( $options['advanced']['emailSummary']['recipients'][ $k ] ); } } } /** * If the user does not have access to unfiltered HTML, we need to remove them from saving. * * @since 4.0.0 * * @param array $options An array of options. * @return array An array of options. */ private function maybeRemoveUnfilteredHtmlFields( $options ) { if ( current_user_can( 'unfiltered_html' ) ) { return $options; } if ( ! empty( $options['webmasterTools'] ) && isset( $options['webmasterTools']['miscellaneousVerification'] ) ) { unset( $options['webmasterTools']['miscellaneousVerification'] ); } if ( ! empty( $options['rssContent'] ) && isset( $options['rssContent']['before'] ) ) { unset( $options['rssContent']['before'] ); } if ( ! empty( $options['rssContent'] ) && isset( $options['rssContent']['after'] ) ) { unset( $options['rssContent']['after'] ); } return $options; } /** * Indicate we need to flush rewrite rules on next load. * * @since 4.0.17 * * @return void */ public function flushRewriteRules() { update_option( 'aioseo_flush_rewrite_rules_flag', true ); } /** * Flush rewrite rules if needed. * * @since 4.0.17 * * @return void */ public function maybeFlushRewriteRules() { if ( get_option( 'aioseo_flush_rewrite_rules_flag' ) ) { flush_rewrite_rules(); delete_option( 'aioseo_flush_rewrite_rules_flag' ); } } }