Changeset 3765447 for gt-performance/trunk/src/Admin/AdminModule.php
- Timestamp:
- 10/26/2026 02:39:16 AM (3 hours ago)
- File:
-
- 1 edited
-
gt-performance/trunk/src/Admin/AdminModule.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gt-performance/trunk/src/Admin/AdminModule.php
r3750368 r3765447 45 45 use GTPerformance\Redis\ObjectCacheInstaller; 46 46 use GTPerformance\XCloud\EdgeOwnership; 47 use GTPerformance\XCloud\EnterprisePurgeHook; 48 use GTPerformance\XCloud\EnterprisePurgeModule; 47 49 use GTPerformance\XCloud\SiteService; 48 50 … … 750 752 $settings = Settings::all(); 751 753 $before = $settings; 754 if ( ( new EdgeOwnership() )->enterprisePurgeHookActive() ) { 755 $this->redirect( 'gtperf_edge_owner_xcloud_hook', 'cloudflare' ); 756 } 752 757 if ( ( new EdgeOwnership() )->xcloudOwnsEdge() ) { 753 758 $this->redirect( 'gtperf_edge_owner_conflict', 'cloudflare' ); … … 1566 1571 ); 1567 1572 } 1573 if ( ( new EdgeOwnership() )->enterprisePurgeHookActive() ) { 1574 printf( 1575 '<div class="notice notice-info inline"><p>%s</p></div>', 1576 esc_html__( 'xCloud Cloudflare Enterprise serves this site: its automatic cache purge plugin is installed. GT Performance purges through xCloud, so this direct Cloudflare integration is paused and makes no API calls. Its settings are kept, and it resumes if the xCloud plugin is removed.', 'gt-performance' ) 1577 ); 1578 } 1568 1579 $this->settingsFormOpen(); 1569 1580 $this->panelOpen( __( 'Connection', 'gt-performance' ), __( 'A scoped token is safer. Global API Key authentication remains available for legacy accounts.', 'gt-performance' ) ); … … 1962 1973 1963 1974 $this->settingsFormClose(); 1964 if ( ! empty( $settings['xcloud']['enabled'] ) ) {1975 if ( ! empty( $settings['xcloud']['enabled'] ) || ( new EnterprisePurgeHook() )->installed() ) { 1965 1976 $this->renderXcloudStatus( $settings ); 1966 1977 } … … 2044 2055 $purge = is_array( $purge ) ? $purge : array(); 2045 2056 $conflict = ( new EdgeOwnership() )->hasDirectCloudflareConflict(); 2057 $hook = new EnterprisePurgeHook(); 2058 $hookOn = $hook->available(); 2059 $edge = get_option( EnterprisePurgeModule::STATUS_OPTION, array() ); 2060 $edge = is_array( $edge ) ? $edge : array(); 2061 $enterprise = ! empty( $xcloud['enterprise_available'] ) || $hookOn; 2062 if ( $hookOn ) { 2063 $hookState = __( 'Automatic, through xCloud\'s cache purge plugin', 'gt-performance' ); 2064 } elseif ( $hook->installed() ) { 2065 $hookState = __( 'xCloud\'s plugin is installed but has no usable purge token', 'gt-performance' ); 2066 } else { 2067 $hookState = __( 'Manual: xCloud\'s automatic cache purge is not installed', 'gt-performance' ); 2068 } 2069 $lastEdge = __( 'Never', 'gt-performance' ); 2070 if ( isset( $edge['created_at'] ) ) { 2071 $lastEdge = (string) $edge['created_at'] . ' (' . (string) ( $edge['status'] ?? '' ) . ')'; 2072 if ( ! empty( $edge['origin_only'] ) ) { 2073 $lastEdge .= '; ' . sprintf( 2074 /* translators: %s: number of pages. */ 2075 _n( '%s listing page cleared at the origin only', '%s listing pages cleared at the origin only', (int) $edge['origin_only'], 'gt-performance' ), 2076 number_format_i18n( (int) $edge['origin_only'] ) 2077 ); 2078 } 2079 } 2046 2080 ?> 2047 2081 <section class="gtp-panel"> … … 2049 2083 <div> 2050 2084 <h3><?php esc_html_e( 'xCloud cache status', 'gt-performance' ); ?></h3> 2051 <p><?php esc_html_e( 'Status is refreshed only on request. Enterprise settings and purge remain owned by the xCloud dashboard; GT Performance detects and reports the add-on.', 'gt-performance' ); ?></p>2085 <p><?php esc_html_e( 'Status is refreshed only on request. Enterprise settings stay in the xCloud dashboard. When xCloud\'s automatic cache purge plugin is installed, GT Performance purges Cloudflare Enterprise through it.', 'gt-performance' ); ?></p> 2052 2086 </div> 2053 2087 </div> … … 2058 2092 <div><dt><?php esc_html_e( 'Redis', 'gt-performance' ); ?></dt><dd><?php echo esc_html( ! empty( $xcloud['redis_enabled'] ) ? __( 'Enabled', 'gt-performance' ) : __( 'Disabled', 'gt-performance' ) ); ?></dd></div> 2059 2093 <div><dt><?php esc_html_e( 'Object Cache Pro', 'gt-performance' ); ?></dt><dd><?php echo esc_html( ! empty( $xcloud['object_cache_pro'] ) ? __( 'Enabled', 'gt-performance' ) : __( 'Disabled', 'gt-performance' ) ); ?></dd></div> 2060 <div><dt><?php esc_html_e( 'Cloudflare Enterprise', 'gt-performance' ); ?></dt><dd><?php echo esc_html( ! empty( $xcloud['enterprise_available'] ) ? __( 'Active through xCloud', 'gt-performance' ) : __( 'Not detected', 'gt-performance' ) ); ?></dd></div> 2094 <div><dt><?php esc_html_e( 'Cloudflare Enterprise', 'gt-performance' ); ?></dt><dd><?php echo esc_html( $enterprise ? __( 'Active through xCloud', 'gt-performance' ) : __( 'Not detected', 'gt-performance' ) ); ?></dd></div> 2095 <div><dt><?php esc_html_e( 'Enterprise purge', 'gt-performance' ); ?></dt><dd><?php echo esc_html( $hookState ); ?></dd></div> 2096 <div><dt><?php esc_html_e( 'Last Enterprise purge', 'gt-performance' ); ?></dt><dd><?php echo esc_html( $lastEdge ); ?></dd></div> 2061 2097 <div><dt><?php esc_html_e( 'Enterprise edge traffic (12h)', 'gt-performance' ); ?></dt><dd><?php echo esc_html( number_format_i18n( (int) ( $xcloud['enterprise_edge_requests'] ?? 0 ) ) . ' / ' . number_format_i18n( (int) ( $xcloud['enterprise_requests'] ?? 0 ) ) . ' (' . number_format_i18n( (float) ( $xcloud['enterprise_hit_percent'] ?? 0 ), 1 ) . '%)' ); ?></dd></div> 2062 2098 <div><dt><?php esc_html_e( 'Free xCloud edge cache', 'gt-performance' ); ?></dt><dd><?php echo esc_html( ! empty( $xcloud['free_edge_cache_enabled'] ) ? __( 'Enabled', 'gt-performance' ) : __( 'Disabled', 'gt-performance' ) ); ?></dd></div> … … 2064 2100 <div><dt><?php esc_html_e( 'Last xCloud purge', 'gt-performance' ); ?></dt><dd><?php echo esc_html( (string) ( $purge['created_at'] ?? __( 'Never', 'gt-performance' ) ) ); ?></dd></div> 2065 2101 </dl> 2066 <?php if ( $conflict || ! empty( $xcloud['enterprise_available'] )) : ?>2102 <?php if ( $conflict || $enterprise ) : ?> 2067 2103 <div class="gtp-guidance-list"> 2068 2104 <?php if ( $conflict ) : ?> … … 2072 2108 </div> 2073 2109 <?php endif; ?> 2074 <?php if ( ! empty( $xcloud['enterprise_available'] ) ) : ?> 2110 <?php if ( $hookOn ) : ?> 2111 <div class="gtp-callout gtp-callout--info" role="note"> 2112 <strong><?php esc_html_e( 'Enterprise purge is automatic', 'gt-performance' ); ?></strong> 2113 <p><?php esc_html_e( 'Every GT Performance purge also clears Cloudflare Enterprise through xCloud: post saves and their related pages, the Purge button, scheduled purges, and WP-CLI. Direct Cloudflare is paused, because xCloud serves this site from its own Cloudflare zone.', 'gt-performance' ); ?></p> 2114 </div> 2115 <?php endif; ?> 2116 <?php if ( $enterprise && ! $hookOn ) : ?> 2075 2117 <div class="gtp-callout gtp-callout--warning" role="note"> 2076 2118 <strong><?php esc_html_e( 'Enterprise purge remains manual', 'gt-performance' ); ?></strong> 2077 <p><?php esc_html_e( ' Enterprise analytics are available through the API token, but its purge action currently requires an xCloud dashboard session. Automatic Enterprise purge is intentionally disabled until xCloud publishes a token-authenticated endpoint.', 'gt-performance' ); ?></p>2119 <p><?php esc_html_e( 'xCloud\'s Public API does not expose an Enterprise purge. Install automatic cache purge from the site\'s Cloudflare Enterprise page in xCloud, and GT Performance will purge through it. Until then, purge from the xCloud dashboard.', 'gt-performance' ); ?></p> 2078 2120 </div> 2121 <?php endif; ?> 2122 <?php if ( $enterprise ) : ?> 2079 2123 <div class="gtp-callout gtp-callout--danger" role="note"> 2080 2124 <strong><?php esc_html_e( 'Keep commerce HTML out of edge cache', 'gt-performance' ); ?></strong> … … 4119 4163 'gtperf_xcloud_json' => array( __( 'xCloud returned an unreadable response. Try again in a moment.', 'gt-performance' ), 'error' ), 4120 4164 'gtperf_xcloud_api' => array( __( 'xCloud rejected the request. Check the token scopes and team permissions.', 'gt-performance' ), 'error' ), 4121 'gtperf_xcloud_enterprise_purge_unavailable' => array( __( 'Cloudflare Enterprise purge is not available through the xCloud Public API token. Use the Purge control in the xCloud Enterprise dashboard.', 'gt-performance' ), 'warning' ), 4165 'gtperf_xcloud_enterprise_purge_unavailable' => array( __( 'Cloudflare Enterprise purge is not available through the xCloud Public API token. Install automatic cache purge from the site\'s Cloudflare Enterprise page in xCloud, or use the Purge control in the xCloud dashboard.', 'gt-performance' ), 'warning' ), 4166 'gtperf_edge_owner_xcloud_hook' => array( __( 'xCloud Cloudflare Enterprise serves this site, so direct Cloudflare is paused and no cache rule was synchronized. GT Performance purges through xCloud\'s automatic cache purge plugin instead.', 'gt-performance' ), 'info' ), 4122 4167 'gtperf_edge_owner_conflict' => array( __( 'xCloud Cloudflare Enterprise is the active owner. Disable it or the direct Cloudflare integration before synchronizing another cache rule.', 'gt-performance' ), 'warning' ), 4123 4168 'xcloud-connected' => array( __( 'xCloud site, host cache, and Cloudflare Enterprise status refreshed.', 'gt-performance' ), 'success' ),
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)