403 ) ); } check_admin_referer( self::ACTION ); self::rebuild_and_record( self::built_for() ); $back = wp_get_referer(); wp_safe_redirect( $back ? $back : admin_url() ); exit; } private static function rebuild_and_record( $was ) { $parts = self::rebuild(); $now = self::home(); update_option( self::OPTION, $now, false ); set_transient( self::NOTICE . '_' . get_current_user_id(), array( 'from' => (string) $was, 'to' => $now, 'parts' => $parts ), DAY_IN_SECONDS ); } public static function rebuild() { $done = array(); if ( class_exists( 'AIEO_Engine_Mega_Menu' ) && method_exists( 'AIEO_Engine_Mega_Menu', 'regenerate' ) ) { AIEO_Engine_Mega_Menu::regenerate(); $done[] = 'menu'; } if ( class_exists( 'AIEO_SEO_Sitemap' ) && method_exists( 'AIEO_SEO_Sitemap', 'build' ) ) { AIEO_SEO_Sitemap::build(); $done[] = 'sitemaps'; } if ( has_action( 'aieo_navigator_generate_json' ) ) { do_action( 'aieo_navigator_generate_json' ); $done[] = 'navigator'; } if ( class_exists( 'Rooster\Core\UsedCss' ) && method_exists( 'Rooster\Core\UsedCss', 'clear' ) ) { \Rooster\Core\UsedCss::clear(); $done[] = 'used_css'; } if ( function_exists( 'rooster_purge_fastcgi_cache' ) ) { rooster_purge_fastcgi_cache(); $done[] = 'page_cache'; } if ( class_exists( '\CF\WordPress\Hooks' ) ) { try { ( new \CF\WordPress\Hooks() )->purgeCacheEverything(); $done[] = 'cloudflare'; } catch ( \Throwable $e ) { unset( $e ); } } do_action( 'aieo_site_address_rebuilt', $done ); return $done; } public static function part_names() { return array( 'menu' => __( 'the mega menu', 'ai-eshop-optimizer' ), 'sitemaps' => __( 'the sitemaps', 'ai-eshop-optimizer' ), 'navigator' => __( 'the admin search', 'ai-eshop-optimizer' ), 'used_css' => __( "the theme's page styles", 'ai-eshop-optimizer' ), 'page_cache' => __( 'the page cache', 'ai-eshop-optimizer' ), 'cloudflare' => __( "Cloudflare's cache", 'ai-eshop-optimizer' ), ); } public static function notice() { $key = self::NOTICE . '_' . get_current_user_id(); $last = get_transient( $key ); if ( ! is_array( $last ) ) { return; } delete_transient( $key ); $names = self::part_names(); $parts = array_values( array_filter( array_map( static fn ( $p ) => $names[ $p ] ?? '', (array) ( $last['parts'] ?? array() ) ) ) ); $list = $parts ? wp_sprintf_l( '%l', $parts ) : __( 'nothing (none of them is in use here)', 'ai-eshop-optimizer' ); if ( '' !== (string) $last['from'] && (string) $last['from'] !== (string) $last['to'] ) { $text = sprintf( __( 'The site moved from %1$s to %2$s. Rooster One rebuilt what it makes from the address and emptied the caches: %3$s.', 'ai-eshop-optimizer' ), (string) $last['from'], (string) $last['to'], $list ); } else { $text = sprintf( __( 'Rooster One rebuilt what it makes from the address and emptied the caches: %s.', 'ai-eshop-optimizer' ), $list ); } echo '

' . esc_html( $text ) . '

'; } }