GV_Extension_DataTables_Data
Source: includes/class-datatables-data.php:24
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
maybe_bootstrap_wp() | If this file is being accessed directly, then set up WP so we can handle the AJAX request |
bootstrap_setup_globals() | Create required globals for minimal bootstrap |
bootstrap_gv() | Include Gravity Forms, GravityView, and GravityView Extensions |
bootstrap_wp_for_direct_access() | Include only the WP files needed |
add_hooks() | |
check_ajax_nonce() | Verify AJAX request nonce |
reduce_query_load() | Removes the queries caused by widgets_init for AJAX calls (and for generating the data) |
do_ajax_headers() | Get AJAX ready by defining AJAX constants and sending proper headers. |
get_datatables_data() | main AJAX logic to retrieve DataTables data |
add_global_search() | Add the generic search to the global get_entries query |
set_global_search_argument() | Adds the DataTables global search box value under the temporary dt_global_search argument. |
rewrite_global_search() | Rewrites the temporary dt_global_search marker into a canonical search_all filter. |
allow_search_all() | Updates the allowed search fields to include search_all, if the search request does not have it. |
set_column_search_arguments() | Injects the DataTables per-column searches into the Search Request arguments. |
allow_column_search_fields() | Adds the DataTables searchable columns to the allowed search fields. |
restrict_created_by_user_fields() | Restricts the created-by search to the user fields matching the column display format. |
restrict_created_by_user_meta_fields() | Restricts the created-by search to the user meta keys matching the column display format. |
split_created_by_search() | Splits a composite-format created-by search into an AND group of per-word filters. |
group_column_searches() | Combines the per-column searches, and the rewritten global search when present, into one AND group. |
get_output_data() | Get the array of entry data |
get_user_session() | Calculates the user ID and Session Token to be used when calculating the Cache Key |
set_view_template_class() | Override the template class to the correct one. |
set_entry_template_class() | Override the template class to use the correct one. |
add_template_path() | Include this extension templates path |
get_length_menu() | Generate the values for the page length menu |
get_ajax_url() | Get the url to the AJAX endpoint in use |
get_datatables_script_configuration() | Generate the script configuration array |
add_scripts_and_styles() | Enqueue Scripts and Styles for DataTable View Type |
maybe_modify_inline_edit_settings() | Modify Inline Edit settings |
has_search_request_arguments() | Whether the installed GravityView supports Search Request arguments. |
Method Reference
maybe_bootstrap_wp()
function maybe_bootstrap_wp()
If this file is being accessed directly, then set up WP so we can handle the AJAX request
Since: 1.3
Deprecated: Remove direct access altogether.
Source: includes/class-datatables-data.php:76
bootstrap_setup_globals()
function bootstrap_setup_globals()
Create required globals for minimal bootstrap
Since: 1.3
Deprecated: Remove direct access altogether.
Source: includes/class-datatables-data.php:87
bootstrap_gv()
function bootstrap_gv()
Include Gravity Forms, GravityView, and GravityView Extensions
Since: 1.3
Deprecated: Remove direct access altogether.
Source: includes/class-datatables-data.php:98
bootstrap_wp_for_direct_access()
function bootstrap_wp_for_direct_access()
Include only the WP files needed
This brilliant piece of code (cough) is from the dsIDXpress plugin.
Since: 1.3
Deprecated: Remove direct access altogether.
Source: includes/class-datatables-data.php:111
add_hooks()
function add_hooks()
Since: 1.3
Source: includes/class-datatables-data.php:119
check_ajax_nonce()
function check_ajax_nonce()
Verify AJAX request nonce
Returns
boolean— Whether the nonce is okay or not.
Source: includes/class-datatables-data.php:153
reduce_query_load()
public function reduce_query_load()
Removes the queries caused by widgets_init for AJAX calls (and for generating the data)
Returns
void
Since: 2.3.1
Source: includes/class-datatables-data.php:171
do_ajax_headers()
static function do_ajax_headers( $content_type='text/plain', $cache=false )
Get AJAX ready by defining AJAX constants and sending proper headers.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content_type | string | 'text/plain' | Type of content to be set in header. |
$cache | boolean | false | Do you want to cache the results? |
Since: 1.1
Source: includes/class-datatables-data.php:192
get_datatables_data()
function get_datatables_data()
main AJAX logic to retrieve DataTables data
Source: includes/class-datatables-data.php:335
add_global_search()
function add_global_search( $search_criteria )
Add the generic search to the global get_entries query
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search_criteria | array | Search Criteria |
Returns
mixed
Since: 1.3.3
Source: includes/class-datatables-data.php:692
set_global_search_argument()
public function set_global_search_argument( $search_arguments, $request_arguments )
Adds the DataTables global search box value under the temporary dt_global_search argument.
The marker key lets \self::rewrite_global_search() convert it to the canonical search_all
filter once the request has been parsed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search_arguments | array | The search arguments. | |
$request_arguments | array | The request arguments. |
Returns
array— The updated search arguments.
Since: 3.9.0
Source: includes/class-datatables-data.php:780
rewrite_global_search()
public function rewrite_global_search( $filters ): array
Rewrites the temporary dt_global_search marker into a canonical search_all filter.
The marker key (see \self::set_global_search_argument()) is renamed to search_all while
dt_global_search is kept as the request key, so the operator allowlist resolves like the native
global search and \self::group_column_searches() can target the row to fold it into the
per-column AND group. Runs whenever the global search box is used, independent of column searches.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$filters | array | The normalized search filters. |
Returns
array— The updated filters.
Since: 3.9.0
Source: includes/class-datatables-data.php:810
allow_search_all()
public function allow_search_all( $allowed, $view, $with_full_field )
Updates the allowed search fields to include search_all, if the search request does not have it.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$allowed | array | The allowed search fields. | |
$view | \GV\View | The View being searched. | |
$with_full_field | bool | Whether the allowed array contains the full field information. |
Returns
array|mixed
Since: 3.9.0
Source: includes/class-datatables-data.php:839
set_column_search_arguments()
public function set_column_search_arguments( $search_arguments, $request_arguments, $view )
Injects the DataTables per-column searches into the Search Request arguments.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search_arguments | array | The search arguments. | |
$request_arguments | array | The request arguments. | |
$view | \GV\View | The View being searched. |
Returns
array— The updated search arguments.
Since: 3.9.0
Source: includes/class-datatables-data.php:867
allow_column_search_fields()
public function allow_column_search_fields( $allowed, $view, $with_full_field )
Adds the DataTables searchable columns to the allowed search fields.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$allowed | array | The allowed search fields. | |
$view | \GV\View | The View being searched. | |
$with_full_field | bool | Whether the allowed array contains the full field information. |
Returns
array|mixed— The updated allowed search fields.
Since: 3.9.0
Source: includes/class-datatables-data.php:899
restrict_created_by_user_fields()
public function restrict_created_by_user_fields( $fields )
Restricts the created-by search to the user fields matching the column display format.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$fields | array | The default user fields. |
Returns
array— The user fields to search.
Since: 3.9.0
Source: includes/class-datatables-data.php:1078
restrict_created_by_user_meta_fields()
public function restrict_created_by_user_meta_fields( $meta_fields )
Restricts the created-by search to the user meta keys matching the column display format.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$meta_fields | array | The default user meta keys. |
Returns
array— The user meta keys to search.
Since: 3.9.0
Source: includes/class-datatables-data.php:1093
split_created_by_search()
public function split_created_by_search( $filters ): array
Splits a composite-format created-by search into an AND group of per-word filters.
Composite formats (first_last_name/last_first_name) render across separate user meta keys, so a multi-word value cannot match a single key with LIKE. The created-by filter is replaced in place by an AND group of per-word created-by filters — each word may match either name part.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$filters | array | The normalized search filters. |
Returns
array— The updated filters.
Since: 3.9.0
Source: includes/class-datatables-data.php:1112
group_column_searches()
public function group_column_searches( $filters ): array
Combines the per-column searches, and the rewritten global search when present, into one AND group.
The Search Request groups every filter under its own mode (OR by default), which would turn the
column filters into alternatives instead of cumulative narrowing. Collecting them in a dedicated
AND group keeps each one required without changing the mode of the search-bar filters. The global
search row is matched by its dt_global_search request key, assigned by \self::rewrite_global_search().
The composite created-by AND subgroup from \self::split_created_by_search() is matched by its
dt_created_by key and folded as a column member.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$filters | array | The normalized search filters. |
Returns
array— The updated filters.
Since: 3.9.0
Source: includes/class-datatables-data.php:1163
get_output_data()
public function get_output_data( $entries, $view, $post=null )
Get the array of entry data
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entries | Entry_Collection | The collection of entries for the current search. | |
$view | View | The View. | |
$post | WP_Post | null | Current View or post/page where View is embedded. |
Returns
array
Since: 1.3
Source: includes/class-datatables-data.php:1217
get_user_session()
function get_user_session()
Calculates the user ID and Session Token to be used when calculating the Cache Key
Returns
string
Source: includes/class-datatables-data.php:1386
set_view_template_class()
public function set_view_template_class( $class, $view )
Override the template class to the correct one.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$class | string | The class to use as the template class. | |
$view | View | The View we're looking at. |
Returns
string— The class
Source: includes/class-datatables-data.php:1413
set_entry_template_class()
public function set_entry_template_class( $class, $entry, $view )
Override the template class to use the correct one.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$class | string | The class to use as the template class. | |
$entry | \GV\Entry | The Entry we're looking at. | |
$view | View | The View we're looking at. |
Returns
string— The class
Source: includes/class-datatables-data.php:1431
add_template_path()
function add_template_path( $file_paths )
Include this extension templates path
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$file_paths | array | List of template paths ordered |
Source: includes/class-datatables-data.php:1450
get_length_menu()
function get_length_menu( $view )
Generate the values for the page length menu
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view | View | The View |
Returns
array— 2D array formatted for DataTables
Source: includes/class-datatables-data.php:1474
get_ajax_url()
function get_ajax_url()
Get the url to the AJAX endpoint in use
Returns
string— If direct access, it's this file. otherwise, admin-ajax.php
Source: includes/class-datatables-data.php:1725
get_datatables_script_configuration()
public function get_datatables_script_configuration( $post, $view )
Generate the script configuration array
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post | WP_Post | Current View or post/page where View is embedded | |
$view | View | The View |
Returns
array— Array of settings formatted as DataTables options array. {@see https://datatables.net/reference/option/}
Since: 1.3.3
Source: includes/class-datatables-data.php:1784
add_scripts_and_styles()
public function add_scripts_and_styles( $gravityview )
Enqueue Scripts and Styles for DataTable View Type
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$gravityview | Template_Context | The $gravityview object available in templates. |
Since: 2.5 (Added $gravityview parameter)
Source: includes/class-datatables-data.php:1999
maybe_modify_inline_edit_settings()
function maybe_modify_inline_edit_settings( $settings, $item_id=[] )
Modify Inline Edit settings
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$settings | array | ||
$item_id | array | [] | Array with form_id or view_id set |
Returns
array— Array with Inline Edit settings
Since: 2.3
Source: includes/class-datatables-data.php:2166
has_search_request_arguments()
public static function has_search_request_arguments(): bool
Whether the installed GravityView supports Search Request arguments.
Returns
bool
Since: 3.9.0
Source: includes/class-datatables-data.php:2243