diff --git a/.idea/mainwp-child.iml b/.idea/mainwp-child.iml
deleted file mode 100644
index ef61b18..0000000
--- a/.idea/mainwp-child.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index ef004d1..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index fe6fe3f..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 9661ac7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 333632d..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $PROJECT_DIR$/composer.json
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1589946461231
-
-
- 1589946461231
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/class/class-mainwp-child-comments.php b/class/class-mainwp-child-comments.php
index 5e116c3..c24c788 100644
--- a/class/class-mainwp-child-comments.php
+++ b/class/class-mainwp-child-comments.php
@@ -1,28 +1,50 @@
comments_and_clauses = '';
}
+ /**
+ * Create a public static instance of ainWP_Child_Comments.
+ *
+ * @return MainWP_Child_Comments|null
+ */
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
@@ -30,6 +52,9 @@ class MainWP_Child_Comments {
return self::$instance;
}
+ /**
+ * MainWP Child Comment actions: approve, unapprove, spam, unspam, trash, restore, delete.
+ */
public function comment_action() {
$action = $_POST['action'];
$commentId = $_POST['id'];
@@ -59,6 +84,9 @@ class MainWP_Child_Comments {
MainWP_Helper::write( $information );
}
+ /**
+ * MainWP Child Bulk Comment actions: approve, unapprove, spam, unspam, trash, restore, delete.
+ */
public function comment_bulk_action() {
$action = $_POST['action'];
$commentIds = explode( ',', $_POST['ids'] );
@@ -89,6 +117,12 @@ class MainWP_Child_Comments {
}
+ /**
+ * Comment WHERE Clauses.
+ *
+ * @param $clauses MySQL WHERE Clause.
+ * @return array $clauses, Array of MySQL WHERE Clauses.
+ */
public function comments_clauses( $clauses ) {
if ( $this->comments_and_clauses ) {
$clauses['where'] .= ' ' . $this->comments_and_clauses;
@@ -97,7 +131,14 @@ class MainWP_Child_Comments {
return $clauses;
}
+ /**
+ * Get all comments.
+ *
+ * @return array $rslt Array of comments.
+ */
public function get_all_comments() {
+
+ /** @var global $wbdb wpdb. */
global $wpdb;
add_filter( 'comments_clauses', array( &$this, 'comments_clauses' ) );
@@ -135,6 +176,13 @@ class MainWP_Child_Comments {
MainWP_Helper::write( $rslt );
}
+ /**
+ * Get recent comments.
+ *
+ * @param $pAllowedStatuses Allowed comment statuses.
+ * @param $pCount Comment count.
+ * @return array $allComments Array of all comments found.
+ */
public function get_recent_comments( $pAllowedStatuses, $pCount ) {
if ( ! function_exists( 'get_comment_author_url' ) ) {
include_once WPINC . '/comment-template.php';
diff --git a/class/class-mainwp-child-install.php b/class/class-mainwp-child-install.php
index cef42d3..278cefc 100644
--- a/class/class-mainwp-child-install.php
+++ b/class/class-mainwp-child-install.php
@@ -279,6 +279,10 @@ class MainWP_Child_Install {
/**
* Hook to set ssl verify.
+ *
+ * @param array $r
+ * @param string $url
+ * @return array $r
*/
public static function no_ssl_filter_function( $r, $url ) {
$r['sslverify'] = false;
diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php
index 6996738..82ff964 100644
--- a/class/class-mainwp-child-plugins-check.php
+++ b/class/class-mainwp-child-plugins-check.php
@@ -11,16 +11,49 @@
namespace MainWP\Child;
+/**
+ * Class MainWP_Child_Plugins_Check
+ *
+ * @package MainWP\Child
+ */
class MainWP_Child_Plugins_Check {
+
+ /**
+ * @var string
+ */
+ private $cron_name_watcher = 'mainwp_child_cron_plugin_health_check_watcher';
+ /**
+ * @var string
+ */
+ private $cron_name_daily = 'mainwp_child_cron_plugin_health_check_daily';
+ /**
+ * @var string
+ */
+ private $cron_name_batching = 'mainwp_child_cron_plugin_health_check_batching';
+ /**
+ * @var string
+ */
+ private $tran_name_plugin_timestamps = 'mainwp_child_tran_name_plugin_timestamps';
+ /**
+ * @var string
+ */
+ private $tran_name_plugins_to_batch = 'mainwp_child_tran_name_plugins_to_batch';
+ /**
+ * @var string
+ */
+ private $option_name_last_daily_run = 'mainwp_child_plugin_last_daily_run';
+
+ /**
+ * @static
+ * @var null Holds the Public static instance of MainWP_Child_Plugins_Check.
+ */
public static $instance = null;
- private $cron_name_watcher = 'mainwp_child_cron_plugin_health_check_watcher';
- private $cron_name_daily = 'mainwp_child_cron_plugin_health_check_daily';
- private $cron_name_batching = 'mainwp_child_cron_plugin_health_check_batching';
- private $tran_name_plugin_timestamps = 'mainwp_child_tran_name_plugin_timestamps';
- private $tran_name_plugins_to_batch = 'mainwp_child_tran_name_plugins_to_batch';
- private $option_name_last_daily_run = 'mainwp_child_plugin_last_daily_run';
-
+ /**
+ * Create a public static instance of MainWP_Child_Plugins_Check.
+ *
+ * @return MainWP_Child_Plugins_Check|null
+ */
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
@@ -29,6 +62,9 @@ class MainWP_Child_Plugins_Check {
return self::$instance;
}
+ /**
+ * MainWP_Child_Plugins_Check constructor.
+ */
public function __construct() {
if ( get_option( 'mainwp_child_plugintheme_days_outdate' ) ) {
$this->schedule_watchdog();
@@ -41,6 +77,13 @@ class MainWP_Child_Plugins_Check {
}
}
+ /**
+ * Un-schedules all events attached to the hook with the specified arguments.
+ *
+ * @return int|false|bool On success an integer indicating number of events un-scheduled
+ * (0 indicates no events were registered with the hook and arguments combination),
+ * false if un-scheduling one or more events fail.
+ */
private function cleanup_basic() {
wp_clear_scheduled_hook( $this->cron_name_daily );
wp_clear_scheduled_hook( $this->cron_name_batching );
@@ -48,6 +91,14 @@ class MainWP_Child_Plugins_Check {
}
+ /**
+ * Un-schedules all events attached to the hook with the specified arguments.
+ *
+ * @param bool $del Whether or not to delete the transient data. Default: true.
+ * @return int|false|bool On success an integer indicating number of events un-scheduled
+ * (0 indicates no events were registered with the hook and arguments combination),
+ * false if un-scheduling one or more events fail.
+ */
public function cleanup_deactivation( $del = true ) {
$this->cleanup_basic();
wp_clear_scheduled_hook( $this->cron_name_watcher );
@@ -57,7 +108,13 @@ class MainWP_Child_Plugins_Check {
}
}
-
+ /**
+ * Modify plugin API Search Query.
+ *
+ * @param object $args Query arguments.
+ * @param string $action Action to perform: query_plugins.
+ * @return \stdClass $args Modified Search Query.
+ */
public function modify_plugin_api_search_query( $args, $action ) {
if ( isset( $action ) && 'query_plugins' === $action ) {
@@ -75,6 +132,11 @@ class MainWP_Child_Plugins_Check {
return $args;
}
+ /**
+ * Schedule watchdog crons.
+ *
+ * @throws \Exception Error message on failure.
+ */
public function perform_watchdog() {
if ( false === wp_next_scheduled( $this->cron_name_daily ) && false === wp_next_scheduled( $this->cron_name_batching ) ) {
$last_run = get_option( $this->option_name_last_daily_run );
@@ -98,13 +160,20 @@ class MainWP_Child_Plugins_Check {
}
}
+ /**
+ * Schedule a global watchdog cron just in case both other crons get killed.
+ */
public function schedule_watchdog() {
- // Schedule a global watching cron just in case both other crons get killed.
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
}
}
+ /**
+ * Get plugins outdated info.
+ *
+ * @return array $plugins_outdate Array of outdated plugin info.
+ */
public function get_plugins_outdate_info() {
$plugins_outdate = get_transient( $this->tran_name_plugin_timestamps );
if ( ! is_array( $plugins_outdate ) ) {
@@ -128,6 +197,9 @@ class MainWP_Child_Plugins_Check {
return $plugins_outdate;
}
+ /**
+ * Update Days out of date option.
+ */
public static function may_outdate_number_change() {
if ( isset( $_POST['numberdaysOutdatePluginTheme'] ) ) {
$days_outdate = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
@@ -140,6 +212,11 @@ class MainWP_Child_Plugins_Check {
}
}
+ /**
+ * Run plugin update check.
+ *
+ * @throws \Exception Error message on failure.
+ */
public function run_check() {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
@@ -174,6 +251,7 @@ class MainWP_Child_Plugins_Check {
}
$avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' );
+
// Grab a small number of plugins to scan.
$plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
@@ -229,10 +307,19 @@ class MainWP_Child_Plugins_Check {
}
}
+ /**
+ * Try to get response body.
+ *
+ * @param $plugin
+ * @param $second_pass
+ * @return bool|string true|false The body of the response. Empty string if no body or incorrect parameter given.
+ */
private function try_get_response_body( $plugin, $second_pass ) {
+
// Get the WordPress current version to be polite in the API call.
include ABSPATH . WPINC . '/version.php';
+ /** @var global $wp_version WordPress Version. */
global $wp_version;
// General options to be passed to wp_remote_get.
diff --git a/class/class-mainwp-child-users.php b/class/class-mainwp-child-users.php
index 1ff5959..88bf2bd 100644
--- a/class/class-mainwp-child-users.php
+++ b/class/class-mainwp-child-users.php
@@ -112,7 +112,6 @@ class MainWP_Child_Users {
MainWP_Helper::write( $information );
}
-
/**
* Get all users.
*
@@ -150,7 +149,6 @@ class MainWP_Child_Users {
return $allusers;
}
-
/**
* Get all Child Site users.
*
@@ -185,7 +183,6 @@ class MainWP_Child_Users {
MainWP_Helper::write( $allusers );
}
-
/**
* Search Child Site users.
*/
@@ -251,7 +248,6 @@ class MainWP_Child_Users {
MainWP_Helper::write( $allusers );
}
-
/**
* Edit Child Site user.
*
@@ -454,7 +450,6 @@ class MainWP_Child_Users {
return $edit_data;
}
-
/**
* New Child Site administrator password.
*
@@ -526,5 +521,4 @@ class MainWP_Child_Users {
MainWP_Helper::write( $information );
}
-
}
diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php
index 2247ea5..39468c1 100644
--- a/class/class-mainwp-child.php
+++ b/class/class-mainwp-child.php
@@ -1,5 +1,10 @@
update();
$this->load_all_options();
@@ -69,7 +99,14 @@ class MainWP_Child {
}
}
+ /**
+ * Load all MainWP Child Plugin options.
+ *
+ * @return array|bool Return array of options $alloptions[] or FALSE on failure.
+ */
public function load_all_options() {
+
+ /** @var global $wbdb wpdb. */
global $wpdb;
if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
@@ -143,6 +180,11 @@ class MainWP_Child {
}
+ /**
+ * Update MainWP Child Plugin.
+ *
+ * @return string Update verison.
+ */
public function update() {
$update_version = get_option( 'mainwp_child_update_version' );
@@ -153,14 +195,23 @@ class MainWP_Child {
MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
}
+ /**
+ * Load MainWP Child Plugin textdomains.
+ */
public function localization() {
load_plugin_textdomain( 'mainwp-child', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
}
+ /**
+ * Template redirect.
+ */
public function template_redirect() {
MainWP_Utility::instance()->maintenance_alert();
}
+ /**
+ *
+ */
public function parse_init() {
if ( isset( $_REQUEST['cloneFunc'] ) ) {
@@ -173,7 +224,9 @@ class MainWP_Child {
}
}
+ /** @var global $wp_rewrite Core class used to implement a rewrite component API. */
global $wp_rewrite;
+
$snPluginDir = basename( $this->plugin_dir );
if ( isset( $wp_rewrite->non_wp_rules[ 'wp-content/plugins/' . $snPluginDir . '/([^js\/]*)$' ] ) ) {
unset( $wp_rewrite->non_wp_rules[ 'wp-content/plugins/' . $snPluginDir . '/([^js\/]*)$' ] );
@@ -233,16 +286,25 @@ class MainWP_Child {
MainWP_Keyword_Links::instance()->parse_init_keyword_links();
}
+ /**
+ * Check login.
+ */
public function init_check_login() {
MainWP_Connect::instance()->check_login();
}
+ /**
+ * If user is administrator initiate the admin ajax.
+ */
public function admin_init() {
if ( MainWP_Helper::is_admin() && is_admin() ) {
MainWP_Clone::get()->init_ajax();
}
}
+ /**
+ * Parse MainWP Extension initiations.
+ */
private function parse_init_extensions() {
// Handle fatal errors for those init if needed.
MainWP_Child_Branding::instance()->branding_init();
@@ -261,9 +323,10 @@ class MainWP_Child {
\MainWP_Child_WPvivid_BackupRestore::instance()->init();
}
-
- /*
- * hook to deactivation child plugin action
+ /**
+ * Hook to deactivate MainWP Child Plugin.
+ *
+ * @param bool $deact Whether or not to deactivate pugin. Default: true.
*/
public function deactivation( $deact = true ) {
@@ -295,8 +358,8 @@ class MainWP_Child {
}
}
- /*
- * hook to activation child plugin action
+ /**
+ * Hook to deactivate Child Plugin.
*/
public function activation() {
$mu_plugin_enabled = apply_filters( 'mainwp_child_mu_plugin_enabled', false );
diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php
index 1bf43b5..1b8016c 100644
--- a/class/class-mainwp-clone-install.php
+++ b/class/class-mainwp-clone-install.php
@@ -1,19 +1,33 @@
file || ! file_exists( $this->file ) ) {
return false;
@@ -87,6 +111,11 @@ class MainWP_Clone_Install {
return false;
}
+ /**
+ * Test the download.
+ *
+ * @throws \Exception Error message.
+ */
public function test_download() {
if ( ! $this->file_exists( 'wp-content/' ) ) {
throw new \Exception( __( 'This is not a full backup.', 'mainwp-child' ) );
@@ -99,6 +128,12 @@ class MainWP_Clone_Install {
}
}
+ /**
+ * Check if clone config.txt exists.
+ *
+ * @param $file Config.txt file path.
+ * @return bool|string False or True on success. Return config.txt content on true.
+ */
private function file_exists( $file ) {
if ( 'extracted' === $this->file ) {
return file_get_contents( '../clone/config.txt' );
@@ -134,6 +169,11 @@ class MainWP_Clone_Install {
return false;
}
+ /**
+ * Read configuration file.
+ *
+ * @throws \Exception Error message on failure.
+ */
public function read_configuration_file() {
$configContents = $this->get_config_contents();
if ( false === $configContents ) {
@@ -153,6 +193,9 @@ class MainWP_Clone_Install {
}
}
+ /**
+ * Clean file structure after installation.
+ */
public function clean() {
$files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' );
foreach ( $files as $file ) {
@@ -180,6 +223,9 @@ class MainWP_Clone_Install {
}
}
+ /**
+ * Update wp-config.php file.
+ */
public function update_wp_config() {
$wpConfig = file_get_contents( ABSPATH . 'wp-config.php' );
$wpConfig = $this->replace_var( 'table_prefix', $this->config['prefix'], $wpConfig );
@@ -189,7 +235,14 @@ class MainWP_Clone_Install {
file_put_contents( ABSPATH . 'wp-config.php', $wpConfig );
}
+ /**
+ * Update DB options.
+ *
+ * @param $name Option name.
+ * @param $value Option value to update.
+ */
public function update_option( $name, $value ) {
+
/** @var $wpdb wpdb */
global $wpdb;
@@ -201,7 +254,14 @@ class MainWP_Clone_Install {
}
}
+ /**
+ * Database Installation.
+ *
+ * @return bool true|false.
+ * @throws \Exception Error message on failure.
+ */
public function install() {
+
/** @var $wpdb wpdb */
global $wpdb;
@@ -273,6 +333,11 @@ class MainWP_Clone_Install {
return true;
}
+ /**
+ * Get config contents.
+ *
+ * @return bool|false|mixed|string
+ */
public function get_config_contents() {
if ( 'extracted' === $this->file ) {
return file_get_contents( '../clone/config.txt' );
@@ -319,9 +384,10 @@ class MainWP_Clone_Install {
}
/**
- * Extract backup
+ * Extract backup file.
*
- * @return bool
+ * @return bool|null true or null.
+ * @throws \Exception Error message on failure.
*/
public function extract_backup() {
if ( ! $this->file || ! file_exists( $this->file ) ) {
@@ -347,9 +413,9 @@ class MainWP_Clone_Install {
}
/**
- * Extract backup using default PHP zip library
+ * Extract backup using default PHP zip library.
*
- * @return bool
+ * @return bool true|false.
*/
public function extract_zip_backup() {
$zip = new \ZipArchive();
@@ -364,6 +430,11 @@ class MainWP_Clone_Install {
return false;
}
+ /**
+ * Extract with unzip_file.
+ *
+ * @return bool true|false.
+ */
public function extract_wp_zip_backup() {
MainWP_Helper::get_wp_filesystem();
global $wp_filesystem;
@@ -380,6 +451,12 @@ class MainWP_Clone_Install {
return true;
}
+ /**
+ * Extract PCLZIP.
+ *
+ * @return bool true|false.
+ * @throws \Exception Error on failure.
+ */
public function extract_zip_pcl_backup() {
$zip = new \PclZip( $this->file );
if ( 0 === $zip->extract( PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER ) ) {
@@ -393,40 +470,46 @@ class MainWP_Clone_Install {
}
/**
- * Extract backup using zip on console
+ * Extract backup using zip on console.
*
- * @return bool
+ * @return bool true|false.
*/
public function extract_zip_console_backup() {
return false;
}
/**
- * Replace define statement to work with wp-config.php
+ * Replace define statement to work with wp-config.php.
*
- * @param string $constant The constant name
- * @param string $value The new value
- * @param string $content The PHP file content
+ * @param string $constant The constant name.
+ * @param string $value The new value.
+ * @param string $content The PHP file content.
*
- * @return string Replaced define statement with new value
+ * @return string Replaced define statement with new value.
*/
protected function replace_define( $constant, $value, $content ) {
return preg_replace( '/(define *\( *[\'"]' . $constant . '[\'"] *, *[\'"])(.*?)([\'"] *\))/is', '${1}' . $value . '${3}', $content );
}
/**
- * Replace variable value to work with wp-config.php
+ * Replace variable value to work with wp-config.php.
*
- * @param string $varname The variable name
- * @param string $value The new value
- * @param string $content The PHP file content
+ * @param string $varname The variable name.
+ * @param string $value The new value.
+ * @param string $content The PHP file content.
*
- * @return string Replaced variable value with new value
+ * @return string Replaced variable value with new value.
*/
protected function replace_var( $varname, $value, $content ) {
return preg_replace( '/(\$' . $varname . ' *= *[\'"])(.*?)([\'"] *;)/is', '${1}' . $value . '${3}', $content );
}
+ /**
+ * Recursively chmod file structure.
+ *
+ * @param $mypath Path to files.
+ * @param $arg chmod arguments.
+ */
public function recurse_chmod( $mypath, $arg ) {
$d = opendir( $mypath );
while ( ( $file = readdir( $d ) ) !== false ) {
@@ -440,20 +523,19 @@ class MainWP_Clone_Install {
}
}
-
/**
* The main loop triggered in step 5. Up here to keep it out of the way of the
* HTML. This walks every table in the db that was selected in step 3 and then
- * walks every row and column replacing all occurences of a string with another.
+ * walks every row and column replacing all occurrences of a string with another.
* We split large tables into 50,000 row blocks when dealing with them to save
- * on memmory consumption.
+ * on memory consumption.
*
- * @param mysql $connection The db connection object
- * @param string $search What we want to replace
+ * @param mysql $connection The db connection object.
+ * @param string $search What we want to replace.
* @param string $replace What we want to replace it with.
* @param array $tables The tables we want to look at.
*
- * @return array Collection of information gathered during the run.
+ * @return array Collection of information gathered during the run.
*/
public function icit_srdb_replacer( $connection, $search = '', $replace = '', $tables = array() ) {
global $guid, $exclude_cols;
@@ -550,15 +632,15 @@ class MainWP_Clone_Install {
}
/**
- * Take a serialised array and unserialise it replacing elements as needed and
- * unserialising any subordinate arrays and performing the replace on those too.
+ * Take a serialised array and un-serialize it replacing elements as needed and
+ * un-serializing any subordinate arrays and performing the replace on those too.
*
* @param string $from String we're looking to replace.
- * @param string $to What we want it to be replaced with
- * @param array $data Used to pass any subordinate arrays back to in.
+ * @param string $to What we want it to be replaced with.
+ * @param array $data Used to pass any subordinate arrays back.
* @param bool $serialised Does the array passed via $data need serialising.
*
- * @return array The original array with all elements replaced as needed.
+ * @return array The original array with all elements replaced as needed.
*/
public function recursive_unserialize_replace( $from = '', $to = '', $data = '', $serialised = false ) {
@@ -605,6 +687,11 @@ class MainWP_Clone_Install {
return $data;
}
+ /**
+ * Request clone.
+ *
+ * @return bool|void true|void.
+ */
public function request_clone_funct() {
if ( ! isset( $_REQUEST['key'] ) ) {
@@ -652,6 +739,9 @@ class MainWP_Clone_Install {
return true;
}
+ /**
+ * Create backup of clone.
+ */
private function create_clone_backup() {
MainWP_Helper::end_session();
$files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' );