This commit is contained in:
Javier Casares 2026-08-18 10:49:06 +00:00
commit 4f8ab239b0
5 changed files with 23 additions and 22 deletions

View file

@ -44,6 +44,7 @@ class Robotstxt_Manager_Settings {
$menu_hook = is_multisite() ? 'network_admin_menu' : 'admin_menu';
$loader->add_action( $menu_hook, $this, 'add_settings_page' );
$loader->add_action( 'admin_init', $this, 'register_settings' );
$loader->add_action( 'admin_init', $this, 'handle_form_submission' );
$loader->add_action( 'admin_enqueue_scripts', $this, 'enqueue_scripts' );
$loader->add_action( 'wp_ajax_robotstxt_manager_test_connection', $this, 'handle_test_connection' );
$loader->add_action( 'wp_ajax_robotstxt_manager_delete_key', $this, 'handle_delete_key' );
@ -209,8 +210,6 @@ class Robotstxt_Manager_Settings {
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'robotstxt-manager' ) );
}
$this->handle_form_submission();
require_once ROBOTSTXT_MANAGER_DIR . 'admin/views/page-settings.php';
}
@ -218,11 +217,12 @@ class Robotstxt_Manager_Settings {
* Handles manual form submission for network settings.
*
* The WordPress Settings API (options.php) does not handle network
* options, so the network settings page must process its own form.
* options, so the settings page must process its own form. Hooked to
* admin_init so the redirect runs before any output is sent.
*
* @return void
*/
private function handle_form_submission(): void {
public function handle_form_submission(): void {
if ( ! isset( $_POST['robotstxt_manager_settings_group_nonce'] ) ) {
return;
}