\MainWP\DashboardMainWP_DB_Site_Actions

Class MainWP_DB_Site_Actions

Summary

Methods
Properties
Constants
instance()
get_option_view()
get_connected_websites()
get_disconnected_websites()
get_websites_count()
get_websites_stats_count()
get_website_option()
get_website_options_array()
update_website_option()
get_general_options_array()
update_general_option()
get_general_option()
get_websites_by_user_id()
get_sql_websites()
get_sql_websites_to_check_status()
get_sql_websites_to_check_individual_status()
get_sql_websites_by_user_id()
get_sql_websites_for_current_user()
get_sql_wp_for_current_user()
get_sql_select_wp_valid_fields()
get_websites_for_current_user()
get_sql_search_websites_for_current_user()
get_sql_where_allow_access_sites()
get_sql_where_allow_groups()
get_website_by_id()
get_sql_website_by_id()
get_websites_by_ids()
get_websites_by_group_ids()
get_websites_by_group_id()
get_sql_websites_by_group_id()
get_websites_by_group_name()
get_sql_websites_by_group_name()
get_wp_ip()
add_website()
remove_website()
update_website_values()
update_website_sync_values()
update_website()
get_websites_check_updates_count()
get_websites_count_where_dts_automatic_sync_smaller_then_start()
get_websites_last_automatic_sync()
get_websites_check_updates()
get_websites_stats_update_sql()
update_website_stats()
get_websites_by_url()
get_websites_offline_status_to_send_notice()
get_websites_to_notice_health_threshold()
get_websites_offline_check_status()
get_db_sites()
get_sites()
__construct()
get_table_name()
get_my_sql_version()
get_row_result()
get_results_result()
query()
escape()
use_mysqli()
ping()
m_query()
fetch_object()
free_result()
data_seek()
fetch_array()
num_rows()
is_result()
hook_db_install_tables()
hook_delete_site()
sync_site_actions()
add_site_action()
update_action_by_id()
get_wp_action_by_id()
delete_action_by()
delete_all_actions()
get_wp_actions()
No public properties found
No constants found
test_connection()
table_name()
$table_prefix
$wpdb
N/A
get_general_website_option()
$instance
$general_options
$possible_options
N/A

Properties

$table_prefix

$table_prefix : string

Table prefix.

Type

string

$wpdb

$wpdb : mixed

WordPress Database.

Type

mixed — WordPress Database.

$instance

$instance : mixed

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

Type

mixed — Default null

$general_options

$general_options : mixed

Private static variable to hold the single instance.

Type

mixed — Default null

$possible_options

$possible_options : array

Possible options.

Type

array

Methods

get_option_view()

get_option_view(array  $fields = array(), boolean  $default_value = true) : array

Get wp_options database table view.

Parameters

array $fields

Extra option fields.

boolean $default_value

Whether or not to get default option fields.

Returns

array —

wp_options view.

get_connected_websites()

get_connected_websites(array  $sites_ids = false) : array

Get connected child sites.

Parameters

array $sites_ids

Websites ids - option field.

Returns

array —

$connected_sites Array of connected sites.

get_disconnected_websites()

get_disconnected_websites(array  $sites_ids = false) : array

Get disconnected child sites.

Parameters

array $sites_ids

Websites ids - option field.

Returns

array —

$disc_sites Array of disonnected sites.

get_websites_count()

get_websites_count(null  $userId = null, boolean  $all_access = false) : integer

Get child site count.

Parameters

null $userId

Current user ID.

boolean $all_access

Check if user has access to all sites.

Returns

integer —

Child site count.

get_websites_stats_count()

get_websites_stats_count(array  $params = array()) 

Get child sites stats count.

Parameters

array $params

Params.

get_website_option()

get_website_option(array  $website, mixed  $option, mixed  $default_value = null) : string|null

Get Child site wp_options database table.

Parameters

array $website

Child Site array.

mixed $option

Child Site wp_options table name.

mixed $default_value

default value.

Returns

string|null —

Database query result (as string), or null on failure.

get_website_options_array()

