Properties

$instance

$instance : mixed

Public static variable to hold the single instance of the class.

Type

mixed — Default null

Methods

get_class_name()

get_class_name() : string

Method get_class_name()

Get class name.

Returns

string —

CLASS Class name.

instance()

instance() : mixed

Method instance()

Create a public static instance.

Returns

mixed —

Class instance.

write()

write(mixed  $value) 

Method write()

Write response data to be sent to the MainWP Dashboard.

Parameters

mixed $value

Contains information to be written.

send()

send(mixed  $value, mixed  $action = '') 

Method send()

Send response data to be sent to the MainWP Dashboard.

Parameters

mixed $value

Contains information to be send.

mixed $action

action send message.

error()

error(string  $error, mixed  $code = null) 

Method write()

Handle response data errors.

Parameters

string $error

Contains error message.

mixed $code

Contains the error code.

get_mainwp_dir()

get_mainwp_dir(string  $what = null, boolean  $die_on_error = true) : array

Method get_mainwp_dir()

Get the MainWP directory.

Parameters

string $what

Contains directory name.

boolean $die_on_error

If true, process will die on error, if false, process will continue.

Throws

\Exception

Error Message.

Returns

array —

Return directory and directory URL.

fs_is_connected()

fs_is_connected() 

Method fs_is_connected()

Check if WP FileSystem is connected.

file_put_contents()

file_put_contents(string  $file, string  $content) 

Method fwrite()

Parameters

string $file

File path.

string $content

content write.

mkdir()

mkdir(string  $file, integer  $mode = FS_CHMOD_DIR) 

Method mkdir()

Parameters

string $file

File path.

integer $mode

File mode.

move()

move(string  $source, string  $desc) 

Method move()

Parameters

string $source

File source.

string $desc

File desc.

is_writable()

is_writable(string  $dir) 

Method is_writable()

Parameters

string $dir

dir path.

rmdir()

rmdir(string  $dir) 

Method is_writable()

Parameters

string $dir

dir path.

check_dir()

check_dir(string  $dir, boolean  $die_on_error, integer  $chmod = 493) 

Method check_dir()

Check if the /mainwp/ direcorty is writable by server.

Parameters

string $dir

Contains directory path.

boolean $die_on_error

If true, process will die on error, if false, process will continue.

integer $chmod

Contains information about the directory permissions settings.

Throws

\Exception

Error message.

search()

search(array|object  $arr, string  $key) : mixed

Method search()

Nested search field value in an array or object.

Parameters

array|object $arr

Array or object to search.

string $key

Field value to search for in the $array.

Returns

mixed —

If found return field value, if not, return NULL.

get_wp_filesystem()

get_wp_filesystem() : mixed

Method get_wp_filesystem()

Get the WordPress filesystem.

Returns

mixed —

$init WordPress filesystem base.

check_wp_filesystem()

check_wp_filesystem() : mixed

Method check_wp_filesystem()

Check the WordPress filesystem.

Returns

mixed —

$wp_filesystem WordPress filesystem check result.

reject_unsafe_urls()

reject_unsafe_urls(array  $r) : array

Method reject_unsafe_urls()

Reject unsafe URLs in HTTP Basic Authentication handler.

Parameters

array $r

Array containing the request data.

Returns

array —

$r Updated array containing the request data.

starts_with()

starts_with(string  $haystack, string  $needle) : boolean

Method starts_with()

Check if the String 1 starts with the String 2.

Parameters

string $haystack

Contains the String 1 for the comparison.

string $needle

Contains the String 2 for the comparison.

Returns

boolean —

true|false Return true if the comparison is positive, false if not.

ends_with()

ends_with(string  $haystack, string  $needle) : boolean

Method ends_with()

Check if the String 1 ends with the String 2.

Parameters

string $haystack

Contains the String 1 for the comparison.

string $needle

Contains the String 2 for the comparison.

Returns

boolean —

true|false Return true if the comparison is positive, false if not.

get_nice_url()

get_nice_url(string  $url_to_clean, boolean  $show_http = false) : string

Method get_nice_url()

Convert noraml URL to nice URL.

Parameters

string $url_to_clean

Contains the URL that needs to be cleaned.

boolean $show_http

