Skip to main content

GravityKit\GravityMigrate\Export

Gravity Forms export class.

Source: src/Export.php:24

Details​

  • Kind: class
  • Namespace: GravityKit\GravityMigrate

Methods​

MethodDescription
__construct()Constructor.
get_instance()Returns class instance.
filter_available_data_types()Filters requested export data types down to those whose backing Gravity Forms
get_gf_settings()Returns Gravity Forms form settings allowed to be exported.
get_gk_settings()Returns GravityKit settings allowed to be exported.
settings_options_for()The settings options an export carries, for the data types it was asked for.
usable_export_date()A Y-m-d date, or '' for anything that is not one.
date_range_refusal()Why an entries date range cannot be honoured, or null when it can.
get_dates_filter_query()Returns the WHERE statement for date filter.
get_tables_where()Returns the final WHERE statement to add to the export query.
post_content_match_selection()Checks if post content shortcodes' or blocks' attribute value matches user's selection of forms to export.
get_table_structure()Returns the table structure for the provided table.
get_table_structure_keys()Returns the keys of the provided table.
get_keyset_pk_column()Resolves the single column safe to page a table's export by (`> last
get_nested_forms()Returns Gravity Perks' Nested Forms.
ajax_routes()Exports the data & the dump file.
generate_export_file_name()Generate a filename for the export file.
sanitize_file_name()Sanitize filename by removing accents and applying other rules
mysql_escape_mimic()Mimics the mysql_real_escape_string function. Adapted from a post by 'feedr' on php.net.

Method Reference​

__construct()​

public function __construct()

Constructor.

Since: 1.0.0

Source: src/Export.php:66

get_instance()​

public static function get_instance(): Export

Returns class instance.

Returns​

  • Export

Since: 1.0.0

Source: src/Export.php:78

filter_available_data_types()​

public function filter_available_data_types( array $types )

Filters requested export data types down to those whose backing Gravity Forms

tables exist on this install: selecting a type whose table is absent otherwise fatals in the export loop when SHOW CREATE TABLE returns nothing. Types with no dedicated table (views, posts, gf_settings, gk_settings) always pass.

Parameters​

NameTypeDefaultDescription
$typesarrayRequested data types.

Returns​

  • array — Types whose tables exist.

Since: 1.2.0

Source: src/Export.php:272

get_gf_settings()​

static public function get_gf_settings()

Returns Gravity Forms form settings allowed to be exported.

Returns​

  • array

Since: 1.0.0

Source: src/Export.php:323

get_gk_settings()​

static public function get_gk_settings()

Returns GravityKit settings allowed to be exported.

Returns​

  • array

Since: 1.0.0

Source: src/Export.php:344

settings_options_for()​

public static function settings_options_for( $export_data=null )

The settings options an export carries, for the data types it was asked for.

The Gravity Forms and GravityKit allow lists stay separate per selection: get_gf_settings() names gravityformsaddon_gravityformswebapi_settings, which holds Web API credentials on a site where that add-on is configured, so a file must never carry options its author did not tick.

Parameters​

NameTypeDefaultDescription
$export_dataarray | nullnullData types requested. Null means "no selection given" and carries both groups.

Returns​

  • string[] — Option names, empty when settings were not asked for at all.

Since: %ver%

Source: src/Export.php:363

usable_export_date()​

public static function usable_export_date( $date )

A Y-m-d date, or '' for anything that is not one.

The value comes from the request and is interpolated into the entries WHERE clause. It lands inside quotes there, so escaping holds, but escaping does not make a non-date meaningful: a malformed value survives into a BETWEEN comparing against nonsense and quietly changes which entries the export carries. Refusing it exports everything, which is what an absent range already means.

checkdate() is the part that matters -- '2026-02-31' matches the shape and is not a day.

Parameters​

NameTypeDefaultDescription
$datemixedRaw value.

Returns​

  • string

Since: %ver%

Source: src/Export.php:411

date_range_refusal()​

public static function date_range_refusal( $start, $end )

Why an entries date range cannot be honoured, or null when it can.

Dropping an unusable date is right for the WHERE clause and wrong for the person who typed it. Both shapes below produce a bundle that is reported as complete and is not what was asked for:

  • A reversed range becomes BETWEEN '2026-08-17' AND '2026-08-15', which no row satisfies, so the file carries no entries.
  • An impossible date is dropped and the range then WIDENS to everything on or before the other bound. A typo is not a request for everything.

