v1.0.0
This commit is contained in:
parent
8caa140991
commit
5cdf7f48e5
29 changed files with 6526 additions and 0 deletions
56
includes/class-robotstxt-mlp2-mlp5-ajax.php
Normal file
56
includes/class-robotstxt-mlp2-mlp5-ajax.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* AJAX handler registry.
|
||||
*
|
||||
* All AJAX actions for the migration wizard are registered here.
|
||||
* Every handler verifies a nonce and the manage_network capability
|
||||
* before performing any work.
|
||||
*
|
||||
* @package Robotstxt_Mlp2_Mlp5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Robotstxt_Mlp2_Mlp5_Ajax
|
||||
*/
|
||||
class Robotstxt_Mlp2_Mlp5_Ajax {
|
||||
|
||||
/**
|
||||
* Nonce action used for all batch AJAX requests.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const NONCE_ACTION = 'mlp_migrator_batch';
|
||||
|
||||
/**
|
||||
* Register all AJAX hooks. Called once on plugins_loaded.
|
||||
*/
|
||||
public static function register(): void {
|
||||
add_action( 'wp_ajax_mlp_migrator_run_batch', array( static::class, 'action_run_batch' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler: run one content-relations migration batch.
|
||||
*
|
||||
* Verifies nonce and capability, delegates to Step_Content_Relations,
|
||||
* and returns a JSON progress snapshot.
|
||||
*/
|
||||
public static function action_run_batch(): void {
|
||||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$raw_nonce = isset( $_POST['nonce'] ) ? wp_unslash( $_POST['nonce'] ) : '';
|
||||
if ( ! wp_verify_nonce( (string) $raw_nonce, self::NONCE_ACTION ) ) {
|
||||
wp_send_json_error( array( 'message' => 'Invalid nonce.' ), 403 );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_network' ) ) {
|
||||
wp_send_json_error( array( 'message' => 'Insufficient permissions.' ), 403 );
|
||||
}
|
||||
|
||||
$progress = Robotstxt_Mlp2_Mlp5_Step_Content_Relations::run_batch();
|
||||
|
||||
wp_send_json_success( $progress );
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue