From 68f7f6871ceabd0645d46d95378fe4cedc750a88 Mon Sep 17 00:00:00 2001
From: wpdev
Date: Fri, 31 Jul 2026 05:27:57 +0800
Subject: [PATCH] =?UTF-8?q?fix(admin):=2013=20=E5=80=8B=E7=A0=B4=E5=A3=9E?=
=?UTF-8?q?=E6=80=A7=E5=8B=95=E4=BD=9C=E7=94=B1=20GET=20=E6=94=B9=20POST?=
=?UTF-8?q?=20+=20nonce=EF=BC=88A1-A4=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
nonce 走 query string 會經 Referer 外洩,且 GET 觸發的破壞性動作(刪快照、
cutover、promote aeav_only、清 postmeta)可被 prefetch/爬蟲觸發。對應 A v3.3.1 P1-6。
Handler 端(admin/class-tmdo-admin.php:300-700):13 個動作與其附屬參數
(post_type / count / mode / samples)全部改讀 $_POST。唯讀的 tab /
classify_type / wpdo_msg / wpdo_module 維持 GET。
渲染端改為
@@ -2849,15 +2839,17 @@ wpdo.getListings({ per_page: 3 }).then(r => console.log(r));'
-
-
-
-
-
-
+
+
@@ -2887,11 +2879,12 @@ wpdo.getListings({ per_page: 3 }).then(r => console.log(r));'
|
|
-
-
-
+
|
@@ -3109,10 +3102,6 @@ wpdo.getListings({ per_page: 3 }).then(r => console.log(r));'
$conf = (float) $r['confidence'];
$bar_w = (int) round( $conf * 100 );
$color = $conf >= 0.7 ? '#46b450' : ( $conf >= 0.5 ? '#dba617' : '#c3c4c7' );
- $enable_url = wp_nonce_url(
- add_query_arg( 'wpdo_enable_module', $module, admin_url( 'tools.php?page=' . self::MENU_SLUG ) ),
- 'wpdo_enable_module'
- );
printf(
'%s | | ',
esc_html( $module ),
@@ -3129,12 +3118,15 @@ wpdo.getListings({ per_page: 3 }).then(r => console.log(r));'
}
echo '';
printf( '%s | ', esc_html( (string) $r['current_state'] ) );
+ echo ' | ';
echo '
';
}
echo '
';
diff --git a/admin/class-tmdo-dashboard-widget.php b/admin/class-tmdo-dashboard-widget.php
index d16ebaf..577199a 100644
--- a/admin/class-tmdo-dashboard-widget.php
+++ b/admin/class-tmdo-dashboard-widget.php
@@ -59,9 +59,7 @@ class TMDO_Dashboard_Widget {
*/
public static function render(): void {
$page_url = admin_url( 'tools.php?page=wp-data-optimizer' );
- $run_health_url = wp_nonce_url( add_query_arg( array( 'wpdo_run_health' => '1' ), $page_url ), 'wpdo_run_health' );
- $create_snap_url = wp_nonce_url( add_query_arg( array( 'wpdo_create_snapshot' => '1' ), $page_url ), 'wpdo_create_snapshot' );
- $bridge_url = add_query_arg( 'tab', 'entity-bridge', $page_url );
+ $bridge_url = add_query_arg( 'tab', 'entity-bridge', $page_url );
$status = self::compute_status();
$light = self::traffic_light( $status['level'] );
@@ -188,10 +186,6 @@ class TMDO_Dashboard_Widget {
? TMDO_Postmeta_Cleaner::count_garbage( TMDO_Postmeta_Cleaner::TARGET_ALL )
: array( 'total' => 0 );
if ( ! empty( $gc['total'] ) && (int) $gc['total'] > 0 ) :
- $cleanup_url = wp_nonce_url(
- add_query_arg( array( 'wpdo_postmeta_cleanup' => '1' ), $page_url ),
- 'wpdo_postmeta_cleanup'
- );
$confirm_msg = sprintf(
/* translators: %s: total garbage row count */
esc_html__( '即將從 wp_postmeta 刪除 %s 行垃圾資料(transients + _wp_old_date + 過期 _edit_lock)。確認執行?', '2meet-data-optimizer' ),
@@ -211,10 +205,14 @@ class TMDO_Dashboard_Widget {
esc_html( number_format_i18n( (int) $gc['edit_locks'] ) )
);
?>
-
-
-
+
@@ -275,15 +273,19 @@ class TMDO_Dashboard_Widget {
@@ -246,10 +228,14 @@ $wpdo_format_msg = static function ( string $code ): string {
@@ -257,10 +243,14 @@ $wpdo_format_msg = static function ( string $code ): string {
@@ -268,10 +258,14 @@ $wpdo_format_msg = static function ( string $code ): string {
@@ -279,10 +273,14 @@ $wpdo_format_msg = static function ( string $code ): string {
diff --git a/admin/templates/post-stress-test.php b/admin/templates/post-stress-test.php
index 1ef71be..f61206a 100644
--- a/admin/templates/post-stress-test.php
+++ b/admin/templates/post-stress-test.php
@@ -7,8 +7,7 @@
* 2. 即時進度(progress bar + processed/target/rate/ETA/peak memory)
* 3. Benchmark 報告(write metrics + DB sizes + query performance)
*
- * Backward-compat: legacy GET ?wpdo_post_stress_create / cleanup / bench
- * handlers in admin still work for bookmarked URLs; the new UI uses REST.
+ * The UI uses REST/AJAX exclusively; legacy admin action handlers now require POST.
*
* Variables in scope from render_post_stress_test():
* $test_post_count — int, posts matching TMDO_STRESS_TEST_ prefix
@@ -23,11 +22,6 @@ if ( ! defined( 'ABSPATH' ) ) {
$page_url = admin_url( 'tools.php?page=wp-data-optimizer&tab=post-stress-test' );
-$cleanup_url = wp_nonce_url(
- add_query_arg( array( 'wpdo_post_stress_cleanup' => '1' ), $page_url ),
- 'wpdo_post_stress_cleanup'
-);
-
// Read-only display banner — server-set redirect message, no form processing.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$msg_raw = isset( $_GET['wpdo_msg'] ) ? sanitize_text_field( wp_unslash( (string) $_GET['wpdo_msg'] ) ) : '';