The wizard refuses both before exporting (exportDateRange.js); this is the same rule where the CLI and the export record can reach it.

Parameters​

NameTypeDefaultDescription
$startmixedRaw start bound.
$endmixedRaw end bound.

Returns​

  • string | null — A sentence naming what is wrong, or null when the range is usable.

Since: %ver%

Source: src/Export.php:443

get_dates_filter_query()​

public function get_dates_filter_query( $start_date='', $end_date='' )

Returns the WHERE statement for date filter.

Parameters​

NameTypeDefaultDescription
$start_datestring''DATE FORMAT: YYYY-MM-DD.
$end_datestring''DATE FORMAT: YYYY-MM-DD.

Returns​

  • string

Since: 1.0.0

Source: src/Export.php:487

get_tables_where()​

public function get_tables_where( $forms='', $entries_date_filter_query='', $export_data=null )

Returns the final WHERE statement to add to the export query.

Parameters​

NameTypeDefaultDescription
$formsstring''Comma-separated list of form IDs.
$entries_date_filter_querystring''AND statement with start date AND/OR end date.
$export_dataarraynullData types the export was asked for. The options clause is built from this: a file must carry the settings that were chosen and no others. Defaults to both settings groups.

Returns​

  • array

Since: 1.0.0

Source: src/Export.php:525

post_content_match_selection()​

public function post_content_match_selection( $content, $forms_arr )

Checks if post content shortcodes' or blocks' attribute value matches user's selection of forms to export.

Parameters​

NameTypeDefaultDescription
$contentstringPost content.
$forms_arrarrayUser's selection of forms to export.

Returns​

  • bool | array

Since: 1.1.0

Source: src/Export.php:851

get_table_structure()​

public function get_table_structure( $table_name )

Returns the table structure for the provided table.

Parameters​

NameTypeDefaultDescription
$table_namestringTable name.

Returns​

  • array | bool

Since: 1.0.0

Source: src/Export.php:1007

get_table_structure_keys()​

public function get_table_structure_keys( $table_name )

Returns the keys of the provided table.

Parameters​

NameTypeDefaultDescription
$table_namestringTable name.

Returns​

  • array

Since: 1.0.0

Source: src/Export.php:1024

get_keyset_pk_column()​

public function get_keyset_pk_column( array $table_structure )

Resolves the single column safe to page a table's export by (`> last

value ORDER BY column) instead of OFFSET, from a DESCRIBEresult. Returns null for any table without exactly onePRIcolumn -- a composite or missing primary key can't be paged this way without a risk of dropping or duplicating rows, so callers must fall back toOFFSET`.

Parameters​

NameTypeDefaultDescription
$table_structurearray\get_table_structure output.

Returns​

  • array{field:string,is_int:bool} | null

Since: 1.3.0

Source: src/Export.php:1049

get_nested_forms()​

public function get_nested_forms( $selected_forms )

Returns Gravity Perks' Nested Forms.

Merged with selected forms.

Parameters​

NameTypeDefaultDescription
$selected_forms

Returns​

  • array

Since: 1.0.0

Source: src/Export.php:1072

ajax_routes()​

public function ajax_routes( $routes )

Exports the data & the dump file.

Parameters​

NameTypeDefaultDescription
$routesarrayFoundation routes.

Returns​

  • array

Since: 1.0.0

Source: src/Export.php:1151

generate_export_file_name()​

public function generate_export_file_name()

Generate a filename for the export file.

gk-migrate-{domain}-{date generated in Y-m-d}-{8 random hex chars}.zip

Returns​

  • string

Since:

  • 1.0.0
  • %ver% The trailing component is a random value rather than a unix timestamp, which a downloader's domain and this file's own date narrow to at most 86,400 guesses.

Source: src/Export.php:1893

sanitize_file_name()​

public function sanitize_file_name( $filename )

Sanitize filename by removing accents and applying other rules

Parameters​

NameTypeDefaultDescription
$filenamestring

Returns​

  • string

Source: src/Export.php:1929

mysql_escape_mimic()​

static public function mysql_escape_mimic( $input )

Mimics the mysql_real_escape_string function. Adapted from a post by 'feedr' on php.net.

Parameters​

NameTypeDefaultDescription
$inputstring | arrayThe string to escape.

Returns​

  • string | array

Since: 1.0.0

Source: src/Export.php:1949