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.

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.

Returns

array —

Return directory and directory URL.

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  $array, string  $key) : mixed

Method search()

Nested search field value in an array or object.

Parameters

array|object $array

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, string  $url) : array

Method reject_unsafe_urls()

Reject unsafe URLs in HTTP Basic Authentication handler.

Parameters

array $r

Array containing the request data.

string $url

URL to check.

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  $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') : string

Method rand_string()

Generate random string.

Parameters

integer $length

Contains the string lenghts.

string $charset

Contain all allowed characters for the generated string.

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) : 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') : mixed

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

mixed —

$success Option updated.

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() : boolean

Method is_admin()

Check if the current user is administrator.

Returns

boolean —

true|false If the current 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.

check_files_exists()

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

Method check_files_exists()

Check if a certain files exist.

Parameters

array $files

Array containing list of files to check.

boolean $return

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 = false) : mixed

Method check_classes_exists()

Check if a certain classes exist.

Parameters

array $classes

Array containing list of classes to check.

boolean $return

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  $object, array  $methods = array(), boolean  $return = false) : mixed

Method check_methods()

Check if a certain methods exist.

Parameters

object $object

Object to check.

array $methods

Array containing list of methods to check.

boolean $return

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  $object, array  $properties = array(), boolean  $return = false) : mixed

Method check_properties()

Check if a certain properties exist.

Parameters

object $object

Object to check.

array $properties

Array containing list of properties to check.

boolean $return

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 = false) : mixed

Method check_functions()

Check if a certain functions exist.

Parameters

array $funcs

Array containing list of functions to check.

boolean $return

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.