@@ -87,10 +87,17 @@ function pmpro_add_pages() {
8787 add_submenu_page ( 'admin.php ' , __ ( 'Advanced Settings ' , 'paid-memberships-pro ' ), __ ( 'Advanced Settings ' , 'paid-memberships-pro ' ), 'pmpro_advancedsettings ' , 'pmpro-advancedsettings ' , 'pmpro_advancedsettings ' );
8888
8989 // Set up screen settings for list tables.
90- add_action ( 'load- ' . $ members_list_table_hook , 'PMPro_Members_List_Table::hook_screen_options ' );
91- add_action ( 'load- ' . $ orders_list_table_hook , 'PMPro_Orders_List_Table::hook_screen_options ' );
92- add_action ( 'load- ' . $ subscriptions_list_table_hook , 'PMPro_Subscriptions_List_Table::hook_screen_options ' );
93- add_action ( 'load- ' . $ discount_codes_list_table_hook , 'PMPro_Discount_Code_List_Table::hook_screen_options ' );
90+ $ pmpro_list_table_hooks = array (
91+ $ members_list_table_hook => 'PMPro_Members_List_Table::hook_screen_options ' ,
92+ $ orders_list_table_hook => 'PMPro_Orders_List_Table::hook_screen_options ' ,
93+ $ subscriptions_list_table_hook => 'PMPro_Subscriptions_List_Table::hook_screen_options ' ,
94+ $ discount_codes_list_table_hook => 'PMPro_Discount_Code_List_Table::hook_screen_options ' ,
95+ );
96+
97+ foreach ( $ pmpro_list_table_hooks as $ list_table_hook => $ hook_screen_options_callback ) {
98+ add_action ( 'load- ' . $ list_table_hook , 'pmpro_maybe_redirect_list_table_referer ' , 5 );
99+ add_action ( 'load- ' . $ list_table_hook , $ hook_screen_options_callback );
100+ }
94101
95102 //updates page only if needed
96103 if ( pmpro_isUpdateRequired () ) {
@@ -111,6 +118,25 @@ function pmpro_add_pages() {
111118}
112119add_action ( 'admin_menu ' , 'pmpro_add_pages ' );
113120
121+ /**
122+ * Remove stale list table referer parameters from PMPro admin URLs.
123+ *
124+ * WP_List_Table adds _wp_http_referer to GET forms. Leaving that value in the
125+ * URL causes Screen Options submissions to redirect back to the previous URL
126+ * because set_screen_options() prefers the request referer. Mirror WordPress
127+ * core list screens by stripping the transient referer args once.
128+ *
129+ * @since TBD
130+ */
131+ function pmpro_maybe_redirect_list_table_referer () {
132+ if ( empty ( $ _REQUEST ['_wp_http_referer ' ] ) || empty ( $ _SERVER ['REQUEST_URI ' ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
133+ return ;
134+ }
135+
136+ wp_safe_redirect ( remove_query_arg ( array ( '_wp_http_referer ' , '_wpnonce ' ), esc_url_raw ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) ) ) );
137+ exit ;
138+ }
139+
114140/**
115141 * Keep the Memberships menu selected on subpages.
116142 */
0 commit comments