Properties

$instance

$instance : mixed

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

Type

mixed — Default null

$mail_from

$mail_from : mixed

Public variable to hold the mail from.

Type

mixed — Default empty.

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.

run_saved_snippets()

run_saved_snippets() : void

Method run_saved_snippets()

Fire off MainWP Code Snippets Extension code snipets execution.

execute_snippet()

execute_snippet(string  $code) : array

Method execute_snippet()

Execute MainWP Code Snippets Extension custom code snippets.

Parameters

string $code

Custom code snippet code (content).

Returns

array —

Array contaning result information.

fix_for_custom_themes()

fix_for_custom_themes() 

Method fix_for_custom_themes()

Custom fix for the Elegant Themes products compatibility.

send_wp_mail()

send_wp_mail(string|array  $to, string  $subject, string  $message, string|array  $headers = '') : boolean

Method send_wp_mail()

Sends notification email.

Parameters

string|array $to

Array or comma-separated list of email addresses to send message.

string $subject

Email subject.

string $message

Message contents.

string|array $headers

Optional. Additional headers.

Returns

boolean —

Whether the email contents were sent successfully.

handle_shutdown()

handle_shutdown() 

Method handle_shutdown()

Handle fatal and compile errors.

handle_fatal_error()

handle_fatal_error() 

Method handle_fatal_error()

Handle fatal error for requests from the MainWP Dashboard.

cron_active()

cron_active() : void

Method cron_active()

Start job if in cron and run query args are set.

upload_file_backup()

upload_file_backup(mixed  $file, integer  $offset) 

Method upload_file()

Upload bacup fils to execute clone or restore proces.

Parameters

mixed $file

Backup file.

integer $offset

Offset value.

upload_file()

upload_file(mixed  $file, mixed|false  $dir = false, integer  $offset) 

Method upload_file()

Upload bacup fils to execute clone or restore proces.

Parameters

mixed $file

Backup file.

mixed|false $dir

dir value.

integer $offset

Offset value.

readfile_chunked()

readfile_chunked(string  $filename, integer  $offset) : mixed

Method readfile_chunked()

Read chunked backup file.

Parameters

string $filename

Backup file name.

integer $offset

Offset value.

Returns

mixed —

Close file.

upload_image()

upload_image(string  $img_url, array  $img_data = array(), boolean  $check_file_existed = false, integer  $parent_id) : null

Method upload_image()

Upload images from the MainWP Dashboard while posting Posts and/or Pages.

Parameters

string $img_url

Contains image URL.

array $img_data

Contains image data.

boolean $check_file_existed

Does the file exist? True or false.

integer $parent_id

Attachment parent post ID.

Throws

\Exception

Error message.

Returns

null —

NULL

check_image_file_name()

check_image_file_name(string  $filename) : true|false

Method check_image_file_name()

Check if the file image.

Parameters

string $filename

Contains image (file) name.

Returns

true|false —

valid name or not.

get_maybe_existed_attached_id()

get_maybe_existed_attached_id(string  $filename, boolean  $full_guid = true) : integer

Method get_maybe_existed_attached_id()

If the media file exists, get the attachment ID.

Parameters

string $filename

Contains the media file name.

boolean $full_guid

Full global unique identifier.

Returns

integer —

Attachment ID.

fetch_url()

fetch_url(string  $url, array  $postdata) 

Method fetch_url()

Fire off the m_fetch_url() to execute communication with the MainWP Dashboard.

Parameters

string $url

Contains the URL.

array $postdata

Array containg the post request information.

Throws

string

$e Error message.

m_fetch_url()

m_fetch_url(string  $url, array  $postdata) 

Method fetch_url()

Execute communication with the MainWP Dashboard.

Parameters

string $url

Contains the URL.

array $postdata

Array containg the post request information.

Throws

\Exception

Error message.

validate_mainwp_dir()

validate_mainwp_dir() : boolean

Method validate_mainwp_dir()

Check if the /mainwp/ directory is writable.

Returns

boolean —

$done Is the /mainwp/ directory writable? True or false.

close_connection()

close_connection(array  $val = null) 

Method close_connection()

Close connection.

Parameters

array $val

Array containing connection information.

send_maintenance_alert()

send_maintenance_alert() 

Method send_maintenance_alert()

MainWP Maintenance Extension feature to send email notification for 404 (Page not found) errors.

send_support_mail()

send_support_mail() : boolean

Send support email.

Returns

boolean —

Return TRUE on success FALSE on failure.

hook_wp_mail_from()

hook_wp_mail_from(mixed  $from_name) : mixed

Method hook_wp_mail_from()

Hook hook_wp_mail.

Parameters

mixed $from_name

From email.

Returns

mixed —

$from_name From email.

create_nonce_without_session()

create_nonce_without_session(mixed  $action = -1) : string

Method create_nonce_without_session()

Create nonce without session.

Parameters

mixed $action

Action to perform.

Returns

string —

Custom nonce.

verify_nonce_without_session()

verify_nonce_without_session(string  $nonce, mixed  $action = -1) : mixed

