| @@ -100,17 +100,17 @@ | ||
| 100 | 100 | $response_code = $backoff['response_code']; |
| 101 | 101 | $endpoint_hash = $backoff['endpoint_hash']; |
| 102 | 102 | |
| 103 | 103 | $notice_class = 'notice notice-warning is-dismissible metasync-backoff-notice'; |
| 104 | - $notice_id = 'metasync-backoff-' . esc_attr($endpoint_hash); | |
| 104 | + $notice_id = 'metasync-backoff-' . $endpoint_hash; | |
| 105 | 105 | |
| 106 | 106 | $status_label = $response_code === 429 ? 'Rate Limited' : 'Service Unavailable'; |
| 107 | 107 | $status_icon = '⏸️'; |
| 108 | 108 | |
| 109 | 109 | ?> |
| 110 | - <div id="<?php echo $notice_id; ?>" class="<?php echo esc_attr($notice_class); ?>" data-endpoint-hash="<?php echo esc_attr($endpoint_hash); ?>"> | |
| 110 | + <div id="<?php echo esc_attr($notice_id); ?>" class="<?php echo esc_attr($notice_class); ?>" data-endpoint-hash="<?php echo esc_attr($endpoint_hash); ?>"> | |
| 111 | 111 | <div style="display: flex; align-items: flex-start; gap: 12px; padding: 4px 0;"> |
| 112 | - <div style="font-size: 24px; line-height: 1;"><?php echo $status_icon; ?></div> | |
| 112 | + <div style="font-size: 24px; line-height: 1;"><?php echo esc_html($status_icon); ?></div> | |
| 113 | 113 | <div style="flex: 1;"> |
| 114 | 114 | <p style="margin: 0 0 8px 0; font-weight: 600; font-size: 14px;"> |
| 115 | 115 | <strong>API Backoff Active:</strong> <?php echo esc_html($endpoint); ?> |
| 116 | 116 | </p> |
| @@ -142,8 +142,11 @@ | ||
| 142 | 142 | * |
| 143 | 143 | * @return bool True if on MetaSync admin page. |
| 144 | 144 | */ |
| 145 | 145 | private function is_metasync_admin_page() { |
| 146 | + if ( ! function_exists( 'get_current_screen' ) ) { | |
| 147 | + return false; | |
| 148 | + } | |
| 146 | 149 | $screen = get_current_screen(); |
| 147 | 150 | |
| 148 | 151 | if (!$screen) { |
| 149 | 152 | return false; |
| @@ -150,9 +153,9 @@ | ||
| 150 | 153 | } |
| 151 | 154 | |
| 152 | 155 | // Check if on MetaSync settings page or any page with metasync in the ID |
| 153 | 156 | return strpos($screen->id, 'metasync') !== false || |
| 154 | - (isset($_GET['page']) && strpos($_GET['page'], 'metasync') !== false); | |
| 157 | + (isset($_GET['page']) && strpos($_GET['page'], 'metasync') !== false); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page check to scope notice scripts | |
| 155 | 158 | } |
| 156 | 159 | |
| 157 | 160 | /** |
| 158 | 161 | * Enqueue admin scripts for notice handling |
| @@ -214,15 +217,8 @@ | ||
| 214 | 217 | |
| 215 | 218 | if (empty($endpoint_hash)) { |
| 216 | 219 | wp_send_json_error(['message' => 'Invalid endpoint hash']); |
| 217 | 220 | } |
| 218 | - | |
| 219 | - // Log the dismissal (notice will reappear on page refresh if still active) | |
| 220 | - error_log(sprintf( | |
| 221 | - '[MetaSync API_BACKOFF_NOTICE_DISMISSED] User %d dismissed notice for endpoint: %s', | |
| 222 | - get_current_user_id(), | |
| 223 | - $endpoint_hash | |
| 224 | - )); | |
| 225 | 221 | |
| 226 | 222 | wp_send_json_success(['message' => 'Notice dismissed']); |
| 227 | 223 | } |
| 228 | 224 | |