Skip to main content

GravityKit\GravityMigrate\Util

Utility class.

Source: src/Util.php:18

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate

Properties

PropertyTypeDescription
$wp_filesystemWP_Filesystem_BaseWP Filesystem variable.

Methods

MethodDescription
get_instance()Returns class instance.
__construct()Constructor.
set_time_limit()Sets time limit.
log_debug()Writes debug message to the Foundation log.
log_error()Writes error message to the Foundation log.
db_query()Simple {@see wpdb} query function wrapper.
db_get_var()Simple {@see wpdb} function wrapper for get_var.
db_get_results()Simple {@see wpdb} function wrapper for get_results.
delete_directory()Deletes files and folder recursively.
array_remove()Removes an item from the array and returns its value.
get_imports_dir()Returns the directory path for storing imports.
get_current_import_dir()Returns the directory path for the current import files.
get_current_import_file()Returns an array containing file paths for the current import files.
get_exports_dir()Returns the directory path for storing exports.
get_local_upload_info()Gets the local filesystem upload directory info without any plugin filters.
get_shortcodes_list()Returns a list of shortcode names.
get_blocks_list()Returns a list of block names.
post_content_like_statement()Generates a "WHERE statement" for querying posts based on shortcodes and blocks in post content.

Method Reference

get_instance()

public static function get_instance(): Util

Returns class instance.

Returns

  • Util

Since: 1.0.0

Source: src/Util.php:68

__construct()

public function __construct()

Constructor.

Since: 1.0.0

Source: src/Util.php:81

set_time_limit()

public function set_time_limit()

Sets time limit.

Returns

  • void

Since: 1.0.0

Source: src/Util.php:102

log_debug()

public function log_debug( $message )

Writes debug message to the Foundation log.

Parameters

NameTypeDefaultDescription
$message

Since: 1.0.0

Source: src/Util.php:118

log_error()

public function log_error( $message )

Writes error message to the Foundation log.

Parameters

NameTypeDefaultDescription
$message

Since: 1.0.0

Source: src/Util.php:127

db_query()

public function db_query( $query, $type='IMPORT' )

Simple {@see wpdb} query function wrapper.

Logs error.

Parameters

NameTypeDefaultDescription
$querystring
$typestring'IMPORT'

Returns

  • mixed

Since: 1.0.0

Source: src/Util.php:142

db_get_var()

public function db_get_var( $query, $type='IMPORT' )

Simple {@see wpdb} function wrapper for get_var.

Logs error if required.

Parameters

NameTypeDefaultDescription
$querystring
$typestring'IMPORT'

Returns

  • mixed

Since: 1.0.0

Source: src/Util.php:169

db_get_results()

public function db_get_results( $query, $return_data_type='OBJECT', $type='IMPORT' )

Simple {@see wpdb} function wrapper for get_results.

Logs error if required.

Parameters

NameTypeDefaultDescription
$querystring
$return_data_typestring'OBJECT'
$typestring'IMPORT'

Returns

  • array | object | null — Database query results.

Since: 1.0.0

Source: src/Util.php:197

delete_directory()

public function delete_directory( $dir )

Deletes files and folder recursively.

Parameters

NameTypeDefaultDescription
$dirstringDirectory path.

Returns

  • bool — Returns true on success or false on failure.

Source: src/Util.php:220

array_remove()

public function array_remove( $original_array, $removal_array )

Removes an item from the array and returns its value.

Parameters

NameTypeDefaultDescription
$original_arrayarrayOriginal array to remove from.
$removal_arrayarrayArray of items to remove.

Returns

  • array

Since: 1.0.0

Source: src/Util.php:247

get_imports_dir()

public function get_imports_dir()

Returns the directory path for storing imports.

Returns

  • string — The directory path for storing imports.

Since: 1.1.0

Source: src/Util.php:258

get_current_import_dir()

public function get_current_import_dir()

Returns the directory path for the current import files.

Returns

  • string — The directory path for the current import files.

Since: 1.1.0

Source: src/Util.php:269

get_current_import_file()

public function get_current_import_file()

Returns an array containing file paths for the current import files.

Returns

  • array — An array with 'dump' and 'json' file paths for the current import.

Since: 1.1.0

Source: src/Util.php:280

get_exports_dir()

public function get_exports_dir()

Returns the directory path for storing exports.

Returns

  • string — The directory path for storing exports.

Since: 1.1.0

Source: src/Util.php:296

get_local_upload_info()

public function get_local_upload_info()

Gets the local filesystem upload directory info without any plugin filters.

Works with any cloud storage plugin by temporarily removing filters.

Returns

  • array — The local upload directory info (basedir, baseurl, etc).

Since: 1.1.4

Source: src/Util.php:308

get_shortcodes_list()

public function get_shortcodes_list()

Returns a list of shortcode names.

Returns

  • array — List of shortcode names.

Since: 1.1.0

Source: src/Util.php:331

get_blocks_list()

public function get_blocks_list()

Returns a list of block names.

Returns

  • array — List of block names.

Since: 1.0.0

Source: src/Util.php:396

post_content_like_statement()

public function post_content_like_statement( $column='post_content' )

Generates a "WHERE statement" for querying posts based on shortcodes and blocks in post content.

Parameters

NameTypeDefaultDescription
$columnstring'post_content'The column name for where statement.

Returns

  • string — The generated WHERE statement for database queries.

Since: 1.1.0

Source: src/Util.php:473