get_website_options_array(array  $website, mixed  $options) : string|null

Get child site options.

Parameters

array $website

Child site.

mixed $options

Child site options name.

Returns

string|null —

Database query result (as string), or null on failure.

update_website_option()

update_website_option(object  $website, mixed  $option, mixed  $value) 

Update child site options.

Parameters

object $website

Child site object.

mixed $option

Option to update.

mixed $value

Value to update with.

get_general_options_array()

get_general_options_array(mixed  $options) : string|null

Get child site options.

Parameters

mixed $options

Child site options name.

Returns

string|null —

Database query result (as string), or null on failure.

update_general_option()

update_general_option(mixed  $option, mixed  $value, string  $type_value = 'single') 

Update general site options.

Parameters

mixed $option

Option to update.

mixed $value

Value to update with.

string $type_value

Type values: single|array.

get_general_option()

get_general_option(mixed  $opt, string  $type_value = 'single') : string|null

Get general Child site option.

Parameters

mixed $opt

Child Site option name.

string $type_value

Type values: single|array.

Returns

string|null —

Database query result (as string), or null on failure.

get_websites_by_user_id()

get_websites_by_user_id(integer  $userid, boolean  $selectgroups = false, null  $search_site = null, string  $orderBy = 'wp.url') : array|object|null

Get child sites by user ID.

Parameters

integer $userid

User ID.

boolean $selectgroups

Selected groups.

null $search_site

Site search field value.

string $orderBy

Order list by. Default: URL.

Returns

array|object|null —

Database query results or null on failer.

get_sql_websites()

get_sql_websites() : string

Get child sites.

Returns

string —

SQL string.

get_sql_websites_to_check_status()

get_sql_websites_to_check_status(integer  $last_check, integer  $count = 20) : string

Get child sites to run the status check process.

Parameters

integer $last_check

Time of the last check.

integer $count

Number of websites.

Returns

string —

SQL string.

get_sql_websites_to_check_individual_status()

get_sql_websites_to_check_individual_status(integer  $count = 20) : string

Get child sites to run the status individual check process.

Parameters

integer $count

Number of websites.

Returns

string —

SQL string.

get_sql_websites_by_user_id()

get_sql_websites_by_user_id(integer  $userid, boolean  $selectgroups = false, null  $search_site = null, string  $orderBy = 'wp.url', boolean  $offset = false, boolean  $rowcount = false) : object|null

Get child sites by user id via SQL.

Parameters

integer $userid

Given user ID.

boolean $selectgroups

Selected groups. Default: false.

null $search_site

Site search field value. Default: null.

string $orderBy

Order list by. Default: URL.

boolean $offset

Query offset. Default: false.

boolean $rowcount

Row count. Default: falese.

Returns

object|null —

Return database query or null on failure.

get_sql_websites_for_current_user()

get_sql_websites_for_current_user(boolean  $selectgroups = false, null  $search_site = null, string  $orderBy = 'wp.url', boolean  $offset = false, boolean  $rowcount = false, null  $extraWhere = null, boolean  $for_manager = false, mixed  $extra_view = array('favi_icon'), string  $is_staging = 'no', array  $params = array()) : object|null

Get SQL to get child sites for current user.

Parameters

boolean $selectgroups

Selected groups. Default: false.

null $search_site

Site search field value. Default: null.

string $orderBy

Order list by. Default: URL.

boolean $offset

Query offset. Default: false.

boolean $rowcount

Row count. Default: false.

null $extraWhere

Extra WHERE. Default: null.

boolean $for_manager

For role manager. Default: false.

mixed $extra_view

Extra view. Default favi_icon.

string $is_staging

yes|no Is child site a staging site.

array $params

other params.

Returns

object|null —

Database query results or null on failure.

get_sql_wp_for_current_user()

get_sql_wp_for_current_user(array  $params = array()) : object|null

Get SQL to get wp child sites for current user.

Parameters

array $params

params .

Returns

object|null —

Database query results or null on failure.

get_sql_select_wp_valid_fields()

