__( 'Security token expired. Reload the page.', 'aiforya-sitemap' ) ], 403 ); } if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( [ 'message' => __( 'Permission denied.', 'aiforya-sitemap' ) ], 403 ); } } /** * @return void */ public function save_settings(): void { $this->guard(); /* * The nonce and the capability are both verified in guard() just above. PHPCS cannot * follow a method call, so it reports the reads below as unverified; the ignores name * that reason rather than silencing the sniff blindly. * * The payload is never stored as received: Aiforya_Smap_Settings::save() rebuilds a * clean array (sanitize_key + whitelist of registered post types, integer bounded to * 1..2000, booleans), so no unvalidated value reaches the database. */ // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- nonce and capability are verified in guard() above; PHPCS cannot follow the method call. Every value is sanitized field by field in Aiforya_Smap_Settings::save(). $in = []; if ( isset( $_POST['settings'] ) && is_array( $_POST['settings'] ) ) { $in = wp_unslash( $_POST['settings'] ); } // phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized Aiforya_Smap_Settings::get_instance()->save( $in ); wp_send_json_success( [ 'message' => __( 'Settings saved.', 'aiforya-sitemap' ) ] ); } } endif;