Skip to main content

GV_Extension_DataTables_Data

Source: includes/class-datatables-data.php:24

Details

  • Kind: class
  • Namespace: (global)

Methods

MethodDescription
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

NameTypeDefaultDescription
$content_typestring'text/plain'Type of content to be set in header.
$cachebooleanfalseDo 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

function add_global_search( $search_criteria )

Add the generic search to the global get_entries query

Parameters

NameTypeDefaultDescription
$search_criteriaarraySearch 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

NameTypeDefaultDescription
$search_argumentsarrayThe search arguments.
$request_argumentsarrayThe request arguments.

Returns

  • array — The updated search arguments.

Since: 3.9.0

Source: includes/class-datatables-data.php:780

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

NameTypeDefaultDescription
$filtersarrayThe 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

NameTypeDefaultDescription
$allowedarrayThe allowed search fields.
$view\GV\ViewThe View being searched.
$with_full_fieldboolWhether 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

NameTypeDefaultDescription
$search_argumentsarrayThe search arguments.
$request_argumentsarrayThe request arguments.
$view\GV\ViewThe 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

NameTypeDefaultDescription
$allowedarrayThe allowed search fields.
$view\GV\ViewThe View being searched.
$with_full_fieldboolWhether 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

NameTypeDefaultDescription
$fieldsarrayThe 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

NameTypeDefaultDescription
$meta_fieldsarrayThe default user meta keys.

Returns

  • array — The user meta keys to search.

Since: 3.9.0

Source: includes/class-datatables-data.php:1093

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

NameTypeDefaultDescription
$filtersarrayThe 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

NameTypeDefaultDescription
$filtersarrayThe 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

NameTypeDefaultDescription
$entriesEntry_CollectionThe collection of entries for the current search.
$viewViewThe View.
$postWP_PostnullCurrent 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

NameTypeDefaultDescription
$classstringThe class to use as the template class.
$viewViewThe 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

NameTypeDefaultDescription
$classstringThe class to use as the template class.
$entry\GV\EntryThe Entry we're looking at.
$viewViewThe 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

NameTypeDefaultDescription
$file_pathsarrayList 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

NameTypeDefaultDescription
$viewViewThe 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

NameTypeDefaultDescription
$postWP_PostCurrent View or post/page where View is embedded
$viewViewThe View

Returns

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

NameTypeDefaultDescription
$gravityviewTemplate_ContextThe $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

NameTypeDefaultDescription
$settingsarray
$item_idarray[]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