Method verify_nonce_without_session()

Verify nonce without session.

Parameters

string $nonce

Nonce to verify.

mixed $action

Action to perform.

Returns

mixed —

If verified return 1 or 2, if not return false.

hook_get_ping_nonce()

hook_get_ping_nonce() : string

Method hook_get_ping_nonce()

Get mainwp ping nonce.

Returns

string —

nonce.

hook_create_nonce_action()

hook_create_nonce_action(boolean  $false_value, mixed  $action = -1) : string

Method hook_create_nonce_action()

Create nonce without session and user id.

Parameters

boolean $false_value

Boolean value, it should always be FALSE.

mixed $action

Action to perform.

Returns

string —

Custom nonce.

create_nonce_action()

create_nonce_action(mixed  $action = -1) : string

Method create_nonce_action()

Create nonce without session and user id.

Parameters

mixed $action

Action to perform.

Returns

string —

Custom nonce.

hook_verify_authed_action_nonce()

hook_verify_authed_action_nonce(boolean  $false_value, string  $act_nonce = '') : mixed

Method hook_verify_authed_action_nonce()

Verify nonce without session and user id.

Parameters

boolean $false_value

Boolean value, it should always be FALSE.

string $act_nonce

Nonce action to verify.

Returns

mixed —

If verified return 1 or 2, if not return false.

verify_action_nonce()

verify_action_nonce(string  $act_nonce = '') : mixed

Method verify_action_nonce()

Verify nonce without session and user id.

Parameters

string $act_nonce

Nonce action to verify.

Returns

mixed —

If verified return 1 or 2, if not return false.

verify_authed_nonce()

verify_authed_nonce(string  $nonce, mixed  $action = -1) : mixed

Method verify_authed_nonce()

Verify nonce without session and user id.

Parameters

string $nonce

Nonce to verify.

mixed $action

Action to perform.

Returns

mixed —

If verified return 1 or 2, if not return false.

update_lasttime_backup()

update_lasttime_backup(string  $by, string  $time) : boolean

Method update_lasttime_backup()

Update the last backup timestap.

Parameters

string $by

Selected backup system.

string $time

Time of the backup exacution.

Returns

boolean —

true|false If updated, return true, if the last backup time not updated, return false.

get_lasttime_backup()

get_lasttime_backup(string  $by) : mixed

Method get_lasttime_backup()

Get the last backup timestap.

Parameters

string $by

Selected backup system.

Returns

mixed —

If activated any of the supported backup systems, return the last backup timestamp.

remove_filters_by_hook_name()

remove_filters_by_hook_name(string  $hook_name = '', integer  $priority) : boolean

Method remove_filters_by_hook_name()

Remove filters with method name.

Parameters

string $hook_name

Contains the hook name.

integer $priority

Contains the priority value.

Returns

boolean —

Return false if filtr is not set.

get_roles()

get_roles() : array

Get an array of user roles

Returns

array

maybe_base64_decode()

maybe_base64_decode(string  $str) : string

Method maybe_base64_decode()

Maybe base64 decode string.

Parameters

string $str

input string.

Returns

string —

$decoded Maybe base64 decode string.

esc_content()

esc_content(mixed  $content, string  $type = 'note', mixed  $more_allowed = array()) : string

Method esc_content()

Escape content, allowed content (a,href,title,br,em,strong,p,hr,ul,ol,li,h1,h2 ... ).

Parameters

mixed $content

Content to escape.

string $type

Type of content. Default = note.

mixed $more_allowed

input allowed tags - options.

Returns

string —

Filtered content containing only the allowed HTML.

encrypt_decrypt()

encrypt_decrypt(string  $str, boolean  $encrypt = true) : string

Encrypt or Decrypt.

Parameters

string $str

String input.

boolean $encrypt

True to encrypt, FAlSE to decrypt.

Returns

string —

Encrypted string.

right_array_merge()

right_array_merge(array  $left_array, array  $right_array) : array

Merge values from right array to left array.

Parameters

array $left_array

left array.

array $right_array

right array.

Returns

array —

$result result array.

check_media_file_existed()

check_media_file_existed(string  $upload_dir, string  $filename, resource  $temporary_file, string  $local_img_path, string  $local_img_url) : array

Method check_media_file_existed()

Check if the media file already exists.

Parameters

string $upload_dir

Contains upload directory path.

string $filename

Contains image (file) name.

resource $temporary_file

Temporary file.

string $local_img_path

Local media file path.

string $local_img_url

Local media file URL.

Returns

array —

Media file ID and URL.

insert_attachment_media()

insert_attachment_media(array  $img_data, string  $img_url, integer  $parent_id, string  $local_img_path, string  $local_img_url) : array

Method insert_attachment_media()

Insterd attachment media.

Parameters

array $img_data

Array containing image data.

string $img_url

Contains the media file URL.

integer $parent_id

Attachment parent post ID.

string $local_img_path

Contains the local media file path.

string $local_img_url

Contains the local media file URL.

Returns

array —

Media file ID and URL.