get_sql_select_wp_valid_fields(array  $other_fields = array()) : string

Get SQL select websites fields.

Parameters

array $other_fields

extra select wp fields .

Returns

string —

sql string.

get_websites_for_current_user()

get_websites_for_current_user(array  $params = array()) : array

Get child sites for current user.

Parameters

array $params

to get sites. Default: array().

Returns

array —

Results or null on failure.

get_sql_search_websites_for_current_user()

get_sql_search_websites_for_current_user(array  $params) : boolean|null

Get the child sites the current user has searched for.

Parameters

array $params

Query parameters.

Returns

boolean|null —

$qry Database query results or null on failure.

get_sql_where_allow_access_sites()

get_sql_where_allow_access_sites(string  $site_table_alias = '', string  $is_staging = 'no') : boolean|null

Get child sites where allowed access via SQL.

Parameters

string $site_table_alias

Child site table alias.

string $is_staging

yes|no Is child site a staging site.

Returns

boolean|null —

$_where Database query results or null on failure.

get_sql_where_allow_groups()

get_sql_where_allow_groups(string  $group_table_alias = '', string  $with_staging = 'no') : boolean|null

Get groupd where allowed access via SQL.

Parameters

string $group_table_alias

Child site table alias.

string $with_staging

yes|no Is child site a staging site.

Returns

boolean|null —

$_where Database query results or null on failer.

get_website_by_id()

get_website_by_id(integer  $id, array  $selectGroups = false, array  $extra_view = array()) : object|null

Get child site by id.

Parameters

integer $id

Child site ID.

array $selectGroups

Select groups.

array $extra_view

Get extra option fields.

Returns

object|null —

Database query results or null on failure.

get_sql_website_by_id()

get_sql_website_by_id(integer  $id, boolean  $selectGroups = false, mixed  $extra_view = array()) : object|null

Get child site by id via SQL.

Parameters

integer $id

Child site ID.

boolean $selectGroups

Selected groups.

mixed $extra_view

Extra view value.

Returns

object|null —

Database query result or null on failure.

get_websites_by_ids()

get_websites_by_ids(array  $ids, integer  $userId = null) : object|null

Method get_websites_by_ids()

Get child sites by child site IDs.

Parameters

array $ids

Child site IDs.

integer $userId

User ID.

Returns

object|null —

Database query result or null on failure.

get_websites_by_group_ids()

get_websites_by_group_ids(array  $ids, integer  $userId = null) : object|null

Get child sites by groups IDs.

Parameters

array $ids

Groups IDs.

integer $userId

User ID.

Returns

object|null —

Database query result or null on failure.

get_websites_by_group_id()

get_websites_by_group_id(integer  $id) : object|null

Get child sites by group ID.

Parameters

integer $id

Group ID.

Returns

object|null —

Database query result or null on failure.

get_sql_websites_by_group_id()

get_sql_websites_by_group_id(integer  $id, boolean  $selectgroups = false, string  $orderBy = 'wp.url', boolean  $offset = false, boolean  $rowcount = false, null  $where = null, null  $search_site = null) : object|null

Get child sites by group id via SQL.

Parameters

integer $id

Group ID.

boolean $selectgroups

Selected groups. Default: false.

string $orderBy

Order list by. Default: URL.

boolean $offset

Query offset. Default: false.

boolean $rowcount

Row count. Default: falese.

null $where

SQL WHERE value.

null $search_site

Site search field value. Default: null.

Returns

object|null —

Return database query or null on failure.

get_websites_by_group_name()

get_websites_by_group_name(integer  $userid, string  $groupname) : object|null

Get child sites by group name.

Parameters

integer $userid

Current user ID.

string $groupname

Group name.

Returns

object|null —

Database query result or null on failure.

get_sql_websites_by_group_name()

get_sql_websites_by_group_name(string  $groupname, integer  $userid = null) : object|null

Get child sites by group name.

Parameters

string $groupname

Group name.

integer $userid

Current user ID.

Returns

object|null —

Database query result or null on failure.

get_wp_ip()

