# automatorwp/6.0.4/libraries/ct-ajax-list-table/includes/ajax-functions.php

AutomatorWP – No-Code Workflow Automation, Integration &amp; Webhooks Plugin, now with AI, version 6.0.4. 92 lines.

- Page: https://pluginprobe.com/plugins/automatorwp/6.0.4/code/libraries/ct-ajax-list-table/includes/ajax-functions.php
- Raw: https://pluginprobe.com/plugins/automatorwp/6.0.4/raw/libraries/ct-ajax-list-table/includes/ajax-functions.php
- Modified: 2026-10-04T21:05:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/automatorwp/6.0.4/code/libraries/ct-ajax-list-table/includes/ajax-functions.php#L10-L20`.

```php
<?php
/**
 * Ajax Functions
 *
 * @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gamil.com>
 *
 * @since 1.0.0
 */
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;

function ct_ajax_list_table_handle_request() {

    global $ct_table, $ct_query, $ct_list_table, $ct_ajax_list_items_per_page;

    // Security check, forces to die if not security passed
    check_ajax_referer( 'ct_ajax_list_table', 'nonce' );

    if( ! isset( $_GET['object'] ) ) {
        wp_send_json_error();
    }

    // Setup the CT Table
    $ct_table = ct_setup_table( sanitize_text_field( wp_unslash( $_GET['object'] ) ) );

    if( ! is_object( $ct_table ) ) {
        wp_send_json_error();
    }

    /**
     * Filter capability to check
     *
     * @param string $capability By default, "manage_options"
     *
     * @return string
     */
    $capability = apply_filters( 'ct_ajax_list_table_' . $ct_table->name . '_capability', 'manage_options' );

    if( ! current_user_can( $capability ) ) {
        wp_send_json_error();
    }

    // Setup this constant to allow from CT_List_Table meet that this render comes from this plugin
    @define( 'IS_CT_AJAX_LIST_TABLE', true );

    if( isset( $_GET['query_args'] ) && is_array( $_GET['query_args'] ) ) {
        $query_args = map_deep( wp_unslash( $_GET['query_args'] ), 'sanitize_text_field' );
    } else {
        $query_args = json_decode( wp_unslash( $_GET['query_args'] ), true );
        // Sanitize
        $query_args = map_deep( $query_args, 'sanitize_text_field' );
    }

    if( isset( $_GET['paged'] ) ) {
        $query_args['paged'] = absint( $_GET['paged'] );
    }
    
    $query_args = wp_parse_args( $query_args, array(
        'paged' => 1,
        'items_per_page' => 20,
    ) );

    if( isset( $query_args['paged'] ) ) {
        $query_args['paged'] = absint( $query_args['paged'] );
    }

    /**
     * Filter query vars
     *
     * @param array $query_args
     *
     * @return array
     */
    $query_args = apply_filters( 'ct_ajax_list_table_' . $ct_table->name . '_query_args', $query_args );

    $ct_ajax_list_items_per_page = $query_args['items_per_page'];
    add_filter( 'edit_' . $ct_table->name . '_per_page', 'ct_ajax_list_override_items_per_page' );

    // Set up vars
    $ct_query = new CT_Query( $query_args );
    $ct_list_table = new CT_List_Table();

    $ct_list_table->prepare_items();

    ob_start();
    $ct_list_table->display();
    $output = ob_get_clean();

    wp_send_json_success( $output );

}
add_action( 'wp_ajax_ct_ajax_list_table_request', 'ct_ajax_list_table_handle_request' );
```