True to include HTTP|HTTPS in URL.

Returns

string —

$url Cleaned (nice) URL.

end_session()

end_session() 

Method end_session()

End session and flush the output buffer.

rand_string()

rand_string(integer  $length) : string

Method rand_string()

Generate random string.

Parameters

integer $length

Contains the string lenghts.

Returns

string —

$str Generated random string.

return_bytes()

return_bytes(string  $val) : string

Method return_bytes()

Convert value to bytes.

Parameters

string $val

Contains the value to convert to bytes.

Returns

string —

$val Value converted to bytes.

human_filesize()

human_filesize(integer  $bytes, integer  $decimals = 2) : string

Method human_filesize()

Convert filesize to more user-friendly format.

Parameters

integer $bytes

Contains the value in bytes to convert.

integer $decimals

Contains the number of decimal places to round.

Returns

string —

Value converted to more user-friendly format.

is_dir_empty()

is_dir_empty(string  $dir) : boolean

Method is_dir_empty()

Check if a directory is empty.

Parameters

string $dir

Contains the directory location path.

Returns

boolean —

true|false Return true if the directory is empty, false if not.

delete_dir()

delete_dir(string  $dir) 

Method delete_dir()

Delete wanted directory.

Parameters

string $dir

Contains the directory location path.

funct_exists()

funct_exists(string  $func) : boolean

Method funct_exists()

Check if a function exists.

Parameters

string $func

Contains the function name.

Returns

boolean —

true|false Return true if the function exists, false if not.

get_timestamp()

get_timestamp(string  $timestamp = false) : string

Method get_timestamp()

Get the timestamp and include GMT offset.

Parameters

string $timestamp

Contains the timestamp value.

Returns

string —

$timestamp The timestamp including the GMT offset.

format_date()

format_date(string  $timestamp) : string

Method format_date()

Format date as per the WordPress general settings.

Parameters

string $timestamp

Contains the timestamp value.

Returns

string —

Formatted date.

format_time()

format_time(string  $timestamp) : string

Method format_time()

Format time as per the WordPress general settings.

Parameters

string $timestamp

Contains the timestamp value.

Returns

string —

Formatted time.

format_timestamp()

format_timestamp(string  $timestamp) : string

Method format_timestamp()

Format timestamp as per the WordPress general settings.

Parameters

string $timestamp

Contains the timestamp value.

Returns

string —

Formatted date and time.

update_option()

update_option(string  $option_name, string  $option_value, string  $autoload = 'no') : boolean

Method update_option()

Update option.

Parameters

string $option_name

Contains the option name.

string $option_value

Contains the option value.

string $autoload

Autoload? Yes or no.

Returns

boolean —

$success true|false Option updated.

get_site_unique_id()

get_site_unique_id() : string

Method get_site_unique_id()

Get site unique id.

Returns

string —

$uniqueId unique id.

in_excludes()

in_excludes(array  $excludes, string  $value) : boolean

Method in_excludes()

Check if the value is in the excludes list.

Parameters

array $excludes

Array containing the list of excludes.

string $value

Value to check.

Returns

boolean —

true|false If in excluded list, return true, if not, return false.

sanitize_filename()

sanitize_filename(string  $filename) : string

Method sanitize_filename()

Sanitize file name.

Parameters

string $filename

Contains the file name to be sanitized.

Returns

string —

$filename Sanitized filename.

ctype_digit()

ctype_digit(string  $str) : boolean

Method ctype_digit()

Check for numberic character(s).

Parameters

string $str

Contains the string to check.

Returns

boolean —

true|false If numberic characters found, return true, if not, return false.

is_admin()

is_admin(object|null  $user = null) : boolean

Method is_admin()

Check if the user is administrator.

Parameters

object|null $user

user check.

Returns

boolean —

true|false If the user is administrator (Level 10), return true, if not, return false.

current_user_has_role()

current_user_has_role(string|array  $roles, object|null  $user = null) : boolean

Method current_user_has_role()

Check if the user has role.

Parameters

string|array $roles

role or array of roles to check.

object|null $user

user check.

Returns

boolean —

true|false If the user is administrator (Level 10), return true, if not, return false.

is_ssl_enabled()

is_ssl_enabled() : boolean

Method is_ssl_enabled()