get_wp_ip(integer  $wpid) : string|null

Get child site IP address.

Parameters

integer $wpid

Child site ID.

Returns

string|null —

Child site IP address or null on failure.

add_website()

add_website(integer  $userid, string  $name, string  $url, string  $admin, string  $pubkey, string  $privkey, array  $groupids, array  $groupnames, integer  $verifyCertificate = 1, string  $uniqueId = '', string  $http_user = null, string  $http_pass = null, integer  $sslVersion, integer  $wpe, integer  $isStaging) : integer|false

Add website to the MainWP Dashboard.

Parameters

integer $userid

Current user ID.

string $name

Child site name.

string $url

Child site URL.

string $admin

Child site administrator username.

string $pubkey

OpenSSL public key.

string $privkey

OpenSSL private key.

array $groupids

Group IDs.

array $groupnames

Group names.

integer $verifyCertificate

Whether or not to verify SSL Certificate.

string $uniqueId

Unique security ID.

string $http_user

HTTP Basic Authentication username.

string $http_pass

HTTP Basic Authentication password.

integer $sslVersion

SSL Version.

integer $wpe

Is it WP Engine hosted site.

integer $isStaging

Whether or not child site is staging site.

Returns

integer|false —

Child site ID or false on failure.

remove_website()

remove_website(integer  $websiteid) : integer|boolean

Remove child site from the MainWP Dashboard.

Parameters

integer $websiteid

Child site ID.

Returns

integer|boolean —

Return child site ID that was removed or false on failure.

update_website_values()

update_website_values(integer  $websiteid, array  $fields) : integer|boolean

Update child site db values.

Parameters

integer $websiteid

Child site ID.

array $fields

Database fields to update.

Returns

integer|boolean —

The number of rows updated, or false on error.

update_website_sync_values()

update_website_sync_values(integer  $websiteid, array  $fields) : integer|boolean

Update child site sync values.

Parameters

integer $websiteid

Child site ID.

array $fields

Database fields to update.

Returns

integer|boolean —

The number of rows updated, or false on error.

update_website()

update_website(integer  $websiteid, string  $url, integer  $userid, string  $name, string  $siteadmin, array  $groupids, array  $groupnames, string  $pluginDir, mixed  $maximumFileDescriptorsOverride, mixed  $maximumFileDescriptorsAuto, mixed  $maximumFileDescriptors, integer  $verifyCertificate = 1, mixed  $archiveFormat = 'global', string  $uniqueId = '', string  $http_user = null, string  $http_pass = null, integer  $sslVersion, integer  $disableChecking = 1, integer  $checkInterval = 1440, boolean  $disableHealthChecking = 1, integer  $healthThreshold = 80, integer  $wpe) : boolean

Update child site.

Parameters

integer $websiteid

Website ID.

string $url

Child site URL.

integer $userid

Current user ID.

string $name

Child site name.

string $siteadmin

Child site administrator username.

array $groupids

Group IDs.

array $groupnames

Group Names.

string $pluginDir

Plugin directory.

mixed $maximumFileDescriptorsOverride

Overwrite the Maximum File Descriptors option.

mixed $maximumFileDescriptorsAuto

Auto set the Maximum File Descriptors option.

mixed $maximumFileDescriptors

Set the Maximum File Descriptors option.

integer $verifyCertificate

Whether or not to verify SSL Certificate.

mixed $archiveFormat

Backup archive formate.

string $uniqueId

Unique security ID.

string $http_user

HTTP Basic Authentication username.

string $http_pass

HTTP Basic Authentication password.

integer $sslVersion

SSL Version.

integer $disableChecking

Wether or not disable sites status checking.

integer $checkInterval

Status checking interval.

boolean $disableHealthChecking

Disable Site health threshold.

integer $healthThreshold

Site health threshold.

integer $wpe

Is it WP Engine hosted site.

Returns

boolean —

ture on success or false on failure.

get_websites_check_updates_count()

get_websites_check_updates_count(integer  $lasttime_start) : integer

Get websites check updates count.

Parameters

