These instructions are for implementing a new Processor for an AJAX action or REST route:

1. Create a new class that implements Processor_Base and the following functions:

- verify_ajax_nonce : verifies the relevant nonce for AJAX actions. REST processors can add verify_rest_request if the route does not use the same nonce mechanism.
- get_data_map : registers the data map which represents the structure of data received via the AJAX or REST call. This - part is important in order to keep calls secure and lean. See example below.
process_entry : Processes the entry that was stored in the DB. It must return strict true when processing completed. Return false or WP_Error to retry and eventually mark the row failed. A simple implementation would be to call the appropriate AJAX hook that was prevented by this plugin.

* An example of a more complicated Processor class can be found under this plugin's /processors directory, with the name 'class-pys.php' which is intended to process PixelYourSite Data.

2. Register the Processor and action/route:
The action or route and according class_name should be registered in order to be used later in the MU Plugin.
It's better to register only once when you're sure it is needed, however, you can register multiple times without duplication.
The request key allow-list decides what is caught. The processor registration decides which code handles that caught key.

Example:
add_action('admin_init', 'your_code_load_processors');

function your_code_load_processors() {
    
    $_processors = new \QACP\Processors();

    // Sets a directory to load Processors from, in addition to the default QACP directory.
    // The custom directories will be searched for a filename in the form of "{class_name}.php" and
    // before the default directory is searched.
    //
    $_processors->register_custom_processor_directory( __DIR__ . '/processors' );
    
    // Sets an action or REST route and a processor class name to load.
    // Class name is case insensitive.
    //
    $_processors->set_action( {action_name}, {class_name} );

    // REST routes should be prefixed with "rest:".
    //
    $_processors->set_action( 'rest:{namespace}/{route}', {class_name} );

    // or to remove.
    //
    $_processors->remove_action( {action_name}, {class_name} );

}

3. Example Data Map ( for 'get_data_map' function ):

$_data_map = array(
    'url' => array(
        'sanitize' => 'sanitize_text_field',
        'data_max_length' => 1024,
    ),
    'taxonomies' => array(
        'sanitize' => 'sanitize_text_field',
        'fields' => array(
            'categories' => [],
            'tags' => [],
        )
    ),
    'ids' => array(
        'sanitize_as_array' => true,
        'sanitize' => 'sanitize_text_field',
        'array_max_length' => 30,
        'data_max_length' => 256,
    ),
);

4. Schema-only replay processors:

For integrations that only need sanitation before calling their original AJAX action or REST route later, use the Replay Processors builder in the QACP settings page. It creates the request key, processor mapping, and data map as saved configuration; no PHP class is generated.
        