Check if the OpenSSL PHP extension is enabled.

Returns

boolean —

true|false If the OpenSSL PHP extension is enabled, return true, if not, return false.

is_updates_screen()

is_updates_screen() : boolean

Method is_updates_screen()

Check if the current screen is the Updates screen.

Returns

boolean —

true|false If the current screen is updates, return true, if not, return false.

is_wp_engine()

is_wp_engine() : boolean

Method is_wp_engine()

Check if the child site is hosted on the WP Engine server.

Returns

boolean —

true|false If the child site is hosted on the WP Engine, return true, if not, return false.

is_wp_engine_php8()

is_wp_engine_php8() : boolean

Method is_wp_engine_php8()

Check if the child site is hosted on the WP Engine server and PHP8.

Returns

boolean —

true|false If the child site is hosted on the WP Engine and PHP8, return true, if not, return false.

get_wp_host()

get_wp_host() : string

Method get_wp_host()

Get host if hosted on the FLYWHEEL or Pressable host.

Returns

string —

flywheel|pressable If the child site is hosted on FLYWHEEL or Pressable host.

is_flywheel_host()

is_flywheel_host() : boolean

Method is_flywheel_host()

Check if the child site is hosted on the FLYWHEEL server.

Returns

boolean —

true|false If the child site is hosted on the FLYWHEEL, return true, if not, return false.

is_pressable_host()

is_pressable_host() : boolean

Method is_pressable_host()

Check if the child site is hosted on the Pressable host.

Returns

boolean —

true|false If the child site is hosted on the Pressable host, return true, if not, return false.

maybe_set_doing_cron()

maybe_set_doing_cron() 

Method maybe_set_doing_cron()

May be define doing cron.

is_dashboard_request()

is_dashboard_request(boolean  $and_func = false) : boolean

Method is_dashboard_request()

If it is dashboard request.

Parameters

boolean $and_func

If true, check 'function' params existed.

Returns

boolean —

true|false If is dashboard request.

check_files_exists()

check_files_exists(array  $files = array(), boolean  $return_results = false) : mixed

Method check_files_exists()

Check if a certain files exist.

Parameters

array $files

Array containing list of files to check.

boolean $return_results

If true, return feedback.

Throws

\Exception

Error message.

Returns

mixed —

If exists, return true, if not, return list of missing files.

check_classes_exists()

check_classes_exists(array  $classes = array(), boolean  $return_results = false) : mixed

Method check_classes_exists()

Check if a certain classes exist.

Parameters

array $classes

Array containing list of classes to check.

boolean $return_results

If true, return feedback.

Throws

\Exception

Error message.

Returns

mixed —

If exists, return true, if not, return list of missing classes.

check_methods()

check_methods(object  $obj, array  $methods = array(), boolean  $return_results = false) : mixed

Method check_methods()

Check if a certain methods exist.

Parameters

object $obj

Object to check.

array $methods

Array containing list of methods to check.

boolean $return_results

If true, return feedback.

Throws

\Exception

Error message.

Returns

mixed —

If exists, return true, if not, return list of missing methods.

check_properties()

check_properties(object  $obj, array  $properties = array(), boolean  $return_results = false) : mixed

Method check_properties()

Check if a certain properties exist.

Parameters

object $obj

Object to check.

array $properties

Array containing list of properties to check.

boolean $return_results

If true, return feedback.

Throws

\Exception

Error message.

Returns

mixed —

If exists, return true, if not, return list of missing properties.

check_functions()

check_functions(array  $funcs = array(), boolean  $return_results = false) : mixed

Method check_functions()

Check if a certain functions exist.

Parameters

array $funcs

Array containing list of functions to check.

boolean $return_results

If true, return feedback.

Throws

\Exception

Error message.

Returns

mixed —

If exists, return true, if not, return list of missing functions.

log_debug()

log_debug(string  $msg) 

Method log_debug()

Log error message to error log.

Parameters

string $msg

Contains the error message.

set_limit()

set_limit(integer  $timeout, integer  $mem = false) 

Method set_limit()

Set PHP Memory Limit and PHP Max Execution time values.

Parameters

integer $timeout

Contains the timeout value in seconds.

integer $mem

Contains the memory limit value in MB.