integer $lasttime_start

Lasttime start automatic update.

Returns

integer —

Child sites update count.

get_websites_count_where_dts_automatic_sync_smaller_then_start()

get_websites_count_where_dts_automatic_sync_smaller_then_start(integer  $lasttime_start) : integer

Get child site count where date & time Session sync is smaller then start.

Parameters

integer $lasttime_start

Last time start automatic.

Returns

integer —

Returned child site count.

get_websites_last_automatic_sync()

get_websites_last_automatic_sync() : string

Get child site last automatic sync date & time.

Returns

string —

Date and time of last automatic sync.

get_websites_check_updates()

get_websites_check_updates(integer  $limit, integer  $lasttime_start) : object|null

Get child sites check updates.

Parameters

integer $limit

Query limit.

integer $lasttime_start

Lasttime start automatic update.

Returns

object|null —

Database query result or null on failure.

get_websites_stats_update_sql()

get_websites_stats_update_sql() : object|null

Get website update stats via SQL.

Returns

object|null —

Database query result of null on failure.

update_website_stats()

update_website_stats(mixed  $websiteid, mixed  $statsUpdated) : \MainWP\Dashboard\(int|\MainWP\Dashboard\boolean)

Update child site statistics.

Update whether or not a child site has been updated.

Parameters

mixed $websiteid

Child site ID.

mixed $statsUpdated

Child site Update status.

Returns

\MainWP\Dashboard\(int|\MainWP\Dashboard\boolean) —

Number of rows effected in update or false on failure.

get_websites_by_url()

get_websites_by_url(string  $url) : object|null

Get child site by url.

Parameters

string $url

Child site URL.

Returns

object|null —

Database query result or null on failure.

get_websites_offline_status_to_send_notice()

get_websites_offline_status_to_send_notice() : array

Get websites offline status.

Returns

array —

Child site monitoring status.

get_websites_to_notice_health_threshold()

get_websites_to_notice_health_threshold(integer  $globalThreshold, integer  $count = 10) 

Method get_websites_to_notice_health_threshold()

Get websites to notice site health.

Parameters

integer $globalThreshold

Global site health threshold.

integer $count

Limit count.

get_websites_offline_check_status()

get_websites_offline_check_status() : array

Get websites offline status.

Returns

array —

Sites with offline status.

get_db_sites()

get_db_sites(mixed  $params = array()) : array

Get DB Sites.

Parameters

mixed $params

params.

Returns

array —

$dbwebsites.

get_sites()

get_sites(integer  $websiteid = null, boolean  $for_manager = false, array  $others = array()) : array

Get Sites.

Parameters

integer $websiteid

The id of the child site you wish to retrieve.

boolean $for_manager

Check Team Control.

array $others

Array of others.

Returns

array —

$output Array of content to output.

__construct()

__construct() 

Constructor.

Run each time the class is called.

get_table_name()

get_table_name(mixed  $suffix) : string

Method get_table_name()

Create entire table name.

Parameters

mixed $suffix

Table suffix.

Returns

string —

Table name.

get_my_sql_version()

get_my_sql_version() : mixed

Method get_my_sql_version()

Get MySQL Version.

Returns

mixed —

MySQL vresion.

get_row_result()

get_row_result(mixed  $sql) : mixed

Method get_row_result()

Get row result.

Parameters

mixed $sql

SQL Query.

Returns

mixed —

null|Row

get_results_result()

get_results_result(mixed  $sql) : mixed

Method get_results_result()

Get Results of result.

Parameters

mixed $sql

SQL query.

Returns

mixed —

null|get_results()

query()

query(mixed  $sql) : mixed

Method query()

SQL Query.

Parameters

mixed $sql

SQL Query.

Returns

mixed —

false|$result.

escape()

escape(mixed  $data) : mixed

Method escape()

Escape SQL Data.

Parameters

mixed $data

Data to escape.

Returns

mixed —

Escapped SQL Data.

use_mysqli()

use_mysqli() : boolean|self

Method use_mysqli()

Use MySQLi, Support old & new versions of WordPress (3.9+).

Returns

boolean|self —

false|$instance Instance of \mysqli

ping()

ping(mixed  $link) : mixed

Method ping()

Ping MySQLi.

Parameters

mixed $link

Query link.

Returns

mixed —

\mysqli_ping

m_query()

m_query(mixed  $query, mixed  $link) : mixed

Method m_query()

MySQLi m_query.

Parameters

mixed $query

Query params.

mixed $link

Query link.

Returns

mixed —

\mysqli_query

fetch_object()

fetch_object(mixed  $result) : boolean|mixed

Method fetch_object()

Fetch object.

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_fetch_object

free_result()

free_result(mixed  $result) : boolean|mixed

Method free_result()

MySQLi free result.

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_free_result

data_seek()

data_seek(mixed  $result, mixed  $offset) : boolean|mixed

Method data_seek()

MySQLi data seek.

Parameters

mixed $result

Query result.

mixed $offset

Query offset.

Returns

boolean|mixed —

false|\mysqli_data_seek

fetch_array()

fetch_array(mixed  $result, null  $result_type = null) : boolean|mixed

Method fetch_array()

MySQLi fetch array.

Parameters

mixed $result

Query result.

null $result_type

Query result type.

Returns

boolean|mixed —

false|\mysqli_fetch_array.

num_rows()

num_rows(mixed  $result) : boolean|mixed

Method num_rows()

MySQLi number of rows.

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_num_rows.

is_result()

is_result(mixed  $result) : boolean|mixed

Method is_result()

Return instance of \mysqli_result

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_result

hook_db_install_tables()

hook_db_install_tables(array  $sql, string  $currentVersion, string  $charset_collate) : array

Method hook_db_install_tables()

Get the query to install db tables.

Parameters

array $sql

input filter.

string $currentVersion

Current db Version.

string $charset_collate

charset collate.

Returns

array —

$sql queries.

hook_delete_site()

hook_delete_site(mixed  $site) : boolean

Method hook_delete_site()

Installs the new DB.

Parameters

mixed $site

site object.

Returns

boolean —

result.

sync_site_actions()

sync_site_actions(integer  $site_id, array  $sync_actions) : boolean

Method sync_site_actions().

Sync site actions data.

Parameters

integer $site_id

site id.

array $sync_actions

action data.

Returns

boolean

add_site_action()

add_site_action(array  $data) : boolean

Method add_new_action.

Add new action.

Parameters

array $data

action data.

Returns

boolean

update_action_by_id()

update_action_by_id(array  $action_id, array  $data) : boolean

Method update_action_by_id.

Create or update action.

Parameters

array $action_id

action id.

array $data

action data.

Returns

boolean

get_wp_action_by_id()

get_wp_action_by_id(array  $action_id) : boolean

Method update_action.

Create or update action.

Parameters

array $action_id

action id.

Returns

boolean

delete_action_by()

delete_action_by(string  $by = 'action_id', mixed  $value = null) : boolean

Method delete_action_by.

Delete action by.

Parameters

string $by

By what.

mixed $value

By value.

Returns

boolean —

Results.

delete_all_actions()

delete_all_actions() : boolean

Method delete_all_actions.

Deletes all actions.

Returns

boolean —

Results.

get_wp_actions()

get_wp_actions(boolean  $params = array(), mixed  $obj = OBJECT) : mixed

Method get_wp_actions.

Get wp actions.

Parameters

boolean $params

params.

mixed $obj

Format data.

Returns

mixed —

$result result.

test_connection()

test_connection() 

Method test_connection()

Test db connection.

table_name()

table_name(mixed  $suffix, null  $tablePrefix = null) : string

Method table_name()

Create entire table name.

Parameters

mixed $suffix

Table suffix.

null $tablePrefix

Table prefix.

Returns

string —

Table name.

get_general_website_option()

get_general_website_option(mixed  $option) : string|null

Get general Child site option.

Parameters

mixed $option

Child Site option name.

Returns

string|null —

Database query result (as string), or null on failure.