From 807efc6452c21a7d0a89ad7a95d6ffac41a6a34d Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Wed, 26 Feb 2020 22:04:44 -0700 Subject: [PATCH 01/98] Create test-case.php --- tests/test-case.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test-case.php diff --git a/tests/test-case.php b/tests/test-case.php new file mode 100644 index 0000000..3ef8b48 --- /dev/null +++ b/tests/test-case.php @@ -0,0 +1,20 @@ + Date: Wed, 26 Feb 2020 22:20:13 -0700 Subject: [PATCH 02/98] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 84be180..d9e6486 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,6 @@ matrix: env: WP_VERSION=latest - php: 5.6 env: WP_VERSION=latest - - php: 5.6 - env: WP_VERSION=trunk dist: precise before_script: From 9421a7550a92aec0325c28f5483190d054681504 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2020 14:16:18 +0000 Subject: [PATCH 03/98] Bump wp-cli/wp-cli from 2.4.0 to 2.4.1 Bumps [wp-cli/wp-cli](https://github.com/wp-cli/wp-cli) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/wp-cli/wp-cli/releases) - [Commits](https://github.com/wp-cli/wp-cli/compare/v2.4.0...v2.4.1) Signed-off-by: dependabot-preview[bot] --- composer.lock | 76 +++++++++------------------------------------------ 1 file changed, 13 insertions(+), 63 deletions(-) diff --git a/composer.lock b/composer.lock index d5ca6fb..a58bf1a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a964220680db8aa4990a65c395fc0bd6", + "content-hash": "56eb205466c5010b883f6f55fe6017ad", "packages": [ { "name": "composer/installers", @@ -132,50 +132,6 @@ } ], "packages-dev": [ - { - "name": "cweagans/composer-patches", - "version": "1.6.7", - "source": { - "type": "git", - "url": "https://github.com/cweagans/composer-patches.git", - "reference": "2e6f72a2ad8d59cd7e2b729f218bf42adb14f590" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/2e6f72a2ad8d59cd7e2b729f218bf42adb14f590", - "reference": "2e6f72a2ad8d59cd7e2b729f218bf42adb14f590", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0", - "php": ">=5.3.0" - }, - "require-dev": { - "composer/composer": "~1.0", - "phpunit/phpunit": "~4.6" - }, - "type": "composer-plugin", - "extra": { - "class": "cweagans\\Composer\\Patches" - }, - "autoload": { - "psr-4": { - "cweagans\\Composer\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Cameron Eagans", - "email": "me@cweagans.net" - } - ], - "description": "Provides a way to patch Composer packages.", - "time": "2019-08-29T20:11:49+00:00" - }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v0.5.0", @@ -1923,16 +1879,16 @@ }, { "name": "symfony/finder", - "version": "v5.0.4", + "version": "v5.0.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "4176e7cb846fe08f32518b7e0ed8462e2db8d9bb" + "reference": "6251f201187ca9d66f6b099d3de65d279e971138" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/4176e7cb846fe08f32518b7e0ed8462e2db8d9bb", - "reference": "4176e7cb846fe08f32518b7e0ed8462e2db8d9bb", + "url": "https://api.github.com/repos/symfony/finder/zipball/6251f201187ca9d66f6b099d3de65d279e971138", + "reference": "6251f201187ca9d66f6b099d3de65d279e971138", "shasum": "" }, "require": { @@ -1968,7 +1924,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-01-04T14:08:26+00:00" + "time": "2020-02-14T07:43:07+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2289,22 +2245,21 @@ }, { "name": "wp-cli/wp-cli", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/wp-cli/wp-cli.git", - "reference": "74c949c74708e3a88ad0add70f3236c8675dfd85" + "reference": "ceb18598e79befa9b2a37a51efbb34910628988b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/74c949c74708e3a88ad0add70f3236c8675dfd85", - "reference": "74c949c74708e3a88ad0add70f3236c8675dfd85", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/ceb18598e79befa9b2a37a51efbb34910628988b", + "reference": "ceb18598e79befa9b2a37a51efbb34910628988b", "shasum": "" }, "require": { - "cweagans/composer-patches": "^1.6", "ext-curl": "*", - "mustache/mustache": "~2.4", + "mustache/mustache": "~2.13", "php": "^5.4 || ^7.0", "rmccue/requests": "~1.6", "symfony/finder": ">2.7", @@ -2331,11 +2286,6 @@ "extra": { "branch-alias": { "dev-master": "2.4.x-dev" - }, - "patches": { - "mustache/mustache": { - "Avoid notices on PHP 7.4+": "https://patch-diff.githubusercontent.com/raw/bobthecow/mustache.php/pull/349.patch" - } } }, "autoload": { @@ -2353,7 +2303,7 @@ "cli", "wordpress" ], - "time": "2019-11-12T15:26:05+00:00" + "time": "2020-02-18T08:15:37+00:00" }, { "name": "wp-coding-standards/wpcs", @@ -2402,7 +2352,7 @@ } ], "aliases": [], - "minimum-stability": "stable", + "minimum-stability": "dev", "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, From 85634244e6a686059c5450ee2e29b8e04ea76fa6 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Wed, 4 Mar 2020 19:54:14 -0500 Subject: [PATCH 04/98] Delete .phpcs.xml.dist No longer needed per Sebastion --- .phpcs.xml.dist | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .phpcs.xml.dist diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist deleted file mode 100644 index 067d574..0000000 --- a/.phpcs.xml.dist +++ /dev/null @@ -1,49 +0,0 @@ - - - Generally-applicable sniffs for WordPress plugins. - - - . - /vendor/ - /node_modules/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From e88f5e5df57b85aee9aae45ff91b0468cbd61112 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Wed, 4 Mar 2020 19:46:05 -0700 Subject: [PATCH 05/98] Delete phpunit.xml.dist --- phpunit.xml.dist | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 16a3902..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - ./tests/ - ./tests/test-sample.php - - - From b1528812cfcab5c3478a3c7a031b145b0007a1bc Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Wed, 4 Mar 2020 20:11:48 -0700 Subject: [PATCH 06/98] Delete test-case.php --- tests/test-case.php | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 tests/test-case.php diff --git a/tests/test-case.php b/tests/test-case.php deleted file mode 100644 index 3ef8b48..0000000 --- a/tests/test-case.php +++ /dev/null @@ -1,20 +0,0 @@ - Date: Wed, 4 Mar 2020 20:16:52 -0700 Subject: [PATCH 07/98] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 482d042..31a472b 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "prefer-stable": true, "config": { "platform": { - "php": "7.3" + "php": "7.4" }, "preferred-install": "dist", "sort-packages": true From 152028bf59db0e7c8c64cc4ad00c4091f707ee8f Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Sat, 7 Mar 2020 21:39:33 -0700 Subject: [PATCH 08/98] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9e6486..aa0a1b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,6 @@ matrix: env: WP_VERSION=latest - php: 7.0 env: WP_VERSION=latest - - php: 5.6 - env: WP_VERSION=latest dist: precise before_script: From e5fcdcd4304b72002bcfd47c3a8bdb6a87e49a0a Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Sat, 7 Mar 2020 21:48:22 -0700 Subject: [PATCH 09/98] Update .travis.yml --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index aa0a1b9..ba966a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,10 @@ matrix: include: - php: 7.4 env: WP_VERSION=latest + - php: 7.4 + env: WP_VERSION=trunk + - php: 7.4 + env: WP_TRAVISCI=phpcs - php: 7.3 env: WP_VERSION=latest - php: 7.2 From 88c666c332a4b767e9e64ea2b8176151fbf14b64 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Sat, 7 Mar 2020 21:51:57 -0700 Subject: [PATCH 10/98] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 31a472b..65cc422 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require": { "composer/installers": "^1.6", - "php": ">=5.6|>=7.0" + "php": ">=5.6|>=7.4" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.5", From 880d216ae9bf0ed4da5fdc8d9af7610f6ce6ad54 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Sat, 7 Mar 2020 21:59:56 -0700 Subject: [PATCH 11/98] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 65cc422..31a472b 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require": { "composer/installers": "^1.6", - "php": ">=5.6|>=7.4" + "php": ">=5.6|>=7.0" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.5", From 0cd29bafebf803d3283bb2273b2bd397c6ce8d4f Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Mon, 9 Mar 2020 11:24:44 -0600 Subject: [PATCH 12/98] Update .travis.yml --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba966a9..baa2f3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,11 +19,7 @@ cache: matrix: include: - php: 7.4 - env: WP_VERSION=latest - - php: 7.4 - env: WP_VERSION=trunk - - php: 7.4 - env: WP_TRAVISCI=phpcs + env: WP_TRAVISCI=phpcs WP_VERSION=latest - php: 7.3 env: WP_VERSION=latest - php: 7.2 @@ -32,8 +28,12 @@ matrix: env: WP_VERSION=latest - php: 7.0 env: WP_VERSION=latest + - php: 7.4 + env: WP_VERSION=trunk + - php: nightly + env: WP_VERSION=trunk dist: precise - + before_script: - export PATH="$HOME/.composer/vendor/bin:$PATH" - | From 6683ce6492f355158123db94aa663f181439820a Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Mon, 9 Mar 2020 11:29:40 -0600 Subject: [PATCH 13/98] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index baa2f3b..ac13d7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ matrix: env: WP_VERSION=trunk - php: nightly env: WP_VERSION=trunk - dist: precise + dist: xenial before_script: - export PATH="$HOME/.composer/vendor/bin:$PATH" From 07094fed0dc4dd6d87de38abd9a5a692ff6e7237 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Mon, 9 Mar 2020 11:32:29 -0600 Subject: [PATCH 14/98] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ac13d7d..b176592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false -dist: trusty +dist: xenial language: php @@ -32,7 +32,6 @@ matrix: env: WP_VERSION=trunk - php: nightly env: WP_VERSION=trunk - dist: xenial before_script: - export PATH="$HOME/.composer/vendor/bin:$PATH" From cbe5efaaa95ab63095b05c96a53242780e2f392f Mon Sep 17 00:00:00 2001 From: wpvivid-com <61955919+wpvivid-com@users.noreply.github.com> Date: Tue, 10 Mar 2020 14:42:38 +0800 Subject: [PATCH 15/98] Integrate WPvivid into Client Reports wpvivid_backup is added in line 105. --- class/class-mainwp-client-report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/class-mainwp-client-report.php b/class/class-mainwp-client-report.php index cf62aa7..65134a1 100644 --- a/class/class-mainwp-client-report.php +++ b/class/class-mainwp-client-report.php @@ -102,7 +102,7 @@ class MainWP_Client_Report { } public function is_backup_action( $action ) { - if ( in_array( $action, array( 'mainwp_backup', 'backupbuddy_backup', 'backupwordpress_backup', 'backwpup_backup', 'updraftplus_backup', 'wptimecapsule_backup' ) ) ) + if ( in_array( $action, array( 'mainwp_backup', 'backupbuddy_backup', 'backupwordpress_backup', 'backwpup_backup', 'updraftplus_backup', 'wptimecapsule_backup', 'wpvivid_backup' ) ) ) return true; return false; } From 81d2ca850bff320b15674e7b4c5832a8914b309a Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Wed, 11 Mar 2020 16:22:09 -0600 Subject: [PATCH 16/98] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b176592..0e6103f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,6 @@ matrix: env: WP_VERSION=latest - php: 7.4 env: WP_VERSION=trunk - - php: nightly - env: WP_VERSION=trunk before_script: - export PATH="$HOME/.composer/vendor/bin:$PATH" From e43bc66cbb91a145dd51f085ef14924462b95201 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Fri, 13 Mar 2020 22:04:10 -0600 Subject: [PATCH 17/98] Update composer.json --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 31a472b..e29b3ec 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,6 @@ "phpcompatibility/php-compatibility": "^9.0", "phpunit/phpunit": "^6.5", "wp-cli/wp-cli": "^2.0", - "wp-coding-standards/wpcs": "^2.2.0" }, "autoload-dev": { "classmap": [ From 19db8afaabb5b73993c3e6e74326f06d4e1220dd Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Fri, 13 Mar 2020 22:08:44 -0600 Subject: [PATCH 18/98] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e29b3ec..3cafdc8 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "dealerdirect/phpcodesniffer-composer-installer": "^0.5", "phpcompatibility/php-compatibility": "^9.0", "phpunit/phpunit": "^6.5", - "wp-cli/wp-cli": "^2.0", + "wp-cli/wp-cli": "^2.0" }, "autoload-dev": { "classmap": [ From c380dd6a216bd0fa09a55c351e6dce4040fd8763 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Sun, 15 Mar 2020 12:51:56 -0600 Subject: [PATCH 19/98] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e6103f..769a300 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,6 @@ matrix: env: WP_VERSION=latest - php: 7.0 env: WP_VERSION=latest - - php: 7.4 - env: WP_VERSION=trunk before_script: - export PATH="$HOME/.composer/vendor/bin:$PATH" From 2edfca5d848b33b54c863746d9446b5990f10493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Tue, 17 Mar 2020 17:17:34 +0100 Subject: [PATCH 20/98] Create phpcs.xml.dist --- phpcs.xml.dist | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 phpcs.xml.dist diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..46243bb --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,59 @@ + + + + The Coding standard for the WordPress Coding Standards itself. + + . + + + + + + + */vendor/* + */bin/* + */.github/* + */tests/* + + */vendor/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /WordPress/AbstractClassRestrictionsSniff\.php$ + + + From 63466df20f21333938b40664e0d0270ed29ee51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Tue, 17 Mar 2020 18:00:46 +0100 Subject: [PATCH 21/98] Removed: invalid ignore rules --- phpcs.xml.dist | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 46243bb..3adf2c6 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -10,12 +10,9 @@ - */vendor/* */bin/* */.github/* */tests/* - - */vendor/* From 3c5bd79c2b09a48a05e3412a200ff06d17c9bc39 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Tue, 17 Mar 2020 14:39:20 -0400 Subject: [PATCH 22/98] Rename phpcs.xml.dist to .phpcs.xml.dist --- phpcs.xml.dist => .phpcs.xml.dist | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename phpcs.xml.dist => .phpcs.xml.dist (100%) diff --git a/phpcs.xml.dist b/.phpcs.xml.dist similarity index 100% rename from phpcs.xml.dist rename to .phpcs.xml.dist From 2802274c71165a4d74d392ab98ba6361a2622dc9 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Tue, 17 Mar 2020 18:40:10 +0000 Subject: [PATCH 23/98] [CodeFactor] Apply fixes to commit 3c5bd79 [ci skip] [skip ci] --- class/class-mainwp-client-report.php | 728 ++++++++++++++------------- 1 file changed, 366 insertions(+), 362 deletions(-) diff --git a/class/class-mainwp-client-report.php b/class/class-mainwp-client-report.php index 65134a1..5ef2ed6 100644 --- a/class/class-mainwp-client-report.php +++ b/class/class-mainwp-client-report.php @@ -1,48 +1,49 @@ do_reports_log( $ext ); break; @@ -55,7 +56,7 @@ class MainWP_Client_Report { case 'wordfence': MainWP_Child_Wordfence::Instance()->do_reports_log( $ext ); break; - case 'wptimecapsule': + case 'wptimecapsule': MainWP_Child_Timecapsule::Instance()->do_reports_log( $ext ); break; } @@ -63,9 +64,9 @@ class MainWP_Client_Report { public function action() { - $information = array(); + $information = array(); - if ( !function_exists( 'wp_mainwp_stream_get_instance' ) ) { + if ( ! function_exists( 'wp_mainwp_stream_get_instance' ) ) { $information['error'] = __( 'Error: No MainWP Client Reports plugin installed.' ); MainWP_Helper::write( $information ); } @@ -89,8 +90,8 @@ class MainWP_Client_Report { MainWP_Helper::write( $information ); } - public function save_sucuri_stream() { - $scan_data = isset($_POST['scan_data']) ? $_POST['scan_data'] : ''; + public function save_sucuri_stream() { + $scan_data = isset($_POST['scan_data']) ? $_POST['scan_data'] : ''; do_action( 'mainwp_reports_sucuri_scan', $_POST['result'], $_POST['scan_status'], $scan_data, isset($_POST['scan_time']) ? $_POST['scan_time'] : 0 ); return true; } @@ -100,103 +101,108 @@ class MainWP_Client_Report { return true; } - + public function is_backup_action( $action ) { - if ( in_array( $action, array( 'mainwp_backup', 'backupbuddy_backup', 'backupwordpress_backup', 'backwpup_backup', 'updraftplus_backup', 'wptimecapsule_backup', 'wpvivid_backup' ) ) ) + if ( in_array( $action, array( 'mainwp_backup', 'backupbuddy_backup', 'backupwordpress_backup', 'backwpup_backup', 'updraftplus_backup', 'wptimecapsule_backup', 'wpvivid_backup' ) ) ) { return true; - return false; + } + return false; } - - public function get_compatible_context( $context ) { + + public function get_compatible_context( $context ) { // convert context name of tokens to context name saved in child report - // some context are not difference - $mapping_contexts = array( - 'comment' => 'comments', // actual context values: post,page - 'plugin' => 'plugins', - 'users' => 'profiles', - 'user' => 'profiles', - 'session' => 'sessions', - 'setting' => 'settings', - 'theme' => 'themes', - 'posts' => 'post', - 'pages' => 'page', - 'widgets' => 'widgets', - 'widget' => 'widgets', - 'menu' => 'menus', - 'backups' => 'backups', - 'backup' => 'backups', - 'sucuri' => 'sucuri_scan', + // some context are not difference + $mapping_contexts = array( + 'comment' => 'comments', // actual context values: post,page + 'plugin' => 'plugins', + 'users' => 'profiles', + 'user' => 'profiles', + 'session' => 'sessions', + 'setting' => 'settings', + 'theme' => 'themes', + 'posts' => 'post', + 'pages' => 'page', + 'widgets' => 'widgets', + 'widget' => 'widgets', + 'menu' => 'menus', + 'backups' => 'backups', + 'backup' => 'backups', + 'sucuri' => 'sucuri_scan', 'maintenance' => 'mainwp_maintenance', - 'wordfence' => 'wordfence_scan', - 'backups' => 'backups', - 'backup' => 'backups', - 'media' => 'media' + 'wordfence' => 'wordfence_scan', + 'backups' => 'backups', + 'backup' => 'backups', + 'media' => 'media', ); - - $context = isset( $mapping_contexts[ $context ] ) ? $mapping_contexts[ $context ] : $context; + + $context = isset( $mapping_contexts[ $context ] ) ? $mapping_contexts[ $context ] : $context; return strtolower($context); } - - + + public function get_connector_by_compatible_context( $context ) { - - $connector = ""; - if ( $context == "plugins" || $context == "themes" || $context == "wordpress" ) { - $connector = "installer"; - } else if ( $context == 'profiles' ) { - $connector = "users"; - } else if ( $context == 'comments' ) { // multi values - $connector = "comments"; - } -// else if ( $context == 'sessions' ) { -// $connector = "users"; -// } - else if ( $context == 'settings' ) { - $connector = "settings"; - } else if ( $context == 'post' || $context == 'page') { - $connector = "posts"; - } else if ( $context == 'widgets' ) { - $connector = "widgets"; - } else if ( $context == 'menus' ) { - $connector = "menus"; - } else if ( $context == 'backups' ) { - $connector = "mainwp_backups"; - } else if ( $context == 'sucuri_scan' ) { - $connector = "mainwp_sucuri"; - } else if ( $context == 'mainwp_maintenance' ) { - $connector = "mainwp_maintenance"; - } else if ( $context == 'wordfence_scan' ) { - $connector = "mainwp_wordfence"; - } else if ( $context == 'media' ) { - $connector = "media"; - } - - return $connector; + + $connector = ''; + if ( $context == 'plugins' || $context == 'themes' || $context == 'WordPress' ) { + $connector = 'installer'; + } elseif ( $context == 'profiles' ) { + $connector = 'users'; + } elseif ( $context == 'comments' ) { // multi values + $connector = 'comments'; + } + // else if ( $context == 'sessions' ) { + // $connector = "users"; + // } + elseif ( $context == 'settings' ) { + $connector = 'settings'; + } elseif ( $context == 'post' || $context == 'page' ) { + $connector = 'posts'; + } elseif ( $context == 'widgets' ) { + $connector = 'widgets'; + } elseif ( $context == 'menus' ) { + $connector = 'menus'; + } elseif ( $context == 'backups' ) { + $connector = 'mainwp_backups'; + } elseif ( $context == 'sucuri_scan' ) { + $connector = 'mainwp_sucuri'; + } elseif ( $context == 'mainwp_maintenance' ) { + $connector = 'mainwp_maintenance'; + } elseif ( $context == 'wordfence_scan' ) { + $connector = 'mainwp_wordfence'; + } elseif ( $context == 'media' ) { + $connector = 'media'; + } + + return $connector; } public function get_compatible_action( $action, $context = '' ) { - + $mapping_actions = array( 'restored' => 'untrashed', - 'spam' => 'spammed', - ); - - if (isset($mapping_actions[ $action ])) + 'spam' => 'spammed', + ); + + if ( isset($mapping_actions[ $action ]) ) { return $mapping_actions[ $action ]; - + } + if ( $context == 'mainwp_maintenance' ) { - if ( $action == 'process') + if ( $action == 'process' ) { $action = 'maintenance'; - } else if ( $context == 'sucuri_scan' ) { - if ( $action == 'checks') + } + } elseif ( $context == 'sucuri_scan' ) { + if ( $action == 'checks' ) { $action = 'sucuri_scan'; - } else if ($context == 'wordfence_scan') { - if ( $action == 'scan') + } + } elseif ( $context == 'wordfence_scan' ) { + if ( $action == 'scan' ) { $action = 'wordfence_scan'; - } + } + } return $action; } - + public function get_stream() { // Filters $allowed_params = array( @@ -219,13 +225,13 @@ class MainWP_Client_Report { if ( ! is_array( $sections ) ) { $sections = array(); } - //return $sections; + // return $sections; $other_tokens = isset( $_POST['other_tokens'] ) ? maybe_unserialize( base64_decode( $_POST['other_tokens'] ) ) : array(); if ( ! is_array( $other_tokens ) ) { $other_tokens = array(); } - //return $other_tokens; + // return $other_tokens; unset( $_POST['sections'] ); unset( $_POST['other_tokens'] ); @@ -247,71 +253,72 @@ class MainWP_Client_Report { // to fix bug $exclude_connector_posts = true; if ( isset( $sections['body'] ) && isset( $sections['body']['section_token'] ) && is_array($sections['body']['section_token']) ) { - foreach ($sections['body']['section_token'] as $sec) { - if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) { + foreach ( $sections['body']['section_token'] as $sec ) { + if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) { $exclude_connector_posts = false; break; } } } - if ($exclude_connector_posts) { + if ( $exclude_connector_posts ) { if ( isset( $sections['header'] ) && isset( $sections['header']['section_token'] ) && is_array($sections['header']['section_token']) ) { - foreach ($sections['header']['section_token'] as $sec) { - if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) { + foreach ( $sections['header']['section_token'] as $sec ) { + if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) { $exclude_connector_posts = false; break; } } } } - if ($exclude_connector_posts) { + if ( $exclude_connector_posts ) { if ( isset( $sections['footer'] ) && isset( $sections['footer']['section_token'] ) && is_array($sections['footer']['section_token']) ) { - foreach ($sections['footer']['section_token'] as $sec) { - if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) { + foreach ( $sections['footer']['section_token'] as $sec ) { + if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) { $exclude_connector_posts = false; break; } } } } - if ($exclude_connector_posts) { + if ( $exclude_connector_posts ) { if ( isset( $other_tokens['body'] ) && is_array( $other_tokens['body'] ) ) { foreach ( $other_tokens['body'] as $sec ) { - if ( strpos( $sec, "[post." ) !== false || strpos($sec, "[page.") !== false) { + if ( strpos( $sec, '[post.' ) !== false || strpos($sec, '[page.') !== false ) { $exclude_connector_posts = false; break; } } } } - if ($exclude_connector_posts) { + if ( $exclude_connector_posts ) { if ( isset( $other_tokens['header'] ) && is_array($other_tokens['header']) ) { - foreach ($other_tokens['header'] as $sec) { - if (strpos($sec, "[post.") !== false || strpos($sec, "[page.") !== false) { + foreach ( $other_tokens['header'] as $sec ) { + if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) { $exclude_connector_posts = false; break; } } } } - if ($exclude_connector_posts) { + if ( $exclude_connector_posts ) { if ( isset( $other_tokens['footer'] ) && is_array($other_tokens['footer']) ) { - foreach ($other_tokens['footer'] as $sec) { - if (strpos($sec, "[post.") !== false || strpos($sec, "[page.") !== false) { + foreach ( $other_tokens['footer'] as $sec ) { + if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) { $exclude_connector_posts = false; break; } } } } - if ($exclude_connector_posts) - $args['connector__not_in'] = array('posts'); - ///// end fix ///// + if ( $exclude_connector_posts ) { + $args['connector__not_in'] = array( 'posts' ); + } + // end fix ///// $args['action__not_in'] = array( 'login' ); $args['with-meta'] = 1; - + if ( isset( $args['date_from'] ) ) { $args['date_from'] = date( 'Y-m-d', $args['date_from'] ); } @@ -326,9 +333,9 @@ class MainWP_Client_Report { $args['records_per_page'] = 9999; -// $records = mainwp_wp_stream_query( $args ); + // $records = mainwp_wp_stream_query( $args ); $records = wp_mainwp_stream_get_instance()->db->query( $args ); - + if ( ! is_array( $records ) ) { $records = array(); } @@ -384,12 +391,13 @@ class MainWP_Client_Report { $tokens = array(); } - $backups_created_time_to_fix = array(); + $backups_created_time_to_fix = array(); foreach ( $tokens as $token ) { - - if ( isset( $token_values[ $token ] ) ) + + if ( isset( $token_values[ $token ] ) ) { continue; - + } + $str_tmp = str_replace( array( '[', ']' ), '', $token ); $array_tmp = explode( '.', $str_tmp ); @@ -397,81 +405,79 @@ class MainWP_Client_Report { $context = $action = $data = ''; if ( 2 === count( $array_tmp ) ) { list( $context, $data ) = $array_tmp; - } else if ( 3 === count( $array_tmp ) ) { + } elseif ( 3 === count( $array_tmp ) ) { list( $context, $action, $data ) = $array_tmp; } - $context = $this->get_compatible_context( $context ); - + $context = $this->get_compatible_context( $context ); + // to compatible with new version of child report - // to check condition for grabbing report data + // to check condition for grabbing report data $connector = $this->get_connector_by_compatible_context( $context ); - + $action = $this->get_compatible_action( $action, $context ); - + // custom values if ( $context == 'profiles' ) { if ( $action == 'created' || $action == 'deleted' ) { $context = 'users'; // see class-connector-user.php } } - //// - + switch ( $data ) { case 'count': - $count = 0; foreach ( $records as $record ) { - - // check connector - if ( $record->connector == 'editor' ) { - if ( !in_array( $context, array('plugins', 'themes') ) || $action !== 'updated' ) - continue; - } else if ( $connector !== $record->connector ) { + + // check connector + if ( $record->connector == 'editor' ) { + if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) { + continue; + } + } elseif ( $connector !== $record->connector ) { continue; - } - - // check context - if ( $context == 'comments' ) { // multi values - $comment_contexts = array( 'post', 'page' ); + } + + // check context + if ( $context == 'comments' ) { // multi values + $comment_contexts = array( 'post', 'page' ); if ( ! in_array( $record->context, $comment_contexts ) ) { continue; } - } else if ( $context == "menus") { + } elseif ( $context == 'menus' ) { // ok, pass, don't check context - } else if ( $record->connector == 'editor' ) { - // ok, pass, checked above - } else if ( $connector == 'media' && $record->connector == 'media' ) { + } elseif ( $record->connector == 'editor' ) { + // ok, pass, checked above + } elseif ( $connector == 'media' && $record->connector == 'media' ) { // ok, pass, do not check context - } else if ( $connector == "widgets" && $record->connector == 'widgets') { + } elseif ( $connector == 'widgets' && $record->connector == 'widgets' ) { // ok, pass, don't check context - } else if ( $context !== strtolower( $record->context )) { + } elseif ( $context !== strtolower( $record->context ) ) { continue; } - + // custom action value - if ( $connector == "widgets" ) { - if ( $action == "deleted" ) { - $action = "removed"; // action saved in database - } + if ( $connector == 'widgets' ) { + if ( $action == 'deleted' ) { + $action = 'removed'; // action saved in database + } } - //// - + // check action - if ( 'backups' === $context ) { + if ( 'backups' === $context ) { if ( ! $this->is_backup_action($record->action) ) { continue; } - $created = strtotime( $record->created ); - if ( in_array( $created, $backups_created_time_to_fix ) ) { - if ( ! in_array($record->ID, $skip_records) ) { - $skip_records[] = $record->ID; - } - continue; - } else { - $backups_created_time_to_fix[] = $created; - } - } else { + $created = strtotime( $record->created ); + if ( in_array( $created, $backups_created_time_to_fix ) ) { + if ( ! in_array($record->ID, $skip_records) ) { + $skip_records[] = $record->ID; + } + continue; + } else { + $backups_created_time_to_fix[] = $created; + } + } else { if ( $action !== $record->action ) { continue; } @@ -481,21 +487,23 @@ class MainWP_Client_Report { if ( 'draft' === $new_status ) { // avoid auto save post continue; } - } else if ( 'updated' === $action && ('themes' === $context || 'plugins' === $context)) { + } elseif ( 'updated' === $action && ( 'themes' === $context || 'plugins' === $context ) ) { $name = $this->get_stream_meta_data( $record, 'name' ); if ( empty($name) ) { // to fix empty value - if (!in_array($record->ID, $skip_records)) + if ( ! in_array($record->ID, $skip_records) ) { $skip_records[] = $record->ID; + } continue; } else { $old_version = $this->get_stream_meta_data( $record, 'old_version' ); - $version = $this->get_stream_meta_data( $record, 'version' ); - if (version_compare($version, $old_version, '<=')) { // to fix - if (!in_array($record->ID, $skip_records)) + $version = $this->get_stream_meta_data( $record, 'version' ); + if ( version_compare($version, $old_version, '<=') ) { // to fix + if ( ! in_array($record->ID, $skip_records) ) { $skip_records[] = $record->ID; + } continue; } - } + } } } $count ++; @@ -508,100 +516,99 @@ class MainWP_Client_Report { return $token_values; } - + function get_section_loop_data( $records, $tokens, $section, $skip_records = array() ) { - $maintenance_details = array( 'revisions' => __( 'Delete all post revisions', 'mainwp-child' ), - 'autodraft' => __( 'Delete all auto draft posts', 'mainwp-child' ), - 'trashpost' => __( 'Delete trash posts', 'mainwp-child' ), - 'spam' => __( 'Delete spam comments', 'mainwp-child' ), - 'pending' => __( 'Delete pending comments', 'mainwp-child' ), - 'trashcomment' => __( 'Delete trash comments', 'mainwp-child' ), - 'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-child' ), - 'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-child' ), - 'optimize' => __( 'Optimize database tables', 'mainwp-child' ) + 'autodraft' => __( 'Delete all auto draft posts', 'mainwp-child' ), + 'trashpost' => __( 'Delete trash posts', 'mainwp-child' ), + 'spam' => __( 'Delete spam comments', 'mainwp-child' ), + 'pending' => __( 'Delete pending comments', 'mainwp-child' ), + 'trashcomment' => __( 'Delete trash comments', 'mainwp-child' ), + 'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-child' ), + 'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-child' ), + 'optimize' => __( 'Optimize database tables', 'mainwp-child' ), ); - + $context = $action = ''; - + // parse $context, $action values from section tokens $str_tmp = str_replace( array( '[', ']' ), '', $section ); $array_tmp = explode( '.', $str_tmp ); if ( is_array( $array_tmp ) ) { if ( 2 === count( $array_tmp ) ) { list( $str1, $context ) = $array_tmp; - } else if ( 3 === count( $array_tmp ) ) { + } elseif ( 3 === count( $array_tmp ) ) { list( $str1, $context, $action ) = $array_tmp; } } // end - + // get db $context value by mapping - $context = $this->get_compatible_context( $context ); + $context = $this->get_compatible_context( $context ); // to compatible with new version of child report - // to check condition for grabbing report data + // to check condition for grabbing report data $connector = $this->get_connector_by_compatible_context( $context ); - + $action = $this->get_compatible_action( $action, $context ); - + if ( $context == 'profiles' ) { if ( $action == 'created' || $action == 'deleted' ) { $context = 'users'; // see class-connector-user.php } } - + $loops = array(); $loop_count = 0; - foreach ( $records as $record ) { - + foreach ( $records as $record ) { + if ( in_array($record->ID, $skip_records) ) { continue; } - + // check connector - if ( $record->connector == 'editor' ) { - if ( !in_array( $context, array('plugins', 'themes') ) || $action !== 'updated' ) - continue; - } else if ( $connector !== $record->connector ) { + if ( $record->connector == 'editor' ) { + if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) { + continue; + } + } elseif ( $connector !== $record->connector ) { continue; } - + // check context - if ( $context == "comments" ) { // multi values - $comment_contexts = array('post', 'page'); + if ( $context == 'comments' ) { // multi values + $comment_contexts = array( 'post', 'page' ); if ( ! in_array( $record->context, $comment_contexts ) ) { continue; - } - } else if ( $context == "menus") { + } + } elseif ( $context == 'menus' ) { // ok, pass, don't check context - } else if ( $record->connector == 'editor' ) { - // ok, pass, checked above - } else if ( $connector == 'media' && $record->connector == 'media' ) { + } elseif ( $record->connector == 'editor' ) { + // ok, pass, checked above + } elseif ( $connector == 'media' && $record->connector == 'media' ) { // ok, pass, do not check context - } else if ( $connector == "widgets" && $record->connector == 'widgets') { + } elseif ( $connector == 'widgets' && $record->connector == 'widgets' ) { // ok, pass, don't check context // - } else if ( $context !== strtolower( $record->context ) ) { + } elseif ( $context !== strtolower( $record->context ) ) { continue; - } - - // custom action value - if ( $connector == "widgets" ) { - if ( $action == "deleted" ) { - $action = "removed"; // action saved in database - } } - //// - - // check action - if ( $context == 'backups' ) { + + // custom action value + if ( $connector == 'widgets' ) { + if ( $action == 'deleted' ) { + $action = 'removed'; // action saved in database + } + } + + // check action + if ( $context == 'backups' ) { if ( ! $this->is_backup_action($record->action) ) { continue; } - } else if ( $action !== $record->action ) { + } elseif ( $action !== $record->action ) { continue; } @@ -610,12 +617,12 @@ class MainWP_Client_Report { if ( 'draft' === $new_status ) { // avoid auto save post continue; } - } - - //$skip_this_loop = false; - $token_values = array(); - - foreach ( $tokens as $token ) { + } + + // $skip_this_loop = false; + $token_values = array(); + + foreach ( $tokens as $token ) { // parse $data value from tokens in sections $data = ''; $token_name = str_replace( array( '[', ']' ), '', $token ); @@ -626,16 +633,16 @@ class MainWP_Client_Report { } else { if ( 1 === count( $array_tmp ) ) { list( $data ) = $array_tmp; - } else if ( 2 === count( $array_tmp ) ) { + } elseif ( 2 === count( $array_tmp ) ) { list( $str1, $data ) = $array_tmp; - } else if ( 3 === count( $array_tmp ) ) { + } elseif ( 3 === count( $array_tmp ) ) { list( $str1, $str2, $data ) = $array_tmp; } if ( 'version' === $data ) { if ( 'old' === $str2 ) { $data = 'old_version'; - } else if ( 'current' === $str2 && 'wordpress' === $str1 ) { + } elseif ( 'current' === $str2 && 'WordPress' === $str1 ) { $data = 'new_version'; } } @@ -656,7 +663,7 @@ class MainWP_Client_Report { $tok_value = MainWP_Helper::formatTime( MainWP_Helper::getTimestamp( strtotime( $record->created ) ) ); break; case 'area': - $data = 'sidebar_name'; + $data = 'sidebar_name'; $tok_value = $this->get_stream_meta_data( $record, $data ); break; case 'name': @@ -665,11 +672,12 @@ class MainWP_Client_Report { case 'new_version': case 'display_name': case 'roles': - if ( $data == 'name' ) { - if ( $context == 'profiles' ) - $data = 'display_name'; - } - $tok_value = $this->get_stream_meta_data( $record, $data ); + if ( $data == 'name' ) { + if ( $context == 'profiles' ) { + $data = 'display_name'; + } + } + $tok_value = $this->get_stream_meta_data( $record, $data ); break; case 'title': if ( 'comments' === $context ) { @@ -677,101 +685,99 @@ class MainWP_Client_Report { } else { if ( 'page' === $context || 'post' === $context ) { $data = 'post_title'; - } else if ( 'menus' === $record->connector ) { + } elseif ( 'menus' === $record->connector ) { $data = 'name'; } $tok_value = $this->get_stream_meta_data( $record, $data ); } break; - case 'author': - if ( $connector == "comment" ) { - $data = 'user_name'; + case 'author': + if ( $connector == 'comment' ) { + $data = 'user_name'; } else { - $data = 'user_meta'; + $data = 'user_meta'; } - + $value = $this->get_stream_meta_data( $record, $data ); - + if ( empty( $value ) && 'comments' === $context ) { $value = __( 'Guest', 'mainwp-child-reports' ); } - + // to check may compatible with old meta data - if ( empty( $value )) { - $value = $this->get_stream_meta_data( $record, 'author_meta' ); + if ( empty( $value ) ) { + $value = $this->get_stream_meta_data( $record, 'author_meta' ); } - - $tok_value = $value; + + $tok_value = $value; break; case 'status': // sucuri cases case 'webtrust': if ( 'sucuri_scan' === $context ) { - $scan_data = $this->get_stream_meta_data( $record, 'scan_data' ); - if (!empty($scan_data)) { - $scan_data = maybe_unserialize( base64_decode( $scan_data ) ); - if ( is_array( $scan_data ) ) { + $scan_data = $this->get_stream_meta_data( $record, 'scan_data' ); + if ( ! empty($scan_data) ) { + $scan_data = maybe_unserialize( base64_decode( $scan_data ) ); + if ( is_array( $scan_data ) ) { - $blacklisted = $scan_data['blacklisted']; - $malware_exists = $scan_data['malware_exists']; + $blacklisted = $scan_data['blacklisted']; + $malware_exists = $scan_data['malware_exists']; - $status = array(); - if ( $blacklisted ) { - $status[] = __( 'Site Blacklisted', 'mainwp-child' ); } - if ( $malware_exists ) { - $status[] = __( 'Site With Warnings', 'mainwp-child' ); } + $status = array(); + if ( $blacklisted ) { + $status[] = __( 'Site Blacklisted', 'mainwp-child' ); } + if ( $malware_exists ) { + $status[] = __( 'Site With Warnings', 'mainwp-child' ); } - if ($data == 'status') { - $tok_value = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' ); - } else if ($data == 'webtrust') { - $tok_value = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' ); - } - } - - } else { - $tok_value = $this->get_stream_meta_data( $record, $data ); - } + if ( $data == 'status' ) { + $tok_value = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' ); + } elseif ( $data == 'webtrust' ) { + $tok_value = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' ); + } + } + } else { + $tok_value = $this->get_stream_meta_data( $record, $data ); + } } else { $tok_value = $value; } break; case 'details': case 'result': - - if ('mainwp_maintenance' === $context && 'details' == $data) { - - $meta_value = $this->get_stream_meta_data( $record, $data ); - $meta_value = explode(",", $meta_value); - + if ( 'mainwp_maintenance' === $context && 'details' == $data ) { + + $meta_value = $this->get_stream_meta_data( $record, $data ); + $meta_value = explode(',', $meta_value); + $details = array(); - + if ( is_array( $meta_value) ) { - foreach($meta_value as $mt) { - if ( isset($maintenance_details[$mt]) ) { - $details[] = $maintenance_details[$mt]; + foreach ( $meta_value as $mt ) { + if ( isset($maintenance_details[ $mt ]) ) { + $details[] = $maintenance_details[ $mt ]; } } } - $tok_value = implode(", ", $details); - - } else if ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) { - $meta_value = $this->get_stream_meta_data( $record, $data ); - // to fix - if ('wordfence_scan' === $context && $data == 'result') { - // SUM_FINAL:Scan complete. You have xxx new issues to fix. See below. - // SUM_FINAL:Scan complete. Congratulations, no new problems found - if (stripos($meta_value, 'Congratulations')) { - $meta_value = 'No issues detected'; - } else if (stripos($meta_value, 'You have')) { - $meta_value = 'Issues Detected'; - } else { - $meta_value = ''; - } - } + $tok_value = implode(', ', $details); + + } elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) { + $meta_value = $this->get_stream_meta_data( $record, $data ); + // to fix + if ( 'wordfence_scan' === $context && $data == 'result' ) { + // SUM_FINAL:Scan complete. You have xxx new issues to fix. See below. + // SUM_FINAL:Scan complete. Congratulations, no new problems found + if ( stripos($meta_value, 'Congratulations') ) { + $meta_value = 'No issues detected'; + } elseif ( stripos($meta_value, 'You have') ) { + $meta_value = 'Issues Detected'; + } else { + $meta_value = ''; + } + } $tok_value = $meta_value; } break; - //case 'destination': // for backup tokens - case 'type': + // case 'destination': // for backup tokens + case 'type': if ( 'backups' === $context ) { $tok_value = $this->get_stream_meta_data( $record, $data ); } else { @@ -782,24 +788,22 @@ class MainWP_Client_Report { $tok_value = 'N/A'; break; } - + $token_values[ $token ] = $tok_value; - + if ( empty( $tok_value ) ) { - //$skip_this_loop = true; - if ( defined( 'MAINWP_CHILD_DEBUG' ) && MAINWP_CHILD_DEBUG === TRUE ) { - error_log("MainWP Child Report:: skip empty value :: token :: " . $token . " :: record :: " . print_r( $record, true )); + // $skip_this_loop = true; + if ( defined( 'MAINWP_CHILD_DEBUG' ) && MAINWP_CHILD_DEBUG === true ) { + error_log('MainWP Child Report:: skip empty value :: token :: ' . $token . ' :: record :: ' . print_r( $record, true )); } - //break; - } - + // break; + } } // foreach $tokens if ( ! empty( $token_values ) ) { $loops[ $loop_count ] = $token_values; $loop_count ++; } - } // foreach $records return $loops; } @@ -816,81 +820,81 @@ class MainWP_Client_Report { if ( isset( $record->meta ) ) { $meta = $record->meta; - - if ( isset( $meta[ $meta_key ] ) ) { + + if ( isset( $meta[ $meta_key ] ) ) { $value = $meta[ $meta_key ]; - $value = current( $value ); - + $value = current( $value ); + // to compatible with old meta data - if ( 'author_meta' === $meta_key ) { - $value = maybe_unserialize( $value ); - if (is_array($value)) { + if ( 'author_meta' === $meta_key ) { + $value = maybe_unserialize( $value ); + if ( is_array($value) ) { $value = $value['display_name']; // to fix empty author value if ( empty($value) ) { - if (isset($value['agent']) && !empty($value['agent'])) { + if ( isset($value['agent']) && ! empty($value['agent']) ) { $value = $value['agent']; } } } - if (!is_string($value)) { - $value = ''; - } + if ( ! is_string($value) ) { + $value = ''; + } } // end - } + } } return $value; } function set_showhide() { - $hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : ''; - MainWP_Child_Branding::Instance()->save_branding_options('hide_child_reports', $hide); - //MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports + $hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : ''; + MainWP_Child_Branding::Instance()->save_branding_options('hide_child_reports', $hide); + // MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports $information['result'] = 'SUCCESS'; - return $information; + return $information; } public function creport_init() { - $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); - $hide_nag = false; + $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); + $hide_nag = false; - // check setting of 'hide_child_reports' - if ( isset($branding_opts['hide_child_reports']) && $branding_opts['hide_child_reports'] == 'hide' ) { - add_filter( 'all_plugins', array( $this, 'creport_branding_plugin' ) ); - add_action( 'admin_menu', array( $this, 'creport_remove_menu' ) ); - $hide_nag = true; - } + // check setting of 'hide_child_reports' + if ( isset($branding_opts['hide_child_reports']) && $branding_opts['hide_child_reports'] == 'hide' ) { + add_filter( 'all_plugins', array( $this, 'creport_branding_plugin' ) ); + add_action( 'admin_menu', array( $this, 'creport_remove_menu' ) ); + $hide_nag = true; + } - if ( ! $hide_nag ) { - // check child branding settings - if ( MainWP_Child_Branding::Instance()->is_branding() ) { - $hide_nag = true; - } - } + if ( ! $hide_nag ) { + // check child branding settings + if ( MainWP_Child_Branding::Instance()->is_branding() ) { + $hide_nag = true; + } + } - if ($hide_nag) { - add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) ); - add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) ); - } + if ( $hide_nag ) { + add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) ); + add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) ); + } } - function hide_update_notice( $slugs ) { - $slugs[] = 'mainwp-child-reports/mainwp-child-reports.php'; - return $slugs; - } + function hide_update_notice( $slugs ) { + $slugs[] = 'mainwp-child-reports/mainwp-child-reports.php'; + return $slugs; + } function remove_update_nag( $value ) { - if ( isset( $_POST['mainwpsignature'] ) ) { + if ( isset( $_POST['mainwpsignature'] ) ) { return $value; } - if (! MainWP_Helper::is_screen_with_update()) { - return $value; - } + if ( ! MainWP_Helper::is_screen_with_update() ) { + return $value; + } if ( isset( $value->response['mainwp-child-reports/mainwp-child-reports.php'] ) ) { unset( $value->response['mainwp-child-reports/mainwp-child-reports.php'] ); From 361a6f01161d8ee03b6b99b413246dfd8a1dedb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Wed, 18 Mar 2020 18:52:41 +0100 Subject: [PATCH 24/98] Renamed to phpcs.xml --- .phpcs.xml.dist => phpcs.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .phpcs.xml.dist => phpcs.xml (100%) diff --git a/.phpcs.xml.dist b/phpcs.xml similarity index 100% rename from .phpcs.xml.dist rename to phpcs.xml From 19273a181d7fa406a08ad0eb21462aecbfdd9909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 13:54:34 +0100 Subject: [PATCH 25/98] Update .gitattributes --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index a810b8d..12e399e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,4 +9,4 @@ tests export-ignore LICENSE.md export-ignore LICENSE.txt export-ignore README.md export-ignore -phpunit.xml.dist export-ignore +phpunit.xml export-ignore From 5b4844ee95fc61d5ee4345006bb3d610db9f6db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 13:57:12 +0100 Subject: [PATCH 26/98] Update .gitattributes --- .gitattributes | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 12e399e..8f35e6b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,9 +4,8 @@ bin export-ignore composer.* export-ignore tests export-ignore .gitattributes export-ignore -.phpcs.xml.dist export-ignore +phpcs.xml export-ignore .travis.yml export-ignore LICENSE.md export-ignore LICENSE.txt export-ignore README.md export-ignore -phpunit.xml export-ignore From ea47f2f4d165154c038af98ec5ad716ef81af406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 14:09:54 +0100 Subject: [PATCH 27/98] Fixed: CodeFactor Issues --- class/class-mainwp-backup.php | 72 +++++++++-------------------------- 1 file changed, 19 insertions(+), 53 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 0f49c5f..e03c9d3 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -68,30 +68,15 @@ class MainWP_Backup { $ext = $this->archiver->getExtension(); } - // throw new Exception('Test 1 2 : ' . print_r($append,1)); if ( ( false !== $fileSuffix ) && ! empty( $fileSuffix ) ) { - $file = $fileSuffix . ( true === $append ? '' : $ext ); //Append already contains extension! + //Append already contains extension! + $file = $fileSuffix . ( true === $append ? '' : $ext ); } else { $file = 'backup-' . $filePrefix . $timestamp . $ext; } $filepath = $backupdir . $file; $fileurl = $file; - // if (!$append) - // { - // if ($dh = opendir($backupdir)) - // { - // while (($file = readdir($dh)) !== false) - // { - // if ($file != '.' && $file != '..' && preg_match('/(.*).(zip|tar|tar.gz|tar.bz2|pid|done)$/', $file)) - // { - // @unlink($backupdir . $file); - // } - // } - // closedir($dh); - // } - // } - if ( ! $addConfig ) { if ( ! in_array( str_replace( ABSPATH, '', WP_CONTENT_DIR ), $excludes ) && ! in_array( 'wp-admin', $excludes ) && ! in_array( WPINC, $excludes ) ) { $addConfig = true; @@ -99,7 +84,7 @@ class MainWP_Backup { } } - $this->timeout = 20 * 60 * 60; /*20 minutes*/ + $this->timeout = 20 * 60 * 60; $mem = '512M'; // @codingStandardsIgnoreStart @ini_set( 'memory_limit', $mem ); @@ -109,9 +94,9 @@ class MainWP_Backup { if ( null !== $this->archiver ) { $success = $this->archiver->createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append ); - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $success = $this->createZipFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ); - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { $success = $this->createZipConsoleFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ); } else { $success = $this->createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ); @@ -125,7 +110,7 @@ class MainWP_Backup { } public function zipFile( $files, $archive ) { - $this->timeout = 20 * 60 * 60; /*20 minutes*/ + $this->timeout = 20 * 60 * 60; $mem = '512M'; // @codingStandardsIgnoreStart @ini_set( 'memory_limit', $mem ); @@ -134,14 +119,14 @@ class MainWP_Backup { // @codingStandardsIgnoreEnd if ( !is_array( $files ) ) { - $files = array ($files ); + $files = array ( $files ); } if ( null !== $this->archiver ) { $success = $this->archiver->zipFile( $files, $archive ); - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $success = $this->_zipFile( $files, $archive ); - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { $success = $this->_zipFileConsole( $files, $archive ); } else { $success = $this->_zipFilePcl( $files, $archive ); @@ -202,7 +187,6 @@ class MainWP_Backup { */ public function checkZipConsole() { return false; - // return function_exists('system'); } /** @@ -248,7 +232,7 @@ class MainWP_Backup { foreach ( $nodes as $key => $node ) { if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { unset( $nodes[ $key ] ); - } else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { + } elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { unset( $nodes[ $key ] ); } else { foreach ( $coreFiles as $coreFile ) { @@ -280,7 +264,7 @@ class MainWP_Backup { if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( is_dir( $node ) ) { $this->zipAddDir( $node, $excludes ); - } else if ( is_file( $node ) ) { + } elseif ( is_file( $node ) ) { $this->addFileToZip( $node, str_replace( ABSPATH, '', $node ) ); } } @@ -382,7 +366,7 @@ class MainWP_Backup { foreach ( $nodes as $key => $node ) { if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { unset( $nodes[ $key ] ); - } else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { + } elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { unset( $nodes[ $key ] ); } else { foreach ( $coreFiles as $coreFile ) { @@ -414,7 +398,7 @@ class MainWP_Backup { $error = true; break; } - } else if ( is_file( $node ) ) { + } elseif ( is_file( $node ) ) { if ( 0 === ( $rslt = $this->zip->add( $node, PCLZIP_OPT_REMOVE_PATH, ABSPATH ) ) ) { $error = true; break; @@ -471,7 +455,7 @@ class MainWP_Backup { $newnodes = glob( $node . DIRECTORY_SEPARATOR . '*' ); $this->copy_dir( $newnodes, $excludes, $backupfolder, $excludenonwp, false ); unset( $newnodes ); - } else if ( is_file( $node ) ) { + } elseif ( is_file( $node ) ) { if ( $this->excludeZip && MainWP_Helper::endsWith( $node, '.zip' ) ) { continue; } @@ -523,7 +507,7 @@ class MainWP_Backup { foreach ( $nodes as $key => $node ) { if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { unset( $nodes[ $key ] ); - } else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { + } elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { unset( $nodes[ $key ] ); } else { foreach ( $coreFiles as $coreFile ) { @@ -600,23 +584,6 @@ class MainWP_Backup { $iterator = null; unset( $iterator ); - // $nodes = glob(rtrim($path, '/') . '/*'); - // if (empty($nodes)) return true; - // - // foreach ($nodes as $node) - // { - // if (!MainWP_Helper::inExcludes($excludes, str_replace(ABSPATH, '', $node))) - // { - // if (is_dir($node)) - // { - // $this->zipAddDir($node, $excludes); - // } - // else if (is_file($node)) - // { - // $this->addFileToZip($node, str_replace(ABSPATH, '', $node)); - // } - // } - // } } public function pclZipAddDir( $path, $excludes ) { @@ -633,7 +600,7 @@ class MainWP_Backup { $error = true; break; } - } else if ( is_file( $node ) ) { + } elseif ( is_file( $node ) ) { if ( 0 === ( $rslt = $this->zip->add( $node, PCLZIP_OPT_REMOVE_PATH, ABSPATH ) ) ) { $error = true; break; @@ -657,7 +624,8 @@ class MainWP_Backup { $this->zip->delete( PCLZIP_OPT_BY_NAME, $file ); $add = $this->zip->add( $tmpfilename, PCLZIP_OPT_REMOVE_PATH, dirname( $filepath ), - PCLZIP_OPT_ADD_PATH, $localpath ); + PCLZIP_OPT_ADD_PATH, $localpath + ); unlink( $tmpfilename ); if ( ! empty( $add ) ) { return true; @@ -742,13 +710,11 @@ class MainWP_Backup { } public function createZipConsoleFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) { - // @TODO to work with 'zip' from system if PHP Zip library not available - //system('zip'); return false; } public function createBackupDB( $filepath_prefix, $archiveExt = false, &$archiver = null ) { - $timeout = 20 * 60 * 60; //20minutes + $timeout = 20 * 60 * 60; // @codingStandardsIgnoreStart @set_time_limit( $timeout ); @ini_set( 'max_execution_time', $timeout ); From 6e2458204bf5c0eccf8caae8ffb0e661dc2cf9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 14:51:43 +0100 Subject: [PATCH 28/98] Update phpcs.xml --- phpcs.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 3adf2c6..539b881 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,18 +1,18 @@ - + The Coding standard for the WordPress Coding Standards itself. . - - - - - */bin/* */.github/* */tests/* + + + + + From 252aeebe2a2cebd34d59fec15e6d5a6be04a1dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:00:13 +0100 Subject: [PATCH 29/98] Update phpcs.xml --- phpcs.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 539b881..3a928b7 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,5 +1,5 @@ - + The Coding standard for the WordPress Coding Standards itself. @@ -13,6 +13,8 @@ + + From a18355b720e3a2d4f2a45364a1653183f2325e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:04:14 +0100 Subject: [PATCH 30/98] Update phpcs.xml --- phpcs.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 3a928b7..ac0ba40 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -9,12 +9,10 @@ */.github/* */tests/* - + - - - + From e59250ad1dacc0a2458ddeefbd5191667cf060d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:22:10 +0100 Subject: [PATCH 31/98] Update phpcs.xml --- phpcs.xml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index ac0ba40..281bdae 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,18 +1,18 @@ - + The Coding standard for the WordPress Coding Standards itself. . + + + + + */bin/* */.github/* */tests/* - - - - - @@ -22,6 +22,7 @@ + @@ -30,10 +31,8 @@ - - - + @@ -48,8 +47,6 @@ - /WordPress/AbstractClassRestrictionsSniff\.php$ From 5fb9ca0c9d12a31d348bafd0a2c635bee5550312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:42:35 +0100 Subject: [PATCH 32/98] Update phpcs.xml --- phpcs.xml | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 281bdae..351f131 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,40 +1,44 @@ - - + The Coding standard for the WordPress Coding Standards itself. - + . - - */bin/* - */.github/* - */tests/* + + + + + + - - - - - + + + + + + + + + + error + - - - @@ -49,5 +53,9 @@ /WordPress/AbstractClassRestrictionsSniff\.php$ + + */bin/* + */.github/* + */tests/* From 6e381b6e166c895a7dec846326ff088744796a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:43:12 +0100 Subject: [PATCH 33/98] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 351f131..4deb1ad 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,6 @@ - The Coding standard for the WordPress Coding Standards itself. + WordPress coding standards for the MainWP Child. . From ba393942b2046b361cb2b8666a536f2657c57611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:48:15 +0100 Subject: [PATCH 34/98] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3cafdc8..a509511 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "dealerdirect/phpcodesniffer-composer-installer": "^0.5", "phpcompatibility/php-compatibility": "^9.0", "phpunit/phpunit": "^6.5", - "wp-cli/wp-cli": "^2.0" + "wp-cli/wp-cli": "^2.0", + "wp-coding-standards/wpcs": "2.2.1" }, "autoload-dev": { "classmap": [ From f34d6071369348d6302fb414f144d9989b8dd58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:52:25 +0100 Subject: [PATCH 35/98] Update composer.json --- composer.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a509511..33607d2 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,13 @@ "php": ">=5.6|>=7.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5", + "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", "phpcompatibility/php-compatibility": "^9.0", + "sirbrillig/phpcs-changed": "2.2.7", + "sirbrillig/phpcs-variable-analysis": "2.8.1", + "wp-coding-standards/wpcs": "2.2.1" "phpunit/phpunit": "^6.5", - "wp-cli/wp-cli": "^2.0", - "wp-coding-standards/wpcs": "2.2.1" + "wp-cli/wp-cli": "^2.0" }, "autoload-dev": { "classmap": [ From 1473f3eef7d46d5719ffdfc323571dd68b120108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:53:07 +0100 Subject: [PATCH 36/98] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 33607d2..c72f434 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", "phpcompatibility/php-compatibility": "^9.0", "sirbrillig/phpcs-changed": "2.2.7", - "sirbrillig/phpcs-variable-analysis": "2.8.1", - "wp-coding-standards/wpcs": "2.2.1" + "sirbrillig/phpcs-variable-analysis": "2.8.1", + "wp-coding-standards/wpcs": "2.2.1", "phpunit/phpunit": "^6.5", "wp-cli/wp-cli": "^2.0" }, From 1c148a9ae73407ce1be38c39d044ac086845a4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 15:55:43 +0100 Subject: [PATCH 37/98] Update composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index c72f434..78f17af 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "php": ">=5.6|>=7.0" }, "require-dev": { + "squizlabs/php_codesniffer": "3.*", "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", "phpcompatibility/php-compatibility": "^9.0", "sirbrillig/phpcs-changed": "2.2.7", From 5d5e2433dfb06986849729f36f86dd3c491a7c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 16:03:57 +0100 Subject: [PATCH 38/98] Update composer.json --- composer.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/composer.json b/composer.json index 78f17af..bca100c 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,8 @@ "php": ">=5.6|>=7.0" }, "require-dev": { - "squizlabs/php_codesniffer": "3.*", "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", "phpcompatibility/php-compatibility": "^9.0", - "sirbrillig/phpcs-changed": "2.2.7", - "sirbrillig/phpcs-variable-analysis": "2.8.1", - "wp-coding-standards/wpcs": "2.2.1", "phpunit/phpunit": "^6.5", "wp-cli/wp-cli": "^2.0" }, From 993325fec0e92b4196c524c9e5ae2424b88e4d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 16:07:27 +0100 Subject: [PATCH 39/98] Update phpcs.xml --- phpcs.xml | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 4deb1ad..3348819 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -9,50 +9,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - error - - - - - - - - - - - - - - - - /WordPress/AbstractClassRestrictionsSniff\.php$ - */bin/* */.github/* From 81d2ea3ad2f02eb4ed1884c4a1f4a1be8a2964f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 16:20:18 +0100 Subject: [PATCH 40/98] Update phpcs.xml --- phpcs.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 3348819..50179b3 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -2,12 +2,6 @@ WordPress coding standards for the MainWP Child. - . - - - - - From da879904f866d626e2db372a77306bad81686a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 16:27:11 +0100 Subject: [PATCH 41/98] Update phpcs.xml --- phpcs.xml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 50179b3..a3f4c05 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -2,11 +2,62 @@ WordPress coding standards for the MainWP Child. - - + . + + + + + */bin/* */.github/* */tests/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + error + + + + + + + + + + + + + + + + /WordPress/AbstractClassRestrictionsSniff\.php$ + + + From 3775e74d3d02ff2f4f90cc3c7422378cfb6a964d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 16:28:35 +0100 Subject: [PATCH 42/98] Update phpcs.xml --- phpcs.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index a3f4c05..cb8c13d 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -37,10 +37,6 @@ - - - error - From 16ee96e03fc7574393157d1dff844cc0225a4bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 16:32:54 +0100 Subject: [PATCH 43/98] Update phpcs.xml --- phpcs.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index cb8c13d..9b9fb64 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -50,10 +50,4 @@ - - /WordPress/AbstractClassRestrictionsSniff\.php$ - - - - From 9cf1bfbb7c7fdd5c6a4a020bac78caa6de968df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 17:22:42 +0100 Subject: [PATCH 44/98] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 9b9fb64..1486fe9 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -7,7 +7,7 @@ - + */bin/* */.github/* From 42ba14dcd8de15b758da19a1d2684ddee001689d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 17:31:52 +0100 Subject: [PATCH 45/98] Rename phpcs.xml to .phpcs.xml --- phpcs.xml => .phpcs.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename phpcs.xml => .phpcs.xml (100%) diff --git a/phpcs.xml b/.phpcs.xml similarity index 100% rename from phpcs.xml rename to .phpcs.xml From 2489f5e55fccc8edcae305edc340402bd2e31677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 17:32:05 +0100 Subject: [PATCH 46/98] Rename .phpcs.xml to phpcs.xml --- .phpcs.xml => phpcs.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .phpcs.xml => phpcs.xml (100%) diff --git a/.phpcs.xml b/phpcs.xml similarity index 100% rename from .phpcs.xml rename to phpcs.xml From 1aa642e318d14094edd1d8e2dcdb84a66555d64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 17:33:46 +0100 Subject: [PATCH 47/98] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 1486fe9..9b9fb64 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -7,7 +7,7 @@ - + */bin/* */.github/* From 8979679a95ee6e8a55bf57a8baa3bcbe0c9985b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 19:03:24 +0100 Subject: [PATCH 48/98] Fixed: CodeFactor issues Not using strict comparison for in_array --- class/class-mainwp-backup.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index e03c9d3..c524430 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -43,7 +43,7 @@ class MainWP_Backup { $pid = trailingslashit( $backupdir ) . 'backup-' . $pid . '.pid'; } - //Verify if another backup is running, if so, return an error + // Verify if another backup is running, if so, return an error $files = glob( $backupdir . '*.pid' ); foreach ( $files as $file ) { if ( basename( $file ) == basename( $pid ) ) { @@ -78,7 +78,7 @@ class MainWP_Backup { $fileurl = $file; if ( ! $addConfig ) { - if ( ! in_array( str_replace( ABSPATH, '', WP_CONTENT_DIR ), $excludes ) && ! in_array( 'wp-admin', $excludes ) && ! in_array( WPINC, $excludes ) ) { + if ( ! in_array( str_replace( ABSPATH, '', WP_CONTENT_DIR ), $excludes, true ) && ! in_array( 'wp-admin', $excludes, true ) && ! in_array( WPINC, $excludes, true ) ) { $addConfig = true; $includeCoreFiles = true; } @@ -392,7 +392,7 @@ class MainWP_Backup { } if ( ! $error ) { foreach ( $nodes as $node ) { - if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes ) ) { + if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes, true ) ) { if ( is_dir( $node ) ) { if ( ! $this->pclZipAddDir( $node, $excludes ) ) { $error = true; @@ -594,7 +594,7 @@ class MainWP_Backup { } foreach ( $nodes as $node ) { - if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes ) ) { + if ( null === $excludes || ! in_array( str_replace( ABSPATH, '', $node ), $excludes, true ) ) { if ( is_dir( $node ) ) { if ( ! $this->pclZipAddDir( $node, $excludes ) ) { $error = true; From 15bc4534e10c719e3caf9288d36d43cb43030735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:13:09 +0100 Subject: [PATCH 49/98] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 9b9fb64..17e259d 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -14,7 +14,7 @@ */tests/* - + From 7a53d8fa9319f83159e45aff9ea596b784e2cd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:35:48 +0100 Subject: [PATCH 50/98] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index bca100c..b692611 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,14 @@ "issues": "https://github.com/mainwp/mainwp-child/issues", "source": "https://github.com/mainwp/mainwp" }, - "require": { + "require": { "composer/installers": "^1.6", "php": ">=5.6|>=7.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "0.6.2", + "dealerdirect/phpcodesniffer-composer-installer": "^0.5", "phpcompatibility/php-compatibility": "^9.0", - "phpunit/phpunit": "^6.5", + "phpunit/phpunit": "^9.0", "wp-cli/wp-cli": "^2.0" }, "autoload-dev": { From 6da8688ede025fce05eeadfe7f737b278734e178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:40:06 +0100 Subject: [PATCH 51/98] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index 17e259d..9cea9a5 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -13,7 +13,7 @@ */.github/* */tests/* - + From c5f7bee413cb08adf65fa917bd777e883287fc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:43:26 +0100 Subject: [PATCH 52/98] Update phpcs.xml --- phpcs.xml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 9cea9a5..b3248d8 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -13,8 +13,8 @@ */.github/* */tests/* - - + + @@ -38,16 +38,6 @@ - - - - - - - - - - - + From ea7a02a370ec6dfc92093e1d3645a7bfdefbf513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:47:27 +0100 Subject: [PATCH 53/98] Update phpcs.xml --- phpcs.xml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index b3248d8..a3424bd 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -13,31 +13,6 @@ */.github/* */tests/* - - - - - - - - - - - - - - - - - - - - - - - - - From d6bbd5e30167ebadcacf9f89f15272ab1db12118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:53:38 +0100 Subject: [PATCH 54/98] Update phpcs.xml --- phpcs.xml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index a3424bd..8b13789 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,18 +1 @@ - - - WordPress coding standards for the MainWP Child. - - . - - - - - - */bin/* - */.github/* - */tests/* - - - - From a1b3a1b2e7d1a99eac88c6ded93f02b095562ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 20:57:38 +0100 Subject: [PATCH 55/98] Update and rename phpcs.xml to .phpcs.xml --- .phpcs.xml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ phpcs.xml | 1 - 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .phpcs.xml delete mode 100644 phpcs.xml diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 0000000..17e259d --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,53 @@ + + + WordPress coding standards for the MainWP Child. + + . + + + + + + + */bin/* + */.github/* + */tests/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 8b13789..0000000 --- a/phpcs.xml +++ /dev/null @@ -1 +0,0 @@ - From a30c5d8f9cc500410f2f421c36b35d33df07fdcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 19 Mar 2020 21:00:38 +0100 Subject: [PATCH 56/98] Rename .phpcs.xml to phpcs.xml --- .phpcs.xml => phpcs.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .phpcs.xml => phpcs.xml (100%) diff --git a/.phpcs.xml b/phpcs.xml similarity index 100% rename from .phpcs.xml rename to phpcs.xml From bf753d0a1dcb7a0af627381fd286a65085a91f95 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Fri, 20 Mar 2020 17:04:03 +0100 Subject: [PATCH 57/98] Delete phpcs.xml --- phpcs.xml | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 17e259d..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - WordPress coding standards for the MainWP Child. - - . - - - - - - - */bin/* - */.github/* - */tests/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From d4a57a4b1fdb9b53b0f03a527169c30b6804f511 Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Fri, 20 Mar 2020 17:05:20 +0100 Subject: [PATCH 58/98] Create phpcs.xml --- phpcs.xml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..17e259d --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,53 @@ + + + WordPress coding standards for the MainWP Child. + + . + + + + + + + */bin/* + */.github/* + */tests/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6a9a136799ea7fde66465e5fe254efc5cec1cf8d Mon Sep 17 00:00:00 2001 From: Dennis Dornon Date: Tue, 24 Mar 2020 19:04:04 -0400 Subject: [PATCH 59/98] Update README.md Removed travis-ci build status until tests are completed --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0d888d8..0a4094c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Latest Stable Version WordPress Plugin Active Installs WordPress Plugin Rating - Build Status

Welcome to the [MainWP](https://mainwp.com) Child plugin repository on GitHub. Here you can browse the source, look at open issues and keep track of development. From cfd8b0f31feb4373fe4951a47d9a65663e1287cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Wed, 25 Mar 2020 16:32:49 +0100 Subject: [PATCH 60/98] Update phpcs.xml --- phpcs.xml | 51 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 17e259d..a8e8021 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,36 +1,42 @@ - - WordPress coding standards for the MainWP Child. - + + + The Coding standard for the MainWP Child plugin. + . - + + */vendor/* */bin/* */.github/* */tests/* - - - - - - + + + + + + + + + + + + + - - - - - - - + + + + @@ -38,7 +44,12 @@ + + + + + @@ -50,4 +61,10 @@ + + + /WordPress/AbstractClassRestrictionsSniff\.php$ + + From 7a2f38d78d8482a8798b17aa45c87235f1bc9cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Wed, 25 Mar 2020 20:41:38 +0100 Subject: [PATCH 61/98] Update phpcs.xml --- phpcs.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpcs.xml b/phpcs.xml index a8e8021..3f73ef1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -31,6 +31,8 @@ + +
From fc6f2036f3fd9d92192e73d0319a4bfb3144088d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Wed, 25 Mar 2020 20:43:54 +0100 Subject: [PATCH 62/98] Update phpcs.xml --- phpcs.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/phpcs.xml b/phpcs.xml index 3f73ef1..a46af61 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -33,6 +33,7 @@ +
From a7db171e8baad4e2f65be0537815bec80565b391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 15:01:57 +0100 Subject: [PATCH 63/98] Update phpcs.xml --- phpcs.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/phpcs.xml b/phpcs.xml index a46af61..b6e9207 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -34,6 +34,19 @@ + + + + + + + + + + + + +
From c0d6616242935bd691cdee8200b02ecacf6dee4d Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 14:05:04 +0000 Subject: [PATCH 64/98] [CodeFactor] Apply fixes --- class/class-mainwp-backup.php | 2 - class/class-mainwp-child-back-up-buddy.php | 317 +++++++------ .../class-mainwp-child-back-up-wordpress.php | 89 ++-- class/class-mainwp-child-back-wp-up.php | 56 ++- class/class-mainwp-child-branding.php | 71 +-- class/class-mainwp-child-db.php | 6 +- class/class-mainwp-child-ithemes-security.php | 66 ++- class/class-mainwp-child-links-checker.php | 17 +- class/class-mainwp-child-pagespeed.php | 23 +- class/class-mainwp-child-plugins-check.php | 8 +- class/class-mainwp-child-robot.php | 6 +- .../class-mainwp-child-server-information.php | 73 +-- class/class-mainwp-child-skeleton-key.php | 7 +- class/class-mainwp-child-staging.php | 52 +- class/class-mainwp-child-themes-check.php | 9 +- class/class-mainwp-child-timecapsule.php | 180 ++++--- ...lass-mainwp-child-updraft-plus-backups.php | 160 +++---- ...ass-mainwp-child-vulnerability-checker.php | 64 +-- .../class-mainwp-child-woocommerce-status.php | 28 +- class/class-mainwp-child-wordfence.php | 446 +++++++++--------- class/class-mainwp-child-wp-rocket.php | 48 +- ...ass-mainwp-child-wpvivid-backuprestore.php | 88 ++-- class/class-mainwp-child.php | 152 +++--- class/class-mainwp-clone-install.php | 18 +- class/class-mainwp-clone.php | 49 +- class/class-mainwp-custom-post-type.php | 26 +- class/class-mainwp-debug.php | 67 ++- class/class-mainwp-helper.php | 144 +++--- class/class-mainwp-keyword-links.php | 14 +- class/class-mainwp-security.php | 30 +- class/class-mainwp-tools.php | 4 +- class/class-mainwp-wordpress-seo.php | 6 +- class/class-tar-archiver.php | 2 +- mainwp-child.php | 4 +- 34 files changed, 1155 insertions(+), 1177 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index c524430..da1d5dd 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -583,7 +583,6 @@ class MainWP_Backup { $iterator = null; unset( $iterator ); - } public function pclZipAddDir( $path, $excludes ) { @@ -809,7 +808,6 @@ class MainWP_Backup { } } - return ( false !== $archiveExt ? array( 'filepath' => $archivefilePath ) : $db_files ); } } diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 3b2e065..6dd18af 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -21,10 +21,10 @@ class MainWP_Child_Back_Up_Buddy { public $is_backupbuddy_installed = false; static function Instance() { - if ( null === MainWP_Child_Back_Up_Buddy::$instance ) { - MainWP_Child_Back_Up_Buddy::$instance = new MainWP_Child_Back_Up_Buddy(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Back_Up_Buddy(); } - return MainWP_Child_Back_Up_Buddy::$instance; + return self::$instance; } public function __construct() { @@ -104,7 +104,7 @@ class MainWP_Child_Back_Up_Buddy { } } // ok - function do_reports_log($ext = '') { + function do_reports_log( $ext = '') { if ($ext !== 'backupbuddy') return; @@ -129,14 +129,13 @@ class MainWP_Child_Back_Up_Buddy { // Backup type. $pretty_type = array( - 'full' => 'Full', - 'db' => 'Database', - 'files' => 'Files', + 'full' => 'Full', + 'db' => 'Database', + 'files' => 'Files', ); $recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' ); - foreach( $recentBackups_list as $backup_fileoptions ) { $backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true ); @@ -439,7 +438,6 @@ class MainWP_Child_Back_Up_Buddy { 'ignore_zip_symlinks', ); - $filter_general_settings = array( 'importbuddy_pass_hash', 'importbuddy_pass_length', @@ -470,7 +468,7 @@ class MainWP_Child_Back_Up_Buddy { 'email_notify_error', 'email_notify_error_subject', 'email_notify_error_body', - 'email_return' + 'email_return', ); $filter_profile0_values = array( @@ -479,7 +477,7 @@ class MainWP_Child_Back_Up_Buddy { 'excludes', 'integrity_check', 'skip_database_dump', - 'backup_nonwp_tables' + 'backup_nonwp_tables', ); $settings = unserialize(base64_decode($_POST['options'])); @@ -587,7 +585,7 @@ class MainWP_Child_Back_Up_Buddy { } // Determine next run. - $next_run = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int)$schedule_id ) ) ); + $next_run = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); if ( false === $next_run ) { $next_run = 'Error: Cron event not found'; } else { @@ -661,9 +659,9 @@ class MainWP_Child_Back_Up_Buddy { } } else { $first_run = $schedule['first_run']; - $next_scheduled_time = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int)$schedule_id ) ) ); - backupbuddy_core::unschedule_event( $next_scheduled_time, 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int)$schedule_id ) ) ); - backupbuddy_core::schedule_event( $first_run, $schedule['interval'], 'run_scheduled_backup', array( (int)$schedule_id ) ); // Add new schedule. + $next_scheduled_time = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); + backupbuddy_core::unschedule_event( $next_scheduled_time, 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); + backupbuddy_core::schedule_event( $first_run, $schedule['interval'], 'run_scheduled_backup', array( (int) $schedule_id ) ); // Add new schedule. pb_backupbuddy::$options['schedules'][$schedule_id] = $schedule; } pb_backupbuddy::save(); @@ -774,8 +772,6 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) ); MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) ); - - $data = array(); $data['plugins_root'] = backupbuddy_core::get_plugins_root(); $data['themes_root'] = backupbuddy_core::get_themes_root(); @@ -784,12 +780,12 @@ class MainWP_Child_Back_Up_Buddy { $data['abspath'] = ABSPATH; $getOverview = backupbuddy_api::getOverview(); - $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup'] ; + $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup']; if ( isset( $getOverview['lastBackupStats']['finish'] ) ) { - $finish_time = $getOverview['lastBackupStats']['finish'] ; + $finish_time = $getOverview['lastBackupStats']['finish']; $time = $this->localize_time( $finish_time ); - $data['lastBackupStats'] = date("M j - g:i A", $time); + $data['lastBackupStats'] = date('M j - g:i A', $time); $data['lasttime_backup'] = $finish_time; MainWP_Helper::update_lasttime_backup('backupbuddy', $finish_time); // to support Require Backup Before Update feature } else { @@ -822,7 +818,7 @@ class MainWP_Child_Back_Up_Buddy { $backup_directory = backupbuddy_core::getBackupDirectory(); $backup_directory = str_replace( '\\', '/', $backup_directory ); $backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; - $information['backupDirectoryWithinSiteRoot'] = (FALSE !== stristr( $backup_directory, ABSPATH )) ? 'yes' : 'no'; + $information['backupDirectoryWithinSiteRoot'] = (false !== stristr( $backup_directory, ABSPATH )) ? 'yes' : 'no'; $information['result'] = 'SUCCESS'; return $information; } @@ -834,11 +830,10 @@ class MainWP_Child_Back_Up_Buddy { } $backup_file = $_POST['backup_file']; $note = $_POST['note']; - $note = preg_replace( "/[[:space:]]+/", ' ', $note ); - $note = preg_replace( "/[^[:print:]]/", '', $note ); + $note = preg_replace( '/[[:space:]]+/', ' ', $note ); + $note = preg_replace( '/[^[:print:]]/', '', $note ); $note = substr( $note, 0, 200 ); - // Returns true on success, else the error message. $old_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment( $backup_file ); $comment = backupbuddy_core::normalize_comment_data( $old_comment ); @@ -894,7 +889,7 @@ class MainWP_Child_Back_Up_Buddy { // Purge cache if too old. if ( file_exists( $fileoptions_file ) && ( ( time() - filemtime( $fileoptions_file ) ) > $max_cache_time ) ) { if ( false === unlink( $fileoptions_file ) ) { - $alerts[] = 'Error #456765545. Unable to wipe cached fileoptions file `' . $fileoptions_file . '`.' ; + $alerts[] = 'Error #456765545. Unable to wipe cached fileoptions file `' . $fileoptions_file . '`.'; } } @@ -997,7 +992,6 @@ class MainWP_Child_Back_Up_Buddy { } return array('result' => 'SUCCESS', 'files' => $files, 'message' => implode('
', $alerts)); - } function exclude_tree() { @@ -1058,11 +1052,10 @@ class MainWP_Child_Back_Up_Buddy { } $html = ob_get_clean(); - return array('result' => $html) ; + return array('result' => $html); } else { - return array('error' => 'Error #1127555. Unable to read child site root.') ; + return array('error' => 'Error #1127555. Unable to read child site root.'); } - } // ok @@ -1073,15 +1066,14 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_properties('pb_backupbuddy', 'format'); MainWP_Helper::check_methods(pb_backupbuddy::$format, 'file_size'); - $return = ''; $size_string = ''; global $wpdb; if ( true === $display_size ) { - $results = $wpdb->get_results( "SHOW TABLE STATUS", ARRAY_A ); + $results = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A ); } else { - $results = $wpdb->get_results( "SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()", ARRAY_A ); + $results = $wpdb->get_results( 'SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()', ARRAY_A ); } foreach( $results as $result ) { @@ -1135,7 +1127,7 @@ class MainWP_Child_Back_Up_Buddy { // If temp directory is within webroot then lock it down. $temp_dir = str_replace( '\\', '/', $temp_dir ); // Normalize for Windows. $temp_dir = rtrim( $temp_dir, '/\\' ) . '/'; // Enforce single trailing slash. - if ( FALSE !== stristr( $temp_dir, ABSPATH ) ) { // Temp dir is within webroot. + if ( false !== stristr( $temp_dir, ABSPATH ) ) { // Temp dir is within webroot. pb_backupbuddy::anti_directory_browsing( $destination ); } unset( $temp_dir ); @@ -1247,22 +1239,21 @@ class MainWP_Child_Back_Up_Buddy { // Backup status. $pretty_status = array( - true => 'Good', // v4.0+ Good. - 'pass' => 'Good', // Pre-v4.0 Good. - false => 'Bad', // v4.0+ Bad. - 'fail' => 'Bad', // Pre-v4.0 Bad. + true => 'Good', // v4.0+ Good. + 'pass' => 'Good', // Pre-v4.0 Good. + false => 'Bad', // v4.0+ Bad. + 'fail' => 'Bad', // Pre-v4.0 Bad. ); // Backup type. $pretty_type = array( - 'full' => 'Full', - 'db' => 'Database', - 'files' => 'Files', - 'themes' => 'Themes', - 'plugins' => 'Plugins', + 'full' => 'Full', + 'db' => 'Database', + 'files' => 'Files', + 'themes' => 'Themes', + 'plugins' => 'Plugins', ); - // Defaults... $detected_type = ''; $file_size = ''; @@ -1292,8 +1283,7 @@ class MainWP_Child_Back_Up_Buddy { ' . htmlentities( $backup_options->options['profile']['title'] ) . ' - ' - ; + '; } } @@ -1306,7 +1296,6 @@ class MainWP_Child_Back_Up_Buddy { $status = $backup_integrity['is_ok']; } - // Calculate main row string. if ( $type == 'default' ) { // Default backup listing. $download_url = '/wp-admin/admin-ajax.php?action=mainwp_backupbuddy_download_archive&backupbuddy_backup=' . basename( $file ) . '&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_backup' ); @@ -1321,14 +1310,13 @@ class MainWP_Child_Back_Up_Buddy { $main_string .= '
Note: ' . htmlentities( $backup_integrity['comment'] ) . ''; } - $integrity = pb_backupbuddy::$format->prettify( $status, $pretty_status ) . ' '; - if ( isset( $backup_integrity['scan_notes'] ) && count( (array)$backup_integrity['scan_notes'] ) > 0 ) { - foreach( (array)$backup_integrity['scan_notes'] as $scan_note ) { + if ( isset( $backup_integrity['scan_notes'] ) && count( (array) $backup_integrity['scan_notes'] ) > 0 ) { + foreach( (array) $backup_integrity['scan_notes'] as $scan_note ) { $integrity .= $scan_note . ' '; } } - $integrity .= ' '; + $integrity .= ' '; $integrity .= ''; $sumLogFile = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_' . pb_backupbuddy::$options['log_serial'] . '.txt'; @@ -1351,7 +1339,6 @@ class MainWP_Child_Back_Up_Buddy { $integrity, ); - $backup_sort_dates[basename( $file)] = $modified_time; } // End foreach(). @@ -1368,7 +1355,6 @@ class MainWP_Child_Back_Up_Buddy { } unset( $backups ); return $sorted_backups; - } // End backups_list(). function get_recent_backup_list () { @@ -1382,9 +1368,9 @@ class MainWP_Child_Back_Up_Buddy { // Backup type. $pretty_type = array( - 'full' => 'Full', - 'db' => 'Database', - 'files' => 'Files', + 'full' => 'Full', + 'db' => 'Database', + 'files' => 'Files', ); foreach( $recentBackups_list as $backup_fileoptions ) { @@ -1405,7 +1391,7 @@ class MainWP_Child_Back_Up_Buddy { $status = 'Completed'; } elseif ( $backup['finish_time'] == -1 ) { $status = 'Cancelled'; - } elseif ( FALSE === $backup['finish_time'] ) { + } elseif ( false === $backup['finish_time'] ) { $status = 'Failed (timeout?)'; } elseif ( ( time() - $backup['updated_time'] ) > backupbuddy_constants::TIME_BEFORE_CONSIDERED_TIMEOUT ) { $status = 'Failed (likely timeout)'; @@ -1414,7 +1400,6 @@ class MainWP_Child_Back_Up_Buddy { } $status .= '
'; - // Technical details link. $status .= '
'; $status .= 'View Details'; @@ -1480,7 +1465,7 @@ class MainWP_Child_Back_Up_Buddy { __('Status', 'mainwp-child' ) . ' (hover for options)', ); - function pb_backupbuddy_aasort (&$array, $key) { + function pb_backupbuddy_aasort ( &$array, $key) { $sorter=array(); $ret=array(); reset($array); @@ -1531,8 +1516,9 @@ class MainWP_Child_Back_Up_Buddy { ob_start(); ?> -

+ ?> +

Log file:
Integrity Technical Details'; @@ -1628,7 +1614,7 @@ class MainWP_Child_Back_Up_Buddy { } else { // 4.0+ Tests. $tests = array(); if ( isset( $integrity['tests'] ) ) { - foreach( (array)$integrity['tests'] as $test ) { + foreach( (array) $integrity['tests'] as $test ) { if ( true === $test['pass'] ) { $status_text = 'Pass'; } else { @@ -1647,8 +1633,8 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::$ui->list_table( $tests, array( - 'columns' => $columns, - 'css' => 'width: 100%; min-width: 200px;', + 'columns' => $columns, + 'css' => 'width: 100%; min-width: 200px;', ) ); @@ -1656,7 +1642,6 @@ class MainWP_Child_Back_Up_Buddy { echo '

'; //***** END TESTS AND RESULTS. - // Output meta info table (if any). $metaInfo = array(); if ( isset( $integrity['file'] ) && ( false === ( $metaInfo = backupbuddy_core::getZipMeta( backupbuddy_core::getBackupDirectory() . $integrity['file'] ) ) ) ) { // $backup_options->options['archive_file'] @@ -1665,14 +1650,13 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::$ui->list_table( $metaInfo, array( - 'columns' => array( 'Backup Details', 'Value' ), - 'css' => 'width: 100%; min-width: 200px;', + 'columns' => array( 'Backup Details', 'Value' ), + 'css' => 'width: 100%; min-width: 200px;', ) ); } echo '

'; - //***** BEGIN STEPS. $steps = array(); $steps[] = array( 'Start Time', $start_time, '' ); @@ -1714,14 +1698,13 @@ class MainWP_Child_Back_Up_Buddy { } // Step time taken. - $seconds = (int)( $step['finish_time'] - $step['start_time'] ); + $seconds = (int) ( $step['finish_time'] - $step['start_time'] ); if ( $seconds < 1 ) { $step_time = '< 1 second'; } else { $step_time = $seconds . ' seconds'; } - // Compile details for this step into array. $steps[] = array( $step_name, @@ -1735,7 +1718,6 @@ class MainWP_Child_Back_Up_Buddy { $step_times[] = 'unknown'; } // End if serial in array is NOT set. - // Total overall time from initiation to end. if ( isset( $backup_options->options['finish_time'] ) && isset( $backup_options->options['start_time'] ) && ( $backup_options->options['finish_time'] != 0 ) && ( $backup_options->options['start_time'] != 0 ) ) { $seconds = ( $backup_options->options['finish_time'] - $backup_options->options['start_time'] ); @@ -1766,8 +1748,8 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::$ui->list_table( $steps, array( - 'columns' => $columns, - 'css' => 'width: 100%; min-width: 200px;', + 'columns' => $columns, + 'css' => 'width: 100%; min-width: 200px;', ) ); } @@ -1830,7 +1812,7 @@ class MainWP_Child_Back_Up_Buddy { $abspath = str_replace( '\\', '/', ABSPATH ); $backup_dir = str_replace( '\\', '/', backupbuddy_core::getBackupDirectory() ); - if ( FALSE === stristr( $backup_dir, $abspath ) ) { + if ( false === stristr( $backup_dir, $abspath ) ) { die( 'Error #5432532. You cannot download backups stored outside of the WordPress web root. Please use FTP or other means.' ); } @@ -1914,7 +1896,6 @@ class MainWP_Child_Back_Up_Buddy { } return array('ok' => 1); - } function backup_status() { @@ -1922,7 +1903,7 @@ class MainWP_Child_Back_Up_Buddy { $result = ''; if (is_array($data) && isset($data['serial'])) { ob_start(); - backupbuddy_api::getBackupStatus( $data['serial'], $data['specialAction'], $data['initwaitretrycount'], $data['sqlFile'], $echo = true ); + backupbuddy_api::getBackupStatus( $data['serial'], $data['specialAction'], $data['initwaitretrycount'], $data['sqlFile'], $echo = true ); $result = ob_get_clean(); } else { return array('error' => 'Invalid backup request.'); @@ -1948,7 +1929,7 @@ class MainWP_Child_Back_Up_Buddy { 'accesskey', 'secretkey', 'bucket', - 'region' + 'region', ); foreach($not_override as $opt) { if (isset($data[$opt])) { @@ -1961,7 +1942,6 @@ class MainWP_Child_Back_Up_Buddy { unset($data['do_not_override']); } - if (is_array($data)) { if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data ); @@ -2043,7 +2023,6 @@ class MainWP_Child_Back_Up_Buddy { return array( 'error' => 'Error #833383: Invalid destination ID `' . htmlentities( $destination_id ) . '`.' ); } - // For Stash we will check the quota prior to initiating send. if ( pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash' ) { // Pass off to destination handler. @@ -2079,7 +2058,7 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::status( 'details', 'Scheduling cron to send to this remote destination...' ); $schedule_result = backupbuddy_core::schedule_single_event( time(), 'remote_send', array( $destination_id, $backup_file, $trigger, $send_importbuddy, $delete_after ) ); - if ( $schedule_result === FALSE ) { + if ( $schedule_result === false ) { $error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.'; pb_backupbuddy::status( 'error', $error ); return array( 'error' => $error); @@ -2120,7 +2099,7 @@ class MainWP_Child_Back_Up_Buddy { } else if ( 'delete_tempfiles_now' == $other_action) { $tempDir = backupbuddy_core::getTempDirectory(); $logDir = backupbuddy_core::getLogDirectory(); - $message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.' ; + $message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.'; pb_backupbuddy::$filesystem->unlink_recursive( $tempDir ); pb_backupbuddy::$filesystem->unlink_recursive( $logDir ); pb_backupbuddy::anti_directory_browsing( $logDir, $die = false ); // Put log dir back in place. @@ -2156,7 +2135,7 @@ class MainWP_Child_Back_Up_Buddy { if ( true !== ( $result = $backup_options->is_ok() ) ) { pb_backupbuddy::status( 'error', 'Error retrieving fileoptions file `' . $file . '`. Err 335353266.' ); } else { - if ( empty( $backup_options->options['finish_time'] ) || ( ( FALSE !== $backup_options->options['finish_time'] ) && ( '-1' != $backup_options->options['finish_time'] ) ) ) { + if ( empty( $backup_options->options['finish_time'] ) || ( ( false !== $backup_options->options['finish_time'] ) && ( '-1' != $backup_options->options['finish_time'] ) ) ) { $backup_options->options['finish_time'] = -1; // Force marked as cancelled by user. $backup_options->save(); $cancelCount++; @@ -2184,7 +2163,7 @@ class MainWP_Child_Back_Up_Buddy { $url = home_url(); } else { $url = str_replace( $_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI'] ); - $url = str_replace( basename( $url ) , '', $url ); + $url = str_replace( basename( $url ), '', $url ); $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; } ?> @@ -2239,12 +2218,12 @@ class MainWP_Child_Back_Up_Buddy { 'blocking' => true, 'headers' => array(), 'body' => null, - 'cookies' => array() + 'cookies' => array(), ) ); if ( is_wp_error( $scan ) ) { - pb_backupbuddy::alert( __('ERROR #24452. Unable to load Malware Scan results. Details:', 'it-l10n-backupbuddy' ). ' ' . $scan->get_error_message(), true ); + pb_backupbuddy::alert( __('ERROR #24452. Unable to load Malware Scan results. Details:', 'it-l10n-backupbuddy' ) . ' ' . $scan->get_error_message(), true ); $scan = 'N;'; } else { $scan = $scan['body']; @@ -2255,7 +2234,7 @@ class MainWP_Child_Back_Up_Buddy { $continue_2 = true; if ( substr( $scan, 0, 2 ) == 'N;' ) { - echo __('An error was encountered attempting to scan this site.','it-l10n-backupbuddy' ), '
'; + echo __('An error was encountered attempting to scan this site.', 'it-l10n-backupbuddy' ), '
'; echo __('An internet connection is required and this site must be accessible on the public internet.', 'it-l10n-backupbuddy' ); echo '
'; $scan = array(); @@ -2276,7 +2255,6 @@ class MainWP_Child_Back_Up_Buddy { '.__('none', 'it-l10n-backupbuddy' ).'
'; + return '' . __('none', 'it-l10n-backupbuddy' ) . '
'; } else { return $array . '
'; } @@ -2312,10 +2290,10 @@ class MainWP_Child_Back_Up_Buddy {
@@ -2396,7 +2441,6 @@ class MainWP_Child_Back_Up_Buddy {
$errors ); } - } function live_save_settings() { $data = $_POST['data']; $new_destination_id = $_POST['destination_id']; - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live.php' ); require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); @@ -2603,7 +2641,7 @@ class MainWP_Child_Back_Up_Buddy { $sumLogFile = backupbuddy_core::getLogDirectory() . 'status-live_periodic_' . pb_backupbuddy::$options['log_serial'] . '.txt'; @unlink( $sumLogFile ); if ( file_exists( $sumLogFile ) ) { - $error = 'Error #893489322: Unable to clear log file `' . $sumLogFile . '`. Check permissions or manually delete.' ; + $error = 'Error #893489322: Unable to clear log file `' . $sumLogFile . '`. Check permissions or manually delete.'; } else { $message = 'Log file cleared.'; } @@ -2691,14 +2729,14 @@ class MainWP_Child_Back_Up_Buddy { } $backup_list_temp = array(); - foreach( (array)$files as $file ) { + foreach( (array) $files as $file ) { if ( ( '' != $remotePath ) && ( ! backupbuddy_core::startsWith( basename( $file['filename'] ), $remotePath ) ) ) { // Only show backups for this site unless set to show all. continue; } $last_modified = $file['uploaded_timestamp']; - $size = (double) $file['size']; + $size = (float) $file['size']; $backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true ); // Generate array of table rows. @@ -2748,14 +2786,13 @@ class MainWP_Child_Back_Up_Buddy { $settings = &pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; $settings = pb_backupbuddy_destination_stash2::_formatSettings( $settings ); - pb_backupbuddy::status( 'details', 'Scheduling Cron for creating Stash copy.' ); + pb_backupbuddy::status( 'details', 'Scheduling Cron for creating Stash copy.' ); backupbuddy_core::schedule_single_event( time(), 'process_remote_copy', array( 'stash2', $file, $settings ) ); if ( '1' != pb_backupbuddy::$options['skip_spawn_cron_call'] ) { update_option( '_transient_doing_cron', 0 ); // Prevent cron-blocking for next item. spawn_cron( time() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit. } return array( 'ok' => 1 ); - } function delete_file_backup() { @@ -2773,12 +2810,12 @@ class MainWP_Child_Back_Up_Buddy { $settings = pb_backupbuddy_destination_stash2::_formatSettings( $settings ); $deleteFiles = array(); - foreach( (array)$files as $file ) { + foreach( (array) $files as $file ) { $file = base64_decode( $file ); $startPos = pb_backupbuddy_destination_stash2::strrpos_count( $file, '/', 2 ) + 1; // next to last slash. $file = substr( $file, $startPos ); - if ( FALSE !== strstr( $file, '?' ) ) { + if ( false !== strstr( $file, '?' ) ) { $file = substr( $file, 0, strpos( $file, '?' ) ); } $deleteFiles[] = $file; @@ -2846,7 +2883,7 @@ class MainWP_Child_Back_Up_Buddy { } - return array('result' => json_encode( $stats )); + return array('result' => json_encode( $stats )); } function save_license_settings() { @@ -2896,7 +2933,6 @@ class MainWP_Child_Back_Up_Buddy { require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); - $response = Ithemes_Updater_API::activate_package( $username, $password, $packages ); if ( is_wp_error( $response ) ) { @@ -2931,7 +2967,6 @@ class MainWP_Child_Back_Up_Buddy { $fail[$name] = $data['error']['message']; } - if ( ! empty( $success ) ) { $messages[] = wp_sprintf( __( 'Successfully licensed %l.', 'it-l10n-backupbuddy' ), $success ); $return['messages'] = $messages; @@ -2983,7 +3018,6 @@ class MainWP_Child_Back_Up_Buddy { return $return; } - uksort( $response['packages'], 'strnatcasecmp' ); $success = array(); @@ -3003,7 +3037,6 @@ class MainWP_Child_Back_Up_Buddy { $fail[$name] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' ); } - if ( ! empty( $success ) ) { $messages[] = wp_sprintf( _n( 'Successfully removed license from %l.', 'Successfully removed licenses from %l.', count( $success ), 'it-l10n-mainwp-backupbuddy' ), $success ); $return['messages'] = $messages; @@ -3040,7 +3073,7 @@ class MainWP_Child_Back_Up_Buddy { $message = sprintf( __( '%1$s could not be licensed since the membership account is out of available licenses for this product. You can unlicense the product on other sites or upgrade your membership to one with a higher number of licenses in order to increase the amount of available licenses.', 'it-l10n-mainwp-backupbuddy' ), $package_name ); break; case 'ITXAPI_License_Key_Generate_Failed': - $message = sprintf( __( '%s could not be licensed due to an internal error. Please try to license %s again at a later time. If this problem continues, please contact iThemes support.', 'it-l10n-mainwp-backupbuddy' ), $package_name ); + $message = sprintf( __( '%1$s could not be licensed due to an internal error. Please try to license %2$s again at a later time. If this problem continues, please contact iThemes support.', 'it-l10n-mainwp-backupbuddy' ), $package_name ); break; } diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index 17659d1..7fb7860 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -21,11 +21,11 @@ class MainWP_Child_Back_Up_Wordpress { public static $instance = null; public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_Back_Up_Wordpress::$instance ) { - MainWP_Child_Back_Up_Wordpress::$instance = new MainWP_Child_Back_Up_Wordpress(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Back_Up_Wordpress(); } - return MainWP_Child_Back_Up_Wordpress::$instance; + return self::$instance; } public function __construct() { @@ -36,7 +36,6 @@ class MainWP_Child_Back_Up_Wordpress { add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } } - } public function init() { @@ -201,7 +200,7 @@ class MainWP_Child_Back_Up_Wordpress { } // ok - public function do_reports_log($ext = '') { + public function do_reports_log( $ext = '') { if ( $ext !== 'backupwordpress' ) return; if (!$this->is_plugin_installed) return; @@ -219,12 +218,12 @@ class MainWP_Child_Back_Up_Wordpress { foreach($schedules as $schedule) { foreach ( $schedule->get_backups() as $file ) { $backup_type = $schedule->get_type(); - $message = "BackupWordpres backup " . $backup_type . ' finished'; - $destination = "N/A"; + $message = 'BackupWordpres backup ' . $backup_type . ' finished'; + $destination = 'N/A'; if ( file_exists( $file ) ) { $date = @filemtime( $file ); if ( !empty( $date ) ) { - do_action( "mainwp_reports_backupwordpress_backup", $destination, $message, 'finished', $backup_type, $date ); + do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date ); MainWP_Helper::update_lasttime_backup('backupwordpress', $date); // to support backup before update feature } } @@ -262,7 +261,6 @@ class MainWP_Child_Back_Up_Wordpress { $schedule_id = $this->check_schedule(); $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); - // Delete the running backup if (method_exists($schedule, 'get_running_backup_filename' )) { if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) { @@ -445,7 +443,7 @@ class MainWP_Child_Back_Up_Wordpress { - + @@ -456,7 +454,8 @@ class MainWP_Child_Back_Up_Wordpress { - get_backups() ) { + get_backups() ) { $schedule->delete_old_backups(); @@ -469,7 +468,8 @@ class MainWP_Child_Back_Up_Wordpress { $this->hmbkp_get_backup_row( $file, $schedule ); } - } else { ?> + } else { + ?> ' . __( 'calculating the size of your backup…', 'mainwp-backupwordpress-extension' ) . ')' ); - } function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) { @@ -525,20 +524,23 @@ class MainWP_Child_Back_Up_Wordpress { - | - | - @@ -550,7 +552,8 @@ class MainWP_Child_Back_Up_Wordpress { - get_default_excludes() ) ) || ( HM\BackUpWordPress\Path::get_path() === trailingslashit( HM\BackUpWordPress\Path::get_root() ) . untrailingslashit( $exclude ) ); else - $is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ) ; + $is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ); - if ( $is_default_rule ) : ?> + if ( $is_default_rule ) : + ?> @@ -668,7 +672,7 @@ class MainWP_Child_Back_Up_Wordpress { // Kick off a recursive filesize scan if ($new_version) { - $site_size = new HM\BackUpWordPress\Site_Size; + $site_size = new HM\BackUpWordPress\Site_Size(); $exclude_string = implode( '|', $excludes->get_excludes_for_regex() ); @@ -680,7 +684,8 @@ class MainWP_Child_Back_Up_Wordpress { $exclude_string = $schedule->backup->exclude_string( 'regex' ); } - if ( $files ) { ?> + if ( $files ) { + ?> @@ -702,16 +707,19 @@ class MainWP_Child_Back_Up_Wordpress { - $file ) { + $file ) { $is_excluded = $is_unreadable = false; @@ -811,7 +820,8 @@ class MainWP_Child_Back_Up_Wordpress { // Skip unreadable files if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) { $is_unreadable = true; - } ?> + } + ?> @@ -836,7 +846,8 @@ class MainWP_Child_Back_Up_Wordpress { - - + + =', '3.4', 'getWordpressVersion' ); self::renderRow( 'WordPress Memory Limit', '>=', '64M', 'getWordpressMemoryLimit' ); self::renderRow( 'MultiSite Disabled', '=', true, 'checkIfMultisite' ); @@ -599,7 +605,8 @@ class MainWP_Child_Server_Information { - + =', '5.6', 'getPHPVersion' ); ?> @@ -629,13 +636,15 @@ class MainWP_Child_Server_Information { - + =', '5.0', 'getMySQLVersion' ); ?> - + - + Warning'; } @@ -1170,7 +1178,10 @@ class MainWP_Child_Server_Information { } protected static function getArchitecture() { - echo esc_html( PHP_INT_SIZE * 8 ) ?> bit +  bit + 'test'); $url = add_query_arg( $query_args, $url ); - $args = array( 'blocking' => TRUE, - 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), - 'timeout' => 15 + $args = array( 'blocking' => true, + 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), + 'timeout' => 15, ); $response = wp_remote_post( $url, $args ); $test_result = ''; if ( is_wp_error( $response ) ) { - $test_result .= sprintf( __( 'The HTTP response test get an error "%s"','mainwp-child' ), $response->get_error_message() ); + $test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() ); } $response_code = wp_remote_retrieve_response_code( $response ); if ( $response_code < 200 && $response_code > 204 ) { - $test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)','mainwp-child' ), wp_remote_retrieve_response_code( $response ) ); + $test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), wp_remote_retrieve_response_code( $response ) ); } else { $response_body = wp_remote_retrieve_body( $response ); - if ( FALSE === strstr( $response_body, 'MainWP Test' ) ) { - $test_result .= sprintf( __( 'Not expected HTTP response body: %s','mainwp-child' ), esc_attr( strip_tags( $response_body ) ) ); + if ( false === strstr( $response_body, 'MainWP Test' ) ) { + $test_result .= sprintf( __( 'Not expected HTTP response body: %s', 'mainwp-child' ), esc_attr( strip_tags( $response_body ) ) ); } } if ( empty( $test_result ) ) { @@ -1411,7 +1422,6 @@ class MainWP_Child_Server_Information { } return $bytes; - } @@ -1472,7 +1482,7 @@ class MainWP_Child_Server_Information { $branding_title = 'MainWP'; } $msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.'; - echo ''; + echo ''; return; } @@ -1504,7 +1514,6 @@ class MainWP_Child_Server_Information { echo wp_kses_post( "" ); } } - } static function time_compare( $a, $b ) { @@ -1624,27 +1633,27 @@ class MainWP_Child_Server_Information { 'siteurl' => array( 'title' => __('Site URL', 'mainwp-child'), 'value' => get_bloginfo( 'url' ), - 'desc' => get_bloginfo( 'url' ) + 'desc' => get_bloginfo( 'url' ), ), 'adminuser' => array( 'title' => __('Administrator name', 'mainwp-child'), 'value' => $current_user->user_login, - 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child') + 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), ), 'friendly_name' => array( 'title' => __('Friendly site name', 'mainwp-child'), 'value' => get_bloginfo( 'name' ), - 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child') + 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), ), 'uniqueid' => array( 'title' => __('Child unique security id', 'mainwp-child'), 'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), - 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child') , stripslashes( $branding_title ) ) + 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), ), 'verify_ssl' => array( 'title' => __('Verify certificate', 'mainwp-child'), 'value' => __('Yes', 'mainwp-child'), - 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child') + 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), ), 'ssl_version' => array( 'title' => __('SSL version', 'mainwp-child'), @@ -1659,7 +1668,7 @@ class MainWP_Child_Server_Information {
- / - + foreach ( $parents as $directory_basename ) { + ?> @@ -793,7 +801,8 @@ class MainWP_Child_Back_Up_Wordpress {
+ if ( $is_unreadable ) { + ?> getBasename() ); ?> @@ -852,9 +863,11 @@ class MainWP_Child_Back_Up_Wordpress { onclick="event.preventDefault(); mainwp_backupwp_directory_browse('getPathname()) ); ?>', this)">getBasename() ); ?> - + if ( $is_unreadable ) { + ?> getBasename() ); ?> @@ -864,14 +877,16 @@ class MainWP_Child_Back_Up_Wordpress { getBasename() ); ?> - isDir() ) { + isDir() ) { //echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) ); ?> getBasename() ); ?> - @@ -897,7 +912,8 @@ class MainWP_Child_Back_Up_Wordpress { if ( ! $size ) { $size = '0 B'; - } ?> + } + ?> @@ -918,7 +934,8 @@ class MainWP_Child_Back_Up_Wordpress { -- - @@ -935,7 +952,8 @@ class MainWP_Child_Back_Up_Wordpress { - isDir() ) : + isDir() ) : esc_html_e( 'Folder', 'backupwordpress' ); @@ -999,7 +1017,6 @@ class MainWP_Child_Back_Up_Wordpress { $information['e'] = $output; return $information; - } function directory_browse() { @@ -1038,7 +1055,6 @@ class MainWP_Child_Back_Up_Wordpress { $out['current_browse_dir'] = $_POST['browse_dir']; return $out; - } function hmbkp_remove_exclude_rule() { @@ -1101,7 +1117,6 @@ class MainWP_Child_Back_Up_Wordpress { } } - $un_exclude_paths = urldecode( $_POST['un_exclude_paths'] ); $un_exclude_paths = explode("\n", $un_exclude_paths); diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 2eccfcf..1a93178 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -58,11 +58,11 @@ class MainWP_Child_Back_WP_Up { ); static function Instance() { - if ( MainWP_Child_Back_WP_Up::$instance == null ) { - MainWP_Child_Back_WP_Up::$instance = new MainWP_Child_Back_WP_Up(); + if ( self::$instance == null ) { + self::$instance = new MainWP_Child_Back_WP_Up(); } - return MainWP_Child_Back_WP_Up::$instance; + return self::$instance; } public function __construct() { @@ -73,12 +73,12 @@ class MainWP_Child_Back_WP_Up { if ( is_plugin_active( 'backwpup-pro/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php' ) ) { $file_path1 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/backwpup.php'; $file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/Pro/class-pro.php'; - + // to fix if ( ! file_exists( $file_path2 ) ) { $file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php'; } - + MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 )); require_once( $file_path1 ); require_once( $file_path2 ); @@ -97,7 +97,7 @@ class MainWP_Child_Back_WP_Up { BackWPup::get_instance(); //add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) ); - add_action( 'admin_init', array( $this, 'init_download_backup' ) ); + add_action( 'admin_init', array( $this, 'init_download_backup' ) ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } } catch ( Exception $e) { @@ -116,11 +116,11 @@ class MainWP_Child_Back_WP_Up { error_reporting( 0 ); function mainwp_backwpup_handle_fatal_error() { $error = error_get_last(); - $info = MainWP_Child_Back_WP_Up::$information; + $info = self::$information; if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); } else if ( ! empty( $info ) ) { - MainWP_Helper::write( MainWP_Child_Back_WP_Up::$information ); + MainWP_Helper::write( self::$information ); } else { MainWP_Helper::write( array( 'error' => 'Missing information array inside fatal_error' ) ); } @@ -212,7 +212,7 @@ class MainWP_Child_Back_WP_Up { } } - MainWP_Child_Back_WP_Up::$information = $information; + self::$information = $information; exit(); } @@ -237,7 +237,7 @@ class MainWP_Child_Back_WP_Up { } } // ok - public function do_reports_log($ext = '') { + public function do_reports_log( $ext = '') { if ( $ext !== 'backwpup' ) return; if (!$this->is_backwpup_installed) return; @@ -257,9 +257,9 @@ class MainWP_Child_Back_WP_Up { //load logs $logfiles = array(); if ( is_readable( $log_folder ) && $dir = opendir( $log_folder ) ) { - while ( ( $file = readdir( $dir ) ) !== FALSE ) { + while ( ( $file = readdir( $dir ) ) !== false ) { $log_file = $log_folder . '/' . $file; - if ( is_file( $log_file ) && is_readable( $log_file ) && FALSE !== strpos( $file, 'backwpup_log_' ) && FALSE !== strpos( $file, '.html' ) ) { + if ( is_file( $log_file ) && is_readable( $log_file ) && false !== strpos( $file, 'backwpup_log_' ) && false !== strpos( $file, '.html' ) ) { $logfiles[] = $file; } } @@ -286,13 +286,13 @@ class MainWP_Child_Back_WP_Up { 'FILE' => __('File backup', 'mainwp-child'), 'WPEXP' => __('WordPress XML export', 'mainwp-child'), 'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'), - 'DBCHECK' => __('Check database tables', 'mainwp-child') + 'DBCHECK' => __('Check database tables', 'mainwp-child'), ); $new_lasttime_logged = $lasttime_logged; foreach ($log_items as $log) { - $backup_time = $log[ "logtime" ]; + $backup_time = $log[ 'logtime' ]; if ($backup_time < $lasttime_logged) { // small than last backup time then skip continue; @@ -332,7 +332,7 @@ class MainWP_Child_Back_WP_Up { try{ $lastbackup = MainWP_Helper::get_lasttime_backup('backwpup'); $information['syncBackwpupData'] = array( - 'lastbackup' => $lastbackup + 'lastbackup' => $lastbackup, ); } catch(Exception $e) { @@ -692,7 +692,7 @@ class MainWP_Child_Back_WP_Up { foreach ( $items as $item ) { $temp_single_item = $item; $temp_single_item['dest'] = $jobid . '_' . $dest; - $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item[ 'time' ], TRUE ), date_i18n( get_option( 'time_format' ), $temp_single_item[ 'time' ], TRUE ) ); + $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item[ 'time' ], true ), date_i18n( get_option( 'time_format' ), $temp_single_item[ 'time' ], true ) ); $output->items[] = $temp_single_item; } } @@ -755,17 +755,17 @@ class MainWP_Child_Back_WP_Up { '&', admin_url( 'admin-ajax.php' ) . '?action=mainwp_backwpup_download_backup&type=', ), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) ); - + $temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups'; if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches )) { if ( !empty( $matches[1] ) && is_numeric( $matches[1] ) ) { - $temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1]; - } - error_log('did match' . print_r($matches, true)); + $temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1]; + } + error_log('did match' . print_r($matches, true)); } else { error_log('not match'); } - + $temp_array['website_id'] = $website_id; if ( ! isset( $without_dupes[ $temp_array['file'] ] ) ) { @@ -798,8 +798,8 @@ class MainWP_Child_Back_WP_Up { verify_nonce_without_session( $_GET['_wpnonce'], 'mainwp_download_backup' ) ) { die( '-3' ); } - + $dest = strtoupper( str_replace( 'download', '', $_GET['type'] ) ); if ( ! empty( $dest ) && strstr( $_GET['type'], 'download' ) ) { $dest_class = BackWPup::get_destination( $dest ); if ( is_null( $dest_class ) ) { die( '-4' ); - } + } $dest_class->file_download( (int) $_GET['jobid'], $_GET['file'] ); } else { @@ -825,7 +825,7 @@ class MainWP_Child_Back_WP_Up { } die(); - } + } protected function create_nonce_without_session( $action = - 1 ) { $user = wp_get_current_user(); @@ -969,7 +969,6 @@ class MainWP_Child_Back_WP_Up { if ( ! function_exists( 'add_screen_option' ) ) { function add_screen_option( $option, $args = array() ) { - } } @@ -1376,7 +1375,7 @@ class MainWP_Child_Back_WP_Up { update_site_option( 'backwpup_messages', array() ); if (isset($settings['value']['backupdir']) && empty($settings['value']['backupdir'])) { - $backupdir = BackWPup_Option::get( (int)$job_id, 'backupdir' ); + $backupdir = BackWPup_Option::get( (int) $job_id, 'backupdir' ); if (!empty($backupdir)) { $settings['value']['backupdir'] = $backupdir; } @@ -1524,7 +1523,6 @@ class MainWP_Child_Back_WP_Up { } else { return array( 'error' => 'Generic error' ); } - } } diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 0b560de..9e007f9 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -7,10 +7,10 @@ class MainWP_Child_Branding { public $child_branding_options = null; static function Instance() { - if ( null === MainWP_Child_Branding::$instance ) { - MainWP_Child_Branding::$instance = new MainWP_Child_Branding(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Branding(); } - return MainWP_Child_Branding::$instance; + return self::$instance; } public function __construct() { @@ -20,7 +20,7 @@ class MainWP_Child_Branding { $this->child_branding_options = $this->init_options(); } - function init_options(){ + function init_options() { $opts = get_option( 'mainwp_child_branding_settings' ); @@ -56,9 +56,9 @@ class MainWP_Child_Branding { $opts['branding_preserve_title'] = stripslashes( $branding_header['name'] ); } } - } - - $opts = apply_filters( 'mainwp_child_branding_init_options', $opts ); + } + + $opts = apply_filters( 'mainwp_child_branding_init_options', $opts ); return $opts; } @@ -150,7 +150,6 @@ class MainWP_Child_Branding { } } MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options ); - } @@ -211,7 +210,7 @@ class MainWP_Child_Branding { $current_settings['remove_restore'] = $settings['child_remove_restore']; $current_settings['remove_setting'] = $settings['child_remove_setting']; $current_settings['remove_server_info'] = $settings['child_remove_server_info']; - $current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0 ; + $current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0; $current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools']; $current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting']; $current_settings['remove_permalink'] = $settings['child_remove_permalink']; @@ -410,18 +409,22 @@ class MainWP_Child_Branding { if ( 'T' === $opts['disable_change']) { - // Disable the wordpress plugin update notifications + // Disable the WordPress plugin update notifications remove_action('load-update-core.php', 'wp_update_plugins'); add_filter('pre_site_transient_update_plugins', '__return_null'); - // Disable the wordpress theme update notifications + // Disable the WordPress theme update notifications remove_action('load-update-core.php', 'wp_update_themes'); - add_filter('pre_site_transient_update_themes', ( $func = function($a){ return null;} )); + add_filter('pre_site_transient_update_themes', ( $func = function( $a) { + return null; +} )); - // Disable the wordpress core update notifications + // Disable the WordPress core update notifications add_action('after_setup_theme', 'remove_core_updates'); function remove_core_updates() { - add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2); + add_action('init', ( $func = function( $a) { + remove_action( 'wp_version_check', 'wp_version_check' ); +} ), 2); add_filter('pre_option_update_core', '__return_null'); add_filter('pre_site_transient_update_core', '__return_null'); } @@ -470,8 +473,7 @@ class MainWP_Child_Branding { // to fix conflict with other plugin function admin_menu() { $allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false); - if ( $allow_contact ) { - ; // ok + if ( $allow_contact ) {; // ok } else if ( !current_user_can( 'administrator' ) ) { return false; } @@ -500,7 +502,6 @@ class MainWP_Child_Branding { add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 ); } } - } function remove_default_post_metaboxes() { @@ -630,7 +631,8 @@ class MainWP_Child_Branding { el.parentElement.innerHTML = ''; } }); - + child_branding_options['support_email']; $sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) ); $from = trim($_POST['mainwp_branding_contact_send_from']); - $subject = !empty( $sub ) ? $sub : "MainWP - Support Contact"; + $subject = !empty( $sub ) ? $sub : 'MainWP - Support Contact'; $content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) ); $mail = $headers = ''; if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) { global $current_user; $headers .= "Content-Type: text/html;charset=utf-8\r\n"; if (!empty($from)) - $headers .= "From: \"" . $from . "\" <" . $from . ">\r\n"; + $headers .= 'From: "' . $from . '" <' . $from . ">\r\n"; $mail .= "

Support Email from: " . site_url() . "

\r\n\r\n"; - $mail .= "

Sent from WordPress page: " . ( ! empty( $_POST["mainwp_branding_send_from_page"] ) ? "" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "

\r\n\r\n" : "" ); - $mail .= "

Client Email: " . $current_user->user_email . "

\r\n\r\n"; + $mail .= '

Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "

\r\n\r\n" : '' ); + $mail .= '

Client Email: ' . $current_user->user_email . "

\r\n\r\n"; $mail .= "

Support Text:

\r\n\r\n"; - $mail .= "

" . $content . "

\r\n\r\n"; + $mail .= '

' . $content . "

\r\n\r\n"; - if ( @wp_mail( $email, $subject, $mail, $headers ) ) { - ; + if ( @wp_mail( $email, $subject, $mail, $headers ) ) {; } return true; @@ -860,7 +861,8 @@ class MainWP_Child_Branding { } ?>
+ "/> - + + dbh ); + $rows = self::_query( 'SHOW table STATUS', $wpdb->dbh ); $size = 0; - while ( $row = MainWP_Child_DB::fetch_array( $rows ) ) { + while ( $row = self::fetch_array( $rows ) ) { $size += $row['Data_length']; } diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index ba421d3..73d9df8 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -20,11 +20,11 @@ class MainWP_Child_iThemes_Security { public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_iThemes_Security::$instance ) { - MainWP_Child_iThemes_Security::$instance = new MainWP_Child_iThemes_Security(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_iThemes_Security(); } - return MainWP_Child_iThemes_Security::$instance; + return self::$instance; } public function __construct() { @@ -43,7 +43,7 @@ class MainWP_Child_iThemes_Security { if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) { try{ $information['syncIThemeData'] = array( - 'users_and_roles' => $this->get_available_admin_users_and_roles() + 'users_and_roles' => $this->get_available_admin_users_and_roles(), ); } catch(Exception $e) { error_log($e->getMessage()); @@ -63,7 +63,6 @@ class MainWP_Child_iThemes_Security { $mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/'; - if ( isset( $_POST['mwp_action'] ) ) { switch ( $_POST['mwp_action'] ) { case 'set_showhide': @@ -205,7 +204,7 @@ class MainWP_Child_iThemes_Security { $require_permalinks = false; $updated = false; - $errors = array(); + $errors = array(); $nbf_settings = array(); $update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); @@ -216,7 +215,7 @@ class MainWP_Child_iThemes_Security { if ($module == 'wordpress-salts') { $settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update } else if ($module == 'global') { - $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check' , 'nginx_file' ); + $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' ); foreach($keep_olds as $key) { $settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update } @@ -242,7 +241,8 @@ class MainWP_Child_iThemes_Security { } } if (!isset($settings['exclude']) ) { - $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );; + $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' ); + } } else if ($module == 'hide-backend') { if (isset($settings['enabled']) && !empty($settings['enabled'])) { @@ -317,21 +317,21 @@ class MainWP_Child_iThemes_Security { 'is_multisite' => is_multisite() ? 1 : 0, 'users_can_register' => get_site_option( 'users_can_register' ) ? 1 : 0, 'server_nginx' => ( ITSEC_Lib::get_server() === 'nginx' ) ? 1 : 0, - 'has_ssl' => ITSEC_Lib::get_ssl_support_probability(), - 'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ), - 'server_rules' => ITSEC_Lib_Config_File::get_server_config(), - 'config_rules' => ITSEC_Lib_Config_File::get_wp_config(), + 'has_ssl' => ITSEC_Lib::get_ssl_support_probability(), + 'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ), + 'server_rules' => ITSEC_Lib_Config_File::get_server_config(), + 'config_rules' => ITSEC_Lib_Config_File::get_wp_config(), 'lockouts_host' => $this->get_lockouts( 'host', true ), 'lockouts_user' => $this->get_lockouts( 'user', true ), 'lockouts_username' => $this->get_lockouts( 'username', true ), 'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ), 'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ), 'excludable_tables' => $this->get_excludable_tables(), - 'users_and_roles' => $this->get_available_admin_users_and_roles() + 'users_and_roles' => $this->get_available_admin_users_and_roles(), ); $return = array( - 'site_status' => $values + 'site_status' => $values, ); if ($require_permalinks) { @@ -376,7 +376,7 @@ class MainWP_Child_iThemes_Security { return $information; } - private function validate_directory($name, $folder) { + private function validate_directory( $name, $folder) { require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' ); $error = null; if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) { @@ -399,7 +399,7 @@ class MainWP_Child_iThemes_Security { } } - private function activate_api_key($settings) { + private function activate_api_key( $settings) { global $mainwp_itsec_modules_path; require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' ); @@ -483,7 +483,6 @@ class MainWP_Child_iThemes_Security { return $response; } - } function whitelist_release() { @@ -516,7 +515,7 @@ class MainWP_Child_iThemes_Security { $return['result'] = 'success'; $return['message'] = $result; } else { - $str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type %1$s.', 'better-wp-security' ), gettype( $result ) ) ; + $str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type %1$s.', 'better-wp-security' ), gettype( $result ) ); } if (!empty($str_error)) { @@ -542,7 +541,7 @@ class MainWP_Child_iThemes_Security { } } else { $return['result'] = 'success'; - $return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ) ; + $return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ); $last_generated = ITSEC_Core::get_current_time_gmt(); ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated ); } @@ -584,7 +583,7 @@ class MainWP_Child_iThemes_Security { ), array( WP_PLUGIN_DIR, - 0755 + 0755, ), array( $wp_upload_dir['basedir'], @@ -600,7 +599,6 @@ class MainWP_Child_iThemes_Security { ), ); - $rows = array(); foreach ( $path_data as $path ) { @@ -632,7 +630,6 @@ class MainWP_Child_iThemes_Security { $rows[] = $row; } - $class = 'entry-row'; ob_start(); ?> @@ -696,7 +693,6 @@ class MainWP_Child_iThemes_Security { $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; - //load utility functions if ( ! class_exists( 'ITSEC_Lib' ) ) { global $itsec_globals; @@ -716,7 +712,6 @@ class MainWP_Child_iThemes_Security { } } - if ( true === $change_id && ! $user_id_exists ) { if ( ! empty( $msg ) ) { $msg .= '
'; @@ -773,7 +768,7 @@ class MainWP_Child_iThemes_Security { } else { // we're only changing the username //query main user table - $wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); + $wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation @@ -826,10 +821,10 @@ class MainWP_Child_iThemes_Security { $new_user = $wpdb->insert_id; - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . "` SET post_author = %s WHERE post_author = 1;", $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . "` SET user_id = %s WHERE user_id = 1;", $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . "` SET user_id = %s WHERE user_id = 1;", $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . "` SET link_owner = %s WHERE link_owner = 1;", $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . '` SET post_author = %s WHERE post_author = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . '` SET link_owner = %s WHERE link_owner = 1;', $new_user ) ); wp_clear_auth_cookie(); $itsec_files->release_file_lock( 'admin_user' ); @@ -840,7 +835,6 @@ class MainWP_Child_iThemes_Security { //} return false; - } public function build_wpconfig_rules( $rules_array, $input = null ) { @@ -872,7 +866,6 @@ class MainWP_Child_iThemes_Security { $rules_array[] = array( 'type' => 'wpconfig', 'name' => 'Content Directory', 'rules' => $rules ); return $rules_array; - } @@ -1120,18 +1113,17 @@ class MainWP_Child_iThemes_Security { update_site_option( 'itsec_active_modules', $current_val ); return array('result' => 'success'); - } - private function reload_backup_exclude( ) { + private function reload_backup_exclude() { return array( 'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ), 'excludable_tables' => $this->get_excludable_tables(), - 'result' => 'success' + 'result' => 'success', ); } - private function get_excludable_tables( ) { + private function get_excludable_tables() { global $wpdb; $all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' ); $ignored_tables = array( @@ -1167,7 +1159,7 @@ class MainWP_Child_iThemes_Security { $excludes[$short_table] = $table[0]; } - return $excludes ; + return $excludes; } private function security_site() { @@ -1178,7 +1170,7 @@ class MainWP_Child_iThemes_Security { ob_start(); ITSEC_Security_Check_Feedback_Renderer::render( $results ); $response = ob_get_clean(); - return array('result' => 'success' , 'response' => $response); + return array('result' => 'success', 'response' => $response); } // source from itheme plugin diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index c91e756..7b8cfe5 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -19,11 +19,11 @@ class MainWP_Child_Links_Checker { public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_Links_Checker::$instance ) { - MainWP_Child_Links_Checker::$instance = new MainWP_Child_Links_Checker(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Links_Checker(); } - return MainWP_Child_Links_Checker::$instance; + return self::$instance; } public function __construct() { @@ -36,7 +36,6 @@ class MainWP_Child_Links_Checker { return; add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); - } public function action() { @@ -248,13 +247,12 @@ class MainWP_Child_Links_Checker { $total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) ); - $max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50; $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $params = array( array( 'load_instances' => true ), - 'max_results' => $max_results + 'max_results' => $max_results, ); if (empty($offset)) { @@ -316,7 +314,7 @@ class MainWP_Child_Links_Checker { return $data; } - function links_checker_data($params) { + function links_checker_data( $params) { MainWP_Helper::check_functions('blc_get_links'); MainWP_Helper::check_classes_exists('blcLink'); @@ -345,7 +343,7 @@ class MainWP_Child_Links_Checker { 'dismissed', 'status_text', 'status_code', - 'log' + 'log', ); $return = array(); @@ -449,7 +447,6 @@ class MainWP_Child_Links_Checker { } return $return; - } function edit_link() { @@ -680,7 +677,7 @@ class MainWP_Child_Links_Checker { function ui_get_source_post( $container, $container_field = '' ) { return array( 'post_title' => get_the_title( $container->container_id ), - 'post_status' => get_post_status($container->container_id), + 'post_status' => get_post_status($container->container_id), 'container_anypost' => true, ); } diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index 43ccd2f..b104672 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -21,11 +21,11 @@ class MainWP_Child_Pagespeed { public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_Pagespeed::$instance ) { - MainWP_Child_Pagespeed::$instance = new MainWP_Child_Pagespeed(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Pagespeed(); } - return MainWP_Child_Pagespeed::$instance; + return self::$instance; } public function __construct() { @@ -60,7 +60,7 @@ class MainWP_Child_Pagespeed { case 'sync_data': $information = $this->get_sync_data(); break; - case "check_pages": + case 'check_pages': $information = $this->check_pages(); break; } @@ -267,7 +267,7 @@ class MainWP_Child_Pagespeed { return $information; } - function do_check_pages($forceRecheck = false) { + function do_check_pages( $forceRecheck = false) { $information = array(); if ( defined( 'GPI_DIRECTORY' ) ) { $checkstatus = apply_filters( 'gpi_check_status', false ); @@ -343,7 +343,6 @@ class MainWP_Child_Pagespeed { $score_column = $strategy . '_score'; //$page_stats_column = $strategy . '_page_stats'; - $data_typestocheck = self::get_filter_options( 'all' ); $gpi_page_stats = $wpdb->prefix . 'gpi_page_stats'; @@ -437,7 +436,7 @@ class MainWP_Child_Pagespeed { ); } - static function get_filter_options($restrict_type = 'all') { + static function get_filter_options( $restrict_type = 'all') { $types = array(); $gpi_options = get_option('gpagespeedi_options'); @@ -446,21 +445,21 @@ class MainWP_Child_Pagespeed { if($gpi_options['check_pages']) { if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') { $typestocheck[] = 'type = %s'; - $types[1][] = "page"; + $types[1][] = 'page'; } } if($gpi_options['check_posts']) { if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') { $typestocheck[] = 'type = %s'; - $types[1][] = "post"; + $types[1][] = 'post'; } } if($gpi_options['check_categories']) { if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') { $typestocheck[] = 'type = %s'; - $types[1][] = "category"; + $types[1][] = 'category'; } } if($gpi_options['cpt_whitelist']) { @@ -472,9 +471,9 @@ class MainWP_Child_Pagespeed { } $args=array( 'public' => true, - '_builtin' => false + '_builtin' => false, ); - $custom_post_types = get_post_types($args,'names','and'); + $custom_post_types = get_post_types($args, 'names', 'and'); if($restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored') { $restrict_type = str_replace('gpi_custom_posts-', '', $restrict_type); foreach($custom_post_types as $post_type) diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php index c0d52a0..24fa93c 100644 --- a/class/class-mainwp-child-plugins-check.php +++ b/class/class-mainwp-child-plugins-check.php @@ -29,11 +29,11 @@ class MainWP_Child_Plugins_Check { private $option_name_last_daily_run = 'mainwp_child_plugin_last_daily_run'; public static function Instance() { - if ( null === MainWP_Child_Plugins_Check::$instance ) { - MainWP_Child_Plugins_Check::$instance = new MainWP_Child_Plugins_Check(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Plugins_Check(); } - return MainWP_Child_Plugins_Check::$instance; + return self::$instance; } public function __construct() { @@ -119,7 +119,6 @@ class MainWP_Child_Plugins_Check { if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) { wp_schedule_event( time(), 'hourly', $this->cron_name_watcher ); } - } public function get_plugins_outdate_info() { @@ -143,7 +142,6 @@ class MainWP_Child_Plugins_Check { } return $plugins_outdate; - } // for testing diff --git a/class/class-mainwp-child-robot.php b/class/class-mainwp-child-robot.php index d48f416..e6abdef 100644 --- a/class/class-mainwp-child-robot.php +++ b/class/class-mainwp-child-robot.php @@ -4,11 +4,11 @@ class MainWP_Child_Robot { public static $instance = null; static function Instance() { - if ( null === MainWP_Child_Robot::$instance ) { - MainWP_Child_Robot::$instance = new MainWP_Child_Robot(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Robot(); } - return MainWP_Child_Robot::$instance; + return self::$instance; } public function wpr_insertcomments( $postid, $comments ) { diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index 4086472..64fd86f 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -473,12 +473,17 @@ class MainWP_Child_Server_Information {
-

+ +

+ +

+
@@ -583,8 +588,9 @@ class MainWP_Child_Server_Information {
' . $msg . '
' . $msg . '
{$time}{$error}
@@ -1682,4 +1691,4 @@ class MainWP_Child_Server_Information { ID ); $token = $manager->create( $expiration ); - $secure = is_ssl(); if ( $secure ) { $auth_cookie_name = SECURE_AUTH_COOKIE; diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index 303a7d5..477a668 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -22,10 +22,10 @@ class MainWP_Child_Staging { public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_Staging::$instance ) { - MainWP_Child_Staging::$instance = new MainWP_Child_Staging(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Staging(); } - return MainWP_Child_Staging::$instance; + return self::$instance; } public function __construct() { @@ -79,7 +79,7 @@ class MainWP_Child_Staging { } if (!class_exists( 'WPStaging\WPStaging' )){ - require_once WPSTG_PLUGIN_DIR . "apps/Core/WPStaging.php"; + require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php'; } \WPStaging\WPStaging::getInstance(); @@ -184,7 +184,7 @@ class MainWP_Child_Staging { public function get_overview() { $return = array( - 'availableClones' => get_option( "wpstg_existing_clones_beta", array()) + 'availableClones' => get_option( 'wpstg_existing_clones_beta', array()), ); return $return; } @@ -200,31 +200,31 @@ class MainWP_Child_Staging { $return = array( 'options' => serialize($options), 'directoryListing' => $scan->directoryListing(), - 'prefix' => WPStaging\WPStaging::getTablePrefix() + 'prefix' => WPStaging\WPStaging::getTablePrefix(), ); return $return; } public function ajaxCheckCloneName() { - $cloneName = sanitize_key( $_POST["cloneID"] ); + $cloneName = sanitize_key( $_POST['cloneID'] ); $cloneNameLength = strlen( $cloneName ); - $clones = get_option( "wpstg_existing_clones_beta", array() ); + $clones = get_option( 'wpstg_existing_clones_beta', array() ); // Check clone name length if( $cloneNameLength < 1 || $cloneNameLength > 16 ) { echo array( - "status" => "failed", - "message" => "Clone name must be between 1 - 16 characters" + 'status' => 'failed', + 'message' => 'Clone name must be between 1 - 16 characters', ); } elseif( array_key_exists( $cloneName, $clones ) ) { return array( - "status" => "failed", - "message" => "Clone name is already in use, please choose an another clone name" + 'status' => 'failed', + 'message' => 'Clone name is already in use, please choose an another clone name', ); } - return array("status" => "success"); + return array('status' => 'success'); } public function ajaxStartClone() { @@ -232,13 +232,12 @@ class MainWP_Child_Staging { $this->url = ''; // to fix warning $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - if( !$cloning->save() ) { return; } ob_start(); - require_once WPSTG_PLUGIN_DIR . "apps/Backend/views/clone/ajax/start.php"; + require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/start.php'; $result = ob_get_clean(); return $result; } @@ -286,7 +285,7 @@ class MainWP_Child_Staging { $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); $this->url = ''; // to fix warning $return = $cloning->start(); - $return->blogInfoName = get_bloginfo("name"); + $return->blogInfoName = get_bloginfo('name'); return $return; } @@ -301,7 +300,7 @@ class MainWP_Child_Staging { $clone = $delete->getClone(); $result = array( 'clone' => $clone, - 'deleteTables' => $delete->getTables() + 'deleteTables' => $delete->getTables(), ); return $result; } @@ -337,7 +336,7 @@ class MainWP_Child_Staging { } ob_start(); - require_once WPSTG_PLUGIN_DIR . "apps/Backend/views/clone/ajax/update.php"; + require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/update.php'; $result = ob_get_clean(); return $result; } @@ -348,20 +347,20 @@ class MainWP_Child_Staging { // from wp-staging plugin public function hasFreeDiskSpace() { - if( !function_exists( "disk_free_space" ) ) { + if( !function_exists( 'disk_free_space' ) ) { return null; } $freeSpace = @disk_free_space( ABSPATH ); if( false === $freeSpace ) { $data = array( 'freespace' => false, - 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)) + 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)), ); return $data; } $data = array( 'freespace' => $this->formatSize($freeSpace), - 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)) + 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)), ); return $data; } @@ -376,20 +375,19 @@ class MainWP_Child_Staging { } // from wp-staging plugin - public function formatSize($bytes, $precision = 2) - { - if ((double) $bytes < 1) + public function formatSize( $bytes, $precision = 2) { + if ( (float) $bytes < 1) { return ''; } - $units = array('B', "KB", "MB", "GB", "TB"); + $units = array('B', 'KB', 'MB', 'GB', 'TB'); - $bytes = (double) $bytes; + $bytes = (float) $bytes; $base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc $pow = pow(1000, $base - floor($base)); // Same rule for 1000 - return round($pow, $precision) . ' ' . $units[(int) floor($base)]; + return round($pow, $precision) . ' ' . $units[ (int) floor($base)]; } diff --git a/class/class-mainwp-child-themes-check.php b/class/class-mainwp-child-themes-check.php index 8bc87ea..a46a984 100644 --- a/class/class-mainwp-child-themes-check.php +++ b/class/class-mainwp-child-themes-check.php @@ -29,11 +29,11 @@ class MainWP_Child_Themes_Check { private $option_name_last_daily_run = 'mainwp_child_theme_last_daily_run'; public static function Instance() { - if ( null === MainWP_Child_Themes_Check::$instance ) { - MainWP_Child_Themes_Check::$instance = new MainWP_Child_Themes_Check(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Themes_Check(); } - return MainWP_Child_Themes_Check::$instance; + return self::$instance; } public function __construct() { @@ -49,7 +49,6 @@ class MainWP_Child_Themes_Check { add_action( 'mainwp_child_deactivation', array( $this, 'cleanup_deactivation' ) ); } - } private function cleanup_basic() { @@ -118,7 +117,6 @@ class MainWP_Child_Themes_Check { if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) { wp_schedule_event( time(), 'hourly', $this->cron_name_watcher ); } - } public function get_themes_outdate_info() { @@ -199,7 +197,6 @@ class MainWP_Child_Themes_Check { $diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' ); - if ( $diff_in_days < $tolerance_in_days ) { continue; } diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index c61d87b..a2ad5cb 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -19,10 +19,10 @@ class MainWP_Child_Timecapsule { public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_Timecapsule::$instance ) { - MainWP_Child_Timecapsule::$instance = new MainWP_Child_Timecapsule(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Timecapsule(); } - return MainWP_Child_Timecapsule::$instance; + return self::$instance; } public function __construct() { @@ -35,7 +35,6 @@ class MainWP_Child_Timecapsule { return; add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); - } @@ -76,8 +75,6 @@ class MainWP_Child_Timecapsule { $is_user_logged_in = $options->get_option('is_user_logged_in'); $privileges_wptc = $options_helper->get_unserialized_privileges(); - - if ( isset( $_POST['mwp_action'] ) ) { if (( @@ -222,7 +219,7 @@ class MainWP_Child_Timecapsule { public function require_files() { if (! class_exists('WPTC_Base_Factory') && defined('WPTC_PLUGIN_DIR') ) { if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Base/Factory.php') ) { - include_once WPTC_PLUGIN_DIR.'Base/Factory.php'; + include_once WPTC_PLUGIN_DIR . 'Base/Factory.php'; } } if ( ! class_exists('Wptc_Options_Helper') && defined('WPTC_PLUGIN_DIR') ) { @@ -285,7 +282,7 @@ class MainWP_Child_Timecapsule { 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), - 'backups_count' => $backups_count + 'backups_count' => $backups_count, ); return $return; } catch ( Exception $e) { @@ -316,7 +313,7 @@ class MainWP_Child_Timecapsule { die(); } - public function exclude_file_list(){ + public function exclude_file_list() { if (!isset($_POST['data'])) { wptc_die_with_json_encode( array('status' => 'no data found') ); } @@ -370,17 +367,16 @@ class MainWP_Child_Timecapsule { if (!empty($last_backup_time)) { $user_time = $config->cnvt_UTC_to_usrTime($last_backup_time); $processed_files->modify_schedule_backup_time($user_time); - $formatted_date = date("M d @ g:i a", $user_time); + $formatted_date = date('M d @ g:i a', $user_time); $return_array['last_backup_time'] = $formatted_date; } else { $return_array['last_backup_time'] = 'No Backup Taken'; } return array( 'result' => $return_array ); - } - function wptc_cron_status(){ + function wptc_cron_status() { $config = WPTC_Factory::get('config'); wptc_own_cron_status(); $status = array(); @@ -459,45 +455,47 @@ function get_sibling_files_callback_wptc() { $type = $_POST['type']; switch ($type) { case 'backups': - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id"; + break; case 'restores': - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'restore%' GROUP BY action_id"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'restore%' GROUP BY action_id"; + break; case 'staging': - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'staging%' GROUP BY action_id"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'staging%' GROUP BY action_id"; + break; case 'backup_and_update': - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'backup_and_update%' GROUP BY action_id"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'backup_and_update%' GROUP BY action_id"; + break; case 'auto_update': - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'auto_update%' GROUP BY action_id"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'auto_update%' GROUP BY action_id"; + break; case 'others': - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE type NOT LIKE 'restore%' AND type NOT LIKE 'backup%' AND show_user = 1"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type NOT LIKE 'restore%' AND type NOT LIKE 'backup%' AND show_user = 1"; + break; default: - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log GROUP BY action_id UNION SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE action_id='' AND show_user = 1"; - break; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log GROUP BY action_id UNION SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE action_id='' AND show_user = 1"; + break; } } else { - $query = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE show_user = 1 GROUP BY action_id "; + $query = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE show_user = 1 GROUP BY action_id '; } /* -- Preparing your query -- */ - /* -- Ordering parameters -- */ + /* + -- Ordering parameters -- */ //Parameters that are going to be used to order the result - $orderby = !empty($_POST["orderby"]) ? mysql_real_escape_string($_POST["orderby"]) : 'id'; - $order = !empty($_POST["order"]) ? mysql_real_escape_string($_POST["order"]) : 'DESC'; + $orderby = !empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id'; + $order = !empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC'; if (!empty($orderby) & !empty($order)) {$query .= ' ORDER BY ' . $orderby . ' ' . $order;} - /* -- Pagination parameters -- */ + /* + -- Pagination parameters -- */ //Number of elements in your table? $totalitems = $wpdb->query($query); //return the total number of affected rows //How many to display per page? $perpage = 20; //Which page is this? - $paged = !empty($_POST["paged"]) ? $_POST["paged"] : ''; + $paged = !empty($_POST['paged']) ? $_POST['paged'] : ''; if (empty($paged) || !is_numeric($paged) || $paged <= 0) {$paged = 1;} //Page Number //How many pages do we have in total? $totalpages = ceil($totalitems / $perpage); //Total number of pages @@ -507,14 +505,14 @@ function get_sibling_files_callback_wptc() { $query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage; } - return array( 'items' => $wpdb->get_results($query) , + return array( 'items' => $wpdb->get_results($query), 'totalitems' => $totalitems, - 'perpage' => $perpage + 'perpage' => $perpage, ); } - function lazy_load_activity_log_wptc(){ + function lazy_load_activity_log_wptc() { if (!isset($_POST['data'])) { return false; @@ -534,7 +532,7 @@ function get_sibling_files_callback_wptc() { $current_limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit'); $to_limit = $from_limit + $current_limit; - $sql = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE action_id=" . $action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT '.$from_limit.' , '.$current_limit; + $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE action_id=' . $action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT ' . $from_limit . ' , ' . $current_limit; $sub_records = $wpdb->get_results($sql); $row_count = count($sub_records); @@ -546,7 +544,7 @@ function get_sibling_files_callback_wptc() { $detailed = $this->get_activity_log($sub_records); if (isset($load_more) && $load_more) { - $detailed .= ''; + $detailed .= ''; } return array( 'result' => $detailed); @@ -555,7 +553,7 @@ function get_sibling_files_callback_wptc() { } - function get_display_rows($records) { + function get_display_rows( $records) { global $wpdb; //Get the records registered in the prepare_items method if (!is_array($records)) @@ -574,7 +572,7 @@ function get_sibling_files_callback_wptc() { $more_logs = false; $load_more = false; if ($rec->action_id != '') { - $sql = "SELECT * FROM " . $wpdb->base_prefix . "wptc_activity_log WHERE action_id=" . $rec->action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , '.$limit; + $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE action_id=' . $rec->action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , ' . $limit; $sub_records = $wpdb->get_results($sql); $row_count = count($sub_records); if ($row_count == $limit) { @@ -586,7 +584,7 @@ function get_sibling_files_callback_wptc() { $detailed = '
Load more
Load more
'; $detailed .= $this->get_activity_log($sub_records); if (isset($load_more) && $load_more) { - $detailed .= ''; + $detailed .= ''; } $detailed .= '
Load more
Load more
'; @@ -600,7 +598,7 @@ function get_sibling_files_callback_wptc() { // $user_tz = new DateTime('@' . $Ldata['log_time'], new DateTimeZone(date_default_timezone_get())); // $user_tz->setTimeZone(new DateTimeZone($timezone)); // $user_tz_now = $user_tz->format("M d, Y @ g:i:s a"); - $user_tz_now = date("M d, Y @ g:i:s a", $user_time); + $user_tz_now = date('M d, Y @ g:i:s a', $user_time); $msg = ''; if (!(strpos($rec->type, 'backup') === false)) { //Backup process @@ -621,14 +619,14 @@ function get_sibling_files_callback_wptc() { if ($more_logs) { $html .= "    View details"; } else { - $html .= ""; + $html .= ''; } $html .= 'Send report to plugin developer'; if ($more_logs) { - $html .= "" . $detailed . ""; + $html .= "" . $detailed . ''; } else { - $html .= ""; + $html .= ''; } //Close the line $html .= ''; @@ -641,7 +639,7 @@ function get_sibling_files_callback_wptc() { } - function get_activity_log($sub_records){ + function get_activity_log( $sub_records) { if (count($sub_records) < 1) { return false; } @@ -651,7 +649,7 @@ function get_sibling_files_callback_wptc() { $Moredata = unserialize($srec->log_data); $user_tmz = new DateTime('@' . $Moredata['log_time'], new DateTimeZone(date_default_timezone_get())); $user_tmz->setTimeZone(new DateTimeZone($timezone)); - $user_tmz_now = $user_tmz->format("M d @ g:i:s a"); + $user_tmz_now = $user_tmz->format('M d @ g:i:s a'); $detailed .= '' . $user_tmz_now . '' . $Moredata['msg'] . ''; } return $detailed; @@ -659,7 +657,7 @@ function get_sibling_files_callback_wptc() { function clear_wptc_logs() { global $wpdb; - if ($wpdb->query("TRUNCATE TABLE `" . $wpdb->base_prefix . "wptc_activity_log`")) { + if ($wpdb->query('TRUNCATE TABLE `' . $wpdb->base_prefix . 'wptc_activity_log`')) { $result = 'yes'; } else { $result = 'no'; @@ -684,7 +682,7 @@ function get_sibling_files_callback_wptc() { } - public function exclude_table_list(){ + public function exclude_table_list() { if (!isset($_POST['data'])) { wptc_die_with_json_encode( array('status' => 'no data found') ); } @@ -703,7 +701,7 @@ function get_sibling_files_callback_wptc() { } // ok - public function do_reports_log($ext = '') { + public function do_reports_log( $ext = '') { if ( $ext !== 'wptimecapsule' ) return; @@ -746,13 +744,12 @@ function get_sibling_files_callback_wptc() { } } - } catch(Exception $e) { } } - public function include_table_list(){ + public function include_table_list() { if (!isset($_POST['data'])) { wptc_die_with_json_encode( array('status' => 'no data found') ); } @@ -762,7 +759,7 @@ function get_sibling_files_callback_wptc() { die(); } - public function include_table_structure_only(){ + public function include_table_structure_only() { if (!isset($_POST['data'])) { wptc_die_with_json_encode( array('status' => 'no data found') ); @@ -774,7 +771,7 @@ function get_sibling_files_callback_wptc() { die(); } - public function include_file_list(){ + public function include_file_list() { if (!isset($_POST['data'])) { wptc_die_with_json_encode( array('status' => 'no data found') ); @@ -799,7 +796,7 @@ function get_sibling_files_callback_wptc() { if($options_helper->get_is_user_logged_in()){ return array( 'result' => 'is_user_logged_in', - 'sync_data' => $this->get_sync_data() + 'sync_data' => $this->get_sync_data(), ); } @@ -810,7 +807,6 @@ function get_sibling_files_callback_wptc() { return array('error' => 'Username and password cannot be empty'); } - $config = WPTC_Base_Factory::get('Wptc_InitialSetup_Config'); $options = WPTC_Factory::get('config'); @@ -823,13 +819,12 @@ function get_sibling_files_callback_wptc() { 'email' => $email, 'pwd' => trim( wp_unslash( $pwd )), 'return_response' => false, - 'sub_action' => false, + 'sub_action' => false, 'login_request' => true, 'reset_login_if_failed' => true, ) ); - $is_user_logged_in = $options->get_option('is_user_logged_in'); if (!$is_user_logged_in) { @@ -838,7 +833,7 @@ function get_sibling_files_callback_wptc() { return array('result' => 'ok', 'sync_data' => $this->get_sync_data()); } - function get_installed_plugins(){ + function get_installed_plugins() { $backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings'); $plugins = $backup_before_auto_update_settings->get_installed_plugins(); @@ -846,10 +841,10 @@ function get_sibling_files_callback_wptc() { if ($plugins) { return array('results' =>$plugins ); } - return array( 'results' => array()); + return array( 'results' => array()); } - function get_installed_themes(){ + function get_installed_themes() { $backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings'); @@ -857,23 +852,23 @@ function get_sibling_files_callback_wptc() { if ($plugins) { return array('results' =>$plugins ); } - return array('results' => array() ) ; + return array('results' => array() ); } - function is_staging_need_request(){ + function is_staging_need_request() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->is_staging_need_request(); die(); } - function get_staging_details_wptc(){ + function get_staging_details_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $details = $staging->get_staging_details(); $details['is_running'] = $staging->is_any_staging_process_going_on(); wptc_die_with_json_encode( $details, 1 ); } - function start_fresh_staging_wptc(){ + function start_fresh_staging_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); if (empty($_POST['path'])) { @@ -884,43 +879,43 @@ function get_sibling_files_callback_wptc() { die(); } - function get_staging_url_wptc(){ + function get_staging_url_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->get_staging_url_wptc(); die(); } - function stop_staging_wptc(){ + function stop_staging_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->stop_staging_wptc(); die(); } - function continue_staging_wptc(){ + function continue_staging_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->choose_action(); die(); } - function delete_staging_wptc(){ + function delete_staging_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->delete_staging_wptc(); die(); } - function copy_staging_wptc(){ + function copy_staging_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->choose_action(false, $reqeust_type = 'copy'); die(); } - function get_staging_current_status_key(){ + function get_staging_current_status_key() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); $staging->get_staging_current_status_key(); die(); } - function wptc_sync_purchase(){ + function wptc_sync_purchase() { $config = WPTC_Factory::get('config'); $config->request_service( @@ -928,7 +923,7 @@ function get_sibling_files_callback_wptc() { 'email' => false, 'pwd' => false, 'return_response' => false, - 'sub_action' => 'sync_all_settings_to_node', + 'sub_action' => 'sync_all_settings_to_node', 'login_request' => true, ) ); @@ -946,14 +941,14 @@ function get_sibling_files_callback_wptc() { die(); } - function save_settings_wptc(){ + function save_settings_wptc() { $options_helper = new Wptc_Options_Helper(); if( !$options_helper->get_is_user_logged_in() ){ return array( 'sync_data' => $this->get_sync_data(), - 'error' => 'Login to your WP Time Capsule account first' + 'error' => 'Login to your WP Time Capsule account first', ); } @@ -962,7 +957,6 @@ function get_sibling_files_callback_wptc() { $tabName = $_POST['tabname']; $is_general = $_POST['is_general']; - $saved = false; $config = WPTC_Factory::get('config'); @@ -972,7 +966,6 @@ function get_sibling_files_callback_wptc() { $config->set_option('user_excluded_extenstions', $data['user_excluded_extenstions']); $config->set_option('user_excluded_files_more_than_size_settings', $data['user_excluded_files_more_than_size_settings']); - if (!empty($data['backup_slot'])) { $config->set_option('old_backup_slot', $config->get_option('backup_slot')); $config->set_option('backup_slot', $data['backup_slot']); @@ -1006,7 +999,7 @@ function get_sibling_files_callback_wptc() { $current['update_settings']['status'] = $new['update_settings']['status']; $current['update_settings']['schedule']['enabled'] = $new['update_settings']['schedule']['enabled']; - $current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time']; + $current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time']; $current['update_settings']['core']['major']['status'] = $new['update_settings']['core']['major']['status']; $current['update_settings']['core']['minor']['status'] = $new['update_settings']['core']['minor']['status']; $current['update_settings']['themes']['status'] = $new['update_settings']['themes']['status']; @@ -1043,22 +1036,17 @@ function get_sibling_files_callback_wptc() { if (!empty($vulns_plugins_included)) { $plugin_include_array = explode(',', $vulns_plugins_included); - $plugin_include_array = !empty($plugin_include_array) ? $plugin_include_array : array() ; + $plugin_include_array = !empty($plugin_include_array) ? $plugin_include_array : array(); } wptc_log($plugin_include_array, '--------$plugin_include_array--------'); - - $included_plugins = $this->filter_plugins($plugin_include_array); - - wptc_log($included_plugins, '--------$included_plugins--------'); $current['plugins']['excluded'] = serialize($included_plugins); - $vulns_themes_included = !empty($new['themes']['vulns_themes_included']) ? $new['themes']['vulns_themes_included'] : array(); $themes_include_array = array(); @@ -1094,7 +1082,7 @@ function get_sibling_files_callback_wptc() { return array('result' => 'ok'); } - private function filter_plugins($included_plugins){ + private function filter_plugins( $included_plugins) { $app_functions = WPTC_Base_Factory::get('Wptc_App_Functions'); $plugins_data = $app_functions->get_all_plugins_data($specific = true, $attr = 'slug'); $not_included_plugin = array_diff($plugins_data, $included_plugins); @@ -1104,7 +1092,7 @@ function get_sibling_files_callback_wptc() { } - private function filter_themes($included_themes){ + private function filter_themes( $included_themes) { $app_functions = WPTC_Base_Factory::get('Wptc_App_Functions'); $themes_data = $app_functions->get_all_themes_data($specific = true, $attr = 'slug'); $not_included_theme = array_diff($themes_data, $included_themes); @@ -1114,13 +1102,13 @@ function get_sibling_files_callback_wptc() { } - public function analyze_inc_exc(){ + public function analyze_inc_exc() { $exclude_opts_obj = WPTC_Base_Factory::get('Wptc_ExcludeOption'); $exclude_opts_obj = $exclude_opts_obj->analyze_inc_exc(); // raw response die(); } - public function get_enabled_plugins(){ + public function get_enabled_plugins() { $vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns'); $plugins = $vulns_obj->get_enabled_plugins(); @@ -1129,14 +1117,14 @@ function get_sibling_files_callback_wptc() { return array('results' => $plugins); } - public function get_enabled_themes(){ + public function get_enabled_themes() { $vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns'); $themes = $vulns_obj->get_enabled_themes(); $themes = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($themes, 'themes'); return array('results' => $themes); } - public function get_system_info(){ + public function get_system_info() { global $wpdb; $wptc_settings = WPTC_Base_Factory::get('Wptc_Settings'); @@ -1157,7 +1145,7 @@ function get_sibling_files_callback_wptc() { } echo '' . __( 'PHP version', 'wp-time-capsule' ) . '' . esc_html( PHP_VERSION . ' ' . $bit ) . ''; - echo '' . __( 'MySQL version', 'wp-time-capsule' ) . '' . esc_html( $wpdb->get_var( "SELECT VERSION() AS version" ) ) . ''; + echo '' . __( 'MySQL version', 'wp-time-capsule' ) . '' . esc_html( $wpdb->get_var( 'SELECT VERSION() AS version' ) ) . ''; if ( function_exists( 'curl_version' ) ) { $curlversion = curl_version(); @@ -1178,7 +1166,7 @@ function get_sibling_files_callback_wptc() { $php_user = get_current_user(); } - echo '' . __( 'Current PHP user', 'wp-time-capsule' ) . '' . esc_html( $php_user ) . ''; + echo '' . __( 'Current PHP user', 'wp-time-capsule' ) . '' . esc_html( $php_user ) . ''; echo '' . __( 'Maximum execution time', 'wp-time-capsule' ) . '' . esc_html( ini_get( 'max_execution_time' ) ) . ' ' . __( 'seconds', 'wp-time-capsule' ) . ''; if ( defined( 'FS_CHMOD_DIR' ) ) @@ -1186,7 +1174,7 @@ function get_sibling_files_callback_wptc() { else echo '' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '0755'; - $now = localtime( time(), TRUE ); + $now = localtime( time(), true ); echo '' . __( 'Server Time', 'wp-time-capsule' ) . '' . esc_html( $now[ 'tm_hour' ] . ':' . $now[ 'tm_min' ] ) . ''; echo '' . __( 'Blog Time', 'wp-time-capsule' ) . '' . date( 'H:i', current_time( 'timestamp' ) ) . ''; echo '' . __( 'Blog language', 'wp-time-capsule' ) . '' . get_bloginfo( 'language' ) . ''; @@ -1197,7 +1185,7 @@ function get_sibling_files_callback_wptc() { echo '' . __( 'PHP Memory limit', 'wp-time-capsule' ) . '' . esc_html( ini_get( 'memory_limit' ) ) . ''; echo '' . __( 'WP memory limit', 'wp-time-capsule' ) . '' . esc_html( WP_MEMORY_LIMIT ) . ''; echo '' . __( 'WP maximum memory limit', 'wp-time-capsule' ) . '' . esc_html( WP_MAX_MEMORY_LIMIT ) . ''; - echo '' . __( 'Memory in use', 'wp-time-capsule' ) . '' . size_format( @memory_get_usage( TRUE ), 2 ) . ''; + echo '' . __( 'Memory in use', 'wp-time-capsule' ) . '' . size_format( @memory_get_usage( true ), 2 ) . ''; //disabled PHP functions $disabled = esc_html( ini_get( 'disable_functions' ) ); @@ -1212,7 +1200,7 @@ function get_sibling_files_callback_wptc() { echo '' . __( 'Loaded PHP Extensions:', 'wp-time-capsule' ) . ''; $extensions = get_loaded_extensions(); sort( $extensions ); - echo esc_html( implode( ', ', $extensions ) ); + echo esc_html( implode( ', ', $extensions ) ); echo ''; echo ''; @@ -1221,11 +1209,11 @@ function get_sibling_files_callback_wptc() { } - public function update_vulns_settings(){ + public function update_vulns_settings() { $vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns'); - $data = isset($_POST['data']) ? $_POST['data'] : array() ; + $data = isset($_POST['data']) ? $_POST['data'] : array(); $vulns_obj->update_vulns_settings($data); return array( 'success' => 1 ); diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 4e9a037..0a94e76 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -19,11 +19,11 @@ class MainWP_Child_Updraft_Plus_Backups { public static $instance = null; public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_Updraft_Plus_Backups::$instance ) { - MainWP_Child_Updraft_Plus_Backups::$instance = new MainWP_Child_Updraft_Plus_Backups(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Updraft_Plus_Backups(); } - return MainWP_Child_Updraft_Plus_Backups::$instance; + return self::$instance; } public function __construct() { @@ -39,7 +39,7 @@ class MainWP_Child_Updraft_Plus_Backups { add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' )); } - public static function hookUpdraftplusSaveLastBackup($last_backup) { + public static function hookUpdraftplusSaveLastBackup( $last_backup) { if (!is_array($last_backup)) return $last_backup; @@ -250,7 +250,7 @@ class MainWP_Child_Updraft_Plus_Backups { $response = array( 'connected' => true, 'html' => $this->connected_html() ); } else { $response = array( - 'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ) + 'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ), ); if ( is_wp_error( $connect ) ) { $response['e'] = $connect->get_error_message(); @@ -273,7 +273,7 @@ class MainWP_Child_Updraft_Plus_Backups { $ret = ''; $ret .= '

'; - $ret .= __( 'This site is connected to UpdraftPlus Vault.', 'updraftplus' ).' '.__( "Well done - there's nothing more needed to set up.", 'updraftplus' ).'

'.__( 'Vault owner', 'updraftplus' ).': ' . htmlspecialchars( $vault_settings['email'] ); + $ret .= __( 'This site is connected to UpdraftPlus Vault.', 'updraftplus' ) . ' ' . __( "Well done - there's nothing more needed to set up.", 'updraftplus' ) . '

' . __( 'Vault owner', 'updraftplus' ) . ': ' . htmlspecialchars( $vault_settings['email'] ); $ret .= '
' . __( 'Quota:', 'updraftplus' ) . ' '; if ( !isset( $vault_settings['quota'] ) || !is_numeric( $vault_settings['quota'] ) || ( $vault_settings['quota'] < 0 ) ) { @@ -297,15 +297,15 @@ class MainWP_Child_Updraft_Plus_Backups { $vault_mothership = 'https://vault.updraftplus.com/plugin-info/'; // Use SSL to prevent snooping - $result = wp_remote_post( $vault_mothership.'/?udm_action=vault_connect', + $result = wp_remote_post( $vault_mothership . '/?udm_action=vault_connect', array( 'timeout' => 20, 'body' => array( 'e' => $email, 'p' => base64_encode( $password ), 'sid' => $updraftplus->siteid(), - 'su' => base64_encode( home_url() ) - ) + 'su' => base64_encode( home_url() ), + ), ) ); @@ -340,7 +340,6 @@ class MainWP_Child_Updraft_Plus_Backups { } break; case 'authfailed': - if ( !empty( $response['authproblem'] ) ) { if ( 'invalidpassword' == $response['authproblem'] ) { $authfail_error = new WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' ' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '' ); @@ -372,7 +371,7 @@ class MainWP_Child_Updraft_Plus_Backups { delete_transient( 'updraftvault_quota_text' ); MainWP_Helper::close_connection( array( 'disconnected' => 1, - 'html' => $this->connected_html() ) + 'html' => $this->connected_html(), ) ); // If $_POST['reset_hash'] is set, then we were alerted by updraftplus.com - no need to notify back @@ -380,13 +379,13 @@ class MainWP_Child_Updraft_Plus_Backups { $post_body = array( 'e' => (string) $vault_settings['email'], 'sid' => $updraftplus->siteid(), - 'su' => base64_encode( home_url() ) + 'su' => base64_encode( home_url() ), ); if ( !empty( $vault_settings['token'] ) ) $post_body['token'] = (string) $vault_settings['token']; // Use SSL to prevent snooping - wp_remote_post( $vault_mothership.'/?udm_action=vault_disconnect', array( + wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array( 'timeout' => 20, 'body' => $post_body, )); @@ -651,12 +650,10 @@ class MainWP_Child_Updraft_Plus_Backups { } } - if (!isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) { UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] ); } - global $updraftplus; if ( isset( $settings['updraft_interval'] ) ) { // fix for premium version @@ -685,26 +682,26 @@ class MainWP_Child_Updraft_Plus_Backups { return $out; } - function replace_tokens($str = '') { + function replace_tokens( $str = '') { if (stripos($str, '%sitename%') !== false) { $replace_token = get_bloginfo( 'name' ); $replace_token = sanitize_file_name($replace_token); $replace_token = strtolower($replace_token); - $str = str_ireplace("%sitename%", $replace_token, $str); + $str = str_ireplace('%sitename%', $replace_token, $str); } if (stripos($str, '%siteurl%') !== false) { $replace_token = get_bloginfo( 'url' ); $replace_token = preg_replace('/^https?:\/\//i', '', $replace_token); $replace_token = sanitize_file_name($replace_token); - $str = str_ireplace("%siteurl%", $replace_token, $str); + $str = str_ireplace('%siteurl%', $replace_token, $str); } return $str; } function addons_connect() { if ( ! defined( 'UDADDONS2_SLUG' ) ) { - if (is_file(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php'); + if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'); if ( ! defined( 'UDADDONS2_SLUG' ) ) { return array( 'error' => 'NO_PREMIUM' ); } @@ -880,7 +877,7 @@ class MainWP_Child_Updraft_Plus_Backups { $our_prefix ++; } } - $ret_info .= sprintf( __( '%s total table(s) found; %s with the indicated prefix.', 'updraftplus' ), count( $all_tables ), $our_prefix ); + $ret_info .= sprintf( __( '%1$s total table(s) found; %2$s with the indicated prefix.', 'updraftplus' ), count( $all_tables ), $our_prefix ); } } @@ -910,7 +907,7 @@ class MainWP_Child_Updraft_Plus_Backups { return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after ); } - private function cb_get_name_base_type($a) { + private function cb_get_name_base_type( $a) { return $a[0]; } @@ -945,7 +942,6 @@ class MainWP_Child_Updraft_Plus_Backups { // Control returns when the backup finished; but, the browser connection should have been closed before die; - // not used anymore // if (wp_schedule_single_event(time()+5, $event, array($backupnow_nocloud)) === false) { // $updraftplus->log("A backup run failed to schedule"); @@ -1007,7 +1003,6 @@ class MainWP_Child_Updraft_Plus_Backups { 'ds' => $download_status, 'u' => $logupdate_array, ); - } @@ -1063,7 +1058,6 @@ class MainWP_Child_Updraft_Plus_Backups { } return array( 'b' => $last_backup_text, 'lasttime_gmt' => $backup_time ); - } private function get_updraft_data( $with_hist = true ) { @@ -1089,8 +1083,7 @@ class MainWP_Child_Updraft_Plus_Backups { $next_scheduled_backup = 'Nothing currently scheduled'; } - - MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' )) ; + MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Options', 'UpdraftPlus_Filesystem_Functions' )); MainWP_Helper::check_methods('UpdraftPlus_Options', 'get_updraft_option'); MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable'); MainWP_Helper::check_methods($updraftplus, array( 'backups_dir_location' )); @@ -1167,12 +1160,12 @@ class MainWP_Child_Updraft_Plus_Backups { } $next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database'); - if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database',UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) { + if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database', UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) { if (isset($files_not_scheduled)) { $next_scheduled_backup_database = $next_scheduled_backup; $database_not_scheduled = true; } else { - $next_scheduled_backup_database = __("At the same time as the files backup", 'updraftplus'); + $next_scheduled_backup_database = __('At the same time as the files backup', 'updraftplus'); $next_scheduled_backup_database_same_time = true; } } else { @@ -1195,20 +1188,20 @@ class MainWP_Child_Updraft_Plus_Backups { ' . __( 'Files', 'mainwp-updraftplus-extension' ) . ' - ' . __( 'Database', 'mainwp-updraftplus-extension' ) . ' - ' . __( 'Time now', 'mainwp-updraftplus-extension' ) . ' + ' . __( 'Database', 'mainwp-updraftplus-extension' ) . ' + ' . __( 'Time now', 'mainwp-updraftplus-extension' ) . ' - ' . $next_scheduled_backup. ' - ' . $next_scheduled_backup_database. ' - ' . $current_time. ' + ' . $next_scheduled_backup . ' + ' . $next_scheduled_backup_database . ' + ' . $current_time . ' '; - MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ) ; + MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ); MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable'); $updraft_dir = $updraftplus->backups_dir_location(); @@ -1334,7 +1327,7 @@ class MainWP_Child_Updraft_Plus_Backups { $deleted = - 1; if ( class_exists( $objname ) ) { # TODO: Re-use the object (i.e. prevent repeated connection setup/teardown) - $remote_obj = new $objname; + $remote_obj = new $objname(); $deleted = $remote_obj->delete( $files ); } if ( $deleted === - 1 ) { @@ -1577,7 +1570,6 @@ class MainWP_Child_Updraft_Plus_Backups { } return array( 'result' => 'OK' ); - } # Pass only a single service, as a string, into this function @@ -1596,7 +1588,7 @@ class MainWP_Child_Updraft_Plus_Backups { $objname = "UpdraftPlus_BackupModule_${service}"; if ( method_exists( $objname, 'download' ) ) { - $remote_obj = new $objname; + $remote_obj = new $objname(); return $remote_obj->download( $file ); } else { @@ -1605,7 +1597,6 @@ class MainWP_Child_Updraft_Plus_Backups { return false; } - } // This options filter removes ABSPATH off the front of updraft_dir, if it is given absolutely and contained within it @@ -1724,7 +1715,7 @@ class MainWP_Child_Updraft_Plus_Backups { $itext = ( 0 === $index ) ? '' : $index; if ( ! empty( $backups[ $timestamp ][ $type . $itext . '-size' ] ) && filesize( $updraft_dir . '/' . $file ) !== $backups[ $timestamp ][ $type . $itext . '-size' ] ) { if ( empty( $warn['doublecompressfixed'] ) ) { - $warn[] = sprintf( __( 'File (%s) was found, but has a different size (%s) from what was expected (%s) - it may be corrupt.', 'updraftplus' ), $file, filesize( $updraft_dir . '/' . $file ), $backups[ $timestamp ][ $type . $itext . '-size' ] ); + $warn[] = sprintf( __( 'File (%1$s) was found, but has a different size (%2$s) from what was expected (%3$s) - it may be corrupt.', 'updraftplus' ), $file, filesize( $updraft_dir . '/' . $file ), $backups[ $timestamp ][ $type . $itext . '-size' ] ); } } do_action_ref_array( "updraftplus_checkzip_$type", array( @@ -1815,7 +1806,6 @@ class MainWP_Child_Updraft_Plus_Backups { $output = ob_get_clean(); return array( 'o' => $output ); - } // not used @@ -1947,7 +1937,7 @@ class MainWP_Child_Updraft_Plus_Backups { require_once( UPDRAFTPLUS_DIR . '/restorer.php' ); global $updraftplus_restorer; - $updraftplus_restorer = new Updraft_Restorer( new Updraft_Restorer_Skin, $backup_set ); + $updraftplus_restorer = new Updraft_Restorer( new Updraft_Restorer_Skin(), $backup_set ); $second_loop = array(); @@ -1997,7 +1987,7 @@ class MainWP_Child_Updraft_Plus_Backups { foreach ( $files as $ind => $file ) { $fullpath = $updraft_dir . $file; - echo sprintf( esc_html__( 'Looking for %s archive: file name: %s', 'updraftplus' ), esc_html( $type ), esc_html( htmlspecialchars( $file ) ) ) . '
'; + echo sprintf( esc_html__( 'Looking for %1$s archive: file name: %2$s', 'updraftplus' ), esc_html( $type ), esc_html( htmlspecialchars( $file ) ) ) . '
'; add_action( 'http_request_args', array( $updraftplus, 'modify_http_options' ) ); foreach ( $service as $serv ) { @@ -2470,14 +2460,14 @@ class MainWP_Child_Updraft_Plus_Backups { } if ( version_compare( $old_wp_version, $wp_version, '>' ) ) { //$mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); - $warn[] = sprintf( __( 'You are importing from a newer version of WordPress (%s) into an older one (%s). There are no guarantees that WordPress can handle this.', 'updraftplus' ), $old_wp_version, $wp_version ); + $warn[] = sprintf( __( 'You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus' ), $old_wp_version, $wp_version ); } if ( preg_match( '/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches ) && preg_match( '/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches ) ) { $old_php_version = $nmatches[1]; $current_php_version = $cmatches[1]; if ( version_compare( $old_php_version, $current_php_version, '>' ) ) { //$mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); - $warn[] = sprintf( __( 'The site in this backup was running on a webserver with version %s of %s. ', 'updraftplus' ), $old_php_version, 'PHP' ) . ' ' . sprintf( __( 'This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus' ), PHP_VERSION ) . ' ' . sprintf( __( 'You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus' ), 'PHP' ) . ' ' . sprintf( __( 'Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus' ), 'PHP' ); + $warn[] = sprintf( __( 'The site in this backup was running on a webserver with version %1$s of %2$s. ', 'updraftplus' ), $old_php_version, 'PHP' ) . ' ' . sprintf( __( 'This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus' ), PHP_VERSION ) . ' ' . sprintf( __( 'You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus' ), 'PHP' ) . ' ' . sprintf( __( 'Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus' ), 'PHP' ); } } } elseif ( '' === $old_table_prefix && ( preg_match( '/^\# Table prefix: (\S+)$/', $buffer, $matches ) || preg_match( '/^-- Table prefix: (\S+)$/i', $buffer, $matches ) ) ) { @@ -2553,11 +2543,10 @@ class MainWP_Child_Updraft_Plus_Backups { } return array( $mess, $warn, $err, $info ); - } - public function analyse_db_file($timestamp, $res, $db_file = false, $header_only = false) { + public function analyse_db_file( $timestamp, $res, $db_file = false, $header_only = false) { global $updraftplus; $mess = array(); @@ -2576,7 +2565,7 @@ class MainWP_Child_Updraft_Plus_Backups { $backup = UpdraftPlus_Backup_History::get_history($timestamp); if (!isset($backup['nonce']) || !isset($backup['db'])) return array($mess, $warn, $err, $info); - $db_file = (is_string($backup['db'])) ? $updraft_dir.'/'.$backup['db'] : $updraft_dir.'/'.$backup['db'][0]; + $db_file = (is_string($backup['db'])) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; } if (!is_readable($db_file)) return array($mess, $warn, $err, $info); @@ -2671,7 +2660,7 @@ class MainWP_Child_Updraft_Plus_Backups { $processing_create = false; if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) { $old_siteurl = untrailingslashit($matches[1]); - $mess[] = __('Backup of:', 'updraftplus').' '.htmlspecialchars($old_siteurl).((!empty($old_wp_version)) ? ' '.sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : ''); + $mess[] = __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . ((!empty($old_wp_version)) ? ' ' . sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : ''); // Check for should-be migration if (untrailingslashit(site_url()) != $old_siteurl) { if (!$migration_warning) { @@ -2684,16 +2673,16 @@ class MainWP_Child_Updraft_Plus_Backups { $old_siteurl_parsed = parse_url($old_siteurl); $actual_siteurl_parsed = parse_url(site_url()); if ((stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0) || (stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0)) { - $powarn = sprintf(__('The website address in the backup set (%s) is slightly different from that of the site now (%s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()).' '; + $powarn = sprintf(__('The website address in the backup set (%1$s) is slightly different from that of the site now (%2$s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()) . ' '; } else { $powarn = ''; } if (('https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme']) || ('http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'])) { - $powarn .= sprintf(__('This backup set is of this site, but at the time of the backup you were using %s, whereas the site now uses %s.', 'updraftplus'), $old_siteurl_parsed['scheme'], $actual_siteurl_parsed['scheme']); + $powarn .= sprintf(__('This backup set is of this site, but at the time of the backup you were using %1$s, whereas the site now uses %2$s.', 'updraftplus'), $old_siteurl_parsed['scheme'], $actual_siteurl_parsed['scheme']); if ('https' == $old_siteurl_parsed['scheme']) { - $powarn .= ' '.apply_filters('updraftplus_https_to_http_additional_warning', sprintf(__('This restoration will work if you still have an SSL certificate (i.e. can use https) to access the site. Otherwise, you will want to use %s to search/replace the site address so that the site can be visited without https.', 'updraftplus'), ''.__('the migrator add-on', 'updraftplus').'')); + $powarn .= ' ' . apply_filters('updraftplus_https_to_http_additional_warning', sprintf(__('This restoration will work if you still have an SSL certificate (i.e. can use https) to access the site. Otherwise, you will want to use %s to search/replace the site address so that the site can be visited without https.', 'updraftplus'), '' . __('the migrator add-on', 'updraftplus') . '')); } else { - $powarn .= ' '.apply_filters('updraftplus_http_to_https_additional_warning', sprintf(__('As long as your web hosting allows http (i.e. non-SSL access) or will forward requests to https (which is almost always the case), this is no problem. If that is not yet set up, then you should set it up, or use %s so that the non-https links are automatically replaced.', 'updraftplus'), apply_filters('updraftplus_migrator_addon_link', ''.__('the migrator add-on', 'updraftplus').''))); + $powarn .= ' ' . apply_filters('updraftplus_http_to_https_additional_warning', sprintf(__('As long as your web hosting allows http (i.e. non-SSL access) or will forward requests to https (which is almost always the case), this is no problem. If that is not yet set up, then you should set it up, or use %s so that the non-https links are automatically replaced.', 'updraftplus'), apply_filters('updraftplus_migrator_addon_link', '' . __('the migrator add-on', 'updraftplus') . ''))); } } else { $powarn .= apply_filters('updraftplus_dbscan_urlchange_www_append_warning', ''); @@ -2702,15 +2691,15 @@ class MainWP_Child_Updraft_Plus_Backups { } else { // For completely different site migration $info['same_url'] = false; - $warn[] = apply_filters('updraftplus_dbscan_urlchange', ''.__('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus').'', $old_siteurl, $res); + $warn[] = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_siteurl, $res); } if (!class_exists('UpdraftPlus_Addons_Migrator')) { - $warn[] .= ''.__('You can search and replace your database (for migrating a website to a new location/URL) with the Migrator add-on - follow this link for more information', 'updraftplus').''; + $warn[] .= '' . __('You can search and replace your database (for migrating a website to a new location/URL) with the Migrator add-on - follow this link for more information', 'updraftplus') . ''; } } if ($updraftplus->mod_rewrite_unavailable(false)) { - $warn[] = sprintf(__('You are using the %s webserver, but do not seem to have the %s module loaded.', 'updraftplus'), 'Apache', 'mod_rewrite').' '.sprintf(__('You should enable %s to make any pretty permalinks (e.g. %s) work', 'updraftplus'), 'mod_rewrite', 'http://example.com/my-page/'); + $warn[] = sprintf(__('You are using the %1$s webserver, but do not seem to have the %2$s module loaded.', 'updraftplus'), 'Apache', 'mod_rewrite') . ' ' . sprintf(__('You should enable %1$s to make any pretty permalinks (e.g. %2$s) work', 'updraftplus'), 'mod_rewrite', 'http://example.com/my-page/'); } } else { @@ -2722,7 +2711,7 @@ class MainWP_Child_Updraft_Plus_Backups { // Check for should-be migration if (!$migration_warning && home_url() != $old_home) { $migration_warning = true; - $powarn = apply_filters('updraftplus_dbscan_urlchange', ''.__('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus').'', $old_home, $res); + $powarn = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_home, $res); if (!empty($powarn)) $warn[] = $powarn; } } elseif (!isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) { @@ -2732,14 +2721,14 @@ class MainWP_Child_Updraft_Plus_Backups { if (!empty($matches[3])) $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1); if (version_compare($old_wp_version, $wp_version, '>')) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); - $warn[] = sprintf(__('You are importing from a newer version of WordPress (%s) into an older one (%s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version); + $warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version); } if (preg_match('/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches) && preg_match('/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches)) { $old_php_version = $nmatches[1]; $current_php_version = $cmatches[1]; if (version_compare($old_php_version, $current_php_version, '>')) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); - $warn[] = sprintf(__('The site in this backup was running on a webserver with version %s of %s. ', 'updraftplus'), $old_php_version, 'PHP').' '.sprintf(__('This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus'), PHP_VERSION).' '.sprintf(__('You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus'), 'PHP').' '.sprintf(__('Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus'), 'PHP'); + $warn[] = sprintf(__('The site in this backup was running on a webserver with version %1$s of %2$s. ', 'updraftplus'), $old_php_version, 'PHP') . ' ' . sprintf(__('This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus'), PHP_VERSION) . ' ' . sprintf(__('You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus'), 'PHP') . ' ' . sprintf(__('Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus'), 'PHP'); } } } elseif ('' == $old_table_prefix && (preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches))) { @@ -2747,7 +2736,7 @@ class MainWP_Child_Updraft_Plus_Backups { // echo ''.__('Old table prefix:', 'updraftplus').' '.htmlspecialchars($old_table_prefix).'
'; } elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) { $info['label'] = $matches[1]; - $mess[] = __('Backup label:', 'updraftplus').' '.htmlspecialchars($info['label']); + $mess[] = __('Backup label:', 'updraftplus') . ' ' . htmlspecialchars($info['label']); } elseif ($gathering_siteinfo && preg_match('/^\# Site info: (\S+)$/', $buffer, $matches)) { if ('end' == $matches[1]) { $gathering_siteinfo = false; @@ -2758,7 +2747,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $err[] = sprintf(__('Error: %s', 'updraftplus'), __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus')); // return array($mess, $warn, $err, $info); // } else { - $warn[] = __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus').' '.__('It will be imported as a new site.', 'updraftplus').' '.__('Please read this link for important information on this process.', 'updraftplus').''; + $warn[] = __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus') . ' ' . __('It will be imported as a new site.', 'updraftplus') . ' ' . __('Please read this link for important information on this process.', 'updraftplus') . ''; // } // Got the needed code? if (!class_exists('UpdraftPlusAddOn_MultiSite') || !class_exists('UpdraftPlus_Addons_Migrator')) { @@ -2766,14 +2755,14 @@ class MainWP_Child_Updraft_Plus_Backups { return array($mess, $warn, $err, $info); } } elseif (isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && !is_multisite()) { - $warn[] = __('Warning:', 'updraftplus').' '.__('Your backup is of a WordPress multisite install; but this site is not. Only the first site of the network will be accessible.', 'updraftplus').' '.__('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus').''; + $warn[] = __('Warning:', 'updraftplus') . ' ' . __('Your backup is of a WordPress multisite install; but this site is not. Only the first site of the network will be accessible.', 'updraftplus') . ' ' . __('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus') . ''; } } elseif (preg_match('/^([^=]+)=(.*)$/', $matches[1], $kvmatches)) { $key = $kvmatches[1]; $val = $kvmatches[2]; if ('multisite' == $key) { $info['multisite'] = $val ? true : false; - if ($val) $mess[] = ''.__('Site information:', 'updraftplus').' '.'backup is of a WordPress Network'; + if ($val) $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; } $old_siteinfo[$key] = $val; } @@ -2831,7 +2820,7 @@ class MainWP_Child_Updraft_Plus_Backups { static $mysql_version_warned = false; if (!$mysql_version_warned && version_compare($db_version, '5.2.0', '<') && preg_match('/(CHARSET|COLLATE)[= ]utf8mb4/', $buffer)) { $mysql_version_warned = true; - $err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('The database backup uses MySQL features not available in the old MySQL version (%s) that this site is running on.', 'updraftplus'), $db_version).' '.__('You must upgrade MySQL to be able to use this database.', 'updraftplus')); + $err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('The database backup uses MySQL features not available in the old MySQL version (%s) that this site is running on.', 'updraftplus'), $db_version) . ' ' . __('You must upgrade MySQL to be able to use this database.', 'updraftplus')); } } } @@ -2852,7 +2841,7 @@ class MainWP_Child_Updraft_Plus_Backups { } if ($db_charset_forbidden) { $db_unsupported_charset_unique = array_unique($db_unsupported_charset); - $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count($db_unsupported_charset_unique), 'updraftplus'), implode(', ', $db_unsupported_charset_unique)).' '.__('You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus').' '.__('Go here for more information.', 'updraftplus').''.' '.__('Go here for more information.', 'updraftplus').''; + $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count($db_unsupported_charset_unique), 'updraftplus'), implode(', ', $db_unsupported_charset_unique)) . ' ' . __('You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus') . ' ' . __('Go here for more information.', 'updraftplus') . '' . ' ' . __('Go here for more information.', 'updraftplus') . ''; $db_supported_character_sets = array_keys($db_supported_character_sets); $similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_charset_unique, $db_supported_character_sets, true); if (empty($similar_type_charset)) { @@ -2862,11 +2851,11 @@ class MainWP_Child_Updraft_Plus_Backups { if (empty($similar_type_charset) && !empty($db_supported_character_sets[0])) { $similar_type_charset = $db_supported_character_sets[0]; } - $charset_select_html = ' '; + $charset_select_html = ' '; $charset_select_html .= ''; @@ -2886,7 +2875,7 @@ class MainWP_Child_Updraft_Plus_Backups { } if ($db_collate_forbidden) { $db_unsupported_collate_unique = array_unique($db_unsupported_collate); - $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the collation (%s) used in the database which you are trying to import.", "The database server that this WordPress site is running on doesn't support multiple collations (%s) used in the database which you are trying to import.", count($db_unsupported_collate_unique), 'updraftplus'), implode(', ', $db_unsupported_collate_unique)).' '.__('You can choose another suitable collation instead and continue with the restoration (at your own risk).', 'updraftplus'); + $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the collation (%s) used in the database which you are trying to import.", "The database server that this WordPress site is running on doesn't support multiple collations (%s) used in the database which you are trying to import.", count($db_unsupported_collate_unique), 'updraftplus'), implode(', ', $db_unsupported_collate_unique)) . ' ' . __('You can choose another suitable collation instead and continue with the restoration (at your own risk).', 'updraftplus'); $similar_type_collate = ''; if ($db_charset_forbidden && !empty($similar_type_charset)) { $similar_type_collate = $updraftplus->get_similar_collate_related_to_charset($db_supported_collations, $db_unsupported_collate_unique, $similar_type_charset); @@ -2909,21 +2898,21 @@ class MainWP_Child_Updraft_Plus_Backups { $similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, array_keys($db_supported_collations), false); } - $collate_select_html = ''; + $collate_select_html = ''; $collate_select_html .= ''; - $info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'].'
'.$collate_select_html; + $info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'] . '
' . $collate_select_html; if ($db_charset_forbidden) { $collate_change_on_charset_selection_data = array( @@ -2931,11 +2920,12 @@ class MainWP_Child_Updraft_Plus_Backups { 'db_unsupported_collate_unique' => $db_unsupported_collate_unique, 'db_collates_found' => $db_collates_found, ); - $info['addui'] .= ''; + $info['addui'] .= ''; } } } - /* $blog_tables = "CREATE TABLE $wpdb->terms ( + /* + $blog_tables = "CREATE TABLE $wpdb->terms ( CREATE TABLE $wpdb->term_taxonomy ( CREATE TABLE $wpdb->term_relationships ( CREATE TABLE $wpdb->commentmeta ( @@ -2959,13 +2949,13 @@ class MainWP_Child_Updraft_Plus_Backups { if ($old_table_prefix) { if (!$header_only) { foreach ($wanted_tables as $table) { - if (!in_array($old_table_prefix.$table, $tables_found)) { + if (!in_array($old_table_prefix . $table, $tables_found)) { $missing_tables[] = $table; } } foreach ($missing_tables as $key => $value) { - if (in_array($old_table_prefix.$value, $skipped_tables)) { + if (in_array($old_table_prefix . $value, $skipped_tables)) { unset($missing_tables[$key]); } } @@ -3124,7 +3114,6 @@ class MainWP_Child_Updraft_Plus_Backups { $non = $backup['nonce']; - // $rawbackup = "

$esc_pretty_date ($key)

" . esc_attr( print_r( $backup, true ) ); // if ( ! empty( $non ) ) { // $jd = $updraftplus->jobdata_getarray( $non ); @@ -3135,7 +3124,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $rawbackup .= '

'; // to fix - $rawbackup = '' ; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); + $rawbackup = ''; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); $jobdata = $updraftplus->jobdata_getarray( $non ); @@ -3158,7 +3147,6 @@ class MainWP_Child_Updraft_Plus_Backups { } } - $ret .= << @@ -3534,7 +3522,6 @@ ENDHERE; } else { return round( $size, 1 ) . ' b'; } - } private function recursive_directory_size_raw( $prefix_directory, &$exclude = array(), $suffix_directory = '' ) { @@ -3575,7 +3562,6 @@ ENDHERE; } return $size; - } @@ -3695,7 +3681,7 @@ ENDHERE; $p = min( $jobdata['uploading_substatus']['p'], 1 ); $pd = $i + $p / $t; $stage = 4 + $pd; - $curstage .= ' ' . sprintf( __( '(%s%%, file %s of %s)', 'updraftplus' ), floor( 100 * $pd ), $jobdata['uploading_substatus']['i'] + 1, $t ); + $curstage .= ' ' . sprintf( __( '(%1$s%%, file %2$s of %3$s)', 'updraftplus' ), floor( 100 * $pd ), $jobdata['uploading_substatus']['i'] + 1, $t ); } break; case 'pruning': @@ -3712,7 +3698,6 @@ ENDHERE; $curstage = __( 'Backup finished', 'updraftplus' ); break; default: - # Database creation and encryption occupies the space from 2 to 4. Databases are created then encrypted, then the next databae is created/encrypted, etc. if ( 'dbcreated' === substr( $jobstatus, 0, 9 ) ) { $jobstatus = 'dbcreated'; @@ -3786,7 +3771,7 @@ ENDHERE; } $next_res_after = (int) $time - time(); - $next_res_txt = ( $is_oneshot ) ? '' : ' - ' . sprintf( __( 'next resumption: %d (after %ss)', 'updraftplus' ), $next_resumption, $next_res_after ) . ' '; + $next_res_txt = ( $is_oneshot ) ? '' : ' - ' . sprintf( __( 'next resumption: %1$d (after %2$ss)', 'updraftplus' ), $next_resumption, $next_res_after ) . ' '; $last_activity_txt = ( $last_checkin_ago >= 0 ) ? ' - ' . sprintf( __( 'last activity: %ss ago', 'updraftplus' ), floor( $last_checkin_ago ) ) . ' ' : ''; if ( ( $last_checkin_ago < 50 && $next_res_after > 30 ) || $is_oneshot ) { @@ -3823,7 +3808,6 @@ ENDHERE; $ret .= '
'; return $ret; - } private function fetch_updraft_log() { @@ -3969,13 +3953,13 @@ ENDHERE; } private function close_browser_connection( $txt = '' ) { - + if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) : - $output = json_encode( $txt ); + $output = json_encode( $txt ); else: $output = serialize( $txt ); - endif; - + endif; + $txt = '' . base64_encode( $output ) . ''; // Close browser connection so that it can resume AJAX polling header( 'Content-Length: ' . ( ( ! empty( $txt ) ) ? strlen( $txt ) : '0' ) ); diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php index 8af1000..a4a06c2 100644 --- a/class/class-mainwp-child-vulnerability-checker.php +++ b/class/class-mainwp-child-vulnerability-checker.php @@ -23,19 +23,19 @@ class MainWP_Child_Vulnerability_Checker { private $wpvulndb_token = false; static function Instance() { - if ( null === MainWP_Child_Vulnerability_Checker::$instance ) { - MainWP_Child_Vulnerability_Checker::$instance = new MainWP_Child_Vulnerability_Checker(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Vulnerability_Checker(); } - return MainWP_Child_Vulnerability_Checker::$instance; + return self::$instance; } public function __construct() { - $this->wpvulndb_token = get_option('mainwp_child_wpvulndb_token', ''); + $this->wpvulndb_token = get_option('mainwp_child_wpvulndb_token', ''); } public function action() { $information = array(); - + if ( ! empty( $this->wpvulndb_token ) ) { if ( isset( $_POST['mwp_action'] ) ) { switch ( $_POST['mwp_action'] ) { @@ -45,11 +45,11 @@ class MainWP_Child_Vulnerability_Checker { } } } - + MainWP_Helper::write( $information ); } - function vulner_recheck(){ + function vulner_recheck() { $result = array(); $force = (isset($_POST['force']) && !empty($_POST['force'])) ? true : false; $result['plugin'] = $this->check_plugins($force); @@ -59,7 +59,7 @@ class MainWP_Child_Vulnerability_Checker { return $information; } - function check_plugins($force = false){ + function check_plugins( $force = false) { $result = array(); $active_plugins = get_option('active_plugins'); @@ -69,11 +69,11 @@ class MainWP_Child_Vulnerability_Checker { $plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug; $plugin_info = get_plugin_data($plugin_file); $plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : ''; - $string = explode('/',$plug); - $plug_vuln = get_transient('mainwp_vulnche_trans_plug_'.$string[0]); + $string = explode('/', $plug); + $plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]); if(false === $plug_vuln || $force) { - $plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]); - set_transient('mainwp_vulnche_trans_plug_'.$string[0],$plug_vuln, 1 * DAY_IN_SECONDS); + $plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]); + set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS); } if ($plug_vuln) { $plug_vuln = json_decode($plug_vuln, true); @@ -117,7 +117,7 @@ class MainWP_Child_Vulnerability_Checker { return $result; } - function check_wp($force = false){ + function check_wp( $force = false) { $wp_vuln = get_transient('mainwp_vulnche_trans_wp_json'); $wp_version = str_replace('.', '', get_bloginfo('version')); if(false === $wp_vuln || $force) { @@ -127,7 +127,7 @@ class MainWP_Child_Vulnerability_Checker { return $wp_vuln; } - function check_themes($force = false){ + function check_themes( $force = false) { require_once( ABSPATH . 'wp-admin/includes/misc.php' ); require_once( ABSPATH . 'wp-admin/includes/theme.php' ); @@ -197,14 +197,14 @@ class MainWP_Child_Vulnerability_Checker { function vulnche_get_content ( $url ) { - + $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token token=' . $this->wpvulndb_token)); curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent()); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); $info = curl_getinfo($ch, CURLINFO_HTTP_CODE); @@ -212,30 +212,30 @@ class MainWP_Child_Vulnerability_Checker { curl_close($ch); if ($output === false || $info != 200) { $output = null; - } + } return $output; } - function get_random_user_agent ( ) { + function get_random_user_agent () { $someUA = array ( - "Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19", - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13", - "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)", - "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)", - "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)", - "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)", - "Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)", - "Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)", - "Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)" + 'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1', + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0', + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19', + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13', + 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)', + 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)', + 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)', + 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)', + 'Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)', + 'Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)', + 'Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)', ); - srand((double)microtime()*1000000); + srand( (float) microtime()*1000000); - return $someUA[rand(0,count($someUA)-1)]; + return $someUA[rand(0, count($someUA)-1)]; } diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index f5ffa05..9597529 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -18,20 +18,18 @@ class MainWP_Child_WooCommerce_Status { public static $instance = null; static function Instance() { - if ( null === MainWP_Child_WooCommerce_Status::$instance ) { - MainWP_Child_WooCommerce_Status::$instance = new MainWP_Child_WooCommerce_Status(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_WooCommerce_Status(); } - return MainWP_Child_WooCommerce_Status::$instance; + return self::$instance; } public function __construct() { add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) ); - } public function child_deactivation() { - } public function action() { @@ -92,8 +90,6 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_date <= %s ", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date ) ) ); - - // Get top seller $top_seller = $wpdb->get_row( $wpdb->prepare( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id FROM {$wpdb->posts} as posts @@ -118,7 +114,7 @@ class MainWP_Child_WooCommerce_Status { GROUP BY product_id ORDER BY qty DESC LIMIT 1 - ", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date )) ); + ", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date )) ); if ( ! empty( $top_seller ) ) { $top_seller->name = get_the_title( $top_seller->product_id ); @@ -215,9 +211,6 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') " ); - - - // Get top seller $top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id FROM {$wpdb->posts} as posts @@ -353,8 +346,8 @@ class MainWP_Child_WooCommerce_Status { 'on-hold', ) ) ) . "' ) "; $query['where'] .= "AND postmeta.meta_key = '_order_total' "; - $query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; - $query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; + $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; + $query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; $sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) ); @@ -373,14 +366,13 @@ class MainWP_Child_WooCommerce_Status { ) ) ) . "' ) "; $query['where'] .= "AND order_item_meta.meta_key = '_qty' "; $query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' "; - $query['where'] .= "AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; - $query['where'] .= "AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; + $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; + $query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['groupby'] = 'GROUP BY product_id'; $query['orderby'] = 'ORDER BY qty DESC'; $query['limits'] = 'LIMIT 1'; - $top_seller = $wpdb->get_row( implode( ' ', $query ) ); - + $top_seller = $wpdb->get_row( implode( ' ', $query ) ); if ( ! empty( $top_seller ) ) { $top_seller->name = get_the_title( $top_seller->product_id ); @@ -441,7 +433,7 @@ class MainWP_Child_WooCommerce_Status { 'stock' => $stock, 'nostock' => $nostock, 'lowstock' => $lowinstock_count, - 'outstock' => $outofstock_count + 'outstock' => $outofstock_count, ); $information['data'] = $data; $information['need_db_update'] = $this->check_db_update(); diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index a7fadda..c3b6190 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -52,11 +52,11 @@ class MainWP_Child_Wordfence { 'loginSec_countFailMins', 'loginSec_disableAuthorScan', 'notification_updatesNeeded', - "notification_securityAlerts", - "notification_promotions", - "notification_blogHighlights", - "notification_productUpdates", - "notification_scanStatus", + 'notification_securityAlerts', + 'notification_promotions', + 'notification_blogHighlights', + 'notification_productUpdates', + 'notification_scanStatus', 'loginSec_lockInvalidUsers', 'loginSec_breachPasswds_enabled', 'loginSec_breachPasswds', @@ -87,7 +87,7 @@ class MainWP_Child_Wordfence { 'lowResourceScansEnabled', 'scansEnabled_malware', 'scansEnabled_oldVersions', - "scansEnabled_suspiciousAdminUsers", + 'scansEnabled_suspiciousAdminUsers', 'scansEnabled_passwds', 'scansEnabled_plugins', 'scansEnabled_coreUnknown', @@ -138,10 +138,10 @@ class MainWP_Child_Wordfence { //'addCacheComment', // removed 'disableCodeExecutionUploads', //'isPaid', - "advancedCommentScanning", - "scansEnabled_checkGSB", - "checkSpamIP", - "spamvertizeCheck", + 'advancedCommentScanning', + 'scansEnabled_checkGSB', + 'checkSpamIP', + 'spamvertizeCheck', //'scansEnabled_public', 'email_summary_enabled', 'email_summary_dashboard_widget_enabled', @@ -163,7 +163,7 @@ class MainWP_Child_Wordfence { 'schedMode', // paid, if free then auto 'wafStatus', 'learningModeGracePeriodEnabled', - 'learningModeGracePeriod' + 'learningModeGracePeriod', ); // for separated saving this values @@ -179,16 +179,16 @@ class MainWP_Child_Wordfence { public static $firewall_options_filter = array( 'wafStatus', 'learningModeGracePeriodEnabled', - 'learningModeGracePeriod' + 'learningModeGracePeriod', ); static function Instance() { - if ( null === MainWP_Child_Wordfence::$instance ) { - MainWP_Child_Wordfence::$instance = new MainWP_Child_Wordfence(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Wordfence(); } - return MainWP_Child_Wordfence::$instance; + return self::$instance; } @@ -206,7 +206,6 @@ class MainWP_Child_Wordfence { if ( $this->is_wordfence_installed ) { add_action( 'wp_ajax_mainwp_wordfence_download_htaccess', array( $this, 'downloadHtaccess' ) ); } - } public function deactivation() { @@ -329,37 +328,37 @@ class MainWP_Child_Wordfence { case 'downgrade_license': $information = $this->downgrade_license(); break; - case "import_settings": + case 'import_settings': $information = $this->import_settings(); break; - case "export_settings": + case 'export_settings': $information = $this->export_settings(); break; - case "save_cache_config": + case 'save_cache_config': $information = $this->saveCacheConfig(); break; - case "check_falcon_htaccess": + case 'check_falcon_htaccess': $information = $this->checkFalconHtaccess(); break; - case "checkHtaccess": + case 'checkHtaccess': $information = $this->checkHtaccess(); break; - case "save_cache_options": + case 'save_cache_options': $information = $this->saveCacheOptions(); break; - case "clear_page_cache": + case 'clear_page_cache': $information = $this->clearPageCache(); break; - case "get_cache_stats": + case 'get_cache_stats': $information = $this->getCacheStats(); break; - case "add_cache_exclusion": + case 'add_cache_exclusion': $information = $this->addCacheExclusion(); break; - case "load_cache_exclusions": + case 'load_cache_exclusions': $information = $this->loadCacheExclusions(); break; - case "remove_cache_exclusion": + case 'remove_cache_exclusion': $information = $this->removeCacheExclusion(); break; case 'get_diagnostics': @@ -430,20 +429,20 @@ class MainWP_Child_Wordfence { break; case 'whitelist_bulk_disable': $information = $this->whitelistBulkDisable(); - break; + break; case 'update_config': $information = $this->updateConfig(); - break; + break; case 'save_country_blocking': $information = $this->saveCountryBlocking(); - break; + break; } } MainWP_Helper::write( $information ); } - public static function getSectionSettings($section) { + public static function getSectionSettings( $section) { $general_opts = array( 'scheduleScan', 'apiKey', @@ -484,7 +483,7 @@ class MainWP_Child_Wordfence { 'email_summary_dashboard_widget_enabled', 'other_noAnonMemberComments', 'other_scanComments', - 'advancedCommentScanning' // paid + 'advancedCommentScanning', // paid ); $traffic_opts = array( @@ -495,7 +494,7 @@ class MainWP_Child_Wordfence { 'liveTraf_ignoreIPs', 'liveTraf_ignoreUA', 'liveTraf_maxRows', - 'displayTopLevelLiveTraffic' + 'displayTopLevelLiveTraffic', ); $firewall_opts = array( @@ -539,7 +538,7 @@ class MainWP_Child_Wordfence { 'other_WFNet', 'wafStatus', 'learningModeGracePeriodEnabled', - 'learningModeGracePeriod' + 'learningModeGracePeriod', ); $scan_opts = array( @@ -576,13 +575,13 @@ class MainWP_Child_Wordfence { 'scan_exclude', 'scan_include_extra', 'scanType', - 'schedMode' + 'schedMode', ); $diagnostics_opts = array( 'debugOn', 'startScansRemotely', 'ssl_verify', - 'betaThreatDefenseFeed' + 'betaThreatDefenseFeed', ); $blocking_opts = array( @@ -627,8 +626,8 @@ class MainWP_Child_Wordfence { } private function kill_scan() { - wordfence::status(1, 'info', "Scan kill request received."); - wordfence::status(10, 'info', "SUM_KILLED:A request was received to kill the previous scan."); + wordfence::status(1, 'info', 'Scan kill request received.'); + wordfence::status(10, 'info', 'SUM_KILLED:A request was received to kill the previous scan.'); wfUtils::clearScanLock(); //Clear the lock now because there may not be a scan running to pick up the kill request and clear the lock wfScanEngine::requestKill(); return array( @@ -669,7 +668,7 @@ class MainWP_Child_Wordfence { do_action( 'mainwp_child_reports_log', 'wordfence' ); } // ok - public function do_reports_log($ext = '') { + public function do_reports_log( $ext = '') { if ( $ext !== 'wordfence' ) return; if ( ! $this->is_wordfence_installed ) return; @@ -695,7 +694,7 @@ class MainWP_Child_Wordfence { } if ($scan_time) { - $message = "Wordfence scan completed"; + $message = 'Wordfence scan completed'; foreach($scan_time as $ctime => $details) { $sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime > %d AND ctime < %d AND level = 10 AND type = 'info' AND msg LIKE ", $ctime, $ctime + 100 ); // to get nearest SUM_FINAL msg $sql .= " 'SUM_FINAL:Scan complete.%';"; @@ -802,11 +801,11 @@ class MainWP_Child_Wordfence { 'todayAttBlocked' => $this->count_attacks_blocked(1), 'weekAttBlocked' => $this->count_attacks_blocked(7), 'monthAttBlocked' => $this->count_attacks_blocked(30), - 'wafData' => $this->_getWAFData() + 'wafData' => $this->_getWAFData(), ); } - public static function ajax_loadIssues_callback(){ + public static function ajax_loadIssues_callback() { $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $limit = isset($_POST['limit']) ? intval($_POST['limit']) : WORDFENCE_SCAN_ISSUES_PER_PAGE; @@ -819,10 +818,10 @@ class MainWP_Child_Wordfence { 'lastScanCompleted' => wfConfig::get('lastScanCompleted'), 'apiKey' => wfConfig::get( 'apiKey' ), 'isPaid' => wfConfig::get('isPaid'), - 'lastscan_timestamp' => MainWP_Child_Wordfence::Instance()->get_lastscan(), - 'todayAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(1), - 'weekAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(7), - 'monthAttBlocked' => MainWP_Child_Wordfence::Instance()->count_attacks_blocked(30), + 'lastscan_timestamp' => self::Instance()->get_lastscan(), + 'todayAttBlocked' => self::Instance()->count_attacks_blocked(1), + 'weekAttBlocked' => self::Instance()->count_attacks_blocked(7), + 'monthAttBlocked' => self::Instance()->count_attacks_blocked(30), 'issueCount' => $i->getIssueCount(), ); return $return; @@ -833,8 +832,8 @@ class MainWP_Child_Wordfence { $return = array( 'wafData' => $this->_getWAFData(), 'ip' => wfUtils::getIP(), - 'ajaxWatcherDisabled_front' => (bool)wfConfig::get('ajaxWatcherDisabled_front'), - 'ajaxWatcherDisabled_admin' => (bool)wfConfig::get('ajaxWatcherDisabled_admin') + 'ajaxWatcherDisabled_front' => (bool) wfConfig::get('ajaxWatcherDisabled_front'), + 'ajaxWatcherDisabled_admin' => (bool) wfConfig::get('ajaxWatcherDisabled_admin'), ); if (class_exists('wfFirewall')) { @@ -844,7 +843,7 @@ class MainWP_Child_Wordfence { return $return; } - public function count_attacks_blocked($maxAgeDays) { + public function count_attacks_blocked( $maxAgeDays) { global $wpdb; $table_wfBlockedIPLog = wfDB::networkTable('wfBlockedIPLog'); $interval = 'FLOOR(UNIX_TIMESTAMP(DATE_SUB(NOW(), interval ' . $maxAgeDays . ' day)) / 86400)'; @@ -885,7 +884,7 @@ SQL $status = $_POST['status']; $issueID = $_POST['id']; if(! preg_match('/^(?:new|delete|ignoreP|ignoreC)$/', $status)){ - return array('errorMsg' => "An invalid status was specified when trying to update that issue."); + return array('errorMsg' => 'An invalid status was specified when trying to update that issue.'); } $wfIssues->updateIssue($issueID, $status); wfScanEngine::refreshScanNotification($wfIssues); @@ -1088,7 +1087,7 @@ SQL ); } - function simple_crypt($key, $data, $action = 'encrypt'){ + function simple_crypt( $key, $data, $action = 'encrypt') { $res = ''; if($action == 'encrypt'){ $string = base64_encode( serialize($data) ); @@ -1112,8 +1111,7 @@ SQL return $res; } - function save_settings_new() - { + function save_settings_new() { if (isset($_POST['encrypted'])) $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost else { @@ -1276,22 +1274,19 @@ SQL // Finished saving settings ///////////////////// - $result['cacheType'] = wfConfig::get( 'cacheType' ); $result['paidKeyMsg'] = false; // if saving then validate data if (in_array('apiKey', $saving_opts)) { - + $apiKey = trim( $_POST['apiKey'] ); - $apiKey = strtolower(trim($apiKey)); + $apiKey = strtolower(trim($apiKey)); $existingAPIKey = wfConfig::get('apiKey', ''); - - - - $ping = false; + + $ping = false; if ( empty( $apiKey ) && empty($existingAPIKey) ) { // then try to get one. - + $api = new wfAPI( '', wfUtils::getWPVersion() ); try { $keyData = $api->call( 'get_anon_api_key' ); @@ -1310,13 +1305,13 @@ SQL $result['error'] = 'Your options have been saved, but you left your license key blank, so we tried to get you a free license key from the Wordfence servers. There was a problem fetching the free key: ' . wp_kses( $e->getMessage(), array() ); return $result; } - - } else if ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { + + } else if ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); try { $res = $api->call('check_api_key', array(), array('previousLicense' => $existingAPIKey)); if ( $res['ok'] && isset( $res['isPaid'] ) ) { - + // wfConfig::set( 'apiKey', $apiKey ); // wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. // $result['apiKey'] = $apiKey; @@ -1324,7 +1319,7 @@ SQL // if ( $res['isPaid'] ) { // $result['paidKeyMsg'] = true; // } - + $isPaid = wfUtils::truthyToBoolean($res['isPaid']); wfConfig::set('apiKey', $apiKey); wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. @@ -1332,14 +1327,13 @@ SQL if (!$isPaid) { wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE); } - - + $result['apiKey'] = $apiKey; $result['isPaid'] = $isPaid; if ( $isPaid ) { $result['paidKeyMsg'] = true; } - + $ping = true; $reload = 'reload'; } else { @@ -1350,13 +1344,13 @@ SQL return $result; } } else { - $ping = true; - $apiKey = $existingAPIKey; + $ping = true; + $apiKey = $existingAPIKey; } - - if ( $ping ) { - - $api = new wfAPI($apiKey, wfUtils::getWPVersion()); + + if ( $ping ) { + + $api = new wfAPI($apiKey, wfUtils::getWPVersion()); try { $keyType = wfAPI::KEY_TYPE_FREE; $keyData = $api->call('ping_api_key', array(), array('supportHash' => wfConfig::get('supportHash', ''), 'whitelistHash' => wfConfig::get('whitelistHash', ''))); @@ -1383,10 +1377,10 @@ SQL } wfConfig::set('keyType', $keyType); - + if (!isset($result['apiKey'])) { $isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true; - $result['apiKey'] = $apiKey; + $result['apiKey'] = $apiKey; $result['isPaid'] = $isPaid; if ( $isPaid ) { $result['paidKeyMsg'] = true; @@ -1394,7 +1388,7 @@ SQL } } catch ( Exception $e ) { - $result['error'] = 'Your options have been saved. However we tried to verify your license key with the Wordfence servers and received an error: ' . wp_kses($e->getMessage(), array()) ; + $result['error'] = 'Your options have been saved. However we tried to verify your license key with the Wordfence servers and received an error: ' . wp_kses($e->getMessage(), array()); return $result; } } @@ -1412,7 +1406,7 @@ SQL } - public static function recentTraffic(){ + public static function recentTraffic() { return wordfence::ajax_recentTraffic_callback(); } @@ -1572,8 +1566,7 @@ SQL } } - public function export_settings(){ - + public function export_settings() { $export = array(); @@ -1600,18 +1593,18 @@ SQL ); } else if ($res['err']) { - return array('errorExport' => __("An error occurred: ", 'wordfence') . $res['err']); + return array('errorExport' => __('An error occurred: ', 'wordfence') . $res['err']); } else { - throw new Exception(__("Invalid response: ", 'wordfence') . var_export($res, true)); + throw new Exception(__('Invalid response: ', 'wordfence') . var_export($res, true)); } } catch (Exception $e) { - return array('errorExport' => __("An error occurred: ", 'wordfence') . $e->getMessage()); + return array('errorExport' => __('An error occurred: ', 'wordfence') . $e->getMessage()); } } - public function import_settings(){ + public function import_settings() { $token = $_POST['token']; try { $api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion()); @@ -1620,7 +1613,7 @@ SQL $totalSet = 0; $import = @json_decode($res['export'], true); if (!is_array($import)) { - return array('errorImport' => __("An error occurred: Invalid options format received.", 'wordfence')); + return array('errorImport' => __('An error occurred: Invalid options format received.', 'wordfence')); } //Basic Options @@ -1662,20 +1655,19 @@ SQL return array( 'ok' => 1, 'totalSet' => $totalSet, - 'settings' => $this->get_settings() + 'settings' => $this->get_settings(), ); } else if ($res['err']) { - return array('errorImport' => "An error occurred: " . $res['err']); + return array('errorImport' => 'An error occurred: ' . $res['err']); } else { - throw new Exception("Invalid response: " . var_export($res, true)); + throw new Exception('Invalid response: ' . var_export($res, true)); } } catch (Exception $e) { - return array('errorImport' => "An error occurred: " . $e->getMessage()); + return array('errorImport' => 'An error occurred: ' . $e->getMessage()); } - } function get_settings() { @@ -1750,7 +1742,7 @@ SQL return $return; } - public static function fixFPD(){ + public static function fixFPD() { $return = wordfence::ajax_fixFPD_callback(); return $return; } @@ -1838,7 +1830,7 @@ SQL } // credit of Wordfence - private static function _getWAFData($updated = null) { + private static function _getWAFData( $updated = null) { // custom if(!class_exists('wfWAF')) return false; @@ -1906,7 +1898,7 @@ SQL } - public function saveOptions(){ + public function saveOptions() { if (!empty($_POST['changes']) && ($changes = json_decode(stripslashes($_POST['changes']), true)) !== false) { try { if (is_array($changes) && isset($changes['whitelistedURLParams']) && isset($changes['whitelistedURLParams']['add'])) { @@ -1967,13 +1959,12 @@ SQL ); } - public function ajax_getBlocks_callback(){ + public function ajax_getBlocks_callback() { $information = wordfence::ajax_getBlocks_callback(); return $information; } // credit of Wordfence - public function ajax_createBlock_callback() - { + public function ajax_createBlock_callback() { return wordfence::ajax_createBlock_callback(); } @@ -1987,12 +1978,12 @@ SQL return $information; } - public function ajax_blockIP_callback(){ + public function ajax_blockIP_callback() { return wordfence::ajax_blockIP_callback(); } // credit of Wordfence - public function whois(){ + public function whois() { return wordfence::ajax_whois_callback(); } @@ -2004,9 +1995,9 @@ SQL } } - public static function saveCountryBlocking(){ + public static function saveCountryBlocking() { if(! wfConfig::get('isPaid')){ - return array('error' => "Sorry but this feature is only available for paid customers."); + return array('error' => 'Sorry but this feature is only available for paid customers.'); } $settings = $_POST['settings']; wfConfig::set('cbl_action', $settings['blockAction']); @@ -2062,13 +2053,13 @@ SQL return $return; } - public static function saveCacheConfig(){ + public static function saveCacheConfig() { $noEditHtaccess = '1'; if (isset($_POST['needToCheckFalconHtaccess']) && !empty($_POST['needToCheckFalconHtaccess'])) { $checkHtaccess = self::checkFalconHtaccess(); if (isset($checkHtaccess['ok'])) $noEditHtaccess = '0'; - } else if (isset($_POST['noEditHtaccess'])) { + } else if (isset($_POST['noEditHtaccess'])) { $noEditHtaccess = $_POST['noEditHtaccess']; } @@ -2079,20 +2070,20 @@ SQL foreach($plugins as $pluginFile => $data){ if(is_plugin_active($pluginFile)){ if($pluginFile == 'w3-total-cache/w3-total-cache.php'){ - $badPlugins[] = "W3 Total Cache"; + $badPlugins[] = 'W3 Total Cache'; } else if($pluginFile == 'quick-cache/quick-cache.php'){ - $badPlugins[] = "Quick Cache"; - } else if($pluginFile == "wp-super-cache/wp-cache.php"){ - $badPlugins[] = "WP Super Cache"; - } else if($pluginFile == "wp-fast-cache/wp-fast-cache.php"){ - $badPlugins[] = "WP Fast Cache"; - } else if($pluginFile == "wp-fastest-cache/wpFastestCache.php"){ - $badPlugins[] = "WP Fastest Cache"; + $badPlugins[] = 'Quick Cache'; + } else if($pluginFile == 'wp-super-cache/wp-cache.php'){ + $badPlugins[] = 'WP Super Cache'; + } else if($pluginFile == 'wp-fast-cache/wp-fast-cache.php'){ + $badPlugins[] = 'WP Fast Cache'; + } else if($pluginFile == 'wp-fastest-cache/wpFastestCache.php'){ + $badPlugins[] = 'WP Fastest Cache'; } } } if(count($badPlugins) > 0){ - return array('errorMsg' => "You can not enable caching in Wordfence with other caching plugins enabled. This may cause conflicts. You need to disable other caching plugins first. Wordfence caching is very fast and does not require other caching plugins to be active. The plugins you have that conflict are: " . implode(', ', $badPlugins) . ". Disable these plugins, then return to this page and enable Wordfence caching."); + return array('errorMsg' => 'You can not enable caching in Wordfence with other caching plugins enabled. This may cause conflicts. You need to disable other caching plugins first. Wordfence caching is very fast and does not require other caching plugins to be active. The plugins you have that conflict are: ' . implode(', ', $badPlugins) . '. Disable these plugins, then return to this page and enable Wordfence caching.'); } $siteURL = site_url(); if(preg_match('/^https?:\/\/[^\/]+\/[^\/]+\/[^\/]+\/.+/i', $siteURL)){ @@ -2101,7 +2092,7 @@ SQL } if($cacheType == 'falcon'){ if(! get_option('permalink_structure', '')){ - return array('errorMsg' => "You need to enable Permalinks for your site to use Falcon Engine. You can enable Permalinks in WordPress by going to the Settings - Permalinks menu and enabling it there. Permalinks change your site URL structure from something that looks like /p=123 to pretty URLs like /my-new-post-today/ that are generally more search engine friendly."); + return array('errorMsg' => 'You need to enable Permalinks for your site to use Falcon Engine. You can enable Permalinks in WordPress by going to the Settings - Permalinks menu and enabling it there. Permalinks change your site URL structure from something that looks like /p=123 to pretty URLs like /my-new-post-today/ that are generally more search engine friendly.'); } } $warnHtaccess = false; @@ -2115,7 +2106,7 @@ SQL if($cacheType == 'php' || $cacheType == 'falcon'){ $err = wfCache::cacheDirectoryTest(); if($err){ - return array('ok' => 1, 'heading' => "Could not write to cache directory", 'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err"); + return array('ok' => 1, 'heading' => 'Could not write to cache directory', 'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err"); } } @@ -2123,59 +2114,59 @@ SQL if($cacheType != wfConfig::get('cacheType', false)){ wfCache::scheduleCacheClear(); } - $htMsg = ""; + $htMsg = ''; if($warnHtaccess){ $htMsg = " Warning: We could not remove the caching code from your .htaccess file. you need to remove this manually yourself. "; } if($cacheType == 'disable'){ wfConfig::set('cacheType', false); - return array('ok' => 1, 'heading' => "Caching successfully disabled.", 'body' => "{$htMsg}Caching has been disabled on your system.

"); + return array('ok' => 1, 'heading' => 'Caching successfully disabled.', 'body' => "{$htMsg}Caching has been disabled on your system.

"); } else if($cacheType == 'php'){ wfConfig::set('cacheType', 'php'); - return array('ok' => 1, 'heading' => "Wordfence Basic Caching Enabled", 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

"); + return array('ok' => 1, 'heading' => 'Wordfence Basic Caching Enabled', 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

"); } else if($cacheType == 'falcon'){ if($noEditHtaccess != '1'){ $err = wfCache::addHtaccessCode('add'); if($err){ - return array('ok' => 1, 'heading' => "Wordfence could not edit .htaccess", 'body' => "Wordfence could not edit your .htaccess code. The error was: " . $err); + return array('ok' => 1, 'heading' => 'Wordfence could not edit .htaccess', 'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err); } } wfConfig::set('cacheType', 'falcon'); wfCache::scheduleUpdateBlockedIPs(); //Runs every 5 mins until we change cachetype - return array('ok' => 1, 'heading' => "Wordfence Falcon Engine Activated!", 'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:
"); + return array('ok' => 1, 'heading' => 'Wordfence Falcon Engine Activated!', 'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:
"); } - return array('errorMsg' => "An error occurred."); + return array('errorMsg' => 'An error occurred.'); } - public static function checkFalconHtaccess(){ + public static function checkFalconHtaccess() { if(wfUtils::isNginx()){ return array('nginx' => 1); } $file = wfCache::getHtaccessPath(); if(! $file){ - return array('err' => "We could not find your .htaccess file to modify it.", 'code' => wfCache::getHtaccessCode() ); + return array('err' => 'We could not find your .htaccess file to modify it.', 'code' => wfCache::getHtaccessCode() ); } $fh = @fopen($file, 'r+'); if(! $fh){ $err = error_get_last(); - return array('err' => "We found your .htaccess file but could not open it for writing: " . $err['message'], 'code' => wfCache::getHtaccessCode() ); + return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'], 'code' => wfCache::getHtaccessCode() ); } $download_url = admin_url( 'admin-ajax.php' ) . '?action=mainwp_wordfence_download_htaccess&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_htaccess' ); - return array( 'ok' => 1 , 'download_url' => $download_url ); + return array( 'ok' => 1, 'download_url' => $download_url ); } - public static function checkHtaccess(){ + public static function checkHtaccess() { if(wfUtils::isNginx()){ return array('nginx' => 1); } $file = wfCache::getHtaccessPath(); if(! $file){ - return array('err' => "We could not find your .htaccess file to modify it."); + return array('err' => 'We could not find your .htaccess file to modify it.'); } $fh = @fopen($file, 'r+'); if(! $fh){ $err = error_get_last(); - return array('err' => "We found your .htaccess file but could not open it for writing: " . $err['message']); + return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message']); } return array('ok' => 1); } @@ -2201,7 +2192,7 @@ SQL die(); } - public static function saveCacheOptions(){ + public static function saveCacheOptions() { $changed = false; if($_POST['allowHTTPSCaching'] != wfConfig::get('allowHTTPSCaching', false)){ $changed = true; @@ -2212,30 +2203,30 @@ SQL if($changed && wfConfig::get('cacheType', false) == 'falcon'){ $err = wfCache::addHtaccessCode('add'); if($err){ - return array('updateErr' => "Wordfence could not edit your .htaccess file. The error was: " . $err, 'code' => wfCache::getHtaccessCode() ); + return array('updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err, 'code' => wfCache::getHtaccessCode() ); } } wfCache::scheduleCacheClear(); return array('ok' => 1); } - public static function clearPageCache(){ + public static function clearPageCache() { $stats = wfCache::clearPageCache(); if($stats['error']){ - $body = "A total of " . $stats['totalErrors'] . " errors occurred while trying to clear your cache. The last error was: " . $stats['error']; + $body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error']; return array('ok' => 1, 'heading' => 'Error occurred while clearing cache', 'body' => $body ); } - $body = "A total of " . $stats['filesDeleted'] . ' files were deleted and ' . $stats['dirsDeleted'] . ' directories were removed. We cleared a total of ' . $stats['totalData'] . 'KB of data in the cache.'; + $body = 'A total of ' . $stats['filesDeleted'] . ' files were deleted and ' . $stats['dirsDeleted'] . ' directories were removed. We cleared a total of ' . $stats['totalData'] . 'KB of data in the cache.'; if($stats['totalErrors'] > 0){ $body .= ' A total of ' . $stats['totalErrors'] . ' errors were encountered. This probably means that we could not remove some of the files or directories in the cache. Please use your CPanel or file manager to remove the rest of the files in the directory: ' . WP_CONTENT_DIR . '/wfcache/'; } return array('ok' => 1, 'heading' => 'Page Cache Cleared', 'body' => $body ); } - public static function getCacheStats(){ + public static function getCacheStats() { $s = wfCache::getCacheStats(); if($s['files'] == 0){ - return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => "The cache is currently empty. It may be disabled or it may have been recently cleared."); + return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.'); } $body = 'Total files in cache: ' . $s['files'] . '
Total directories in cache: ' . $s['dirs'] . @@ -2269,7 +2260,7 @@ SQL return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => $body); } - public static function addCacheExclusion(){ + public static function addCacheExclusion() { $ex = wfConfig::get('cacheExclusions', false); if($ex){ $ex = unserialize($ex); @@ -2289,13 +2280,13 @@ SQL wfCache::scheduleCacheClear(); if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])){ if(wfCache::addHtaccessCode('add')){ //rewrites htaccess rules - return array('errorMsg' => "We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.", 'ex' => $ex); + return array('errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.', 'ex' => $ex); } } return array('ok' => 1, 'ex' => $ex); } - public static function loadCacheExclusions(){ + public static function loadCacheExclusions() { $ex = wfConfig::get('cacheExclusions', false); if(! $ex){ return array('ex' => false); @@ -2304,7 +2295,7 @@ SQL return array('ok' => 1, 'ex' => $ex); } - public static function removeCacheExclusion(){ + public static function removeCacheExclusion() { $id = $_POST['id']; $ex = wfConfig::get('cacheExclusions', false); if(! $ex){ @@ -2314,7 +2305,7 @@ SQL $rewriteHtaccess = false; $removed = false; for($i = 0; $i < sizeof($ex); $i++){ - if((string)$ex[$i]['id'] == (string)$id){ + if( (string) $ex[$i]['id'] == (string) $id){ if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[$i]['pt'])){ $rewriteHtaccess = true; } @@ -2325,7 +2316,7 @@ SQL } $return = array('ex' => $ex); if (!$removed) { - $return['error'] = "Not found the cache exclusion."; + $return['error'] = 'Not found the cache exclusion.'; return $return; } @@ -2341,7 +2332,7 @@ SQL public function getDiagnostics() { - $diagnostic = new wfDiagnostic; + $diagnostic = new wfDiagnostic(); $plugins = get_plugins(); $activePlugins = array_flip(get_option('active_plugins')); $activeNetworkPlugins = is_multisite() ? array_flip(wp_get_active_network_plugins()) : array(); @@ -2359,7 +2350,8 @@ SQL
- getResults() as $title => $tests): + getResults() as $title => $tests): $key = sanitize_key('wf-diagnostics-' . $title); $hasFailingTest = false; foreach ($tests['results'] as $result) { @@ -2369,28 +2361,33 @@ SQL } } - if ($inEmail): ?> + if ($inEmail): + ?> - + + )) + ?> + @@ -2398,13 +2395,17 @@ SQL
"> + array(), 'strong' => array(), 'em' => array(), 'a' => array('href' => true), - )) ?> -
+
-
+
-
+
- - + +
@@ -2416,16 +2417,20 @@ SQL
  • "> + array(), 'strong' => array(), 'em' => array(), 'a' => array('href' => true), - )) ?>
    + )) + ?> +
  • -
    +
    -
    +
    @@ -2451,12 +2456,12 @@ SQL } } ?> -
    +
    - - + +
    @@ -2465,7 +2470,7 @@ SQL
    - > +
    > @@ -2482,10 +2487,12 @@ SQL 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label): ?> + ) as $variable => $label): + ?> - - + + ?> + @@ -2534,12 +2542,12 @@ SQL -
    +
    - - + +
    @@ -2547,7 +2555,7 @@ SQL
    -
    IPs
    + In use
    > +
    > - - - + + + @@ -2632,12 +2640,12 @@ SQL -
    +
    - - + +
    @@ -2645,14 +2653,14 @@ SQL
    -
    > +
    > $pluginData): ?> - @@ -2668,12 +2676,12 @@ SQL
    - + + - - Version + - Version
    -
    +
    - - + +
    @@ -2681,15 +2689,15 @@ SQL
    - > +
    > $pluginData): ?> - @@ -2699,7 +2707,7 @@ SQL - + @@ -2707,12 +2715,12 @@ SQL
    - + + - - Version + - Version Active
    No MU-PluginsNo MU-Plugins
    -
    +
    - - + +
    @@ -2720,14 +2728,14 @@ SQL
    - > +
    > $themeData): ?> - + get_stylesheet()): ?> @@ -2739,7 +2747,7 @@ SQL - + @@ -2747,12 +2755,12 @@ SQL
    - - Version + + Version Active
    No ThemesNo Themes
    -
    +
    - - + +
    @@ -2760,7 +2768,7 @@ SQL
    - > +
    > - - + + querySelect("SHOW TABLE STATUS WHERE Name IN (" . implode(',', $tables) . ')'); + $q = $wfdb->querySelect('SHOW TABLE STATUS WHERE Name IN (' . implode(',', $tables) . ')'); if ($q): $databaseCols = count($q[0]); ?> -
    +
    - - + +
    @@ -2813,14 +2821,14 @@ SQL
    -
    > +
    > $tval): ?> - + @@ -2831,7 +2839,7 @@ SQL ?> $tval): ?> - + -
    +
    - - + +
    @@ -2868,7 +2876,7 @@ SQL
    -
    > +
    > @@ -2878,18 +2886,23 @@ SQL + if (count($errorLogs) < 1): + ?> - $readable): ?> + $readable): + ?> - +
    File
    No log files found.
    Download' : 'Requires downloading from the server directly'); ?>
    @@ -2941,7 +2954,6 @@ SQL 1, 'html' => $html); - } public static function updateWAFRules() { @@ -2970,4 +2982,4 @@ SQL } return array('ok' => 1 ); } -} \ No newline at end of file +} diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index ba1ebd4..8771c1b 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -20,11 +20,11 @@ class MainWP_Child_WP_Rocket { public $is_plugin_installed = false; public static function Instance() { - if ( null === MainWP_Child_WP_Rocket::$instance ) { - MainWP_Child_WP_Rocket::$instance = new MainWP_Child_WP_Rocket(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_WP_Rocket(); } - return MainWP_Child_WP_Rocket::$instance; + return self::$instance; } public function __construct() { @@ -60,7 +60,7 @@ class MainWP_Child_WP_Rocket { 'do_caching_mobile_files' => 0, 'cache_logged_user' => 0, 'cache_ssl' => 0, - 'emoji' => 0, + 'emoji' => 0, 'embeds' => 1, 'control_heartbeat' => 0, 'heartbeat_site_behavior' => 'reduce_periodicity', @@ -92,23 +92,23 @@ class MainWP_Child_WP_Rocket { 'exclude_css' => array(), 'exclude_js' => array(), 'exclude_inline_js' => array(), - 'async_css' => 0, + 'async_css' => 0, 'defer_all_js' => 0, - 'defer_all_js_safe' => 1, + 'defer_all_js_safe' => 1, 'critical_css' => '', 'deferred_js_files' => array(), - 'lazyload' => 0, + 'lazyload' => 0, 'lazyload_iframes' => 0, - 'lazyload_youtube' =>0, + 'lazyload_youtube' =>0, 'minify_css' => 0, // 'minify_css_key' => $minify_css_key, - 'minify_concatenate_css' => 0, + 'minify_concatenate_css' => 0, //'minify_css_combine_all' => 0, - 'minify_css_legacy' => 0, + 'minify_css_legacy' => 0, 'minify_js' => 0, // 'minify_js_key' => $minify_js_key, 'minify_js_in_footer' => array(), - 'minify_concatenate_js' => 0, + 'minify_concatenate_js' => 0, 'minify_js_combine_all' => 0, //'minify_js_legacy' => 0, 'minify_google_fonts' => 0, @@ -120,12 +120,12 @@ class MainWP_Child_WP_Rocket { 'cdn_zone' => array(), //'cdn_ssl' => 0, 'cdn_reject_files' => array(), - 'do_cloudflare' => 0, - 'cloudflare_email' => '', - 'cloudflare_api_key' => '', - 'cloudflare_domain' => '', + 'do_cloudflare' => 0, + 'cloudflare_email' => '', + 'cloudflare_api_key' => '', + 'cloudflare_domain' => '', //'cloudflare_zone_id' => '', - 'cloudflare_devmode' => 0, + 'cloudflare_devmode' => 0, 'cloudflare_protocol_rewrite' => 0, 'cloudflare_auto_settings' => 0, 'cloudflare_old_settings' => 0, @@ -251,7 +251,6 @@ class MainWP_Child_WP_Rocket { $information = array(); - if ( isset( $_POST['mwp_action'] ) ) { // MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' ); try { @@ -274,7 +273,7 @@ class MainWP_Child_WP_Rocket { case 'save_settings': $information = $this->save_settings(); break; - case "load_existing_settings": + case 'load_existing_settings': $information = $this->load_existing_settings(); break; case 'optimize_database': @@ -342,7 +341,7 @@ class MainWP_Child_WP_Rocket { // to fix include_once( ABSPATH . '/wp-admin/includes/template.php' ); - + // Generate a new random key for minify cache file $options = get_option( WP_ROCKET_SLUG ); $options['minify_css_key'] = create_rocket_uniqid(); @@ -379,7 +378,7 @@ class MainWP_Child_WP_Rocket { 'WP_Rocket\Optimization\CSS\Critical_CSS', 'WP_Rocket\Optimization\CSS\Critical_CSS_Generation', 'WP_Rocket\Admin\Options', - 'WP_Rocket\Admin\Options_Data' + 'WP_Rocket\Admin\Options_Data', )); $critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() ); @@ -411,7 +410,6 @@ class MainWP_Child_WP_Rocket { } } - update_option( WP_ROCKET_SLUG, $options ); if (isset($_POST['do_database_optimization']) && !empty($_POST['do_database_optimization'])) { @@ -426,7 +424,7 @@ class MainWP_Child_WP_Rocket { MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization', 'WP_Rocket\Admin\Database\Optimization_Process', 'WP_Rocket\Admin\Options', - 'WP_Rocket\Admin\Options_Data' + 'WP_Rocket\Admin\Options_Data', )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); @@ -436,7 +434,7 @@ class MainWP_Child_WP_Rocket { $options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' ); $options = new WP_Rocket\Admin\Options_Data( $options_api->get( 'settings', array() ) ); - $items = array_filter( array_keys( $optimization->get_options() ), [ $options, 'get' ] ); + $items = array_filter( array_keys( $optimization->get_options() ), array( $options, 'get' ) ); if ( !empty( $items ) ) { $optimization->process_handler( $items ); @@ -449,7 +447,7 @@ class MainWP_Child_WP_Rocket { function get_optimize_info() { MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization', - 'WP_Rocket\Admin\Database\Optimization_Process' + 'WP_Rocket\Admin\Database\Optimization_Process', )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); @@ -464,7 +462,7 @@ class MainWP_Child_WP_Rocket { 'total_trashed_comments' => $optimization->count_cleanup_items( 'database_trashed_comments' ), 'total_expired_transients' => $optimization->count_cleanup_items( 'database_expired_transients' ), 'total_all_transients' => $optimization->count_cleanup_items( 'database_all_transients' ), - 'total_optimize_tables' => $optimization->count_cleanup_items( 'database_optimize_tables' ) + 'total_optimize_tables' => $optimization->count_cleanup_items( 'database_optimize_tables' ), ); $information['result'] = 'SUCCESS'; diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index 85a1eab..612e62c 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -1,22 +1,20 @@ public_intetface = new WPvivid_Public_Interface(); } - public function init() - { - + public function init() { } - function syncOthersData( $information, $data = array() ) - { + function syncOthersData( $information, $data = array() ) { try{ if ( isset( $data['syncWPvividData'] )) @@ -56,8 +51,7 @@ class MainWP_Child_WPvivid_BackupRestore return $information; } - public function action() - { + public function action() { $information = array(); if ( ! $this->is_plugin_installed ) { @@ -141,167 +135,147 @@ class MainWP_Child_WPvivid_BackupRestore } } - public function post_mainwp_data($data){ + public function post_mainwp_data( $data) { global $wpvivid_plugin; $ret =$wpvivid_plugin->wpvivid_handle_mainwp_action($data); return $ret; } - public function prepare_backup() - { + public function prepare_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->prepare_backup($_POST['backup']); return $ret; } - public function backup_now() - { + public function backup_now() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->backup_now($_POST['task_id']); return $ret; } - public function get_status() - { + public function get_status() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_status(); return $ret; } - public function get_backup_schedule() - { + public function get_backup_schedule() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_backup_schedule(); return $ret; } - public function get_backup_list() - { + public function get_backup_list() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_backup_list(); return $ret; } - public function get_default_remote() - { + public function get_default_remote() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_default_remote(); return $ret; } - public function delete_backup() - { + public function delete_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']); return $ret; } - public function delete_backup_array() - { + public function delete_backup_array() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->delete_backup_array($_POST['backup_id']); return $ret; } - public function set_security_lock() - { + public function set_security_lock() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']); return $ret; } - public function view_log() - { + public function view_log() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->view_log($_POST['id']); return $ret; } - public function read_last_backup_log() - { + public function read_last_backup_log() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']); return $ret; } - public function view_backup_task_log() - { + public function view_backup_task_log() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->view_backup_task_log($_POST['id']); return $ret; } - public function backup_cancel() - { + public function backup_cancel() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->backup_cancel($_POST['task_id']); return $ret; } - public function init_download_page() - { + public function init_download_page() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->init_download_page($_POST['backup_id']); return $ret; } - public function prepare_download_backup() - { + public function prepare_download_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']); return $ret; } - public function get_download_task() - { + public function get_download_task() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_download_task($_POST['backup_id']); return $ret; } - public function download_backup() - { + public function download_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']); return $ret; } - public function set_general_setting() - { + public function set_general_setting() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_general_setting($_POST['setting']); return $ret; } - public function set_schedule() - { + public function set_schedule() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_schedule($_POST['schedule']); return $ret; } - public function set_remote() - { + public function set_remote() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_remote($_POST['remote']); diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 0678626..e4effc9 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -1,11 +1,11 @@ ' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '
    Trace: ' .$stackTrace) ) ) . '' ); + die( '' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '
    Trace: ' . $stackTrace) ) ) . '
    ' ); } // To fix verify nonce conflict #2 @@ -81,7 +81,6 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus return false; } - $token = wp_get_session_token(); $i = wp_nonce_tick(); @@ -109,7 +108,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus $stackTrace = "\n" . @ob_get_clean(); // Invalid nonce - die( '' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '
    Trace: ' .$stackTrace) ) ) . '
    ' ); + die( '' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '
    Trace: ' . $stackTrace) ) ) . '
    ' ); } endif; } @@ -178,7 +177,7 @@ class MainWP_Child { 'wp_rocket' => 'wp_rocket', 'settings_tools' => 'settings_tools', 'skeleton_key' => 'skeleton_key', - 'custom_post_type' => 'custom_post_type', + 'custom_post_type' => 'custom_post_type', 'backup_buddy' => 'backup_buddy', 'get_site_icon' => 'get_site_icon', 'vulner_checker' => 'vulner_checker', @@ -187,7 +186,7 @@ class MainWP_Child { 'time_capsule' => 'time_capsule', 'extra_excution' => 'extra_execution', // deprecated 'extra_execution' => 'extra_execution', - 'wpvivid_backuprestore'=>'wpvivid_backuprestore' + 'wpvivid_backuprestore'=>'wpvivid_backuprestore', ); private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.'; @@ -212,9 +211,9 @@ class MainWP_Child { public function __construct( $plugin_file ) { $this->update(); $this->load_all_options(); - $this->filterFunction = function($a) { + $this->filterFunction = function( $a) { if ($a == null) { return false; } - if (is_object($a) && property_exists($a, "last_checked") && !property_exists($a, "checked")) + if (is_object($a) && property_exists($a, 'last_checked') && !property_exists($a, 'checked')) return false; return $a; }; @@ -235,7 +234,6 @@ class MainWP_Child { add_action( 'pre_current_active_plugins', array( &$this, 'detect_premium_themesplugins_updates' ) ); // to support detect premium plugins update add_action( 'core_upgrade_preamble', array( &$this, 'detect_premium_themesplugins_updates' ) ); // to support detect premium themes - if ( is_admin() ) { MainWP_Helper::update_option( 'mainwp_child_plugin_version', self::$version, 'yes' ); } @@ -264,7 +262,6 @@ class MainWP_Child { add_action( 'init', array( $this, 'cron_active' ), PHP_INT_MAX ); } } - } @@ -317,14 +314,14 @@ class MainWP_Child { 'mainwp_linkschecker_ext_enabled', //'mainwp_ithemes_ext_enabled', 'mainwp_child_branding_settings', - 'mainwp_child_plugintheme_days_outdate' + 'mainwp_child_plugintheme_days_outdate', ); $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in ("; foreach ($options as $option) { $query .= "'" . $option . "', "; } $query = substr($query, 0, strlen($query) - 2); - $query .= ")"; + $query .= ')'; $alloptions_db = $wpdb->get_results( $query ); $wpdb->suppress_errors($suppress); @@ -501,7 +498,7 @@ class MainWP_Child { 'disable_change' => 'mainwp_branding_disable_change', 'disable_switching_theme' => 'mainwp_branding_disable_switching_theme', //'hide_child_reports' => 'mainwp_creport_branding_stream_hide', - 'branding_ext_enabled' => 'mainwp_branding_ext_enabled' + 'branding_ext_enabled' => 'mainwp_branding_ext_enabled', ); $convertBranding = array(); @@ -525,9 +522,9 @@ class MainWP_Child { return; } @session_write_close(); - @header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ), TRUE ); - @header( 'X-Robots-Tag: noindex, nofollow', TRUE ); - @header( 'X-MainWP-Child-Version: ' . MainWP_Child::$version, TRUE ); + @header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ), true ); + @header( 'X-Robots-Tag: noindex, nofollow', true ); + @header( 'X-MainWP-Child-Version: ' . self::$version, true ); nocache_headers(); if ( $_GET[ 'mainwp_child_run' ] == 'test' ) { die( 'MainWP Test' ); @@ -542,20 +539,20 @@ class MainWP_Child { $child_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Child' : $branding_opts['branding_preserve_title']; $dashboard_name = ( $branding_opts['branding_preserve_title'] === '' ) ? 'MainWP Dashboard' : $branding_opts['branding_preserve_title'] . ' Dashboard'; - $msg = '

    '; + $msg = '

    '; $msg .= __( 'Attention!', 'mainwp-child' ); - $msg .= '

    '; - $msg .= __( 'Please add this site to your ', 'mainwp-child' ) . $dashboard_name . ' ' . __( 'NOW or deactivate the ', 'mainwp-child' ) . $child_name . __( ' plugin until you are ready to connect this site to your Dashboard in order to avoid unexpected security issues.','mainwp-child' ); - $msg .= '

    '; + $msg .= '

    '; + $msg .= __( 'Please add this site to your ', 'mainwp-child' ) . $dashboard_name . ' ' . __( 'NOW or deactivate the ', 'mainwp-child' ) . $child_name . __( ' plugin until you are ready to connect this site to your Dashboard in order to avoid unexpected security issues.', 'mainwp-child' ); + $msg .= '

    '; $msg .= '

    '; $msg .= __( 'If you are not sure how to add this site to your Dashboard, please review these instructions.', 'mainwp-child' ); - $msg .= '

    '; + $msg .= '

    '; if ( ! MainWP_Child_Branding::Instance()->is_branding() ) { - $msg .= '

    '; - $msg .= __( 'You can also turn on the unique security ID option in ', 'mainwp-child' ) . $child_name . __( ' settings if you would like extra security and additional time to add this site to your Dashboard.
    Find out more in this help document How do I use the child unique security ID?', 'mainwp-child' ); - $msg .= '

    '; + $msg .= '

    '; + $msg .= __( 'You can also turn on the unique security ID option in ', 'mainwp-child' ) . $child_name . __( ' settings if you would like extra security and additional time to add this site to your Dashboard.
    Find out more in this help document How do I use the child unique security ID?', 'mainwp-child' ); + $msg .= '

    '; } - $msg .= '
    '; + $msg .= '
    '; echo wp_kses_post( $msg ); } MainWP_Child_Server_Information::showWarnings(); @@ -590,7 +587,6 @@ class MainWP_Child { //wp_destroy_current_session(); // to fix issue multi user session } - $type = isset($_GET['_request_update_premiums_type']) ? $_GET['_request_update_premiums_type'] : ''; if ( $type == 'plugin' || $type == 'theme' ) { $list = isset( $_GET['list'] ) ? $_GET['list'] : ''; @@ -607,7 +603,6 @@ class MainWP_Child { //wp_destroy_current_session(); // to fix issue multi user session } } - } function checkOtherAuth() { @@ -723,7 +718,7 @@ class MainWP_Child { $subpageargs = array( 'child_slug' => 'options-general.php', // to backwards compatible 'branding' => (self::$brandingTitle === null) ? 'MainWP' : self::$brandingTitle, - 'parent_menu' => $settingsPage + 'parent_menu' => $settingsPage, ); do_action( 'mainwp-child-subpages', $subpageargs ); // to compatible @@ -742,7 +737,7 @@ class MainWP_Child { $subpage = array(); $subpage['slug'] = $slug; $subpage['title'] = $page['title']; - $subpage['page'] = 'mainwp-' . str_replace( ' ', '-', strtolower( str_replace( '-', ' ', $slug ) ) ); + $subpage['page'] = 'mainwp-' . str_replace( ' ', '-', strtolower( str_replace( '-', ' ', $slug ) ) ); if ( isset( $page['callback'] ) ) { $subpage['callback'] = $page['callback']; $created_page = add_submenu_page( 'options-general.php', $subpage['title'], '
    ' . $subpage['title'] . '
    ', 'manage_options', $subpage['page'], $subpage['callback'] ); @@ -771,7 +766,7 @@ class MainWP_Child { } } - function render_pages($shownPage) { + function render_pages( $shownPage) { $shownPage = ''; if ( isset($_GET['tab']) ) { $shownPage = $_GET['tab']; @@ -800,7 +795,7 @@ class MainWP_Child { self::render_header($shownPage, false); ?> -
    > +
    > settings(); ?>
    @@ -827,13 +822,13 @@ class MainWP_Child { -
    > +
    >
    -
    > +
    >
    @@ -844,7 +839,7 @@ class MainWP_Child { self::render_footer(); } - public static function render_header($shownPage, $subpage = true) { + public static function render_header( $shownPage, $subpage = true) { if ( isset($_GET['tab']) ) { $shownPage = $_GET['tab']; } @@ -922,16 +917,16 @@ class MainWP_Child {

    - + - + - + - +
    - ' . esc_html__( 'Your unique security ID is:', 'mainwp-child' ) . ' ' . esc_html( get_option( 'mainwp_child_uniqueId' ) ) . ''; - } ?> + } + ?>

    - +
    @@ -1437,7 +1434,7 @@ class MainWP_Child { //Register does not require auth, so we register here.. if ( isset( $_POST['function'] ) && 'register' === $_POST['function'] ) { define( 'DOING_CRON', true ); - MainWP_Child::fix_for_custom_themes(); + self::fix_for_custom_themes(); $this->registerSite(); } @@ -1531,17 +1528,16 @@ class MainWP_Child { // ob_end_clean(); MainWP_Helper::handle_fatal_error(); - MainWP_Child::fix_for_custom_themes(); + self::fix_for_custom_themes(); call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) ); } else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) { define( 'DOING_CRON', true ); - MainWP_Child::fix_for_custom_themes(); + self::fix_for_custom_themes(); call_user_func( array( $this, $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ); } else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) { MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) ); } - if ( 1 === (int) get_option( 'mainwpKeywordLinks' ) ) { new MainWP_Keyword_Links(); if ( ! is_admin() ) { @@ -1552,7 +1548,6 @@ class MainWP_Child { } else if ( 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { MainWP_Keyword_Links::clear_htaccess(); // force clear } - } // Check to support login by alternative admin @@ -2218,7 +2213,6 @@ class MainWP_Child { remove_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ), 10 ); delete_site_transient( 'mainwp_update_themes_cached' ); // to fix cached update info - // $last_update = get_site_transient( 'update_themes' ); // if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { // $last_update->last_checked = $originalLastChecked; @@ -2316,7 +2310,7 @@ class MainWP_Child { public function set_cached_update_plugins( $false = false, $_transient_data = null ) { if ( ! is_object( $_transient_data ) ) { - $_transient_data = new stdClass; + $_transient_data = new stdClass(); } $pre = false; @@ -2339,7 +2333,7 @@ class MainWP_Child { public function set_cached_update_themes( $false = false, $_transient_data = null ) { if ( ! is_object( $_transient_data ) ) { - $_transient_data = new stdClass; + $_transient_data = new stdClass(); } $pre = false; @@ -2426,8 +2420,8 @@ class MainWP_Child { //Login if ( isset( $_POST['user'] ) ) { if ( ! $this->login( $_POST['user'] ) ) { - $hint = "
    " . __('Hint: Check if the administrator user exists on the child site, if not, you need to use an existing administrator.', 'mainwp-child'); - MainWP_Helper::error(__('That administrator username was not found on this child site. Please verify that it is an existing administrator.' . $hint,'mainwp-child')); + $hint = '
    ' . __('Hint: Check if the administrator user exists on the child site, if not, you need to use an existing administrator.', 'mainwp-child'); + MainWP_Helper::error(__('That administrator username was not found on this child site. Please verify that it is an existing administrator.' . $hint, 'mainwp-child')); } if ( 10 !== $current_user->wp_user_level && ( ! isset( $current_user->user_level ) || 10 !== $current_user->user_level ) && ! $current_user->has_cap( 'level_10' ) ) { @@ -2505,11 +2499,11 @@ class MainWP_Child { wp_publish_post( $postId ); // to fix: fail when publish future page wp_update_post(array('ID' => $postId, 'post_date' => current_time( 'mysql', false ), - 'post_date_gmt' => current_time( 'mysql', true ) + 'post_date_gmt' => current_time( 'mysql', true ), )); } else { // to fix error post slug - wp_update_post(array('ID' => $postId,'post_status' => 'publish' )); + wp_update_post(array('ID' => $postId, 'post_status' => 'publish' )); } } } else if ( 'update' === $action ) { @@ -2560,7 +2554,7 @@ class MainWP_Child { MainWP_Helper::write( $information ); } - function get_post_edit($id) { + function get_post_edit( $id) { $post = get_post( $id ); if ( $post ) { $categoryObjects = get_the_category( $post->ID ); @@ -2601,7 +2595,7 @@ class MainWP_Child { 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, 'src' => $attachment->guid, - 'title' => $attachment->post_title + 'title' => $attachment->post_title, ); } } @@ -2622,7 +2616,7 @@ class MainWP_Child { 'post_name' => $post->post_name, 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, - 'ping_status' => $post->ping_status + 'ping_status' => $post->ping_status, ); if ( $post_featured_image != null ) { //Featured image is set, retrieve URL @@ -2647,7 +2641,7 @@ class MainWP_Child { return false; } - function get_page_edit($id) { + function get_page_edit( $id) { $post = get_post( $id ); if ( $post ) { $post_custom = get_post_custom( $id ); @@ -2667,10 +2661,9 @@ class MainWP_Child { 'post_name' => $post->post_name, 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, - 'ping_status' => $post->ping_status + 'ping_status' => $post->ping_status, ); - if ( $post_featured_image != null ) { //Featured image is set, retrieve URL $img = wp_get_attachment_image_src( $post_featured_image, 'full' ); $post_featured_image = $img[0]; @@ -2690,7 +2683,7 @@ class MainWP_Child { 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, 'src' => $attachment->guid, - 'title' => $attachment->post_title + 'title' => $attachment->post_title, ); } } @@ -2777,7 +2770,7 @@ class MainWP_Child { function edit_user( $user_id, $data) { $wp_roles = wp_roles(); - $user = new stdClass; + $user = new stdClass(); $update = true; @@ -2824,7 +2817,7 @@ class MainWP_Child { } else { $user->user_url = esc_url_raw( $data['url'] ); $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); - $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; + $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url; } } @@ -2854,7 +2847,7 @@ class MainWP_Child { } // Check for "\" in password. - if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) { + if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) { $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); } @@ -3645,7 +3638,7 @@ class MainWP_Child { 'memory_limit' => MainWP_Child_Server_Information::getPHPMemoryLimit(), 'mysql_version' => MainWP_Child_Server_Information::getMySQLVersion(), 'themeactivated' => $theme_name, - 'ip' => $_SERVER['SERVER_ADDR'] + 'ip' => $_SERVER['SERVER_ADDR'], ); //Try to switch to SSL if SSL is enabled in between! @@ -3849,7 +3842,6 @@ class MainWP_Child { } } - $translation_updates = wp_get_translation_updates(); if ( !empty( $translation_updates ) ) { $information['translation_updates'] = array(); @@ -3858,7 +3850,7 @@ class MainWP_Child { $new_translation_update = array('type' => $translation_update->type, 'slug' => $translation_update->slug, 'language' => $translation_update->language, - 'version' => $translation_update->version); + 'version' => $translation_update->version, ); if ( 'plugin' === $translation_update->type ) { $all_plugins = get_plugins(); foreach ( $all_plugins as $file => $plugin ) { @@ -3901,7 +3893,7 @@ class MainWP_Child { 'draft', 'pending', 'trash', - 'future' + 'future', ), $recent_number, 'page' ); $securityIssuess = 0; @@ -4889,7 +4881,7 @@ class MainWP_Child { return $rslt; } - function get_all_users($return = false) { + function get_all_users( $return = false) { $roles = explode( ',', $_POST['role'] ); $allusers = array(); if ( is_array( $roles ) ) { @@ -4917,7 +4909,7 @@ class MainWP_Child { MainWP_Helper::write( $allusers ); } - function get_all_users_int($number = false) { + function get_all_users_int( $number = false) { $allusers = array(); $params = array(); @@ -5011,7 +5003,7 @@ class MainWP_Child { function getSiteStatsNoAuth( $information = array() ) { if ( get_option( 'mainwp_child_pubkey' ) ) { $hint = '
    ' . __('Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again.', 'mainwp-child'); - MainWP_Helper::error(__('This site already contains a link. Please deactivate and reactivate the MainWP plugin.','mainwp-child') . $hint); + MainWP_Helper::error(__('This site already contains a link. Please deactivate and reactivate the MainWP plugin.', 'mainwp-child') . $hint); } global $wp_version; @@ -5299,7 +5291,6 @@ class MainWP_Child { $maint_options = array(); } - // $this->options = array( // 'revisions' => __( 'Delete all post revisions', 'mainwp-maintenance-extension' ), // 'autodraft' => __( 'Delete all auto draft posts', 'mainwp-maintenance-extension' ), @@ -5389,7 +5380,7 @@ class MainWP_Child { if ( !empty( $performed_what ) && has_action( 'mainwp_reports_maintenance' ) ) { $details = implode( ',', $performed_what ); $log_time = time(); - $message = $result = "Maintenance Performed"; + $message = $result = 'Maintenance Performed'; do_action( 'mainwp_reports_maintenance', $message, $log_time, $details, $result); } @@ -5488,7 +5479,6 @@ class MainWP_Child { //'From: "' . $from_email . '" <' . $from_email . '>', 'content-type: text/html', ) ); - } public function keyword_links_action() { @@ -5686,8 +5676,7 @@ class MainWP_Child { MainWP_Child_Updraft_Plus_Backups::Instance()->action(); } - function wpvivid_backuprestore() - { + function wpvivid_backuprestore() { MainWP_Child_WPvivid_BackupRestore::Instance()->action(); } @@ -5736,7 +5725,7 @@ class MainWP_Child { header( 'Content-Description: File Transfer' ); if ( MainWP_Helper::endsWith( $file, '.tar.gz' ) ) { header( 'Content-Type: application/x-gzip' ); - header( "Content-Encoding: gzip" ); + header( 'Content-Encoding: gzip' ); } else { header( 'Content-Type: application/octet-stream' ); } @@ -5745,8 +5734,7 @@ class MainWP_Child { header( 'Cache-Control: must-revalidate' ); header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $backupdir . $file ) ); - while ( @ob_end_flush() ) { - ; + while ( @ob_end_flush() ) {; } $this->readfile_chunked( $backupdir . $file, $offset ); } diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index a75badd..7876ccd 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -331,16 +331,16 @@ class MainWP_Clone_Install { } $token = $data[0]; switch ( $token ) { - case 's' : + case 's': if ( '"' !== $data[ $length - 2 ] ) { return false; } - case 'a' : - case 'O' : + case 'a': + case 'O': return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); - case 'b' : - case 'i' : - case 'd' : + case 'b': + case 'i': + case 'd': return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data ); } @@ -536,10 +536,10 @@ class MainWP_Clone_Install { * We split large tables into 50,000 row blocks when dealing with them to save * on memmory consumption. * - * @param mysql $connection The db connection object + * @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. + * @param array $tables The tables we want to look at. * * @return array Collection of information gathered during the run. */ @@ -647,7 +647,7 @@ class MainWP_Clone_Install { * * @return array The original array with all elements replaced as needed. */ - + /* Fixed serialize issue */ function recursive_unserialize_replace( $from = '', $to = '', $data = '', $serialised = false ) { diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 0cbf1ac..0f51435 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -153,13 +153,17 @@ class MainWP_Clone { + "> + -
    + + "> + @@ -307,7 +314,7 @@ class MainWP_Clone { $branding_msg = esc_html__( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' ); } ?> -
    +


    + title="">
    @@ -459,7 +466,7 @@ class MainWP_Clone { ?>
    - +
    - +
    - +
    var child_security_nonces = []; getSecurityNonces(); + $security_nonces = self::get()->getSecurityNonces(); foreach ($security_nonces as $k => $v) { - echo 'child_security_nonces['."'" .$k . "'". '] = ' . "'" . $v . "';\n"; + echo 'child_security_nonces[' . "'" . $k . "'" . '] = ' . "'" . $v . "';\n"; } ?> @@ -585,8 +592,8 @@ class MainWP_Clone { var translations = []; translations['large_site'] = ""; translations['continue_anyway'] = ""; - translations['creating_backup'] = ""; - translations['backup_created'] = ""; + translations['creating_backup'] = ""; + translations['backup_created'] = ""; translations['downloading_backup'] = ""; translations['backup_downloaded'] = ""; translations['extracting_backup'] = ""; @@ -1208,7 +1215,7 @@ class MainWP_Clone { 'f' => $rand, 'wpversion' => $wp_version, 'zipmethod' => $method, - 'json_result' => true + 'json_result' => true, ) ); if ( ! $result['backup'] ) { @@ -1253,7 +1260,7 @@ class MainWP_Clone { 'cloneFunc' => 'createCloneBackupPoll', 'key' => $key, 'f' => $rand, - 'json_result' => true + 'json_result' => true, ) ); if ( ! isset( $result['size'] ) ) { @@ -1341,7 +1348,7 @@ class MainWP_Clone { 'cloneFunc' => 'deleteCloneBackup', 'key' => $siteToClone['extauth'], 'f' => $_POST['file'], - 'json_result' => true + 'json_result' => true, ) ); } } @@ -1558,11 +1565,15 @@ class MainWP_Clone { clear: both; } -
    + + .
    'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ); // die( '' . base64_encode( serialize( ) ) . '' ); } else { - $data = MainWP_Custom_Post_Type::$information; + $data = self::$information; // die( '' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '' ); } - + if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] ) { $data = json_encode( $data ); } else { $data = serialize( $data ); } - + die('' . base64_encode( $data ) . ''); } - register_shutdown_function( "mainwp_custom_post_type_handle_fatal_error" ); + register_shutdown_function( 'mainwp_custom_post_type_handle_fatal_error' ); $information = array(); switch ( $_POST['action'] ) { @@ -48,7 +48,7 @@ class MainWP_Custom_Post_Type { } - MainWP_Custom_Post_Type::$information = $information; + self::$information = $information; exit(); } @@ -104,7 +104,7 @@ class MainWP_Custom_Post_Type { } try { - $downloadfile = MainWP_Helper::uploadImage( $originalImgUrl , array(), $check_image ); + $downloadfile = MainWP_Helper::uploadImage( $originalImgUrl, array(), $check_image ); $localUrl = $downloadfile['url']; $linkToReplaceWith = dirname( $localUrl ); if ( '' !== $hrefLink ) { @@ -159,7 +159,7 @@ class MainWP_Custom_Post_Type { 'post_modified_gmt', 'post_content_filtered', 'menu_order', - 'post_type' + 'post_type', ); foreach ( $data_keys as $key ) { @@ -190,7 +190,7 @@ class MainWP_Custom_Post_Type { if ( is_null( $old_post ) ) { return array( 'delete_connection' => 1, - 'error' => __( 'Cannot get old post. Probably is deleted now. Please try again for create new post', $this->plugin_translate ) + 'error' => __( 'Cannot get old post. Probably is deleted now. Please try again for create new post', $this->plugin_translate ), ); } @@ -313,7 +313,7 @@ class MainWP_Custom_Post_Type { // @todo missing alias_of which means term_group $term = wp_insert_term( $key['name'], $key['taxonomy'], array( 'description' => $key['description'], - 'slug' => $key['slug'] + 'slug' => $key['slug'], ) ); $term_taxonomy_id = 0; diff --git a/class/class-mainwp-debug.php b/class/class-mainwp-debug.php index 661a186..2615c67 100644 --- a/class/class-mainwp-debug.php +++ b/class/class-mainwp-debug.php @@ -1,34 +1,33 @@ -'; - $start = microtime( true ); - - if ( 'fullbackup' == $_GET['mainwpdebug'] ) { - //Full backup - $_POST['type'] = 'full'; - $_POST['excludebackup'] = '1'; - $_POST['excludecache'] = '1'; - $_POST['excludezip'] = '1'; - $_POST['excludenonwp'] = '1'; - $_POST['ext'] = 'tar.gz'; - print_r( $mainwpChild->backup( false ) ); - } else if ( 'test' == $_GET['mainwpdebug'] ) { - print_r( get_included_files() ); - } else { - print_r( $mainwpChild->getSiteStats( array(), false ) ); - } - - - $stop = microtime( true ); - die( "\n\n\n" . 'duration: ' . ( $stop - $start ) . 's' ); - } -} \ No newline at end of file +'; + $start = microtime( true ); + + if ( 'fullbackup' == $_GET['mainwpdebug'] ) { + //Full backup + $_POST['type'] = 'full'; + $_POST['excludebackup'] = '1'; + $_POST['excludecache'] = '1'; + $_POST['excludezip'] = '1'; + $_POST['excludenonwp'] = '1'; + $_POST['ext'] = 'tar.gz'; + print_r( $mainwpChild->backup( false ) ); + } else if ( 'test' == $_GET['mainwpdebug'] ) { + print_r( get_included_files() ); + } else { + print_r( $mainwpChild->getSiteStats( array(), false ) ); + } + + $stop = microtime( true ); + die( "\n\n\n" . 'duration: ' . ( $stop - $start ) . 's' ); + } +} diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 268f268..55bf006 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -2,30 +2,30 @@ class MainWP_Helper { - static function write( $val ) { + static function write( $val ) { if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) : - $output = self::safe_json_encode( $val ); + $output = self::safe_json_encode( $val ); else: $output = serialize( $val ); - endif; - + endif; + die( '' . base64_encode( $output ) . '' ); } - - public static function utf8ize($mixed) { + + public static function utf8ize( $mixed) { if (is_array($mixed)) { foreach ($mixed as $key => $value) { $mixed[$key] = self::utf8ize($value); } } elseif (is_string($mixed)) { if ( function_exists( 'mb_convert_encoding' )) { - return mb_convert_encoding($mixed, "UTF-8", "UTF-8"); + return mb_convert_encoding($mixed, 'UTF-8', 'UTF-8'); } } return $mixed; } - public static function safe_json_encode($value, $options = 0, $depth = 512) { + public static function safe_json_encode( $value, $options = 0, $depth = 512) { $encoded = @json_encode($value, $options, $depth); if ($encoded === false && $value && json_last_error() == JSON_ERROR_UTF8) { $encoded = @json_encode(self::utf8ize($value), $options, $depth); @@ -34,13 +34,13 @@ class MainWP_Helper { } static function close_connection( $val = null ) { - + if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) : - $output = self::safe_json_encode( $val ); + $output = self::safe_json_encode( $val ); else: $output = serialize( $val ); endif; - + $output = '' . base64_encode( $output ) . ''; // Close browser connection so that it can resume AJAX polling header( 'Content-Length: ' . strlen( $output ) ); @@ -60,7 +60,7 @@ class MainWP_Helper { $information['error'] = $error; if (null !== $code) $information['error_code'] = $code; - MainWP_Helper::write( $information ); + self::write( $information ); } /** @@ -69,26 +69,26 @@ class MainWP_Helper { * CSSPARSER * Copyright (C) 2009 Peter Kröner */ - public static function parse_css($css){ + public static function parse_css( $css) { // Remove CSS-Comments $css = preg_replace('/\/\*.*?\*\//ms', '', $css); // Remove HTML-Comments $css = preg_replace('/([^\'"]+?)(\ + + + From bd796ad04727e83b5daefd60930a702179adf97c Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 14:11:33 +0000 Subject: [PATCH 66/98] [CodeFactor] Apply fixes to commit 7e3b1f2 [ci skip] [skip ci] --- class/class-mainwp-backup.php | 6 +- class/class-mainwp-child-back-up-buddy.php | 179 +++---- .../class-mainwp-child-back-up-wordpress.php | 43 +- class/class-mainwp-child-back-wp-up.php | 43 +- class/class-mainwp-child-branding.php | 38 +- class/class-mainwp-child-ithemes-security.php | 73 +-- class/class-mainwp-child-links-checker.php | 25 +- class/class-mainwp-child-pagespeed.php | 8 +- class/class-mainwp-child-plugins-check.php | 2 +- .../class-mainwp-child-server-information.php | 70 +-- class/class-mainwp-child-skeleton-key.php | 17 +- class/class-mainwp-child-staging.php | 19 +- class/class-mainwp-child-themes-check.php | 9 +- class/class-mainwp-child-timecapsule.php | 72 +-- ...lass-mainwp-child-updraft-plus-backups.php | 141 +++--- ...ass-mainwp-child-vulnerability-checker.php | 7 +- .../class-mainwp-child-woocommerce-status.php | 56 +-- class/class-mainwp-child-wordfence.php | 126 ++--- class/class-mainwp-child-wp-rocket.php | 160 +++---- ...ass-mainwp-child-wpvivid-backuprestore.php | 5 +- class/class-mainwp-child.php | 435 ++++++++++-------- class/class-mainwp-clone-install.php | 26 +- class/class-mainwp-clone.php | 8 +- class/class-mainwp-custom-post-type.php | 4 +- class/class-mainwp-debug.php | 2 +- class/class-mainwp-helper.php | 102 ++-- class/class-mainwp-keyword-links.php | 18 +- class/class-mainwp-security.php | 9 +- class/class-mainwp-wordpress-seo.php | 4 +- class/class-tar-archiver.php | 42 +- mainwp-child.php | 4 +- 31 files changed, 960 insertions(+), 793 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index da1d5dd..41bcd46 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -158,7 +158,7 @@ class MainWP_Backup { public function _zipFilePcl( $files, $archive ) { //Zip this backup folder.. - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $archive ); $error = false; @@ -336,7 +336,7 @@ class MainWP_Backup { * @return bool */ public function createZipPclFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles ) { - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $filepath ); $nodes = glob( ABSPATH . '*' ); if ( ! $includeCoreFiles ) { @@ -531,7 +531,7 @@ class MainWP_Backup { unset( $nodes ); //Zip this backup folder.. - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $filepath ); $this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder ); if ( $addConfig ) { diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 6dd18af..dd1fbb1 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -105,8 +105,9 @@ class MainWP_Child_Back_Up_Buddy { } // ok function do_reports_log( $ext = '') { - if ($ext !== 'backupbuddy') + if ($ext !== 'backupbuddy') { return; + } if (!$this->is_backupbuddy_installed) { return; @@ -117,12 +118,14 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' )); if ( ! class_exists( 'backupbuddy_core' ) ) { - if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') ) - require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' ); + if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') ) { + require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; + } } - if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php')) - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php')) { + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; + } MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' )); MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory'); @@ -180,7 +183,7 @@ class MainWP_Child_Back_Up_Buddy { } if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) { - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; MainWP_Helper::check_classes_exists(array( 'backupbuddy_live_periodic' )); MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats'); @@ -217,7 +220,7 @@ class MainWP_Child_Back_Up_Buddy { } if ( ! class_exists( 'backupbuddy_core' ) ) { - require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; } if ( !isset( pb_backupbuddy::$options ) ) { @@ -692,8 +695,9 @@ class MainWP_Child_Back_Up_Buddy { function delete_profile() { $profile_id = $_POST['profile_id']; - if (isset(pb_backupbuddy::$options['profiles'][$profile_id])) + if (isset(pb_backupbuddy::$options['profiles'][$profile_id])) { unset(pb_backupbuddy::$options['profiles'][$profile_id]); + } pb_backupbuddy::save(); $information['result'] = 'SUCCESS'; @@ -764,8 +768,9 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) ); $plugin_path = pb_backupbuddy::plugin_path(); - if (file_exists($plugin_path . '/classes/core.php')) - require_once( $plugin_path . '/classes/core.php' ); + if (file_exists($plugin_path . '/classes/core.php')) { + require_once $plugin_path . '/classes/core.php'; + } } MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' )); @@ -810,7 +815,7 @@ class MainWP_Child_Back_Up_Buddy { } function backup_list() { - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $information = array(); $information['backup_list'] = $this->get_backup_list(); $information['recent_backup_list'] = $this->get_recent_backup_list(); @@ -825,7 +830,7 @@ class MainWP_Child_Back_Up_Buddy { function save_note() { if ( !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) { - require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' ); + require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); } $backup_file = $_POST['backup_file']; @@ -851,7 +856,7 @@ class MainWP_Child_Back_Up_Buddy { // Even if we cannot save the note into the archive file, store it in internal settings. $serial = backupbuddy_core::get_serial_from_file( $backup_file ); - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #24.' ); $backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' ); if ( true === ( $result = $backup_options->is_ok() ) ) { @@ -864,10 +869,11 @@ class MainWP_Child_Back_Up_Buddy { function get_hash() { $callback_data = $_POST['callback_data']; $file = backupbuddy_core::getBackupDirectory() . $callback_data; - if (file_exists($file)) + if (file_exists($file)) { return array( 'result' =>'SUCCESS', 'hash' => md5_file( $file ) ); - else + } else { return array( 'error' =>'Not found the file' ); + } } function zip_viewer() { @@ -883,7 +889,7 @@ class MainWP_Child_Back_Up_Buddy { $serial = $_POST[ 'serial' ]; $alerts = array(); // The fileoptions file that contains the file tree information - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt'; // Purge cache if too old. @@ -899,7 +905,7 @@ class MainWP_Child_Back_Up_Buddy { // Either we are getting cached file tree information or we need to create afresh if ( true !== ( $result = $fileoptions->is_ok() ) ) { // Get file listing. - require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' ); + require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( ABSPATH, array(), 'unzip' ); $files = pb_backupbuddy::$classes['zipbuddy']->get_file_list( backupbuddy_core::getBackupDirectory() . str_replace( '\\/', '', $zip_viewer ) ); $fileoptions->options = $files; @@ -1112,7 +1118,7 @@ class MainWP_Child_Back_Up_Buddy { $serial = backupbuddy_core::get_serial_from_file( $archive_file ); // serial of archive. $temp_file = uniqid(); // temp filename to extract into. - require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' ); + require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; $zipbuddy = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); // Calculate temp directory & lock it down. @@ -1186,7 +1192,7 @@ class MainWP_Child_Back_Up_Buddy { global $wp_version; pb_backupbuddy::status( 'details', 'BackupBuddy v' . pb_backupbuddy::settings( 'version' ) . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.' ); - require( pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php' ); + require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php'; ob_start(); $result = backupbuddy_restore_files::restore( backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH ); @@ -1229,7 +1235,7 @@ class MainWP_Child_Back_Up_Buddy { $options = array(); if ( file_exists( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' ) ) { - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #33.' ); $backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true ); // Will create file to hold integrity data if nothing exists. } else { @@ -1375,7 +1381,7 @@ class MainWP_Child_Back_Up_Buddy { foreach( $recentBackups_list as $backup_fileoptions ) { - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #1.' ); $backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true ); if ( true !== ( $result = $backup->is_ok() ) ) { @@ -1555,7 +1561,7 @@ class MainWP_Child_Back_Up_Buddy { $serial = str_replace( '/\\', '', $serial ); pb_backupbuddy::load(); - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #27.' ); $optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt'; $backup_options = new pb_backupbuddy_fileoptions( $optionsFile, $read_only = true ); @@ -1851,7 +1857,7 @@ class MainWP_Child_Back_Up_Buddy { return array('error' => 'Invalid Profile. Not found.'); } - require_once( pb_backupbuddy::plugin_path() . '/classes/backup.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ]; @@ -1874,7 +1880,7 @@ class MainWP_Child_Back_Up_Buddy { } function start_backup() { - require_once( pb_backupbuddy::plugin_path() . '/classes/backup.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $data = $_POST['data']; if (is_array($data) && isset($data['serial_override'])) { @@ -1968,7 +1974,7 @@ class MainWP_Child_Back_Up_Buddy { function remote_delete() { $destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : null; if ($destination_id !== null) { - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $delete_response = pb_backupbuddy_destinations::delete_destination( $destination_id, true ); if ( $delete_response !== true ) { @@ -2026,7 +2032,7 @@ class MainWP_Child_Back_Up_Buddy { // For Stash we will check the quota prior to initiating send. if ( pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash' ) { // Pass off to destination handler. - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info( 'stash' ); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ); @@ -2093,17 +2099,17 @@ class MainWP_Child_Back_Up_Buddy { if ( 'cleanup_now' == $other_action ) { $message = 'Performing cleanup procedures now trimming old files and data.'; - require_once( pb_backupbuddy::plugin_path() . '/classes/housekeeping.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/housekeeping.php'; backupbuddy_housekeeping::run_periodic( 0 ); // 0 cleans up everything even if not very old. - } else if ( 'delete_tempfiles_now' == $other_action) { + } elseif ( 'delete_tempfiles_now' == $other_action) { $tempDir = backupbuddy_core::getTempDirectory(); $logDir = backupbuddy_core::getLogDirectory(); $message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.'; pb_backupbuddy::$filesystem->unlink_recursive( $tempDir ); pb_backupbuddy::$filesystem->unlink_recursive( $logDir ); pb_backupbuddy::anti_directory_browsing( $logDir, $die = false ); // Put log dir back in place. - } else if ( 'reset_log' == $other_action ) { + } elseif ( 'reset_log' == $other_action ) { $log_file = backupbuddy_core::getLogDirectory() . 'log-' . pb_backupbuddy::$options['log_serial'] . '.txt'; if ( file_exists( $log_file ) ) { @unlink( $log_file ); @@ -2113,13 +2119,13 @@ class MainWP_Child_Back_Up_Buddy { } else { // Unlinked. $message = 'Cleared log file.'; } - } else if ( 'reset_disalerts' == $other_action) { + } elseif ( 'reset_disalerts' == $other_action) { pb_backupbuddy::$options['disalerts'] = array(); pb_backupbuddy::save(); $message = 'Dismissed alerts have been reset. They may now be visible again.'; - } else if ( 'cancel_running_backups' == $other_action) { - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + } elseif ( 'cancel_running_backups' == $other_action) { + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; $fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/'; $files = glob( $fileoptions_directory . '*.txt' ); @@ -2470,9 +2476,9 @@ class MainWP_Child_Back_Up_Buddy { $errors[] = 'You must enter your iThemes username & password to log in to BackupBuddy Stash Live.'; } else { // Username and password provided. - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/class.itx_helper2.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/class.itx_helper2.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php'; global $wp_version; $itxapi_username = strtolower( $_POST['live_username'] ); @@ -2566,9 +2572,9 @@ class MainWP_Child_Back_Up_Buddy { $data = $_POST['data']; $new_destination_id = $_POST['destination_id']; - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $destination_id = backupbuddy_live::getLiveID(); $destination_settings = isset(pb_backupbuddy::$options['remote_destinations'][$destination_id]) ? pb_backupbuddy::$options['remote_destinations'][$destination_id] : array(); @@ -2611,7 +2617,7 @@ class MainWP_Child_Back_Up_Buddy { unset( pb_backupbuddy::$options['remote_destinations'][ $liveDestinationID ] ); pb_backupbuddy::save(); // Clear cached Live credentials. - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php'; delete_transient( pb_backupbuddy_destination_live::LIVE_ACTION_TRANSIENT_NAME ); } else { $error = 'Error: destination not found.'; @@ -2621,8 +2627,9 @@ class MainWP_Child_Back_Up_Buddy { $error = 'Error: Empty destination id.'; } - if (!empty($error)) + if (!empty($error)) { $return['error'] = $error; + } return $return; } @@ -2631,7 +2638,7 @@ class MainWP_Child_Back_Up_Buddy { $action = $_POST['live_action']; $error = $message = ''; - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $state = backupbuddy_live_periodic::get_stats(); $destination_id = backupbuddy_live::getLiveID(); @@ -2646,20 +2653,20 @@ class MainWP_Child_Back_Up_Buddy { $message = 'Log file cleared.'; } - } else if ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime ) + } elseif ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime ) if ( true === backupbuddy_api::runLiveSnapshot() ) { //pb_backupbuddy::alert( '

    ' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '

    ' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '

    ', false, '', 'backupbuddy_live_snapshot_verify_uptodate' ); $message = '

    ' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '

    ' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '

    '; - require( pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php' ); + require pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php'; } - } else if ( 'pause_periodic' == $action ) { + } elseif ( 'pause_periodic' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true ); $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. //pb_backupbuddy::disalert( '', __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ); - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - } else if ( 'resume_periodic' == $action ) { + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + } elseif ( 'resume_periodic' == $action ) { $launchNowText = ' ' . __( 'Unpaused but not running now.', 'it-l10n-backupbuddy' ); $start_run = false; if ( '1' != pb_backupbuddy::_GET( 'skip_run_live_now' ) ) { @@ -2670,17 +2677,17 @@ class MainWP_Child_Back_Up_Buddy { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run ); //pb_backupbuddy::disalert( '', __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText ); $message = __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText; - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - } else if ( 'pause_continuous' == $action ) { + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + } elseif ( 'pause_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = true, $pause_periodic = '' ); $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. //pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ); - } else if ( 'resume_continuous' == $action ) { + } elseif ( 'resume_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = false, $pause_periodic = '' ); $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. //pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ); } else { @@ -2693,7 +2700,7 @@ class MainWP_Child_Back_Up_Buddy { function download_troubleshooting() { - require( pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php' ); + require pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php'; backupbuddy_live_troubleshooting::run(); $output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true ); $backup_prefix = backupbuddy_core::backup_prefix(); @@ -2703,12 +2710,12 @@ class MainWP_Child_Back_Up_Buddy { function get_live_backups() { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php'; $settings = &pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; $settings = pb_backupbuddy_destination_stash2::_formatSettings( $settings ); @@ -2778,7 +2785,7 @@ class MainWP_Child_Back_Up_Buddy { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } @@ -2801,7 +2808,7 @@ class MainWP_Child_Back_Up_Buddy { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } @@ -2856,7 +2863,7 @@ class MainWP_Child_Back_Up_Buddy { if ( $time_since_last_activity > ( $detected_execution + backupbuddy_constants::TIMED_OUT_PROCESS_RESUME_WIGGLE_ROOM ) ) { // Enough time has passed to assume timed out. - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; if ( false === ( $liveID = backupbuddy_live::getLiveID() ) ) { die( '-1' ); } @@ -2900,11 +2907,11 @@ class MainWP_Child_Back_Up_Buddy { $packages_name = array(); if (isset($GLOBALS['ithemes_updater_path'])) { - require_once( $GLOBALS['ithemes_updater_path'] . '/functions.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/api.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; - require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $details = Ithemes_Updater_Packages::get_full_details(); $packages = isset($details['packages']) ? $details['packages'] : array(); @@ -2927,11 +2934,11 @@ class MainWP_Child_Back_Up_Buddy { $return = array( 'ok' => 1 ); if (isset($GLOBALS['ithemes_updater_path'])) { - require_once( $GLOBALS['ithemes_updater_path'] . '/functions.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/api.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; - require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $response = Ithemes_Updater_API::activate_package( $username, $password, $packages ); @@ -2954,17 +2961,19 @@ class MainWP_Child_Back_Up_Buddy { $fail = array(); foreach ( $response['packages'] as $package => $data ) { - if ( preg_match( '/ \|\|\| \d+$/', $package ) ) + if ( preg_match( '/ \|\|\| \d+$/', $package ) ) { continue; + } $name = Ithemes_Updater_Functions::get_package_name( $package ); - if ( ! empty( $data['key'] ) ) + if ( ! empty( $data['key'] ) ) { $success[] = $name; - else if ( ! empty( $data['status'] ) && ( 'expired' == $data['status'] ) ) + } elseif ( ! empty( $data['status'] ) && ( 'expired' == $data['status'] ) ) { $warn[$name] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' ); - else + } else { $fail[$name] = $data['error']['message']; + } } if ( ! empty( $success ) ) { @@ -2973,14 +2982,16 @@ class MainWP_Child_Back_Up_Buddy { } if ( ! empty( $fail ) ) { - foreach ( $fail as $name => $reason ) + foreach ( $fail as $name => $reason ) { $errors[] = sprintf( __( 'Unable to license %1$s. Reason: %2$s', 'it-l10n-backupbuddy' ), $name, $reason ); + } $return['errors'] = $errors; } if ( ! empty( $warn ) ) { - foreach ( $warn as $name => $reason ) + foreach ( $warn as $name => $reason ) { $soft_errors[] = sprintf( __( 'Unable to license %1$s. Reason: %2$s', 'it-l10n-backupbuddy' ), $name, $reason ); + } $return['soft_errors'] = $soft_errors; } @@ -2998,11 +3009,11 @@ class MainWP_Child_Back_Up_Buddy { if (isset($GLOBALS['ithemes_updater_path'])) { - require_once( $GLOBALS['ithemes_updater_path'] . '/functions.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/api.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; - require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $response = Ithemes_Updater_API::deactivate_package($username, $password, $packages ); @@ -3024,17 +3035,19 @@ class MainWP_Child_Back_Up_Buddy { $fail = array(); foreach ( $response['packages'] as $package => $data ) { - if ( preg_match( '/ \|\|\| \d+$/', $package ) ) + if ( preg_match( '/ \|\|\| \d+$/', $package ) ) { continue; + } $name = Ithemes_Updater_Functions::get_package_name( $package ); - if ( isset( $data['status'] ) && ( 'inactive' == $data['status'] ) ) + if ( isset( $data['status'] ) && ( 'inactive' == $data['status'] ) ) { $success[] = $name; - else if ( isset( $data['error'] ) && isset( $data['error']['message'] ) ) + } elseif ( isset( $data['error'] ) && isset( $data['error']['message'] ) ) { $fail[$name] = $data['error']['message']; - else + } else { $fail[$name] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' ); + } } if ( ! empty( $success ) ) { @@ -3043,8 +3056,9 @@ class MainWP_Child_Back_Up_Buddy { } if ( ! empty( $fail ) ) { - foreach ( $fail as $name => $reason ) + foreach ( $fail as $name => $reason ) { $errors[] = sprintf( __( 'Unable to remove license from %1$s. Reason: %2$s', 'it-l10n-mainwp-backupbuddy' ), $name, $reason ); + } $return['errors'] = $errors; } @@ -3078,10 +3092,11 @@ class MainWP_Child_Back_Up_Buddy { } if ( empty( $message ) ) { - if ( ! empty( $package ) ) + if ( ! empty( $package ) ) { $message = sprintf( __( 'An unknown error relating to the %1$s product occurred. Please contact iThemes support. Error details: %2$s', 'it-l10n-mainwp-backupbuddy' ), $package_name, $error->get_error_message() . " ($code)" ); - else + } else { $message = sprintf( __( 'An unknown error occurred. Please contact iThemes support. Error details: %s', 'it-l10n-mainwp-backupbuddy' ), $error->get_error_message() . " ($code)" ); + } } return $message; diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index 7fb7860..df00422 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -29,7 +29,7 @@ class MainWP_Child_Back_Up_Wordpress { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) { $this->is_plugin_installed = true; if ( version_compare( phpversion(), '5.3', '>=' ) ) { @@ -43,7 +43,8 @@ class MainWP_Child_Back_Up_Wordpress { return; } - if (!$this->is_plugin_installed) return; + if (!$this->is_plugin_installed) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -201,8 +202,10 @@ class MainWP_Child_Back_Up_Wordpress { // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'backupwordpress' ) return; - if (!$this->is_plugin_installed) return; + if ( $ext !== 'backupwordpress' ) { return; + } + if (!$this->is_plugin_installed) { return; + } try { MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules'); @@ -314,14 +317,15 @@ class MainWP_Child_Back_Up_Wordpress { $schedule_id = $this->check_schedule(); if (function_exists('hmbkp_run_schedule_async')) { hmbkp_run_schedule_async($schedule_id); - } else if (function_exists('\HM\BackUpWordPress\run_schedule_async')) { + } elseif (function_exists('\HM\BackUpWordPress\run_schedule_async')) { HM\BackUpWordPress\Path::get_instance()->cleanup(); // Fixes an issue on servers which only allow a single session per client session_write_close(); $task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id ); $task->schedule(); - } else + } else { return array( 'error' => __('Error while trying to trigger the schedule', 'mainwp-child') ); + } return array( 'result' => 'SUCCESS' ); } @@ -392,10 +396,11 @@ class MainWP_Child_Back_Up_Wordpress { } } - if (function_exists('HM\BackUpWordPress\Backup::get_home_path')) + if (function_exists('HM\BackUpWordPress\Backup::get_home_path')) { $backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() ); - else + } else { $backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() ); + } $information['backups_path'] = $backups_path; $information['send_back_schedules'] = $send_back_schedules; @@ -533,7 +538,7 @@ class MainWP_Child_Back_Up_Wordpress { class="download-action"> | get_default_excludes() ) ) || ( HM\BackUpWordPress\Path::get_path() === trailingslashit( HM\BackUpWordPress\Path::get_root() ) . untrailingslashit( $exclude ) ); - else + } else { $is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ); + } if ( $is_default_rule ) : ?> @@ -676,8 +682,9 @@ class MainWP_Child_Back_Up_Wordpress { $exclude_string = implode( '|', $excludes->get_excludes_for_regex() ); - if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize')) + if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize')) { $files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes ); + } } else { $files = $schedule->list_directory_by_total_filesize( $directory ); @@ -1071,8 +1078,9 @@ class MainWP_Child_Back_Up_Wordpress { if (method_exists($excludes, 'get_user_excludes')) { $schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) ); - } else + } else { $schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) ); + } $schedule->save(); @@ -1103,8 +1111,9 @@ class MainWP_Child_Back_Up_Wordpress { $excl_rule = trim($excl_rule); $excl_rule = trim($excl_rule, '/'); - if (empty($excl_rule)) + if (empty($excl_rule)) { continue; + } $exclude_rule = ABSPATH . $excl_rule; $path = realpath($exclude_rule); @@ -1125,8 +1134,9 @@ class MainWP_Child_Back_Up_Wordpress { $exclude_rule_to_remove = trim($exclude_rule_to_remove); $exclude_rule_to_remove = trim($exclude_rule_to_remove, '/'); - if (empty($exclude_rule_to_remove)) + if (empty($exclude_rule_to_remove)) { continue; + } $excludes = $schedule->get_excludes(); if (method_exists($excludes, 'get_user_excludes')) { @@ -1210,8 +1220,9 @@ class MainWP_Child_Back_Up_Wordpress { $out = array(); foreach($schedules as $sch_id => $sch) { - if ( empty($sch_id) || !isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) + if ( empty($sch_id) || !isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) { continue; + } $options = $sch['options']; $filter_opts = array( 'type', diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 1a93178..647b423 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -66,7 +66,7 @@ class MainWP_Child_Back_WP_Up { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; try { @@ -80,14 +80,14 @@ class MainWP_Child_Back_WP_Up { } MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 )); - require_once( $file_path1 ); - require_once( $file_path2 ); + require_once $file_path1; + require_once $file_path2; $this->is_backwpup_installed = true; $this->is_backwpup_pro = true; - } else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) { + } elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) { $file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php'; MainWP_Helper::check_files_exists(array( $file_path )); - require_once( $file_path ); + require_once $file_path; $this->is_backwpup_installed = true; } @@ -119,7 +119,7 @@ class MainWP_Child_Back_WP_Up { $info = self::$information; if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); - } else if ( ! empty( $info ) ) { + } elseif ( ! empty( $info ) ) { MainWP_Helper::write( self::$information ); } else { MainWP_Helper::write( array( 'error' => 'Missing information array inside fatal_error' ) ); @@ -218,8 +218,9 @@ class MainWP_Child_Back_WP_Up { public function init() { - if (!$this->is_backwpup_installed) + if (!$this->is_backwpup_installed) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -238,9 +239,11 @@ class MainWP_Child_Back_WP_Up { } // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'backwpup' ) return; - if (!$this->is_backwpup_installed) + if ( $ext !== 'backwpup' ) { return; + } + if (!$this->is_backwpup_installed) { return; + } try { @@ -269,8 +272,9 @@ class MainWP_Child_Back_WP_Up { $log_items = array(); foreach ( $logfiles as $mtime => $logfile ) { $meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile ); - if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged) + if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged) { continue; + } if (isset($meta['errors']) && !empty($meta['errors'])) { continue; // do not logging backups have errors @@ -313,8 +317,9 @@ class MainWP_Child_Back_WP_Up { $message = 'BackWPup backup finished (' . $backup_type . ')'; do_action( 'mainwp_reports_backwpup_backup', $message, $backup_type, $backup_time ); - if ($new_lasttime_logged < $backup_time) + if ($new_lasttime_logged < $backup_time) { $new_lasttime_logged = $backup_time; + } } if ($new_lasttime_logged > $lasttime_logged ) { @@ -744,7 +749,7 @@ class MainWP_Child_Back_WP_Up { $temp_array['website_id'] = $website_id; $array[] = $temp_array; } - } else if ( $type == 'backups' ) { + } elseif ( $type == 'backups' ) { $without_dupes = array(); foreach ( $output->items as $key ) { $temp_array = $key; @@ -973,7 +978,7 @@ class MainWP_Child_Back_WP_Up { } if ( ! class_exists( 'WP_List_Table' ) ) { - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; } } @@ -1136,9 +1141,9 @@ class MainWP_Child_Back_WP_Up { if ( $dir = @opendir( $main_folder_name ) ) { while ( ( $file = readdir( $dir ) ) !== false ) { if ( ! in_array( $file, array( - '.', - '..', - ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) + '.', + '..', + ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) { $folder_size = ' (' . size_format( BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')'; @@ -1394,7 +1399,7 @@ class MainWP_Child_Back_WP_Up { $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); BackWPup_Admin::message( sprintf( __( 'Changes for job %s saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' ' . __( 'Jobs overview', 'backwpup' ) . ' | ' . __( 'Run now', 'backwpup' ) . '' ); } - } else if ($settings['tab'] == 'dest-DROPBOX') { + } elseif ($settings['tab'] == 'dest-DROPBOX') { unset($settings['value']); // do not save dropbox settings BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); } else { @@ -1436,7 +1441,7 @@ class MainWP_Child_Back_WP_Up { if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) { $changes_array[ $key ] = $temp_value; } - } else if ( strcmp( $temp_value, $val ) != 0 ) { + } elseif ( strcmp( $temp_value, $val ) != 0 ) { $changes_array[ $key ] = $temp_value; } } @@ -1518,7 +1523,7 @@ class MainWP_Child_Back_WP_Up { if ( isset( $message['error'] ) ) { return array( 'error' => implode( ', ', $message['error'] ) ); - } else if ( isset( $message['updated'] ) ) { + } elseif ( isset( $message['updated'] ) ) { return array( 'message' => $message['updated'] ); } else { return array( 'error' => 'Generic error' ); diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 9e007f9..c03d54d 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -66,8 +66,9 @@ class MainWP_Child_Branding { $extra = array(); if (is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings'])) { $extra = $this->child_branding_options['extra_settings']; - if (!is_array($extra)) + if (!is_array($extra)) { $extra = array(); + } } return $extra; @@ -279,7 +280,7 @@ class MainWP_Child_Branding { $information['error']['login_image'] = $e->getMessage(); } } - } else if ( isset( $current_extra_setting['login_image'] ) ) { + } elseif ( isset( $current_extra_setting['login_image'] ) ) { $extra_setting['login_image'] = $current_extra_setting['login_image']; } @@ -302,7 +303,7 @@ class MainWP_Child_Branding { $information['error']['favico_image'] = $e->getMessage(); } } - } else if ( isset( $current_extra_setting['favico_image'] ) ) { + } elseif ( isset( $current_extra_setting['favico_image'] ) ) { $extra_setting['favico_image'] = $current_extra_setting['favico_image']; } @@ -347,7 +348,7 @@ class MainWP_Child_Branding { } static function uploadImage( $img_url ) { - include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url + include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url global $mainWPChild; add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 ); //Download $img_url @@ -382,7 +383,7 @@ class MainWP_Child_Branding { if (is_admin()) { // back end add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) ); - } else if (is_user_logged_in()) { + } elseif (is_user_logged_in()) { // front end add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' )); } @@ -474,7 +475,7 @@ class MainWP_Child_Branding { function admin_menu() { $allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false); if ( $allow_contact ) {; // ok - } else if ( !current_user_can( 'administrator' ) ) { + } elseif ( !current_user_can( 'administrator' ) ) { return false; } @@ -805,8 +806,9 @@ class MainWP_Child_Branding { if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) { global $current_user; $headers .= "Content-Type: text/html;charset=utf-8\r\n"; - if (!empty($from)) + if (!empty($from)) { $headers .= 'From: "' . $from . '" <' . $from . ">\r\n"; + } $mail .= "

    Support Email from: " . site_url() . "

    \r\n\r\n"; $mail .= '

    Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "

    \r\n\r\n" : '' ); $mail .= '

    Client Email: ' . $current_user->user_email . "

    \r\n\r\n"; @@ -892,12 +894,12 @@ class MainWP_Child_Branding { 'mainwp_branding_contact_message_content', - 'textarea_rows' => 10, - 'teeny' => true, - 'wpautop' => true, - 'media_buttons' => false, - ) + 'textarea_name' => 'mainwp_branding_contact_message_content', + 'textarea_rows' => 10, + 'teeny' => true, + 'wpautop' => true, + 'media_buttons' => false, + ) ); ?>
    @@ -925,7 +927,7 @@ class MainWP_Child_Branding { public function add_support_button_in_top_admin_bar( $wp_admin_bar ) { $allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false); if ( $allow_contact ) {; // ok - } else if ( !current_user_can( 'administrator' ) ) { + } elseif ( !current_user_can( 'administrator' ) ) { return false; } @@ -995,15 +997,16 @@ class MainWP_Child_Branding { $hide_slugs = apply_filters('mainwp_child_hide_update_notice', array()); - if (!is_array($hide_slugs)) + if (!is_array($hide_slugs)) { $hide_slugs = array(); + } if (count($hide_slugs) == 0) { return; } if (!function_exists('get_plugin_updates')) { - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; } $count_hide = 0; @@ -1047,8 +1050,9 @@ class MainWP_Child_Branding { $hide_slugs = apply_filters('mainwp_child_hide_update_notice', array()); - if (!is_array($hide_slugs)) + if (!is_array($hide_slugs)) { $hide_slugs = array(); + } $count_hide = 0; diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index 73d9df8..0e292f1 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -28,13 +28,14 @@ class MainWP_Child_iThemes_Security { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } @@ -130,8 +131,9 @@ class MainWP_Child_iThemes_Security { } public function ithemes_init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); @@ -177,7 +179,7 @@ class MainWP_Child_iThemes_Security { function save_settings() { if ( ! class_exists( 'ITSEC_Lib' ) ) { - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $_itsec_modules = array( @@ -214,7 +216,7 @@ class MainWP_Child_iThemes_Security { if (in_array($module, $_itsec_modules)) { if ($module == 'wordpress-salts') { $settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update - } else if ($module == 'global') { + } elseif ($module == 'global') { $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' ); foreach($keep_olds as $key) { $settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update @@ -230,7 +232,7 @@ class MainWP_Child_iThemes_Security { } } - } else if ($module == 'backup') { + } elseif ($module == 'backup') { if (!isset($settings['location']) || empty($settings['location']) ) { $settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); } else { @@ -244,7 +246,7 @@ class MainWP_Child_iThemes_Security { $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' ); } - } else if ($module == 'hide-backend') { + } elseif ($module == 'hide-backend') { if (isset($settings['enabled']) && !empty($settings['enabled'])) { $permalink_structure = get_option( 'permalink_structure', false ); if ( empty( $permalink_structure ) && ! is_multisite() ) { @@ -253,7 +255,7 @@ class MainWP_Child_iThemes_Security { $do_not_save = true; } } - } else if ($module == 'network-brute-force') { + } elseif ($module == 'network-brute-force') { if ( isset( $settings['email'] ) ) { $result = $this->activate_api_key($settings); @@ -275,7 +277,7 @@ class MainWP_Child_iThemes_Security { } } $settings = $nbf_settings; - } else if ($module == 'notification-center') { + } elseif ($module == 'notification-center') { $current_settings = ITSEC_Modules::get_settings( $module ); if (isset($settings['notifications'])) { $update_fields = array( 'schedule', 'enabled', 'subject'); @@ -310,7 +312,7 @@ class MainWP_Child_iThemes_Security { update_site_option( 'itsec_active_modules', $current_val ); } - require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); + require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $values = array( 'permalink_structure' => get_option( 'permalink_structure' ), @@ -344,10 +346,11 @@ class MainWP_Child_iThemes_Security { $return['extra_message'] = $errors; } - if ($updated) + if ($updated) { $return['result'] = 'success'; - else + } else { $return['error'] = __('Not Updated', 'mainwp-child' ); + } return $return; } @@ -363,7 +366,7 @@ class MainWP_Child_iThemes_Security { $results = ITSEC_Modules::set_settings( 'network-brute-force', $settings ); if ( is_wp_error( $results ) ) { $information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key'; - } else if ( $results['saved'] ) { + } elseif ( $results['saved'] ) { ITSEC_Modules::activate( 'network-brute-force' ); $nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' ); // ITSEC_Response::set_response( '

    ' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '

    ' ); @@ -377,7 +380,7 @@ class MainWP_Child_iThemes_Security { } private function validate_directory( $name, $folder) { - require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' ); + require_once ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php'; $error = null; if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) { $result = ITSEC_Lib_Directory::create( $folder ); @@ -401,7 +404,7 @@ class MainWP_Child_iThemes_Security { private function activate_api_key( $settings) { global $mainwp_itsec_modules_path; - require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' ); + require_once $mainwp_itsec_modules_path . 'ipcheck/utilities.php'; $key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] ); if ( is_wp_error( $key ) ) { @@ -495,7 +498,7 @@ class MainWP_Child_iThemes_Security { global $itsec_backup, $mainwp_itsec_modules_path; if ( ! isset( $itsec_backup ) ) { - require_once ( $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php' ); + require_once $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php'; $itsec_backup = new ITSEC_Backup(); $itsec_backup->run(); } @@ -511,7 +514,7 @@ class MainWP_Child_iThemes_Security { foreach ( $errors as $error ) { $str_error .= $error . '
    '; } - } else if ( is_string( $result ) ) { + } elseif ( is_string( $result ) ) { $return['result'] = 'success'; $return['message'] = $result; } else { @@ -529,7 +532,7 @@ class MainWP_Child_iThemes_Security { private function wordpress_salts() { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) { - require( $mainwp_itsec_modules_path . 'salts/utilities.php' ); + require $mainwp_itsec_modules_path . 'salts/utilities.php'; } $result = ITSEC_WordPress_Salts_Utilities::generate_new_salts(); $str_error = ''; @@ -552,7 +555,7 @@ class MainWP_Child_iThemes_Security { } private function file_permissions() { - require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); + require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $wp_upload_dir = ITSEC_Core::get_wp_upload_dir(); @@ -673,7 +676,7 @@ class MainWP_Child_iThemes_Security { public function file_change() { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'file-change/scanner.php' ); + require_once $mainwp_itsec_modules_path . 'file-change/scanner.php'; } $result = ITSEC_File_Change_Scanner::run_scan( false ); if ($result === false || $result === true || $result === -1) { @@ -687,8 +690,9 @@ class MainWP_Child_iThemes_Security { $settings = $_POST['settings']; - if (!is_array($settings)) + if (!is_array($settings)) { $settings = array(); + } $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; @@ -696,7 +700,7 @@ class MainWP_Child_iThemes_Security { //load utility functions if ( ! class_exists( 'ITSEC_Lib' ) ) { global $itsec_globals; - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $username_exists = username_exists( 'admin' ); @@ -706,7 +710,7 @@ class MainWP_Child_iThemes_Security { global $current_user; if ( ! $username_exists ) { $msg = __( 'Admin user already changes.', 'mainwp-child' ); - } else if ($current_user->user_login == 'admin') { + } elseif ($current_user->user_login == 'admin') { $return['result'] = 'CHILD_ADMIN'; return $return; } @@ -871,7 +875,7 @@ class MainWP_Child_iThemes_Security { public function change_database_prefix() { global $mainwp_itsec_modules_path; - require_once( $mainwp_itsec_modules_path . 'database-prefix/utility.php' ); + require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php'; $str_error = ''; $return = array(); @@ -929,7 +933,7 @@ class MainWP_Child_iThemes_Security { if ( $results['saved'] ) { $information['result'] = 'success'; $information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force'); - } else if ( empty( $results['errors'] ) ) { + } elseif ( empty( $results['errors'] ) ) { $information['error_reset_api'] = 1; } return $information; @@ -939,8 +943,8 @@ class MainWP_Child_iThemes_Security { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' ); - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' ); + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php'; + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php'; } $response = array(); @@ -958,8 +962,8 @@ class MainWP_Child_iThemes_Security { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' ); - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' ); + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php'; + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php'; } $response = array(); $results= ITSEC_Malware_Scanner::scan(); @@ -1061,7 +1065,7 @@ class MainWP_Child_iThemes_Security { global $wpdb; if ( ! class_exists( 'ITSEC_Lib' ) ) { - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $lockout_ids = $_POST['lockout_ids']; @@ -1088,7 +1092,7 @@ class MainWP_Child_iThemes_Security { if ( ! is_multisite() ) { if ( ! function_exists( 'add_settings_error' ) ) { - require_once( ABSPATH . '/wp-admin/includes/template.php' ); + require_once ABSPATH . '/wp-admin/includes/template.php'; } add_settings_error( 'itsec', esc_attr( 'settings_updated' ), $message, $type ); @@ -1103,8 +1107,9 @@ class MainWP_Child_iThemes_Security { $active_modules = $_POST['active_modules']; - if (!is_array($active_modules)) + if (!is_array($active_modules)) { $active_modules = array(); + } $current_val = get_site_option( 'itsec_active_modules', array() ); foreach ($active_modules as $mod => $val) { @@ -1164,8 +1169,8 @@ class MainWP_Child_iThemes_Security { private function security_site() { global $mainwp_itsec_modules_path; - require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' ); - require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' ); + require_once $mainwp_itsec_modules_path . 'security-check/scanner.php'; + require_once $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php'; $results = ITSEC_Security_Check_Scanner::get_results(); ob_start(); ITSEC_Security_Check_Feedback_Renderer::render( $results ); diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index 7b8cfe5..e8c45b3 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -27,13 +27,14 @@ class MainWP_Child_Links_Checker { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) { $this->is_plugin_installed = true; } - if ( !$this->is_plugin_installed ) + if ( !$this->is_plugin_installed ) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } @@ -222,14 +223,16 @@ class MainWP_Child_Links_Checker { function get_sync_data( $strategy = '' ) { $information = array(); $data = $this->get_count_links(); - if (is_array($data)) + if (is_array($data)) { $information['data'] = $data; + } return $information; } function get_links_data() { - if (!defined('BLC_DIRECTORY')) return; + if (!defined('BLC_DIRECTORY')) { return; + } $file_path1 = BLC_DIRECTORY . '/includes/link-query.php'; $file_path2 = BLC_DIRECTORY . '/includes/modules.php'; @@ -251,9 +254,9 @@ class MainWP_Child_Links_Checker { $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $params = array( - array( 'load_instances' => true ), - 'max_results' => $max_results, - ); + array( 'load_instances' => true ), + 'max_results' => $max_results, + ); if (empty($offset)) { $first_sync = true; @@ -288,7 +291,8 @@ class MainWP_Child_Links_Checker { } function get_count_links() { - if (!defined('BLC_DIRECTORY')) return; + if (!defined('BLC_DIRECTORY')) { return; + } $file_path1 = BLC_DIRECTORY . '/includes/link-query.php'; $file_path2 = BLC_DIRECTORY . '/includes/modules.php'; @@ -638,7 +642,7 @@ class MainWP_Child_Links_Checker { function ui_get_source( $container, $container_field = '' ) { if ( 'comment' === $container->container_type ) { return $this->ui_get_source_comment( $container, $container_field ); - } else if ( $container instanceof blcAnyPostContainer ) { + } elseif ( $container instanceof blcAnyPostContainer ) { return $this->ui_get_source_post( $container, $container_field ); } @@ -653,8 +657,9 @@ class MainWP_Child_Links_Checker { $image = 'font-awesome/font-awesome-comment-alt.png'; } - if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true )) + if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true )) { return false; + } $comment = $container->get_wrapped_object(); diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index b104672..466a169 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -29,13 +29,14 @@ class MainWP_Child_Pagespeed { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); @@ -75,8 +76,9 @@ class MainWP_Child_Pagespeed { } public function init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'hide_plugin' ) ); diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php index 24fa93c..3efb52a 100644 --- a/class/class-mainwp-child-plugins-check.php +++ b/class/class-mainwp-child-plugins-check.php @@ -279,7 +279,7 @@ class MainWP_Child_Plugins_Check { //Some of this code is lifted from class-wp-upgrader //Get the WordPress current version to be polite in the API call - include( ABSPATH . WPINC . '/version.php' ); + include ABSPATH . WPINC . '/version.php'; global $wp_version; diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index 64fd86f..7127ff7 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -19,10 +19,11 @@ class MainWP_Child_Server_Information { } if ( $_POST['what'] == 'warning' ) { - if (isset($_POST['warnings'])) + if (isset($_POST['warnings'])) { $warnings = intval($_POST['warnings']); - else + } else { $warnings = self::getWarnings(); + } $dismissWarnings['warnings'] = $warnings; } MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings ); @@ -826,7 +827,7 @@ class MainWP_Child_Server_Information { if ( $isBranding ) { if ( $slug == 'mainwp-child/mainwp-child.php' ) { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ); - } else if ($slug == 'mainwp-child-reports/mainwp-child-reports.php') { + } elseif ($slug == 'mainwp-child-reports/mainwp-child-reports.php') { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports'; } } @@ -905,7 +906,7 @@ class MainWP_Child_Server_Information { } protected static function getMainwpVersion() { - include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' ); + include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; $api = plugins_api( 'plugin_information', array( 'slug' => 'mainwp-child', 'fields' => array( 'sections' => false ), @@ -966,8 +967,9 @@ class MainWP_Child_Server_Information { protected static function checkDirectoryMainWPDirectory( $write = true ) { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') + if ($branding_title == '') { $branding_title = 'MainWP'; + } $branding_title .= ' Upload Directory'; @@ -1052,9 +1054,9 @@ class MainWP_Child_Server_Information { Pass' : self::getWarningHTML( $errorType ) ); ?> - + Pass' : self::getWarningHTML( $errorType ) ); ?> - + Pass'; ?> Pass' : self::getWarningHTML( $errorType )); ?> @@ -1349,8 +1351,9 @@ class MainWP_Child_Server_Information { } if ( empty( $test_result ) ) { _e( 'Response Test O.K.', 'mainwp-child' ); - } else + } else { echo $test_result; + } } @@ -1624,42 +1627,43 @@ class MainWP_Child_Server_Information { public static function renderConnectionDetails() { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') + if ($branding_title == '') { $branding_title = 'MainWP'; + } global $current_user; $uniqueId = get_option('mainwp_child_uniqueId'); $details = array( 'siteurl' => array( - 'title' => __('Site URL', 'mainwp-child'), - 'value' => get_bloginfo( 'url' ), - 'desc' => get_bloginfo( 'url' ), - ), + 'title' => __('Site URL', 'mainwp-child'), + 'value' => get_bloginfo( 'url' ), + 'desc' => get_bloginfo( 'url' ), + ), 'adminuser' => array( - 'title' => __('Administrator name', 'mainwp-child'), - 'value' => $current_user->user_login, - 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), - ), + 'title' => __('Administrator name', 'mainwp-child'), + 'value' => $current_user->user_login, + 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), + ), 'friendly_name' => array( - 'title' => __('Friendly site name', 'mainwp-child'), - 'value' => get_bloginfo( 'name' ), - 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), - ), + 'title' => __('Friendly site name', 'mainwp-child'), + 'value' => get_bloginfo( 'name' ), + 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), + ), 'uniqueid' => array( - 'title' => __('Child unique security id', 'mainwp-child'), - 'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), - 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), - ), + 'title' => __('Child unique security id', 'mainwp-child'), + 'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), + 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), + ), 'verify_ssl' => array( - 'title' => __('Verify certificate', 'mainwp-child'), - 'value' => __('Yes', 'mainwp-child'), - 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), - ), + 'title' => __('Verify certificate', 'mainwp-child'), + 'value' => __('Yes', 'mainwp-child'), + 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), + ), 'ssl_version' => array( - 'title' => __('SSL version', 'mainwp-child'), - 'value' => __('Auto Detect', 'mainwp-child'), - 'desc' => __('Auto Detect', 'mainwp-child'), - ), + 'title' => __('SSL version', 'mainwp-child'), + 'value' => __('Auto Detect', 'mainwp-child'), + 'desc' => __('Auto Detect', 'mainwp-child'), + ), ); ?> diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php index ae64d7c..3398b44 100644 --- a/class/class-mainwp-child-skeleton-key.php +++ b/class/class-mainwp-child-skeleton-key.php @@ -189,18 +189,21 @@ class MainWP_Child_Skeleton_Key { public function save_settings() { $settings = isset($_POST['settings']) ? $_POST['settings'] : array(); - if (!is_array($settings) || empty($settings)) + if (!is_array($settings) || empty($settings)) { return array('error' => 'Invalid data. Please check and try again.'); + } $whitelist_options = array( 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ), ); if ( !is_multisite() ) { - if ( !defined( 'WP_SITEURL' ) ) + if ( !defined( 'WP_SITEURL' ) ) { $whitelist_options['general'][] = 'siteurl'; - if ( !defined( 'WP_HOME' ) ) + } + if ( !defined( 'WP_HOME' ) ) { $whitelist_options['general'][] = 'home'; + } $whitelist_options['general'][] = 'admin_email'; $whitelist_options['general'][] = 'users_can_register'; @@ -212,7 +215,7 @@ class MainWP_Child_Skeleton_Key { // Handle translation install. if ( ! empty( $settings['WPLANG'] ) ) { - require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); + require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if ( wp_can_install_language_pack() ) { $language = wp_download_language_pack( $settings['WPLANG'] ); if ( $language ) { @@ -224,16 +227,18 @@ class MainWP_Child_Skeleton_Key { $updated = false; foreach($settings as $option => $value) { if (in_array($option, $whitelist_general)) { - if ( ! is_array( $value ) ) + if ( ! is_array( $value ) ) { $value = trim( $value ); + } $value = wp_unslash( $value ); update_option($option, $value); $updated = true; } } - if (!$updated) + if (!$updated) { return false; + } return array('result' => 'ok'); } diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index 477a668..17516c2 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -29,26 +29,29 @@ class MainWP_Child_Staging { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR')) { $this->is_plugin_installed = true; - } else if ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) { + } elseif ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } public function init() { - if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) + if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) { return; + } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); @@ -299,9 +302,9 @@ class MainWP_Child_Staging { $delete->setData(); $clone = $delete->getClone(); $result = array( - 'clone' => $clone, - 'deleteTables' => $delete->getTables(), - ); + 'clone' => $clone, + 'deleteTables' => $delete->getTables(), + ); return $result; } diff --git a/class/class-mainwp-child-themes-check.php b/class/class-mainwp-child-themes-check.php index a46a984..acf9807 100644 --- a/class/class-mainwp-child-themes-check.php +++ b/class/class-mainwp-child-themes-check.php @@ -125,7 +125,7 @@ class MainWP_Child_Themes_Check { $themes_outdate = array(); } if ( ! function_exists( 'wp_get_themes' ) ) { - require_once( ABSPATH . '/wp-admin/includes/theme.php' ); + require_once ABSPATH . '/wp-admin/includes/theme.php'; } $themes = wp_get_themes(); $update = false; @@ -144,7 +144,7 @@ class MainWP_Child_Themes_Check { public function run_check() { if ( ! function_exists( 'wp_get_themes' ) ) { - require_once( ABSPATH . '/wp-admin/includes/theme.php' ); + require_once ABSPATH . '/wp-admin/includes/theme.php'; } //Get our previous results @@ -177,7 +177,8 @@ class MainWP_Child_Themes_Check { $tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); foreach ( $themes_to_scan as $slug => $v ) { - if ( in_array( $slug, $avoid_themes ) ) continue; + if ( in_array( $slug, $avoid_themes ) ) { continue; + } $body = $this->try_get_response_body( $slug, false ); @@ -226,7 +227,7 @@ class MainWP_Child_Themes_Check { private function try_get_response_body( $theme ) { //Get the WordPress current version to be polite in the API call - include( ABSPATH . WPINC . '/version.php' ); + include ABSPATH . WPINC . '/version.php'; $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index a2ad5cb..7dfcc73 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -26,24 +26,27 @@ class MainWP_Child_Timecapsule { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) && defined('WPTC_CLASSES_DIR')) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } public function init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } - if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) + if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -240,8 +243,9 @@ class MainWP_Child_Timecapsule { public function syncOthersData( $information, $data = array() ) { if ( isset( $data['syncWPTimeCapsule'] ) && $data['syncWPTimeCapsule'] ) { $information['syncWPTimeCapsule'] = $this->get_sync_data(); - if (get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y') + if (get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y') { MainWP_Helper::update_option( 'mainwp_time_capsule_ext_enabled', 'Y', 'yes' ); + } } return $information; } @@ -276,13 +280,13 @@ class MainWP_Child_Timecapsule { } $return = array( - 'main_account_email' => $main_account_email_var, - 'signed_in_repos' => $wptc_settings->get_connected_cloud_info(), - 'plan_name' => $options_helper->get_plan_interval_from_subs_info(), - 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), - 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, - 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), - 'backups_count' => $backups_count, + 'main_account_email' => $main_account_email_var, + 'signed_in_repos' => $wptc_settings->get_connected_cloud_info(), + 'plan_name' => $options_helper->get_plan_interval_from_subs_info(), + 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), + 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, + 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), + 'backups_count' => $backups_count, ); return $return; } catch ( Exception $e) { @@ -418,7 +422,7 @@ function start_restore_tc_callback_wptc() { $request = $_POST['data']; } - include_once ( WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php' ); + include_once WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php'; new WPTC_Prepare_Restore_Bridge($request); } @@ -508,7 +512,7 @@ function get_sibling_files_callback_wptc() { return array( 'items' => $wpdb->get_results($query), 'totalitems' => $totalitems, 'perpage' => $perpage, - ); + ); } @@ -556,8 +560,9 @@ function get_sibling_files_callback_wptc() { function get_display_rows( $records) { global $wpdb; //Get the records registered in the prepare_items method - if (!is_array($records)) + if (!is_array($records)) { return ''; + } $i=0; $limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit'); @@ -603,10 +608,10 @@ function get_sibling_files_callback_wptc() { if (!(strpos($rec->type, 'backup') === false)) { //Backup process $msg = 'Backup Process'; - } else if (!(strpos($rec->type, 'restore') === false)) { + } elseif (!(strpos($rec->type, 'restore') === false)) { //Restore Process $msg = 'Restore Process'; - } else if (!(strpos($rec->type, 'staging') === false)) { + } elseif (!(strpos($rec->type, 'staging') === false)) { //Restore Process $msg = 'Staging Process'; } else { @@ -703,10 +708,12 @@ function get_sibling_files_callback_wptc() { // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'wptimecapsule' ) return; + if ( $ext !== 'wptimecapsule' ) { return; + } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } try { MainWP_Helper::check_classes_exists(array( 'WPTC_Factory')); @@ -723,8 +730,9 @@ function get_sibling_files_callback_wptc() { $last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago $lasttime_logged = MainWP_Helper::get_lasttime_backup('wptimecapsule'); - if (empty($lasttime_logged)) + if (empty($lasttime_logged)) { $last_time = time() - 24 * 7 * 8 * 60 * 60; // 8 weeks ago + } $all_last_backups = $this->getBackups( $last_time ); @@ -977,8 +985,9 @@ function get_sibling_files_callback_wptc() { $config->set_option('schedule_time_str', $data['schedule_time_str']); if(!empty($data['schedule_time_str']) && !empty($data['wptc_timezone']) ){ - if (function_exists('wptc_modify_schedule_backup')) + if (function_exists('wptc_modify_schedule_backup')) { wptc_modify_schedule_backup(); + } } $notice = apply_filters('check_requirements_auto_backup_wptc', ''); @@ -989,7 +998,7 @@ function get_sibling_files_callback_wptc() { $saved = true; - } else if ( $tabName == 'backup_auto' ) { // update_auto_update_settings() + } elseif ( $tabName == 'backup_auto' ) { // update_auto_update_settings() $config->set_option('backup_before_update_setting', $data['backup_before_update_setting']); @@ -1006,20 +1015,22 @@ function get_sibling_files_callback_wptc() { $current['update_settings']['plugins']['status'] = $new['update_settings']['plugins']['status']; if (!$is_general) { - if (isset($new['update_settings']['plugins']['included'])) + if (isset($new['update_settings']['plugins']['included'])) { $current['update_settings']['plugins']['included'] = $new['update_settings']['plugins']['included']; - else + } else { $current['update_settings']['plugins']['included'] = array(); + } - if (isset($new['update_settings']['themes']['included'])) + if (isset($new['update_settings']['themes']['included'])) { $current['update_settings']['themes']['included'] = $new['update_settings']['themes']['included']; - else + } else { $current['update_settings']['themes']['included'] = array(); + } } $config->set_option('wptc_auto_update_settings', serialize($current)); $saved = true; - } else if ( $tabName == 'vulns_update' ) { + } elseif ( $tabName == 'vulns_update' ) { $current = $config->get_option('vulns_settings'); $current = unserialize($current); $new = unserialize($data['vulns_settings']); @@ -1062,7 +1073,7 @@ function get_sibling_files_callback_wptc() { $saved = true; - } else if ( $tabName == 'staging_opts' ) { + } elseif ( $tabName == 'staging_opts' ) { $config->set_option('user_excluded_extenstions_staging', $data['user_excluded_extenstions_staging']); $config->set_option('internal_staging_db_rows_copy_limit', $data['internal_staging_db_rows_copy_limit']); $config->set_option('internal_staging_file_copy_limit', $data['internal_staging_file_copy_limit']); @@ -1169,10 +1180,11 @@ function get_sibling_files_callback_wptc() { echo '' . __( 'Current PHP user', 'wp-time-capsule' ) . '' . esc_html( $php_user ) . ''; echo '' . __( 'Maximum execution time', 'wp-time-capsule' ) . '' . esc_html( ini_get( 'max_execution_time' ) ) . ' ' . __( 'seconds', 'wp-time-capsule' ) . ''; - if ( defined( 'FS_CHMOD_DIR' ) ) + if ( defined( 'FS_CHMOD_DIR' ) ) { echo '' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '' . esc_html( FS_CHMOD_DIR ) . ''; - else + } else { echo '' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '0755'; + } $now = localtime( time(), true ); echo '' . __( 'Server Time', 'wp-time-capsule' ) . '' . esc_html( $now[ 'tm_hour' ] . ':' . $now[ 'tm_min' ] ) . ''; diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 0a94e76..d594af4 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -27,21 +27,23 @@ class MainWP_Child_Updraft_Plus_Backups { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' )); } public static function hookUpdraftplusSaveLastBackup( $last_backup) { - if (!is_array($last_backup)) + if (!is_array($last_backup)) { return $last_backup; + } if (isset($last_backup['backup_time'])) { $backup_time = $last_backup['backup_time']; @@ -242,8 +244,9 @@ class MainWP_Child_Updraft_Plus_Backups { private function do_vault_connect() { $vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' ); - if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) + if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) { return array( 'connected' => true, 'html' => $this->connected_html() ); + } $connect = $this->vault_connect( $_REQUEST['email'], $_REQUEST['passwd'] ); if ( true === $connect ) { @@ -309,7 +312,8 @@ class MainWP_Child_Updraft_Plus_Backups { ) ); - if ( is_wp_error( $result ) || ( false === $result ) ) return $result; + if ( is_wp_error( $result ) || ( false === $result ) ) { return $result; + } $response = json_decode( $result['body'], true ); @@ -326,12 +330,14 @@ class MainWP_Child_Updraft_Plus_Backups { if ( !empty( $response['token'] ) ) { // Store it $vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' ); - if ( !is_array( $vault_settings ) ) $vault_settings = array(); + if ( !is_array( $vault_settings ) ) { $vault_settings = array(); + } $vault_settings['email'] = $email; $vault_settings['token'] = (string) $response['token']; $vault_settings['quota'] = -1; unset( $vault_settings['last_config'] ); - if ( isset($response['quota'] ) ) $vault_settings['quota'] = $response['quota']; + if ( isset($response['quota'] ) ) { $vault_settings['quota'] = $response['quota']; + } UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings ); } elseif ( isset( $response['quota'] ) && !$response['quota'] ) { return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) ); @@ -382,7 +388,8 @@ class MainWP_Child_Updraft_Plus_Backups { 'su' => base64_encode( home_url() ), ); - if ( !empty( $vault_settings['token'] ) ) $post_body['token'] = (string) $vault_settings['token']; + if ( !empty( $vault_settings['token'] ) ) { $post_body['token'] = (string) $vault_settings['token']; + } // Use SSL to prevent snooping wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array( @@ -395,11 +402,11 @@ class MainWP_Child_Updraft_Plus_Backups { function required_files() { if (defined('UPDRAFTPLUS_DIR')) { if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) { - require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' ); + require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php'; } if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) { - require_once( UPDRAFTPLUS_DIR . '/options.php' ); + require_once UPDRAFTPLUS_DIR . '/options.php'; } } } @@ -417,8 +424,9 @@ class MainWP_Child_Updraft_Plus_Backups { $settings_key = null; if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if (isset($settings['is_general']) && !empty($settings['is_general'])){ @@ -438,7 +446,7 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_googledrive' === $key ) { + } elseif ( 'updraft_googledrive' === $key ) { // do not saving from dashboard // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' ); // if (!is_array($opts)) @@ -454,7 +462,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); // } // UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_googlecloud' === $key ) { + } elseif ( 'updraft_googlecloud' === $key ) { // do not saving from dashboard // $opts = UpdraftPlus_Options::get_updraft_option( $key ); // if (!is_array($opts)) @@ -476,7 +484,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $opts['bucket_location'] = $settings[ $key ]['bucket_location']; // } // UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_onedrive' === $key ) { + } elseif ( 'updraft_onedrive' === $key ) { // do not saving from dashboard // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' ); // if (!is_array($opts)) @@ -493,7 +501,7 @@ class MainWP_Child_Updraft_Plus_Backups { // } // // UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_email' === $key ) { + } elseif ( 'updraft_email' === $key ) { $value = $settings[ $key ]; // free version if ( ! is_array( $value ) ) { @@ -502,10 +510,11 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( $key, $value ); - } else if ( 'updraft_s3' === $key ) { + } elseif ( 'updraft_s3' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey']; @@ -532,10 +541,11 @@ class MainWP_Child_Updraft_Plus_Backups { } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_s3generic' === $key ) { + } elseif ( 'updraft_s3generic' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint']; @@ -550,10 +560,11 @@ class MainWP_Child_Updraft_Plus_Backups { } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_dreamobjects' === $key ) { + } elseif ( 'updraft_dreamobjects' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']); @@ -563,10 +574,11 @@ class MainWP_Child_Updraft_Plus_Backups { $opts['endpoint'] = $settings[ $key ]['endpoint']; } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_ftp' === $key ) { + } elseif ( 'updraft_ftp' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { @@ -587,10 +599,11 @@ class MainWP_Child_Updraft_Plus_Backups { } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_sftp_settings' === $key ) { + } elseif ( 'updraft_sftp_settings' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { @@ -614,10 +627,11 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts ); - } else if ('updraft_webdav_settings' == $key) { + } elseif ('updraft_webdav_settings' == $key) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_webdav' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); @@ -625,10 +639,11 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts ); } - } else if ( 'updraft_backblaze' === $key ) { + } elseif ( 'updraft_backblaze' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if (is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id']; @@ -701,7 +716,8 @@ class MainWP_Child_Updraft_Plus_Backups { function addons_connect() { if ( ! defined( 'UDADDONS2_SLUG' ) ) { - if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'); + if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) { require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; + } if ( ! defined( 'UDADDONS2_SLUG' ) ) { return array( 'error' => 'NO_PREMIUM' ); } @@ -801,7 +817,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ( ! class_exists( 'UpdraftPlus_WPDB_OtherDB_Test' ) ) { if ( file_exists( UPDRAFTPLUS_DIR . '/addons/moredatabase.php' ) ) { - require_once( UPDRAFTPLUS_DIR . '/addons/moredatabase.php' ); + require_once UPDRAFTPLUS_DIR . '/addons/moredatabase.php'; } } @@ -1232,7 +1248,7 @@ class MainWP_Child_Updraft_Plus_Backups { if (method_exists($updraftplus, 'get_backup_history')) { $backups = $updraftplus->get_backup_history(); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backups = UpdraftPlus_Backup_History::get_history(); } $timestamp = $_POST['backup_timestamp']; @@ -1321,7 +1337,7 @@ class MainWP_Child_Updraft_Plus_Backups { continue; } if ( file_exists( UPDRAFTPLUS_DIR . "/methods/$service.php" ) ) { - require_once( UPDRAFTPLUS_DIR . "/methods/$service.php" ); + require_once UPDRAFTPLUS_DIR . "/methods/$service.php"; } $objname = 'UpdraftPlus_BackupModule_' . $service; $deleted = - 1; @@ -1457,7 +1473,7 @@ class MainWP_Child_Updraft_Plus_Backups { // Retrieve the information from our backup history if (method_exists($updraftplus, 'get_backup_history')) { $backup_history = $updraftplus->get_backup_history(); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backup_history = UpdraftPlus_Backup_History::get_history(); } @@ -1583,7 +1599,7 @@ class MainWP_Child_Updraft_Plus_Backups { $method_include = UPDRAFTPLUS_DIR . '/methods/' . $service . '.php'; if ( file_exists( $method_include ) ) { - require_once( $method_include ); + require_once $method_include; } $objname = "UpdraftPlus_BackupModule_${service}"; @@ -1617,7 +1633,7 @@ class MainWP_Child_Updraft_Plus_Backups { if (method_exists($updraftplus, 'get_backup_history')) { $backups = $updraftplus->get_backup_history(); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backups = UpdraftPlus_Backup_History::get_history(); } @@ -1767,7 +1783,7 @@ class MainWP_Child_Updraft_Plus_Backups { global $updraftplus_admin, $updraftplus; if ( empty( $updraftplus_admin ) ) { - require_once( UPDRAFTPLUS_DIR . '/admin.php' ); + require_once UPDRAFTPLUS_DIR . '/admin.php'; } ob_start(); $backup_success = $this->restore_backup( $_REQUEST['backup_timestamp'] ); @@ -1934,7 +1950,7 @@ class MainWP_Child_Updraft_Plus_Backups { uksort( $backup_set, array( $this, 'sort_restoration_entities' ) ); // We use a single object for each entity, because we want to store information about the backup set - require_once( UPDRAFTPLUS_DIR . '/restorer.php' ); + require_once UPDRAFTPLUS_DIR . '/restorer.php'; global $updraftplus_restorer; $updraftplus_restorer = new Updraft_Restorer( new Updraft_Restorer_Skin(), $backup_set ); @@ -2142,7 +2158,7 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus_restorer->clear_cache(); if ( ! function_exists( 'validate_current_theme' ) ) { - require_once( ABSPATH . WPINC . '/themes' ); + require_once ABSPATH . WPINC . '/themes'; } # Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system @@ -2319,7 +2335,7 @@ class MainWP_Child_Updraft_Plus_Backups { $info = array(); global $updraftplus, $wp_version; - include( ABSPATH . WPINC . '/version.php' ); + include ABSPATH . WPINC . '/version.php'; $updraft_dir = $updraftplus->backups_dir_location(); @@ -2329,7 +2345,7 @@ class MainWP_Child_Updraft_Plus_Backups { if (method_exists($updraftplus, 'get_backup_history')) { $backup = $updraftplus->get_backup_history($timestamp); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backup = UpdraftPlus_Backup_History::get_history($timestamp); } @@ -2563,12 +2579,14 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus->get_max_packet_size(); $backup = UpdraftPlus_Backup_History::get_history($timestamp); - if (!isset($backup['nonce']) || !isset($backup['db'])) return array($mess, $warn, $err, $info); + if (!isset($backup['nonce']) || !isset($backup['db'])) { return array($mess, $warn, $err, $info); + } $db_file = (is_string($backup['db'])) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; } - if (!is_readable($db_file)) return array($mess, $warn, $err, $info); + if (!is_readable($db_file)) { return array($mess, $warn, $err, $info); + } // Encrypted - decrypt it if (UpdraftPlus_Encryption::is_file_encrypted($db_file)) { @@ -2712,13 +2730,15 @@ class MainWP_Child_Updraft_Plus_Backups { if (!$migration_warning && home_url() != $old_home) { $migration_warning = true; $powarn = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_home, $res); - if (!empty($powarn)) $warn[] = $powarn; + if (!empty($powarn)) { $warn[] = $powarn; + } } } elseif (!isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) { $info['created_by_version'] = trim($matches[1]); } elseif ('' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches)) { $old_wp_version = $matches[1]; - if (!empty($matches[3])) $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1); + if (!empty($matches[3])) { $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1); + } if (version_compare($old_wp_version, $wp_version, '>')) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); $warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version); @@ -2762,7 +2782,8 @@ class MainWP_Child_Updraft_Plus_Backups { $val = $kvmatches[2]; if ('multisite' == $key) { $info['multisite'] = $val ? true : false; - if ($val) $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; + if ($val) { $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; + } } $old_siteinfo[$key] = $val; } @@ -2859,7 +2880,8 @@ class MainWP_Child_Updraft_Plus_Backups { } } $charset_select_html .= ''; - if (empty($info['addui'])) $info['addui'] = ''; + if (empty($info['addui'])) { $info['addui'] = ''; + } $info['addui'] .= $charset_select_html; } } @@ -2944,7 +2966,8 @@ class MainWP_Child_Updraft_Plus_Backups { CREATE TABLE $wpdb->sitemeta ( CREATE TABLE $wpdb->signups ( */ - if (!isset($skipped_tables)) $skipped_tables = array(); + if (!isset($skipped_tables)) { $skipped_tables = array(); + } $missing_tables = array(); if ($old_table_prefix) { if (!$header_only) { @@ -3133,8 +3156,10 @@ class MainWP_Child_Updraft_Plus_Backups { $date_label = $this->date_label( $pretty_date, $key, $backup, $jobdata, $non ); $service_title = ''; - if (!isset($backup['service'])) $backup['service'] = array(); - if (!is_array($backup['service'])) $backup['service'] = array($backup['service']); + if (!isset($backup['service'])) { $backup['service'] = array(); + } + if (!is_array($backup['service'])) { $backup['service'] = array($backup['service']); + } foreach ($backup['service'] as $service) { if ('none' === $service || '' === $service || (is_array($service) && (empty($service) || array('none') === $service || array('') === $service))) { // Do nothing @@ -3164,9 +3189,11 @@ ENDHERE; // Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field. $db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db']; if ( class_exists( 'UpdraftPlus_Encryption')) { - if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) - if (UpdraftPlus_Encryption::is_file_encrypted($db)) $entities .= '/dbcrypted=1/'; - } else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) { + if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) { + if (UpdraftPlus_Encryption::is_file_encrypted($db)) { $entities .= '/dbcrypted=1/'; + } + } + } elseif ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) { $entities .= '/dbcrypted=1/'; } @@ -3378,8 +3405,9 @@ ENDHERE; } $fix_perfomance++; - if ($fix_perfomance > 50) // // to fix perfomance issue of response when too much backup files + if ($fix_perfomance > 50) { // // to fix perfomance issue of response when too much backup files break; + } } } } @@ -3433,7 +3461,7 @@ ENDHERE; $messages = null; if ( method_exists( $updraftplus, 'rebuild_backup_history' ) ) { $messages = $updraftplus->rebuild_backup_history( $remotescan ); - } else if ( method_exists( $updraftplus_admin, 'rebuild_backup_history' ) ) { + } elseif ( method_exists( $updraftplus_admin, 'rebuild_backup_history' ) ) { $messages = $updraftplus_admin->rebuild_backup_history( $remotescan ); } @@ -3977,8 +4005,9 @@ ENDHERE; } public function updraftplus_init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_updraftplus_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php index a4a06c2..32367b7 100644 --- a/class/class-mainwp-child-vulnerability-checker.php +++ b/class/class-mainwp-child-vulnerability-checker.php @@ -129,8 +129,8 @@ class MainWP_Child_Vulnerability_Checker { function check_themes( $force = false) { - require_once( ABSPATH . 'wp-admin/includes/misc.php' ); - require_once( ABSPATH . 'wp-admin/includes/theme.php' ); + require_once ABSPATH . 'wp-admin/includes/misc.php'; + require_once ABSPATH . 'wp-admin/includes/theme.php'; if ( current_user_can( 'switch_themes' ) ) { $themes = wp_prepare_themes_for_js(); @@ -156,8 +156,9 @@ class MainWP_Child_Vulnerability_Checker { $th_vulner_data = array(); foreach($th_data['vulnerabilities'] as $vuln_data) { - if (empty($vuln_data)) + if (empty($vuln_data)) { continue; + } if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) { continue; diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 9597529..7151132 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -64,7 +64,7 @@ class MainWP_Child_WooCommerce_Status { global $wpdb; $file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php'; if ( file_exists( $file ) ) { - include_once( $file ); + include_once $file; } else { return false; } @@ -81,10 +81,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= %s AND posts.post_date <= %s @@ -103,10 +103,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' AND posts.post_date >= %s @@ -180,7 +180,7 @@ class MainWP_Child_WooCommerce_Status { global $wpdb; $file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php'; if ( file_exists( $file ) ) { - include_once( $file ); + include_once $file; } else { return false; } @@ -202,10 +202,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') @@ -224,10 +224,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') @@ -326,7 +326,7 @@ class MainWP_Child_WooCommerce_Status { global $wpdb; $file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php'; if ( file_exists( $file ) ) { - include_once( $file ); + include_once $file; } else { return false; } @@ -341,10 +341,10 @@ class MainWP_Child_WooCommerce_Status { $query['join'] = "INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'reports' ) ) . "' ) "; $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) "; + 'completed', + 'processing', + 'on-hold', + ) ) ) . "' ) "; $query['where'] .= "AND postmeta.meta_key = '_order_total' "; $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; @@ -360,10 +360,10 @@ class MainWP_Child_WooCommerce_Status { $query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) "; $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) "; + 'completed', + 'processing', + 'on-hold', + ) ) ) . "' ) "; $query['where'] .= "AND order_item_meta.meta_key = '_qty' "; $query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' "; $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; @@ -441,7 +441,7 @@ class MainWP_Child_WooCommerce_Status { } private static function update_wc_db() { - include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' ); + include_once WC()->plugin_path() . '/includes/class-wc-background-updater.php'; $background_updater = new WC_Background_Updater(); $current_db_version = get_option( 'woocommerce_db_version' ); diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index c3b6190..bb86c97 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -195,11 +195,11 @@ class MainWP_Child_Wordfence { public function __construct() { add_action( 'mainwp_child_deactivation', array( $this, 'deactivation' ) ); - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; // ok if ( is_plugin_active( 'wordfence/wordfence.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' ) ) { - require_once( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' ); + require_once plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php'; $this->is_wordfence_installed = true; } @@ -619,8 +619,9 @@ class MainWP_Child_Wordfence { private function start_scan() { $information = wordfence::ajax_scan_callback(); - if ( is_array($information) && isset($information['ok']) ) + if ( is_array($information) && isset($information['ok']) ) { $information['result'] = 'SUCCESS'; + } return $information; } @@ -653,7 +654,8 @@ class MainWP_Child_Wordfence { public function wordfence_init() { - if ( ! $this->is_wordfence_installed ) return; + if ( ! $this->is_wordfence_installed ) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); if ( get_option( 'mainwp_wordfence_hide_plugin' ) === 'hide' ) { @@ -669,8 +671,10 @@ class MainWP_Child_Wordfence { } // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'wordfence' ) return; - if ( ! $this->is_wordfence_installed ) return; + if ( $ext !== 'wordfence' ) { return; + } + if ( ! $this->is_wordfence_installed ) { return; + } global $wpdb; @@ -868,9 +872,9 @@ SQL $i = new wfIssues(); if ( 'deleteIgnored' === $op ) { $i->deleteIgnored(); - } else if ( 'deleteNew' === $op ) { + } elseif ( 'deleteNew' === $op ) { $i->deleteNew(); - } else if ( 'ignoreAllNew' === $op ) { + } elseif ( 'ignoreAllNew' === $op ) { $i->ignoreAllNew(); } else { return array( 'errorMsg' => 'An invalid operation was called.' ); @@ -893,7 +897,7 @@ SQL return array( 'ok' => 1, 'issueCounts' => $counts, - ); + ); } function update_issues_status() { @@ -944,13 +948,13 @@ SQL $err = error_get_last(); $errors[] = 'Could not delete file ' . htmlentities( $file ) . '. Error was: ' . htmlentities( $err['message'] ); } - } else if ( 'repair' === $op ) { + } elseif ( 'repair' === $op ) { $dat = $issue['data']; $result = wordfence::getWPFileContent( $dat['file'], $dat['cType'], $dat['cName'], $dat['cVersion'] ); if ( $result['cerrorMsg'] ) { $errors[] = $result['cerrorMsg']; continue; - } else if ( ! $result['fileContent'] ) { + } elseif ( ! $result['fileContent'] ) { $errors[] = 'We could not get the original file of ' . htmlentities( $file ) . ' to do a repair.'; continue; } @@ -989,10 +993,10 @@ SQL if ( $filesWorkedOn > 0 && count( $errors ) > 0 ) { $headMsg = "$verb some files with errors"; $bodyMsg = "$verb $filesWorkedOn files but we encountered the following errors with other files: " . implode( '
    ', $errors ); - } else if ( $filesWorkedOn > 0 ) { + } elseif ( $filesWorkedOn > 0 ) { $headMsg = "$verb $filesWorkedOn files successfully"; $bodyMsg = "$verb $filesWorkedOn files successfully. No errors were encountered."; - } else if ( count( $errors ) > 0 ) { + } elseif ( count( $errors ) > 0 ) { $headMsg = "Could not $verb2 files"; $bodyMsg = "We could not $verb2 any of the files you selected. We encountered the following errors: " . implode( '
    ', $errors ); } else { @@ -1053,7 +1057,7 @@ SQL $file = $dat['file']; if ( isset( $result['cerrorMsg'] ) && $result['cerrorMsg'] ) { return $result; - } else if ( ! $result['fileContent'] ) { + } elseif ( ! $result['fileContent'] ) { return array( 'cerrorMsg' => 'We could not get the original file to do a repair.' ); } @@ -1112,9 +1116,9 @@ SQL } function save_settings_new() { - if (isset($_POST['encrypted'])) + if (isset($_POST['encrypted'])) { $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost - else { + } else { $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); } @@ -1224,7 +1228,7 @@ SQL if (in_array('autoUpdate', $saving_opts)) { if ( '1' === $opts['autoUpdate'] ) { wfConfig::enableAutoUpdate(); - } else if ( '0' === $opts['autoUpdate'] ) { + } elseif ( '0' === $opts['autoUpdate'] ) { wfConfig::disableAutoUpdate(); } } @@ -1306,7 +1310,7 @@ SQL return $result; } - } else if ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { + } elseif ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); try { $res = $api->call('check_api_key', array(), array('previousLicense' => $existingAPIKey)); @@ -1411,9 +1415,9 @@ SQL } function save_setting() { - if (isset($_POST['encrypted'])) + if (isset($_POST['encrypted'])) { $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost - else { + } else { $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); } @@ -1470,7 +1474,7 @@ SQL if ( '1' === $opts['autoUpdate'] ) { wfConfig::enableAutoUpdate(); - } else if ( '0' === $opts['autoUpdate'] ) { + } elseif ( '0' === $opts['autoUpdate'] ) { wfConfig::disableAutoUpdate(); } @@ -1528,7 +1532,7 @@ SQL return $result; } - } else if ( wfConfig::get( 'apiKey' ) !== $apiKey ) { + } elseif ( wfConfig::get( 'apiKey' ) !== $apiKey ) { $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); try { $res = $api->call( 'check_api_key', array(), array() ); @@ -1592,7 +1596,7 @@ SQL 'token' => $res['token'], ); } - else if ($res['err']) { + elseif ($res['err']) { return array('errorExport' => __('An error occurred: ', 'wordfence') . $res['err']); } else { @@ -1658,7 +1662,7 @@ SQL 'settings' => $this->get_settings(), ); } - else if ($res['err']) { + elseif ($res['err']) { return array('errorImport' => 'An error occurred: ' . $res['err']); } else { @@ -1704,10 +1708,10 @@ SQL $listType = 'logins'; } $events = wordfence::getLog()->getHits( $listType, $type, $newestEventTime ); - } else if ( 'perfStats' === $alsoGet ) { + } elseif ( 'perfStats' === $alsoGet ) { $newestEventTime = $_POST['otherParams']; $events = wordfence::getLog()->getPerfStats( $newestEventTime ); - } else if ($alsoGet == 'liveTraffic') { + } elseif ($alsoGet == 'liveTraffic') { if (get_site_option('wordfence_syncAttackDataAttempts') > 10) { wordfence::syncAttackData(false); } @@ -1832,8 +1836,9 @@ SQL // credit of Wordfence private static function _getWAFData( $updated = null) { // custom - if(!class_exists('wfWAF')) + if(!class_exists('wfWAF')) { return false; + } // end if custom $data['learningMode'] = wfWAF::getInstance()->isInLearningMode(); @@ -1924,7 +1929,7 @@ SQL 'error' => sprintf(__('An error occurred while saving the configuration: %s', 'wordfence'), $errors[0]['error']), ); } - else if (count($errors) > 1) { + elseif (count($errors) > 1) { $compoundMessage = array(); foreach ($errors as $e) { $compoundMessage[] = $e['error']; @@ -2017,11 +2022,11 @@ SQL $wfLog = wordfence::getLog(); if ( 'topScanners' === $mode || 'topLeechers' === $mode ) { $results = $wfLog->getLeechers( $mode ); - } else if ( 'blockedIPs' === $mode ) { + } elseif ( 'blockedIPs' === $mode ) { $results = $wfLog->getBlockedIPs(); - } else if ( 'lockedOutIPs' === $mode ) { + } elseif ( 'lockedOutIPs' === $mode ) { $results = $wfLog->getLockedOutIPs(); - } else if ( 'throttledIPs' === $mode ) { + } elseif ( 'throttledIPs' === $mode ) { $results = $wfLog->getThrottledIPs(); } @@ -2057,9 +2062,10 @@ SQL $noEditHtaccess = '1'; if (isset($_POST['needToCheckFalconHtaccess']) && !empty($_POST['needToCheckFalconHtaccess'])) { $checkHtaccess = self::checkFalconHtaccess(); - if (isset($checkHtaccess['ok'])) + if (isset($checkHtaccess['ok'])) { $noEditHtaccess = '0'; - } else if (isset($_POST['noEditHtaccess'])) { + } + } elseif (isset($_POST['noEditHtaccess'])) { $noEditHtaccess = $_POST['noEditHtaccess']; } @@ -2071,13 +2077,13 @@ SQL if(is_plugin_active($pluginFile)){ if($pluginFile == 'w3-total-cache/w3-total-cache.php'){ $badPlugins[] = 'W3 Total Cache'; - } else if($pluginFile == 'quick-cache/quick-cache.php'){ + } elseif($pluginFile == 'quick-cache/quick-cache.php'){ $badPlugins[] = 'Quick Cache'; - } else if($pluginFile == 'wp-super-cache/wp-cache.php'){ + } elseif($pluginFile == 'wp-super-cache/wp-cache.php'){ $badPlugins[] = 'WP Super Cache'; - } else if($pluginFile == 'wp-fast-cache/wp-fast-cache.php'){ + } elseif($pluginFile == 'wp-fast-cache/wp-fast-cache.php'){ $badPlugins[] = 'WP Fast Cache'; - } else if($pluginFile == 'wp-fastest-cache/wpFastestCache.php'){ + } elseif($pluginFile == 'wp-fastest-cache/wpFastestCache.php'){ $badPlugins[] = 'WP Fastest Cache'; } } @@ -2121,10 +2127,10 @@ SQL if($cacheType == 'disable'){ wfConfig::set('cacheType', false); return array('ok' => 1, 'heading' => 'Caching successfully disabled.', 'body' => "{$htMsg}Caching has been disabled on your system.

    "); - } else if($cacheType == 'php'){ + } elseif($cacheType == 'php'){ wfConfig::set('cacheType', 'php'); return array('ok' => 1, 'heading' => 'Wordfence Basic Caching Enabled', 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

    "); - } else if($cacheType == 'falcon'){ + } elseif($cacheType == 'falcon'){ if($noEditHtaccess != '1'){ $err = wfCache::addHtaccessCode('add'); if($err){ @@ -2376,11 +2382,11 @@ SQL colspan=""> array(), - 'strong' => array(), - 'em' => array(), - 'a' => array('href' => true), - )) + 'code' => array(), + 'strong' => array(), + 'em' => array(), + 'a' => array('href' => true), + )) ?> @@ -2420,11 +2426,11 @@ SQL colspan=""> array(), - 'strong' => array(), - 'em' => array(), - 'a' => array('href' => true), - )) + 'code' => array(), + 'strong' => array(), + 'em' => array(), + 'a' => array('href' => true), + )) ?>
    @@ -2445,11 +2451,11 @@ SQL list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); $howGetHasErrors = false; foreach (array( - 'REMOTE_ADDR' => 'REMOTE_ADDR', - 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', - 'HTTP_X_REAL_IP' => 'X-Real-IP', - 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label) { + 'REMOTE_ADDR' => 'REMOTE_ADDR', + 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', + 'HTTP_X_REAL_IP' => 'X-Real-IP', + 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', + ) as $variable => $label) { if (!($currentServerVarForIP && $currentServerVarForIP === $variable) && $howGet === $variable) { $howGetHasErrors = true; break; @@ -2483,11 +2489,11 @@ SQL $howGet = wfConfig::get('howGetIPs', false); list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); foreach (array( - 'REMOTE_ADDR' => 'REMOTE_ADDR', - 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', - 'HTTP_X_REAL_IP' => 'X-Real-IP', - 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label): + 'REMOTE_ADDR' => 'REMOTE_ADDR', + 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', + 'HTTP_X_REAL_IP' => 'X-Real-IP', + 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', + ) as $variable => $label): ?> @@ -2558,7 +2564,7 @@ SQL > array('description' => '', 'value' => $wp_version), diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index 8771c1b..8b3b7bb 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -56,82 +56,82 @@ class MainWP_Child_WP_Rocket { function get_rocket_default_options() { return array( - 'cache_mobile' => 1, - 'do_caching_mobile_files' => 0, - 'cache_logged_user' => 0, - 'cache_ssl' => 0, - 'emoji' => 0, - 'embeds' => 1, - 'control_heartbeat' => 0, - 'heartbeat_site_behavior' => 'reduce_periodicity', - 'heartbeat_admin_behavior' => 'reduce_periodicity', - 'heartbeat_editor_behavior' => 'reduce_periodicity', - 'varnish_auto_purge' => 0, - 'manual_preload' => 0, - 'automatic_preload' => 0, - 'sitemap_preload' => 0, - 'sitemap_preload_url_crawl' => 500000, - 'sitemaps' => array(), - 'database_revisions' => 0, - 'database_auto_drafts' => 0, - 'database_trashed_posts' => 0, - 'database_spam_comments' => 0, - 'database_trashed_comments' => 0, - 'database_expired_transients' => 0, - 'database_all_transients' => 0, - 'database_optimize_tables' => 0, - 'schedule_automatic_cleanup' => 0, - 'automatic_cleanup_frequency' => '', - 'cache_reject_uri' => array(), - 'cache_reject_cookies' => array(), - 'cache_reject_ua' => array(), - 'cache_query_strings' => array(), - 'cache_purge_pages' => array(), - 'purge_cron_interval' => 10, - 'purge_cron_unit' => 'HOUR_IN_SECONDS', - 'exclude_css' => array(), - 'exclude_js' => array(), - 'exclude_inline_js' => array(), - 'async_css' => 0, - 'defer_all_js' => 0, - 'defer_all_js_safe' => 1, - 'critical_css' => '', - 'deferred_js_files' => array(), - 'lazyload' => 0, - 'lazyload_iframes' => 0, - 'lazyload_youtube' =>0, - 'minify_css' => 0, -// 'minify_css_key' => $minify_css_key, - 'minify_concatenate_css' => 0, - //'minify_css_combine_all' => 0, - 'minify_css_legacy' => 0, - 'minify_js' => 0, -// 'minify_js_key' => $minify_js_key, - 'minify_js_in_footer' => array(), - 'minify_concatenate_js' => 0, - 'minify_js_combine_all' => 0, - //'minify_js_legacy' => 0, - 'minify_google_fonts' => 0, - 'minify_html' => 0, - 'remove_query_strings' => 0, - 'dns_prefetch' => 0, - 'cdn' => 0, - 'cdn_cnames' => array(), - 'cdn_zone' => array(), - //'cdn_ssl' => 0, - 'cdn_reject_files' => array(), - 'do_cloudflare' => 0, - 'cloudflare_email' => '', - 'cloudflare_api_key' => '', - 'cloudflare_domain' => '', - //'cloudflare_zone_id' => '', - 'cloudflare_devmode' => 0, - 'cloudflare_protocol_rewrite' => 0, - 'cloudflare_auto_settings' => 0, - 'cloudflare_old_settings' => 0, - 'do_beta' => 0, - 'analytics_enabled' => 1, - ); + 'cache_mobile' => 1, + 'do_caching_mobile_files' => 0, + 'cache_logged_user' => 0, + 'cache_ssl' => 0, + 'emoji' => 0, + 'embeds' => 1, + 'control_heartbeat' => 0, + 'heartbeat_site_behavior' => 'reduce_periodicity', + 'heartbeat_admin_behavior' => 'reduce_periodicity', + 'heartbeat_editor_behavior' => 'reduce_periodicity', + 'varnish_auto_purge' => 0, + 'manual_preload' => 0, + 'automatic_preload' => 0, + 'sitemap_preload' => 0, + 'sitemap_preload_url_crawl' => 500000, + 'sitemaps' => array(), + 'database_revisions' => 0, + 'database_auto_drafts' => 0, + 'database_trashed_posts' => 0, + 'database_spam_comments' => 0, + 'database_trashed_comments' => 0, + 'database_expired_transients' => 0, + 'database_all_transients' => 0, + 'database_optimize_tables' => 0, + 'schedule_automatic_cleanup' => 0, + 'automatic_cleanup_frequency' => '', + 'cache_reject_uri' => array(), + 'cache_reject_cookies' => array(), + 'cache_reject_ua' => array(), + 'cache_query_strings' => array(), + 'cache_purge_pages' => array(), + 'purge_cron_interval' => 10, + 'purge_cron_unit' => 'HOUR_IN_SECONDS', + 'exclude_css' => array(), + 'exclude_js' => array(), + 'exclude_inline_js' => array(), + 'async_css' => 0, + 'defer_all_js' => 0, + 'defer_all_js_safe' => 1, + 'critical_css' => '', + 'deferred_js_files' => array(), + 'lazyload' => 0, + 'lazyload_iframes' => 0, + 'lazyload_youtube' =>0, + 'minify_css' => 0, + // 'minify_css_key' => $minify_css_key, + 'minify_concatenate_css' => 0, + //'minify_css_combine_all' => 0, + 'minify_css_legacy' => 0, + 'minify_js' => 0, + // 'minify_js_key' => $minify_js_key, + 'minify_js_in_footer' => array(), + 'minify_concatenate_js' => 0, + 'minify_js_combine_all' => 0, + //'minify_js_legacy' => 0, + 'minify_google_fonts' => 0, + 'minify_html' => 0, + 'remove_query_strings' => 0, + 'dns_prefetch' => 0, + 'cdn' => 0, + 'cdn_cnames' => array(), + 'cdn_zone' => array(), + //'cdn_ssl' => 0, + 'cdn_reject_files' => array(), + 'do_cloudflare' => 0, + 'cloudflare_email' => '', + 'cloudflare_api_key' => '', + 'cloudflare_domain' => '', + //'cloudflare_zone_id' => '', + 'cloudflare_devmode' => 0, + 'cloudflare_protocol_rewrite' => 0, + 'cloudflare_auto_settings' => 0, + 'cloudflare_old_settings' => 0, + 'do_beta' => 0, + 'analytics_enabled' => 1, + ); } // ok @@ -340,7 +340,7 @@ class MainWP_Child_WP_Rocket { } // to fix - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; // Generate a new random key for minify cache file $options = get_option( WP_ROCKET_SLUG ); @@ -379,7 +379,7 @@ class MainWP_Child_WP_Rocket { 'WP_Rocket\Optimization\CSS\Critical_CSS_Generation', 'WP_Rocket\Admin\Options', 'WP_Rocket\Admin\Options_Data', - )); + )); $critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() ); $options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' ); @@ -425,7 +425,7 @@ class MainWP_Child_WP_Rocket { 'WP_Rocket\Admin\Database\Optimization_Process', 'WP_Rocket\Admin\Options', 'WP_Rocket\Admin\Options_Data', - )); + )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); $optimization = new WP_Rocket\Admin\Database\Optimization( $process ); @@ -448,7 +448,7 @@ class MainWP_Child_WP_Rocket { MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization', 'WP_Rocket\Admin\Database\Optimization_Process', - )); + )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); $optimization = new WP_Rocket\Admin\Database\Optimization( $process ); diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index 612e62c..3e2444f 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -15,14 +15,15 @@ class MainWP_Child_WPvivid_BackupRestore { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR')) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); $this->public_intetface = new WPvivid_Public_Interface(); diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index e4effc9..8f6d272 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -13,8 +13,8 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) { define( 'MAINWP_CHILD_NR_OF_COMMENTS', 50 ); define( 'MAINWP_CHILD_NR_OF_PAGES', 50 ); -include_once( ABSPATH . '/wp-admin/includes/file.php' ); -include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); +require_once ABSPATH . '/wp-admin/includes/file.php'; +require_once ABSPATH . '/wp-admin/includes/plugin.php'; if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyuse_nonce_hmac'] ) ) { @@ -213,8 +213,9 @@ class MainWP_Child { $this->load_all_options(); $this->filterFunction = function( $a) { if ($a == null) { return false; } - if (is_object($a) && property_exists($a, 'last_checked') && !property_exists($a, 'checked')) + if (is_object($a) && property_exists($a, 'last_checked') && !property_exists($a, 'checked')) { return false; + } return $a; }; $this->plugin_dir = dirname( $plugin_file ); @@ -269,15 +270,17 @@ class MainWP_Child { function load_all_options() { global $wpdb; - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { $alloptions = wp_cache_get( 'alloptions', 'options' ); - else + } else { $alloptions = false; + } - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { $notoptions = wp_cache_get( 'notoptions', 'options' ); - else + } else { $notoptions = false; + } if ( !isset($alloptions['mainwp_db_version']) ) { $suppress = $wpdb->suppress_errors(); @@ -303,9 +306,9 @@ class MainWP_Child { 'mainwp_child_nossl', 'mainwp_security', 'mainwp_backupwordpress_ext_enabled', -// 'mainwp_wprocket_ext_enabled', - //'mainwp_wordfence_ext_enabled', - 'mainwp_branding_button_contact_label', + // 'mainwp_wprocket_ext_enabled', + //'mainwp_wordfence_ext_enabled', + 'mainwp_branding_button_contact_label', 'mainwp_branding_extra_settings', 'mainwp_branding_child_hide', 'mainwp_branding_ext_enabled', @@ -325,7 +328,8 @@ class MainWP_Child { $alloptions_db = $wpdb->get_results( $query ); $wpdb->suppress_errors($suppress); - if ( !is_array( $alloptions ) ) $alloptions = array(); + if ( !is_array( $alloptions ) ) { $alloptions = array(); + } if ( is_array( $alloptions_db ) ) { foreach ( (array) $alloptions_db as $o ) { $alloptions[ $o->option_name ] = $o->option_value; @@ -417,7 +421,7 @@ class MainWP_Child { foreach ( $options as $option ) { MainWP_Helper::fix_option( $option ); } - } else if ( ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) { + } elseif ( ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) { $options = array( 'mainwp_child_pubkey', //'mainwp_child_branding_disconnected', @@ -726,14 +730,16 @@ class MainWP_Child { $all_subpages = apply_filters( 'mainwp-child-init-subpages', array() ); - if ( !is_array( $all_subpages ) ) + if ( !is_array( $all_subpages ) ) { $all_subpages = array(); + } if ( !self::$subPagesLoaded ) { foreach( $all_subpages as $page ) { $slug = isset( $page['slug'] ) ? $page['slug'] : ''; - if ( empty( $slug ) ) + if ( empty( $slug ) ) { continue; + } $subpage = array(); $subpage['slug'] = $slug; $subpage['title'] = $page['title']; @@ -783,11 +789,11 @@ class MainWP_Child { if ($shownPage == '') { if (!$hide_settings ) { $shownPage = 'settings'; - } else if (!$hide_restore) { + } elseif (!$hide_restore) { $shownPage = 'restore-clone'; - } else if (!$hide_server_info) { + } elseif (!$hide_server_info) { $shownPage = 'server-info'; - } else if (!$hide_connection_detail) { + } elseif (!$hide_connection_detail) { $shownPage = 'connection-detail'; } } @@ -844,8 +850,9 @@ class MainWP_Child { $shownPage = $_GET['tab']; } - if (empty($shownPage)) + if (empty($shownPage)) { $shownPage = 'settings'; + } $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); @@ -1081,7 +1088,7 @@ class MainWP_Child { } if ( $hard ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; $home_path = ABSPATH; $htaccess_file = $home_path . '.htaccess'; @@ -1104,9 +1111,9 @@ class MainWP_Child { $file = ''; if ( isset( $_REQUEST['f'] ) ) { $file = $_REQUEST['f']; - } else if ( isset( $_REQUEST['file'] ) ) { + } elseif ( isset( $_REQUEST['file'] ) ) { $file = $_REQUEST['file']; - } else if ( isset( $_REQUEST['fdl'] ) ) { + } elseif ( isset( $_REQUEST['fdl'] ) ) { $file = $_REQUEST['fdl']; } @@ -1191,7 +1198,7 @@ class MainWP_Child { if ( 'dl' === $_REQUEST['cloneFunc'] ) { $this->uploadFile( $_REQUEST['f'] ); exit; - } else if ( 'deleteCloneBackup' === $_POST['cloneFunc'] ) { + } elseif ( 'deleteCloneBackup' === $_POST['cloneFunc'] ) { $dirs = MainWP_Helper::getMainWPDir( 'backup' ); $backupdir = $dirs[0]; $result = glob( $backupdir . $_POST['f'] ); @@ -1201,7 +1208,7 @@ class MainWP_Child { @unlink( $result[0] ); MainWP_Helper::write( array( 'result' => 'ok' ) ); - } else if ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { + } elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { $dirs = MainWP_Helper::getMainWPDir( 'backup' ); $backupdir = $dirs[0]; $result = glob( $backupdir . 'backup-' . $_POST['f'] . '-*' ); @@ -1217,7 +1224,7 @@ class MainWP_Child { } MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) ); - } else if ( 'createCloneBackup' === $_POST['cloneFunc'] ) { + } elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) { MainWP_Helper::endSession(); $files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' ); @@ -1308,7 +1315,7 @@ class MainWP_Child { } if ( get_option( 'mainwp_child_fix_htaccess' ) === false ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; $wp_rewrite->flush_rules(); MainWP_Helper::update_option( 'mainwp_child_fix_htaccess', 'yes', 'yes' ); @@ -1341,9 +1348,9 @@ class MainWP_Child { $file = ''; if ( isset( $_REQUEST['f'] ) ) { $file = $_REQUEST['f']; - } else if ( isset( $_REQUEST['file'] ) ) { + } elseif ( isset( $_REQUEST['file'] ) ) { $file = $_REQUEST['file']; - } else if ( isset( $_REQUEST['fdl'] ) ) { + } elseif ( isset( $_REQUEST['fdl'] ) ) { $file = $_REQUEST['fdl']; } @@ -1384,7 +1391,7 @@ class MainWP_Child { $file = ''; if ( isset( $_POST['f'] ) ) { $file = $_POST['f']; - } else if ( isset( $_POST['file'] ) ) { + } elseif ( isset( $_POST['file'] ) ) { $file = $_POST['file']; } @@ -1517,8 +1524,9 @@ class MainWP_Child { MainWP_Child_Links_Checker::Instance()->init(); MainWP_Child_WPvivid_BackupRestore::Instance()->init(); global $_wp_submenu_nopriv; - if ($_wp_submenu_nopriv === null) + if ($_wp_submenu_nopriv === null) { $_wp_submenu_nopriv = array(); // fix warning + } //Call the function required if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) { @@ -1530,11 +1538,11 @@ class MainWP_Child { MainWP_Helper::handle_fatal_error(); self::fix_for_custom_themes(); call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) ); - } else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) { + } elseif ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) { define( 'DOING_CRON', true ); self::fix_for_custom_themes(); call_user_func( array( $this, $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ); - } else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) { + } elseif (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) { MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) ); } @@ -1545,7 +1553,7 @@ class MainWP_Child { } MainWP_Keyword_Links::Instance()->update_htaccess(); // if needed MainWP_Keyword_Links::Instance()->redirect_cloak(); - } else if ( 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { + } elseif ( 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { MainWP_Keyword_Links::clear_htaccess(); // force clear } } @@ -1669,12 +1677,12 @@ class MainWP_Child { } // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } - include_once( ABSPATH . '/wp-admin/includes/template.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . '/wp-admin/includes/plugin.php'; $urlgot = json_decode( stripslashes( $_POST['url'] ) ); @@ -1807,17 +1815,17 @@ class MainWP_Child { $information = array(); - include_once( ABSPATH . '/wp-admin/includes/update.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; if ( null !== $this->filterFunction ) { add_filter( 'pre_site_transient_update_core', $this->filterFunction, 99 ); @@ -1834,7 +1842,7 @@ class MainWP_Child { foreach ( $core_updates as $core_update ) { if ( 'latest' === $core_update->response ) { $information['upgrade'] = 'SUCCESS'; - } else if ( 'upgrade' === $core_update->response && $core_update->locale === get_locale() && version_compare( $wp_version, $core_update->current, '<=' ) ) { + } elseif ( 'upgrade' === $core_update->response && $core_update->locale === get_locale() && version_compare( $wp_version, $core_update->current, '<=' ) ) { //Upgrade! $upgrade = false; if ( class_exists( 'Core_Upgrader' ) ) { @@ -1894,19 +1902,19 @@ class MainWP_Child { define( 'DOING_CRON', true ); MainWP_Helper::getWPFilesystem(); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/misc.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // to fix @wp_version_check(); @@ -1948,32 +1956,33 @@ class MainWP_Child { */ function upgradePluginTheme() { //Prevent disable/re-enable at upgrade - if (!defined( 'DOING_CRON') ) + if (!defined( 'DOING_CRON') ) { define( 'DOING_CRON', true ); + } MainWP_Helper::getWPFilesystem(); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/misc.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); - include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/plugin.php'; + include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; $information = array(); $information['upgrades'] = array(); $mwp_premium_updates_todo = array(); $mwp_premium_updates_todo_slugs = array(); if ( isset( $_POST['type'] ) && 'plugin' === $_POST['type'] ) { - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; if ( null !== $this->filterFunction ) { // ET_Automatic_Updates add_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); @@ -1985,7 +1994,7 @@ class MainWP_Child { if ( in_array( 'backupbuddy/backupbuddy.php', $plugins ) ) { if ( isset( $GLOBALS['ithemes_updater_path'] ) ) { if ( ! class_exists( 'Ithemes_Updater_Settings' ) ) { - require( $GLOBALS['ithemes_updater_path'] . '/settings.php' ); + require $GLOBALS['ithemes_updater_path'] . '/settings.php'; } if ( class_exists( 'Ithemes_Updater_Settings' ) ) { $ithemes_updater = new Ithemes_Updater_Settings(); @@ -1999,7 +2008,7 @@ class MainWP_Child { if (in_array('smart-manager-for-wp-e-commerce/smart-manager.php', $plugins)) { if (file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php') && file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php')) { include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php'; - include_once (plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php'); + include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php'; } } //// @@ -2109,11 +2118,11 @@ class MainWP_Child { if ( null !== $this->filterFunction ) { remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); } - } else if ( isset( $_POST['type'] ) && 'theme' === $_POST['type'] ) { + } elseif ( isset( $_POST['type'] ) && 'theme' === $_POST['type'] ) { $last_update = get_site_transient( 'update_themes' ); - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; if ( null !== $this->filterFunction ) { add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } @@ -2122,7 +2131,7 @@ class MainWP_Child { // $originalLastChecked = !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ? $last_update->last_checked : 0; @wp_update_themes(); - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + include_once ABSPATH . '/wp-admin/includes/theme.php'; // to support cached premium themes update info, hooking in the bulk_upgrade() add_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ) ); @@ -2285,14 +2294,14 @@ class MainWP_Child { 'hook_extra' => array(), ) ); $information['upgrades'][ $slug ] = ( ! is_wp_error( $result ) && ! empty( $result ) ); - } else if ( isset( $update['callback'] ) ) { + } elseif ( isset( $update['callback'] ) ) { if ( is_array( $update['callback'] ) && isset( $update['callback'][0] ) && isset( $update['callback'][1] ) ) { $update_result = @call_user_func( array( $update['callback'][0], $update['callback'][1], ) ); $information['upgrades'][ $slug ] = $update_result && true; - } else if ( is_string( $update['callback'] ) ) { + } elseif ( is_string( $update['callback'] ) ) { $update_result = @call_user_func( $update['callback'] ); $information['upgrades'][ $slug ] = $update_result && true; } else { @@ -2324,8 +2333,9 @@ class MainWP_Child { } } - if ($pre == false) + if ($pre == false) { return $false; + } return $_transient_data; } @@ -2347,8 +2357,9 @@ class MainWP_Child { } } - if ($pre == false) + if ($pre == false) { return $false; + } return $_transient_data; } @@ -2407,7 +2418,7 @@ class MainWP_Child { if ( '' != get_option( 'mainwp_child_uniqueId' ) ) { if ( ! isset( $_POST['uniqueId'] ) || ( '' === $_POST['uniqueId'] ) ) { MainWP_Helper::error( __( 'This child site is set to require a unique security ID. Please enter it before the connection can be established.', 'mainwp-child' ) ); - } else if ( get_option( 'mainwp_child_uniqueId' ) !== $_POST['uniqueId'] ) { + } elseif ( get_option( 'mainwp_child_uniqueId' ) !== $_POST['uniqueId'] ) { MainWP_Helper::error( __( 'The unique security ID mismatch! Please correct it before the connection can be established.', 'mainwp-child' ) ); } } @@ -2506,23 +2517,23 @@ class MainWP_Child { wp_update_post(array('ID' => $postId, 'post_status' => 'publish' )); } } - } else if ( 'update' === $action ) { + } elseif ( 'update' === $action ) { $postData = $_POST['post_data']; $my_post = is_array( $postData ) ? $postData : array(); wp_update_post( $my_post ); - } else if ( 'unpublish' === $action ) { + } elseif ( 'unpublish' === $action ) { $my_post['ID'] = $postId; $my_post['post_status'] = 'draft'; wp_update_post( $my_post ); - } else if ( 'trash' === $action ) { + } elseif ( 'trash' === $action ) { add_action( 'trash_post', array( 'MainWP_Child_Links_Checker', 'hook_post_deleted' ) ); wp_trash_post( $postId ); - } else if ( 'delete' === $action ) { + } elseif ( 'delete' === $action ) { add_action( 'delete_post', array( 'MainWP_Child_Links_Checker', 'hook_post_deleted' ) ); wp_delete_post( $postId, true ); - } else if ( 'restore' === $action ) { + } elseif ( 'restore' === $action ) { wp_untrash_post( $postId ); - } else if ( 'update_meta' === $action ) { + } elseif ( 'update_meta' === $action ) { $values = maybe_unserialize( base64_decode( $_POST['values'] ) ); $meta_key = $values['meta_key']; $meta_value = $values['meta_value']; @@ -2535,7 +2546,7 @@ class MainWP_Child { update_post_meta( $postId, $key, $meta_value[ $i ] ); } } - } else if ( 'get_edit' === $action ) { + } elseif ( 'get_edit' === $action ) { $postId = $_POST['id']; $post_type = $_POST['post_type']; if ( $post_type == 'post' ) { @@ -2601,7 +2612,7 @@ class MainWP_Child { } } - include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php' ); + include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; $post_featured_image = get_post_thumbnail_id( $id ); $child_upload_dir = wp_upload_dir(); $new_post = array( @@ -2646,22 +2657,22 @@ class MainWP_Child { if ( $post ) { $post_custom = get_post_custom( $id ); //post_slug = base64_decode( get_post_meta( $id, '_slug', true ) ); - include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php' ); + include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; $post_featured_image = get_post_thumbnail_id( $id ); $child_upload_dir = wp_upload_dir(); $new_post = array( - 'edit_id' => $id, - 'post_title' => $post->post_title, - 'post_content' => $post->post_content, - 'post_status' => $post->post_status, - 'post_date' => $post->post_date, - 'post_date_gmt' => $post->post_date_gmt, - 'post_type' => 'page', - 'post_name' => $post->post_name, - 'post_excerpt' => $post->post_excerpt, - 'comment_status' => $post->comment_status, - 'ping_status' => $post->ping_status, + 'edit_id' => $id, + 'post_title' => $post->post_title, + 'post_content' => $post->post_content, + 'post_status' => $post->post_status, + 'post_date' => $post->post_date, + 'post_date_gmt' => $post->post_date_gmt, + 'post_type' => 'page', + 'post_name' => $post->post_name, + 'post_excerpt' => $post->post_excerpt, + 'comment_status' => $post->comment_status, + 'ping_status' => $post->ping_status, ); if ( $post_featured_image != null ) { //Featured image is set, retrieve URL @@ -2678,12 +2689,12 @@ class MainWP_Child { $attachment = get_post( $attachment_id ); if ( $attachment ) { $post_gallery_images[] = array( - 'id' => $attachment_id, - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), - 'caption' => $attachment->post_excerpt, - 'description' => $attachment->post_content, - 'src' => $attachment->guid, - 'title' => $attachment->post_title, + 'id' => $attachment_id, + 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), + 'caption' => $attachment->post_excerpt, + 'description' => $attachment->post_content, + 'src' => $attachment->guid, + 'title' => $attachment->post_title, ); } } @@ -2693,11 +2704,11 @@ class MainWP_Child { wp_set_post_lock($id); $post_data = array( - 'new_post' => base64_encode( serialize( $new_post ) ), - 'post_custom' => base64_encode( serialize( $post_custom ) ), - 'post_featured_image' => base64_encode( $post_featured_image ), - 'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ), - 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), + 'new_post' => base64_encode( serialize( $new_post ) ), + 'post_custom' => base64_encode( serialize( $post_custom ) ), + 'post_featured_image' => base64_encode( $post_featured_image ), + 'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ), + 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), ); return $post_data; } @@ -2715,28 +2726,28 @@ class MainWP_Child { global $current_user; $reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0; - include_once( ABSPATH . '/wp-admin/includes/user.php' ); + include_once ABSPATH . '/wp-admin/includes/user.php'; if ( 'delete' === $action ) { wp_delete_user( $userId, $reassign ); - } else if ( 'changeRole' === $action ) { + } elseif ( 'changeRole' === $action ) { $my_user = array(); $my_user['ID'] = $userId; $my_user['role'] = $extra; wp_update_user( $my_user ); - } else if ( 'update_password' === $action ) { + } elseif ( 'update_password' === $action ) { $my_user = array(); $my_user['ID'] = $userId; $my_user['user_pass'] = $user_pass; wp_update_user( $my_user ); - } else if ( 'edit' === $action ) { + } elseif ( 'edit' === $action ) { $user_data = $this->get_user_to_edit($userId); if (!empty($user_data)) { $information['user_data'] = $user_data; } else { $failed = true; } - } else if ( 'update_user' === $action ) { + } elseif ( 'update_user' === $action ) { $my_user = $_POST['extra']; if (is_array($my_user)) { foreach($my_user as $idx => $val) { @@ -2755,8 +2766,9 @@ class MainWP_Child { $failed = true; } - if ($failed) + if ($failed) { $information['status'] = 'FAIL'; + } if ( ! isset( $information['status'] ) && !isset($information['error']) ) { $information['status'] = 'SUCCESS'; @@ -2783,33 +2795,39 @@ class MainWP_Child { } $pass1 = $pass2 = ''; - if ( isset( $data['pass1'] ) ) + if ( isset( $data['pass1'] ) ) { $pass1 = $data['pass1']; - if ( isset( $data['pass2'] ) ) + } + if ( isset( $data['pass2'] ) ) { $pass2 = $data['pass2']; + } if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) { $new_role = sanitize_text_field( $data['role'] ); $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. // Multisite super admins can freely edit their blog roles -- they possess all caps. - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) + if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { $user->role = $new_role; + } // If the new role isn't editable by the logged-in user die with error $editable_roles = get_editable_roles(); - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) + if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) { return array('error' => 'You can’t give users that role.'); + } } $email = ''; - if ( isset( $data['email'] ) ) + if ( isset( $data['email'] ) ) { $email = trim( $data['email'] ); + } - if ( !empty( $email ) ) + if ( !empty( $email ) ) { $user->user_email = sanitize_text_field( wp_unslash( $email ) ); - else + } else { $user->user_email = $userdata->user_email; + } if ( isset( $data['url'] ) ) { if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) { @@ -2821,22 +2839,28 @@ class MainWP_Child { } } - if ( isset( $data['first_name'] ) ) + if ( isset( $data['first_name'] ) ) { $user->first_name = sanitize_text_field( $data['first_name'] ); - if ( isset( $data['last_name'] ) ) + } + if ( isset( $data['last_name'] ) ) { $user->last_name = sanitize_text_field( $data['last_name'] ); - if ( isset( $data['nickname'] ) && !empty($data['nickname'])) + } + if ( isset( $data['nickname'] ) && !empty($data['nickname'])) { $user->nickname = sanitize_text_field( $data['nickname'] ); - if ( isset( $data['display_name'] ) ) + } + if ( isset( $data['display_name'] ) ) { $user->display_name = sanitize_text_field( $data['display_name'] ); - if ( isset( $data['description'] ) ) + } + if ( isset( $data['description'] ) ) { $user->description = trim( $data['description'] ); + } $errors = new WP_Error(); /* checking that username has been typed */ - if ( $user->user_login == '' ) + if ( $user->user_login == '' ) { $errors->add( 'user_login', __( 'ERROR: Please enter a username.' ) ); + } do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); @@ -2856,8 +2880,9 @@ class MainWP_Child { $errors->add( 'pass', __( 'ERROR: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); } - if ( !empty( $pass1 ) ) + if ( !empty( $pass1 ) ) { $user->user_pass = $pass1; + } } else { $user->user_pass = $userdata->user_pass; } @@ -2883,8 +2908,9 @@ class MainWP_Child { if ( $errors->get_error_codes() ) { $error_str = ''; foreach ( $errors->get_error_messages() as $message ) { - if ( is_string( $message ) ) + if ( is_string( $message ) ) { $error_str .= ' ' . esc_html( strip_tags( $message ) ); + } } return array( 'error' => $error_str ); @@ -2896,7 +2922,7 @@ class MainWP_Child { } function get_user_to_edit( $user_id ) { - require_once(ABSPATH . 'wp-admin/includes/user.php'); + require_once ABSPATH . 'wp-admin/includes/user.php'; $profileuser = get_user_to_edit($user_id); $edit_data = array(); @@ -2912,19 +2938,22 @@ class MainWP_Child { $public_display['display_nickname'] = $profileuser->nickname; $public_display['display_username'] = $profileuser->user_login; - if ( !empty($profileuser->first_name) ) + if ( !empty($profileuser->first_name) ) { $public_display['display_firstname'] = $profileuser->first_name; + } - if ( !empty($profileuser->last_name) ) + if ( !empty($profileuser->last_name) ) { $public_display['display_lastname'] = $profileuser->last_name; + } if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; } - if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere + if ( !in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; + } $public_display = array_map( 'trim', $public_display ); $public_display = array_unique( $public_display ); @@ -2949,18 +2978,18 @@ class MainWP_Child { if ( 'approve' === $action ) { wp_set_comment_status( $commentId, 'approve' ); - } else if ( 'unapprove' === $action ) { + } elseif ( 'unapprove' === $action ) { wp_set_comment_status( $commentId, 'hold' ); - } else if ( 'spam' === $action ) { + } elseif ( 'spam' === $action ) { wp_spam_comment( $commentId ); - } else if ( 'unspam' === $action ) { + } elseif ( 'unspam' === $action ) { wp_unspam_comment( $commentId ); - } else if ( 'trash' === $action ) { + } elseif ( 'trash' === $action ) { add_action( 'trashed_comment', array( 'MainWP_Child_Links_Checker', 'hook_trashed_comment' ), 10, 1 ); wp_trash_comment( $commentId ); - } else if ( 'restore' === $action ) { + } elseif ( 'restore' === $action ) { wp_untrash_comment( $commentId ); - } else if ( 'delete' === $action ) { + } elseif ( 'delete' === $action ) { wp_delete_comment( $commentId, true ); } else { $information['status'] = 'FAIL'; @@ -2983,17 +3012,17 @@ class MainWP_Child { $information['success'] ++; if ( 'approve' === $action ) { wp_set_comment_status( $commentId, 'approve' ); - } else if ( 'unapprove' === $action ) { + } elseif ( 'unapprove' === $action ) { wp_set_comment_status( $commentId, 'hold' ); - } else if ( 'spam' === $action ) { + } elseif ( 'spam' === $action ) { wp_spam_comment( $commentId ); - } else if ( 'unspam' === $action ) { + } elseif ( 'unspam' === $action ) { wp_unspam_comment( $commentId ); - } else if ( 'trash' === $action ) { + } elseif ( 'trash' === $action ) { wp_trash_comment( $commentId ); - } else if ( 'restore' === $action ) { + } elseif ( 'restore' === $action ) { wp_untrash_comment( $commentId ); - } else if ( 'delete' === $action ) { + } elseif ( 'delete' === $action ) { wp_delete_comment( $commentId, true ); } else { $information['success']--; @@ -3008,7 +3037,7 @@ class MainWP_Child { //Read form data $new_password = maybe_unserialize( base64_decode( $_POST['new_password'] ) ); $user = get_user_by( 'login', $_POST['user'] ); - require_once( ABSPATH . WPINC . '/registration.php' ); + require_once ABSPATH . WPINC . '/registration.php'; $id = wp_update_user( array( 'ID' => $user->ID, 'user_pass' => $new_password['user_pass'] ) ); if ( $id !== $user->ID ) { @@ -3156,7 +3185,7 @@ class MainWP_Child { } else { $information['status'] = 'stalled'; } - } else if ( $wp_filesystem->is_file( $doneFile ) ) { + } elseif ( $wp_filesystem->is_file( $doneFile ) ) { $file = $wp_filesystem->get_contents( $doneFile ); $information['status'] = 'done'; $information['file'] = basename( $file ); @@ -3303,7 +3332,7 @@ class MainWP_Child { $file = false; if ( isset( $_POST['f'] ) ) { $file = $_POST['f']; - } else if ( isset( $_POST['file'] ) ) { + } elseif ( isset( $_POST['file'] ) ) { $file = $_POST['file']; } @@ -3327,7 +3356,7 @@ class MainWP_Child { $information['size'] = $res['filesize']; } $information['db'] = false; - } else if ( 'db' == $_POST['type'] ) { + } elseif ( 'db' == $_POST['type'] ) { $ext = 'zip'; if ( isset( $_POST['ext'] ) ) { $ext = $_POST['ext']; @@ -3591,7 +3620,7 @@ class MainWP_Child { MainWP_Helper::update_option( 'mainwp_child_pluginDir', $_POST['pluginDir'], 'yes' ); $update_htaccess = true; } - } else if ( false !== get_option( 'mainwp_child_pluginDir' ) ) { + } elseif ( false !== get_option( 'mainwp_child_pluginDir' ) ) { MainWP_Helper::update_option( 'mainwp_child_pluginDir', false, 'yes' ); $update_htaccess = true; } @@ -3652,7 +3681,7 @@ class MainWP_Child { } $information['nossl'] = ( 1 == $nossl ? 1 : 0 ); - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; $timeout = 3 * 60 * 60; // 3minutes @set_time_limit( $timeout ); @@ -3696,7 +3725,7 @@ class MainWP_Child { foreach ( $update_check as $updateFeedback ) { if ( is_array( $updateFeedback['callback'] ) && isset( $updateFeedback['callback'][0] ) && isset( $updateFeedback['callback'][1] ) ) { @call_user_func( array( $updateFeedback['callback'][0], $updateFeedback['callback'][1] ) ); - } else if ( is_string( $updateFeedback['callback'] ) ) { + } elseif ( is_string( $updateFeedback['callback'] ) ) { @call_user_func( $updateFeedback['callback'] ); } } @@ -3717,7 +3746,7 @@ class MainWP_Child { if ( 'plugin' === $informationPremiumUpdates[ $i ]['type'] ) { $premiumPlugins[] = $slug; - } else if ( 'theme' === $informationPremiumUpdates[ $i ]['type'] ) { + } elseif ( 'theme' === $informationPremiumUpdates[ $i ]['type'] ) { $premiumThemes[] = $slug; } @@ -3750,7 +3779,7 @@ class MainWP_Child { $wp_current_filter[] = 'load-plugins.php'; @wp_update_plugins(); - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + include_once ABSPATH . '/wp-admin/includes/plugin.php'; $plugin_updates = get_plugin_updates(); if ( is_array( $plugin_updates ) ) { @@ -3805,7 +3834,7 @@ class MainWP_Child { add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } @wp_update_themes(); - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + include_once ABSPATH . '/wp-admin/includes/theme.php'; $theme_updates = $this->upgrade_get_theme_updates(); if ( is_array( $theme_updates ) ) { $information['theme_updates'] = array(); @@ -3860,10 +3889,10 @@ class MainWP_Child { break; } } - } else if ( 'theme' === $translation_update->type ) { + } elseif ( 'theme' === $translation_update->type ) { $theme = wp_get_theme($translation_update->slug); $new_translation_update['name'] = $theme->name; - } else if ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) { + } elseif ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) { $new_translation_update['name'] = 'WordPress core'; } $information['translation_updates'][] = $new_translation_update; @@ -4024,8 +4053,9 @@ class MainWP_Child { function get_site_icon() { $information = array(); $url = $this->get_favicon( true ); - if ( !empty( $url ) ) + if ( !empty( $url ) ) { $information['faviIconUrl'] = $url; + } MainWP_Helper::write( $information ); } @@ -4046,7 +4076,7 @@ class MainWP_Child { if ( empty( $favi ) ) { if ( file_exists( ABSPATH . 'favicon.ico' ) ) { $favi = 'favicon.ico'; - } else if ( file_exists( ABSPATH . 'favicon.png' ) ) { + } elseif ( file_exists( ABSPATH . 'favicon.png' ) ) { $favi = 'favicon.png'; } @@ -4067,7 +4097,7 @@ class MainWP_Child { if ( preg_match( $preg_str1, $request['body'], $matches ) ) { $favi = $matches[2]; - } else if ( preg_match( $preg_str2, $request['body'], $matches ) ) { + } elseif ( preg_match( $preg_str2, $request['body'], $matches ) ) { $favi = $matches[2]; } } @@ -4192,9 +4222,9 @@ class MainWP_Child { $tokens = $extra['tokens']; if ( 1 == $extra['extract_post_type'] ) { $args['post_type'] = 'post'; - } else if ( 2 == $extra['extract_post_type'] ) { + } elseif ( 2 == $extra['extract_post_type'] ) { $args['post_type'] = 'page'; - } else if ( 3 == $extra['extract_post_type'] ) { + } elseif ( 3 == $extra['extract_post_type'] ) { $args['post_type'] = array( 'post', 'page' ); } } @@ -4385,7 +4415,7 @@ class MainWP_Child { $where = ' WHERE '; if ( ! empty( $start_date ) && ! empty( $end_date ) ) { $where .= " p.post_date>='$start_date' AND p.post_date<='$end_date' AND "; - } else if ( ! empty( $start_date ) && empty( $end_date ) ) { + } elseif ( ! empty( $start_date ) && empty( $end_date ) ) { $where .= " p.post_date='$start_date' AND "; } $where .= " ( p.post_status='publish' OR p.post_status='future' OR p.post_status='draft' ) @@ -4416,7 +4446,7 @@ class MainWP_Child { if ( ! $result ) { $information['status'] = 'SUCCESS'; } - } else if ( $cancel_all ) { + } elseif ( $cancel_all ) { $post_type = $_POST['post_type']; $where = " WHERE p.post_status='future' AND p.post_type = %s AND pm.meta_key = '_is_auto_generate_content' AND pm.meta_value = 'yes' "; $posts = $wpdb->get_results( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id $where ", $post_type) ); @@ -4497,14 +4527,14 @@ class MainWP_Child { $where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false; if ( isset( $_POST['postId'] ) ) { $this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId']; - } else if ( isset( $_POST['userId'] ) ) { + } elseif ( isset( $_POST['userId'] ) ) { $this->posts_where_suffix .= " AND $wpdb->posts.post_author = " . $_POST['userId']; } else { if ( isset( $_POST['keyword'] ) ) { $search_on = isset($_POST['search_on']) ? $_POST['search_on'] : ''; if ($search_on == 'title') { $this->posts_where_suffix .= " AND ( $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )"; - } else if ($search_on == 'content') { + } elseif ($search_on == 'content') { $this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' )"; } else { $this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' OR $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )"; @@ -4595,7 +4625,7 @@ class MainWP_Child { function get_recent_comments( $pAllowedStatuses, $pCount ) { if ( ! function_exists( 'get_comment_author_url' ) ) { - include_once( WPINC . '/comment-template.php' ); + include_once WPINC . '/comment-template.php'; } $allComments = array(); @@ -4637,23 +4667,23 @@ class MainWP_Child { $theme = $_POST['theme']; if ( 'activate' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + include_once ABSPATH . '/wp-admin/includes/theme.php'; $theTheme = wp_get_theme( $theme ); if ( null !== $theTheme && '' !== $theTheme ) { switch_theme( $theTheme['Template'], $theTheme['Stylesheet'] ); } - } else if ( 'delete' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + } elseif ( 'delete' === $action ) { + include_once ABSPATH . '/wp-admin/includes/theme.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/template.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/template.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; $wp_filesystem = $this->getWPFilesystem(); if ( empty( $wp_filesystem ) ) { @@ -4725,7 +4755,7 @@ class MainWP_Child { if ( '' == $keyword || stristr( $out['title'], $keyword ) ) { $rslt[] = $out; } - } else if ( $out['active'] === ( ( 'active' === $status ) ? 1 : 0 ) ) { + } elseif ( $out['active'] === ( ( 'active' === $status ) ? 1 : 0 ) ) { if ( '' == $keyword || stristr( $out['title'], $keyword ) ) { $rslt[] = $out; } @@ -4742,7 +4772,7 @@ class MainWP_Child { $plugins = explode( '||', $_POST['plugin'] ); if ( 'activate' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + include_once ABSPATH . '/wp-admin/includes/plugin.php'; foreach ( $plugins as $idx => $plugin ) { if ( $plugin !== $this->plugin_slug ) { @@ -4758,8 +4788,8 @@ class MainWP_Child { } } } - } else if ( 'deactivate' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + } elseif ( 'deactivate' === $action ) { + include_once ABSPATH . '/wp-admin/includes/plugin.php'; foreach ( $plugins as $idx => $plugin ) { if ( $plugin !== $this->plugin_slug ) { @@ -4769,18 +4799,18 @@ class MainWP_Child { } } } - } else if ( 'delete' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + } elseif ( 'delete' === $action ) { + include_once ABSPATH . '/wp-admin/includes/plugin.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/template.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/template.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; $wp_filesystem = $this->getWPFilesystem(); if ( null === $wp_filesystem ) { @@ -4828,7 +4858,7 @@ class MainWP_Child { function get_all_plugins_int( $filter, $keyword = '', $status = '' ) { if ( ! function_exists( 'get_plugins' ) ) { - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + include_once ABSPATH . 'wp-admin/includes/plugin.php'; } $rslt = array(); $plugins = get_plugins(); @@ -4847,7 +4877,7 @@ class MainWP_Child { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } - } else if ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { + } elseif ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } @@ -4870,7 +4900,7 @@ class MainWP_Child { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } - } else if ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { + } elseif ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } @@ -4904,8 +4934,9 @@ class MainWP_Child { } } } - if ($return) + if ($return) { return $allusers; + } MainWP_Helper::write( $allusers ); } @@ -4913,8 +4944,9 @@ class MainWP_Child { $allusers = array(); $params = array(); - if ($number) + if ($number) { $params['number'] = $number; + } $new_users = get_users($params); if ( is_array( $new_users ) ) { @@ -5015,7 +5047,7 @@ class MainWP_Child { //Deactivating the plugin function deactivate() { - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + include_once ABSPATH . 'wp-admin/includes/plugin.php'; deactivate_plugins( $this->plugin_slug, true ); $information = array(); if ( is_plugin_active( $this->plugin_slug ) ) { @@ -5027,8 +5059,9 @@ class MainWP_Child { function activation() { $mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false); - if ($mu_plugin_enabled) + if ($mu_plugin_enabled) { return; + } $to_delete = array( 'mainwp_child_pubkey', @@ -5054,8 +5087,9 @@ class MainWP_Child { function deactivation( $deact = true) { $mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false); - if ($mu_plugin_enabled) + if ($mu_plugin_enabled) { return; + } $to_delete = array( 'mainwp_child_pubkey', @@ -5075,8 +5109,9 @@ class MainWP_Child { } } - if ($deact) + if ($deact) { do_action( 'mainwp_child_deactivation' ); + } } function getWPFilesystem() { @@ -5086,10 +5121,10 @@ class MainWP_Child { ob_start(); // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } $creds = request_filesystem_credentials( 'test', '', false, false, $extra_fields = null ); ob_end_clean(); @@ -5101,7 +5136,7 @@ class MainWP_Child { if ( empty( $wp_filesystem ) ) { MainWP_Helper::error( $this->FTP_ERROR ); - } else if ( is_wp_error( $wp_filesystem->errors ) ) { + } elseif ( is_wp_error( $wp_filesystem->errors ) ) { $errorCodes = $wp_filesystem->errors->get_error_codes(); if ( ! empty( $errorCodes ) ) { MainWP_Helper::error( __( 'WordPress Filesystem error: ', 'mainwp-child' ) . $wp_filesystem->errors->get_error_message() ); @@ -5274,7 +5309,7 @@ class MainWP_Child { MainWP_Helper::write( $information ); return; - } else if ( 'clear_settings' === $_POST['action'] ) { + } elseif ( 'clear_settings' === $_POST['action'] ) { delete_option( 'mainwp_maintenance_opt_alert_404' ); delete_option( 'mainwp_maintenance_opt_alert_404_email' ); $information['result'] = 'SUCCESS'; @@ -5500,7 +5535,7 @@ class MainWP_Child { $code = stripslashes( $_POST['code'] ); if ( 'run_snippet' === $action ) { $information = MainWP_Tools::execute_snippet( $code ); - } else if ( 'save_snippet' === $action ) { + } elseif ( 'save_snippet' === $action ) { $type = $_POST['type']; $slug = $_POST['slug']; $snippets = get_option( 'mainwp_ext_code_snippets' ); @@ -5520,7 +5555,7 @@ class MainWP_Child { } } MainWP_Helper::update_option( 'mainwp_ext_snippets_enabled', true, 'yes' ); - } else if ( 'delete_snippet' === $action ) { + } elseif ( 'delete_snippet' === $action ) { $type = $_POST['type']; $slug = $_POST['slug']; $snippets = get_option( 'mainwp_ext_code_snippets' ); @@ -5566,7 +5601,7 @@ class MainWP_Child { if ( 'delete' === $action ) { $wpConfig = preg_replace( '/' . PHP_EOL . '{1,2}\/\*\*\*snippet_' . $slug . '\*\*\*\/(.*)\/\*\*\*end_' . $slug . '\*\*\*\/' . PHP_EOL . '/is', '', $wpConfig ); - } else if ( 'save' === $action ) { + } elseif ( 'save' === $action ) { $wpConfig = preg_replace( '/(\$table_prefix *= *[\'"][^\'|^"]*[\'"] *;)/is', '${1}' . PHP_EOL . PHP_EOL . '/***snippet_' . $slug . '***/' . PHP_EOL . $code . PHP_EOL . '/***end_' . $slug . '***/' . PHP_EOL, $wpConfig ); } file_put_contents( $config_file, $wpConfig ); @@ -5611,7 +5646,7 @@ class MainWP_Child { if ( strpos( $path, 'wp-content' ) === 0 ) { $path = basename( WP_CONTENT_DIR ) . substr( $path, 10 ); - } else if ( strpos( $path, 'wp-includes' ) === 0 ) { + } elseif ( strpos( $path, 'wp-includes' ) === 0 ) { $path = WPINC . substr( $path, 11 ); } @@ -5824,7 +5859,7 @@ class MainWP_Child { static function fix_for_custom_themes() { if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( function_exists( 'et_register_updates_component' ) ) { diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index 7876ccd..24c7cc2 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -12,16 +12,16 @@ class MainWP_Clone_Install { * @param string $file The zip backup file path */ public function __construct( $file ) { - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->file = $file; if ( '.zip' === substr( $this->file, - 4 ) ) { $this->archiver = null; - } else if ( '.tar.gz' === substr( $this->file, - 7 ) ) { + } elseif ( '.tar.gz' === substr( $this->file, - 7 ) ) { $this->archiver = new Tar_Archiver( null, 'tar.gz' ); - } else if ( '.tar.bz2' === substr( $this->file, - 8 ) ) { + } elseif ( '.tar.bz2' === substr( $this->file, - 8 ) ) { $this->archiver = new Tar_Archiver( null, 'tar.bz2' ); - } else if ( '.tar' === substr( $this->file, - 4 ) ) { + } elseif ( '.tar' === substr( $this->file, - 4 ) ) { $this->archiver = new Tar_Archiver( null, 'tar' ); } } @@ -58,9 +58,9 @@ class MainWP_Clone_Install { if ( null !== $this->archiver ) { - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { //todo: implement - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { @@ -114,9 +114,9 @@ class MainWP_Clone_Install { } return $this->archiver->file_exists( $file ); - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { //todo: implement - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { @@ -374,7 +374,7 @@ class MainWP_Clone_Install { } else { if ( $this->checkZipConsole() ) { //todo: implement - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { @@ -419,13 +419,13 @@ class MainWP_Clone_Install { } return $this->archiver->extractTo( ABSPATH ); - } else if ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) { + } elseif ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) { return $this->extractWPZipBackup(); - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { return $this->extractZipConsoleBackup(); - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { return $this->extractZipBackup(); - } else if ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) { + } elseif ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) { return $this->extractWPZipBackup(); } else { return $this->extractZipPclBackup(); diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 0f51435..3f7c36f 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -18,7 +18,7 @@ class MainWP_Clone { } if ( ! function_exists( 'wp_create_nonce' ) ) { - include_once( ABSPATH . WPINC . '/pluggable.php' ); + include_once ABSPATH . WPINC . '/pluggable.php'; } $this->security_nonces[ $action ] = wp_create_nonce( $action ); } @@ -112,7 +112,7 @@ class MainWP_Clone { if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { - require_once( ABSPATH . 'wp-admin/includes/file.php' ); + require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_FILES['file']; $upload_overrides = array( 'test_form' => false ); @@ -254,7 +254,7 @@ class MainWP_Clone { if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { - require_once( ABSPATH . 'wp-admin/includes/file.php' ); + require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_FILES['file']; $upload_overrides = array( 'test_form' => false ); @@ -1414,7 +1414,7 @@ class MainWP_Clone { throw new Exception( __( 'No download file found', 'mainwp-child' ) ); } $file = $archiveFile; - } else if ( file_exists( $file ) ) { + } elseif ( file_exists( $file ) ) { $testFull = true; } else { $file = ABSPATH . $file; diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php index 136a925..449d338 100755 --- a/class/class-mainwp-custom-post-type.php +++ b/class/class-mainwp-custom-post-type.php @@ -114,7 +114,7 @@ class MainWP_Custom_Post_Type { $serverHref = 'href="' . $serverHost; $replaceServerHref = 'href="' . parse_url( $localUrl, PHP_URL_SCHEME ) . '://' . parse_url( $localUrl, PHP_URL_HOST ); $post_content = str_replace( $serverHref, $replaceServerHref, $post_content ); - } else if ( strpos( $hrefLink, 'http' ) !== false ) { + } elseif ( strpos( $hrefLink, 'http' ) !== false ) { $lnkToReplace = dirname( $hrefLink ); if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { $post_content = str_replace( $lnkToReplace, $linkToReplaceWith, $post_content ); @@ -286,7 +286,7 @@ class MainWP_Custom_Post_Type { // MainWP Categories if ( ! empty( $data['categories'] ) && is_array( $data['categories'] ) ) { // Contains wp_create_categories - include_once( ABSPATH . 'wp-admin/includes/taxonomy.php' ); + include_once ABSPATH . 'wp-admin/includes/taxonomy.php'; $categories = $data['categories']; if ( $data['post_only_existing'] == '0' ) { $post_category = wp_create_categories( $categories, $post_id ); diff --git a/class/class-mainwp-debug.php b/class/class-mainwp-debug.php index 2615c67..4cce37d 100644 --- a/class/class-mainwp-debug.php +++ b/class/class-mainwp-debug.php @@ -21,7 +21,7 @@ class MainWP_Debug { $_POST['excludenonwp'] = '1'; $_POST['ext'] = 'tar.gz'; print_r( $mainwpChild->backup( false ) ); - } else if ( 'test' == $_GET['mainwpdebug'] ) { + } elseif ( 'test' == $_GET['mainwpdebug'] ) { print_r( get_included_files() ); } else { print_r( $mainwpChild->getSiteStats( array(), false ) ); diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 55bf006..9fd4387 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -58,8 +58,9 @@ class MainWP_Helper { static function error( $error, $code = null ) { $information['error'] = $error; - if (null !== $code) + if (null !== $code) { $information['error_code'] = $code; + } self::write( $information ); } @@ -110,7 +111,8 @@ class MainWP_Helper { $selector = trim($val[$i], " \r\n\t"); if(!empty($selector)){ - if(!isset($new[$selector])) $new[$selector] = array(); + if(!isset($new[$selector])) { $new[$selector] = array(); + } $rules = explode(';', $val[++$i]); foreach($rules as $rule){ $rule = trim($rule, " \r\n\t"); @@ -119,8 +121,9 @@ class MainWP_Helper { $property = trim(array_pop($rule), " \r\n\t"); $value = implode(':', array_reverse($rule)); - if(!isset($new[$selector][$property]) || !preg_match('/!important/', $new[$selector][$property])) $new[$selector][$property] = $value; - elseif(preg_match('/!important/', $new[$selector][$property]) && preg_match('/!important/', $value)) $new[$selector][$property] = $value; + if(!isset($new[$selector][$property]) || !preg_match('/!important/', $new[$selector][$property])) { $new[$selector][$property] = $value; + } elseif(preg_match('/!important/', $new[$selector][$property]) && preg_match('/!important/', $value)) { $new[$selector][$property] = $value; + } } } } @@ -135,7 +138,8 @@ class MainWP_Helper { $output .= $media . " {\n"; $prefix = "\t"; } - else $prefix = ''; + else { $prefix = ''; + } foreach($content as $selector => $rules){ $output .= $prefix . $selector . " {\n"; @@ -155,9 +159,10 @@ class MainWP_Helper { // $check_file_existed: to support checking if file existed // $parent_id: optional static function uploadImage( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) { - if ( !is_array($img_data) ) + if ( !is_array($img_data) ) { $img_data = array(); - include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url + } + include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url $upload_dir = wp_upload_dir(); //Download $img_url $temporary_file = download_url( $img_url ); @@ -233,11 +238,12 @@ class MainWP_Helper { } $attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database - require_once( ABSPATH . 'wp-admin/includes/image.php' ); + require_once ABSPATH . 'wp-admin/includes/image.php'; $attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path ); wp_update_attachment_metadata( $attach_id, $attach_data ); //Update generated metadata - if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) + if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) { update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] ); + } return array( 'id' => $attach_id, 'url' => $local_img_url ); } } @@ -364,7 +370,7 @@ class MainWP_Helper { if ( $is_robot_post ) { // retirement soon if ( 1 === $post_author ) { $new_post['post_author'] = $current_uid; - } else if ( ! is_numeric( $post_author ) ) { + } elseif ( ! is_numeric( $post_author ) ) { $user_author = get_user_by( 'login', $post_author ); if ( $user_author ) { $post_author = $user_author->ID; @@ -373,7 +379,7 @@ class MainWP_Helper { $post_author = wp_create_user( $post_author, $random_password, $post_author . '@asdf.com' ); } } - } else if ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) { + } elseif ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) { $_author = get_user_by( 'login', $new_post['custom_post_author'] ); if ( ! empty( $_author ) ) { $new_post['post_author'] = $_author->ID; @@ -410,7 +416,7 @@ class MainWP_Helper { if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) { $edit_post_id = current($post_custom['_mainwp_edit_post_id']); - } else if (isset( $new_post['ID'] ) && $new_post['ID']) { + } elseif (isset( $new_post['ID'] ) && $new_post['ID']) { $edit_post_id = $new_post['ID']; } @@ -424,8 +430,9 @@ class MainWP_Helper { } $check_image_existed = false; - if ( $edit_post_id ) + if ( $edit_post_id ) { $check_image_existed = true; // if editing post then will check if image existed + } //Search for all the images added to the new post //some images have a href tag to click to navigate to the image.. we need to replace this too @@ -583,8 +590,9 @@ class MainWP_Helper { return array( 'error' => 'Empty post id'); } - if ( !$edit_post_id ) + if ( !$edit_post_id ) { wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) ); + } if ( ! empty( $terms ) ) { wp_set_object_terms( $new_post_id, array_map( intval, $terms ), 'category' ); @@ -641,8 +649,9 @@ class MainWP_Helper { foreach ( $post_custom as $meta_key => $meta_values ) { if ( ! in_array( $meta_key, $not_allowed ) ) { foreach ( $meta_values as $meta_value ) { - if (strpos($meta_key, '_mainwp_spinner_') === 0) + if (strpos($meta_key, '_mainwp_spinner_') === 0) { continue; // not save + } if ( ! $seo_ext_activated ) { // if WordPress SEO plugin is not activated do not save yoast post meta @@ -653,13 +662,13 @@ class MainWP_Helper { update_post_meta( $new_post_id, $meta_key, $meta_value ); } } - } else if ( '_sticky' === $meta_key ) { + } elseif ( '_sticky' === $meta_key ) { foreach ( $meta_values as $meta_value ) { if ( 'sticky' === base64_decode( $meta_value ) ) { stick_post( $new_post_id ); } } - } else if ( '_post_to_only_existing_categories' === $meta_key ) { + } elseif ( '_post_to_only_existing_categories' === $meta_key ) { if ( isset( $meta_values[0] ) && $meta_values[0] ) { $post_to_only_existing_categories = true; } @@ -692,7 +701,7 @@ class MainWP_Helper { } //If categories exist, create them (second parameter of wp_create_categories adds the categories to the post) - include_once( ABSPATH . 'wp-admin/includes/taxonomy.php' ); //Contains wp_create_categories + include_once ABSPATH . 'wp-admin/includes/taxonomy.php'; //Contains wp_create_categories if ( isset( $post_category ) && '' !== $post_category ) { $categories = explode( ',', $post_category ); if ( count( $categories ) > 0 ) { @@ -727,7 +736,7 @@ class MainWP_Helper { 'post_excerpt' => $_image_data['caption'], 'post_content' => $_image_data['description'], 'post_title' => $_image_data['title'], - ) + ) ); } } @@ -923,10 +932,10 @@ class MainWP_Helper { // include_once( ABSPATH . '/wp-admin/includes/deprecated.php' ); // } if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } $creds = request_filesystem_credentials( 'test' ); ob_end_clean(); @@ -964,7 +973,7 @@ class MainWP_Helper { if ( ! $showHttp ) { $url = substr( $url, 7 ); } - } else if ( self::startsWith( $pUrl, 'https://' ) ) { + } elseif ( self::startsWith( $pUrl, 'https://' ) ) { if ( ! $showHttp ) { $url = substr( $url, 8 ); } @@ -1022,8 +1031,9 @@ class MainWP_Helper { //$agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'; $agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)'; - if (!is_array( $postdata )) + if (!is_array( $postdata )) { $postdata = array(); + } $postdata['json_result'] = true; // forced all response in json format @@ -1041,14 +1051,14 @@ class MainWP_Helper { if ( ( false === $data ) && ( 0 === $http_status ) ) { throw new Exception( 'Http Error: ' . $err ); - } else if ( preg_match( '/(.*)<\/mainwp>/', $data, $results ) > 0 ) { + } elseif ( preg_match( '/(.*)<\/mainwp>/', $data, $results ) > 0 ) { $result = $results[1]; $result_base = base64_decode( $result ); //$information = maybe_unserialize( $result_base ); $information = json_decode( $result_base, true ); // it is json_encode result return $information; - } else if ( '' === $data ) { + } elseif ( '' === $data ) { throw new Exception( __( 'Something went wrong while contacting the child site. Please check if there is an error on the child site. This error could also be caused by trying to clone or restore a site to large for your server settings.', 'mainwp-child' ) ); } else { throw new Exception( __( 'Child plugin is disabled or the security key is incorrect. Please resync with your main installation.', 'mainwp-child' ) ); @@ -1234,8 +1244,9 @@ class MainWP_Helper { static function update_lasttime_backup( $by, $time ) { $backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule'); - if (!in_array($by, $backup_by)) + if (!in_array($by, $backup_by)) { return false; + } $lasttime = get_option('mainwp_lasttime_backup_' . $by); if ( $time > $lasttime ) { @@ -1246,8 +1257,9 @@ class MainWP_Helper { } static function get_lasttime_backup( $by ) { - if ($by == 'backupwp') // to compatible + if ($by == 'backupwp') { // to compatible $by = 'backupwordpress'; + } switch($by) { case 'backupbuddy': if ( !is_plugin_active( 'backupbuddy/backupbuddy.php' ) && !is_plugin_active( 'Backupbuddy/backupbuddy.php' )) { @@ -1356,9 +1368,9 @@ class MainWP_Helper { if ( self::startsWith( $value, substr( $exclude, 0, strlen( $exclude ) - 1 ) ) ) { return true; } - } else if ( $value == $exclude ) { + } elseif ( $value == $exclude ) { return true; - } else if ( self::startsWith( $value, $exclude . '/' ) ) { + } elseif ( self::startsWith( $value, $exclude . '/' ) ) { return true; } } @@ -1444,7 +1456,8 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } public static function sanitize_filename( $filename ) { - if (!function_exists('mb_ereg_replace')) return sanitize_file_name($filename); + if (!function_exists('mb_ereg_replace')) { return sanitize_file_name($filename); + } // Remove anything which isn't a word, whitespace, number // or any of the following caracters -_~,;:[](). @@ -1515,14 +1528,16 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } public static function isSSLEnabled() { - if ( defined( 'MAINWP_NOSSL' ) ) return !MAINWP_NOSSL; + if ( defined( 'MAINWP_NOSSL' ) ) { return !MAINWP_NOSSL; + } return function_exists( 'openssl_verify' ); } public static function is_screen_with_update() { - if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined('DOING_CRON') && DOING_CRON ) ) + if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined('DOING_CRON') && DOING_CRON ) ) { return false; + } if (function_exists('get_current_screen')) { $screen = get_current_screen(); @@ -1555,10 +1570,11 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = if (!empty($missing)) { $message = 'Missing file(s): ' . implode(',', $missing); - if ($return) + if ($return) { return $message; - else + } else { throw new Exception( $message ); + } } return true; } @@ -1572,8 +1588,9 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } } } else { - if ( !class_exists($classes) ) + if ( !class_exists($classes) ) { $missing[] = $classes; + } } if ( !empty($missing) ) { @@ -1596,9 +1613,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = $missing[] = $name; } } - } else if (!empty($methods)) { - if ( !method_exists($object, $methods) ) + } elseif (!empty($methods)) { + if ( !method_exists($object, $methods) ) { $missing[] = $methods; + } } @@ -1622,9 +1640,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = $missing[] = $name; } } - } else if (!empty($properties)) { - if ( !property_exists($object, $properties) ) + } elseif (!empty($properties)) { + if ( !property_exists($object, $properties) ) { $missing[] = $properties; + } } @@ -1648,9 +1667,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = $missing[] = $name; } } - } else if (!empty($funcs)) { - if ( !function_exists($funcs) ) + } elseif (!empty($funcs)) { + if ( !function_exists($funcs) ) { $missing[] = $funcs; + } } diff --git a/class/class-mainwp-keyword-links.php b/class/class-mainwp-keyword-links.php index 7ae8f1f..99b77a9 100644 --- a/class/class-mainwp-keyword-links.php +++ b/class/class-mainwp-keyword-links.php @@ -95,13 +95,13 @@ class MainWP_Keyword_Links { function update_htaccess( $force_update = false, $force_clear = false ) { if ( $force_clear ) { $this->do_update_htaccess( true ); - } else if ( $force_update ) { + } elseif ( $force_update ) { return $this->do_update_htaccess(); } else { if ( '' == get_option( 'permalink_structure' ) && 'yes' !== get_option( 'mainwp_keyword_links_htaccess_set' ) ) { $this->do_update_htaccess(); } // need to update - else if ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { + elseif ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { $this->do_update_htaccess(); } // need to update } @@ -110,7 +110,7 @@ class MainWP_Keyword_Links { } public static function clear_htaccess() { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; $home_path = ABSPATH; $htaccess_file = $home_path . '.htaccess'; if ( function_exists( 'save_mod_rewrite_rules' ) ) { @@ -125,8 +125,8 @@ class MainWP_Keyword_Links { self::clear_htaccess(); return true; - } else if ( '' === get_option( 'permalink_structure' ) ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + } elseif ( '' === get_option( 'permalink_structure' ) ) { + include_once ABSPATH . '/wp-admin/includes/misc.php'; $redirection_folder = $this->get_option( 'redirection_folder', '' ); if ( empty( $redirection_folder ) ) { $rules = $this->get_cloak_rules(); @@ -534,7 +534,7 @@ class MainWP_Keyword_Links { } else { $links[] = $link; } - } else if ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link + } elseif ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link if ( $link->check_post_date ) { if ( $post_timestamp < $link->check_post_date ) { $links[] = $link; @@ -741,7 +741,7 @@ class MainWP_Keyword_Links { if ( $remove_settings ) { $this->clear_settings(); $return['status'] = 'SUCCESS'; - } else if ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) { + } elseif ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) { $new_keyword_links = array(); foreach ( $this->keyword_links as $link_id => $link ) { $lnk_kws = $link->keyword; @@ -853,7 +853,7 @@ class MainWP_Keyword_Links { if ( 3 === (int) $clear_link->type ) { $clear_link->type = 2; $cleared = $this->set_link( $clear_link->id, $clear_link ); - } else if ( 1 === (int) $clear_link->type ) { + } elseif ( 1 === (int) $clear_link->type ) { $cleared = $this->set_link( $clear_link->id, '' ); // delete link } $this->update_htaccess_for_change_cloak_links( $clear_link ); @@ -901,7 +901,7 @@ class MainWP_Keyword_Links { if ( 2 === (int) $link->type || 3 === (int) $link->type ) { if ( intval( $_POST['post_id'] ) ) { $link->post_id = intval( $_POST['post_id'] ); - } else if ( $old && $old->post_id ) { + } elseif ( $old && $old->post_id ) { $link->post_id = $old->post_id; } if ( $link->post_id ) { diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index 206e8dd..c194475 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -320,8 +320,9 @@ class MainWP_Security { public static function remove_readme( $force = false ) { // to prevent remove readme.html file on WPE hosts - if ( MainWP_Helper::is_wp_engine() ) + if ( MainWP_Helper::is_wp_engine() ) { return true; + } if ( $force || self::get_security_option( 'readme' ) ) { if ( @file_exists( ABSPATH . 'readme.html' ) ) { @@ -351,7 +352,8 @@ class MainWP_Security { //Admin user name is not admin public static function admin_user_ok() { $user = get_user_by( 'login', 'admin' ); - if ( ! $user ) return true; + if ( ! $user ) { return true; + } if ( 10 !== $user->wp_user_level && ( ! isset( $user->user_level ) || 10 !== $user->user_level ) && ! user_can( $user, 'level_10' ) ) { return true; @@ -362,8 +364,9 @@ class MainWP_Security { public static function update_security_option( $key, $value ) { $security = get_option( 'mainwp_security' ); - if ( !empty($key) ) + if ( !empty($key) ) { $security[$key] = $value; + } MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' ); } } diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index 0f1cb3b..7abfaee 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -58,7 +58,7 @@ class MainWP_Wordpress_SEO { $file_url = base64_decode( $_POST['file_url'] ); $temporary_file = ''; try { - include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url + include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url $temporary_file = download_url( $file_url ); if ( is_wp_error( $temporary_file ) ) { @@ -78,7 +78,7 @@ class MainWP_Wordpress_SEO { unlink( $temporary_file ); } - } else if ( isset( $_POST['settings'] ) ) { + } elseif ( isset( $_POST['settings'] ) ) { try { $settings = base64_decode( $_POST['settings'] ); // @codingStandardsIgnoreLine diff --git a/class/class-tar-archiver.php b/class/class-tar-archiver.php index c041b80..837e3d9 100644 --- a/class/class-tar-archiver.php +++ b/class/class-tar-archiver.php @@ -176,7 +176,7 @@ class Tar_Archiver { foreach ( $nodes as $key => $node ) { if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { unset( $nodes[ $key ] ); - } else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { + } elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { unset( $nodes[ $key ] ); } else { foreach ( $coreFiles as $coreFile ) { @@ -209,7 +209,7 @@ class Tar_Archiver { if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( is_dir( $node ) ) { $this->addDir( $node, $excludes ); - } else if ( is_file( $node ) ) { + } elseif ( is_file( $node ) ) { $this->addFile( $node, str_replace( ABSPATH, '', $node ) ); } } @@ -333,7 +333,7 @@ class Tar_Archiver { throw new Exception( 'Could not write to archive' ); } //@fflush($this->archive); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) { throw new Exception( 'Could not write to archive' ); } @@ -365,7 +365,7 @@ class Tar_Archiver { throw new Exception( 'Could not write to archive' ); } @fflush( $this->archive ); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { if ( false === @bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) { throw new Exception( 'Could not write to archive' ); } @@ -741,14 +741,14 @@ class Tar_Archiver { $startOffset = $rslt['startOffset']; @fseek( $this->archive, $startOffset ); @ftruncate( $this->archive, $startOffset ); - } else if ( 'tar.gz' == $this->type ) { + } elseif ( 'tar.gz' == $this->type ) { $readOffset = $rslt['readOffset']; $bytesRead = $rslt['bytesRead']; //@fseek($this->archive, $readOffset + $bytesRead); $out = array( 'bytesRead' => $bytesRead ); } - } else if ( false === $rslt ) { + } elseif ( false === $rslt ) { if ( 'tar' == $this->type ) { @fseek( $this->archive, 0, SEEK_END ); } @@ -820,7 +820,7 @@ class Tar_Archiver { } else { throw new Exception( 'Unexpected directory [' . $file['name'] . ']' ); } - } else if ( 0 == $file['type'] ) { + } elseif ( 0 == $file['type'] ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { $previousFtell = @ftell( $this->archive ); @@ -862,7 +862,7 @@ class Tar_Archiver { return $rslt; } - } else if ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) { + } elseif ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) { $this->log( 'Will append this: ' . print_r( $rslt, 1 ) ); return $rslt; @@ -906,7 +906,7 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { //$this->archive = @fopen('compress.zlib://' . $filepath, 'ab'); $this->archive = @gzopen( $filepath, 'wb' ); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { $this->archive = @bzopen( $filepath, 'w' ); } else { $this->archive = @fopen( $filepath, 'wb+' ); @@ -928,7 +928,7 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { //$this->archive = @fopen('compress.zlib://' . $filepath, 'ab'); $this->archive = @gzopen( $filepath, 'ab' ); - } else if ( $this->type == 'tar.bz2' ) { + } elseif ( $this->type == 'tar.bz2' ) { $this->archive = @bzopen( $filepath, 'a' ); } else { $this->archive = @fopen( $filepath, 'ab+' ); @@ -992,7 +992,7 @@ class Tar_Archiver { $this->type = 'tar.gz'; // $this->archive = @fopen('compress.zlib://' . $filepath, 'rb'); $this->archive = @gzopen( $filepath, 'r' ); - } else if ( 'tar.bz2' == substr( $filepath, - 7 ) ) { + } elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) { $this->type = 'tar.bz2'; $this->archive = @bzopen( $filepath, 'r' ); } else { @@ -1022,7 +1022,7 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { //@fclose($this->archive); @gzclose( $this->archive ); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { @bzclose( $this->archive ); } else { @fclose( $this->archive ); @@ -1065,7 +1065,7 @@ class Tar_Archiver { if ( $file['checksum'] == 0x00000000 ) { break; - } else if ( substr( $file['magic'], 0, 5 ) != 'ustar' ) { + } elseif ( substr( $file['magic'], 0, 5 ) != 'ustar' ) { // $this->error[] = "This script does not support extracting this type of tar file."; break; } @@ -1134,7 +1134,7 @@ class Tar_Archiver { if ( $file['checksum'] == 0x00000000 ) { break; - } else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { + } elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { // $this->error[] = "This script does not support extracting this type of tar file."; break; } @@ -1151,7 +1151,7 @@ class Tar_Archiver { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { return true; } - } else if ( 0 == $file['type'] ) { + } elseif ( 0 == $file['type'] ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { return true; } else { @@ -1198,7 +1198,7 @@ class Tar_Archiver { if ( $file['checksum'] == 0x00000000 ) { break; - } else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { + } elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { // $this->error[] = "This script does not support extracting this type of tar file."; break; } @@ -1217,7 +1217,7 @@ class Tar_Archiver { mkdir( $to . $file['name'], 0777, true ); } } - } else if ( 0 == $file['type'] ) { + } elseif ( 0 == $file['type'] ) { if ( ! is_dir( dirname( $to . $file['name'] ) ) ) { if ( ! empty( $wp_filesystem ) ) { $wp_filesystem->mkdir( dirname( $to . $file['name'] ), FS_CHMOD_DIR ); @@ -1306,16 +1306,16 @@ if ( class_exists( 'SplHeap' ) ) { if ( dirname( $pathA ) == dirname( $pathB ) ) { if ( is_file( $pathA ) && ! is_file( $pathB ) ) { return - 1; - } else if ( ! is_file( $pathA ) && is_file( $pathB ) ) { + } elseif ( ! is_file( $pathA ) && is_file( $pathB ) ) { return 1; } return strcmp( $pathA, $pathB ); - } else if ( $dirnameA == $dirnameB ) { + } elseif ( $dirnameA == $dirnameB ) { return strcmp( $pathA, $pathB ); - } else if ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) { + } elseif ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) { return 1; - } else if ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) { + } elseif ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) { return - 1; } else { $cmp = strcmp( $dirnameA, $dirnameB ); diff --git a/mainwp-child.php b/mainwp-child.php index af6d382..300b17c 100644 --- a/mainwp-child.php +++ b/mainwp-child.php @@ -8,7 +8,7 @@ Text Domain: mainwp-child Version: 4.0.7 */ -include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from WordPress +require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; //Version information from WordPress define( 'MAINWP_DEBUG', false ); @@ -25,7 +25,7 @@ function mainwp_child_autoload( $class_name ) { $autoload_path = sprintf( '%sclass-%s.php', $autoload_dir, strtolower( str_replace( '_', '-', $class_name ) ) ); if ( file_exists( $autoload_path ) ) { - require_once( $autoload_path ); + require_once $autoload_path; } } From 0b47709fe86e24882ac99ebf71cdb093897c052b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 15:14:04 +0100 Subject: [PATCH 67/98] Update phpcs.xml --- phpcs.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 6cf7339..2f257de 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -35,14 +35,14 @@ - - - - - - - - + + + + + + + + From 709ae78688285c7d2adc5fa1dbce5f99787e41eb Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 14:14:15 +0000 Subject: [PATCH 68/98] [CodeFactor] Apply fixes --- class/class-mainwp-backup.php | 6 +- class/class-mainwp-child-back-up-buddy.php | 179 +++---- .../class-mainwp-child-back-up-wordpress.php | 43 +- class/class-mainwp-child-back-wp-up.php | 43 +- class/class-mainwp-child-branding.php | 38 +- class/class-mainwp-child-ithemes-security.php | 73 +-- class/class-mainwp-child-links-checker.php | 25 +- class/class-mainwp-child-pagespeed.php | 8 +- class/class-mainwp-child-plugins-check.php | 2 +- .../class-mainwp-child-server-information.php | 70 +-- class/class-mainwp-child-skeleton-key.php | 17 +- class/class-mainwp-child-staging.php | 19 +- class/class-mainwp-child-themes-check.php | 9 +- class/class-mainwp-child-timecapsule.php | 72 +-- ...lass-mainwp-child-updraft-plus-backups.php | 141 +++--- ...ass-mainwp-child-vulnerability-checker.php | 7 +- .../class-mainwp-child-woocommerce-status.php | 56 +-- class/class-mainwp-child-wordfence.php | 126 ++--- class/class-mainwp-child-wp-rocket.php | 160 +++---- ...ass-mainwp-child-wpvivid-backuprestore.php | 5 +- class/class-mainwp-child.php | 435 ++++++++++-------- class/class-mainwp-clone-install.php | 26 +- class/class-mainwp-clone.php | 8 +- class/class-mainwp-custom-post-type.php | 4 +- class/class-mainwp-debug.php | 2 +- class/class-mainwp-helper.php | 102 ++-- class/class-mainwp-keyword-links.php | 18 +- class/class-mainwp-security.php | 9 +- class/class-mainwp-wordpress-seo.php | 4 +- class/class-tar-archiver.php | 42 +- mainwp-child.php | 4 +- 31 files changed, 960 insertions(+), 793 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index da1d5dd..41bcd46 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -158,7 +158,7 @@ class MainWP_Backup { public function _zipFilePcl( $files, $archive ) { //Zip this backup folder.. - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $archive ); $error = false; @@ -336,7 +336,7 @@ class MainWP_Backup { * @return bool */ public function createZipPclFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles ) { - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $filepath ); $nodes = glob( ABSPATH . '*' ); if ( ! $includeCoreFiles ) { @@ -531,7 +531,7 @@ class MainWP_Backup { unset( $nodes ); //Zip this backup folder.. - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $filepath ); $this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder ); if ( $addConfig ) { diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 6dd18af..dd1fbb1 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -105,8 +105,9 @@ class MainWP_Child_Back_Up_Buddy { } // ok function do_reports_log( $ext = '') { - if ($ext !== 'backupbuddy') + if ($ext !== 'backupbuddy') { return; + } if (!$this->is_backupbuddy_installed) { return; @@ -117,12 +118,14 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods( 'pb_backupbuddy', array( 'plugin_path' )); if ( ! class_exists( 'backupbuddy_core' ) ) { - if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') ) - require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' ); + if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/core.php') ) { + require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; + } } - if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php')) - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php')) { + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; + } MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'pb_backupbuddy_fileoptions' )); MainWP_Helper::check_methods('backupbuddy_core', 'getLogDirectory'); @@ -180,7 +183,7 @@ class MainWP_Child_Back_Up_Buddy { } if ( file_exists(pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php') ) { - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; MainWP_Helper::check_classes_exists(array( 'backupbuddy_live_periodic' )); MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats'); @@ -217,7 +220,7 @@ class MainWP_Child_Back_Up_Buddy { } if ( ! class_exists( 'backupbuddy_core' ) ) { - require_once( pb_backupbuddy::plugin_path() . '/classes/core.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; } if ( !isset( pb_backupbuddy::$options ) ) { @@ -692,8 +695,9 @@ class MainWP_Child_Back_Up_Buddy { function delete_profile() { $profile_id = $_POST['profile_id']; - if (isset(pb_backupbuddy::$options['profiles'][$profile_id])) + if (isset(pb_backupbuddy::$options['profiles'][$profile_id])) { unset(pb_backupbuddy::$options['profiles'][$profile_id]); + } pb_backupbuddy::save(); $information['result'] = 'SUCCESS'; @@ -764,8 +768,9 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) ); $plugin_path = pb_backupbuddy::plugin_path(); - if (file_exists($plugin_path . '/classes/core.php')) - require_once( $plugin_path . '/classes/core.php' ); + if (file_exists($plugin_path . '/classes/core.php')) { + require_once $plugin_path . '/classes/core.php'; + } } MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' )); @@ -810,7 +815,7 @@ class MainWP_Child_Back_Up_Buddy { } function backup_list() { - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $information = array(); $information['backup_list'] = $this->get_backup_list(); $information['recent_backup_list'] = $this->get_recent_backup_list(); @@ -825,7 +830,7 @@ class MainWP_Child_Back_Up_Buddy { function save_note() { if ( !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) { - require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' ); + require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); } $backup_file = $_POST['backup_file']; @@ -851,7 +856,7 @@ class MainWP_Child_Back_Up_Buddy { // Even if we cannot save the note into the archive file, store it in internal settings. $serial = backupbuddy_core::get_serial_from_file( $backup_file ); - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #24.' ); $backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' ); if ( true === ( $result = $backup_options->is_ok() ) ) { @@ -864,10 +869,11 @@ class MainWP_Child_Back_Up_Buddy { function get_hash() { $callback_data = $_POST['callback_data']; $file = backupbuddy_core::getBackupDirectory() . $callback_data; - if (file_exists($file)) + if (file_exists($file)) { return array( 'result' =>'SUCCESS', 'hash' => md5_file( $file ) ); - else + } else { return array( 'error' =>'Not found the file' ); + } } function zip_viewer() { @@ -883,7 +889,7 @@ class MainWP_Child_Back_Up_Buddy { $serial = $_POST[ 'serial' ]; $alerts = array(); // The fileoptions file that contains the file tree information - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt'; // Purge cache if too old. @@ -899,7 +905,7 @@ class MainWP_Child_Back_Up_Buddy { // Either we are getting cached file tree information or we need to create afresh if ( true !== ( $result = $fileoptions->is_ok() ) ) { // Get file listing. - require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' ); + require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( ABSPATH, array(), 'unzip' ); $files = pb_backupbuddy::$classes['zipbuddy']->get_file_list( backupbuddy_core::getBackupDirectory() . str_replace( '\\/', '', $zip_viewer ) ); $fileoptions->options = $files; @@ -1112,7 +1118,7 @@ class MainWP_Child_Back_Up_Buddy { $serial = backupbuddy_core::get_serial_from_file( $archive_file ); // serial of archive. $temp_file = uniqid(); // temp filename to extract into. - require_once( pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php' ); + require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; $zipbuddy = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); // Calculate temp directory & lock it down. @@ -1186,7 +1192,7 @@ class MainWP_Child_Back_Up_Buddy { global $wp_version; pb_backupbuddy::status( 'details', 'BackupBuddy v' . pb_backupbuddy::settings( 'version' ) . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.' ); - require( pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php' ); + require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php'; ob_start(); $result = backupbuddy_restore_files::restore( backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH ); @@ -1229,7 +1235,7 @@ class MainWP_Child_Back_Up_Buddy { $options = array(); if ( file_exists( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' ) ) { - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #33.' ); $backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true ); // Will create file to hold integrity data if nothing exists. } else { @@ -1375,7 +1381,7 @@ class MainWP_Child_Back_Up_Buddy { foreach( $recentBackups_list as $backup_fileoptions ) { - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #1.' ); $backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true ); if ( true !== ( $result = $backup->is_ok() ) ) { @@ -1555,7 +1561,7 @@ class MainWP_Child_Back_Up_Buddy { $serial = str_replace( '/\\', '', $serial ); pb_backupbuddy::load(); - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #27.' ); $optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt'; $backup_options = new pb_backupbuddy_fileoptions( $optionsFile, $read_only = true ); @@ -1851,7 +1857,7 @@ class MainWP_Child_Back_Up_Buddy { return array('error' => 'Invalid Profile. Not found.'); } - require_once( pb_backupbuddy::plugin_path() . '/classes/backup.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ]; @@ -1874,7 +1880,7 @@ class MainWP_Child_Back_Up_Buddy { } function start_backup() { - require_once( pb_backupbuddy::plugin_path() . '/classes/backup.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $data = $_POST['data']; if (is_array($data) && isset($data['serial_override'])) { @@ -1968,7 +1974,7 @@ class MainWP_Child_Back_Up_Buddy { function remote_delete() { $destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : null; if ($destination_id !== null) { - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $delete_response = pb_backupbuddy_destinations::delete_destination( $destination_id, true ); if ( $delete_response !== true ) { @@ -2026,7 +2032,7 @@ class MainWP_Child_Back_Up_Buddy { // For Stash we will check the quota prior to initiating send. if ( pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash' ) { // Pass off to destination handler. - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info( 'stash' ); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ); @@ -2093,17 +2099,17 @@ class MainWP_Child_Back_Up_Buddy { if ( 'cleanup_now' == $other_action ) { $message = 'Performing cleanup procedures now trimming old files and data.'; - require_once( pb_backupbuddy::plugin_path() . '/classes/housekeeping.php' ); + require_once pb_backupbuddy::plugin_path() . '/classes/housekeeping.php'; backupbuddy_housekeeping::run_periodic( 0 ); // 0 cleans up everything even if not very old. - } else if ( 'delete_tempfiles_now' == $other_action) { + } elseif ( 'delete_tempfiles_now' == $other_action) { $tempDir = backupbuddy_core::getTempDirectory(); $logDir = backupbuddy_core::getLogDirectory(); $message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.'; pb_backupbuddy::$filesystem->unlink_recursive( $tempDir ); pb_backupbuddy::$filesystem->unlink_recursive( $logDir ); pb_backupbuddy::anti_directory_browsing( $logDir, $die = false ); // Put log dir back in place. - } else if ( 'reset_log' == $other_action ) { + } elseif ( 'reset_log' == $other_action ) { $log_file = backupbuddy_core::getLogDirectory() . 'log-' . pb_backupbuddy::$options['log_serial'] . '.txt'; if ( file_exists( $log_file ) ) { @unlink( $log_file ); @@ -2113,13 +2119,13 @@ class MainWP_Child_Back_Up_Buddy { } else { // Unlinked. $message = 'Cleared log file.'; } - } else if ( 'reset_disalerts' == $other_action) { + } elseif ( 'reset_disalerts' == $other_action) { pb_backupbuddy::$options['disalerts'] = array(); pb_backupbuddy::save(); $message = 'Dismissed alerts have been reset. They may now be visible again.'; - } else if ( 'cancel_running_backups' == $other_action) { - require_once( pb_backupbuddy::plugin_path() . '/classes/fileoptions.php' ); + } elseif ( 'cancel_running_backups' == $other_action) { + require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; $fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/'; $files = glob( $fileoptions_directory . '*.txt' ); @@ -2470,9 +2476,9 @@ class MainWP_Child_Back_Up_Buddy { $errors[] = 'You must enter your iThemes username & password to log in to BackupBuddy Stash Live.'; } else { // Username and password provided. - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/class.itx_helper2.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/class.itx_helper2.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php'; global $wp_version; $itxapi_username = strtolower( $_POST['live_username'] ); @@ -2566,9 +2572,9 @@ class MainWP_Child_Back_Up_Buddy { $data = $_POST['data']; $new_destination_id = $_POST['destination_id']; - require_once( pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live.php' ); - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $destination_id = backupbuddy_live::getLiveID(); $destination_settings = isset(pb_backupbuddy::$options['remote_destinations'][$destination_id]) ? pb_backupbuddy::$options['remote_destinations'][$destination_id] : array(); @@ -2611,7 +2617,7 @@ class MainWP_Child_Back_Up_Buddy { unset( pb_backupbuddy::$options['remote_destinations'][ $liveDestinationID ] ); pb_backupbuddy::save(); // Clear cached Live credentials. - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/init.php'; delete_transient( pb_backupbuddy_destination_live::LIVE_ACTION_TRANSIENT_NAME ); } else { $error = 'Error: destination not found.'; @@ -2621,8 +2627,9 @@ class MainWP_Child_Back_Up_Buddy { $error = 'Error: Empty destination id.'; } - if (!empty($error)) + if (!empty($error)) { $return['error'] = $error; + } return $return; } @@ -2631,7 +2638,7 @@ class MainWP_Child_Back_Up_Buddy { $action = $_POST['live_action']; $error = $message = ''; - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $state = backupbuddy_live_periodic::get_stats(); $destination_id = backupbuddy_live::getLiveID(); @@ -2646,20 +2653,20 @@ class MainWP_Child_Back_Up_Buddy { $message = 'Log file cleared.'; } - } else if ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime ) + } elseif ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime ) if ( true === backupbuddy_api::runLiveSnapshot() ) { //pb_backupbuddy::alert( '

    ' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '

    ' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '

    ', false, '', 'backupbuddy_live_snapshot_verify_uptodate' ); $message = '

    ' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '

    ' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '

    '; - require( pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php' ); + require pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php'; } - } else if ( 'pause_periodic' == $action ) { + } elseif ( 'pause_periodic' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true ); $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. //pb_backupbuddy::disalert( '', __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ); - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - } else if ( 'resume_periodic' == $action ) { + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + } elseif ( 'resume_periodic' == $action ) { $launchNowText = ' ' . __( 'Unpaused but not running now.', 'it-l10n-backupbuddy' ); $start_run = false; if ( '1' != pb_backupbuddy::_GET( 'skip_run_live_now' ) ) { @@ -2670,17 +2677,17 @@ class MainWP_Child_Back_Up_Buddy { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run ); //pb_backupbuddy::disalert( '', __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText ); $message = __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText; - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - } else if ( 'pause_continuous' == $action ) { + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + } elseif ( 'pause_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = true, $pause_periodic = '' ); $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. //pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ); - } else if ( 'resume_continuous' == $action ) { + } elseif ( 'resume_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = false, $pause_periodic = '' ); $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. //pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ); } else { @@ -2693,7 +2700,7 @@ class MainWP_Child_Back_Up_Buddy { function download_troubleshooting() { - require( pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php' ); + require pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php'; backupbuddy_live_troubleshooting::run(); $output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true ); $backup_prefix = backupbuddy_core::backup_prefix(); @@ -2703,12 +2710,12 @@ class MainWP_Child_Back_Up_Buddy { function get_live_backups() { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php'; $settings = &pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; $settings = pb_backupbuddy_destination_stash2::_formatSettings( $settings ); @@ -2778,7 +2785,7 @@ class MainWP_Child_Back_Up_Buddy { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } @@ -2801,7 +2808,7 @@ class MainWP_Child_Back_Up_Buddy { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } @@ -2856,7 +2863,7 @@ class MainWP_Child_Back_Up_Buddy { if ( $time_since_last_activity > ( $detected_execution + backupbuddy_constants::TIMED_OUT_PROCESS_RESUME_WIGGLE_ROOM ) ) { // Enough time has passed to assume timed out. - require_once( pb_backupbuddy::plugin_path() . '/destinations/live/live.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php'; if ( false === ( $liveID = backupbuddy_live::getLiveID() ) ) { die( '-1' ); } @@ -2900,11 +2907,11 @@ class MainWP_Child_Back_Up_Buddy { $packages_name = array(); if (isset($GLOBALS['ithemes_updater_path'])) { - require_once( $GLOBALS['ithemes_updater_path'] . '/functions.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/api.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; - require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $details = Ithemes_Updater_Packages::get_full_details(); $packages = isset($details['packages']) ? $details['packages'] : array(); @@ -2927,11 +2934,11 @@ class MainWP_Child_Back_Up_Buddy { $return = array( 'ok' => 1 ); if (isset($GLOBALS['ithemes_updater_path'])) { - require_once( $GLOBALS['ithemes_updater_path'] . '/functions.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/api.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; - require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $response = Ithemes_Updater_API::activate_package( $username, $password, $packages ); @@ -2954,17 +2961,19 @@ class MainWP_Child_Back_Up_Buddy { $fail = array(); foreach ( $response['packages'] as $package => $data ) { - if ( preg_match( '/ \|\|\| \d+$/', $package ) ) + if ( preg_match( '/ \|\|\| \d+$/', $package ) ) { continue; + } $name = Ithemes_Updater_Functions::get_package_name( $package ); - if ( ! empty( $data['key'] ) ) + if ( ! empty( $data['key'] ) ) { $success[] = $name; - else if ( ! empty( $data['status'] ) && ( 'expired' == $data['status'] ) ) + } elseif ( ! empty( $data['status'] ) && ( 'expired' == $data['status'] ) ) { $warn[$name] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' ); - else + } else { $fail[$name] = $data['error']['message']; + } } if ( ! empty( $success ) ) { @@ -2973,14 +2982,16 @@ class MainWP_Child_Back_Up_Buddy { } if ( ! empty( $fail ) ) { - foreach ( $fail as $name => $reason ) + foreach ( $fail as $name => $reason ) { $errors[] = sprintf( __( 'Unable to license %1$s. Reason: %2$s', 'it-l10n-backupbuddy' ), $name, $reason ); + } $return['errors'] = $errors; } if ( ! empty( $warn ) ) { - foreach ( $warn as $name => $reason ) + foreach ( $warn as $name => $reason ) { $soft_errors[] = sprintf( __( 'Unable to license %1$s. Reason: %2$s', 'it-l10n-backupbuddy' ), $name, $reason ); + } $return['soft_errors'] = $soft_errors; } @@ -2998,11 +3009,11 @@ class MainWP_Child_Back_Up_Buddy { if (isset($GLOBALS['ithemes_updater_path'])) { - require_once( $GLOBALS['ithemes_updater_path'] . '/functions.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/api.php' ); - require_once( $GLOBALS['ithemes_updater_path'] . '/keys.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; + require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; - require_once( $GLOBALS['ithemes_updater_path'] . '/packages.php' ); + require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $response = Ithemes_Updater_API::deactivate_package($username, $password, $packages ); @@ -3024,17 +3035,19 @@ class MainWP_Child_Back_Up_Buddy { $fail = array(); foreach ( $response['packages'] as $package => $data ) { - if ( preg_match( '/ \|\|\| \d+$/', $package ) ) + if ( preg_match( '/ \|\|\| \d+$/', $package ) ) { continue; + } $name = Ithemes_Updater_Functions::get_package_name( $package ); - if ( isset( $data['status'] ) && ( 'inactive' == $data['status'] ) ) + if ( isset( $data['status'] ) && ( 'inactive' == $data['status'] ) ) { $success[] = $name; - else if ( isset( $data['error'] ) && isset( $data['error']['message'] ) ) + } elseif ( isset( $data['error'] ) && isset( $data['error']['message'] ) ) { $fail[$name] = $data['error']['message']; - else + } else { $fail[$name] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' ); + } } if ( ! empty( $success ) ) { @@ -3043,8 +3056,9 @@ class MainWP_Child_Back_Up_Buddy { } if ( ! empty( $fail ) ) { - foreach ( $fail as $name => $reason ) + foreach ( $fail as $name => $reason ) { $errors[] = sprintf( __( 'Unable to remove license from %1$s. Reason: %2$s', 'it-l10n-mainwp-backupbuddy' ), $name, $reason ); + } $return['errors'] = $errors; } @@ -3078,10 +3092,11 @@ class MainWP_Child_Back_Up_Buddy { } if ( empty( $message ) ) { - if ( ! empty( $package ) ) + if ( ! empty( $package ) ) { $message = sprintf( __( 'An unknown error relating to the %1$s product occurred. Please contact iThemes support. Error details: %2$s', 'it-l10n-mainwp-backupbuddy' ), $package_name, $error->get_error_message() . " ($code)" ); - else + } else { $message = sprintf( __( 'An unknown error occurred. Please contact iThemes support. Error details: %s', 'it-l10n-mainwp-backupbuddy' ), $error->get_error_message() . " ($code)" ); + } } return $message; diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index 7fb7860..df00422 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -29,7 +29,7 @@ class MainWP_Child_Back_Up_Wordpress { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) { $this->is_plugin_installed = true; if ( version_compare( phpversion(), '5.3', '>=' ) ) { @@ -43,7 +43,8 @@ class MainWP_Child_Back_Up_Wordpress { return; } - if (!$this->is_plugin_installed) return; + if (!$this->is_plugin_installed) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -201,8 +202,10 @@ class MainWP_Child_Back_Up_Wordpress { // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'backupwordpress' ) return; - if (!$this->is_plugin_installed) return; + if ( $ext !== 'backupwordpress' ) { return; + } + if (!$this->is_plugin_installed) { return; + } try { MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules'); @@ -314,14 +317,15 @@ class MainWP_Child_Back_Up_Wordpress { $schedule_id = $this->check_schedule(); if (function_exists('hmbkp_run_schedule_async')) { hmbkp_run_schedule_async($schedule_id); - } else if (function_exists('\HM\BackUpWordPress\run_schedule_async')) { + } elseif (function_exists('\HM\BackUpWordPress\run_schedule_async')) { HM\BackUpWordPress\Path::get_instance()->cleanup(); // Fixes an issue on servers which only allow a single session per client session_write_close(); $task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id ); $task->schedule(); - } else + } else { return array( 'error' => __('Error while trying to trigger the schedule', 'mainwp-child') ); + } return array( 'result' => 'SUCCESS' ); } @@ -392,10 +396,11 @@ class MainWP_Child_Back_Up_Wordpress { } } - if (function_exists('HM\BackUpWordPress\Backup::get_home_path')) + if (function_exists('HM\BackUpWordPress\Backup::get_home_path')) { $backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() ); - else + } else { $backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() ); + } $information['backups_path'] = $backups_path; $information['send_back_schedules'] = $send_back_schedules; @@ -533,7 +538,7 @@ class MainWP_Child_Back_Up_Wordpress { class="download-action"> | get_default_excludes() ) ) || ( HM\BackUpWordPress\Path::get_path() === trailingslashit( HM\BackUpWordPress\Path::get_root() ) . untrailingslashit( $exclude ) ); - else + } else { $is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ); + } if ( $is_default_rule ) : ?> @@ -676,8 +682,9 @@ class MainWP_Child_Back_Up_Wordpress { $exclude_string = implode( '|', $excludes->get_excludes_for_regex() ); - if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize')) + if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize')) { $files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes ); + } } else { $files = $schedule->list_directory_by_total_filesize( $directory ); @@ -1071,8 +1078,9 @@ class MainWP_Child_Back_Up_Wordpress { if (method_exists($excludes, 'get_user_excludes')) { $schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) ); - } else + } else { $schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) ); + } $schedule->save(); @@ -1103,8 +1111,9 @@ class MainWP_Child_Back_Up_Wordpress { $excl_rule = trim($excl_rule); $excl_rule = trim($excl_rule, '/'); - if (empty($excl_rule)) + if (empty($excl_rule)) { continue; + } $exclude_rule = ABSPATH . $excl_rule; $path = realpath($exclude_rule); @@ -1125,8 +1134,9 @@ class MainWP_Child_Back_Up_Wordpress { $exclude_rule_to_remove = trim($exclude_rule_to_remove); $exclude_rule_to_remove = trim($exclude_rule_to_remove, '/'); - if (empty($exclude_rule_to_remove)) + if (empty($exclude_rule_to_remove)) { continue; + } $excludes = $schedule->get_excludes(); if (method_exists($excludes, 'get_user_excludes')) { @@ -1210,8 +1220,9 @@ class MainWP_Child_Back_Up_Wordpress { $out = array(); foreach($schedules as $sch_id => $sch) { - if ( empty($sch_id) || !isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) + if ( empty($sch_id) || !isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) { continue; + } $options = $sch['options']; $filter_opts = array( 'type', diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 1a93178..647b423 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -66,7 +66,7 @@ class MainWP_Child_Back_WP_Up { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; try { @@ -80,14 +80,14 @@ class MainWP_Child_Back_WP_Up { } MainWP_Helper::check_files_exists(array( $file_path1, $file_path2 )); - require_once( $file_path1 ); - require_once( $file_path2 ); + require_once $file_path1; + require_once $file_path2; $this->is_backwpup_installed = true; $this->is_backwpup_pro = true; - } else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) { + } elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) { $file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php'; MainWP_Helper::check_files_exists(array( $file_path )); - require_once( $file_path ); + require_once $file_path; $this->is_backwpup_installed = true; } @@ -119,7 +119,7 @@ class MainWP_Child_Back_WP_Up { $info = self::$information; if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); - } else if ( ! empty( $info ) ) { + } elseif ( ! empty( $info ) ) { MainWP_Helper::write( self::$information ); } else { MainWP_Helper::write( array( 'error' => 'Missing information array inside fatal_error' ) ); @@ -218,8 +218,9 @@ class MainWP_Child_Back_WP_Up { public function init() { - if (!$this->is_backwpup_installed) + if (!$this->is_backwpup_installed) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -238,9 +239,11 @@ class MainWP_Child_Back_WP_Up { } // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'backwpup' ) return; - if (!$this->is_backwpup_installed) + if ( $ext !== 'backwpup' ) { return; + } + if (!$this->is_backwpup_installed) { return; + } try { @@ -269,8 +272,9 @@ class MainWP_Child_Back_WP_Up { $log_items = array(); foreach ( $logfiles as $mtime => $logfile ) { $meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile ); - if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged) + if (!isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged) { continue; + } if (isset($meta['errors']) && !empty($meta['errors'])) { continue; // do not logging backups have errors @@ -313,8 +317,9 @@ class MainWP_Child_Back_WP_Up { $message = 'BackWPup backup finished (' . $backup_type . ')'; do_action( 'mainwp_reports_backwpup_backup', $message, $backup_type, $backup_time ); - if ($new_lasttime_logged < $backup_time) + if ($new_lasttime_logged < $backup_time) { $new_lasttime_logged = $backup_time; + } } if ($new_lasttime_logged > $lasttime_logged ) { @@ -744,7 +749,7 @@ class MainWP_Child_Back_WP_Up { $temp_array['website_id'] = $website_id; $array[] = $temp_array; } - } else if ( $type == 'backups' ) { + } elseif ( $type == 'backups' ) { $without_dupes = array(); foreach ( $output->items as $key ) { $temp_array = $key; @@ -973,7 +978,7 @@ class MainWP_Child_Back_WP_Up { } if ( ! class_exists( 'WP_List_Table' ) ) { - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; } } @@ -1136,9 +1141,9 @@ class MainWP_Child_Back_WP_Up { if ( $dir = @opendir( $main_folder_name ) ) { while ( ( $file = readdir( $dir ) ) !== false ) { if ( ! in_array( $file, array( - '.', - '..', - ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) + '.', + '..', + ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) { $folder_size = ' (' . size_format( BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')'; @@ -1394,7 +1399,7 @@ class MainWP_Child_Back_WP_Up { $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); BackWPup_Admin::message( sprintf( __( 'Changes for job %s saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' ' . __( 'Jobs overview', 'backwpup' ) . ' | ' . __( 'Run now', 'backwpup' ) . '' ); } - } else if ($settings['tab'] == 'dest-DROPBOX') { + } elseif ($settings['tab'] == 'dest-DROPBOX') { unset($settings['value']); // do not save dropbox settings BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); } else { @@ -1436,7 +1441,7 @@ class MainWP_Child_Back_WP_Up { if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) { $changes_array[ $key ] = $temp_value; } - } else if ( strcmp( $temp_value, $val ) != 0 ) { + } elseif ( strcmp( $temp_value, $val ) != 0 ) { $changes_array[ $key ] = $temp_value; } } @@ -1518,7 +1523,7 @@ class MainWP_Child_Back_WP_Up { if ( isset( $message['error'] ) ) { return array( 'error' => implode( ', ', $message['error'] ) ); - } else if ( isset( $message['updated'] ) ) { + } elseif ( isset( $message['updated'] ) ) { return array( 'message' => $message['updated'] ); } else { return array( 'error' => 'Generic error' ); diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 9e007f9..c03d54d 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -66,8 +66,9 @@ class MainWP_Child_Branding { $extra = array(); if (is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings'])) { $extra = $this->child_branding_options['extra_settings']; - if (!is_array($extra)) + if (!is_array($extra)) { $extra = array(); + } } return $extra; @@ -279,7 +280,7 @@ class MainWP_Child_Branding { $information['error']['login_image'] = $e->getMessage(); } } - } else if ( isset( $current_extra_setting['login_image'] ) ) { + } elseif ( isset( $current_extra_setting['login_image'] ) ) { $extra_setting['login_image'] = $current_extra_setting['login_image']; } @@ -302,7 +303,7 @@ class MainWP_Child_Branding { $information['error']['favico_image'] = $e->getMessage(); } } - } else if ( isset( $current_extra_setting['favico_image'] ) ) { + } elseif ( isset( $current_extra_setting['favico_image'] ) ) { $extra_setting['favico_image'] = $current_extra_setting['favico_image']; } @@ -347,7 +348,7 @@ class MainWP_Child_Branding { } static function uploadImage( $img_url ) { - include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url + include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url global $mainWPChild; add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 ); //Download $img_url @@ -382,7 +383,7 @@ class MainWP_Child_Branding { if (is_admin()) { // back end add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) ); - } else if (is_user_logged_in()) { + } elseif (is_user_logged_in()) { // front end add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' )); } @@ -474,7 +475,7 @@ class MainWP_Child_Branding { function admin_menu() { $allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false); if ( $allow_contact ) {; // ok - } else if ( !current_user_can( 'administrator' ) ) { + } elseif ( !current_user_can( 'administrator' ) ) { return false; } @@ -805,8 +806,9 @@ class MainWP_Child_Branding { if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) { global $current_user; $headers .= "Content-Type: text/html;charset=utf-8\r\n"; - if (!empty($from)) + if (!empty($from)) { $headers .= 'From: "' . $from . '" <' . $from . ">\r\n"; + } $mail .= "

    Support Email from: " . site_url() . "

    \r\n\r\n"; $mail .= '

    Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "

    \r\n\r\n" : '' ); $mail .= '

    Client Email: ' . $current_user->user_email . "

    \r\n\r\n"; @@ -892,12 +894,12 @@ class MainWP_Child_Branding { 'mainwp_branding_contact_message_content', - 'textarea_rows' => 10, - 'teeny' => true, - 'wpautop' => true, - 'media_buttons' => false, - ) + 'textarea_name' => 'mainwp_branding_contact_message_content', + 'textarea_rows' => 10, + 'teeny' => true, + 'wpautop' => true, + 'media_buttons' => false, + ) ); ?> @@ -925,7 +927,7 @@ class MainWP_Child_Branding { public function add_support_button_in_top_admin_bar( $wp_admin_bar ) { $allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false); if ( $allow_contact ) {; // ok - } else if ( !current_user_can( 'administrator' ) ) { + } elseif ( !current_user_can( 'administrator' ) ) { return false; } @@ -995,15 +997,16 @@ class MainWP_Child_Branding { $hide_slugs = apply_filters('mainwp_child_hide_update_notice', array()); - if (!is_array($hide_slugs)) + if (!is_array($hide_slugs)) { $hide_slugs = array(); + } if (count($hide_slugs) == 0) { return; } if (!function_exists('get_plugin_updates')) { - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; } $count_hide = 0; @@ -1047,8 +1050,9 @@ class MainWP_Child_Branding { $hide_slugs = apply_filters('mainwp_child_hide_update_notice', array()); - if (!is_array($hide_slugs)) + if (!is_array($hide_slugs)) { $hide_slugs = array(); + } $count_hide = 0; diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index 73d9df8..0e292f1 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -28,13 +28,14 @@ class MainWP_Child_iThemes_Security { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } @@ -130,8 +131,9 @@ class MainWP_Child_iThemes_Security { } public function ithemes_init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); @@ -177,7 +179,7 @@ class MainWP_Child_iThemes_Security { function save_settings() { if ( ! class_exists( 'ITSEC_Lib' ) ) { - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $_itsec_modules = array( @@ -214,7 +216,7 @@ class MainWP_Child_iThemes_Security { if (in_array($module, $_itsec_modules)) { if ($module == 'wordpress-salts') { $settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update - } else if ($module == 'global') { + } elseif ($module == 'global') { $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' ); foreach($keep_olds as $key) { $settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update @@ -230,7 +232,7 @@ class MainWP_Child_iThemes_Security { } } - } else if ($module == 'backup') { + } elseif ($module == 'backup') { if (!isset($settings['location']) || empty($settings['location']) ) { $settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); } else { @@ -244,7 +246,7 @@ class MainWP_Child_iThemes_Security { $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' ); } - } else if ($module == 'hide-backend') { + } elseif ($module == 'hide-backend') { if (isset($settings['enabled']) && !empty($settings['enabled'])) { $permalink_structure = get_option( 'permalink_structure', false ); if ( empty( $permalink_structure ) && ! is_multisite() ) { @@ -253,7 +255,7 @@ class MainWP_Child_iThemes_Security { $do_not_save = true; } } - } else if ($module == 'network-brute-force') { + } elseif ($module == 'network-brute-force') { if ( isset( $settings['email'] ) ) { $result = $this->activate_api_key($settings); @@ -275,7 +277,7 @@ class MainWP_Child_iThemes_Security { } } $settings = $nbf_settings; - } else if ($module == 'notification-center') { + } elseif ($module == 'notification-center') { $current_settings = ITSEC_Modules::get_settings( $module ); if (isset($settings['notifications'])) { $update_fields = array( 'schedule', 'enabled', 'subject'); @@ -310,7 +312,7 @@ class MainWP_Child_iThemes_Security { update_site_option( 'itsec_active_modules', $current_val ); } - require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); + require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $values = array( 'permalink_structure' => get_option( 'permalink_structure' ), @@ -344,10 +346,11 @@ class MainWP_Child_iThemes_Security { $return['extra_message'] = $errors; } - if ($updated) + if ($updated) { $return['result'] = 'success'; - else + } else { $return['error'] = __('Not Updated', 'mainwp-child' ); + } return $return; } @@ -363,7 +366,7 @@ class MainWP_Child_iThemes_Security { $results = ITSEC_Modules::set_settings( 'network-brute-force', $settings ); if ( is_wp_error( $results ) ) { $information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key'; - } else if ( $results['saved'] ) { + } elseif ( $results['saved'] ) { ITSEC_Modules::activate( 'network-brute-force' ); $nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' ); // ITSEC_Response::set_response( '

    ' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '

    ' ); @@ -377,7 +380,7 @@ class MainWP_Child_iThemes_Security { } private function validate_directory( $name, $folder) { - require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' ); + require_once ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php'; $error = null; if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) { $result = ITSEC_Lib_Directory::create( $folder ); @@ -401,7 +404,7 @@ class MainWP_Child_iThemes_Security { private function activate_api_key( $settings) { global $mainwp_itsec_modules_path; - require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' ); + require_once $mainwp_itsec_modules_path . 'ipcheck/utilities.php'; $key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] ); if ( is_wp_error( $key ) ) { @@ -495,7 +498,7 @@ class MainWP_Child_iThemes_Security { global $itsec_backup, $mainwp_itsec_modules_path; if ( ! isset( $itsec_backup ) ) { - require_once ( $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php' ); + require_once $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php'; $itsec_backup = new ITSEC_Backup(); $itsec_backup->run(); } @@ -511,7 +514,7 @@ class MainWP_Child_iThemes_Security { foreach ( $errors as $error ) { $str_error .= $error . '
    '; } - } else if ( is_string( $result ) ) { + } elseif ( is_string( $result ) ) { $return['result'] = 'success'; $return['message'] = $result; } else { @@ -529,7 +532,7 @@ class MainWP_Child_iThemes_Security { private function wordpress_salts() { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) { - require( $mainwp_itsec_modules_path . 'salts/utilities.php' ); + require $mainwp_itsec_modules_path . 'salts/utilities.php'; } $result = ITSEC_WordPress_Salts_Utilities::generate_new_salts(); $str_error = ''; @@ -552,7 +555,7 @@ class MainWP_Child_iThemes_Security { } private function file_permissions() { - require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); + require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $wp_upload_dir = ITSEC_Core::get_wp_upload_dir(); @@ -673,7 +676,7 @@ class MainWP_Child_iThemes_Security { public function file_change() { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'file-change/scanner.php' ); + require_once $mainwp_itsec_modules_path . 'file-change/scanner.php'; } $result = ITSEC_File_Change_Scanner::run_scan( false ); if ($result === false || $result === true || $result === -1) { @@ -687,8 +690,9 @@ class MainWP_Child_iThemes_Security { $settings = $_POST['settings']; - if (!is_array($settings)) + if (!is_array($settings)) { $settings = array(); + } $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; @@ -696,7 +700,7 @@ class MainWP_Child_iThemes_Security { //load utility functions if ( ! class_exists( 'ITSEC_Lib' ) ) { global $itsec_globals; - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $username_exists = username_exists( 'admin' ); @@ -706,7 +710,7 @@ class MainWP_Child_iThemes_Security { global $current_user; if ( ! $username_exists ) { $msg = __( 'Admin user already changes.', 'mainwp-child' ); - } else if ($current_user->user_login == 'admin') { + } elseif ($current_user->user_login == 'admin') { $return['result'] = 'CHILD_ADMIN'; return $return; } @@ -871,7 +875,7 @@ class MainWP_Child_iThemes_Security { public function change_database_prefix() { global $mainwp_itsec_modules_path; - require_once( $mainwp_itsec_modules_path . 'database-prefix/utility.php' ); + require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php'; $str_error = ''; $return = array(); @@ -929,7 +933,7 @@ class MainWP_Child_iThemes_Security { if ( $results['saved'] ) { $information['result'] = 'success'; $information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force'); - } else if ( empty( $results['errors'] ) ) { + } elseif ( empty( $results['errors'] ) ) { $information['error_reset_api'] = 1; } return $information; @@ -939,8 +943,8 @@ class MainWP_Child_iThemes_Security { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' ); - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' ); + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php'; + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php'; } $response = array(); @@ -958,8 +962,8 @@ class MainWP_Child_iThemes_Security { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' ); - require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' ); + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php'; + require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php'; } $response = array(); $results= ITSEC_Malware_Scanner::scan(); @@ -1061,7 +1065,7 @@ class MainWP_Child_iThemes_Security { global $wpdb; if ( ! class_exists( 'ITSEC_Lib' ) ) { - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $lockout_ids = $_POST['lockout_ids']; @@ -1088,7 +1092,7 @@ class MainWP_Child_iThemes_Security { if ( ! is_multisite() ) { if ( ! function_exists( 'add_settings_error' ) ) { - require_once( ABSPATH . '/wp-admin/includes/template.php' ); + require_once ABSPATH . '/wp-admin/includes/template.php'; } add_settings_error( 'itsec', esc_attr( 'settings_updated' ), $message, $type ); @@ -1103,8 +1107,9 @@ class MainWP_Child_iThemes_Security { $active_modules = $_POST['active_modules']; - if (!is_array($active_modules)) + if (!is_array($active_modules)) { $active_modules = array(); + } $current_val = get_site_option( 'itsec_active_modules', array() ); foreach ($active_modules as $mod => $val) { @@ -1164,8 +1169,8 @@ class MainWP_Child_iThemes_Security { private function security_site() { global $mainwp_itsec_modules_path; - require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' ); - require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' ); + require_once $mainwp_itsec_modules_path . 'security-check/scanner.php'; + require_once $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php'; $results = ITSEC_Security_Check_Scanner::get_results(); ob_start(); ITSEC_Security_Check_Feedback_Renderer::render( $results ); diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index 7b8cfe5..e8c45b3 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -27,13 +27,14 @@ class MainWP_Child_Links_Checker { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) { $this->is_plugin_installed = true; } - if ( !$this->is_plugin_installed ) + if ( !$this->is_plugin_installed ) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } @@ -222,14 +223,16 @@ class MainWP_Child_Links_Checker { function get_sync_data( $strategy = '' ) { $information = array(); $data = $this->get_count_links(); - if (is_array($data)) + if (is_array($data)) { $information['data'] = $data; + } return $information; } function get_links_data() { - if (!defined('BLC_DIRECTORY')) return; + if (!defined('BLC_DIRECTORY')) { return; + } $file_path1 = BLC_DIRECTORY . '/includes/link-query.php'; $file_path2 = BLC_DIRECTORY . '/includes/modules.php'; @@ -251,9 +254,9 @@ class MainWP_Child_Links_Checker { $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $params = array( - array( 'load_instances' => true ), - 'max_results' => $max_results, - ); + array( 'load_instances' => true ), + 'max_results' => $max_results, + ); if (empty($offset)) { $first_sync = true; @@ -288,7 +291,8 @@ class MainWP_Child_Links_Checker { } function get_count_links() { - if (!defined('BLC_DIRECTORY')) return; + if (!defined('BLC_DIRECTORY')) { return; + } $file_path1 = BLC_DIRECTORY . '/includes/link-query.php'; $file_path2 = BLC_DIRECTORY . '/includes/modules.php'; @@ -638,7 +642,7 @@ class MainWP_Child_Links_Checker { function ui_get_source( $container, $container_field = '' ) { if ( 'comment' === $container->container_type ) { return $this->ui_get_source_comment( $container, $container_field ); - } else if ( $container instanceof blcAnyPostContainer ) { + } elseif ( $container instanceof blcAnyPostContainer ) { return $this->ui_get_source_post( $container, $container_field ); } @@ -653,8 +657,9 @@ class MainWP_Child_Links_Checker { $image = 'font-awesome/font-awesome-comment-alt.png'; } - if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true )) + if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true )) { return false; + } $comment = $container->get_wrapped_object(); diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index b104672..466a169 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -29,13 +29,14 @@ class MainWP_Child_Pagespeed { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); @@ -75,8 +76,9 @@ class MainWP_Child_Pagespeed { } public function init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'hide_plugin' ) ); diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php index 24fa93c..3efb52a 100644 --- a/class/class-mainwp-child-plugins-check.php +++ b/class/class-mainwp-child-plugins-check.php @@ -279,7 +279,7 @@ class MainWP_Child_Plugins_Check { //Some of this code is lifted from class-wp-upgrader //Get the WordPress current version to be polite in the API call - include( ABSPATH . WPINC . '/version.php' ); + include ABSPATH . WPINC . '/version.php'; global $wp_version; diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index 64fd86f..7127ff7 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -19,10 +19,11 @@ class MainWP_Child_Server_Information { } if ( $_POST['what'] == 'warning' ) { - if (isset($_POST['warnings'])) + if (isset($_POST['warnings'])) { $warnings = intval($_POST['warnings']); - else + } else { $warnings = self::getWarnings(); + } $dismissWarnings['warnings'] = $warnings; } MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings ); @@ -826,7 +827,7 @@ class MainWP_Child_Server_Information { if ( $isBranding ) { if ( $slug == 'mainwp-child/mainwp-child.php' ) { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ); - } else if ($slug == 'mainwp-child-reports/mainwp-child-reports.php') { + } elseif ($slug == 'mainwp-child-reports/mainwp-child-reports.php') { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports'; } } @@ -905,7 +906,7 @@ class MainWP_Child_Server_Information { } protected static function getMainwpVersion() { - include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' ); + include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; $api = plugins_api( 'plugin_information', array( 'slug' => 'mainwp-child', 'fields' => array( 'sections' => false ), @@ -966,8 +967,9 @@ class MainWP_Child_Server_Information { protected static function checkDirectoryMainWPDirectory( $write = true ) { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') + if ($branding_title == '') { $branding_title = 'MainWP'; + } $branding_title .= ' Upload Directory'; @@ -1052,9 +1054,9 @@ class MainWP_Child_Server_Information {
    - + - + @@ -1349,8 +1351,9 @@ class MainWP_Child_Server_Information { } if ( empty( $test_result ) ) { _e( 'Response Test O.K.', 'mainwp-child' ); - } else + } else { echo $test_result; + } } @@ -1624,42 +1627,43 @@ class MainWP_Child_Server_Information { public static function renderConnectionDetails() { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') + if ($branding_title == '') { $branding_title = 'MainWP'; + } global $current_user; $uniqueId = get_option('mainwp_child_uniqueId'); $details = array( 'siteurl' => array( - 'title' => __('Site URL', 'mainwp-child'), - 'value' => get_bloginfo( 'url' ), - 'desc' => get_bloginfo( 'url' ), - ), + 'title' => __('Site URL', 'mainwp-child'), + 'value' => get_bloginfo( 'url' ), + 'desc' => get_bloginfo( 'url' ), + ), 'adminuser' => array( - 'title' => __('Administrator name', 'mainwp-child'), - 'value' => $current_user->user_login, - 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), - ), + 'title' => __('Administrator name', 'mainwp-child'), + 'value' => $current_user->user_login, + 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), + ), 'friendly_name' => array( - 'title' => __('Friendly site name', 'mainwp-child'), - 'value' => get_bloginfo( 'name' ), - 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), - ), + 'title' => __('Friendly site name', 'mainwp-child'), + 'value' => get_bloginfo( 'name' ), + 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), + ), 'uniqueid' => array( - 'title' => __('Child unique security id', 'mainwp-child'), - 'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), - 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), - ), + 'title' => __('Child unique security id', 'mainwp-child'), + 'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), + 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), + ), 'verify_ssl' => array( - 'title' => __('Verify certificate', 'mainwp-child'), - 'value' => __('Yes', 'mainwp-child'), - 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), - ), + 'title' => __('Verify certificate', 'mainwp-child'), + 'value' => __('Yes', 'mainwp-child'), + 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), + ), 'ssl_version' => array( - 'title' => __('SSL version', 'mainwp-child'), - 'value' => __('Auto Detect', 'mainwp-child'), - 'desc' => __('Auto Detect', 'mainwp-child'), - ), + 'title' => __('SSL version', 'mainwp-child'), + 'value' => __('Auto Detect', 'mainwp-child'), + 'desc' => __('Auto Detect', 'mainwp-child'), + ), ); ?> diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php index ae64d7c..3398b44 100644 --- a/class/class-mainwp-child-skeleton-key.php +++ b/class/class-mainwp-child-skeleton-key.php @@ -189,18 +189,21 @@ class MainWP_Child_Skeleton_Key { public function save_settings() { $settings = isset($_POST['settings']) ? $_POST['settings'] : array(); - if (!is_array($settings) || empty($settings)) + if (!is_array($settings) || empty($settings)) { return array('error' => 'Invalid data. Please check and try again.'); + } $whitelist_options = array( 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ), ); if ( !is_multisite() ) { - if ( !defined( 'WP_SITEURL' ) ) + if ( !defined( 'WP_SITEURL' ) ) { $whitelist_options['general'][] = 'siteurl'; - if ( !defined( 'WP_HOME' ) ) + } + if ( !defined( 'WP_HOME' ) ) { $whitelist_options['general'][] = 'home'; + } $whitelist_options['general'][] = 'admin_email'; $whitelist_options['general'][] = 'users_can_register'; @@ -212,7 +215,7 @@ class MainWP_Child_Skeleton_Key { // Handle translation install. if ( ! empty( $settings['WPLANG'] ) ) { - require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); + require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if ( wp_can_install_language_pack() ) { $language = wp_download_language_pack( $settings['WPLANG'] ); if ( $language ) { @@ -224,16 +227,18 @@ class MainWP_Child_Skeleton_Key { $updated = false; foreach($settings as $option => $value) { if (in_array($option, $whitelist_general)) { - if ( ! is_array( $value ) ) + if ( ! is_array( $value ) ) { $value = trim( $value ); + } $value = wp_unslash( $value ); update_option($option, $value); $updated = true; } } - if (!$updated) + if (!$updated) { return false; + } return array('result' => 'ok'); } diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index 477a668..17516c2 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -29,26 +29,29 @@ class MainWP_Child_Staging { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR')) { $this->is_plugin_installed = true; - } else if ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) { + } elseif ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } public function init() { - if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) + if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) { return; + } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); @@ -299,9 +302,9 @@ class MainWP_Child_Staging { $delete->setData(); $clone = $delete->getClone(); $result = array( - 'clone' => $clone, - 'deleteTables' => $delete->getTables(), - ); + 'clone' => $clone, + 'deleteTables' => $delete->getTables(), + ); return $result; } diff --git a/class/class-mainwp-child-themes-check.php b/class/class-mainwp-child-themes-check.php index a46a984..acf9807 100644 --- a/class/class-mainwp-child-themes-check.php +++ b/class/class-mainwp-child-themes-check.php @@ -125,7 +125,7 @@ class MainWP_Child_Themes_Check { $themes_outdate = array(); } if ( ! function_exists( 'wp_get_themes' ) ) { - require_once( ABSPATH . '/wp-admin/includes/theme.php' ); + require_once ABSPATH . '/wp-admin/includes/theme.php'; } $themes = wp_get_themes(); $update = false; @@ -144,7 +144,7 @@ class MainWP_Child_Themes_Check { public function run_check() { if ( ! function_exists( 'wp_get_themes' ) ) { - require_once( ABSPATH . '/wp-admin/includes/theme.php' ); + require_once ABSPATH . '/wp-admin/includes/theme.php'; } //Get our previous results @@ -177,7 +177,8 @@ class MainWP_Child_Themes_Check { $tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); foreach ( $themes_to_scan as $slug => $v ) { - if ( in_array( $slug, $avoid_themes ) ) continue; + if ( in_array( $slug, $avoid_themes ) ) { continue; + } $body = $this->try_get_response_body( $slug, false ); @@ -226,7 +227,7 @@ class MainWP_Child_Themes_Check { private function try_get_response_body( $theme ) { //Get the WordPress current version to be polite in the API call - include( ABSPATH . WPINC . '/version.php' ); + include ABSPATH . WPINC . '/version.php'; $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/'; if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index a2ad5cb..7dfcc73 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -26,24 +26,27 @@ class MainWP_Child_Timecapsule { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) && defined('WPTC_CLASSES_DIR')) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } public function init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } - if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) + if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -240,8 +243,9 @@ class MainWP_Child_Timecapsule { public function syncOthersData( $information, $data = array() ) { if ( isset( $data['syncWPTimeCapsule'] ) && $data['syncWPTimeCapsule'] ) { $information['syncWPTimeCapsule'] = $this->get_sync_data(); - if (get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y') + if (get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y') { MainWP_Helper::update_option( 'mainwp_time_capsule_ext_enabled', 'Y', 'yes' ); + } } return $information; } @@ -276,13 +280,13 @@ class MainWP_Child_Timecapsule { } $return = array( - 'main_account_email' => $main_account_email_var, - 'signed_in_repos' => $wptc_settings->get_connected_cloud_info(), - 'plan_name' => $options_helper->get_plan_interval_from_subs_info(), - 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), - 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, - 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), - 'backups_count' => $backups_count, + 'main_account_email' => $main_account_email_var, + 'signed_in_repos' => $wptc_settings->get_connected_cloud_info(), + 'plan_name' => $options_helper->get_plan_interval_from_subs_info(), + 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), + 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, + 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), + 'backups_count' => $backups_count, ); return $return; } catch ( Exception $e) { @@ -418,7 +422,7 @@ function start_restore_tc_callback_wptc() { $request = $_POST['data']; } - include_once ( WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php' ); + include_once WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php'; new WPTC_Prepare_Restore_Bridge($request); } @@ -508,7 +512,7 @@ function get_sibling_files_callback_wptc() { return array( 'items' => $wpdb->get_results($query), 'totalitems' => $totalitems, 'perpage' => $perpage, - ); + ); } @@ -556,8 +560,9 @@ function get_sibling_files_callback_wptc() { function get_display_rows( $records) { global $wpdb; //Get the records registered in the prepare_items method - if (!is_array($records)) + if (!is_array($records)) { return ''; + } $i=0; $limit = WPTC_Factory::get('config')->get_option('activity_log_lazy_load_limit'); @@ -603,10 +608,10 @@ function get_sibling_files_callback_wptc() { if (!(strpos($rec->type, 'backup') === false)) { //Backup process $msg = 'Backup Process'; - } else if (!(strpos($rec->type, 'restore') === false)) { + } elseif (!(strpos($rec->type, 'restore') === false)) { //Restore Process $msg = 'Restore Process'; - } else if (!(strpos($rec->type, 'staging') === false)) { + } elseif (!(strpos($rec->type, 'staging') === false)) { //Restore Process $msg = 'Staging Process'; } else { @@ -703,10 +708,12 @@ function get_sibling_files_callback_wptc() { // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'wptimecapsule' ) return; + if ( $ext !== 'wptimecapsule' ) { return; + } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } try { MainWP_Helper::check_classes_exists(array( 'WPTC_Factory')); @@ -723,8 +730,9 @@ function get_sibling_files_callback_wptc() { $last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago $lasttime_logged = MainWP_Helper::get_lasttime_backup('wptimecapsule'); - if (empty($lasttime_logged)) + if (empty($lasttime_logged)) { $last_time = time() - 24 * 7 * 8 * 60 * 60; // 8 weeks ago + } $all_last_backups = $this->getBackups( $last_time ); @@ -977,8 +985,9 @@ function get_sibling_files_callback_wptc() { $config->set_option('schedule_time_str', $data['schedule_time_str']); if(!empty($data['schedule_time_str']) && !empty($data['wptc_timezone']) ){ - if (function_exists('wptc_modify_schedule_backup')) + if (function_exists('wptc_modify_schedule_backup')) { wptc_modify_schedule_backup(); + } } $notice = apply_filters('check_requirements_auto_backup_wptc', ''); @@ -989,7 +998,7 @@ function get_sibling_files_callback_wptc() { $saved = true; - } else if ( $tabName == 'backup_auto' ) { // update_auto_update_settings() + } elseif ( $tabName == 'backup_auto' ) { // update_auto_update_settings() $config->set_option('backup_before_update_setting', $data['backup_before_update_setting']); @@ -1006,20 +1015,22 @@ function get_sibling_files_callback_wptc() { $current['update_settings']['plugins']['status'] = $new['update_settings']['plugins']['status']; if (!$is_general) { - if (isset($new['update_settings']['plugins']['included'])) + if (isset($new['update_settings']['plugins']['included'])) { $current['update_settings']['plugins']['included'] = $new['update_settings']['plugins']['included']; - else + } else { $current['update_settings']['plugins']['included'] = array(); + } - if (isset($new['update_settings']['themes']['included'])) + if (isset($new['update_settings']['themes']['included'])) { $current['update_settings']['themes']['included'] = $new['update_settings']['themes']['included']; - else + } else { $current['update_settings']['themes']['included'] = array(); + } } $config->set_option('wptc_auto_update_settings', serialize($current)); $saved = true; - } else if ( $tabName == 'vulns_update' ) { + } elseif ( $tabName == 'vulns_update' ) { $current = $config->get_option('vulns_settings'); $current = unserialize($current); $new = unserialize($data['vulns_settings']); @@ -1062,7 +1073,7 @@ function get_sibling_files_callback_wptc() { $saved = true; - } else if ( $tabName == 'staging_opts' ) { + } elseif ( $tabName == 'staging_opts' ) { $config->set_option('user_excluded_extenstions_staging', $data['user_excluded_extenstions_staging']); $config->set_option('internal_staging_db_rows_copy_limit', $data['internal_staging_db_rows_copy_limit']); $config->set_option('internal_staging_file_copy_limit', $data['internal_staging_file_copy_limit']); @@ -1169,10 +1180,11 @@ function get_sibling_files_callback_wptc() { echo ''; echo ''; - if ( defined( 'FS_CHMOD_DIR' ) ) + if ( defined( 'FS_CHMOD_DIR' ) ) { echo ''; - else + } else { echo ''; + } $now = localtime( time(), true ); echo ''; diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 0a94e76..d594af4 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -27,21 +27,23 @@ class MainWP_Child_Updraft_Plus_Backups { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' )); } public static function hookUpdraftplusSaveLastBackup( $last_backup) { - if (!is_array($last_backup)) + if (!is_array($last_backup)) { return $last_backup; + } if (isset($last_backup['backup_time'])) { $backup_time = $last_backup['backup_time']; @@ -242,8 +244,9 @@ class MainWP_Child_Updraft_Plus_Backups { private function do_vault_connect() { $vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' ); - if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) + if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) { return array( 'connected' => true, 'html' => $this->connected_html() ); + } $connect = $this->vault_connect( $_REQUEST['email'], $_REQUEST['passwd'] ); if ( true === $connect ) { @@ -309,7 +312,8 @@ class MainWP_Child_Updraft_Plus_Backups { ) ); - if ( is_wp_error( $result ) || ( false === $result ) ) return $result; + if ( is_wp_error( $result ) || ( false === $result ) ) { return $result; + } $response = json_decode( $result['body'], true ); @@ -326,12 +330,14 @@ class MainWP_Child_Updraft_Plus_Backups { if ( !empty( $response['token'] ) ) { // Store it $vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' ); - if ( !is_array( $vault_settings ) ) $vault_settings = array(); + if ( !is_array( $vault_settings ) ) { $vault_settings = array(); + } $vault_settings['email'] = $email; $vault_settings['token'] = (string) $response['token']; $vault_settings['quota'] = -1; unset( $vault_settings['last_config'] ); - if ( isset($response['quota'] ) ) $vault_settings['quota'] = $response['quota']; + if ( isset($response['quota'] ) ) { $vault_settings['quota'] = $response['quota']; + } UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings ); } elseif ( isset( $response['quota'] ) && !$response['quota'] ) { return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) ); @@ -382,7 +388,8 @@ class MainWP_Child_Updraft_Plus_Backups { 'su' => base64_encode( home_url() ), ); - if ( !empty( $vault_settings['token'] ) ) $post_body['token'] = (string) $vault_settings['token']; + if ( !empty( $vault_settings['token'] ) ) { $post_body['token'] = (string) $vault_settings['token']; + } // Use SSL to prevent snooping wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array( @@ -395,11 +402,11 @@ class MainWP_Child_Updraft_Plus_Backups { function required_files() { if (defined('UPDRAFTPLUS_DIR')) { if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) { - require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' ); + require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php'; } if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) { - require_once( UPDRAFTPLUS_DIR . '/options.php' ); + require_once UPDRAFTPLUS_DIR . '/options.php'; } } } @@ -417,8 +424,9 @@ class MainWP_Child_Updraft_Plus_Backups { $settings_key = null; if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if (isset($settings['is_general']) && !empty($settings['is_general'])){ @@ -438,7 +446,7 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_googledrive' === $key ) { + } elseif ( 'updraft_googledrive' === $key ) { // do not saving from dashboard // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' ); // if (!is_array($opts)) @@ -454,7 +462,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); // } // UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_googlecloud' === $key ) { + } elseif ( 'updraft_googlecloud' === $key ) { // do not saving from dashboard // $opts = UpdraftPlus_Options::get_updraft_option( $key ); // if (!is_array($opts)) @@ -476,7 +484,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $opts['bucket_location'] = $settings[ $key ]['bucket_location']; // } // UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_onedrive' === $key ) { + } elseif ( 'updraft_onedrive' === $key ) { // do not saving from dashboard // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' ); // if (!is_array($opts)) @@ -493,7 +501,7 @@ class MainWP_Child_Updraft_Plus_Backups { // } // // UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_email' === $key ) { + } elseif ( 'updraft_email' === $key ) { $value = $settings[ $key ]; // free version if ( ! is_array( $value ) ) { @@ -502,10 +510,11 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( $key, $value ); - } else if ( 'updraft_s3' === $key ) { + } elseif ( 'updraft_s3' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey']; @@ -532,10 +541,11 @@ class MainWP_Child_Updraft_Plus_Backups { } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_s3generic' === $key ) { + } elseif ( 'updraft_s3generic' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint']; @@ -550,10 +560,11 @@ class MainWP_Child_Updraft_Plus_Backups { } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_dreamobjects' === $key ) { + } elseif ( 'updraft_dreamobjects' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']); @@ -563,10 +574,11 @@ class MainWP_Child_Updraft_Plus_Backups { $opts['endpoint'] = $settings[ $key ]['endpoint']; } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_ftp' === $key ) { + } elseif ( 'updraft_ftp' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { @@ -587,10 +599,11 @@ class MainWP_Child_Updraft_Plus_Backups { } UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } else if ( 'updraft_sftp_settings' === $key ) { + } elseif ( 'updraft_sftp_settings' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { @@ -614,10 +627,11 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts ); - } else if ('updraft_webdav_settings' == $key) { + } elseif ('updraft_webdav_settings' == $key) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_webdav' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); @@ -625,10 +639,11 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts ); } - } else if ( 'updraft_backblaze' === $key ) { + } elseif ( 'updraft_backblaze' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' ); - if (!is_array($opts)) + if (!is_array($opts)) { $opts = array(); + } if (is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); $opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id']; @@ -701,7 +716,8 @@ class MainWP_Child_Updraft_Plus_Backups { function addons_connect() { if ( ! defined( 'UDADDONS2_SLUG' ) ) { - if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) require_once(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'); + if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) { require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; + } if ( ! defined( 'UDADDONS2_SLUG' ) ) { return array( 'error' => 'NO_PREMIUM' ); } @@ -801,7 +817,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ( ! class_exists( 'UpdraftPlus_WPDB_OtherDB_Test' ) ) { if ( file_exists( UPDRAFTPLUS_DIR . '/addons/moredatabase.php' ) ) { - require_once( UPDRAFTPLUS_DIR . '/addons/moredatabase.php' ); + require_once UPDRAFTPLUS_DIR . '/addons/moredatabase.php'; } } @@ -1232,7 +1248,7 @@ class MainWP_Child_Updraft_Plus_Backups { if (method_exists($updraftplus, 'get_backup_history')) { $backups = $updraftplus->get_backup_history(); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backups = UpdraftPlus_Backup_History::get_history(); } $timestamp = $_POST['backup_timestamp']; @@ -1321,7 +1337,7 @@ class MainWP_Child_Updraft_Plus_Backups { continue; } if ( file_exists( UPDRAFTPLUS_DIR . "/methods/$service.php" ) ) { - require_once( UPDRAFTPLUS_DIR . "/methods/$service.php" ); + require_once UPDRAFTPLUS_DIR . "/methods/$service.php"; } $objname = 'UpdraftPlus_BackupModule_' . $service; $deleted = - 1; @@ -1457,7 +1473,7 @@ class MainWP_Child_Updraft_Plus_Backups { // Retrieve the information from our backup history if (method_exists($updraftplus, 'get_backup_history')) { $backup_history = $updraftplus->get_backup_history(); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backup_history = UpdraftPlus_Backup_History::get_history(); } @@ -1583,7 +1599,7 @@ class MainWP_Child_Updraft_Plus_Backups { $method_include = UPDRAFTPLUS_DIR . '/methods/' . $service . '.php'; if ( file_exists( $method_include ) ) { - require_once( $method_include ); + require_once $method_include; } $objname = "UpdraftPlus_BackupModule_${service}"; @@ -1617,7 +1633,7 @@ class MainWP_Child_Updraft_Plus_Backups { if (method_exists($updraftplus, 'get_backup_history')) { $backups = $updraftplus->get_backup_history(); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backups = UpdraftPlus_Backup_History::get_history(); } @@ -1767,7 +1783,7 @@ class MainWP_Child_Updraft_Plus_Backups { global $updraftplus_admin, $updraftplus; if ( empty( $updraftplus_admin ) ) { - require_once( UPDRAFTPLUS_DIR . '/admin.php' ); + require_once UPDRAFTPLUS_DIR . '/admin.php'; } ob_start(); $backup_success = $this->restore_backup( $_REQUEST['backup_timestamp'] ); @@ -1934,7 +1950,7 @@ class MainWP_Child_Updraft_Plus_Backups { uksort( $backup_set, array( $this, 'sort_restoration_entities' ) ); // We use a single object for each entity, because we want to store information about the backup set - require_once( UPDRAFTPLUS_DIR . '/restorer.php' ); + require_once UPDRAFTPLUS_DIR . '/restorer.php'; global $updraftplus_restorer; $updraftplus_restorer = new Updraft_Restorer( new Updraft_Restorer_Skin(), $backup_set ); @@ -2142,7 +2158,7 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus_restorer->clear_cache(); if ( ! function_exists( 'validate_current_theme' ) ) { - require_once( ABSPATH . WPINC . '/themes' ); + require_once ABSPATH . WPINC . '/themes'; } # Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system @@ -2319,7 +2335,7 @@ class MainWP_Child_Updraft_Plus_Backups { $info = array(); global $updraftplus, $wp_version; - include( ABSPATH . WPINC . '/version.php' ); + include ABSPATH . WPINC . '/version.php'; $updraft_dir = $updraftplus->backups_dir_location(); @@ -2329,7 +2345,7 @@ class MainWP_Child_Updraft_Plus_Backups { if (method_exists($updraftplus, 'get_backup_history')) { $backup = $updraftplus->get_backup_history($timestamp); - } else if (class_exists('UpdraftPlus_Backup_History')) { + } elseif (class_exists('UpdraftPlus_Backup_History')) { $backup = UpdraftPlus_Backup_History::get_history($timestamp); } @@ -2563,12 +2579,14 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus->get_max_packet_size(); $backup = UpdraftPlus_Backup_History::get_history($timestamp); - if (!isset($backup['nonce']) || !isset($backup['db'])) return array($mess, $warn, $err, $info); + if (!isset($backup['nonce']) || !isset($backup['db'])) { return array($mess, $warn, $err, $info); + } $db_file = (is_string($backup['db'])) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; } - if (!is_readable($db_file)) return array($mess, $warn, $err, $info); + if (!is_readable($db_file)) { return array($mess, $warn, $err, $info); + } // Encrypted - decrypt it if (UpdraftPlus_Encryption::is_file_encrypted($db_file)) { @@ -2712,13 +2730,15 @@ class MainWP_Child_Updraft_Plus_Backups { if (!$migration_warning && home_url() != $old_home) { $migration_warning = true; $powarn = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_home, $res); - if (!empty($powarn)) $warn[] = $powarn; + if (!empty($powarn)) { $warn[] = $powarn; + } } } elseif (!isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) { $info['created_by_version'] = trim($matches[1]); } elseif ('' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches)) { $old_wp_version = $matches[1]; - if (!empty($matches[3])) $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1); + if (!empty($matches[3])) { $old_wp_version .= substr($matches[3], 0, strlen($matches[3])-1); + } if (version_compare($old_wp_version, $wp_version, '>')) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); $warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version); @@ -2762,7 +2782,8 @@ class MainWP_Child_Updraft_Plus_Backups { $val = $kvmatches[2]; if ('multisite' == $key) { $info['multisite'] = $val ? true : false; - if ($val) $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; + if ($val) { $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; + } } $old_siteinfo[$key] = $val; } @@ -2859,7 +2880,8 @@ class MainWP_Child_Updraft_Plus_Backups { } } $charset_select_html .= ''; - if (empty($info['addui'])) $info['addui'] = ''; + if (empty($info['addui'])) { $info['addui'] = ''; + } $info['addui'] .= $charset_select_html; } } @@ -2944,7 +2966,8 @@ class MainWP_Child_Updraft_Plus_Backups { CREATE TABLE $wpdb->sitemeta ( CREATE TABLE $wpdb->signups ( */ - if (!isset($skipped_tables)) $skipped_tables = array(); + if (!isset($skipped_tables)) { $skipped_tables = array(); + } $missing_tables = array(); if ($old_table_prefix) { if (!$header_only) { @@ -3133,8 +3156,10 @@ class MainWP_Child_Updraft_Plus_Backups { $date_label = $this->date_label( $pretty_date, $key, $backup, $jobdata, $non ); $service_title = ''; - if (!isset($backup['service'])) $backup['service'] = array(); - if (!is_array($backup['service'])) $backup['service'] = array($backup['service']); + if (!isset($backup['service'])) { $backup['service'] = array(); + } + if (!is_array($backup['service'])) { $backup['service'] = array($backup['service']); + } foreach ($backup['service'] as $service) { if ('none' === $service || '' === $service || (is_array($service) && (empty($service) || array('none') === $service || array('') === $service))) { // Do nothing @@ -3164,9 +3189,11 @@ ENDHERE; // Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field. $db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db']; if ( class_exists( 'UpdraftPlus_Encryption')) { - if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) - if (UpdraftPlus_Encryption::is_file_encrypted($db)) $entities .= '/dbcrypted=1/'; - } else if ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) { + if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) { + if (UpdraftPlus_Encryption::is_file_encrypted($db)) { $entities .= '/dbcrypted=1/'; + } + } + } elseif ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) { $entities .= '/dbcrypted=1/'; } @@ -3378,8 +3405,9 @@ ENDHERE; } $fix_perfomance++; - if ($fix_perfomance > 50) // // to fix perfomance issue of response when too much backup files + if ($fix_perfomance > 50) { // // to fix perfomance issue of response when too much backup files break; + } } } } @@ -3433,7 +3461,7 @@ ENDHERE; $messages = null; if ( method_exists( $updraftplus, 'rebuild_backup_history' ) ) { $messages = $updraftplus->rebuild_backup_history( $remotescan ); - } else if ( method_exists( $updraftplus_admin, 'rebuild_backup_history' ) ) { + } elseif ( method_exists( $updraftplus_admin, 'rebuild_backup_history' ) ) { $messages = $updraftplus_admin->rebuild_backup_history( $remotescan ); } @@ -3977,8 +4005,9 @@ ENDHERE; } public function updraftplus_init() { - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_updraftplus_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php index a4a06c2..32367b7 100644 --- a/class/class-mainwp-child-vulnerability-checker.php +++ b/class/class-mainwp-child-vulnerability-checker.php @@ -129,8 +129,8 @@ class MainWP_Child_Vulnerability_Checker { function check_themes( $force = false) { - require_once( ABSPATH . 'wp-admin/includes/misc.php' ); - require_once( ABSPATH . 'wp-admin/includes/theme.php' ); + require_once ABSPATH . 'wp-admin/includes/misc.php'; + require_once ABSPATH . 'wp-admin/includes/theme.php'; if ( current_user_can( 'switch_themes' ) ) { $themes = wp_prepare_themes_for_js(); @@ -156,8 +156,9 @@ class MainWP_Child_Vulnerability_Checker { $th_vulner_data = array(); foreach($th_data['vulnerabilities'] as $vuln_data) { - if (empty($vuln_data)) + if (empty($vuln_data)) { continue; + } if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) { continue; diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 9597529..7151132 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -64,7 +64,7 @@ class MainWP_Child_WooCommerce_Status { global $wpdb; $file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php'; if ( file_exists( $file ) ) { - include_once( $file ); + include_once $file; } else { return false; } @@ -81,10 +81,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= %s AND posts.post_date <= %s @@ -103,10 +103,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' AND posts.post_date >= %s @@ -180,7 +180,7 @@ class MainWP_Child_WooCommerce_Status { global $wpdb; $file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php'; if ( file_exists( $file ) ) { - include_once( $file ); + include_once $file; } else { return false; } @@ -202,10 +202,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') @@ -224,10 +224,10 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) + 'completed', + 'processing', + 'on-hold', +) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') @@ -326,7 +326,7 @@ class MainWP_Child_WooCommerce_Status { global $wpdb; $file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php'; if ( file_exists( $file ) ) { - include_once( $file ); + include_once $file; } else { return false; } @@ -341,10 +341,10 @@ class MainWP_Child_WooCommerce_Status { $query['join'] = "INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'reports' ) ) . "' ) "; $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) "; + 'completed', + 'processing', + 'on-hold', + ) ) ) . "' ) "; $query['where'] .= "AND postmeta.meta_key = '_order_total' "; $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; @@ -360,10 +360,10 @@ class MainWP_Child_WooCommerce_Status { $query['join'] .= "INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'order-count' ) ) . "' ) "; $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', - ) ) ) . "' ) "; + 'completed', + 'processing', + 'on-hold', + ) ) ) . "' ) "; $query['where'] .= "AND order_item_meta.meta_key = '_qty' "; $query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' "; $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; @@ -441,7 +441,7 @@ class MainWP_Child_WooCommerce_Status { } private static function update_wc_db() { - include_once( WC()->plugin_path() . '/includes/class-wc-background-updater.php' ); + include_once WC()->plugin_path() . '/includes/class-wc-background-updater.php'; $background_updater = new WC_Background_Updater(); $current_db_version = get_option( 'woocommerce_db_version' ); diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index c3b6190..bb86c97 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -195,11 +195,11 @@ class MainWP_Child_Wordfence { public function __construct() { add_action( 'mainwp_child_deactivation', array( $this, 'deactivation' ) ); - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; // ok if ( is_plugin_active( 'wordfence/wordfence.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' ) ) { - require_once( plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php' ); + require_once plugin_dir_path( __FILE__ ) . '../../wordfence/wordfence.php'; $this->is_wordfence_installed = true; } @@ -619,8 +619,9 @@ class MainWP_Child_Wordfence { private function start_scan() { $information = wordfence::ajax_scan_callback(); - if ( is_array($information) && isset($information['ok']) ) + if ( is_array($information) && isset($information['ok']) ) { $information['result'] = 'SUCCESS'; + } return $information; } @@ -653,7 +654,8 @@ class MainWP_Child_Wordfence { public function wordfence_init() { - if ( ! $this->is_wordfence_installed ) return; + if ( ! $this->is_wordfence_installed ) { return; + } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); if ( get_option( 'mainwp_wordfence_hide_plugin' ) === 'hide' ) { @@ -669,8 +671,10 @@ class MainWP_Child_Wordfence { } // ok public function do_reports_log( $ext = '') { - if ( $ext !== 'wordfence' ) return; - if ( ! $this->is_wordfence_installed ) return; + if ( $ext !== 'wordfence' ) { return; + } + if ( ! $this->is_wordfence_installed ) { return; + } global $wpdb; @@ -868,9 +872,9 @@ SQL $i = new wfIssues(); if ( 'deleteIgnored' === $op ) { $i->deleteIgnored(); - } else if ( 'deleteNew' === $op ) { + } elseif ( 'deleteNew' === $op ) { $i->deleteNew(); - } else if ( 'ignoreAllNew' === $op ) { + } elseif ( 'ignoreAllNew' === $op ) { $i->ignoreAllNew(); } else { return array( 'errorMsg' => 'An invalid operation was called.' ); @@ -893,7 +897,7 @@ SQL return array( 'ok' => 1, 'issueCounts' => $counts, - ); + ); } function update_issues_status() { @@ -944,13 +948,13 @@ SQL $err = error_get_last(); $errors[] = 'Could not delete file ' . htmlentities( $file ) . '. Error was: ' . htmlentities( $err['message'] ); } - } else if ( 'repair' === $op ) { + } elseif ( 'repair' === $op ) { $dat = $issue['data']; $result = wordfence::getWPFileContent( $dat['file'], $dat['cType'], $dat['cName'], $dat['cVersion'] ); if ( $result['cerrorMsg'] ) { $errors[] = $result['cerrorMsg']; continue; - } else if ( ! $result['fileContent'] ) { + } elseif ( ! $result['fileContent'] ) { $errors[] = 'We could not get the original file of ' . htmlentities( $file ) . ' to do a repair.'; continue; } @@ -989,10 +993,10 @@ SQL if ( $filesWorkedOn > 0 && count( $errors ) > 0 ) { $headMsg = "$verb some files with errors"; $bodyMsg = "$verb $filesWorkedOn files but we encountered the following errors with other files: " . implode( '
    ', $errors ); - } else if ( $filesWorkedOn > 0 ) { + } elseif ( $filesWorkedOn > 0 ) { $headMsg = "$verb $filesWorkedOn files successfully"; $bodyMsg = "$verb $filesWorkedOn files successfully. No errors were encountered."; - } else if ( count( $errors ) > 0 ) { + } elseif ( count( $errors ) > 0 ) { $headMsg = "Could not $verb2 files"; $bodyMsg = "We could not $verb2 any of the files you selected. We encountered the following errors: " . implode( '
    ', $errors ); } else { @@ -1053,7 +1057,7 @@ SQL $file = $dat['file']; if ( isset( $result['cerrorMsg'] ) && $result['cerrorMsg'] ) { return $result; - } else if ( ! $result['fileContent'] ) { + } elseif ( ! $result['fileContent'] ) { return array( 'cerrorMsg' => 'We could not get the original file to do a repair.' ); } @@ -1112,9 +1116,9 @@ SQL } function save_settings_new() { - if (isset($_POST['encrypted'])) + if (isset($_POST['encrypted'])) { $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost - else { + } else { $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); } @@ -1224,7 +1228,7 @@ SQL if (in_array('autoUpdate', $saving_opts)) { if ( '1' === $opts['autoUpdate'] ) { wfConfig::enableAutoUpdate(); - } else if ( '0' === $opts['autoUpdate'] ) { + } elseif ( '0' === $opts['autoUpdate'] ) { wfConfig::disableAutoUpdate(); } } @@ -1306,7 +1310,7 @@ SQL return $result; } - } else if ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { + } elseif ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); try { $res = $api->call('check_api_key', array(), array('previousLicense' => $existingAPIKey)); @@ -1411,9 +1415,9 @@ SQL } function save_setting() { - if (isset($_POST['encrypted'])) + if (isset($_POST['encrypted'])) { $settings = $this->simple_crypt( 'thisisakey', $_POST['settings'], 'decrypt' ); // to fix pass through sec rules of Dreamhost - else { + } else { $settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); } @@ -1470,7 +1474,7 @@ SQL if ( '1' === $opts['autoUpdate'] ) { wfConfig::enableAutoUpdate(); - } else if ( '0' === $opts['autoUpdate'] ) { + } elseif ( '0' === $opts['autoUpdate'] ) { wfConfig::disableAutoUpdate(); } @@ -1528,7 +1532,7 @@ SQL return $result; } - } else if ( wfConfig::get( 'apiKey' ) !== $apiKey ) { + } elseif ( wfConfig::get( 'apiKey' ) !== $apiKey ) { $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); try { $res = $api->call( 'check_api_key', array(), array() ); @@ -1592,7 +1596,7 @@ SQL 'token' => $res['token'], ); } - else if ($res['err']) { + elseif ($res['err']) { return array('errorExport' => __('An error occurred: ', 'wordfence') . $res['err']); } else { @@ -1658,7 +1662,7 @@ SQL 'settings' => $this->get_settings(), ); } - else if ($res['err']) { + elseif ($res['err']) { return array('errorImport' => 'An error occurred: ' . $res['err']); } else { @@ -1704,10 +1708,10 @@ SQL $listType = 'logins'; } $events = wordfence::getLog()->getHits( $listType, $type, $newestEventTime ); - } else if ( 'perfStats' === $alsoGet ) { + } elseif ( 'perfStats' === $alsoGet ) { $newestEventTime = $_POST['otherParams']; $events = wordfence::getLog()->getPerfStats( $newestEventTime ); - } else if ($alsoGet == 'liveTraffic') { + } elseif ($alsoGet == 'liveTraffic') { if (get_site_option('wordfence_syncAttackDataAttempts') > 10) { wordfence::syncAttackData(false); } @@ -1832,8 +1836,9 @@ SQL // credit of Wordfence private static function _getWAFData( $updated = null) { // custom - if(!class_exists('wfWAF')) + if(!class_exists('wfWAF')) { return false; + } // end if custom $data['learningMode'] = wfWAF::getInstance()->isInLearningMode(); @@ -1924,7 +1929,7 @@ SQL 'error' => sprintf(__('An error occurred while saving the configuration: %s', 'wordfence'), $errors[0]['error']), ); } - else if (count($errors) > 1) { + elseif (count($errors) > 1) { $compoundMessage = array(); foreach ($errors as $e) { $compoundMessage[] = $e['error']; @@ -2017,11 +2022,11 @@ SQL $wfLog = wordfence::getLog(); if ( 'topScanners' === $mode || 'topLeechers' === $mode ) { $results = $wfLog->getLeechers( $mode ); - } else if ( 'blockedIPs' === $mode ) { + } elseif ( 'blockedIPs' === $mode ) { $results = $wfLog->getBlockedIPs(); - } else if ( 'lockedOutIPs' === $mode ) { + } elseif ( 'lockedOutIPs' === $mode ) { $results = $wfLog->getLockedOutIPs(); - } else if ( 'throttledIPs' === $mode ) { + } elseif ( 'throttledIPs' === $mode ) { $results = $wfLog->getThrottledIPs(); } @@ -2057,9 +2062,10 @@ SQL $noEditHtaccess = '1'; if (isset($_POST['needToCheckFalconHtaccess']) && !empty($_POST['needToCheckFalconHtaccess'])) { $checkHtaccess = self::checkFalconHtaccess(); - if (isset($checkHtaccess['ok'])) + if (isset($checkHtaccess['ok'])) { $noEditHtaccess = '0'; - } else if (isset($_POST['noEditHtaccess'])) { + } + } elseif (isset($_POST['noEditHtaccess'])) { $noEditHtaccess = $_POST['noEditHtaccess']; } @@ -2071,13 +2077,13 @@ SQL if(is_plugin_active($pluginFile)){ if($pluginFile == 'w3-total-cache/w3-total-cache.php'){ $badPlugins[] = 'W3 Total Cache'; - } else if($pluginFile == 'quick-cache/quick-cache.php'){ + } elseif($pluginFile == 'quick-cache/quick-cache.php'){ $badPlugins[] = 'Quick Cache'; - } else if($pluginFile == 'wp-super-cache/wp-cache.php'){ + } elseif($pluginFile == 'wp-super-cache/wp-cache.php'){ $badPlugins[] = 'WP Super Cache'; - } else if($pluginFile == 'wp-fast-cache/wp-fast-cache.php'){ + } elseif($pluginFile == 'wp-fast-cache/wp-fast-cache.php'){ $badPlugins[] = 'WP Fast Cache'; - } else if($pluginFile == 'wp-fastest-cache/wpFastestCache.php'){ + } elseif($pluginFile == 'wp-fastest-cache/wpFastestCache.php'){ $badPlugins[] = 'WP Fastest Cache'; } } @@ -2121,10 +2127,10 @@ SQL if($cacheType == 'disable'){ wfConfig::set('cacheType', false); return array('ok' => 1, 'heading' => 'Caching successfully disabled.', 'body' => "{$htMsg}Caching has been disabled on your system.

    "); - } else if($cacheType == 'php'){ + } elseif($cacheType == 'php'){ wfConfig::set('cacheType', 'php'); return array('ok' => 1, 'heading' => 'Wordfence Basic Caching Enabled', 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

    "); - } else if($cacheType == 'falcon'){ + } elseif($cacheType == 'falcon'){ if($noEditHtaccess != '1'){ $err = wfCache::addHtaccessCode('add'); if($err){ @@ -2376,11 +2382,11 @@ SQL colspan=""> array(), - 'strong' => array(), - 'em' => array(), - 'a' => array('href' => true), - )) + 'code' => array(), + 'strong' => array(), + 'em' => array(), + 'a' => array('href' => true), + )) ?> @@ -2558,7 +2564,7 @@ SQL
    Pass' : self::getWarningHTML( $errorType ) ); ?> Pass' : self::getWarningHTML( $errorType ) ); ?> Pass'; ?> Pass' : self::getWarningHTML( $errorType )); ?>
    ' . __( 'Current PHP user', 'wp-time-capsule' ) . '' . esc_html( $php_user ) . '
    ' . __( 'Maximum execution time', 'wp-time-capsule' ) . '' . esc_html( ini_get( 'max_execution_time' ) ) . ' ' . __( 'seconds', 'wp-time-capsule' ) . '
    ' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '' . esc_html( FS_CHMOD_DIR ) . '
    ' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '0755
    ' . __( 'Server Time', 'wp-time-capsule' ) . '' . esc_html( $now[ 'tm_hour' ] . ':' . $now[ 'tm_min' ] ) . '
    @@ -2420,11 +2426,11 @@ SQL colspan=""> array(), - 'strong' => array(), - 'em' => array(), - 'a' => array('href' => true), - )) + 'code' => array(), + 'strong' => array(), + 'em' => array(), + 'a' => array('href' => true), + )) ?> @@ -2445,11 +2451,11 @@ SQL list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); $howGetHasErrors = false; foreach (array( - 'REMOTE_ADDR' => 'REMOTE_ADDR', - 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', - 'HTTP_X_REAL_IP' => 'X-Real-IP', - 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label) { + 'REMOTE_ADDR' => 'REMOTE_ADDR', + 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', + 'HTTP_X_REAL_IP' => 'X-Real-IP', + 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', + ) as $variable => $label) { if (!($currentServerVarForIP && $currentServerVarForIP === $variable) && $howGet === $variable) { $howGetHasErrors = true; break; @@ -2483,11 +2489,11 @@ SQL $howGet = wfConfig::get('howGetIPs', false); list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); foreach (array( - 'REMOTE_ADDR' => 'REMOTE_ADDR', - 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', - 'HTTP_X_REAL_IP' => 'X-Real-IP', - 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label): + 'REMOTE_ADDR' => 'REMOTE_ADDR', + 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', + 'HTTP_X_REAL_IP' => 'X-Real-IP', + 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', + ) as $variable => $label): ?>
    > array('description' => '', 'value' => $wp_version), diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index 8771c1b..8b3b7bb 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -56,82 +56,82 @@ class MainWP_Child_WP_Rocket { function get_rocket_default_options() { return array( - 'cache_mobile' => 1, - 'do_caching_mobile_files' => 0, - 'cache_logged_user' => 0, - 'cache_ssl' => 0, - 'emoji' => 0, - 'embeds' => 1, - 'control_heartbeat' => 0, - 'heartbeat_site_behavior' => 'reduce_periodicity', - 'heartbeat_admin_behavior' => 'reduce_periodicity', - 'heartbeat_editor_behavior' => 'reduce_periodicity', - 'varnish_auto_purge' => 0, - 'manual_preload' => 0, - 'automatic_preload' => 0, - 'sitemap_preload' => 0, - 'sitemap_preload_url_crawl' => 500000, - 'sitemaps' => array(), - 'database_revisions' => 0, - 'database_auto_drafts' => 0, - 'database_trashed_posts' => 0, - 'database_spam_comments' => 0, - 'database_trashed_comments' => 0, - 'database_expired_transients' => 0, - 'database_all_transients' => 0, - 'database_optimize_tables' => 0, - 'schedule_automatic_cleanup' => 0, - 'automatic_cleanup_frequency' => '', - 'cache_reject_uri' => array(), - 'cache_reject_cookies' => array(), - 'cache_reject_ua' => array(), - 'cache_query_strings' => array(), - 'cache_purge_pages' => array(), - 'purge_cron_interval' => 10, - 'purge_cron_unit' => 'HOUR_IN_SECONDS', - 'exclude_css' => array(), - 'exclude_js' => array(), - 'exclude_inline_js' => array(), - 'async_css' => 0, - 'defer_all_js' => 0, - 'defer_all_js_safe' => 1, - 'critical_css' => '', - 'deferred_js_files' => array(), - 'lazyload' => 0, - 'lazyload_iframes' => 0, - 'lazyload_youtube' =>0, - 'minify_css' => 0, -// 'minify_css_key' => $minify_css_key, - 'minify_concatenate_css' => 0, - //'minify_css_combine_all' => 0, - 'minify_css_legacy' => 0, - 'minify_js' => 0, -// 'minify_js_key' => $minify_js_key, - 'minify_js_in_footer' => array(), - 'minify_concatenate_js' => 0, - 'minify_js_combine_all' => 0, - //'minify_js_legacy' => 0, - 'minify_google_fonts' => 0, - 'minify_html' => 0, - 'remove_query_strings' => 0, - 'dns_prefetch' => 0, - 'cdn' => 0, - 'cdn_cnames' => array(), - 'cdn_zone' => array(), - //'cdn_ssl' => 0, - 'cdn_reject_files' => array(), - 'do_cloudflare' => 0, - 'cloudflare_email' => '', - 'cloudflare_api_key' => '', - 'cloudflare_domain' => '', - //'cloudflare_zone_id' => '', - 'cloudflare_devmode' => 0, - 'cloudflare_protocol_rewrite' => 0, - 'cloudflare_auto_settings' => 0, - 'cloudflare_old_settings' => 0, - 'do_beta' => 0, - 'analytics_enabled' => 1, - ); + 'cache_mobile' => 1, + 'do_caching_mobile_files' => 0, + 'cache_logged_user' => 0, + 'cache_ssl' => 0, + 'emoji' => 0, + 'embeds' => 1, + 'control_heartbeat' => 0, + 'heartbeat_site_behavior' => 'reduce_periodicity', + 'heartbeat_admin_behavior' => 'reduce_periodicity', + 'heartbeat_editor_behavior' => 'reduce_periodicity', + 'varnish_auto_purge' => 0, + 'manual_preload' => 0, + 'automatic_preload' => 0, + 'sitemap_preload' => 0, + 'sitemap_preload_url_crawl' => 500000, + 'sitemaps' => array(), + 'database_revisions' => 0, + 'database_auto_drafts' => 0, + 'database_trashed_posts' => 0, + 'database_spam_comments' => 0, + 'database_trashed_comments' => 0, + 'database_expired_transients' => 0, + 'database_all_transients' => 0, + 'database_optimize_tables' => 0, + 'schedule_automatic_cleanup' => 0, + 'automatic_cleanup_frequency' => '', + 'cache_reject_uri' => array(), + 'cache_reject_cookies' => array(), + 'cache_reject_ua' => array(), + 'cache_query_strings' => array(), + 'cache_purge_pages' => array(), + 'purge_cron_interval' => 10, + 'purge_cron_unit' => 'HOUR_IN_SECONDS', + 'exclude_css' => array(), + 'exclude_js' => array(), + 'exclude_inline_js' => array(), + 'async_css' => 0, + 'defer_all_js' => 0, + 'defer_all_js_safe' => 1, + 'critical_css' => '', + 'deferred_js_files' => array(), + 'lazyload' => 0, + 'lazyload_iframes' => 0, + 'lazyload_youtube' =>0, + 'minify_css' => 0, + // 'minify_css_key' => $minify_css_key, + 'minify_concatenate_css' => 0, + //'minify_css_combine_all' => 0, + 'minify_css_legacy' => 0, + 'minify_js' => 0, + // 'minify_js_key' => $minify_js_key, + 'minify_js_in_footer' => array(), + 'minify_concatenate_js' => 0, + 'minify_js_combine_all' => 0, + //'minify_js_legacy' => 0, + 'minify_google_fonts' => 0, + 'minify_html' => 0, + 'remove_query_strings' => 0, + 'dns_prefetch' => 0, + 'cdn' => 0, + 'cdn_cnames' => array(), + 'cdn_zone' => array(), + //'cdn_ssl' => 0, + 'cdn_reject_files' => array(), + 'do_cloudflare' => 0, + 'cloudflare_email' => '', + 'cloudflare_api_key' => '', + 'cloudflare_domain' => '', + //'cloudflare_zone_id' => '', + 'cloudflare_devmode' => 0, + 'cloudflare_protocol_rewrite' => 0, + 'cloudflare_auto_settings' => 0, + 'cloudflare_old_settings' => 0, + 'do_beta' => 0, + 'analytics_enabled' => 1, + ); } // ok @@ -340,7 +340,7 @@ class MainWP_Child_WP_Rocket { } // to fix - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; // Generate a new random key for minify cache file $options = get_option( WP_ROCKET_SLUG ); @@ -379,7 +379,7 @@ class MainWP_Child_WP_Rocket { 'WP_Rocket\Optimization\CSS\Critical_CSS_Generation', 'WP_Rocket\Admin\Options', 'WP_Rocket\Admin\Options_Data', - )); + )); $critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() ); $options_api = new WP_Rocket\Admin\Options( 'wp_rocket_' ); @@ -425,7 +425,7 @@ class MainWP_Child_WP_Rocket { 'WP_Rocket\Admin\Database\Optimization_Process', 'WP_Rocket\Admin\Options', 'WP_Rocket\Admin\Options_Data', - )); + )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); $optimization = new WP_Rocket\Admin\Database\Optimization( $process ); @@ -448,7 +448,7 @@ class MainWP_Child_WP_Rocket { MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization', 'WP_Rocket\Admin\Database\Optimization_Process', - )); + )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); $optimization = new WP_Rocket\Admin\Database\Optimization( $process ); diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index 612e62c..3e2444f 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -15,14 +15,15 @@ class MainWP_Child_WPvivid_BackupRestore { } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR')) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if (!$this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); $this->public_intetface = new WPvivid_Public_Interface(); diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index e4effc9..8f6d272 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -13,8 +13,8 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) { define( 'MAINWP_CHILD_NR_OF_COMMENTS', 50 ); define( 'MAINWP_CHILD_NR_OF_PAGES', 50 ); -include_once( ABSPATH . '/wp-admin/includes/file.php' ); -include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); +require_once ABSPATH . '/wp-admin/includes/file.php'; +require_once ABSPATH . '/wp-admin/includes/plugin.php'; if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyuse_nonce_hmac'] ) ) { @@ -213,8 +213,9 @@ class MainWP_Child { $this->load_all_options(); $this->filterFunction = function( $a) { if ($a == null) { return false; } - if (is_object($a) && property_exists($a, 'last_checked') && !property_exists($a, 'checked')) + if (is_object($a) && property_exists($a, 'last_checked') && !property_exists($a, 'checked')) { return false; + } return $a; }; $this->plugin_dir = dirname( $plugin_file ); @@ -269,15 +270,17 @@ class MainWP_Child { function load_all_options() { global $wpdb; - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { $alloptions = wp_cache_get( 'alloptions', 'options' ); - else + } else { $alloptions = false; + } - if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) + if ( !defined( 'WP_INSTALLING' ) || !is_multisite() ) { $notoptions = wp_cache_get( 'notoptions', 'options' ); - else + } else { $notoptions = false; + } if ( !isset($alloptions['mainwp_db_version']) ) { $suppress = $wpdb->suppress_errors(); @@ -303,9 +306,9 @@ class MainWP_Child { 'mainwp_child_nossl', 'mainwp_security', 'mainwp_backupwordpress_ext_enabled', -// 'mainwp_wprocket_ext_enabled', - //'mainwp_wordfence_ext_enabled', - 'mainwp_branding_button_contact_label', + // 'mainwp_wprocket_ext_enabled', + //'mainwp_wordfence_ext_enabled', + 'mainwp_branding_button_contact_label', 'mainwp_branding_extra_settings', 'mainwp_branding_child_hide', 'mainwp_branding_ext_enabled', @@ -325,7 +328,8 @@ class MainWP_Child { $alloptions_db = $wpdb->get_results( $query ); $wpdb->suppress_errors($suppress); - if ( !is_array( $alloptions ) ) $alloptions = array(); + if ( !is_array( $alloptions ) ) { $alloptions = array(); + } if ( is_array( $alloptions_db ) ) { foreach ( (array) $alloptions_db as $o ) { $alloptions[ $o->option_name ] = $o->option_value; @@ -417,7 +421,7 @@ class MainWP_Child { foreach ( $options as $option ) { MainWP_Helper::fix_option( $option ); } - } else if ( ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) { + } elseif ( ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) { $options = array( 'mainwp_child_pubkey', //'mainwp_child_branding_disconnected', @@ -726,14 +730,16 @@ class MainWP_Child { $all_subpages = apply_filters( 'mainwp-child-init-subpages', array() ); - if ( !is_array( $all_subpages ) ) + if ( !is_array( $all_subpages ) ) { $all_subpages = array(); + } if ( !self::$subPagesLoaded ) { foreach( $all_subpages as $page ) { $slug = isset( $page['slug'] ) ? $page['slug'] : ''; - if ( empty( $slug ) ) + if ( empty( $slug ) ) { continue; + } $subpage = array(); $subpage['slug'] = $slug; $subpage['title'] = $page['title']; @@ -783,11 +789,11 @@ class MainWP_Child { if ($shownPage == '') { if (!$hide_settings ) { $shownPage = 'settings'; - } else if (!$hide_restore) { + } elseif (!$hide_restore) { $shownPage = 'restore-clone'; - } else if (!$hide_server_info) { + } elseif (!$hide_server_info) { $shownPage = 'server-info'; - } else if (!$hide_connection_detail) { + } elseif (!$hide_connection_detail) { $shownPage = 'connection-detail'; } } @@ -844,8 +850,9 @@ class MainWP_Child { $shownPage = $_GET['tab']; } - if (empty($shownPage)) + if (empty($shownPage)) { $shownPage = 'settings'; + } $branding_opts = MainWP_Child_Branding::Instance()->get_branding_options(); @@ -1081,7 +1088,7 @@ class MainWP_Child { } if ( $hard ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; $home_path = ABSPATH; $htaccess_file = $home_path . '.htaccess'; @@ -1104,9 +1111,9 @@ class MainWP_Child { $file = ''; if ( isset( $_REQUEST['f'] ) ) { $file = $_REQUEST['f']; - } else if ( isset( $_REQUEST['file'] ) ) { + } elseif ( isset( $_REQUEST['file'] ) ) { $file = $_REQUEST['file']; - } else if ( isset( $_REQUEST['fdl'] ) ) { + } elseif ( isset( $_REQUEST['fdl'] ) ) { $file = $_REQUEST['fdl']; } @@ -1191,7 +1198,7 @@ class MainWP_Child { if ( 'dl' === $_REQUEST['cloneFunc'] ) { $this->uploadFile( $_REQUEST['f'] ); exit; - } else if ( 'deleteCloneBackup' === $_POST['cloneFunc'] ) { + } elseif ( 'deleteCloneBackup' === $_POST['cloneFunc'] ) { $dirs = MainWP_Helper::getMainWPDir( 'backup' ); $backupdir = $dirs[0]; $result = glob( $backupdir . $_POST['f'] ); @@ -1201,7 +1208,7 @@ class MainWP_Child { @unlink( $result[0] ); MainWP_Helper::write( array( 'result' => 'ok' ) ); - } else if ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { + } elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { $dirs = MainWP_Helper::getMainWPDir( 'backup' ); $backupdir = $dirs[0]; $result = glob( $backupdir . 'backup-' . $_POST['f'] . '-*' ); @@ -1217,7 +1224,7 @@ class MainWP_Child { } MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) ); - } else if ( 'createCloneBackup' === $_POST['cloneFunc'] ) { + } elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) { MainWP_Helper::endSession(); $files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' ); @@ -1308,7 +1315,7 @@ class MainWP_Child { } if ( get_option( 'mainwp_child_fix_htaccess' ) === false ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; $wp_rewrite->flush_rules(); MainWP_Helper::update_option( 'mainwp_child_fix_htaccess', 'yes', 'yes' ); @@ -1341,9 +1348,9 @@ class MainWP_Child { $file = ''; if ( isset( $_REQUEST['f'] ) ) { $file = $_REQUEST['f']; - } else if ( isset( $_REQUEST['file'] ) ) { + } elseif ( isset( $_REQUEST['file'] ) ) { $file = $_REQUEST['file']; - } else if ( isset( $_REQUEST['fdl'] ) ) { + } elseif ( isset( $_REQUEST['fdl'] ) ) { $file = $_REQUEST['fdl']; } @@ -1384,7 +1391,7 @@ class MainWP_Child { $file = ''; if ( isset( $_POST['f'] ) ) { $file = $_POST['f']; - } else if ( isset( $_POST['file'] ) ) { + } elseif ( isset( $_POST['file'] ) ) { $file = $_POST['file']; } @@ -1517,8 +1524,9 @@ class MainWP_Child { MainWP_Child_Links_Checker::Instance()->init(); MainWP_Child_WPvivid_BackupRestore::Instance()->init(); global $_wp_submenu_nopriv; - if ($_wp_submenu_nopriv === null) + if ($_wp_submenu_nopriv === null) { $_wp_submenu_nopriv = array(); // fix warning + } //Call the function required if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) { @@ -1530,11 +1538,11 @@ class MainWP_Child { MainWP_Helper::handle_fatal_error(); self::fix_for_custom_themes(); call_user_func( array( $this, $this->callableFunctions[ $_POST['function'] ] ) ); - } else if ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) { + } elseif ( isset( $_POST['function'] ) && isset( $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ) { define( 'DOING_CRON', true ); self::fix_for_custom_themes(); call_user_func( array( $this, $this->callableFunctionsNoAuth[ $_POST['function'] ] ) ); - } else if (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) { + } elseif (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && !isset($this->callableFunctions[ $_POST['function'] ]) && !isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) { MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) ); } @@ -1545,7 +1553,7 @@ class MainWP_Child { } MainWP_Keyword_Links::Instance()->update_htaccess(); // if needed MainWP_Keyword_Links::Instance()->redirect_cloak(); - } else if ( 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { + } elseif ( 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { MainWP_Keyword_Links::clear_htaccess(); // force clear } } @@ -1669,12 +1677,12 @@ class MainWP_Child { } // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } - include_once( ABSPATH . '/wp-admin/includes/template.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . '/wp-admin/includes/plugin.php'; $urlgot = json_decode( stripslashes( $_POST['url'] ) ); @@ -1807,17 +1815,17 @@ class MainWP_Child { $information = array(); - include_once( ABSPATH . '/wp-admin/includes/update.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; if ( null !== $this->filterFunction ) { add_filter( 'pre_site_transient_update_core', $this->filterFunction, 99 ); @@ -1834,7 +1842,7 @@ class MainWP_Child { foreach ( $core_updates as $core_update ) { if ( 'latest' === $core_update->response ) { $information['upgrade'] = 'SUCCESS'; - } else if ( 'upgrade' === $core_update->response && $core_update->locale === get_locale() && version_compare( $wp_version, $core_update->current, '<=' ) ) { + } elseif ( 'upgrade' === $core_update->response && $core_update->locale === get_locale() && version_compare( $wp_version, $core_update->current, '<=' ) ) { //Upgrade! $upgrade = false; if ( class_exists( 'Core_Upgrader' ) ) { @@ -1894,19 +1902,19 @@ class MainWP_Child { define( 'DOING_CRON', true ); MainWP_Helper::getWPFilesystem(); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/misc.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // to fix @wp_version_check(); @@ -1948,32 +1956,33 @@ class MainWP_Child { */ function upgradePluginTheme() { //Prevent disable/re-enable at upgrade - if (!defined( 'DOING_CRON') ) + if (!defined( 'DOING_CRON') ) { define( 'DOING_CRON', true ); + } MainWP_Helper::getWPFilesystem(); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/misc.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); - include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/plugin.php'; + include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; $information = array(); $information['upgrades'] = array(); $mwp_premium_updates_todo = array(); $mwp_premium_updates_todo_slugs = array(); if ( isset( $_POST['type'] ) && 'plugin' === $_POST['type'] ) { - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; if ( null !== $this->filterFunction ) { // ET_Automatic_Updates add_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); @@ -1985,7 +1994,7 @@ class MainWP_Child { if ( in_array( 'backupbuddy/backupbuddy.php', $plugins ) ) { if ( isset( $GLOBALS['ithemes_updater_path'] ) ) { if ( ! class_exists( 'Ithemes_Updater_Settings' ) ) { - require( $GLOBALS['ithemes_updater_path'] . '/settings.php' ); + require $GLOBALS['ithemes_updater_path'] . '/settings.php'; } if ( class_exists( 'Ithemes_Updater_Settings' ) ) { $ithemes_updater = new Ithemes_Updater_Settings(); @@ -1999,7 +2008,7 @@ class MainWP_Child { if (in_array('smart-manager-for-wp-e-commerce/smart-manager.php', $plugins)) { if (file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php') && file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php')) { include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php'; - include_once (plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php'); + include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php'; } } //// @@ -2109,11 +2118,11 @@ class MainWP_Child { if ( null !== $this->filterFunction ) { remove_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); } - } else if ( isset( $_POST['type'] ) && 'theme' === $_POST['type'] ) { + } elseif ( isset( $_POST['type'] ) && 'theme' === $_POST['type'] ) { $last_update = get_site_transient( 'update_themes' ); - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; if ( null !== $this->filterFunction ) { add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } @@ -2122,7 +2131,7 @@ class MainWP_Child { // $originalLastChecked = !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ? $last_update->last_checked : 0; @wp_update_themes(); - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + include_once ABSPATH . '/wp-admin/includes/theme.php'; // to support cached premium themes update info, hooking in the bulk_upgrade() add_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ) ); @@ -2285,14 +2294,14 @@ class MainWP_Child { 'hook_extra' => array(), ) ); $information['upgrades'][ $slug ] = ( ! is_wp_error( $result ) && ! empty( $result ) ); - } else if ( isset( $update['callback'] ) ) { + } elseif ( isset( $update['callback'] ) ) { if ( is_array( $update['callback'] ) && isset( $update['callback'][0] ) && isset( $update['callback'][1] ) ) { $update_result = @call_user_func( array( $update['callback'][0], $update['callback'][1], ) ); $information['upgrades'][ $slug ] = $update_result && true; - } else if ( is_string( $update['callback'] ) ) { + } elseif ( is_string( $update['callback'] ) ) { $update_result = @call_user_func( $update['callback'] ); $information['upgrades'][ $slug ] = $update_result && true; } else { @@ -2324,8 +2333,9 @@ class MainWP_Child { } } - if ($pre == false) + if ($pre == false) { return $false; + } return $_transient_data; } @@ -2347,8 +2357,9 @@ class MainWP_Child { } } - if ($pre == false) + if ($pre == false) { return $false; + } return $_transient_data; } @@ -2407,7 +2418,7 @@ class MainWP_Child { if ( '' != get_option( 'mainwp_child_uniqueId' ) ) { if ( ! isset( $_POST['uniqueId'] ) || ( '' === $_POST['uniqueId'] ) ) { MainWP_Helper::error( __( 'This child site is set to require a unique security ID. Please enter it before the connection can be established.', 'mainwp-child' ) ); - } else if ( get_option( 'mainwp_child_uniqueId' ) !== $_POST['uniqueId'] ) { + } elseif ( get_option( 'mainwp_child_uniqueId' ) !== $_POST['uniqueId'] ) { MainWP_Helper::error( __( 'The unique security ID mismatch! Please correct it before the connection can be established.', 'mainwp-child' ) ); } } @@ -2506,23 +2517,23 @@ class MainWP_Child { wp_update_post(array('ID' => $postId, 'post_status' => 'publish' )); } } - } else if ( 'update' === $action ) { + } elseif ( 'update' === $action ) { $postData = $_POST['post_data']; $my_post = is_array( $postData ) ? $postData : array(); wp_update_post( $my_post ); - } else if ( 'unpublish' === $action ) { + } elseif ( 'unpublish' === $action ) { $my_post['ID'] = $postId; $my_post['post_status'] = 'draft'; wp_update_post( $my_post ); - } else if ( 'trash' === $action ) { + } elseif ( 'trash' === $action ) { add_action( 'trash_post', array( 'MainWP_Child_Links_Checker', 'hook_post_deleted' ) ); wp_trash_post( $postId ); - } else if ( 'delete' === $action ) { + } elseif ( 'delete' === $action ) { add_action( 'delete_post', array( 'MainWP_Child_Links_Checker', 'hook_post_deleted' ) ); wp_delete_post( $postId, true ); - } else if ( 'restore' === $action ) { + } elseif ( 'restore' === $action ) { wp_untrash_post( $postId ); - } else if ( 'update_meta' === $action ) { + } elseif ( 'update_meta' === $action ) { $values = maybe_unserialize( base64_decode( $_POST['values'] ) ); $meta_key = $values['meta_key']; $meta_value = $values['meta_value']; @@ -2535,7 +2546,7 @@ class MainWP_Child { update_post_meta( $postId, $key, $meta_value[ $i ] ); } } - } else if ( 'get_edit' === $action ) { + } elseif ( 'get_edit' === $action ) { $postId = $_POST['id']; $post_type = $_POST['post_type']; if ( $post_type == 'post' ) { @@ -2601,7 +2612,7 @@ class MainWP_Child { } } - include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php' ); + include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; $post_featured_image = get_post_thumbnail_id( $id ); $child_upload_dir = wp_upload_dir(); $new_post = array( @@ -2646,22 +2657,22 @@ class MainWP_Child { if ( $post ) { $post_custom = get_post_custom( $id ); //post_slug = base64_decode( get_post_meta( $id, '_slug', true ) ); - include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php' ); + include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php'; $post_featured_image = get_post_thumbnail_id( $id ); $child_upload_dir = wp_upload_dir(); $new_post = array( - 'edit_id' => $id, - 'post_title' => $post->post_title, - 'post_content' => $post->post_content, - 'post_status' => $post->post_status, - 'post_date' => $post->post_date, - 'post_date_gmt' => $post->post_date_gmt, - 'post_type' => 'page', - 'post_name' => $post->post_name, - 'post_excerpt' => $post->post_excerpt, - 'comment_status' => $post->comment_status, - 'ping_status' => $post->ping_status, + 'edit_id' => $id, + 'post_title' => $post->post_title, + 'post_content' => $post->post_content, + 'post_status' => $post->post_status, + 'post_date' => $post->post_date, + 'post_date_gmt' => $post->post_date_gmt, + 'post_type' => 'page', + 'post_name' => $post->post_name, + 'post_excerpt' => $post->post_excerpt, + 'comment_status' => $post->comment_status, + 'ping_status' => $post->ping_status, ); if ( $post_featured_image != null ) { //Featured image is set, retrieve URL @@ -2678,12 +2689,12 @@ class MainWP_Child { $attachment = get_post( $attachment_id ); if ( $attachment ) { $post_gallery_images[] = array( - 'id' => $attachment_id, - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), - 'caption' => $attachment->post_excerpt, - 'description' => $attachment->post_content, - 'src' => $attachment->guid, - 'title' => $attachment->post_title, + 'id' => $attachment_id, + 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), + 'caption' => $attachment->post_excerpt, + 'description' => $attachment->post_content, + 'src' => $attachment->guid, + 'title' => $attachment->post_title, ); } } @@ -2693,11 +2704,11 @@ class MainWP_Child { wp_set_post_lock($id); $post_data = array( - 'new_post' => base64_encode( serialize( $new_post ) ), - 'post_custom' => base64_encode( serialize( $post_custom ) ), - 'post_featured_image' => base64_encode( $post_featured_image ), - 'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ), - 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), + 'new_post' => base64_encode( serialize( $new_post ) ), + 'post_custom' => base64_encode( serialize( $post_custom ) ), + 'post_featured_image' => base64_encode( $post_featured_image ), + 'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ), + 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), ); return $post_data; } @@ -2715,28 +2726,28 @@ class MainWP_Child { global $current_user; $reassign = ( isset( $current_user ) && isset( $current_user->ID ) ) ? $current_user->ID : 0; - include_once( ABSPATH . '/wp-admin/includes/user.php' ); + include_once ABSPATH . '/wp-admin/includes/user.php'; if ( 'delete' === $action ) { wp_delete_user( $userId, $reassign ); - } else if ( 'changeRole' === $action ) { + } elseif ( 'changeRole' === $action ) { $my_user = array(); $my_user['ID'] = $userId; $my_user['role'] = $extra; wp_update_user( $my_user ); - } else if ( 'update_password' === $action ) { + } elseif ( 'update_password' === $action ) { $my_user = array(); $my_user['ID'] = $userId; $my_user['user_pass'] = $user_pass; wp_update_user( $my_user ); - } else if ( 'edit' === $action ) { + } elseif ( 'edit' === $action ) { $user_data = $this->get_user_to_edit($userId); if (!empty($user_data)) { $information['user_data'] = $user_data; } else { $failed = true; } - } else if ( 'update_user' === $action ) { + } elseif ( 'update_user' === $action ) { $my_user = $_POST['extra']; if (is_array($my_user)) { foreach($my_user as $idx => $val) { @@ -2755,8 +2766,9 @@ class MainWP_Child { $failed = true; } - if ($failed) + if ($failed) { $information['status'] = 'FAIL'; + } if ( ! isset( $information['status'] ) && !isset($information['error']) ) { $information['status'] = 'SUCCESS'; @@ -2783,33 +2795,39 @@ class MainWP_Child { } $pass1 = $pass2 = ''; - if ( isset( $data['pass1'] ) ) + if ( isset( $data['pass1'] ) ) { $pass1 = $data['pass1']; - if ( isset( $data['pass2'] ) ) + } + if ( isset( $data['pass2'] ) ) { $pass2 = $data['pass2']; + } if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) { $new_role = sanitize_text_field( $data['role'] ); $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. // Multisite super admins can freely edit their blog roles -- they possess all caps. - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) + if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { $user->role = $new_role; + } // If the new role isn't editable by the logged-in user die with error $editable_roles = get_editable_roles(); - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) + if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) { return array('error' => 'You can’t give users that role.'); + } } $email = ''; - if ( isset( $data['email'] ) ) + if ( isset( $data['email'] ) ) { $email = trim( $data['email'] ); + } - if ( !empty( $email ) ) + if ( !empty( $email ) ) { $user->user_email = sanitize_text_field( wp_unslash( $email ) ); - else + } else { $user->user_email = $userdata->user_email; + } if ( isset( $data['url'] ) ) { if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) { @@ -2821,22 +2839,28 @@ class MainWP_Child { } } - if ( isset( $data['first_name'] ) ) + if ( isset( $data['first_name'] ) ) { $user->first_name = sanitize_text_field( $data['first_name'] ); - if ( isset( $data['last_name'] ) ) + } + if ( isset( $data['last_name'] ) ) { $user->last_name = sanitize_text_field( $data['last_name'] ); - if ( isset( $data['nickname'] ) && !empty($data['nickname'])) + } + if ( isset( $data['nickname'] ) && !empty($data['nickname'])) { $user->nickname = sanitize_text_field( $data['nickname'] ); - if ( isset( $data['display_name'] ) ) + } + if ( isset( $data['display_name'] ) ) { $user->display_name = sanitize_text_field( $data['display_name'] ); - if ( isset( $data['description'] ) ) + } + if ( isset( $data['description'] ) ) { $user->description = trim( $data['description'] ); + } $errors = new WP_Error(); /* checking that username has been typed */ - if ( $user->user_login == '' ) + if ( $user->user_login == '' ) { $errors->add( 'user_login', __( 'ERROR: Please enter a username.' ) ); + } do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); @@ -2856,8 +2880,9 @@ class MainWP_Child { $errors->add( 'pass', __( 'ERROR: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); } - if ( !empty( $pass1 ) ) + if ( !empty( $pass1 ) ) { $user->user_pass = $pass1; + } } else { $user->user_pass = $userdata->user_pass; } @@ -2883,8 +2908,9 @@ class MainWP_Child { if ( $errors->get_error_codes() ) { $error_str = ''; foreach ( $errors->get_error_messages() as $message ) { - if ( is_string( $message ) ) + if ( is_string( $message ) ) { $error_str .= ' ' . esc_html( strip_tags( $message ) ); + } } return array( 'error' => $error_str ); @@ -2896,7 +2922,7 @@ class MainWP_Child { } function get_user_to_edit( $user_id ) { - require_once(ABSPATH . 'wp-admin/includes/user.php'); + require_once ABSPATH . 'wp-admin/includes/user.php'; $profileuser = get_user_to_edit($user_id); $edit_data = array(); @@ -2912,19 +2938,22 @@ class MainWP_Child { $public_display['display_nickname'] = $profileuser->nickname; $public_display['display_username'] = $profileuser->user_login; - if ( !empty($profileuser->first_name) ) + if ( !empty($profileuser->first_name) ) { $public_display['display_firstname'] = $profileuser->first_name; + } - if ( !empty($profileuser->last_name) ) + if ( !empty($profileuser->last_name) ) { $public_display['display_lastname'] = $profileuser->last_name; + } if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; } - if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere + if ( !in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; + } $public_display = array_map( 'trim', $public_display ); $public_display = array_unique( $public_display ); @@ -2949,18 +2978,18 @@ class MainWP_Child { if ( 'approve' === $action ) { wp_set_comment_status( $commentId, 'approve' ); - } else if ( 'unapprove' === $action ) { + } elseif ( 'unapprove' === $action ) { wp_set_comment_status( $commentId, 'hold' ); - } else if ( 'spam' === $action ) { + } elseif ( 'spam' === $action ) { wp_spam_comment( $commentId ); - } else if ( 'unspam' === $action ) { + } elseif ( 'unspam' === $action ) { wp_unspam_comment( $commentId ); - } else if ( 'trash' === $action ) { + } elseif ( 'trash' === $action ) { add_action( 'trashed_comment', array( 'MainWP_Child_Links_Checker', 'hook_trashed_comment' ), 10, 1 ); wp_trash_comment( $commentId ); - } else if ( 'restore' === $action ) { + } elseif ( 'restore' === $action ) { wp_untrash_comment( $commentId ); - } else if ( 'delete' === $action ) { + } elseif ( 'delete' === $action ) { wp_delete_comment( $commentId, true ); } else { $information['status'] = 'FAIL'; @@ -2983,17 +3012,17 @@ class MainWP_Child { $information['success'] ++; if ( 'approve' === $action ) { wp_set_comment_status( $commentId, 'approve' ); - } else if ( 'unapprove' === $action ) { + } elseif ( 'unapprove' === $action ) { wp_set_comment_status( $commentId, 'hold' ); - } else if ( 'spam' === $action ) { + } elseif ( 'spam' === $action ) { wp_spam_comment( $commentId ); - } else if ( 'unspam' === $action ) { + } elseif ( 'unspam' === $action ) { wp_unspam_comment( $commentId ); - } else if ( 'trash' === $action ) { + } elseif ( 'trash' === $action ) { wp_trash_comment( $commentId ); - } else if ( 'restore' === $action ) { + } elseif ( 'restore' === $action ) { wp_untrash_comment( $commentId ); - } else if ( 'delete' === $action ) { + } elseif ( 'delete' === $action ) { wp_delete_comment( $commentId, true ); } else { $information['success']--; @@ -3008,7 +3037,7 @@ class MainWP_Child { //Read form data $new_password = maybe_unserialize( base64_decode( $_POST['new_password'] ) ); $user = get_user_by( 'login', $_POST['user'] ); - require_once( ABSPATH . WPINC . '/registration.php' ); + require_once ABSPATH . WPINC . '/registration.php'; $id = wp_update_user( array( 'ID' => $user->ID, 'user_pass' => $new_password['user_pass'] ) ); if ( $id !== $user->ID ) { @@ -3156,7 +3185,7 @@ class MainWP_Child { } else { $information['status'] = 'stalled'; } - } else if ( $wp_filesystem->is_file( $doneFile ) ) { + } elseif ( $wp_filesystem->is_file( $doneFile ) ) { $file = $wp_filesystem->get_contents( $doneFile ); $information['status'] = 'done'; $information['file'] = basename( $file ); @@ -3303,7 +3332,7 @@ class MainWP_Child { $file = false; if ( isset( $_POST['f'] ) ) { $file = $_POST['f']; - } else if ( isset( $_POST['file'] ) ) { + } elseif ( isset( $_POST['file'] ) ) { $file = $_POST['file']; } @@ -3327,7 +3356,7 @@ class MainWP_Child { $information['size'] = $res['filesize']; } $information['db'] = false; - } else if ( 'db' == $_POST['type'] ) { + } elseif ( 'db' == $_POST['type'] ) { $ext = 'zip'; if ( isset( $_POST['ext'] ) ) { $ext = $_POST['ext']; @@ -3591,7 +3620,7 @@ class MainWP_Child { MainWP_Helper::update_option( 'mainwp_child_pluginDir', $_POST['pluginDir'], 'yes' ); $update_htaccess = true; } - } else if ( false !== get_option( 'mainwp_child_pluginDir' ) ) { + } elseif ( false !== get_option( 'mainwp_child_pluginDir' ) ) { MainWP_Helper::update_option( 'mainwp_child_pluginDir', false, 'yes' ); $update_htaccess = true; } @@ -3652,7 +3681,7 @@ class MainWP_Child { } $information['nossl'] = ( 1 == $nossl ? 1 : 0 ); - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + include_once ABSPATH . '/wp-admin/includes/update.php'; $timeout = 3 * 60 * 60; // 3minutes @set_time_limit( $timeout ); @@ -3696,7 +3725,7 @@ class MainWP_Child { foreach ( $update_check as $updateFeedback ) { if ( is_array( $updateFeedback['callback'] ) && isset( $updateFeedback['callback'][0] ) && isset( $updateFeedback['callback'][1] ) ) { @call_user_func( array( $updateFeedback['callback'][0], $updateFeedback['callback'][1] ) ); - } else if ( is_string( $updateFeedback['callback'] ) ) { + } elseif ( is_string( $updateFeedback['callback'] ) ) { @call_user_func( $updateFeedback['callback'] ); } } @@ -3717,7 +3746,7 @@ class MainWP_Child { if ( 'plugin' === $informationPremiumUpdates[ $i ]['type'] ) { $premiumPlugins[] = $slug; - } else if ( 'theme' === $informationPremiumUpdates[ $i ]['type'] ) { + } elseif ( 'theme' === $informationPremiumUpdates[ $i ]['type'] ) { $premiumThemes[] = $slug; } @@ -3750,7 +3779,7 @@ class MainWP_Child { $wp_current_filter[] = 'load-plugins.php'; @wp_update_plugins(); - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + include_once ABSPATH . '/wp-admin/includes/plugin.php'; $plugin_updates = get_plugin_updates(); if ( is_array( $plugin_updates ) ) { @@ -3805,7 +3834,7 @@ class MainWP_Child { add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } @wp_update_themes(); - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + include_once ABSPATH . '/wp-admin/includes/theme.php'; $theme_updates = $this->upgrade_get_theme_updates(); if ( is_array( $theme_updates ) ) { $information['theme_updates'] = array(); @@ -3860,10 +3889,10 @@ class MainWP_Child { break; } } - } else if ( 'theme' === $translation_update->type ) { + } elseif ( 'theme' === $translation_update->type ) { $theme = wp_get_theme($translation_update->slug); $new_translation_update['name'] = $theme->name; - } else if ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) { + } elseif ( ( 'core' === $translation_update->type ) && ( 'default' === $translation_update->slug ) ) { $new_translation_update['name'] = 'WordPress core'; } $information['translation_updates'][] = $new_translation_update; @@ -4024,8 +4053,9 @@ class MainWP_Child { function get_site_icon() { $information = array(); $url = $this->get_favicon( true ); - if ( !empty( $url ) ) + if ( !empty( $url ) ) { $information['faviIconUrl'] = $url; + } MainWP_Helper::write( $information ); } @@ -4046,7 +4076,7 @@ class MainWP_Child { if ( empty( $favi ) ) { if ( file_exists( ABSPATH . 'favicon.ico' ) ) { $favi = 'favicon.ico'; - } else if ( file_exists( ABSPATH . 'favicon.png' ) ) { + } elseif ( file_exists( ABSPATH . 'favicon.png' ) ) { $favi = 'favicon.png'; } @@ -4067,7 +4097,7 @@ class MainWP_Child { if ( preg_match( $preg_str1, $request['body'], $matches ) ) { $favi = $matches[2]; - } else if ( preg_match( $preg_str2, $request['body'], $matches ) ) { + } elseif ( preg_match( $preg_str2, $request['body'], $matches ) ) { $favi = $matches[2]; } } @@ -4192,9 +4222,9 @@ class MainWP_Child { $tokens = $extra['tokens']; if ( 1 == $extra['extract_post_type'] ) { $args['post_type'] = 'post'; - } else if ( 2 == $extra['extract_post_type'] ) { + } elseif ( 2 == $extra['extract_post_type'] ) { $args['post_type'] = 'page'; - } else if ( 3 == $extra['extract_post_type'] ) { + } elseif ( 3 == $extra['extract_post_type'] ) { $args['post_type'] = array( 'post', 'page' ); } } @@ -4385,7 +4415,7 @@ class MainWP_Child { $where = ' WHERE '; if ( ! empty( $start_date ) && ! empty( $end_date ) ) { $where .= " p.post_date>='$start_date' AND p.post_date<='$end_date' AND "; - } else if ( ! empty( $start_date ) && empty( $end_date ) ) { + } elseif ( ! empty( $start_date ) && empty( $end_date ) ) { $where .= " p.post_date='$start_date' AND "; } $where .= " ( p.post_status='publish' OR p.post_status='future' OR p.post_status='draft' ) @@ -4416,7 +4446,7 @@ class MainWP_Child { if ( ! $result ) { $information['status'] = 'SUCCESS'; } - } else if ( $cancel_all ) { + } elseif ( $cancel_all ) { $post_type = $_POST['post_type']; $where = " WHERE p.post_status='future' AND p.post_type = %s AND pm.meta_key = '_is_auto_generate_content' AND pm.meta_value = 'yes' "; $posts = $wpdb->get_results( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id $where ", $post_type) ); @@ -4497,14 +4527,14 @@ class MainWP_Child { $where_post_date = isset($_POST['where_post_date']) && !empty($_POST['where_post_date']) ? true : false; if ( isset( $_POST['postId'] ) ) { $this->posts_where_suffix .= " AND $wpdb->posts.ID = " . $_POST['postId']; - } else if ( isset( $_POST['userId'] ) ) { + } elseif ( isset( $_POST['userId'] ) ) { $this->posts_where_suffix .= " AND $wpdb->posts.post_author = " . $_POST['userId']; } else { if ( isset( $_POST['keyword'] ) ) { $search_on = isset($_POST['search_on']) ? $_POST['search_on'] : ''; if ($search_on == 'title') { $this->posts_where_suffix .= " AND ( $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )"; - } else if ($search_on == 'content') { + } elseif ($search_on == 'content') { $this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' )"; } else { $this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' OR $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )"; @@ -4595,7 +4625,7 @@ class MainWP_Child { function get_recent_comments( $pAllowedStatuses, $pCount ) { if ( ! function_exists( 'get_comment_author_url' ) ) { - include_once( WPINC . '/comment-template.php' ); + include_once WPINC . '/comment-template.php'; } $allComments = array(); @@ -4637,23 +4667,23 @@ class MainWP_Child { $theme = $_POST['theme']; if ( 'activate' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + include_once ABSPATH . '/wp-admin/includes/theme.php'; $theTheme = wp_get_theme( $theme ); if ( null !== $theTheme && '' !== $theTheme ) { switch_theme( $theTheme['Template'], $theTheme['Stylesheet'] ); } - } else if ( 'delete' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/theme.php' ); + } elseif ( 'delete' === $action ) { + include_once ABSPATH . '/wp-admin/includes/theme.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/template.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/template.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; $wp_filesystem = $this->getWPFilesystem(); if ( empty( $wp_filesystem ) ) { @@ -4725,7 +4755,7 @@ class MainWP_Child { if ( '' == $keyword || stristr( $out['title'], $keyword ) ) { $rslt[] = $out; } - } else if ( $out['active'] === ( ( 'active' === $status ) ? 1 : 0 ) ) { + } elseif ( $out['active'] === ( ( 'active' === $status ) ? 1 : 0 ) ) { if ( '' == $keyword || stristr( $out['title'], $keyword ) ) { $rslt[] = $out; } @@ -4742,7 +4772,7 @@ class MainWP_Child { $plugins = explode( '||', $_POST['plugin'] ); if ( 'activate' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + include_once ABSPATH . '/wp-admin/includes/plugin.php'; foreach ( $plugins as $idx => $plugin ) { if ( $plugin !== $this->plugin_slug ) { @@ -4758,8 +4788,8 @@ class MainWP_Child { } } } - } else if ( 'deactivate' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + } elseif ( 'deactivate' === $action ) { + include_once ABSPATH . '/wp-admin/includes/plugin.php'; foreach ( $plugins as $idx => $plugin ) { if ( $plugin !== $this->plugin_slug ) { @@ -4769,18 +4799,18 @@ class MainWP_Child { } } } - } else if ( 'delete' === $action ) { - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); + } elseif ( 'delete' === $action ) { + include_once ABSPATH . '/wp-admin/includes/plugin.php'; // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } - include_once( ABSPATH . '/wp-admin/includes/file.php' ); - include_once( ABSPATH . '/wp-admin/includes/template.php' ); - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php' ); - include_once( ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php' ); + include_once ABSPATH . '/wp-admin/includes/file.php'; + include_once ABSPATH . '/wp-admin/includes/template.php'; + include_once ABSPATH . '/wp-admin/includes/misc.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; + include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; $wp_filesystem = $this->getWPFilesystem(); if ( null === $wp_filesystem ) { @@ -4828,7 +4858,7 @@ class MainWP_Child { function get_all_plugins_int( $filter, $keyword = '', $status = '' ) { if ( ! function_exists( 'get_plugins' ) ) { - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + include_once ABSPATH . 'wp-admin/includes/plugin.php'; } $rslt = array(); $plugins = get_plugins(); @@ -4847,7 +4877,7 @@ class MainWP_Child { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } - } else if ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { + } elseif ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } @@ -4870,7 +4900,7 @@ class MainWP_Child { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } - } else if ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { + } elseif ( $out['active'] == ( ( $status == 'active' ) ? 1 : 0 ) ) { if ( '' == $keyword || stristr( $out['name'], $keyword ) ) { $rslt[] = $out; } @@ -4904,8 +4934,9 @@ class MainWP_Child { } } } - if ($return) + if ($return) { return $allusers; + } MainWP_Helper::write( $allusers ); } @@ -4913,8 +4944,9 @@ class MainWP_Child { $allusers = array(); $params = array(); - if ($number) + if ($number) { $params['number'] = $number; + } $new_users = get_users($params); if ( is_array( $new_users ) ) { @@ -5015,7 +5047,7 @@ class MainWP_Child { //Deactivating the plugin function deactivate() { - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + include_once ABSPATH . 'wp-admin/includes/plugin.php'; deactivate_plugins( $this->plugin_slug, true ); $information = array(); if ( is_plugin_active( $this->plugin_slug ) ) { @@ -5027,8 +5059,9 @@ class MainWP_Child { function activation() { $mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false); - if ($mu_plugin_enabled) + if ($mu_plugin_enabled) { return; + } $to_delete = array( 'mainwp_child_pubkey', @@ -5054,8 +5087,9 @@ class MainWP_Child { function deactivation( $deact = true) { $mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false); - if ($mu_plugin_enabled) + if ($mu_plugin_enabled) { return; + } $to_delete = array( 'mainwp_child_pubkey', @@ -5075,8 +5109,9 @@ class MainWP_Child { } } - if ($deact) + if ($deact) { do_action( 'mainwp_child_deactivation' ); + } } function getWPFilesystem() { @@ -5086,10 +5121,10 @@ class MainWP_Child { ob_start(); // if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php'); if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } $creds = request_filesystem_credentials( 'test', '', false, false, $extra_fields = null ); ob_end_clean(); @@ -5101,7 +5136,7 @@ class MainWP_Child { if ( empty( $wp_filesystem ) ) { MainWP_Helper::error( $this->FTP_ERROR ); - } else if ( is_wp_error( $wp_filesystem->errors ) ) { + } elseif ( is_wp_error( $wp_filesystem->errors ) ) { $errorCodes = $wp_filesystem->errors->get_error_codes(); if ( ! empty( $errorCodes ) ) { MainWP_Helper::error( __( 'WordPress Filesystem error: ', 'mainwp-child' ) . $wp_filesystem->errors->get_error_message() ); @@ -5274,7 +5309,7 @@ class MainWP_Child { MainWP_Helper::write( $information ); return; - } else if ( 'clear_settings' === $_POST['action'] ) { + } elseif ( 'clear_settings' === $_POST['action'] ) { delete_option( 'mainwp_maintenance_opt_alert_404' ); delete_option( 'mainwp_maintenance_opt_alert_404_email' ); $information['result'] = 'SUCCESS'; @@ -5500,7 +5535,7 @@ class MainWP_Child { $code = stripslashes( $_POST['code'] ); if ( 'run_snippet' === $action ) { $information = MainWP_Tools::execute_snippet( $code ); - } else if ( 'save_snippet' === $action ) { + } elseif ( 'save_snippet' === $action ) { $type = $_POST['type']; $slug = $_POST['slug']; $snippets = get_option( 'mainwp_ext_code_snippets' ); @@ -5520,7 +5555,7 @@ class MainWP_Child { } } MainWP_Helper::update_option( 'mainwp_ext_snippets_enabled', true, 'yes' ); - } else if ( 'delete_snippet' === $action ) { + } elseif ( 'delete_snippet' === $action ) { $type = $_POST['type']; $slug = $_POST['slug']; $snippets = get_option( 'mainwp_ext_code_snippets' ); @@ -5566,7 +5601,7 @@ class MainWP_Child { if ( 'delete' === $action ) { $wpConfig = preg_replace( '/' . PHP_EOL . '{1,2}\/\*\*\*snippet_' . $slug . '\*\*\*\/(.*)\/\*\*\*end_' . $slug . '\*\*\*\/' . PHP_EOL . '/is', '', $wpConfig ); - } else if ( 'save' === $action ) { + } elseif ( 'save' === $action ) { $wpConfig = preg_replace( '/(\$table_prefix *= *[\'"][^\'|^"]*[\'"] *;)/is', '${1}' . PHP_EOL . PHP_EOL . '/***snippet_' . $slug . '***/' . PHP_EOL . $code . PHP_EOL . '/***end_' . $slug . '***/' . PHP_EOL, $wpConfig ); } file_put_contents( $config_file, $wpConfig ); @@ -5611,7 +5646,7 @@ class MainWP_Child { if ( strpos( $path, 'wp-content' ) === 0 ) { $path = basename( WP_CONTENT_DIR ) . substr( $path, 10 ); - } else if ( strpos( $path, 'wp-includes' ) === 0 ) { + } elseif ( strpos( $path, 'wp-includes' ) === 0 ) { $path = WPINC . substr( $path, 11 ); } @@ -5824,7 +5859,7 @@ class MainWP_Child { static function fix_for_custom_themes() { if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( function_exists( 'et_register_updates_component' ) ) { diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index 7876ccd..24c7cc2 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -12,16 +12,16 @@ class MainWP_Clone_Install { * @param string $file The zip backup file path */ public function __construct( $file ) { - require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' ); + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->file = $file; if ( '.zip' === substr( $this->file, - 4 ) ) { $this->archiver = null; - } else if ( '.tar.gz' === substr( $this->file, - 7 ) ) { + } elseif ( '.tar.gz' === substr( $this->file, - 7 ) ) { $this->archiver = new Tar_Archiver( null, 'tar.gz' ); - } else if ( '.tar.bz2' === substr( $this->file, - 8 ) ) { + } elseif ( '.tar.bz2' === substr( $this->file, - 8 ) ) { $this->archiver = new Tar_Archiver( null, 'tar.bz2' ); - } else if ( '.tar' === substr( $this->file, - 4 ) ) { + } elseif ( '.tar' === substr( $this->file, - 4 ) ) { $this->archiver = new Tar_Archiver( null, 'tar' ); } } @@ -58,9 +58,9 @@ class MainWP_Clone_Install { if ( null !== $this->archiver ) { - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { //todo: implement - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { @@ -114,9 +114,9 @@ class MainWP_Clone_Install { } return $this->archiver->file_exists( $file ); - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { //todo: implement - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { @@ -374,7 +374,7 @@ class MainWP_Clone_Install { } else { if ( $this->checkZipConsole() ) { //todo: implement - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { @@ -419,13 +419,13 @@ class MainWP_Clone_Install { } return $this->archiver->extractTo( ABSPATH ); - } else if ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) { + } elseif ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) { return $this->extractWPZipBackup(); - } else if ( $this->checkZipConsole() ) { + } elseif ( $this->checkZipConsole() ) { return $this->extractZipConsoleBackup(); - } else if ( $this->checkZipSupport() ) { + } elseif ( $this->checkZipSupport() ) { return $this->extractZipBackup(); - } else if ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) { + } elseif ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) { return $this->extractWPZipBackup(); } else { return $this->extractZipPclBackup(); diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 0f51435..3f7c36f 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -18,7 +18,7 @@ class MainWP_Clone { } if ( ! function_exists( 'wp_create_nonce' ) ) { - include_once( ABSPATH . WPINC . '/pluggable.php' ); + include_once ABSPATH . WPINC . '/pluggable.php'; } $this->security_nonces[ $action ] = wp_create_nonce( $action ); } @@ -112,7 +112,7 @@ class MainWP_Clone { if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { - require_once( ABSPATH . 'wp-admin/includes/file.php' ); + require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_FILES['file']; $upload_overrides = array( 'test_form' => false ); @@ -254,7 +254,7 @@ class MainWP_Clone { if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { - require_once( ABSPATH . 'wp-admin/includes/file.php' ); + require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_FILES['file']; $upload_overrides = array( 'test_form' => false ); @@ -1414,7 +1414,7 @@ class MainWP_Clone { throw new Exception( __( 'No download file found', 'mainwp-child' ) ); } $file = $archiveFile; - } else if ( file_exists( $file ) ) { + } elseif ( file_exists( $file ) ) { $testFull = true; } else { $file = ABSPATH . $file; diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php index 136a925..449d338 100755 --- a/class/class-mainwp-custom-post-type.php +++ b/class/class-mainwp-custom-post-type.php @@ -114,7 +114,7 @@ class MainWP_Custom_Post_Type { $serverHref = 'href="' . $serverHost; $replaceServerHref = 'href="' . parse_url( $localUrl, PHP_URL_SCHEME ) . '://' . parse_url( $localUrl, PHP_URL_HOST ); $post_content = str_replace( $serverHref, $replaceServerHref, $post_content ); - } else if ( strpos( $hrefLink, 'http' ) !== false ) { + } elseif ( strpos( $hrefLink, 'http' ) !== false ) { $lnkToReplace = dirname( $hrefLink ); if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { $post_content = str_replace( $lnkToReplace, $linkToReplaceWith, $post_content ); @@ -286,7 +286,7 @@ class MainWP_Custom_Post_Type { // MainWP Categories if ( ! empty( $data['categories'] ) && is_array( $data['categories'] ) ) { // Contains wp_create_categories - include_once( ABSPATH . 'wp-admin/includes/taxonomy.php' ); + include_once ABSPATH . 'wp-admin/includes/taxonomy.php'; $categories = $data['categories']; if ( $data['post_only_existing'] == '0' ) { $post_category = wp_create_categories( $categories, $post_id ); diff --git a/class/class-mainwp-debug.php b/class/class-mainwp-debug.php index 2615c67..4cce37d 100644 --- a/class/class-mainwp-debug.php +++ b/class/class-mainwp-debug.php @@ -21,7 +21,7 @@ class MainWP_Debug { $_POST['excludenonwp'] = '1'; $_POST['ext'] = 'tar.gz'; print_r( $mainwpChild->backup( false ) ); - } else if ( 'test' == $_GET['mainwpdebug'] ) { + } elseif ( 'test' == $_GET['mainwpdebug'] ) { print_r( get_included_files() ); } else { print_r( $mainwpChild->getSiteStats( array(), false ) ); diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 55bf006..9fd4387 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -58,8 +58,9 @@ class MainWP_Helper { static function error( $error, $code = null ) { $information['error'] = $error; - if (null !== $code) + if (null !== $code) { $information['error_code'] = $code; + } self::write( $information ); } @@ -110,7 +111,8 @@ class MainWP_Helper { $selector = trim($val[$i], " \r\n\t"); if(!empty($selector)){ - if(!isset($new[$selector])) $new[$selector] = array(); + if(!isset($new[$selector])) { $new[$selector] = array(); + } $rules = explode(';', $val[++$i]); foreach($rules as $rule){ $rule = trim($rule, " \r\n\t"); @@ -119,8 +121,9 @@ class MainWP_Helper { $property = trim(array_pop($rule), " \r\n\t"); $value = implode(':', array_reverse($rule)); - if(!isset($new[$selector][$property]) || !preg_match('/!important/', $new[$selector][$property])) $new[$selector][$property] = $value; - elseif(preg_match('/!important/', $new[$selector][$property]) && preg_match('/!important/', $value)) $new[$selector][$property] = $value; + if(!isset($new[$selector][$property]) || !preg_match('/!important/', $new[$selector][$property])) { $new[$selector][$property] = $value; + } elseif(preg_match('/!important/', $new[$selector][$property]) && preg_match('/!important/', $value)) { $new[$selector][$property] = $value; + } } } } @@ -135,7 +138,8 @@ class MainWP_Helper { $output .= $media . " {\n"; $prefix = "\t"; } - else $prefix = ''; + else { $prefix = ''; + } foreach($content as $selector => $rules){ $output .= $prefix . $selector . " {\n"; @@ -155,9 +159,10 @@ class MainWP_Helper { // $check_file_existed: to support checking if file existed // $parent_id: optional static function uploadImage( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) { - if ( !is_array($img_data) ) + if ( !is_array($img_data) ) { $img_data = array(); - include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url + } + include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url $upload_dir = wp_upload_dir(); //Download $img_url $temporary_file = download_url( $img_url ); @@ -233,11 +238,12 @@ class MainWP_Helper { } $attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database - require_once( ABSPATH . 'wp-admin/includes/image.php' ); + require_once ABSPATH . 'wp-admin/includes/image.php'; $attach_data = wp_generate_attachment_metadata( $attach_id, $local_img_path ); wp_update_attachment_metadata( $attach_id, $attach_data ); //Update generated metadata - if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) + if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) { update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] ); + } return array( 'id' => $attach_id, 'url' => $local_img_url ); } } @@ -364,7 +370,7 @@ class MainWP_Helper { if ( $is_robot_post ) { // retirement soon if ( 1 === $post_author ) { $new_post['post_author'] = $current_uid; - } else if ( ! is_numeric( $post_author ) ) { + } elseif ( ! is_numeric( $post_author ) ) { $user_author = get_user_by( 'login', $post_author ); if ( $user_author ) { $post_author = $user_author->ID; @@ -373,7 +379,7 @@ class MainWP_Helper { $post_author = wp_create_user( $post_author, $random_password, $post_author . '@asdf.com' ); } } - } else if ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) { + } elseif ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) { $_author = get_user_by( 'login', $new_post['custom_post_author'] ); if ( ! empty( $_author ) ) { $new_post['post_author'] = $_author->ID; @@ -410,7 +416,7 @@ class MainWP_Helper { if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) { $edit_post_id = current($post_custom['_mainwp_edit_post_id']); - } else if (isset( $new_post['ID'] ) && $new_post['ID']) { + } elseif (isset( $new_post['ID'] ) && $new_post['ID']) { $edit_post_id = $new_post['ID']; } @@ -424,8 +430,9 @@ class MainWP_Helper { } $check_image_existed = false; - if ( $edit_post_id ) + if ( $edit_post_id ) { $check_image_existed = true; // if editing post then will check if image existed + } //Search for all the images added to the new post //some images have a href tag to click to navigate to the image.. we need to replace this too @@ -583,8 +590,9 @@ class MainWP_Helper { return array( 'error' => 'Empty post id'); } - if ( !$edit_post_id ) + if ( !$edit_post_id ) { wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) ); + } if ( ! empty( $terms ) ) { wp_set_object_terms( $new_post_id, array_map( intval, $terms ), 'category' ); @@ -641,8 +649,9 @@ class MainWP_Helper { foreach ( $post_custom as $meta_key => $meta_values ) { if ( ! in_array( $meta_key, $not_allowed ) ) { foreach ( $meta_values as $meta_value ) { - if (strpos($meta_key, '_mainwp_spinner_') === 0) + if (strpos($meta_key, '_mainwp_spinner_') === 0) { continue; // not save + } if ( ! $seo_ext_activated ) { // if WordPress SEO plugin is not activated do not save yoast post meta @@ -653,13 +662,13 @@ class MainWP_Helper { update_post_meta( $new_post_id, $meta_key, $meta_value ); } } - } else if ( '_sticky' === $meta_key ) { + } elseif ( '_sticky' === $meta_key ) { foreach ( $meta_values as $meta_value ) { if ( 'sticky' === base64_decode( $meta_value ) ) { stick_post( $new_post_id ); } } - } else if ( '_post_to_only_existing_categories' === $meta_key ) { + } elseif ( '_post_to_only_existing_categories' === $meta_key ) { if ( isset( $meta_values[0] ) && $meta_values[0] ) { $post_to_only_existing_categories = true; } @@ -692,7 +701,7 @@ class MainWP_Helper { } //If categories exist, create them (second parameter of wp_create_categories adds the categories to the post) - include_once( ABSPATH . 'wp-admin/includes/taxonomy.php' ); //Contains wp_create_categories + include_once ABSPATH . 'wp-admin/includes/taxonomy.php'; //Contains wp_create_categories if ( isset( $post_category ) && '' !== $post_category ) { $categories = explode( ',', $post_category ); if ( count( $categories ) > 0 ) { @@ -727,7 +736,7 @@ class MainWP_Helper { 'post_excerpt' => $_image_data['caption'], 'post_content' => $_image_data['description'], 'post_title' => $_image_data['title'], - ) + ) ); } } @@ -923,10 +932,10 @@ class MainWP_Helper { // include_once( ABSPATH . '/wp-admin/includes/deprecated.php' ); // } if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/screen.php' ); + include_once ABSPATH . '/wp-admin/includes/screen.php'; } if ( file_exists( ABSPATH . '/wp-admin/includes/template.php' ) ) { - include_once( ABSPATH . '/wp-admin/includes/template.php' ); + include_once ABSPATH . '/wp-admin/includes/template.php'; } $creds = request_filesystem_credentials( 'test' ); ob_end_clean(); @@ -964,7 +973,7 @@ class MainWP_Helper { if ( ! $showHttp ) { $url = substr( $url, 7 ); } - } else if ( self::startsWith( $pUrl, 'https://' ) ) { + } elseif ( self::startsWith( $pUrl, 'https://' ) ) { if ( ! $showHttp ) { $url = substr( $url, 8 ); } @@ -1022,8 +1031,9 @@ class MainWP_Helper { //$agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'; $agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)'; - if (!is_array( $postdata )) + if (!is_array( $postdata )) { $postdata = array(); + } $postdata['json_result'] = true; // forced all response in json format @@ -1041,14 +1051,14 @@ class MainWP_Helper { if ( ( false === $data ) && ( 0 === $http_status ) ) { throw new Exception( 'Http Error: ' . $err ); - } else if ( preg_match( '/(.*)<\/mainwp>/', $data, $results ) > 0 ) { + } elseif ( preg_match( '/(.*)<\/mainwp>/', $data, $results ) > 0 ) { $result = $results[1]; $result_base = base64_decode( $result ); //$information = maybe_unserialize( $result_base ); $information = json_decode( $result_base, true ); // it is json_encode result return $information; - } else if ( '' === $data ) { + } elseif ( '' === $data ) { throw new Exception( __( 'Something went wrong while contacting the child site. Please check if there is an error on the child site. This error could also be caused by trying to clone or restore a site to large for your server settings.', 'mainwp-child' ) ); } else { throw new Exception( __( 'Child plugin is disabled or the security key is incorrect. Please resync with your main installation.', 'mainwp-child' ) ); @@ -1234,8 +1244,9 @@ class MainWP_Helper { static function update_lasttime_backup( $by, $time ) { $backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule'); - if (!in_array($by, $backup_by)) + if (!in_array($by, $backup_by)) { return false; + } $lasttime = get_option('mainwp_lasttime_backup_' . $by); if ( $time > $lasttime ) { @@ -1246,8 +1257,9 @@ class MainWP_Helper { } static function get_lasttime_backup( $by ) { - if ($by == 'backupwp') // to compatible + if ($by == 'backupwp') { // to compatible $by = 'backupwordpress'; + } switch($by) { case 'backupbuddy': if ( !is_plugin_active( 'backupbuddy/backupbuddy.php' ) && !is_plugin_active( 'Backupbuddy/backupbuddy.php' )) { @@ -1356,9 +1368,9 @@ class MainWP_Helper { if ( self::startsWith( $value, substr( $exclude, 0, strlen( $exclude ) - 1 ) ) ) { return true; } - } else if ( $value == $exclude ) { + } elseif ( $value == $exclude ) { return true; - } else if ( self::startsWith( $value, $exclude . '/' ) ) { + } elseif ( self::startsWith( $value, $exclude . '/' ) ) { return true; } } @@ -1444,7 +1456,8 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } public static function sanitize_filename( $filename ) { - if (!function_exists('mb_ereg_replace')) return sanitize_file_name($filename); + if (!function_exists('mb_ereg_replace')) { return sanitize_file_name($filename); + } // Remove anything which isn't a word, whitespace, number // or any of the following caracters -_~,;:[](). @@ -1515,14 +1528,16 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } public static function isSSLEnabled() { - if ( defined( 'MAINWP_NOSSL' ) ) return !MAINWP_NOSSL; + if ( defined( 'MAINWP_NOSSL' ) ) { return !MAINWP_NOSSL; + } return function_exists( 'openssl_verify' ); } public static function is_screen_with_update() { - if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined('DOING_CRON') && DOING_CRON ) ) + if ( ( defined('DOING_AJAX') && DOING_AJAX ) || ( defined('DOING_CRON') && DOING_CRON ) ) { return false; + } if (function_exists('get_current_screen')) { $screen = get_current_screen(); @@ -1555,10 +1570,11 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = if (!empty($missing)) { $message = 'Missing file(s): ' . implode(',', $missing); - if ($return) + if ($return) { return $message; - else + } else { throw new Exception( $message ); + } } return true; } @@ -1572,8 +1588,9 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } } } else { - if ( !class_exists($classes) ) + if ( !class_exists($classes) ) { $missing[] = $classes; + } } if ( !empty($missing) ) { @@ -1596,9 +1613,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = $missing[] = $name; } } - } else if (!empty($methods)) { - if ( !method_exists($object, $methods) ) + } elseif (!empty($methods)) { + if ( !method_exists($object, $methods) ) { $missing[] = $methods; + } } @@ -1622,9 +1640,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = $missing[] = $name; } } - } else if (!empty($properties)) { - if ( !property_exists($object, $properties) ) + } elseif (!empty($properties)) { + if ( !property_exists($object, $properties) ) { $missing[] = $properties; + } } @@ -1648,9 +1667,10 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = $missing[] = $name; } } - } else if (!empty($funcs)) { - if ( !function_exists($funcs) ) + } elseif (!empty($funcs)) { + if ( !function_exists($funcs) ) { $missing[] = $funcs; + } } diff --git a/class/class-mainwp-keyword-links.php b/class/class-mainwp-keyword-links.php index 7ae8f1f..99b77a9 100644 --- a/class/class-mainwp-keyword-links.php +++ b/class/class-mainwp-keyword-links.php @@ -95,13 +95,13 @@ class MainWP_Keyword_Links { function update_htaccess( $force_update = false, $force_clear = false ) { if ( $force_clear ) { $this->do_update_htaccess( true ); - } else if ( $force_update ) { + } elseif ( $force_update ) { return $this->do_update_htaccess(); } else { if ( '' == get_option( 'permalink_structure' ) && 'yes' !== get_option( 'mainwp_keyword_links_htaccess_set' ) ) { $this->do_update_htaccess(); } // need to update - else if ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { + elseif ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) { $this->do_update_htaccess(); } // need to update } @@ -110,7 +110,7 @@ class MainWP_Keyword_Links { } public static function clear_htaccess() { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + include_once ABSPATH . '/wp-admin/includes/misc.php'; $home_path = ABSPATH; $htaccess_file = $home_path . '.htaccess'; if ( function_exists( 'save_mod_rewrite_rules' ) ) { @@ -125,8 +125,8 @@ class MainWP_Keyword_Links { self::clear_htaccess(); return true; - } else if ( '' === get_option( 'permalink_structure' ) ) { - include_once( ABSPATH . '/wp-admin/includes/misc.php' ); + } elseif ( '' === get_option( 'permalink_structure' ) ) { + include_once ABSPATH . '/wp-admin/includes/misc.php'; $redirection_folder = $this->get_option( 'redirection_folder', '' ); if ( empty( $redirection_folder ) ) { $rules = $this->get_cloak_rules(); @@ -534,7 +534,7 @@ class MainWP_Keyword_Links { } else { $links[] = $link; } - } else if ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link + } elseif ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link if ( $link->check_post_date ) { if ( $post_timestamp < $link->check_post_date ) { $links[] = $link; @@ -741,7 +741,7 @@ class MainWP_Keyword_Links { if ( $remove_settings ) { $this->clear_settings(); $return['status'] = 'SUCCESS'; - } else if ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) { + } elseif ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) { $new_keyword_links = array(); foreach ( $this->keyword_links as $link_id => $link ) { $lnk_kws = $link->keyword; @@ -853,7 +853,7 @@ class MainWP_Keyword_Links { if ( 3 === (int) $clear_link->type ) { $clear_link->type = 2; $cleared = $this->set_link( $clear_link->id, $clear_link ); - } else if ( 1 === (int) $clear_link->type ) { + } elseif ( 1 === (int) $clear_link->type ) { $cleared = $this->set_link( $clear_link->id, '' ); // delete link } $this->update_htaccess_for_change_cloak_links( $clear_link ); @@ -901,7 +901,7 @@ class MainWP_Keyword_Links { if ( 2 === (int) $link->type || 3 === (int) $link->type ) { if ( intval( $_POST['post_id'] ) ) { $link->post_id = intval( $_POST['post_id'] ); - } else if ( $old && $old->post_id ) { + } elseif ( $old && $old->post_id ) { $link->post_id = $old->post_id; } if ( $link->post_id ) { diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index 206e8dd..c194475 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -320,8 +320,9 @@ class MainWP_Security { public static function remove_readme( $force = false ) { // to prevent remove readme.html file on WPE hosts - if ( MainWP_Helper::is_wp_engine() ) + if ( MainWP_Helper::is_wp_engine() ) { return true; + } if ( $force || self::get_security_option( 'readme' ) ) { if ( @file_exists( ABSPATH . 'readme.html' ) ) { @@ -351,7 +352,8 @@ class MainWP_Security { //Admin user name is not admin public static function admin_user_ok() { $user = get_user_by( 'login', 'admin' ); - if ( ! $user ) return true; + if ( ! $user ) { return true; + } if ( 10 !== $user->wp_user_level && ( ! isset( $user->user_level ) || 10 !== $user->user_level ) && ! user_can( $user, 'level_10' ) ) { return true; @@ -362,8 +364,9 @@ class MainWP_Security { public static function update_security_option( $key, $value ) { $security = get_option( 'mainwp_security' ); - if ( !empty($key) ) + if ( !empty($key) ) { $security[$key] = $value; + } MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' ); } } diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index 0f1cb3b..7abfaee 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -58,7 +58,7 @@ class MainWP_Wordpress_SEO { $file_url = base64_decode( $_POST['file_url'] ); $temporary_file = ''; try { - include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url + include_once ABSPATH . 'wp-admin/includes/file.php'; //Contains download_url $temporary_file = download_url( $file_url ); if ( is_wp_error( $temporary_file ) ) { @@ -78,7 +78,7 @@ class MainWP_Wordpress_SEO { unlink( $temporary_file ); } - } else if ( isset( $_POST['settings'] ) ) { + } elseif ( isset( $_POST['settings'] ) ) { try { $settings = base64_decode( $_POST['settings'] ); // @codingStandardsIgnoreLine diff --git a/class/class-tar-archiver.php b/class/class-tar-archiver.php index c041b80..837e3d9 100644 --- a/class/class-tar-archiver.php +++ b/class/class-tar-archiver.php @@ -176,7 +176,7 @@ class Tar_Archiver { foreach ( $nodes as $key => $node ) { if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) { unset( $nodes[ $key ] ); - } else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { + } elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) { unset( $nodes[ $key ] ); } else { foreach ( $coreFiles as $coreFile ) { @@ -209,7 +209,7 @@ class Tar_Archiver { if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( is_dir( $node ) ) { $this->addDir( $node, $excludes ); - } else if ( is_file( $node ) ) { + } elseif ( is_file( $node ) ) { $this->addFile( $node, str_replace( ABSPATH, '', $node ) ); } } @@ -333,7 +333,7 @@ class Tar_Archiver { throw new Exception( 'Could not write to archive' ); } //@fflush($this->archive); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) { throw new Exception( 'Could not write to archive' ); } @@ -365,7 +365,7 @@ class Tar_Archiver { throw new Exception( 'Could not write to archive' ); } @fflush( $this->archive ); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { if ( false === @bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) { throw new Exception( 'Could not write to archive' ); } @@ -741,14 +741,14 @@ class Tar_Archiver { $startOffset = $rslt['startOffset']; @fseek( $this->archive, $startOffset ); @ftruncate( $this->archive, $startOffset ); - } else if ( 'tar.gz' == $this->type ) { + } elseif ( 'tar.gz' == $this->type ) { $readOffset = $rslt['readOffset']; $bytesRead = $rslt['bytesRead']; //@fseek($this->archive, $readOffset + $bytesRead); $out = array( 'bytesRead' => $bytesRead ); } - } else if ( false === $rslt ) { + } elseif ( false === $rslt ) { if ( 'tar' == $this->type ) { @fseek( $this->archive, 0, SEEK_END ); } @@ -820,7 +820,7 @@ class Tar_Archiver { } else { throw new Exception( 'Unexpected directory [' . $file['name'] . ']' ); } - } else if ( 0 == $file['type'] ) { + } elseif ( 0 == $file['type'] ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { $previousFtell = @ftell( $this->archive ); @@ -862,7 +862,7 @@ class Tar_Archiver { return $rslt; } - } else if ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) { + } elseif ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) { $this->log( 'Will append this: ' . print_r( $rslt, 1 ) ); return $rslt; @@ -906,7 +906,7 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { //$this->archive = @fopen('compress.zlib://' . $filepath, 'ab'); $this->archive = @gzopen( $filepath, 'wb' ); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { $this->archive = @bzopen( $filepath, 'w' ); } else { $this->archive = @fopen( $filepath, 'wb+' ); @@ -928,7 +928,7 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { //$this->archive = @fopen('compress.zlib://' . $filepath, 'ab'); $this->archive = @gzopen( $filepath, 'ab' ); - } else if ( $this->type == 'tar.bz2' ) { + } elseif ( $this->type == 'tar.bz2' ) { $this->archive = @bzopen( $filepath, 'a' ); } else { $this->archive = @fopen( $filepath, 'ab+' ); @@ -992,7 +992,7 @@ class Tar_Archiver { $this->type = 'tar.gz'; // $this->archive = @fopen('compress.zlib://' . $filepath, 'rb'); $this->archive = @gzopen( $filepath, 'r' ); - } else if ( 'tar.bz2' == substr( $filepath, - 7 ) ) { + } elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) { $this->type = 'tar.bz2'; $this->archive = @bzopen( $filepath, 'r' ); } else { @@ -1022,7 +1022,7 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { //@fclose($this->archive); @gzclose( $this->archive ); - } else if ( 'tar.bz2' == $this->type ) { + } elseif ( 'tar.bz2' == $this->type ) { @bzclose( $this->archive ); } else { @fclose( $this->archive ); @@ -1065,7 +1065,7 @@ class Tar_Archiver { if ( $file['checksum'] == 0x00000000 ) { break; - } else if ( substr( $file['magic'], 0, 5 ) != 'ustar' ) { + } elseif ( substr( $file['magic'], 0, 5 ) != 'ustar' ) { // $this->error[] = "This script does not support extracting this type of tar file."; break; } @@ -1134,7 +1134,7 @@ class Tar_Archiver { if ( $file['checksum'] == 0x00000000 ) { break; - } else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { + } elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { // $this->error[] = "This script does not support extracting this type of tar file."; break; } @@ -1151,7 +1151,7 @@ class Tar_Archiver { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { return true; } - } else if ( 0 == $file['type'] ) { + } elseif ( 0 == $file['type'] ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { return true; } else { @@ -1198,7 +1198,7 @@ class Tar_Archiver { if ( $file['checksum'] == 0x00000000 ) { break; - } else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { + } elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) { // $this->error[] = "This script does not support extracting this type of tar file."; break; } @@ -1217,7 +1217,7 @@ class Tar_Archiver { mkdir( $to . $file['name'], 0777, true ); } } - } else if ( 0 == $file['type'] ) { + } elseif ( 0 == $file['type'] ) { if ( ! is_dir( dirname( $to . $file['name'] ) ) ) { if ( ! empty( $wp_filesystem ) ) { $wp_filesystem->mkdir( dirname( $to . $file['name'] ), FS_CHMOD_DIR ); @@ -1306,16 +1306,16 @@ if ( class_exists( 'SplHeap' ) ) { if ( dirname( $pathA ) == dirname( $pathB ) ) { if ( is_file( $pathA ) && ! is_file( $pathB ) ) { return - 1; - } else if ( ! is_file( $pathA ) && is_file( $pathB ) ) { + } elseif ( ! is_file( $pathA ) && is_file( $pathB ) ) { return 1; } return strcmp( $pathA, $pathB ); - } else if ( $dirnameA == $dirnameB ) { + } elseif ( $dirnameA == $dirnameB ) { return strcmp( $pathA, $pathB ); - } else if ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) { + } elseif ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) { return 1; - } else if ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) { + } elseif ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) { return - 1; } else { $cmp = strcmp( $dirnameA, $dirnameB ); diff --git a/mainwp-child.php b/mainwp-child.php index af6d382..300b17c 100644 --- a/mainwp-child.php +++ b/mainwp-child.php @@ -8,7 +8,7 @@ Text Domain: mainwp-child Version: 4.0.7 */ -include_once( ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php' ); //Version information from WordPress +require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; //Version information from WordPress define( 'MAINWP_DEBUG', false ); @@ -25,7 +25,7 @@ function mainwp_child_autoload( $class_name ) { $autoload_path = sprintf( '%sclass-%s.php', $autoload_dir, strtolower( str_replace( '_', '-', $class_name ) ) ); if ( file_exists( $autoload_path ) ) { - require_once( $autoload_path ); + require_once $autoload_path; } } From d681a0d95c458c65c3bcedf06f2ac5d2f71776f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 16:01:41 +0100 Subject: [PATCH 69/98] Update phpcs.xml --- phpcs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 2f257de..a7ac2c2 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -33,8 +33,8 @@ - - + + From 3a348d53439e6ad079600c66129dfbf97bb5595a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 16:02:28 +0100 Subject: [PATCH 70/98] Update phpcs.xml --- phpcs.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index a7ac2c2..bc86b17 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -33,10 +33,10 @@ - - - - + + + + From ac49ce16e7a149f8e98d93e26e0f3a2d1f8b09a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 16:11:21 +0100 Subject: [PATCH 71/98] Update phpcs.xml --- phpcs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index bc86b17..2fd0fb9 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -37,8 +37,8 @@ - - + + From 0d6d73e1a6dcd9701fe9bc372849dcb8649ca462 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 15:29:54 +0000 Subject: [PATCH 72/98] [CodeFactor] Apply fixes --- class/class-mainwp-backup.php | 2 +- class/class-mainwp-child-back-up-buddy.php | 306 +++++++----- .../class-mainwp-child-back-up-wordpress.php | 2 +- class/class-mainwp-child-back-wp-up.php | 138 ++++-- class/class-mainwp-child-branding.php | 29 +- class/class-mainwp-child-ithemes-security.php | 47 +- class/class-mainwp-child-links-checker.php | 10 +- class/class-mainwp-child-pagespeed.php | 8 +- .../class-mainwp-child-server-information.php | 25 +- class/class-mainwp-child-skeleton-key.php | 18 +- class/class-mainwp-child-staging.php | 24 +- class/class-mainwp-child-themes-check.php | 8 +- class/class-mainwp-child-timecapsule.php | 115 ++--- ...lass-mainwp-child-updraft-plus-backups.php | 217 +++++---- ...ass-mainwp-child-vulnerability-checker.php | 39 +- .../class-mainwp-child-woocommerce-status.php | 2 +- class/class-mainwp-child-wordfence.php | 456 ++++++++++++------ class/class-mainwp-child-wp-rocket.php | 180 +++---- ...ass-mainwp-child-wpvivid-backuprestore.php | 2 +- class/class-mainwp-child.php | 218 +++++---- class/class-mainwp-clone-install.php | 2 +- class/class-mainwp-clone.php | 33 +- class/class-mainwp-custom-post-type.php | 9 +- class/class-mainwp-helper.php | 94 ++-- class/class-mainwp-keyword-links.php | 2 +- class/class-mainwp-security.php | 18 +- 26 files changed, 1206 insertions(+), 798 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 41bcd46..504cab5 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -119,7 +119,7 @@ class MainWP_Backup { // @codingStandardsIgnoreEnd if ( !is_array( $files ) ) { - $files = array ( $files ); + $files = array( $files ); } if ( null !== $this->archiver ) { diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index dd1fbb1..bebcc11 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -385,7 +385,7 @@ class MainWP_Child_Back_Up_Buddy { $type = isset($_POST['type']) ? $_POST['type'] : ''; if ($type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) { - return array('error' => __('Invalid data. Please check and try again.') ); + return array( 'error' => __('Invalid data. Please check and try again.') ); } $filter_advanced_settings = array( @@ -490,16 +490,16 @@ class MainWP_Child_Back_Up_Buddy { if (is_array($settings)) { if ($type === 'all' || 'general_settings' === $type) { foreach($filter_general_settings as $field) { - if(isset($settings[$field])) { - $save_settings[$field] = $settings[$field]; + if(isset($settings[ $field ])) { + $save_settings[ $field ] = $settings[ $field ]; } } } if ($type === 'all' || 'advanced_settings' === $type) { foreach($filter_advanced_settings as $field) { - if(isset($settings[$field])) { - $save_settings[$field] = $settings[$field]; + if(isset($settings[ $field ])) { + $save_settings[ $field ] = $settings[ $field ]; } } } @@ -509,15 +509,15 @@ class MainWP_Child_Back_Up_Buddy { $newOptions = pb_backupbuddy::$options; foreach($newOptions as $key => $val) { - if (isset($save_settings[$key])) { - $newOptions[$key] = $save_settings[$key]; + if (isset($save_settings[ $key ])) { + $newOptions[ $key ] = $save_settings[ $key ]; } } if (isset($newOptions['profiles']) && isset($newOptions['profiles'][0])) { foreach ($filter_profile0_values as $field) { - if (isset($settings[$field])) { - $newOptions['profiles'][0][$field] = $settings[$field]; + if (isset($settings[ $field ])) { + $newOptions['profiles'][0][ $field ] = $settings[ $field ]; } } } @@ -568,7 +568,10 @@ class MainWP_Child_Back_Up_Buddy { } function get_notifications() { - return array('result' => 'SUCCESS', 'notifications' => backupbuddy_core::getNotifications() ); + return array( + 'result' => 'SUCCESS', + 'notifications' => backupbuddy_core::getNotifications(), + ); } function get_schedules_run_time() { @@ -599,7 +602,7 @@ class MainWP_Child_Back_Up_Buddy { 'Last run: ' . $last_run . '
    ' . 'Next run: ' . $next_run; - $schedules_run_time[$schedule_id] = $run_time; + $schedules_run_time[ $schedule_id ] = $run_time; } @@ -624,16 +627,16 @@ class MainWP_Child_Back_Up_Buddy { function run_scheduled_backup() { if ( ! is_main_site() ) { // Only run for main site or standalone. Multisite subsites do not allow schedules. - return array('error' => __('Only run for main site or standalone. Multisite subsites do not allow schedules', 'mainwp-child') ); + return array( 'error' => __('Only run for main site or standalone. Multisite subsites do not allow schedules', 'mainwp-child') ); } $schedule_id = (int) $_POST['schedule_id']; - if ( !isset( pb_backupbuddy::$options['schedules'][$schedule_id] ) || ! is_array( pb_backupbuddy::$options['schedules'][$schedule_id] ) ) { - return array('error' => __( 'Error: not found the backup schedule or invalid data', 'mainwp-child' )); + if ( !isset( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) || ! is_array( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) ) { + return array( 'error' => __( 'Error: not found the backup schedule or invalid data', 'mainwp-child' ) ); } - pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][$schedule_id]['title'] . '" in the background.' . '
    ' . + pb_backupbuddy::alert( 'Manually running scheduled backup "' . pb_backupbuddy::$options['schedules'][ $schedule_id ]['title'] . '" in the background.' . '
    ' . __( 'Note: If there is no site activity there may be delays between steps in the backup. Access the site or use a 3rd party service, such as a free pinging service, to generate site activity.', 'it-l10n-backupbuddy' ) ); pb_backupbuddy_cron::_run_scheduled_backup( $schedule_id ); @@ -648,24 +651,24 @@ class MainWP_Child_Back_Up_Buddy { $schedule = unserialize(base64_decode($_POST['data'])); if (!is_array($schedule)) { - return array('error' => __( 'Invalid schedule data', 'mainwp-child' )); + return array( 'error' => __( 'Invalid schedule data', 'mainwp-child' ) ); } $information = array(); // add new - if (!isset(pb_backupbuddy::$options['schedules'][$schedule_id])) { + if (!isset(pb_backupbuddy::$options['schedules'][ $schedule_id ])) { $next_index = pb_backupbuddy::$options['next_schedule_index']; pb_backupbuddy::$options['next_schedule_index']++; // This change will be saved in savesettings function below. - pb_backupbuddy::$options['schedules'][$schedule_id] = $schedule; + pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule; $result = backupbuddy_core::schedule_event( $schedule['first_run'], $schedule['interval'], 'run_scheduled_backup', array( $schedule_id ) ); if ( $result === false ) { - return array('error' => 'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439b. Check your BackupBuddy error log for details.'); + return array( 'error' => 'Error scheduling event with WordPress. Your schedule may not work properly. Please try again. Error #3488439b. Check your BackupBuddy error log for details.' ); } } else { $first_run = $schedule['first_run']; $next_scheduled_time = wp_next_scheduled( 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); backupbuddy_core::unschedule_event( $next_scheduled_time, 'backupbuddy_cron', array( 'run_scheduled_backup', array( (int) $schedule_id ) ) ); backupbuddy_core::schedule_event( $first_run, $schedule['interval'], 'run_scheduled_backup', array( (int) $schedule_id ) ); // Add new schedule. - pb_backupbuddy::$options['schedules'][$schedule_id] = $schedule; + pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule; } pb_backupbuddy::save(); $information['result'] = 'SUCCESS'; @@ -681,10 +684,10 @@ class MainWP_Child_Back_Up_Buddy { $profile = unserialize(base64_decode($_POST['data'])); if (!is_array($profile)) { - return array('error' => __( 'Invalid profile data', 'mainwp-child' )); + return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) ); } - pb_backupbuddy::$options['profiles'][$profile_id] = $profile; + pb_backupbuddy::$options['profiles'][ $profile_id ] = $profile; pb_backupbuddy::save(); $information['result'] = 'SUCCESS'; @@ -695,8 +698,8 @@ class MainWP_Child_Back_Up_Buddy { function delete_profile() { $profile_id = $_POST['profile_id']; - if (isset(pb_backupbuddy::$options['profiles'][$profile_id])) { - unset(pb_backupbuddy::$options['profiles'][$profile_id]); + if (isset(pb_backupbuddy::$options['profiles'][ $profile_id ])) { + unset(pb_backupbuddy::$options['profiles'][ $profile_id ]); } pb_backupbuddy::save(); @@ -774,7 +777,7 @@ class MainWP_Child_Back_Up_Buddy { } MainWP_Helper::check_classes_exists(array( 'backupbuddy_core', 'backupbuddy_api' )); - MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) ); + MainWP_Helper::check_methods('backupbuddy_core', array( 'get_plugins_root', 'get_themes_root', 'get_media_root' ) ); MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) ); $data = array(); @@ -823,7 +826,7 @@ class MainWP_Child_Back_Up_Buddy { $backup_directory = backupbuddy_core::getBackupDirectory(); $backup_directory = str_replace( '\\', '/', $backup_directory ); $backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; - $information['backupDirectoryWithinSiteRoot'] = (false !== stristr( $backup_directory, ABSPATH )) ? 'yes' : 'no'; + $information['backupDirectoryWithinSiteRoot'] = ( false !== stristr( $backup_directory, ABSPATH ) ) ? 'yes' : 'no'; $information['result'] = 'SUCCESS'; return $information; } @@ -870,7 +873,10 @@ class MainWP_Child_Back_Up_Buddy { $callback_data = $_POST['callback_data']; $file = backupbuddy_core::getBackupDirectory() . $callback_data; if (file_exists($file)) { - return array( 'result' =>'SUCCESS', 'hash' => md5_file( $file ) ); + return array( + 'result' =>'SUCCESS', + 'hash' => md5_file( $file ), + ); } else { return array( 'error' =>'Not found the file' ); } @@ -882,11 +888,11 @@ class MainWP_Child_Back_Up_Buddy { $max_cache_time = 86400; // This is the root directory we want the listing for - $root = $_POST[ 'dir' ]; + $root = $_POST['dir']; $root_len = strlen( $root ); // This will identify the backup zip file we want to list - $serial = $_POST[ 'serial' ]; + $serial = $_POST['serial']; $alerts = array(); // The fileoptions file that contains the file tree information require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; @@ -901,7 +907,7 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::status( 'details', 'Fileoptions instance #28.' ); $fileoptions = new pb_backupbuddy_fileoptions( $fileoptions_file ); - $zip_viewer = $_POST[ 'zip_viewer' ]; + $zip_viewer = $_POST['zip_viewer']; // Either we are getting cached file tree information or we need to create afresh if ( true !== ( $result = $fileoptions->is_ok() ) ) { // Get file listing. @@ -928,7 +934,7 @@ class MainWP_Child_Back_Up_Buddy { // If shorter than root length then certainly is not within this (root) directory. // It's a quick test that is more effective the longer the root (the deeper you go // into the tree) - if ( strlen( $file[ 0 ] ) < $root_len ) { + if ( strlen( $file[0] ) < $root_len ) { unset( $files[ $key ] ); continue; @@ -939,7 +945,7 @@ class MainWP_Child_Back_Up_Buddy { // e.g., with root=this/dir/path/ // these will fail: file=this/dir/file; file=this/dir/otherpath/; file=that/dir/path/file // and these would succeed: file=this/dir/path/; file=this/dir/path/file; file=this/dir/path/otherpath/ - if ( substr( $file[ 0 ], 0, $root_len ) != $root ) { + if ( substr( $file[0], 0, $root_len ) != $root ) { unset( $files[ $key ] ); continue; @@ -949,7 +955,7 @@ class MainWP_Child_Back_Up_Buddy { // If the file _is_ the root then we don't want to list it // Don't want to do this on _every_ file as very specific so do it here after we have // weeded out files for more common reasons - if ( 0 == strcmp( $file[ 0 ], $root ) ) { + if ( 0 == strcmp( $file[0], $root ) ) { unset( $files[ $key ] ); continue; @@ -958,7 +964,7 @@ class MainWP_Child_Back_Up_Buddy { // Interesting file, get the path with the root prefix removed // Note: root may be empty in which case the result will be the original filename - $unrooted_file = substr( $file[ 0 ], $root_len ); + $unrooted_file = substr( $file[0], $root_len ); // We must ensure that we list the subdir/ even if subdir/ does not appear // as a distinct entry in the list but only subdir/file or subdir/subsubdir/ or @@ -977,7 +983,7 @@ class MainWP_Child_Back_Up_Buddy { $subdirs[] = $subdir; // Replace the original (rooted) file name - $files[ $key ][ 0 ] = $subdir; + $files[ $key ][0] = $subdir; } else { @@ -991,13 +997,17 @@ class MainWP_Child_Back_Up_Buddy { // This is just like file within the root // Replace the original (rooted) file name - $files[ $key ][ 0 ] = $unrooted_file; + $files[ $key ][0] = $unrooted_file; } } - return array('result' => 'SUCCESS', 'files' => $files, 'message' => implode('
    ', $alerts)); + return array( + 'result' => 'SUCCESS', + 'files' => $files, + 'message' => implode('
    ', $alerts), + ); } function exclude_tree() { @@ -1058,9 +1068,9 @@ class MainWP_Child_Back_Up_Buddy { } $html = ob_get_clean(); - return array('result' => $html); + return array( 'result' => $html ); } else { - return array('error' => 'Error #1127555. Unable to read child site root.'); + return array( 'error' => 'Error #1127555. Unable to read child site root.' ); } } @@ -1085,10 +1095,10 @@ class MainWP_Child_Back_Up_Buddy { if ( true === $display_size ) { // Fix up row count and average row length for InnoDB engine which returns inaccurate (and changing) values for these. - if ( 'InnoDB' === $result[ 'Engine' ] ) { + if ( 'InnoDB' === $result['Engine'] ) { if ( false !== ( $rowCount = $wpdb->get_var( "SELECT COUNT(1) as rowCount FROM `{$rs[ 'Name' ]}`", ARRAY_A ) ) ) { - if ( 0 < ( $result[ 'Rows' ] = $rowCount ) ) { - $result[ 'Avg_row_length' ] = ( $result[ 'Data_length' ] / $result[ 'Rows' ] ); + if ( 0 < ( $result['Rows'] = $rowCount ) ) { + $result['Avg_row_length'] = ( $result['Data_length'] / $result['Rows'] ); } } unset( $rowCount ); @@ -1113,8 +1123,8 @@ class MainWP_Child_Back_Up_Buddy { function restore_file_view() { - $archive_file = $_POST[ 'archive' ]; // archive to extract from. - $file = $_POST[ 'file' ]; // file to extract. + $archive_file = $_POST['archive']; // archive to extract from. + $file = $_POST['file']; // file to extract. $serial = backupbuddy_core::get_serial_from_file( $archive_file ); // serial of archive. $temp_file = uniqid(); // temp filename to extract into. @@ -1127,7 +1137,7 @@ class MainWP_Child_Back_Up_Buddy { if ( ( ( ! file_exists( $destination ) ) && ( false === mkdir( $destination ) ) ) ) { $error = 'Error #458485945b: Unable to create temporary location.'; pb_backupbuddy::status( 'error', $error ); - return array('error' => $error); + return array( 'error' => $error ); } // If temp directory is within webroot then lock it down. @@ -1165,14 +1175,17 @@ class MainWP_Child_Back_Up_Buddy { } } - return array( 'result' => 'SUCCESS', 'file_content' => $file_content ); + return array( + 'result' => 'SUCCESS', + 'file_content' => $file_content, + ); } function restore_file_restore() { - $files = $_POST[ 'files' ]; // file to extract. - $archive_file = $_POST[ 'archive' ]; // archive to extract from. + $files = $_POST['files']; // file to extract. + $archive_file = $_POST['archive']; // archive to extract from. $files_array = explode( ',', $files ); $files = array(); @@ -1180,7 +1193,7 @@ class MainWP_Child_Back_Up_Buddy { if ( substr( $file, -1 ) == '/' ) { // If directory then add wildcard. $file = $file . '*'; } - $files[$file] = $file; + $files[ $file ] = $file; } unset( $files_array ); @@ -1198,7 +1211,7 @@ class MainWP_Child_Back_Up_Buddy { $result = backupbuddy_restore_files::restore( backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH ); $restore_result = ob_get_clean(); pb_backupbuddy::flush(); - return array('restore_result' => $restore_result); + return array( 'restore_result' => $restore_result ); } function get_backup_list( $type = 'default', $subsite_mode = false ) { @@ -1226,7 +1239,7 @@ class MainWP_Child_Back_Up_Buddy { // Only allow viewing of their own backups. if ( ! strstr( $file, $backup_prefix ) ) { - unset( $files[$file_id] ); // Remove this backup from the list. This user does not have access to it. + unset( $files[ $file_id ] ); // Remove this backup from the list. This user does not have access to it. continue; // Skip processing to next file. } } @@ -1338,14 +1351,14 @@ class MainWP_Child_Back_Up_Buddy { $integrity = 'n/a'; } - $backups[basename( $file )] = array( + $backups[ basename( $file ) ] = array( array( basename( $file ), $main_string . '
    ' . basename( $file ) . '' ), $detected_type, $file_size, $integrity, ); - $backup_sort_dates[basename( $file)] = $modified_time; + $backup_sort_dates[ basename( $file) ] = $modified_time; } // End foreach(). @@ -1356,8 +1369,8 @@ class MainWP_Child_Back_Up_Buddy { // Re-arrange backups based on sort dates. $sorted_backups = array(); foreach( $backup_sort_dates as $backup_file => $backup_sort_date ) { - $sorted_backups[$backup_file] = $backups[$backup_file]; - unset( $backups[$backup_file] ); + $sorted_backups[ $backup_file ] = $backups[ $backup_file ]; + unset( $backups[ $backup_file ] ); } unset( $backups ); return $sorted_backups; @@ -1476,11 +1489,11 @@ class MainWP_Child_Back_Up_Buddy { $ret=array(); reset($array); foreach ($array as $ii => $va) { - $sorter[$ii]=$va[$key]; + $sorter[ $ii ]=$va[ $key ]; } asort($sorter); foreach ($sorter as $ii => $va) { - $ret[$ii]=$array[$ii]; + $ret[ $ii ]=$array[ $ii ]; } $array=$ret; } @@ -1497,11 +1510,11 @@ class MainWP_Child_Back_Up_Buddy { $schedule_ids = explode(',', $schedule_ids); if (empty($schedule_ids)) { - return array('error' => __( 'Empty schedule ids', 'mainwp-child' )); + return array( 'error' => __( 'Empty schedule ids', 'mainwp-child' ) ); } foreach ($schedule_ids as $sch_id) { - if ( isset( pb_backupbuddy::$options['schedules'][$sch_id] ) ) { - unset( pb_backupbuddy::$options['schedules'][$sch_id] ); + if ( isset( pb_backupbuddy::$options['schedules'][ $sch_id ] ) ) { + unset( pb_backupbuddy::$options['schedules'][ $sch_id ] ); } } pb_backupbuddy::save(); @@ -1510,11 +1523,11 @@ class MainWP_Child_Back_Up_Buddy { } function view_log() { - $serial = $_POST[ 'serial' ]; + $serial = $_POST['serial']; $logFile = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_sum_' . pb_backupbuddy::$options['log_serial'] . '.txt'; if ( ! file_exists( $logFile ) ) { - return array('error' => 'Error #858733: Log file `' . $logFile . '` not found or access denied.' ); + return array( 'error' => 'Error #858733: Log file `' . $logFile . '` not found or access denied.' ); } $lines = file_get_contents( $logFile ); @@ -1552,7 +1565,10 @@ class MainWP_Child_Back_Up_Buddy { 'SUCCESS', 'html_log' => $html); + return array( + 'result' => 'SUCCESS', + 'html_log' => $html, + ); } function view_detail() { @@ -1566,7 +1582,7 @@ class MainWP_Child_Back_Up_Buddy { $optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt'; $backup_options = new pb_backupbuddy_fileoptions( $optionsFile, $read_only = true ); if ( true !== ( $result = $backup_options->is_ok() ) ) { - return array('error' => __('Unable to access fileoptions data file.', 'mainwp-child' ) . ' Error: ' . $result ); + return array( 'error' => __('Unable to access fileoptions data file.', 'mainwp-child' ) . ' Error: ' . $result ); } ob_start(); $integrity = $backup_options->options['integrity']; @@ -1782,7 +1798,10 @@ class MainWP_Child_Back_Up_Buddy { $html = ob_get_clean(); pb_backupbuddy::flush(); - return array('result' => 'SUCCESS', 'html_detail' => $html); + return array( + 'result' => 'SUCCESS', + 'html_detail' => $html, + ); } function reset_integrity() { @@ -1854,7 +1873,7 @@ class MainWP_Child_Back_Up_Buddy { $requested_profile = $_POST['profile_id']; if (!isset(pb_backupbuddy::$options['profiles'][ $requested_profile ])) { - return array('error' => 'Invalid Profile. Not found.'); + return array( 'error' => 'Invalid Profile. Not found.' ); } require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; @@ -1874,9 +1893,9 @@ class MainWP_Child_Back_Up_Buddy { '', // direction '' // deployDestination ) !== true ) { - return array('error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' )); + return array( 'error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' ) ); } - return array('result' => 'SUCCESS'); + return array( 'result' => 'SUCCESS' ); } function start_backup() { @@ -1895,13 +1914,13 @@ class MainWP_Child_Back_Up_Buddy { $data['direction'], isset($data['deployDestination']) ? $data['deployDestination'] : '' ) !== true ) { - return array('error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' )); + return array( 'error' => __('Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'it-l10n-backupbuddy' ) ); } } else { - return array('error' => 'Invalid backup request.'); + return array( 'error' => 'Invalid backup request.' ); } - return array('ok' => 1); + return array( 'ok' => 1 ); } function backup_status() { @@ -1912,15 +1931,18 @@ class MainWP_Child_Back_Up_Buddy { backupbuddy_api::getBackupStatus( $data['serial'], $data['specialAction'], $data['initwaitretrycount'], $data['sqlFile'], $echo = true ); $result = ob_get_clean(); } else { - return array('error' => 'Invalid backup request.'); + return array( 'error' => 'Invalid backup request.' ); } - return array('ok' => 1, 'result' => $result); + return array( + 'ok' => 1, + 'result' => $result, + ); } function stop_backup() { $serial = $_POST['serial']; set_transient( 'pb_backupbuddy_stop_backup-' . $serial, true, ( 60*60*24 ) ); - return array('ok' => 1); + return array( 'ok' => 1 ); } function remote_save() { @@ -1930,7 +1952,7 @@ class MainWP_Child_Back_Up_Buddy { if (is_array($data) && isset($data['do_not_override'])) { if (true == $data['do_not_override']) { - if (($data['type'] == 's32' || $data['type'] == 's33')) { + if (( $data['type'] == 's32' || $data['type'] == 's33' )) { $not_override = array( 'accesskey', 'secretkey', @@ -1938,8 +1960,8 @@ class MainWP_Child_Back_Up_Buddy { 'region', ); foreach($not_override as $opt) { - if (isset($data[$opt])) { - unset($data[$opt]); + if (isset($data[ $opt ])) { + unset($data[ $opt ]); } } } @@ -1949,16 +1971,16 @@ class MainWP_Child_Back_Up_Buddy { } if (is_array($data)) { - if (isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { // update - pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge( pb_backupbuddy::$options['remote_destinations'][$destination_id], $data ); + if (isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ])) { // update + pb_backupbuddy::$options['remote_destinations'][ $destination_id ] = array_merge( pb_backupbuddy::$options['remote_destinations'][ $destination_id ], $data ); } else { // add new $data['token'] = pb_backupbuddy::$options['dropboxtemptoken']; - pb_backupbuddy::$options['remote_destinations'][$destination_id] = $data; + pb_backupbuddy::$options['remote_destinations'][ $destination_id ] = $data; } pb_backupbuddy::save(); - return array('ok' => 1); + return array( 'ok' => 1 ); } else { - return array('error' => 'Invalid request.'); + return array( 'error' => 'Invalid request.' ); } } @@ -1978,12 +2000,12 @@ class MainWP_Child_Back_Up_Buddy { $delete_response = pb_backupbuddy_destinations::delete_destination( $destination_id, true ); if ( $delete_response !== true ) { - return array('error' => $delete_response); + return array( 'error' => $delete_response ); } else { - return array('ok' => 1); + return array( 'ok' => 1 ); } } else { - return array('error' => 'Invalid request.'); + return array( 'error' => 'Invalid request.' ); } } @@ -1998,12 +2020,12 @@ class MainWP_Child_Back_Up_Buddy { if ( ! file_exists( $backup_file ) ) { // Error if file to send did not exist! $error_message = 'Unable to find file `' . $backup_file . '` to send. File does not appear to exist. You can try again in a moment or turn on full error logging and try again to log for support.'; pb_backupbuddy::status( 'error', $error_message ); - return array( 'error' => $error_message); + return array( 'error' => $error_message ); } if ( is_dir( $backup_file ) ) { // Error if a directory is trying to be sent. $error_message = 'You are attempting to send a directory, `' . $backup_file . '`. Try again and verify there were no javascript errors.'; pb_backupbuddy::status( 'error', $error_message ); - return array( 'error' => $error_message); + return array( 'error' => $error_message ); } } else { $backup_file = ''; @@ -2025,19 +2047,19 @@ class MainWP_Child_Back_Up_Buddy { pb_backupbuddy::status( 'details', 'Remote send NOT set to delete after successful send.' ); } - if ( !isset( pb_backupbuddy::$options['remote_destinations'][$destination_id] ) ) { + if ( !isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #833383: Invalid destination ID `' . htmlentities( $destination_id ) . '`.' ); } // For Stash we will check the quota prior to initiating send. - if ( pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash' ) { + if ( pb_backupbuddy::$options['remote_destinations'][ $destination_id ]['type'] == 'stash' ) { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info( 'stash' ); // Used to kick the Stash destination into life. - $stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ); + $stash_quota = pb_backupbuddy_destination_stash::get_quota( pb_backupbuddy::$options['remote_destinations'][ $destination_id ], true ); if ( isset( $stash_quota['error'] ) ) { - return array( 'error' => ' Error accessing Stash account. Send aborted. Details: `' . implode( ' - ', $stash_quota['error'] ) . '`.'); + return array( 'error' => ' Error accessing Stash account. Send aborted. Details: `' . implode( ' - ', $stash_quota['error'] ) . '`.' ); } if ( $backup_file != '' ) { @@ -2067,7 +2089,7 @@ class MainWP_Child_Back_Up_Buddy { if ( $schedule_result === false ) { $error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.'; pb_backupbuddy::status( 'error', $error ); - return array( 'error' => $error); + return array( 'error' => $error ); } else { pb_backupbuddy::status( 'details', 'Cron to send to remote destination scheduled.' ); } @@ -2075,7 +2097,7 @@ class MainWP_Child_Back_Up_Buddy { update_option( '_transient_doing_cron', 0 ); // Prevent cron-blocking for next item. spawn_cron( time() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit. } - return array( 'ok' => 1); + return array( 'ok' => 1 ); } function get_main_log() { @@ -2087,7 +2109,7 @@ class MainWP_Child_Back_Up_Buddy { echo __('Nothing has been logged.', 'it-l10n-backupbuddy' ); } $result = ob_get_clean(); - return array('result' => $result ); + return array( 'result' => $result ); } function settings_other() { @@ -2154,7 +2176,10 @@ class MainWP_Child_Back_Up_Buddy { $message = 'Marked all timed out or running backups & transfers as officially cancelled (`' . $cancelCount . '` total found).'; } - return array('_error' => $error, '_message' => $message); + return array( + '_error' => $error, + '_message' => $message, + ); } function malware_scan() { @@ -2217,14 +2242,14 @@ class MainWP_Child_Back_Up_Buddy { $scan = wp_remote_get( 'http://sitecheck.sucuri.net/scanner/?scan=' . urlencode( $url ) . '&serialized&clear=true', array( - 'method' => 'GET', - 'timeout' => 45, + 'method' => 'GET', + 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', - 'blocking' => true, - 'headers' => array(), - 'body' => null, - 'cookies' => array(), + 'blocking' => true, + 'headers' => array(), + 'body' => null, + 'cookies' => array(), ) ); @@ -2266,7 +2291,7 @@ class MainWP_Child_Back_Up_Buddy { if ( is_array( $array ) ) { foreach( $array as $array_key => $array_item ) { if ( is_array( $array_item ) ) { - $array[$array_key] = lined_array( $array_item ); + $array[ $array_key ] = lined_array( $array_item ); } } //return implode( '
    ', $array ); @@ -2450,7 +2475,7 @@ class MainWP_Child_Back_Up_Buddy { } $result = ob_get_clean(); - return array('result' => $result); + return array( 'result' => $result ); } @@ -2459,10 +2484,10 @@ class MainWP_Child_Back_Up_Buddy { $errors = array(); $archive_types = array( - 'db' => __( 'Database Backup', 'it-l10n-backupbuddy' ), - 'full' => __( 'Full Backup', 'it-l10n-backupbuddy' ), + 'db' => __( 'Database Backup', 'it-l10n-backupbuddy' ), + 'full' => __( 'Full Backup', 'it-l10n-backupbuddy' ), 'plugins' => __( 'Plugins Backup', 'it-l10n-backupbuddy' ), - 'themes' => __( 'Themes Backup', 'it-l10n-backupbuddy' ), + 'themes' => __( 'Themes Backup', 'it-l10n-backupbuddy' ), ); $archive_periods = array( @@ -2525,7 +2550,7 @@ class MainWP_Child_Back_Up_Buddy { foreach( $archive_types as $archive_type => $archive_type_name ) { foreach( $archive_periods as $archive_period ) { $settings_name = 'limit_' . $archive_type . '_' . $archive_period; - pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ][ $settings_name ] = $_POST['live_settings'][$settings_name]; + pb_backupbuddy::$options['remote_destinations'][ $nextDestKey ][ $settings_name ] = $_POST['live_settings'][ $settings_name ]; } } @@ -2562,7 +2587,10 @@ class MainWP_Child_Back_Up_Buddy { if ( 0 == count( $errors ) ) { pb_backupbuddy::save(); $data = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; - return array( 'destination_id' => $destination_id, 'data' => $data); + return array( + 'destination_id' => $destination_id, + 'data' => $data, + ); } else { return array( 'errors' => $errors ); } @@ -2577,7 +2605,7 @@ class MainWP_Child_Back_Up_Buddy { require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php'; $destination_id = backupbuddy_live::getLiveID(); - $destination_settings = isset(pb_backupbuddy::$options['remote_destinations'][$destination_id]) ? pb_backupbuddy::$options['remote_destinations'][$destination_id] : array(); + $destination_settings = isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]) ? pb_backupbuddy::$options['remote_destinations'][ $destination_id ] : array(); $check_current = !empty($destination_settings) ? true : false; @@ -2588,10 +2616,10 @@ class MainWP_Child_Back_Up_Buddy { $destination_settings = array_merge( $destination_settings, $data ); $destination_settings['itxapi_username'] = $itxapi_username; $destination_settings['itxapi_token'] = $itxapi_token; - pb_backupbuddy::$options['remote_destinations'][$new_destination_id] = $destination_settings; + pb_backupbuddy::$options['remote_destinations'][ $new_destination_id ] = $destination_settings; if ($check_current && $destination_id != $new_destination_id) { - unset(pb_backupbuddy::$options['remote_destinations'][$destination_id]); + unset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]); } pb_backupbuddy::save(); @@ -2599,11 +2627,11 @@ class MainWP_Child_Back_Up_Buddy { set_transient( 'backupbuddy_live_jump', array( 'daily_init', array() ), 60*60*48 ); // Tells Live process to restart from the beginning (if mid-process) so new settigns apply. backupbuddy_live::send_trim_settings(); - return array('ok' => 1); + return array( 'ok' => 1 ); } else { $error = 'Invalid data. Please check and try again.'; } - return array('error' => $error); + return array( 'error' => $error ); } function live_action_disconnect() { @@ -2662,7 +2690,7 @@ class MainWP_Child_Back_Up_Buddy { } elseif ( 'pause_periodic' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true ); - $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. + $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. //pb_backupbuddy::disalert( '', __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ); include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. @@ -2680,13 +2708,13 @@ class MainWP_Child_Back_Up_Buddy { include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. } elseif ( 'pause_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = true, $pause_periodic = '' ); - $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. + $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. //pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ); } elseif ( 'resume_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = false, $pause_periodic = '' ); - $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. + $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. //pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ); @@ -2694,7 +2722,11 @@ class MainWP_Child_Back_Up_Buddy { $error = 'Error #1000. Invalid request.'; } - return array( 'ok' => 1, '_error' => $error, '_message' => $message ); + return array( + 'ok' => 1, + '_error' => $error, + '_message' => $message, + ); } @@ -2704,7 +2736,10 @@ class MainWP_Child_Back_Up_Buddy { backupbuddy_live_troubleshooting::run(); $output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true ); $backup_prefix = backupbuddy_core::backup_prefix(); - return array( 'output' => $output, 'backup_prefix' => $backup_prefix ); + return array( + 'output' => $output, + 'backup_prefix' => $backup_prefix, + ); } function get_live_backups() { @@ -2747,19 +2782,19 @@ class MainWP_Child_Back_Up_Buddy { $backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true ); // Generate array of table rows. - while( isset( $backup_list_temp[$last_modified] ) ) { // Avoid collisions. + while( isset( $backup_list_temp[ $last_modified ] ) ) { // Avoid collisions. $last_modified += 0.1; } if ( 'live' == $destination['type'] ) { - $backup_list_temp[$last_modified] = array( + $backup_list_temp[ $last_modified ] = array( array( base64_encode( $file['url'] ), '' . pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . ' (' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)
    ' . basename( $file['filename'] ) . '' ), pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . '
    (' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)', pb_backupbuddy::$format->file_size( $size ), backupbuddy_core::pretty_backup_type( $backup_type ), ); } else { - $backup_list_temp[$last_modified] = array( + $backup_list_temp[ $last_modified ] = array( array( base64_encode( $file['url'] ), '' . basename( $file['filename'] ) . '' ), pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . '
    (' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)', pb_backupbuddy::$format->file_size( $size ), @@ -2835,7 +2870,10 @@ class MainWP_Child_Back_Up_Buddy { $msg = 'Failed to delete one or more files. Details: `' . $response . '`.'; } - return array( 'ok' => 1, 'msg' => $msg ); + return array( + 'ok' => 1, + 'msg' => $msg, + ); } function get_live_stats() { @@ -2843,11 +2881,11 @@ class MainWP_Child_Back_Up_Buddy { // Check if running PHP 5.3+. $php_minimum = 5.3; if ( version_compare( PHP_VERSION, $php_minimum, '<' ) ) { // Server's PHP is insufficient. - return array('error' => '-1'); + return array( 'error' => '-1' ); } if ( false === ( $stats = backupbuddy_api::getLiveStats() ) ) { // Live is disconnected. - return array('error' => '-1'); + return array( 'error' => '-1' ); } // If there is more to do and too long of time has passed since activity then try to jumpstart the process at the beginning. @@ -2890,14 +2928,14 @@ class MainWP_Child_Back_Up_Buddy { } - return array('result' => json_encode( $stats )); + return array( 'result' => json_encode( $stats ) ); } function save_license_settings() { $settings = $_POST['settings']; if (is_array($settings) && isset($GLOBALS['ithemes-updater-settings'])) { $GLOBALS['ithemes-updater-settings']->update_options( $settings ); - return array('ok' => 1); + return array( 'ok' => 1 ); } return false; } @@ -2917,12 +2955,16 @@ class MainWP_Child_Back_Up_Buddy { $packages = isset($details['packages']) ? $details['packages'] : array(); if (is_array($packages)) { foreach ( $packages as $path => $data ) { - $packages_name[$path] = Ithemes_Updater_Functions::get_package_name( $data['package'] ); + $packages_name[ $path ] = Ithemes_Updater_Functions::get_package_name( $data['package'] ); } } } - return array('ok' => 1, 'packages' => $packages, 'packages_name' => $packages_name); + return array( + 'ok' => 1, + 'packages' => $packages, + 'packages_name' => $packages_name, + ); } function activate_package() { @@ -2970,9 +3012,9 @@ class MainWP_Child_Back_Up_Buddy { if ( ! empty( $data['key'] ) ) { $success[] = $name; } elseif ( ! empty( $data['status'] ) && ( 'expired' == $data['status'] ) ) { - $warn[$name] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' ); + $warn[ $name ] = __( 'Your product subscription has expired', 'it-l10n-backupbuddy' ); } else { - $fail[$name] = $data['error']['message']; + $fail[ $name ] = $data['error']['message']; } } @@ -3044,9 +3086,9 @@ class MainWP_Child_Back_Up_Buddy { if ( isset( $data['status'] ) && ( 'inactive' == $data['status'] ) ) { $success[] = $name; } elseif ( isset( $data['error'] ) && isset( $data['error']['message'] ) ) { - $fail[$name] = $data['error']['message']; + $fail[ $name ] = $data['error']['message']; } else { - $fail[$name] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' ); + $fail[ $name ] = __( 'Unknown server error.', 'it-l10n-mainwp-backupbuddy' ); } } diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index df00422..5703ce7 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -1148,7 +1148,7 @@ class MainWP_Child_Back_Up_Wordpress { } } - return array('result' => 'SUCCESS'); + return array( 'result' => 'SUCCESS' ); } diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 647b423..755a393 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -247,7 +247,7 @@ class MainWP_Child_Back_WP_Up { try { - MainWP_Helper::check_classes_exists(array('BackWPup_File', 'BackWPup_Job')); + MainWP_Helper::check_classes_exists(array( 'BackWPup_File', 'BackWPup_Job' )); MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' )); MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' )); @@ -280,23 +280,23 @@ class MainWP_Child_Back_WP_Up { continue; // do not logging backups have errors } - $log_items[$mtime] = $meta; - $log_items[$mtime]['file'] = $logfile; + $log_items[ $mtime ] = $meta; + $log_items[ $mtime ]['file'] = $logfile; } if ( !empty( $log_items ) ) { $job_types = array( - 'DBDUMP' => __('Database backup', 'mainwp-child'), - 'FILE' => __('File backup', 'mainwp-child'), - 'WPEXP' => __('WordPress XML export', 'mainwp-child'), + 'DBDUMP' => __('Database backup', 'mainwp-child'), + 'FILE' => __('File backup', 'mainwp-child'), + 'WPEXP' => __('WordPress XML export', 'mainwp-child'), 'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'), - 'DBCHECK' => __('Check database tables', 'mainwp-child'), + 'DBCHECK' => __('Check database tables', 'mainwp-child'), ); $new_lasttime_logged = $lasttime_logged; foreach ($log_items as $log) { - $backup_time = $log[ 'logtime' ]; + $backup_time = $log['logtime']; if ($backup_time < $lasttime_logged) { // small than last backup time then skip continue; @@ -304,8 +304,8 @@ class MainWP_Child_Back_WP_Up { $job_job_types = explode('+', $log['type']); $backup_type = ''; foreach($job_job_types as $typeid) { - if (isset( $job_types[$typeid] )) { - $backup_type .= ' + ' . $job_types[$typeid]; + if (isset( $job_types[ $typeid ] )) { + $backup_type .= ' + ' . $job_types[ $typeid ]; } } @@ -347,7 +347,7 @@ class MainWP_Child_Back_WP_Up { } function get_destinations_list() { - MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option')); + MainWP_Helper::check_classes_exists(array( 'BackWPup', 'BackWPup_Option' )); MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' )); MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' )); @@ -360,7 +360,7 @@ class MainWP_Child_Back_WP_Up { } $dests = BackWPup_Option::get( $jobid, 'destinations' ); foreach ( $dests as $dest ) { - if ( ! $destinations[ $dest ][ 'class' ] ) { + if ( ! $destinations[ $dest ]['class'] ) { continue; } @@ -368,7 +368,7 @@ class MainWP_Child_Back_WP_Up { if ($dest_class && method_exists($dest_class, 'file_get_list')) { $can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest ); if ( ! empty( $can_do_dest ) ) { - $jobdest[ ] = $jobid . '_' . $dest; + $jobdest[] = $jobid . '_' . $dest; } } } @@ -537,7 +537,10 @@ class MainWP_Child_Back_WP_Up { ob_end_clean(); - return array( 'success' => 1, 'response' => $output ); + return array( + 'success' => 1, + 'response' => $output, + ); } protected function delete_log() { @@ -606,11 +609,17 @@ class MainWP_Child_Back_WP_Up { if ( is_array( $file ) && $file['file'] == $backupfile ) { $dest_class->file_delete( $dest, $backupfile ); - return array( 'success' => 1, 'response' => 'DELETED' ); + return array( + 'success' => 1, + 'response' => 'DELETED', + ); } } - return array( 'success' => 1, 'response' => 'Not found' ); + return array( + 'success' => 1, + 'response' => 'Not found', + ); } protected function view_log() { @@ -640,7 +649,10 @@ class MainWP_Child_Back_WP_Up { } } - return array( 'success' => 1, 'response' => $output ); + return array( + 'success' => 1, + 'response' => $output, + ); } protected function tables() { @@ -666,7 +678,10 @@ class MainWP_Child_Back_WP_Up { $log_folder = untrailingslashit( $log_folder ); if ( ! is_dir( $log_folder ) ) { - return array( 'success' => 1, 'response' => $array ); + return array( + 'success' => 1, + 'response' => $array, + ); } update_user_option( get_current_user_id(), 'backwpuplogs_per_page', 99999999 ); $output = new BackWPup_Page_Logs(); @@ -697,7 +712,7 @@ class MainWP_Child_Back_WP_Up { foreach ( $items as $item ) { $temp_single_item = $item; $temp_single_item['dest'] = $jobid . '_' . $dest; - $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item[ 'time' ], true ), date_i18n( get_option( 'time_format' ), $temp_single_item[ 'time' ], true ) ); + $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) ); $output->items[] = $temp_single_item; } } @@ -785,7 +800,10 @@ class MainWP_Child_Back_WP_Up { } } - return array( 'success' => 1, 'response' => $array ); + return array( + 'success' => 1, + 'response' => $array, + ); } public function init_download_backup() { @@ -902,7 +920,10 @@ class MainWP_Child_Back_WP_Up { ob_end_clean(); - return array( 'success' => 1, 'response' => $output ); + return array( + 'success' => 1, + 'response' => $output, + ); } protected function backup_now() { @@ -938,7 +959,10 @@ class MainWP_Child_Back_WP_Up { 'logfile' => basename( $job_object->logfile ), ); } else { - return array( 'success' => 1, 'response' => $output['message'] ); + return array( + 'success' => 1, + 'response' => $output['message'], + ); } } } @@ -960,7 +984,10 @@ class MainWP_Child_Back_WP_Up { if ( isset( $output['error'] ) ) { return array( 'error' => 'Cannot abort: ' . $output['error'] ); } else { - return array( 'success' => 1, 'response' => $output['message'] ); + return array( + 'success' => 1, + 'response' => $output['message'], + ); } } @@ -993,7 +1020,10 @@ class MainWP_Child_Back_WP_Up { ob_end_clean(); - return array( 'success' => 1, 'response' => $output ); + return array( + 'success' => 1, + 'response' => $output, + ); } else { return array( 'error' => 'Missing BackWPup_Pro_Wizard_SystemTest' ); } @@ -1092,7 +1122,10 @@ class MainWP_Child_Back_WP_Up { } } - return array( 'success' => 1, 'message' => $message ); + return array( + 'success' => 1, + 'message' => $message, + ); } protected function get_job_files() { @@ -1158,11 +1191,18 @@ class MainWP_Child_Back_WP_Up { @closedir( $dir ); } - $return[ $key ] = array( 'size' => $main_folder_size, 'name' => $folder, 'folders' => $return_temp ); + $return[ $key ] = array( + 'size' => $main_folder_size, + 'name' => $folder, + 'folders' => $return_temp, + ); } } - return array( 'success' => 1, 'folders' => $return ); + return array( + 'success' => 1, + 'folders' => $return, + ); } protected function get_child_tables() { @@ -1217,7 +1257,10 @@ class MainWP_Child_Back_WP_Up { if (isset($settings['job_id'])) { $return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' ); } - return array( 'success' => 1, 'return' => $return ); + return array( + 'success' => 1, + 'return' => $return, + ); } protected function insert_or_update_jobs_global() { @@ -1298,7 +1341,7 @@ class MainWP_Child_Back_WP_Up { $to_exclude_parsed = array(); foreach ( $to_exclude as $key => $value ) { $normalized = wp_normalize_path( trim( $value ) ); - $normalized and $to_exclude_parsed[$key] = $normalized; + $normalized and $to_exclude_parsed[ $key ] = $normalized; } sort( $to_exclude_parsed ); BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) ); @@ -1313,7 +1356,7 @@ class MainWP_Child_Back_WP_Up { $normalized = trailingslashit( wp_normalize_path( trim( $value ) ) ); $normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL ); $realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false; - $realpath and $to_include_parsed[$key] = $realpath; + $realpath and $to_include_parsed[ $key ] = $realpath; } sort( $to_include_parsed ); BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) ); @@ -1332,18 +1375,33 @@ class MainWP_Child_Back_WP_Up { ); foreach( $boolean_fields_def as $key => $value ) { - BackWPup_Option::update( $id, $key, ! empty( $post_data[$key] ) ); + BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) ); } // Parse and save directories to exclude $exclude_dirs_def = array( - 'backuprootexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ), - 'backuppluginsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ), - 'backupcontentexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ), - 'backupthemesexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ), - 'backupuploadsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ), + 'backuprootexcludedirs' => array( + 'filter' => FILTER_SANITIZE_URL, + 'flags' => FILTER_FORCE_ARRAY, + ), + 'backuppluginsexcludedirs' => array( + 'filter' => FILTER_SANITIZE_URL, + 'flags' => FILTER_FORCE_ARRAY, + ), + 'backupcontentexcludedirs' => array( + 'filter' => FILTER_SANITIZE_URL, + 'flags' => FILTER_FORCE_ARRAY, + ), + 'backupthemesexcludedirs' => array( + 'filter' => FILTER_SANITIZE_URL, + 'flags' => FILTER_FORCE_ARRAY, + ), + 'backupuploadsexcludedirs' => array( + 'filter' => FILTER_SANITIZE_URL, + 'flags' => FILTER_FORCE_ARRAY, + ), ); foreach( $exclude_dirs_def as $key => $filter ) { - $value = ! empty( $post_data[$key] ) && is_array( $post_data[$key] ) ? $post_data[$key] : array(); + $value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array(); BackWPup_Option::update( $id, $key, $value ); } } @@ -1514,7 +1572,11 @@ class MainWP_Child_Back_WP_Up { } } - return array( 'success' => 1, 'changes' => $changes_array, 'message' => $return['message'] ); + return array( + 'success' => 1, + 'changes' => $changes_array, + 'message' => $return['message'], + ); } protected function check_backwpup_messages() { diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index c03d54d..cda6617 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -146,8 +146,8 @@ class MainWP_Child_Branding { ); foreach($brandingOptions_empty as $opt) { - if (isset($this->child_branding_options[$opt])) { - $this->child_branding_options[$opt] = ''; + if (isset($this->child_branding_options[ $opt ])) { + $this->child_branding_options[ $opt ] = ''; } } MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options ); @@ -233,8 +233,8 @@ class MainWP_Child_Branding { 'remove_widget_activity' => $settings['child_remove_widget_activity'], 'remove_widget_quick' => $settings['child_remove_widget_quick'], 'remove_widget_news' => $settings['child_remove_widget_news'], - 'login_image_link' => $settings['child_login_image_link'], - 'login_image_title' => $settings['child_login_image_title'], + 'login_image_link' => $settings['child_login_image_link'], + 'login_image_title' => $settings['child_login_image_title'], 'site_generator' => $settings['child_site_generator'], 'generator_link' => $settings['child_generator_link'], 'admin_css' => $settings['child_admin_css'], @@ -268,7 +268,10 @@ class MainWP_Child_Branding { try { $upload = $this->uploadImage( $settings['child_login_image_url'] ); //Upload image to WP if ( null !== $upload ) { - $extra_setting['login_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] ); + $extra_setting['login_image'] = array( + 'path' => $upload['path'], + 'url' => $upload['url'], + ); if ( isset( $current_extra_setting['login_image']['path'] ) ) { $old_file = $current_extra_setting['login_image']['path']; if ( ! empty( $old_file ) && file_exists( $old_file ) ) { @@ -291,7 +294,10 @@ class MainWP_Child_Branding { try { $upload = $this->uploadImage( $settings['child_favico_image_url'] ); //Upload image to WP if ( null !== $upload ) { - $extra_setting['favico_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] ); + $extra_setting['favico_image'] = array( + 'path' => $upload['path'], + 'url' => $upload['url'], + ); if ( isset( $current_extra_setting['favico_image']['path'] ) ) { $old_file = $current_extra_setting['favico_image']['path']; if ( ! empty( $old_file ) && file_exists( $old_file ) ) { @@ -364,7 +370,10 @@ class MainWP_Child_Branding { $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); $moved = @rename( $temporary_file, $local_img_path ); if ( $moved ) { - return array( 'path' => $local_img_path, 'url' => $local_img_url ); + return array( + 'path' => $local_img_path, + 'url' => $local_img_url, + ); } } if ( file_exists( $temporary_file ) ) { @@ -431,7 +440,7 @@ class MainWP_Child_Branding { } add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 ); - add_action( 'admin_menu', array($this, 'branding_redirect' ), 9); + add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9); } // to fix @@ -458,7 +467,7 @@ class MainWP_Child_Branding { } if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) { - add_action( 'admin_init', array($this, 'admin_init')); + add_action( 'admin_init', array( $this, 'admin_init' )); } add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) ); @@ -989,7 +998,7 @@ class MainWP_Child_Branding { } public function save_branding_options( $name, $val ) { - $this->child_branding_options[$name] = $val; + $this->child_branding_options[ $name ] = $val; MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options ); } diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index 0e292f1..6ce3259 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -140,7 +140,7 @@ class MainWP_Child_iThemes_Security { add_action( 'admin_menu', array( $this, 'remove_menu' ) ); add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'admin_head', array( &$this, 'custom_admin_css' ) ); - if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check') ) { + if ( isset($_GET['page']) && ( $_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check' ) ) { wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' ); exit(); } @@ -219,7 +219,7 @@ class MainWP_Child_iThemes_Security { } elseif ($module == 'global') { $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' ); foreach($keep_olds as $key) { - $settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update + $settings[ $key ] = ITSEC_Modules::get_setting( $module, $key ); // not update } if (!isset($settings['log_location']) || empty($settings['log_location']) ) { @@ -280,14 +280,14 @@ class MainWP_Child_iThemes_Security { } elseif ($module == 'notification-center') { $current_settings = ITSEC_Modules::get_settings( $module ); if (isset($settings['notifications'])) { - $update_fields = array( 'schedule', 'enabled', 'subject'); + $update_fields = array( 'schedule', 'enabled', 'subject' ); if (isset($_POST['is_individual']) && $_POST['is_individual']) { - $update_fields = array_merge($update_fields, array('user_list', 'email_list')); + $update_fields = array_merge($update_fields, array( 'user_list', 'email_list' )); } foreach ($settings['notifications'] as $key => $val) { foreach ($update_fields as $field) { - if(isset($val[$field])) { - $current_settings['notifications'][$key][$field] = $val[$field]; + if(isset($val[ $field ])) { + $current_settings['notifications'][ $key ][ $field ] = $val[ $field ]; } } } @@ -307,7 +307,7 @@ class MainWP_Child_iThemes_Security { if ( isset( $update_settings['itsec_active_modules'] ) ) { $current_val = get_site_option( 'itsec_active_modules', array() ); foreach ($update_settings['itsec_active_modules'] as $mod => $val) { - $current_val[$mod] = $val; + $current_val[ $mod ] = $val; } update_site_option( 'itsec_active_modules', $current_val ); } @@ -326,10 +326,10 @@ class MainWP_Child_iThemes_Security { 'lockouts_host' => $this->get_lockouts( 'host', true ), 'lockouts_user' => $this->get_lockouts( 'user', true ), 'lockouts_username' => $this->get_lockouts( 'username', true ), - 'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ), - 'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ), - 'excludable_tables' => $this->get_excludable_tables(), - 'users_and_roles' => $this->get_available_admin_users_and_roles(), + 'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ), + 'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ), + 'excludable_tables' => $this->get_excludable_tables(), + 'users_and_roles' => $this->get_available_admin_users_and_roles(), ); $return = array( @@ -670,7 +670,7 @@ class MainWP_Child_iThemes_Security {
    $html); + return array( 'html' => $html ); } public function file_change() { @@ -867,7 +867,11 @@ class MainWP_Child_iThemes_Security { 'rule' => "define( 'WP_CONTENT_DIR', '" . $new_dir . "' );", ); - $rules_array[] = array( 'type' => 'wpconfig', 'name' => 'Content Directory', 'rules' => $rules ); + $rules_array[] = array( + 'type' => 'wpconfig', + 'name' => 'Content Directory', + 'rules' => $rules, + ); return $rules_array; } @@ -1113,18 +1117,18 @@ class MainWP_Child_iThemes_Security { $current_val = get_site_option( 'itsec_active_modules', array() ); foreach ($active_modules as $mod => $val) { - $current_val[$mod] = $val; + $current_val[ $mod ] = $val; } update_site_option( 'itsec_active_modules', $current_val ); - return array('result' => 'success'); + return array( 'result' => 'success' ); } private function reload_backup_exclude() { return array( - 'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ), + 'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ), 'excludable_tables' => $this->get_excludable_tables(), - 'result' => 'success', + 'result' => 'success', ); } @@ -1161,7 +1165,7 @@ class MainWP_Child_iThemes_Security { continue; } - $excludes[$short_table] = $table[0]; + $excludes[ $short_table ] = $table[0]; } return $excludes; @@ -1175,7 +1179,10 @@ class MainWP_Child_iThemes_Security { ob_start(); ITSEC_Security_Check_Feedback_Renderer::render( $results ); $response = ob_get_clean(); - return array('result' => 'success', 'response' => $response); + return array( + 'result' => 'success', + 'response' => $response, + ); } // source from itheme plugin @@ -1192,7 +1199,7 @@ class MainWP_Child_iThemes_Security { foreach ( $roles->roles as $role => $details ) { if ( isset( $details['capabilities']['manage_options'] ) && ( true === $details['capabilities']['manage_options'] ) ) { - $available_roles["role:$role"] = translate_user_role( $details['name'] ); + $available_roles[ "role:$role" ] = translate_user_role( $details['name'] ); $users = get_users( array( 'role' => $role ) ); diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index e8c45b3..85954f3 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -83,7 +83,7 @@ class MainWP_Child_Links_Checker { } MainWP_Helper::write( $information ); } catch(Exception $e) { - MainWP_Helper::write( array('error' => $e->getMessage()) ); + MainWP_Helper::write( array( 'error' => $e->getMessage() ) ); } } @@ -270,9 +270,9 @@ class MainWP_Child_Links_Checker { if ($offset){ $total_sync = $offset; } - $total_sync += (is_array($link_data) ? count($link_data) : 0); + $total_sync += ( is_array($link_data) ? count($link_data) : 0 ); - $information = array('links_data' => $link_data); + $information = array( 'links_data' => $link_data ); if ($first_sync) { $information['data'] = $this->get_count_links(); @@ -393,7 +393,7 @@ class MainWP_Child_Links_Checker { if ( ! empty( $instances ) ) { $first_instance = reset( $instances ); - MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable') ); + MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) ); $new_link->link_text = $first_instance->ui_get_link_text(); $extra_info['count_instance'] = count( $instances ); @@ -657,7 +657,7 @@ class MainWP_Child_Links_Checker { $image = 'font-awesome/font-awesome-comment-alt.png'; } - if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object'), true )) { + if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true )) { return false; } diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index 466a169..3c9a42c 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -82,7 +82,7 @@ class MainWP_Child_Pagespeed { if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'hide_plugin' ) ); - add_action('admin_menu', array($this, 'hide_menu'), 999); + add_action('admin_menu', array( $this, 'hide_menu' ), 999); } $this->init_cron(); } @@ -130,7 +130,7 @@ class MainWP_Child_Pagespeed { if (isset($submenu['tools.php'])) { foreach($submenu['tools.php'] as $key => $menu) { if ($menu[2] == 'google-pagespeed-insights') { - unset($submenu['tools.php'][$key]); + unset($submenu['tools.php'][ $key ]); break; } } @@ -483,7 +483,7 @@ class MainWP_Child_Pagespeed { if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { if($post_type == $restrict_type) { $typestocheck[] = 'type = %s'; - $types[1][] = $custom_post_types[$post_type]; + $types[1][] = $custom_post_types[ $post_type ]; } } } @@ -492,7 +492,7 @@ class MainWP_Child_Pagespeed { { if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { $typestocheck[] = 'type = %s'; - $types[1][] = $custom_post_types[$post_type]; + $types[1][] = $custom_post_types[ $post_type ]; } } } diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index 7127ff7..b53c73c 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -1056,10 +1056,10 @@ class MainWP_Child_Server_Information {
    - + - + 'test'); + $query_args = array( 'mainwp_child_run' => 'test' ); $url = add_query_arg( $query_args, $url ); - $args = array( 'blocking' => true, - 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), - 'timeout' => 15, + $args = array( + 'blocking' => true, + 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), + 'timeout' => 15, ); $response = wp_remote_post( $url, $args ); $test_result = ''; @@ -1637,32 +1638,32 @@ class MainWP_Child_Server_Information { 'siteurl' => array( 'title' => __('Site URL', 'mainwp-child'), 'value' => get_bloginfo( 'url' ), - 'desc' => get_bloginfo( 'url' ), + 'desc' => get_bloginfo( 'url' ), ), 'adminuser' => array( 'title' => __('Administrator name', 'mainwp-child'), 'value' => $current_user->user_login, - 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), + 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), ), 'friendly_name' => array( 'title' => __('Friendly site name', 'mainwp-child'), 'value' => get_bloginfo( 'name' ), - 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), + 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), ), 'uniqueid' => array( 'title' => __('Child unique security id', 'mainwp-child'), 'value' => !empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), - 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), + 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), ), 'verify_ssl' => array( 'title' => __('Verify certificate', 'mainwp-child'), 'value' => __('Yes', 'mainwp-child'), - 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), + 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), ), 'ssl_version' => array( 'title' => __('SSL version', 'mainwp-child'), 'value' => __('Auto Detect', 'mainwp-child'), - 'desc' => __('Auto Detect', 'mainwp-child'), + 'desc' => __('Auto Detect', 'mainwp-child'), ), ); diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php index 3398b44..c0315bf 100644 --- a/class/class-mainwp-child-skeleton-key.php +++ b/class/class-mainwp-child-skeleton-key.php @@ -19,7 +19,7 @@ class MainWP_Child_Skeleton_Key { error_reporting( 0 ); function mainwp_skeleton_key_handle_fatal_error() { $error = error_get_last(); - if ( isset( $error['type'] ) && in_array($error['type'], array(1, 4, 16, 64, 256) ) && isset( $error['message'] ) ) { + if ( isset( $error['type'] ) && in_array($error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) { MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); } // to fix issue double header in response @@ -84,8 +84,14 @@ class MainWP_Child_Skeleton_Key { $post_args['redirection'] = 5; $post_args['decompress'] = false; // For gzinflate() data error bug $post_args['cookies'] = array( - new WP_Http_Cookie( array( 'name' => $auth_cookie_name, 'value' => $auth_cookie ) ), - new WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, 'value' => $logged_in_cookie ) ), + new WP_Http_Cookie( array( + 'name' => $auth_cookie_name, + 'value' => $auth_cookie, + ) ), + new WP_Http_Cookie( array( + 'name' => LOGGED_IN_COOKIE, + 'value' => $logged_in_cookie, + ) ), ); if ( isset( $args['get'] ) ) { @@ -190,7 +196,7 @@ class MainWP_Child_Skeleton_Key { $settings = isset($_POST['settings']) ? $_POST['settings'] : array(); if (!is_array($settings) || empty($settings)) { - return array('error' => 'Invalid data. Please check and try again.'); + return array( 'error' => 'Invalid data. Please check and try again.' ); } $whitelist_options = array( @@ -211,7 +217,7 @@ class MainWP_Child_Skeleton_Key { } //$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); - $whitelist_general = $whitelist_options[ 'general' ]; + $whitelist_general = $whitelist_options['general']; // Handle translation install. if ( ! empty( $settings['WPLANG'] ) ) { @@ -240,7 +246,7 @@ class MainWP_Child_Skeleton_Key { return false; } - return array('result' => 'ok'); + return array( 'result' => 'ok' ); } } diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index 17516c2..fb97d0f 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -78,7 +78,7 @@ class MainWP_Child_Staging { public function action() { if (!$this->is_plugin_installed) { - MainWP_Helper::write( array('error' => 'Please install WP Staging plugin on child website') ); + MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) ); } if (!class_exists( 'WPStaging\WPStaging' )){ @@ -177,12 +177,12 @@ class MainWP_Child_Staging { $save_fields = array(); foreach($filters as $field) { - if (isset($settings[$field])) { - $save_fields[$field] = $settings[$field]; + if (isset($settings[ $field ])) { + $save_fields[ $field ] = $settings[ $field ]; } } update_option('wpstg_settings', $save_fields ); - return array('result' => 'success'); + return array( 'result' => 'success' ); } public function get_overview() { @@ -201,9 +201,9 @@ class MainWP_Child_Staging { $options = $scan->getOptions(); $return = array( - 'options' => serialize($options), + 'options' => serialize($options), 'directoryListing' => $scan->directoryListing(), - 'prefix' => WPStaging\WPStaging::getTablePrefix(), + 'prefix' => WPStaging\WPStaging::getTablePrefix(), ); return $return; } @@ -217,17 +217,17 @@ class MainWP_Child_Staging { // Check clone name length if( $cloneNameLength < 1 || $cloneNameLength > 16 ) { echo array( - 'status' => 'failed', + 'status' => 'failed', 'message' => 'Clone name must be between 1 - 16 characters', ); } elseif( array_key_exists( $cloneName, $clones ) ) { return array( - 'status' => 'failed', + 'status' => 'failed', 'message' => 'Clone name is already in use, please choose an another clone name', ); } - return array('status' => 'success'); + return array( 'status' => 'success' ); } public function ajaxStartClone() { @@ -302,7 +302,7 @@ class MainWP_Child_Staging { $delete->setData(); $clone = $delete->getClone(); $result = array( - 'clone' => $clone, + 'clone' => $clone, 'deleteTables' => $delete->getTables(), ); return $result; @@ -384,13 +384,13 @@ class MainWP_Child_Staging { return ''; } - $units = array('B', 'KB', 'MB', 'GB', 'TB'); + $units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); $bytes = (float) $bytes; $base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc $pow = pow(1000, $base - floor($base)); // Same rule for 1000 - return round($pow, $precision) . ' ' . $units[ (int) floor($base)]; + return round($pow, $precision) . ' ' . $units[ (int) floor($base) ]; } diff --git a/class/class-mainwp-child-themes-check.php b/class/class-mainwp-child-themes-check.php index acf9807..4c8b47e 100644 --- a/class/class-mainwp-child-themes-check.php +++ b/class/class-mainwp-child-themes-check.php @@ -234,7 +234,13 @@ class MainWP_Child_Themes_Check { $url = set_url_scheme( $url, 'https' ); } - $args = array( 'slug' => $theme, 'fields' => array( 'sections' => false, 'tags' => false ) ); + $args = array( + 'slug' => $theme, + 'fields' => array( + 'sections' => false, + 'tags' => false, + ), + ); $args = (object) $args; $http_args = array( diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index 7dfcc73..65aa588 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -61,14 +61,14 @@ class MainWP_Child_Timecapsule { public function action() { if (!$this->is_plugin_installed) { - MainWP_Helper::write( array('error' => 'Please install WP Time Capsule plugin on child website') ); + MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) ); } try { $this->require_files(); } catch ( Exception $e) { $error = $e->getMessage(); - MainWP_Helper::write( array('error' => $error) ); + MainWP_Helper::write( array( 'error' => $error ) ); } $information = array(); @@ -84,9 +84,9 @@ class MainWP_Child_Timecapsule { $_POST['mwp_action'] == 'save_settings' || $_POST['mwp_action'] == 'get_staging_details_wptc' || $_POST['mwp_action'] == 'progress_wptc' - ) && (!$is_user_logged_in || !$privileges_wptc ) + ) && ( !$is_user_logged_in || !$privileges_wptc ) ) { - MainWP_Helper::write( array('error' => 'You are not login to your WP Time Capsule account.') ); + MainWP_Helper::write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) ); } switch ( $_POST['mwp_action'] ) { @@ -254,7 +254,7 @@ class MainWP_Child_Timecapsule { public function get_sync_data() { try { $this->require_files(); - MainWP_Helper::check_classes_exists(array('Wptc_Options_Helper', 'WPTC_Base_Factory', 'WPTC_Factory')); + MainWP_Helper::check_classes_exists(array( 'Wptc_Options_Helper', 'WPTC_Base_Factory', 'WPTC_Factory' )); $config = WPTC_Factory::get('config'); MainWP_Helper::check_methods($config, 'get_option'); @@ -265,8 +265,8 @@ class MainWP_Child_Timecapsule { $options_helper = new Wptc_Options_Helper(); - MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in')); - MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info')); + MainWP_Helper::check_methods($options_helper, array( 'get_plan_interval_from_subs_info', 'get_is_user_logged_in' )); + MainWP_Helper::check_methods($wptc_settings, array( 'get_connected_cloud_info' )); $all_backups = $this->getBackups(); $backups_count = 0; @@ -274,19 +274,19 @@ class MainWP_Child_Timecapsule { $formatted_backups = array(); foreach ($all_backups as $key => $value) { $value_array = (array) $value; - $formatted_backups[$value_array['backupID']][] = $value_array; + $formatted_backups[ $value_array['backupID'] ][] = $value_array; } $backups_count = count($formatted_backups); } $return = array( 'main_account_email' => $main_account_email_var, - 'signed_in_repos' => $wptc_settings->get_connected_cloud_info(), - 'plan_name' => $options_helper->get_plan_interval_from_subs_info(), - 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), - 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, - 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), - 'backups_count' => $backups_count, + 'signed_in_repos' => $wptc_settings->get_connected_cloud_info(), + 'plan_name' => $options_helper->get_plan_interval_from_subs_info(), + 'plan_interval' => $options_helper->get_plan_interval_from_subs_info(), + 'lastbackup_time' => !empty($last_backup_time) ? $last_backup_time : 0, + 'is_user_logged_in' => $options_helper->get_is_user_logged_in(), + 'backups_count' => $backups_count, ); return $return; } catch ( Exception $e) { @@ -319,7 +319,7 @@ class MainWP_Child_Timecapsule { public function exclude_file_list() { if (!isset($_POST['data'])) { - wptc_die_with_json_encode( array('status' => 'no data found') ); + wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['category']; $exclude_class_obj = new Wptc_ExcludeOption($category); @@ -397,7 +397,7 @@ class MainWP_Child_Timecapsule { $status['cron_url'] = $cron_status['cron_url']; $status['ips'] = $cron_status['ips']; } - return array('result' => $status); + return array( 'result' => $status ); } return false; } @@ -505,13 +505,14 @@ function get_sibling_files_callback_wptc() { $totalpages = ceil($totalitems / $perpage); //Total number of pages //adjust the query to take pagination into account if (!empty($paged) && !empty($perpage)) { - $offset = ($paged - 1) * $perpage; + $offset = ( $paged - 1 ) * $perpage; $query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage; } - return array( 'items' => $wpdb->get_results($query), - 'totalitems' => $totalitems, - 'perpage' => $perpage, + return array( + 'items' => $wpdb->get_results($query), + 'totalitems' => $totalitems, + 'perpage' => $perpage, ); } @@ -551,7 +552,7 @@ function get_sibling_files_callback_wptc() { $detailed .= ''; } - return array( 'result' => $detailed); + return array( 'result' => $detailed ); //die($detailed); } @@ -605,13 +606,13 @@ function get_sibling_files_callback_wptc() { // $user_tz_now = $user_tz->format("M d, Y @ g:i:s a"); $user_tz_now = date('M d, Y @ g:i:s a', $user_time); $msg = ''; - if (!(strpos($rec->type, 'backup') === false)) { + if (!( strpos($rec->type, 'backup') === false )) { //Backup process $msg = 'Backup Process'; - } elseif (!(strpos($rec->type, 'restore') === false)) { + } elseif (!( strpos($rec->type, 'restore') === false )) { //Restore Process $msg = 'Restore Process'; - } elseif (!(strpos($rec->type, 'staging') === false)) { + } elseif (!( strpos($rec->type, 'staging') === false )) { //Restore Process $msg = 'Staging Process'; } else { @@ -636,7 +637,7 @@ function get_sibling_files_callback_wptc() { //Close the line $html .= ''; - $display_rows[$key] = $html; + $display_rows[ $key ] = $html; } } @@ -667,7 +668,7 @@ function get_sibling_files_callback_wptc() { } else { $result = 'no'; } - return array('result' => $result); + return array( 'result' => $result ); } function stop_fresh_backup_tc_callback_wptc() { @@ -675,7 +676,7 @@ function get_sibling_files_callback_wptc() { $deactivated_plugin = null; $backup = new WPTC_BackupController(); $backup->stop($deactivated_plugin); - return array('result' => 'ok'); + return array( 'result' => 'ok' ); } @@ -689,7 +690,7 @@ function get_sibling_files_callback_wptc() { public function exclude_table_list() { if (!isset($_POST['data'])) { - wptc_die_with_json_encode( array('status' => 'no data found') ); + wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['data']['category']; $exclude_class_obj = new Wptc_ExcludeOption($category); @@ -716,7 +717,7 @@ function get_sibling_files_callback_wptc() { } try { - MainWP_Helper::check_classes_exists(array( 'WPTC_Factory')); + MainWP_Helper::check_classes_exists(array( 'WPTC_Factory' )); $config = WPTC_Factory::get('config'); @@ -740,7 +741,7 @@ function get_sibling_files_callback_wptc() { $formatted_backups = array(); foreach ($all_last_backups as $key => $value) { $value_array = (array) $value; - $formatted_backups[$value_array['backupID']][] = $value_array; + $formatted_backups[ $value_array['backupID'] ][] = $value_array; } $message = 'WP Time Capsule backup finished'; $backup_type = 'WP Time Capsule backup'; @@ -759,7 +760,7 @@ function get_sibling_files_callback_wptc() { public function include_table_list() { if (!isset($_POST['data'])) { - wptc_die_with_json_encode( array('status' => 'no data found') ); + wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['data']['category']; $exclude_class_obj = new Wptc_ExcludeOption($category); @@ -770,7 +771,7 @@ function get_sibling_files_callback_wptc() { public function include_table_structure_only() { if (!isset($_POST['data'])) { - wptc_die_with_json_encode( array('status' => 'no data found') ); + wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['data']['category']; @@ -782,7 +783,7 @@ function get_sibling_files_callback_wptc() { public function include_file_list() { if (!isset($_POST['data'])) { - wptc_die_with_json_encode( array('status' => 'no data found') ); + wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['category']; $exclude_class_obj = new Wptc_ExcludeOption($category); @@ -803,7 +804,7 @@ function get_sibling_files_callback_wptc() { if($options_helper->get_is_user_logged_in()){ return array( - 'result' => 'is_user_logged_in', + 'result' => 'is_user_logged_in', 'sync_data' => $this->get_sync_data(), ); } @@ -812,7 +813,7 @@ function get_sibling_files_callback_wptc() { $pwd = $_POST['acc_pwd']; if (empty( $email ) || empty($pwd)) { - return array('error' => 'Username and password cannot be empty'); + return array( 'error' => 'Username and password cannot be empty' ); } $config = WPTC_Base_Factory::get('Wptc_InitialSetup_Config'); @@ -836,9 +837,12 @@ function get_sibling_files_callback_wptc() { $is_user_logged_in = $options->get_option('is_user_logged_in'); if (!$is_user_logged_in) { - return array('error' => 'Login failed.'); + return array( 'error' => 'Login failed.' ); } - return array('result' => 'ok', 'sync_data' => $this->get_sync_data()); + return array( + 'result' => 'ok', + 'sync_data' => $this->get_sync_data(), + ); } function get_installed_plugins() { @@ -847,9 +851,9 @@ function get_sibling_files_callback_wptc() { $plugins = $backup_before_auto_update_settings->get_installed_plugins(); if ($plugins) { - return array('results' =>$plugins ); + return array( 'results' =>$plugins ); } - return array( 'results' => array()); + return array( 'results' => array() ); } function get_installed_themes() { @@ -858,9 +862,9 @@ function get_sibling_files_callback_wptc() { $plugins = $backup_before_auto_update_settings->get_installed_themes(); if ($plugins) { - return array('results' =>$plugins ); + return array( 'results' =>$plugins ); } - return array('results' => array() ); + return array( 'results' => array() ); } function is_staging_need_request() { @@ -880,7 +884,10 @@ function get_sibling_files_callback_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); if (empty($_POST['path'])) { - wptc_die_with_json_encode( array('status' => 'error', 'msg' => 'path is missing') ); + wptc_die_with_json_encode( array( + 'status' => 'error', + 'msg' => 'path is missing', + ) ); } $staging->choose_action($_POST['path'], $reqeust_type = 'fresh'); @@ -941,7 +948,7 @@ function get_sibling_files_callback_wptc() { public function init_restore() { if (empty($_POST)) { - return ( array('error' => 'Backup id is empty !') ); + return ( array( 'error' => 'Backup id is empty !' ) ); } $restore_to_staging = WPTC_Base_Factory::get('Wptc_Restore_To_Staging'); $restore_to_staging->init_restore($_POST); @@ -956,7 +963,7 @@ function get_sibling_files_callback_wptc() { if( !$options_helper->get_is_user_logged_in() ){ return array( 'sync_data' => $this->get_sync_data(), - 'error' => 'Login to your WP Time Capsule account first', + 'error' => 'Login to your WP Time Capsule account first', ); } @@ -1087,10 +1094,10 @@ function get_sibling_files_callback_wptc() { } if ( ! $saved ) { - return array('error' => 'Error: Not saved settings'); + return array( 'error' => 'Error: Not saved settings' ); } - return array('result' => 'ok'); + return array( 'result' => 'ok' ); } private function filter_plugins( $included_plugins) { @@ -1125,14 +1132,14 @@ function get_sibling_files_callback_wptc() { $plugins = $vulns_obj->get_enabled_plugins(); $plugins = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($plugins, 'plugins'); - return array('results' => $plugins); + return array( 'results' => $plugins ); } public function get_enabled_themes() { $vulns_obj = WPTC_Base_Factory::get('Wptc_Vulns'); $themes = $vulns_obj->get_enabled_themes(); $themes = WPTC_Base_Factory::get('Wptc_App_Functions')->fancytree_format($themes, 'themes'); - return array('results' => $themes); + return array( 'results' => $themes ); } public function get_system_info() { @@ -1160,15 +1167,15 @@ function get_sibling_files_callback_wptc() { if ( function_exists( 'curl_version' ) ) { $curlversion = curl_version(); - echo ''; - echo ''; + echo ''; + echo ''; } else { echo ''; } echo ''; - echo ''; + echo ''; echo ''; echo ''; @@ -1187,7 +1194,7 @@ function get_sibling_files_callback_wptc() { } $now = localtime( time(), true ); - echo ''; + echo ''; echo ''; echo ''; echo '
    Pass' : self::getWarningHTML( $errorType ) ); ?> Pass' : self::getWarningHTML( $errorType ) ); ?> Pass'; ?> Pass' : self::getWarningHTML( $errorType )); ?> Pass' : self::getWarningHTML( $errorType ) ); ?>
    Load more
    ' . __( 'cURL version', 'wp-time-capsule' ) . '' . esc_html( $curlversion[ 'version' ] ) . '
    ' . __( 'cURL SSL version', 'wp-time-capsule' ) . '' . esc_html( $curlversion[ 'ssl_version' ] ) . '
    ' . __( 'cURL version', 'wp-time-capsule' ) . '' . esc_html( $curlversion['version'] ) . '
    ' . __( 'cURL SSL version', 'wp-time-capsule' ) . '' . esc_html( $curlversion['ssl_version'] ) . '
    ' . __( 'cURL version', 'wp-time-capsule' ) . '' . __( 'unavailable', 'wp-time-capsule' ) . '
    ' . __( 'Server', 'wp-time-capsule' ) . '' . esc_html( $_SERVER[ 'SERVER_SOFTWARE' ] ) . '
    ' . __( 'Server', 'wp-time-capsule' ) . '' . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . '
    ' . __( 'Operating System', 'wp-time-capsule' ) . '' . esc_html( PHP_OS ) . '
    ' . __( 'PHP SAPI', 'wp-time-capsule' ) . '' . esc_html( PHP_SAPI ) . '
    ' . __( 'Server Time', 'wp-time-capsule' ) . '' . esc_html( $now[ 'tm_hour' ] . ':' . $now[ 'tm_min' ] ) . '
    ' . __( 'Server Time', 'wp-time-capsule' ) . '' . esc_html( $now['tm_hour'] . ':' . $now['tm_min'] ) . '
    ' . __( 'Blog Time', 'wp-time-capsule' ) . '' . date( 'H:i', current_time( 'timestamp' ) ) . '
    ' . __( 'Blog language', 'wp-time-capsule' ) . '' . get_bloginfo( 'language' ) . '
    ' . __( 'MySQL Client encoding', 'wp-time-capsule' ) . ''; @@ -1217,7 +1224,7 @@ function get_sibling_files_callback_wptc() { echo '
    '; $html = ob_get_clean(); - return array( 'result' => $html); + return array( 'result' => $html ); } @@ -1233,7 +1240,7 @@ function get_sibling_files_callback_wptc() { function start_fresh_backup_tc_callback_wptc() { start_fresh_backup_tc_callback_wptc($type = '', $args = null, $test_connection = true, $ajax_check = false); - return array('result' => 'success'); + return array( 'result' => 'success' ); } public function save_manual_backup_name_wptc() { diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index d594af4..9d81087 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -163,7 +163,7 @@ class MainWP_Child_Updraft_Plus_Backups { break; } } catch(Exception $e) { - $information = array('error' => $e->getMessage()); + $information = array( 'error' => $e->getMessage() ); } } MainWP_Helper::write( $information ); @@ -245,12 +245,18 @@ class MainWP_Child_Updraft_Plus_Backups { private function do_vault_connect() { $vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' ); if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) { - return array( 'connected' => true, 'html' => $this->connected_html() ); + return array( + 'connected' => true, + 'html' => $this->connected_html(), + ); } $connect = $this->vault_connect( $_REQUEST['email'], $_REQUEST['passwd'] ); if ( true === $connect ) { - $response = array( 'connected' => true, 'html' => $this->connected_html() ); + $response = array( + 'connected' => true, + 'html' => $this->connected_html(), + ); } else { $response = array( 'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ), @@ -303,11 +309,11 @@ class MainWP_Child_Updraft_Plus_Backups { $result = wp_remote_post( $vault_mothership . '/?udm_action=vault_connect', array( 'timeout' => 20, - 'body' => array( - 'e' => $email, - 'p' => base64_encode( $password ), + 'body' => array( + 'e' => $email, + 'p' => base64_encode( $password ), 'sid' => $updraftplus->siteid(), - 'su' => base64_encode( home_url() ), + 'su' => base64_encode( home_url() ), ), ) ); @@ -376,16 +382,18 @@ class MainWP_Child_Updraft_Plus_Backups { delete_transient( 'udvault_last_config' ); delete_transient( 'updraftvault_quota_text' ); - MainWP_Helper::close_connection( array( 'disconnected' => 1, - 'html' => $this->connected_html(), ) + MainWP_Helper::close_connection( array( + 'disconnected' => 1, + 'html' => $this->connected_html(), + ) ); // If $_POST['reset_hash'] is set, then we were alerted by updraftplus.com - no need to notify back if ( is_array( $vault_settings ) && isset( $vault_settings['email'] ) && empty( $_POST['reset_hash'] ) ) { $post_body = array( - 'e' => (string) $vault_settings['email'], + 'e' => (string) $vault_settings['email'], 'sid' => $updraftplus->siteid(), - 'su' => base64_encode( home_url() ), + 'su' => base64_encode( home_url() ), ); if ( !empty( $vault_settings['token'] ) ) { $post_body['token'] = (string) $vault_settings['token']; @@ -394,7 +402,7 @@ class MainWP_Child_Updraft_Plus_Backups { // Use SSL to prevent snooping wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array( 'timeout' => 20, - 'body' => $post_body, + 'body' => $post_body, )); } } @@ -430,11 +438,11 @@ class MainWP_Child_Updraft_Plus_Backups { if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if (isset($settings['is_general']) && !empty($settings['is_general'])){ - $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); + $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } else { // $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey']; // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; - $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); + $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } } else { if (isset($settings['is_general']) && !empty($settings['is_general'])){ @@ -517,15 +525,15 @@ class MainWP_Child_Updraft_Plus_Backups { } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); - $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey']; - $opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey']; - $opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']); - if (!empty($opts['settings'][$settings_key]['path']) && '/' == substr($opts['settings'][$settings_key]['path'], 0, 1)) { - $opts['settings'][$settings_key]['path'] = substr($opts['settings'][$settings_key]['path'], 1); + $opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey']; + $opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey']; + $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); + if (!empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1)) { + $opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1); } if (isset($settings[ $key ]['rrs'])) { // premium settings - $opts['settings'][$settings_key]['rrs'] = $settings[ $key ]['rrs']; - $opts['settings'][$settings_key]['server_side_encryption'] = $settings[ $key ]['server_side_encryption']; + $opts['settings'][ $settings_key ]['rrs'] = $settings[ $key ]['rrs']; + $opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption']; } } else { $opts['accesskey'] = $settings[ $key ]['accesskey']; @@ -548,10 +556,10 @@ class MainWP_Child_Updraft_Plus_Backups { } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); - $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint']; - $opts['settings'][$settings_key]['accesskey'] = $settings[ $key ]['accesskey']; - $opts['settings'][$settings_key]['secretkey'] = $settings[ $key ]['secretkey']; - $opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']); + $opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint']; + $opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey']; + $opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey']; + $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); } else { $opts['endpoint'] = $settings[ $key ]['endpoint']; $opts['accesskey'] = $settings[ $key ]['accesskey']; @@ -567,8 +575,8 @@ class MainWP_Child_Updraft_Plus_Backups { } if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); - $opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']); - $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint']; + $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); + $opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint']; } else { $opts['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['endpoint'] = $settings[ $key ]['endpoint']; @@ -582,11 +590,11 @@ class MainWP_Child_Updraft_Plus_Backups { if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { - $opts['settings'][$settings_key]['host'] = $settings[ $key ]['host']; - $opts['settings'][$settings_key]['user'] = $settings[ $key ]['user']; - $opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass']; - $opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); - $opts['settings'][$settings_key]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0; + $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host']; + $opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user']; + $opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass']; + $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); + $opts['settings'][ $settings_key ]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0; } } else { if ( isset( $settings[ $key ]['path'] ) ) { @@ -607,13 +615,13 @@ class MainWP_Child_Updraft_Plus_Backups { if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { - $opts['settings'][$settings_key]['host'] = $settings[ $key ]['host']; - $opts['settings'][$settings_key]['port'] = $settings[ $key ]['port']; - $opts['settings'][$settings_key]['user'] = $settings[ $key ]['user']; - $opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass']; - $opts['settings'][$settings_key]['key'] = $settings[ $key ]['key']; - $opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); - $opts['settings'][$settings_key]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0; + $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host']; + $opts['settings'][ $settings_key ]['port'] = $settings[ $key ]['port']; + $opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user']; + $opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass']; + $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key']; + $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] ); + $opts['settings'][ $settings_key ]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0; } } else { if ( isset( $settings[ $key ]['path'] ) ) { @@ -635,7 +643,7 @@ class MainWP_Child_Updraft_Plus_Backups { if(is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); - $opts['settings'][$settings_key]['url'] = $this->replace_tokens( $settings[ $key ]['url'] ); + $opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] ); UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts ); } @@ -646,16 +654,16 @@ class MainWP_Child_Updraft_Plus_Backups { } if (is_array($opts) && isset($opts['settings'])) { $settings_key = key($opts['settings']); - $opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id']; - $opts['settings'][$settings_key]['key'] = $settings[ $key ]['key']; + $opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id']; + $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key']; $bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] ); $bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] ); $bname = str_replace('.', '-', $bname); $bpath = str_replace('.', '-', $bpath); $bname = str_replace('_', '', $bname); // to fix strange character $bpath = str_replace('_', '', $bpath); - $opts['settings'][$settings_key]['bucket_name'] = $bname; - $opts['settings'][$settings_key]['backup_path'] = $bpath; + $opts['settings'][ $settings_key ]['bucket_name'] = $bname; + $opts['settings'][ $settings_key ]['backup_path'] = $bpath; UpdraftPlus_Options::update_updraft_option( $key, $opts ); } } else { @@ -822,7 +830,10 @@ class MainWP_Child_Updraft_Plus_Backups { } if ( ! class_exists( 'UpdraftPlus_WPDB_OtherDB_Test' ) ) { - return array( 'r' => $_POST['row'], 'm' => 'Error: Require premium UpdraftPlus plugin.' ); + return array( + 'r' => $_POST['row'], + 'm' => 'Error: Require premium UpdraftPlus plugin.', + ); } if ( empty( $_POST['user_db'] ) ) { @@ -882,7 +893,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ( ! $failed ) { $all_tables = $wpdb_obj->get_results( 'SHOW TABLES', ARRAY_N ); //$all_tables = array_map( create_function( '$a', 'return $a[0];' ), $all_tables ); - $all_tables = array_map(array($this, 'cb_get_name_base_type'), $all_tables); + $all_tables = array_map(array( $this, 'cb_get_name_base_type' ), $all_tables); if ( empty( $_POST['prefix'] ) ) { $ret_info .= sprintf( __( '%s table(s) found.', 'updraftplus' ), count( $all_tables ) ); @@ -920,7 +931,10 @@ class MainWP_Child_Updraft_Plus_Backups { restore_error_handler(); - return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after ); + return array( + 'r' => $_POST['row'], + 'm' => $ret . $ret_after, + ); } private function cb_get_name_base_type( $a) { @@ -944,7 +958,10 @@ class MainWP_Child_Updraft_Plus_Backups { // unfix for tic#22678 $this->close_browser_connection( $msg ); - $options = array( 'nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce ); + $options = array( + 'nocloud' => $backupnow_nocloud, + 'use_nonce' => $nonce, + ); if ( ! empty( $_REQUEST['onlythisfileentity'] ) && is_string( $_REQUEST['onlythisfileentity'] ) ) { // Something to see in the 'last log' field when it first appears, before the backup actually starts $updraftplus->log( __( 'Start backup', 'updraftplus' ) ); @@ -1073,7 +1090,10 @@ class MainWP_Child_Updraft_Plus_Backups { $last_backup_text = '' . __( 'No backup has been completed.', 'updraftplus' ) . ''; } - return array( 'b' => $last_backup_text, 'lasttime_gmt' => $backup_time ); + return array( + 'b' => $last_backup_text, + 'lasttime_gmt' => $backup_time, + ); } private function get_updraft_data( $with_hist = true ) { @@ -1119,7 +1139,7 @@ class MainWP_Child_Updraft_Plus_Backups { } $updraft_dir = $updraftplus->backups_dir_location(); - $backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1; + $backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1; $current_timegmt = time(); $current_time = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $current_timegmt ), 'D, F j, Y H:i' ); @@ -1221,7 +1241,7 @@ class MainWP_Child_Updraft_Plus_Backups { MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable'); $updraft_dir = $updraftplus->backups_dir_location(); - $backup_disabled = (UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir)) ? 0 : 1; + $backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1; $out = array( 'n' => $html, @@ -1396,7 +1416,10 @@ class MainWP_Child_Updraft_Plus_Backups { $output = $noutput . $output; } - return array( 'h' => $output, 'c' => count( $backup_history ) ); + return array( + 'h' => $output, + 'c' => count( $backup_history ), + ); } public function historystatus( $remotescan = null, $rescan = null ) { @@ -1641,7 +1664,11 @@ class MainWP_Child_Updraft_Plus_Backups { $timestamp = (int) $_POST['timestamp']; if ( ! isset( $backups[ $timestamp ] ) ) { - return array( 'm' => '', 'w' => '', 'e' => __( 'No such backup set exists', 'updraftplus' ) ); + return array( + 'm' => '', + 'w' => '', + 'e' => __( 'No such backup set exists', 'updraftplus' ), + ); } @@ -2237,7 +2264,10 @@ class MainWP_Child_Updraft_Plus_Backups { $output = ob_get_clean(); - return array( 'o' => $output, 'd' => $deleted ); + return array( + 'o' => $output, + 'd' => $deleted, + ); } //deletes the -old directories that are created when a backup is restored. @@ -2579,13 +2609,13 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus->get_max_packet_size(); $backup = UpdraftPlus_Backup_History::get_history($timestamp); - if (!isset($backup['nonce']) || !isset($backup['db'])) { return array($mess, $warn, $err, $info); + if (!isset($backup['nonce']) || !isset($backup['db'])) { return array( $mess, $warn, $err, $info ); } - $db_file = (is_string($backup['db'])) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; + $db_file = ( is_string($backup['db']) ) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; } - if (!is_readable($db_file)) { return array($mess, $warn, $err, $info); + if (!is_readable($db_file)) { return array( $mess, $warn, $err, $info ); } // Encrypted - decrypt it @@ -2599,7 +2629,7 @@ class MainWP_Child_Updraft_Plus_Backups { } else { $err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted.', 'updraftplus')); } - return array($mess, $warn, $err, $info); + return array( $mess, $warn, $err, $info ); } $decrypted_file = UpdraftPlus_Encryption::decrypt($db_file, $encryption); @@ -2608,22 +2638,22 @@ class MainWP_Child_Updraft_Plus_Backups { $db_file = $decrypted_file['fullpath']; } else { $err[] = __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus'); - return array($mess, $warn, $err, $info); + return array( $mess, $warn, $err, $info ); } } // Even the empty schema when gzipped comes to 1565 bytes; a blank WP 3.6 install at 5158. But we go low, in case someone wants to share single tables. if (filesize($db_file) < 1000) { $err[] = sprintf(__('The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus'), round(filesize($db_file)/1024, 1)); - return array($mess, $warn, $err, $info); + return array( $mess, $warn, $err, $info ); } - $is_plain = ('.gz' == substr($db_file, -3, 3)) ? false : true; + $is_plain = ( '.gz' == substr($db_file, -3, 3) ) ? false : true; - $dbhandle = ($is_plain) ? fopen($db_file, 'r') : $this->gzopen_for_read($db_file, $warn, $err); + $dbhandle = ( $is_plain ) ? fopen($db_file, 'r') : $this->gzopen_for_read($db_file, $warn, $err); if (!is_resource($dbhandle)) { $err[] = __('Failed to open database file.', 'updraftplus'); - return array($mess, $warn, $err, $info); + return array( $mess, $warn, $err, $info ); } $info['timestamp'] = $timestamp; @@ -2644,7 +2674,7 @@ class MainWP_Child_Updraft_Plus_Backups { // TODO: If the backup is the right size/checksum, then we could restore the $line <= 100 in the 'while' condition and not bother scanning the whole thing? Or better: sort the core tables to be first so that this usually terminates early - $wanted_tables = array('terms', 'term_taxonomy', 'term_relationships', 'commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'users', 'usermeta'); + $wanted_tables = array( 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta', 'comments', 'links', 'options', 'postmeta', 'posts', 'users', 'usermeta' ); $migration_warning = false; $processing_create = false; @@ -2653,32 +2683,32 @@ class MainWP_Child_Updraft_Plus_Backups { // Don't set too high - we want a timely response returned to the browser // Until April 2015, this was always 90. But we've seen a few people with ~1GB databases (uncompressed), and 90s is not enough. Note that we don't bother checking here if it's compressed - having a too-large timeout when unexpected is harmless, as it won't be hit. On very large dbs, they're expecting it to take a while. // "120 or 240" is a first attempt at something more useful than just fixed at 90 - but should be sufficient (as 90 was for everyone without ~1GB databases) - $default_dbscan_timeout = (filesize($db_file) < 31457280) ? 120 : 240; - $dbscan_timeout = (defined('UPDRAFTPLUS_DBSCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DBSCAN_TIMEOUT)) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout; + $default_dbscan_timeout = ( filesize($db_file) < 31457280 ) ? 120 : 240; + $dbscan_timeout = ( defined('UPDRAFTPLUS_DBSCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DBSCAN_TIMEOUT) ) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout; @set_time_limit($dbscan_timeout); // We limit the time that we spend scanning the file for character sets - $db_charset_collate_scan_timeout = (defined('UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT)) ? UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT : 10; + $db_charset_collate_scan_timeout = ( defined('UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT') && is_numeric(UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT) ) ? UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT : 10; $charset_scan_start_time = microtime(true); $db_supported_character_sets_res = $GLOBALS['wpdb']->get_results('SHOW CHARACTER SET', OBJECT_K); - $db_supported_character_sets = (null !== $db_supported_character_sets_res) ? $db_supported_character_sets_res : array(); + $db_supported_character_sets = ( null !== $db_supported_character_sets_res ) ? $db_supported_character_sets_res : array(); $db_charsets_found = array(); $db_supported_collations_res = $GLOBALS['wpdb']->get_results('SHOW COLLATION', OBJECT_K); - $db_supported_collations = (null !== $db_supported_collations_res) ? $db_supported_collations_res : array(); + $db_supported_collations = ( null !== $db_supported_collations_res ) ? $db_supported_collations_res : array(); $db_charsets_found = array(); $db_collates_found = array(); $db_supported_charset_related_to_unsupported_collation = false; $db_supported_charsets_related_to_unsupported_collations = array(); - while ((($is_plain && !feof($dbhandle)) || (!$is_plain && !gzeof($dbhandle))) && ($line<100 || (!$header_only && count($wanted_tables)>0) || ((microtime(true) - $charset_scan_start_time) < $db_charset_collate_scan_timeout && !empty($db_supported_character_sets)))) { + while (( ( $is_plain && !feof($dbhandle) ) || ( !$is_plain && !gzeof($dbhandle) ) ) && ( $line<100 || ( !$header_only && count($wanted_tables)>0 ) || ( ( microtime(true) - $charset_scan_start_time ) < $db_charset_collate_scan_timeout && !empty($db_supported_character_sets) ) )) { $line++; // Up to 1MB - $buffer = ($is_plain) ? rtrim(fgets($dbhandle, 1048576)) : rtrim(gzgets($dbhandle, 1048576)); + $buffer = ( $is_plain ) ? rtrim(fgets($dbhandle, 1048576)) : rtrim(gzgets($dbhandle, 1048576)); // Comments are what we are interested in if (substr($buffer, 0, 1) == '#') { $processing_create = false; if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) { $old_siteurl = untrailingslashit($matches[1]); - $mess[] = __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . ((!empty($old_wp_version)) ? ' ' . sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : ''); + $mess[] = __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . ( ( !empty($old_wp_version) ) ? ' ' . sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : '' ); // Check for should-be migration if (untrailingslashit(site_url()) != $old_siteurl) { if (!$migration_warning) { @@ -2690,12 +2720,12 @@ class MainWP_Child_Updraft_Plus_Backups { $info['same_url'] = false; $old_siteurl_parsed = parse_url($old_siteurl); $actual_siteurl_parsed = parse_url(site_url()); - if ((stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0) || (stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0)) { + if (( stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0 ) || ( stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0 )) { $powarn = sprintf(__('The website address in the backup set (%1$s) is slightly different from that of the site now (%2$s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()) . ' '; } else { $powarn = ''; } - if (('https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme']) || ('http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'])) { + if (( 'https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme'] ) || ( 'http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'] )) { $powarn .= sprintf(__('This backup set is of this site, but at the time of the backup you were using %1$s, whereas the site now uses %2$s.', 'updraftplus'), $old_siteurl_parsed['scheme'], $actual_siteurl_parsed['scheme']); if ('https' == $old_siteurl_parsed['scheme']) { $powarn .= ' ' . apply_filters('updraftplus_https_to_http_additional_warning', sprintf(__('This restoration will work if you still have an SSL certificate (i.e. can use https) to access the site. Otherwise, you will want to use %s to search/replace the site address so that the site can be visited without https.', 'updraftplus'), '' . __('the migrator add-on', 'updraftplus') . '')); @@ -2751,7 +2781,7 @@ class MainWP_Child_Updraft_Plus_Backups { $warn[] = sprintf(__('The site in this backup was running on a webserver with version %1$s of %2$s. ', 'updraftplus'), $old_php_version, 'PHP') . ' ' . sprintf(__('This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus'), PHP_VERSION) . ' ' . sprintf(__('You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus'), 'PHP') . ' ' . sprintf(__('Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus'), 'PHP'); } } - } elseif ('' == $old_table_prefix && (preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches))) { + } elseif ('' == $old_table_prefix && ( preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches) )) { $old_table_prefix = $matches[1]; // echo ''.__('Old table prefix:', 'updraftplus').' '.htmlspecialchars($old_table_prefix).'
    '; } elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) { @@ -2772,7 +2802,7 @@ class MainWP_Child_Updraft_Plus_Backups { // Got the needed code? if (!class_exists('UpdraftPlusAddOn_MultiSite') || !class_exists('UpdraftPlus_Addons_Migrator')) { $err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('To import an ordinary WordPress site into a multisite installation requires %s.', 'updraftplus'), 'UpdraftPlus Premium')); - return array($mess, $warn, $err, $info); + return array( $mess, $warn, $err, $info ); } } elseif (isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && !is_multisite()) { $warn[] = __('Warning:', 'updraftplus') . ' ' . __('Your backup is of a WordPress multisite install; but this site is not. Only the first site of the network will be accessible.', 'updraftplus') . ' ' . __('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus') . ''; @@ -2785,7 +2815,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ($val) { $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; } } - $old_siteinfo[$key] = $val; + $old_siteinfo[ $key ] = $val; } } elseif (preg_match('/^\# Skipped tables: (.*)$/', $buffer, $matches)) { $skipped_tables = explode(',', $matches[1]); @@ -2798,7 +2828,7 @@ class MainWP_Child_Updraft_Plus_Backups { // Remove prefix $table = UpdraftPlus_Manipulation_Functions::str_replace_once($old_table_prefix, '', $table); if (in_array($table, $wanted_tables)) { - $wanted_tables = array_diff($wanted_tables, array($table)); + $wanted_tables = array_diff($wanted_tables, array( $table )); } } if (';' != substr($buffer, -1, 1)) { @@ -2809,19 +2839,19 @@ class MainWP_Child_Updraft_Plus_Backups { if (!empty($db_supported_collations)) { if (preg_match('/ COLLATE=([^\s;]+)/i', $buffer, $collate_match)) { $db_collates_found[] = $collate_match[1]; - if (!isset($db_supported_collations[$collate_match[1]])) { + if (!isset($db_supported_collations[ $collate_match[1] ])) { $db_supported_charset_related_to_unsupported_collation = true; } } if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+),/i', $buffer, $collate_match)) { $db_collates_found[] = $collate_match[1]; - if (!isset($db_supported_collations[$collate_match[1]])) { + if (!isset($db_supported_collations[ $collate_match[1] ])) { $db_supported_charset_related_to_unsupported_collation = true; } } if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+) /i', $buffer, $collate_match)) { $db_collates_found[] = $collate_match[1]; - if (!isset($db_supported_collations[$collate_match[1]])) { + if (!isset($db_supported_collations[ $collate_match[1] ])) { $db_supported_charset_related_to_unsupported_collation = true; } } @@ -2855,7 +2885,7 @@ class MainWP_Child_Updraft_Plus_Backups { $db_unsupported_charset = array(); $db_charset_forbidden = false; foreach ($db_charsets_found_unique as $db_charset) { - if (!isset($db_supported_character_sets[$db_charset])) { + if (!isset($db_supported_character_sets[ $db_charset ])) { $db_unsupported_charset[] = $db_charset; $db_charset_forbidden = true; } @@ -2867,7 +2897,7 @@ class MainWP_Child_Updraft_Plus_Backups { $similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_charset_unique, $db_supported_character_sets, true); if (empty($similar_type_charset)) { $row = $GLOBALS['wpdb']->get_row('show variables like "character_set_database"'); - $similar_type_charset = (null !== $row) ? $row->Value : ''; + $similar_type_charset = ( null !== $row ) ? $row->Value : ''; } if (empty($similar_type_charset) && !empty($db_supported_character_sets[0])) { $similar_type_charset = $db_supported_character_sets[0]; @@ -2890,7 +2920,7 @@ class MainWP_Child_Updraft_Plus_Backups { $db_unsupported_collate = array(); $db_collate_forbidden = false; foreach ($db_collates_found_unique as $db_collate) { - if (!isset($db_supported_collations[$db_collate])) { + if (!isset($db_supported_collations[ $db_collate ])) { $db_unsupported_collate[] = $db_collate; $db_collate_forbidden = true; } @@ -2938,9 +2968,9 @@ class MainWP_Child_Updraft_Plus_Backups { if ($db_charset_forbidden) { $collate_change_on_charset_selection_data = array( - 'db_supported_collations' => $db_supported_collations, + 'db_supported_collations' => $db_supported_collations, 'db_unsupported_collate_unique' => $db_unsupported_collate_unique, - 'db_collates_found' => $db_collates_found, + 'db_collates_found' => $db_collates_found, ); $info['addui'] .= ''; } @@ -2979,7 +3009,7 @@ class MainWP_Child_Updraft_Plus_Backups { foreach ($missing_tables as $key => $value) { if (in_array($old_table_prefix . $value, $skipped_tables)) { - unset($missing_tables[$key]); + unset($missing_tables[ $key ]); } } @@ -3000,7 +3030,7 @@ class MainWP_Child_Updraft_Plus_Backups { // $db_file = $decrypted_file['fullpath'].'.crypt'; // unlink($decrypted_file['fullpath']); - return array($mess, $warn, $err, $info); + return array( $mess, $warn, $err, $info ); } @@ -3158,15 +3188,15 @@ class MainWP_Child_Updraft_Plus_Backups { $service_title = ''; if (!isset($backup['service'])) { $backup['service'] = array(); } - if (!is_array($backup['service'])) { $backup['service'] = array($backup['service']); + if (!is_array($backup['service'])) { $backup['service'] = array( $backup['service'] ); } foreach ($backup['service'] as $service) { - if ('none' === $service || '' === $service || (is_array($service) && (empty($service) || array('none') === $service || array('') === $service))) { + if ('none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) )) { // Do nothing } else { // $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png'; - $remote_storage = ('remotesend' === $service) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[$service]; + $remote_storage = ( 'remotesend' === $service ) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[ $service ]; $service_title = '
    ' . esc_attr(sprintf(__('Remote storage: %s', 'updraftplus'), $remote_storage)); } @@ -3859,7 +3889,10 @@ ENDHERE; $args = $cron[ $time ]['updraft_backup_resume'][ $hook ]['args']; wp_unschedule_event( $time, 'updraft_backup_resume', $args ); if ( ! $found_it ) { - return array( 'ok' => 'Y', 'm' => __( 'Job deleted', 'updraftplus' ) ); + return array( + 'ok' => 'Y', + 'm' => __( 'Job deleted', 'updraftplus' ), + ); } $found_it = 1; } diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php index 32367b7..b438570 100644 --- a/class/class-mainwp-child-vulnerability-checker.php +++ b/class/class-mainwp-child-vulnerability-checker.php @@ -51,11 +51,14 @@ class MainWP_Child_Vulnerability_Checker { function vulner_recheck() { $result = array(); - $force = (isset($_POST['force']) && !empty($_POST['force'])) ? true : false; + $force = ( isset($_POST['force']) && !empty($_POST['force']) ) ? true : false; $result['plugin'] = $this->check_plugins($force); $result['wp'] = $this->check_wp($force); $result['theme'] = $this->check_themes($force); - $information = array( 'result' => $result, 'ok' => 1); + $information = array( + 'result' => $result, + 'ok' => 1, + ); return $information; } @@ -90,15 +93,15 @@ class MainWP_Child_Vulnerability_Checker { } if(count($plug_vulner_data) == 0) { - unset($plug_vuln_filter[$slug]); + unset($plug_vuln_filter[ $slug ]); } else { - $plug_vuln_filter[$slug]['vulnerabilities'] = $plug_vulner_data; - $plug_vuln_filter[$slug]['detected_version'] = $plugin_version; - $plug_vuln_filter[$slug]['plugin_slug'] = $plug; + $plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data; + $plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version; + $plug_vuln_filter[ $slug ]['plugin_slug'] = $plug; } } else { - unset($plug_vuln_filter[$slug]); + unset($plug_vuln_filter[ $slug ]); } } @@ -111,7 +114,7 @@ class MainWP_Child_Vulnerability_Checker { } else { continue; } - $result[$plug] = $plug_vuln; + $result[ $plug ] = $plug_vuln; } } return $result; @@ -168,12 +171,12 @@ class MainWP_Child_Vulnerability_Checker { } if(count($th_vulner_data) == 0) { - unset($th_vuln_filter[$slug]); + unset($th_vuln_filter[ $slug ]); } else { - $th_vuln_filter[$slug]['vulnerabilities'] = $th_vulner_data; + $th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data; } } else { - unset($th_vuln_filter[$slug]); + unset($th_vuln_filter[ $slug ]); } } @@ -186,10 +189,10 @@ class MainWP_Child_Vulnerability_Checker { continue; } - $result[$th['id']]['vulner_data'] = $th_vuln; - $result[$th['id']]['name'] = $th['name']; - $result[$th['id']]['author'] = $th['author']; - $result[$th['id']]['detected_version'] = $th['version']; + $result[ $th['id'] ]['vulner_data'] = $th_vuln; + $result[ $th['id'] ]['name'] = $th['name']; + $result[ $th['id'] ]['author'] = $th['author']; + $result[ $th['id'] ]['detected_version'] = $th['version']; } } } @@ -203,7 +206,7 @@ class MainWP_Child_Vulnerability_Checker { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token token=' . $this->wpvulndb_token)); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Token token=' . $this->wpvulndb_token )); curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -220,7 +223,7 @@ class MainWP_Child_Vulnerability_Checker { function get_random_user_agent () { - $someUA = array ( + $someUA = array( 'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19', @@ -236,7 +239,7 @@ class MainWP_Child_Vulnerability_Checker { srand( (float) microtime()*1000000); - return $someUA[rand(0, count($someUA)-1)]; + return $someUA[ rand(0, count($someUA)-1) ]; } diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 7151132..c16c56f 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -465,7 +465,7 @@ class MainWP_Child_WooCommerce_Status { $background_updater->save()->dispatch(); } - return array('result' => 'success'); + return array( 'result' => 'success' ); } } diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index bb86c97..77c24cf 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -693,7 +693,7 @@ class MainWP_Child_Wordfence { $scan_time = array(); if ( $rows ) { while ( $row = MainWP_Child_DB::fetch_array( $rows ) ) { - $scan_time[$row['ctime']] = $row['msg']; + $scan_time[ $row['ctime'] ] = $row['msg']; } } @@ -795,17 +795,17 @@ class MainWP_Child_Wordfence { $counts = $i->getIssueCounts(); return array( - 'issuesLists' => $iss, - 'issueCounts' => $counts, - 'lastScanCompleted' => wfConfig::get( 'lastScanCompleted' ), - 'apiKey' => wfConfig::get( 'apiKey' ), - 'isPaid' => wfConfig::get('isPaid'), + 'issuesLists' => $iss, + 'issueCounts' => $counts, + 'lastScanCompleted' => wfConfig::get( 'lastScanCompleted' ), + 'apiKey' => wfConfig::get( 'apiKey' ), + 'isPaid' => wfConfig::get('isPaid'), 'lastscan_timestamp' => $this->get_lastscan(), - 'isNginx' => wfUtils::isNginx() ? 1 : 0, - 'todayAttBlocked' => $this->count_attacks_blocked(1), - 'weekAttBlocked' => $this->count_attacks_blocked(7), - 'monthAttBlocked' => $this->count_attacks_blocked(30), - 'wafData' => $this->_getWAFData(), + 'isNginx' => wfUtils::isNginx() ? 1 : 0, + 'todayAttBlocked' => $this->count_attacks_blocked(1), + 'weekAttBlocked' => $this->count_attacks_blocked(7), + 'monthAttBlocked' => $this->count_attacks_blocked(30), + 'wafData' => $this->_getWAFData(), ); } @@ -817,16 +817,16 @@ class MainWP_Child_Wordfence { $iss = $i->getIssues($offset, $limit); $counts = $i->getIssueCounts(); $return = array( - 'issuesLists' => $iss, - 'issueCounts' => $counts, - 'lastScanCompleted' => wfConfig::get('lastScanCompleted'), - 'apiKey' => wfConfig::get( 'apiKey' ), - 'isPaid' => wfConfig::get('isPaid'), + 'issuesLists' => $iss, + 'issueCounts' => $counts, + 'lastScanCompleted' => wfConfig::get('lastScanCompleted'), + 'apiKey' => wfConfig::get( 'apiKey' ), + 'isPaid' => wfConfig::get('isPaid'), 'lastscan_timestamp' => self::Instance()->get_lastscan(), - 'todayAttBlocked' => self::Instance()->count_attacks_blocked(1), - 'weekAttBlocked' => self::Instance()->count_attacks_blocked(7), - 'monthAttBlocked' => self::Instance()->count_attacks_blocked(30), - 'issueCount' => $i->getIssueCount(), + 'todayAttBlocked' => self::Instance()->count_attacks_blocked(1), + 'weekAttBlocked' => self::Instance()->count_attacks_blocked(7), + 'monthAttBlocked' => self::Instance()->count_attacks_blocked(30), + 'issueCount' => $i->getIssueCount(), ); return $return; } @@ -834,8 +834,8 @@ class MainWP_Child_Wordfence { public function load_wafData() { $return = array( - 'wafData' => $this->_getWAFData(), - 'ip' => wfUtils::getIP(), + 'wafData' => $this->_getWAFData(), + 'ip' => wfUtils::getIP(), 'ajaxWatcherDisabled_front' => (bool) wfConfig::get('ajaxWatcherDisabled_front'), 'ajaxWatcherDisabled_admin' => (bool) wfConfig::get('ajaxWatcherDisabled_admin'), ); @@ -888,14 +888,14 @@ SQL $status = $_POST['status']; $issueID = $_POST['id']; if(! preg_match('/^(?:new|delete|ignoreP|ignoreC)$/', $status)){ - return array('errorMsg' => 'An invalid status was specified when trying to update that issue.'); + return array( 'errorMsg' => 'An invalid status was specified when trying to update that issue.' ); } $wfIssues->updateIssue($issueID, $status); wfScanEngine::refreshScanNotification($wfIssues); $counts = $wfIssues->getIssueCounts(); return array( - 'ok' => 1, + 'ok' => 1, 'issueCounts' => $counts, ); } @@ -1004,7 +1004,11 @@ SQL $bodyMsg = "We didn't $verb2 anything and no errors were found."; } - return array( 'ok' => 1, 'bulkHeading' => $headMsg, 'bulkBody' => $bodyMsg ); + return array( + 'ok' => 1, + 'bulkHeading' => $headMsg, + 'bulkBody' => $bodyMsg, + ); } else { return array( 'errorMsg' => 'Invalid bulk operation selected' ); } @@ -1101,10 +1105,10 @@ SQL for( $i = 0; $i < strlen($string); $i++){ $c = ord(substr($string, $i)); if($action == 'encrypt'){ - $c += ord(substr($key, (($i + 1) % strlen($key)))); + $c += ord(substr($key, ( ( $i + 1 ) % strlen($key) ))); $res .= chr($c & 0xFF); }else{ - $c -= ord(substr($key, (($i + 1) % strlen($key)))); + $c -= ord(substr($key, ( ( $i + 1 ) % strlen($key) ))); $res .= chr(abs($c) & 0xFF); } } @@ -1313,7 +1317,7 @@ SQL } elseif ( !empty( $apiKey ) && $existingAPIKey != $apiKey ) { $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); try { - $res = $api->call('check_api_key', array(), array('previousLicense' => $existingAPIKey)); + $res = $api->call('check_api_key', array(), array( 'previousLicense' => $existingAPIKey )); if ( $res['ok'] && isset( $res['isPaid'] ) ) { // wfConfig::set( 'apiKey', $apiKey ); @@ -1357,7 +1361,10 @@ SQL $api = new wfAPI($apiKey, wfUtils::getWPVersion()); try { $keyType = wfAPI::KEY_TYPE_FREE; - $keyData = $api->call('ping_api_key', array(), array('supportHash' => wfConfig::get('supportHash', ''), 'whitelistHash' => wfConfig::get('whitelistHash', ''))); + $keyData = $api->call('ping_api_key', array(), array( + 'supportHash' => wfConfig::get('supportHash', ''), + 'whitelistHash' => wfConfig::get('whitelistHash', ''), + )); if (isset($keyData['_isPaidKey'])) { $keyType = wfConfig::get('keyType'); } @@ -1577,7 +1584,7 @@ SQL //Basic Options $keys = wfConfig::getExportableOptionsKeys(); foreach ($keys as $key) { - $export[$key] = wfConfig::get($key, ''); + $export[ $key ] = wfConfig::get($key, ''); } //Serialized Options @@ -1589,22 +1596,22 @@ SQL //Make the API call try { $api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion()); - $res = $api->call('export_options', array(), array('export' => json_encode($export))); + $res = $api->call('export_options', array(), array( 'export' => json_encode($export) )); if ($res['ok'] && $res['token']) { return array( - 'ok' => 1, + 'ok' => 1, 'token' => $res['token'], ); } elseif ($res['err']) { - return array('errorExport' => __('An error occurred: ', 'wordfence') . $res['err']); + return array( 'errorExport' => __('An error occurred: ', 'wordfence') . $res['err'] ); } else { throw new Exception(__('Invalid response: ', 'wordfence') . var_export($res, true)); } } catch (Exception $e) { - return array('errorExport' => __('An error occurred: ', 'wordfence') . $e->getMessage()); + return array( 'errorExport' => __('An error occurred: ', 'wordfence') . $e->getMessage() ); } } @@ -1612,20 +1619,20 @@ SQL $token = $_POST['token']; try { $api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion()); - $res = $api->call('import_options', array(), array('token' => $token)); + $res = $api->call('import_options', array(), array( 'token' => $token )); if ($res['ok'] && $res['export']) { $totalSet = 0; $import = @json_decode($res['export'], true); if (!is_array($import)) { - return array('errorImport' => __('An error occurred: Invalid options format received.', 'wordfence')); + return array( 'errorImport' => __('An error occurred: Invalid options format received.', 'wordfence') ); } //Basic Options $keys = wfConfig::getExportableOptionsKeys(); $toSet = array(); foreach ($keys as $key) { - if (isset($import[$key])) { - $toSet[$key] = $import[$key]; + if (isset($import[ $key ])) { + $toSet[ $key ] = $import[ $key ]; } } @@ -1634,8 +1641,8 @@ SQL $skipped = array(); if ($validation !== true) { foreach ($validation as $error) { - $skipped[$error['option']] = $error['error']; - unset($toSet[$error['option']]); + $skipped[ $error['option'] ] = $error['error']; + unset($toSet[ $error['option'] ]); } } @@ -1657,20 +1664,20 @@ SQL } return array( - 'ok' => 1, + 'ok' => 1, 'totalSet' => $totalSet, 'settings' => $this->get_settings(), ); } elseif ($res['err']) { - return array('errorImport' => 'An error occurred: ' . $res['err']); + return array( 'errorImport' => 'An error occurred: ' . $res['err'] ); } else { throw new Exception('Invalid response: ' . var_export($res, true)); } } catch (Exception $e) { - return array('errorImport' => 'An error occurred: ' . $e->getMessage()); + return array( 'errorImport' => 'An error occurred: ' . $e->getMessage() ); } } @@ -1678,7 +1685,7 @@ SQL $keys = wfConfig::getExportableOptionsKeys(); $settings = array(); foreach($keys as $key){ - $settings[$key] = wfConfig::get($key, ''); + $settings[ $key ] = wfConfig::get($key, ''); } $settings['apiKey'] = wfConfig::get('apiKey'); //get more apiKey $settings['isPaid'] = wfConfig::get('isPaid'); @@ -1693,9 +1700,9 @@ SQL $table_wfStatus = wfDB::networkTable('wfStatus'); $jsonData = array( - 'serverTime' => $serverTime, + 'serverTime' => $serverTime, 'serverMicrotime' => microtime(true), - 'msg' => $wfdb->querySingle( "select msg from {$table_wfStatus} where level < 3 order by ctime desc limit 1" ), + 'msg' => $wfdb->querySingle( "select msg from {$table_wfStatus} where level < 3 order by ctime desc limit 1" ), ); $events = array(); @@ -1845,7 +1852,7 @@ SQL $data['rules'] = wfWAF::getInstance()->getRules(); /** @var wfWAFRule $rule */ foreach ($data['rules'] as $ruleID => $rule) { - $data['rules'][$ruleID] = $rule->toArray(); + $data['rules'][ $ruleID ] = $rule->toArray(); } $whitelistedURLParams = wfWAF::getInstance()->getStorageEngine()->getConfig('whitelistedURLParams', array()); @@ -1899,12 +1906,15 @@ SQL $res[ $ip ] = wfUtils::reverseLookup( $ip ); } - return array( 'ok' => 1, 'ips' => $res ); + return array( + 'ok' => 1, + 'ips' => $res, + ); } public function saveOptions() { - if (!empty($_POST['changes']) && ($changes = json_decode(stripslashes($_POST['changes']), true)) !== false) { + if (!empty($_POST['changes']) && ( $changes = json_decode(stripslashes($_POST['changes']), true) ) !== false) { try { if (is_array($changes) && isset($changes['whitelistedURLParams']) && isset($changes['whitelistedURLParams']['add'])) { $user = wp_get_current_user(); @@ -1945,7 +1955,7 @@ SQL } wfConfig::save($changes); - return array('success' => true); + return array( 'success' => true ); } catch (wfWAFStorageFileException $e) { return array( @@ -2002,7 +2012,7 @@ SQL public static function saveCountryBlocking() { if(! wfConfig::get('isPaid')){ - return array('error' => 'Sorry but this feature is only available for paid customers.'); + return array( 'error' => 'Sorry but this feature is only available for paid customers.' ); } $settings = $_POST['settings']; wfConfig::set('cbl_action', $settings['blockAction']); @@ -2014,7 +2024,7 @@ SQL wfConfig::set('cbl_bypassRedirURL', $settings['bypassRedirURL']); wfConfig::set('cbl_bypassRedirDest', $settings['bypassRedirDest']); wfConfig::set('cbl_bypassViewURL', $settings['bypassViewURL']); - return array('ok' => 1); + return array( 'ok' => 1 ); } public function load_static_panel() { @@ -2030,7 +2040,10 @@ SQL $results = $wfLog->getThrottledIPs(); } - return array( 'ok' => 1, 'results' => $results ); + return array( + 'ok' => 1, + 'results' => $results, + ); } public function downgrade_license() { @@ -2089,16 +2102,16 @@ SQL } } if(count($badPlugins) > 0){ - return array('errorMsg' => 'You can not enable caching in Wordfence with other caching plugins enabled. This may cause conflicts. You need to disable other caching plugins first. Wordfence caching is very fast and does not require other caching plugins to be active. The plugins you have that conflict are: ' . implode(', ', $badPlugins) . '. Disable these plugins, then return to this page and enable Wordfence caching.'); + return array( 'errorMsg' => 'You can not enable caching in Wordfence with other caching plugins enabled. This may cause conflicts. You need to disable other caching plugins first. Wordfence caching is very fast and does not require other caching plugins to be active. The plugins you have that conflict are: ' . implode(', ', $badPlugins) . '. Disable these plugins, then return to this page and enable Wordfence caching.' ); } $siteURL = site_url(); if(preg_match('/^https?:\/\/[^\/]+\/[^\/]+\/[^\/]+\/.+/i', $siteURL)){ - return array('errorMsg' => "Wordfence caching currently does not support sites that are installed in a subdirectory and have a home page that is more than 2 directory levels deep. e.g. we don't support sites who's home page is http://example.com/levelOne/levelTwo/levelThree"); + return array( 'errorMsg' => "Wordfence caching currently does not support sites that are installed in a subdirectory and have a home page that is more than 2 directory levels deep. e.g. we don't support sites who's home page is http://example.com/levelOne/levelTwo/levelThree" ); } } if($cacheType == 'falcon'){ if(! get_option('permalink_structure', '')){ - return array('errorMsg' => 'You need to enable Permalinks for your site to use Falcon Engine. You can enable Permalinks in WordPress by going to the Settings - Permalinks menu and enabling it there. Permalinks change your site URL structure from something that looks like /p=123 to pretty URLs like /my-new-post-today/ that are generally more search engine friendly.'); + return array( 'errorMsg' => 'You need to enable Permalinks for your site to use Falcon Engine. You can enable Permalinks in WordPress by going to the Settings - Permalinks menu and enabling it there. Permalinks change your site URL structure from something that looks like /p=123 to pretty URLs like /my-new-post-today/ that are generally more search engine friendly.' ); } } $warnHtaccess = false; @@ -2112,7 +2125,11 @@ SQL if($cacheType == 'php' || $cacheType == 'falcon'){ $err = wfCache::cacheDirectoryTest(); if($err){ - return array('ok' => 1, 'heading' => 'Could not write to cache directory', 'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err"); + return array( + 'ok' => 1, + 'heading' => 'Could not write to cache directory', + 'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err", + ); } } @@ -2126,55 +2143,80 @@ SQL } if($cacheType == 'disable'){ wfConfig::set('cacheType', false); - return array('ok' => 1, 'heading' => 'Caching successfully disabled.', 'body' => "{$htMsg}Caching has been disabled on your system.

    "); + return array( + 'ok' => 1, + 'heading' => 'Caching successfully disabled.', + 'body' => "{$htMsg}Caching has been disabled on your system.

    ", + ); } elseif($cacheType == 'php'){ wfConfig::set('cacheType', 'php'); - return array('ok' => 1, 'heading' => 'Wordfence Basic Caching Enabled', 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

    "); + return array( + 'ok' => 1, + 'heading' => 'Wordfence Basic Caching Enabled', + 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

    ", + ); } elseif($cacheType == 'falcon'){ if($noEditHtaccess != '1'){ $err = wfCache::addHtaccessCode('add'); if($err){ - return array('ok' => 1, 'heading' => 'Wordfence could not edit .htaccess', 'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err); + return array( + 'ok' => 1, + 'heading' => 'Wordfence could not edit .htaccess', + 'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err, + ); } } wfConfig::set('cacheType', 'falcon'); wfCache::scheduleUpdateBlockedIPs(); //Runs every 5 mins until we change cachetype - return array('ok' => 1, 'heading' => 'Wordfence Falcon Engine Activated!', 'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:
    "); + return array( + 'ok' => 1, + 'heading' => 'Wordfence Falcon Engine Activated!', + 'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:
    ", + ); } - return array('errorMsg' => 'An error occurred.'); + return array( 'errorMsg' => 'An error occurred.' ); } public static function checkFalconHtaccess() { if(wfUtils::isNginx()){ - return array('nginx' => 1); + return array( 'nginx' => 1 ); } $file = wfCache::getHtaccessPath(); if(! $file){ - return array('err' => 'We could not find your .htaccess file to modify it.', 'code' => wfCache::getHtaccessCode() ); + return array( + 'err' => 'We could not find your .htaccess file to modify it.', + 'code' => wfCache::getHtaccessCode(), + ); } $fh = @fopen($file, 'r+'); if(! $fh){ $err = error_get_last(); - return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'], 'code' => wfCache::getHtaccessCode() ); + return array( + 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'], + 'code' => wfCache::getHtaccessCode(), + ); } $download_url = admin_url( 'admin-ajax.php' ) . '?action=mainwp_wordfence_download_htaccess&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_htaccess' ); - return array( 'ok' => 1, 'download_url' => $download_url ); + return array( + 'ok' => 1, + 'download_url' => $download_url, + ); } public static function checkHtaccess() { if(wfUtils::isNginx()){ - return array('nginx' => 1); + return array( 'nginx' => 1 ); } $file = wfCache::getHtaccessPath(); if(! $file){ - return array('err' => 'We could not find your .htaccess file to modify it.'); + return array( 'err' => 'We could not find your .htaccess file to modify it.' ); } $fh = @fopen($file, 'r+'); if(! $fh){ $err = error_get_last(); - return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message']); + return array( 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'] ); } - return array('ok' => 1); + return array( 'ok' => 1 ); } public static function downloadHtaccess() { @@ -2209,30 +2251,45 @@ SQL if($changed && wfConfig::get('cacheType', false) == 'falcon'){ $err = wfCache::addHtaccessCode('add'); if($err){ - return array('updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err, 'code' => wfCache::getHtaccessCode() ); + return array( + 'updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err, + 'code' => wfCache::getHtaccessCode(), + ); } } wfCache::scheduleCacheClear(); - return array('ok' => 1); + return array( 'ok' => 1 ); } public static function clearPageCache() { $stats = wfCache::clearPageCache(); if($stats['error']){ $body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error']; - return array('ok' => 1, 'heading' => 'Error occurred while clearing cache', 'body' => $body ); + return array( + 'ok' => 1, + 'heading' => 'Error occurred while clearing cache', + 'body' => $body, + ); } $body = 'A total of ' . $stats['filesDeleted'] . ' files were deleted and ' . $stats['dirsDeleted'] . ' directories were removed. We cleared a total of ' . $stats['totalData'] . 'KB of data in the cache.'; if($stats['totalErrors'] > 0){ $body .= ' A total of ' . $stats['totalErrors'] . ' errors were encountered. This probably means that we could not remove some of the files or directories in the cache. Please use your CPanel or file manager to remove the rest of the files in the directory: ' . WP_CONTENT_DIR . '/wfcache/'; } - return array('ok' => 1, 'heading' => 'Page Cache Cleared', 'body' => $body ); + return array( + 'ok' => 1, + 'heading' => 'Page Cache Cleared', + 'body' => $body, + ); } public static function getCacheStats() { $s = wfCache::getCacheStats(); if($s['files'] == 0){ - return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.'); + return array( + 'ok' => 1, + 'heading' => 'Cache Stats', + 'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.', + ); } $body = 'Total files in cache: ' . $s['files'] . '
    Total directories in cache: ' . $s['dirs'] . @@ -2249,7 +2306,7 @@ SQL if($s['oldestFile'] !== false){ $body .= '
    Oldest file in cache created '; if(time() - $s['oldestFile'] < 300){ - $body .= (time() - $s['oldestFile']) . ' seconds ago'; + $body .= ( time() - $s['oldestFile'] ) . ' seconds ago'; } else { $body .= human_time_diff($s['oldestFile']) . ' ago.'; } @@ -2257,13 +2314,17 @@ SQL if($s['newestFile'] !== false){ $body .= '
    Newest file in cache created '; if(time() - $s['newestFile'] < 300){ - $body .= (time() - $s['newestFile']) . ' seconds ago'; + $body .= ( time() - $s['newestFile'] ) . ' seconds ago'; } else { $body .= human_time_diff($s['newestFile']) . ' ago.'; } } - return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => $body); + return array( + 'ok' => 1, + 'heading' => 'Cache Stats', + 'body' => $body, + ); } public static function addCacheExclusion() { @@ -2278,7 +2339,7 @@ SQL } else { $ex[] = array( 'pt' => $_POST['patternType'], - 'p' => $_POST['pattern'], + 'p' => $_POST['pattern'], 'id' => $_POST['id'], ); } @@ -2286,33 +2347,42 @@ SQL wfCache::scheduleCacheClear(); if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])){ if(wfCache::addHtaccessCode('add')){ //rewrites htaccess rules - return array('errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.', 'ex' => $ex); + return array( + 'errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.', + 'ex' => $ex, + ); } } - return array('ok' => 1, 'ex' => $ex); + return array( + 'ok' => 1, + 'ex' => $ex, + ); } public static function loadCacheExclusions() { $ex = wfConfig::get('cacheExclusions', false); if(! $ex){ - return array('ex' => false); + return array( 'ex' => false ); } $ex = unserialize($ex); - return array('ok' => 1, 'ex' => $ex); + return array( + 'ok' => 1, + 'ex' => $ex, + ); } public static function removeCacheExclusion() { $id = $_POST['id']; $ex = wfConfig::get('cacheExclusions', false); if(! $ex){ - return array('ok' => 1); + return array( 'ok' => 1 ); } $ex = unserialize($ex); $rewriteHtaccess = false; $removed = false; for($i = 0; $i < sizeof($ex); $i++){ - if( (string) $ex[$i]['id'] == (string) $id){ - if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[$i]['pt'])){ + if( (string) $ex[ $i ]['id'] == (string) $id){ + if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt'])){ $rewriteHtaccess = true; } array_splice($ex, $i, 1); @@ -2320,7 +2390,7 @@ SQL $removed = true; } } - $return = array('ex' => $ex); + $return = array( 'ex' => $ex ); if (!$removed) { $return['error'] = 'Not found the cache exclusion.'; return $return; @@ -2385,7 +2455,7 @@ SQL 'code' => array(), 'strong' => array(), 'em' => array(), - 'a' => array('href' => true), + 'a' => array( 'href' => true ), )) ?> @@ -2403,8 +2473,8 @@ SQL
    @@ -2429,7 +2499,7 @@ SQL 'code' => array(), 'strong' => array(), 'em' => array(), - 'a' => array('href' => true), + 'a' => array( 'href' => true ), )) ?>
    @@ -2456,13 +2526,13 @@ SQL 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', ) as $variable => $label) { - if (!($currentServerVarForIP && $currentServerVarForIP === $variable) && $howGet === $variable) { + if (!( $currentServerVarForIP && $currentServerVarForIP === $variable ) && $howGet === $variable) { $howGetHasErrors = true; break; } } ?> -
    +
    @@ -2502,9 +2572,9 @@ SQL if (!array_key_exists($variable, $_SERVER)) { echo '(not set)'; } else { - if (strpos($_SERVER[$variable], ',') !== false) { + if (strpos($_SERVER[ $variable ], ',') !== false) { $trustedProxies = explode("\n", wfConfig::get('howGetIPs_trusted_proxies', '')); - $items = preg_replace('/[\s,]/', '', explode(',', $_SERVER[$variable])); + $items = preg_replace('/[\s,]/', '', explode(',', $_SERVER[ $variable ])); $items = array_reverse($items); $output = ''; $markedSelectedAddress = false; @@ -2528,7 +2598,7 @@ SQL echo substr($output, 0, -2); } else { - echo esc_html($_SERVER[$variable]); + echo esc_html($_SERVER[ $variable ]); } } ?> @@ -2548,7 +2618,7 @@ SQL
    -
    +
    @@ -2565,58 +2635,154 @@ SQL array('description' => '', 'value' => $wp_version), - 'WP_DEBUG' => array('description' => 'WordPress debug mode', 'value' => (defined('WP_DEBUG') && WP_DEBUG ? 'On' : 'Off')), - 'WP_DEBUG_LOG' => array('description' => 'WordPress error logging override', 'value' => defined('WP_DEBUG_LOG') ? (WP_DEBUG_LOG ? 'Enabled' : 'Disabled') : '(not set)'), - 'WP_DEBUG_DISPLAY' => array('description' => 'WordPress error display override', 'value' => defined('WP_DEBUG_DISPLAY') ? (WP_DEBUG_LOG ? 'Enabled' : 'Disabled') : '(not set)'), - 'SCRIPT_DEBUG' => array('description' => 'WordPress script debug mode', 'value' => (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'On' : 'Off')), - 'SAVEQUERIES' => array('description' => 'WordPress query debug mode', 'value' => (defined('SAVEQUERIES') && SAVEQUERIES ? 'On' : 'Off')), + 'WordPress Version' => array( + 'description' => '', + 'value' => $wp_version, + ), + 'WP_DEBUG' => array( + 'description' => 'WordPress debug mode', + 'value' => ( defined('WP_DEBUG') && WP_DEBUG ? 'On' : 'Off' ), + ), + 'WP_DEBUG_LOG' => array( + 'description' => 'WordPress error logging override', + 'value' => defined('WP_DEBUG_LOG') ? ( WP_DEBUG_LOG ? 'Enabled' : 'Disabled' ) : '(not set)', + ), + 'WP_DEBUG_DISPLAY' => array( + 'description' => 'WordPress error display override', + 'value' => defined('WP_DEBUG_DISPLAY') ? ( WP_DEBUG_LOG ? 'Enabled' : 'Disabled' ) : '(not set)', + ), + 'SCRIPT_DEBUG' => array( + 'description' => 'WordPress script debug mode', + 'value' => ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'On' : 'Off' ), + ), + 'SAVEQUERIES' => array( + 'description' => 'WordPress query debug mode', + 'value' => ( defined('SAVEQUERIES') && SAVEQUERIES ? 'On' : 'Off' ), + ), 'DB_CHARSET' => 'Database character set', 'DB_COLLATE' => 'Database collation', 'WP_SITEURL' => 'Explicitly set site URL', 'WP_HOME' => 'Explicitly set blog URL', - 'WP_CONTENT_DIR' => array('description' => '"wp-content" folder is in default location', 'value' => (realpath(WP_CONTENT_DIR) === realpath(ABSPATH . 'wp-content') ? 'Yes' : 'No')), + 'WP_CONTENT_DIR' => array( + 'description' => '"wp-content" folder is in default location', + 'value' => ( realpath(WP_CONTENT_DIR) === realpath(ABSPATH . 'wp-content') ? 'Yes' : 'No' ), + ), 'WP_CONTENT_URL' => 'URL to the "wp-content" folder', - 'WP_PLUGIN_DIR' => array('description' => '"plugins" folder is in default location', 'value' => (realpath(WP_PLUGIN_DIR) === realpath(ABSPATH . 'wp-content/plugins') ? 'Yes' : 'No')), - 'WP_LANG_DIR' => array('description' => '"languages" folder is in default location', 'value' => (realpath(WP_LANG_DIR) === realpath(ABSPATH . 'wp-content/languages') ? 'Yes' : 'No')), + 'WP_PLUGIN_DIR' => array( + 'description' => '"plugins" folder is in default location', + 'value' => ( realpath(WP_PLUGIN_DIR) === realpath(ABSPATH . 'wp-content/plugins') ? 'Yes' : 'No' ), + ), + 'WP_LANG_DIR' => array( + 'description' => '"languages" folder is in default location', + 'value' => ( realpath(WP_LANG_DIR) === realpath(ABSPATH . 'wp-content/languages') ? 'Yes' : 'No' ), + ), 'WPLANG' => 'Language choice', 'UPLOADS' => 'Custom upload folder location', - 'TEMPLATEPATH' => array('description' => 'Theme template folder override', 'value' => (defined('TEMPLATEPATH') && realpath(get_template_directory()) !== realpath(TEMPLATEPATH) ? 'Overridden' : '(not set)')), - 'STYLESHEETPATH' => array('description' => 'Theme stylesheet folder override', 'value' => (defined('STYLESHEETPATH') && realpath(get_stylesheet_directory()) !== realpath(STYLESHEETPATH) ? 'Overridden' : '(not set)')), + 'TEMPLATEPATH' => array( + 'description' => 'Theme template folder override', + 'value' => ( defined('TEMPLATEPATH') && realpath(get_template_directory()) !== realpath(TEMPLATEPATH) ? 'Overridden' : '(not set)' ), + ), + 'STYLESHEETPATH' => array( + 'description' => 'Theme stylesheet folder override', + 'value' => ( defined('STYLESHEETPATH') && realpath(get_stylesheet_directory()) !== realpath(STYLESHEETPATH) ? 'Overridden' : '(not set)' ), + ), 'AUTOSAVE_INTERVAL' => 'Post editing automatic saving interval', - 'WP_POST_REVISIONS' => array('description' => 'Post revisions saved by WordPress', 'value' => is_numeric($postRevisions) ? $postRevisions : ($postRevisions ? 'Unlimited' : 'None')), + 'WP_POST_REVISIONS' => array( + 'description' => 'Post revisions saved by WordPress', + 'value' => is_numeric($postRevisions) ? $postRevisions : ( $postRevisions ? 'Unlimited' : 'None' ), + ), 'COOKIE_DOMAIN' => 'WordPress cookie domain', 'COOKIEPATH' => 'WordPress cookie path', 'SITECOOKIEPATH' => 'WordPress site cookie path', 'ADMIN_COOKIE_PATH' => 'WordPress admin cookie path', 'PLUGINS_COOKIE_PATH' => 'WordPress plugins cookie path', - 'WP_ALLOW_MULTISITE' => array('description' => 'Multisite/network ability enabled', 'value' => (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ? 'Yes' : 'No')), + 'WP_ALLOW_MULTISITE' => array( + 'description' => 'Multisite/network ability enabled', + 'value' => ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ? 'Yes' : 'No' ), + ), 'NOBLOGREDIRECT' => 'URL redirected to if the visitor tries to access a nonexistent blog', - 'CONCATENATE_SCRIPTS' => array('description' => 'Concatenate JavaScript files', 'value' => (defined('CONCATENATE_SCRIPTS') && CONCATENATE_SCRIPTS ? 'Yes' : 'No')), + 'CONCATENATE_SCRIPTS' => array( + 'description' => 'Concatenate JavaScript files', + 'value' => ( defined('CONCATENATE_SCRIPTS') && CONCATENATE_SCRIPTS ? 'Yes' : 'No' ), + ), 'WP_MEMORY_LIMIT' => 'WordPress memory limit', 'WP_MAX_MEMORY_LIMIT' => 'Administrative memory limit', - 'WP_CACHE' => array('description' => 'Built-in caching', 'value' => (defined('WP_CACHE') && WP_CACHE ? 'Enabled' : 'Disabled')), - 'CUSTOM_USER_TABLE' => array('description' => 'Custom "users" table', 'value' => (defined('CUSTOM_USER_TABLE') ? 'Set' : '(not set)')), - 'CUSTOM_USER_META_TABLE' => array('description' => 'Custom "usermeta" table', 'value' => (defined('CUSTOM_USER_META_TABLE') ? 'Set' : '(not set)')), - 'FS_CHMOD_DIR' => array('description' => 'Overridden permissions for a new folder', 'value' => defined('FS_CHMOD_DIR') ? decoct(FS_CHMOD_DIR) : '(not set)'), - 'FS_CHMOD_FILE' => array('description' => 'Overridden permissions for a new file', 'value' => defined('FS_CHMOD_FILE') ? decoct(FS_CHMOD_FILE) : '(not set)'), - 'ALTERNATE_WP_CRON' => array('description' => 'Alternate WP cron', 'value' => (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ? 'Enabled' : 'Disabled')), - 'DISABLE_WP_CRON' => array('description' => 'WP cron status', 'value' => (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled')), + 'WP_CACHE' => array( + 'description' => 'Built-in caching', + 'value' => ( defined('WP_CACHE') && WP_CACHE ? 'Enabled' : 'Disabled' ), + ), + 'CUSTOM_USER_TABLE' => array( + 'description' => 'Custom "users" table', + 'value' => ( defined('CUSTOM_USER_TABLE') ? 'Set' : '(not set)' ), + ), + 'CUSTOM_USER_META_TABLE' => array( + 'description' => 'Custom "usermeta" table', + 'value' => ( defined('CUSTOM_USER_META_TABLE') ? 'Set' : '(not set)' ), + ), + 'FS_CHMOD_DIR' => array( + 'description' => 'Overridden permissions for a new folder', + 'value' => defined('FS_CHMOD_DIR') ? decoct(FS_CHMOD_DIR) : '(not set)', + ), + 'FS_CHMOD_FILE' => array( + 'description' => 'Overridden permissions for a new file', + 'value' => defined('FS_CHMOD_FILE') ? decoct(FS_CHMOD_FILE) : '(not set)', + ), + 'ALTERNATE_WP_CRON' => array( + 'description' => 'Alternate WP cron', + 'value' => ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ? 'Enabled' : 'Disabled' ), + ), + 'DISABLE_WP_CRON' => array( + 'description' => 'WP cron status', + 'value' => ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled' ), + ), 'WP_CRON_LOCK_TIMEOUT' => 'Cron running frequency lock', - 'EMPTY_TRASH_DAYS' => array('description' => 'Interval the trash is automatically emptied at in days', 'value' => (EMPTY_TRASH_DAYS > 0 ? EMPTY_TRASH_DAYS : 'Never')), - 'WP_ALLOW_REPAIR' => array('description' => 'Automatic database repair', 'value' => (defined('WP_ALLOW_REPAIR') && WP_ALLOW_REPAIR ? 'Enabled' : 'Disabled')), - 'DO_NOT_UPGRADE_GLOBAL_TABLES' => array('description' => 'Do not upgrade global tables', 'value' => (defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES ? 'Yes' : 'No')), - 'DISALLOW_FILE_EDIT' => array('description' => 'Disallow plugin/theme editing', 'value' => (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'Yes' : 'No')), - 'DISALLOW_FILE_MODS' => array('description' => 'Disallow plugin/theme update and installation', 'value' => (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'Yes' : 'No')), - 'IMAGE_EDIT_OVERWRITE' => array('description' => 'Overwrite image edits when restoring the original', 'value' => (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ? 'Yes' : 'No')), - 'FORCE_SSL_ADMIN' => array('description' => 'Force SSL for administrative logins', 'value' => (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'Yes' : 'No')), - 'WP_HTTP_BLOCK_EXTERNAL' => array('description' => 'Block external URL requests', 'value' => (defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL ? 'Yes' : 'No')), + 'EMPTY_TRASH_DAYS' => array( + 'description' => 'Interval the trash is automatically emptied at in days', + 'value' => ( EMPTY_TRASH_DAYS > 0 ? EMPTY_TRASH_DAYS : 'Never' ), + ), + 'WP_ALLOW_REPAIR' => array( + 'description' => 'Automatic database repair', + 'value' => ( defined('WP_ALLOW_REPAIR') && WP_ALLOW_REPAIR ? 'Enabled' : 'Disabled' ), + ), + 'DO_NOT_UPGRADE_GLOBAL_TABLES' => array( + 'description' => 'Do not upgrade global tables', + 'value' => ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES ? 'Yes' : 'No' ), + ), + 'DISALLOW_FILE_EDIT' => array( + 'description' => 'Disallow plugin/theme editing', + 'value' => ( defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'Yes' : 'No' ), + ), + 'DISALLOW_FILE_MODS' => array( + 'description' => 'Disallow plugin/theme update and installation', + 'value' => ( defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'Yes' : 'No' ), + ), + 'IMAGE_EDIT_OVERWRITE' => array( + 'description' => 'Overwrite image edits when restoring the original', + 'value' => ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ? 'Yes' : 'No' ), + ), + 'FORCE_SSL_ADMIN' => array( + 'description' => 'Force SSL for administrative logins', + 'value' => ( defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'Yes' : 'No' ), + ), + 'WP_HTTP_BLOCK_EXTERNAL' => array( + 'description' => 'Block external URL requests', + 'value' => ( defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL ? 'Yes' : 'No' ), + ), 'WP_ACCESSIBLE_HOSTS' => 'Whitelisted hosts', - 'WP_AUTO_UPDATE_CORE' => array('description' => 'Automatic WP Core updates', 'value' => defined('WP_AUTO_UPDATE_CORE') ? (is_bool(WP_AUTO_UPDATE_CORE) ? (WP_AUTO_UPDATE_CORE ? 'Everything' : 'None') : WP_AUTO_UPDATE_CORE) : 'Default'), - 'WP_PROXY_HOST' => array('description' => 'Hostname for a proxy server', 'value' => defined('WP_PROXY_HOST') ? WP_PROXY_HOST : '(not set)'), - 'WP_PROXY_PORT' => array('description' => 'Port for a proxy server', 'value' => defined('WP_PROXY_PORT') ? WP_PROXY_PORT : '(not set)'), + 'WP_AUTO_UPDATE_CORE' => array( + 'description' => 'Automatic WP Core updates', + 'value' => defined('WP_AUTO_UPDATE_CORE') ? ( is_bool(WP_AUTO_UPDATE_CORE) ? ( WP_AUTO_UPDATE_CORE ? 'Everything' : 'None' ) : WP_AUTO_UPDATE_CORE ) : 'Default', + ), + 'WP_PROXY_HOST' => array( + 'description' => 'Hostname for a proxy server', + 'value' => defined('WP_PROXY_HOST') ? WP_PROXY_HOST : '(not set)', + ), + 'WP_PROXY_PORT' => array( + 'description' => 'Port for a proxy server', + 'value' => defined('WP_PROXY_PORT') ? WP_PROXY_PORT : '(not set)', + ), ); foreach ($wordPressValues as $settingName => $settingData): @@ -2646,7 +2812,7 @@ SQL
    -
    +
    @@ -2682,7 +2848,7 @@ SQL
    -
    +
    @@ -2721,7 +2887,7 @@ SQL
    -
    +
    @@ -2761,7 +2927,7 @@ SQL
    -
    +
    @@ -2813,7 +2979,7 @@ SQL if ($q): $databaseCols = count($q[0]); ?> -
    +
    @@ -2868,7 +3034,7 @@ SQL
    -
    +
    @@ -2903,7 +3069,7 @@ SQL ?> - Download' : 'Requires downloading from the server directly'); ?> + Download' : 'Requires downloading from the server directly' ); ?> 1, 'html' => $html); + return array( + 'ok' => 1, + 'html' => $html, + ); } public static function updateWAFRules() { @@ -2968,7 +3137,10 @@ SQL $event->fire(); $isPaid = (bool) wfConfig::get('isPaid', 0); //return self::_getWAFData(); - return array('ok' => 1, 'isPaid' => $isPaid ); + return array( + 'ok' => 1, + 'isPaid' => $isPaid, + ); } public static function updateWAFRules_New() { @@ -2982,10 +3154,10 @@ SQL public static function save_debugging_config() { $settings = $_POST['settings']; foreach (self::$diagnosticParams as $param) { - if (isset($settings[$param])) { - wfConfig::set( $param, $settings[$param] ); + if (isset($settings[ $param ])) { + wfConfig::set( $param, $settings[ $param ] ); } } - return array('ok' => 1 ); + return array( 'ok' => 1 ); } } diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index 8b3b7bb..f476800 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -56,81 +56,81 @@ class MainWP_Child_WP_Rocket { function get_rocket_default_options() { return array( - 'cache_mobile' => 1, - 'do_caching_mobile_files' => 0, - 'cache_logged_user' => 0, - 'cache_ssl' => 0, - 'emoji' => 0, - 'embeds' => 1, - 'control_heartbeat' => 0, - 'heartbeat_site_behavior' => 'reduce_periodicity', - 'heartbeat_admin_behavior' => 'reduce_periodicity', - 'heartbeat_editor_behavior' => 'reduce_periodicity', - 'varnish_auto_purge' => 0, - 'manual_preload' => 0, - 'automatic_preload' => 0, - 'sitemap_preload' => 0, - 'sitemap_preload_url_crawl' => 500000, - 'sitemaps' => array(), - 'database_revisions' => 0, - 'database_auto_drafts' => 0, - 'database_trashed_posts' => 0, - 'database_spam_comments' => 0, - 'database_trashed_comments' => 0, - 'database_expired_transients' => 0, - 'database_all_transients' => 0, - 'database_optimize_tables' => 0, - 'schedule_automatic_cleanup' => 0, - 'automatic_cleanup_frequency' => '', - 'cache_reject_uri' => array(), - 'cache_reject_cookies' => array(), - 'cache_reject_ua' => array(), - 'cache_query_strings' => array(), - 'cache_purge_pages' => array(), - 'purge_cron_interval' => 10, - 'purge_cron_unit' => 'HOUR_IN_SECONDS', - 'exclude_css' => array(), - 'exclude_js' => array(), - 'exclude_inline_js' => array(), - 'async_css' => 0, - 'defer_all_js' => 0, - 'defer_all_js_safe' => 1, - 'critical_css' => '', - 'deferred_js_files' => array(), - 'lazyload' => 0, - 'lazyload_iframes' => 0, - 'lazyload_youtube' =>0, - 'minify_css' => 0, + 'cache_mobile' => 1, + 'do_caching_mobile_files' => 0, + 'cache_logged_user' => 0, + 'cache_ssl' => 0, + 'emoji' => 0, + 'embeds' => 1, + 'control_heartbeat' => 0, + 'heartbeat_site_behavior' => 'reduce_periodicity', + 'heartbeat_admin_behavior' => 'reduce_periodicity', + 'heartbeat_editor_behavior' => 'reduce_periodicity', + 'varnish_auto_purge' => 0, + 'manual_preload' => 0, + 'automatic_preload' => 0, + 'sitemap_preload' => 0, + 'sitemap_preload_url_crawl' => 500000, + 'sitemaps' => array(), + 'database_revisions' => 0, + 'database_auto_drafts' => 0, + 'database_trashed_posts' => 0, + 'database_spam_comments' => 0, + 'database_trashed_comments' => 0, + 'database_expired_transients' => 0, + 'database_all_transients' => 0, + 'database_optimize_tables' => 0, + 'schedule_automatic_cleanup' => 0, + 'automatic_cleanup_frequency' => '', + 'cache_reject_uri' => array(), + 'cache_reject_cookies' => array(), + 'cache_reject_ua' => array(), + 'cache_query_strings' => array(), + 'cache_purge_pages' => array(), + 'purge_cron_interval' => 10, + 'purge_cron_unit' => 'HOUR_IN_SECONDS', + 'exclude_css' => array(), + 'exclude_js' => array(), + 'exclude_inline_js' => array(), + 'async_css' => 0, + 'defer_all_js' => 0, + 'defer_all_js_safe' => 1, + 'critical_css' => '', + 'deferred_js_files' => array(), + 'lazyload' => 0, + 'lazyload_iframes' => 0, + 'lazyload_youtube' =>0, + 'minify_css' => 0, // 'minify_css_key' => $minify_css_key, - 'minify_concatenate_css' => 0, + 'minify_concatenate_css' => 0, //'minify_css_combine_all' => 0, - 'minify_css_legacy' => 0, - 'minify_js' => 0, + 'minify_css_legacy' => 0, + 'minify_js' => 0, // 'minify_js_key' => $minify_js_key, - 'minify_js_in_footer' => array(), - 'minify_concatenate_js' => 0, - 'minify_js_combine_all' => 0, + 'minify_js_in_footer' => array(), + 'minify_concatenate_js' => 0, + 'minify_js_combine_all' => 0, //'minify_js_legacy' => 0, - 'minify_google_fonts' => 0, - 'minify_html' => 0, - 'remove_query_strings' => 0, - 'dns_prefetch' => 0, - 'cdn' => 0, - 'cdn_cnames' => array(), - 'cdn_zone' => array(), + 'minify_google_fonts' => 0, + 'minify_html' => 0, + 'remove_query_strings' => 0, + 'dns_prefetch' => 0, + 'cdn' => 0, + 'cdn_cnames' => array(), + 'cdn_zone' => array(), //'cdn_ssl' => 0, - 'cdn_reject_files' => array(), - 'do_cloudflare' => 0, - 'cloudflare_email' => '', - 'cloudflare_api_key' => '', - 'cloudflare_domain' => '', + 'cdn_reject_files' => array(), + 'do_cloudflare' => 0, + 'cloudflare_email' => '', + 'cloudflare_api_key' => '', + 'cloudflare_domain' => '', //'cloudflare_zone_id' => '', - 'cloudflare_devmode' => 0, - 'cloudflare_protocol_rewrite' => 0, - 'cloudflare_auto_settings' => 0, - 'cloudflare_old_settings' => 0, - 'do_beta' => 0, - 'analytics_enabled' => 1, + 'cloudflare_devmode' => 0, + 'cloudflare_protocol_rewrite' => 0, + 'cloudflare_auto_settings' => 0, + 'cloudflare_old_settings' => 0, + 'do_beta' => 0, + 'analytics_enabled' => 1, ); } @@ -138,7 +138,7 @@ class MainWP_Child_WP_Rocket { public function syncOthersData( $information, $data = array() ) { if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) { try{ - $data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true )); + $data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) ); $information['syncWPRocketData'] = $data; } catch(Exception $e) { } @@ -305,9 +305,9 @@ class MainWP_Child_WP_Rocket { if ( function_exists( 'opcache_reset' ) ) { @opcache_reset(); } else { - return array('error' => 'The host do not support the function reset opcache.'); + return array( 'error' => 'The host do not support the function reset opcache.' ); } - return array('result' => 'SUCCESS'); + return array( 'result' => 'SUCCESS' ); } function purge_cloudflare() { @@ -361,7 +361,7 @@ class MainWP_Child_WP_Rocket { MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process'); $preload_process = new WP_Rocket\Preload\Full_Process(); - MainWP_Helper::check_methods($preload_process, array( 'is_process_running')); + MainWP_Helper::check_methods($preload_process, array( 'is_process_running' )); if ( $preload_process->is_process_running() ) { return array( 'result' => 'RUNNING' ); @@ -374,11 +374,12 @@ class MainWP_Child_WP_Rocket { } function generate_critical_css() { - MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber', - 'WP_Rocket\Optimization\CSS\Critical_CSS', - 'WP_Rocket\Optimization\CSS\Critical_CSS_Generation', - 'WP_Rocket\Admin\Options', - 'WP_Rocket\Admin\Options_Data', + MainWP_Helper::check_classes_exists( array( + 'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber', + 'WP_Rocket\Optimization\CSS\Critical_CSS', + 'WP_Rocket\Optimization\CSS\Critical_CSS_Generation', + 'WP_Rocket\Admin\Options', + 'WP_Rocket\Admin\Options_Data', )); $critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() ); @@ -421,10 +422,11 @@ class MainWP_Child_WP_Rocket { function optimize_database() { - MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization', - 'WP_Rocket\Admin\Database\Optimization_Process', - 'WP_Rocket\Admin\Options', - 'WP_Rocket\Admin\Options_Data', + MainWP_Helper::check_classes_exists( array( + 'WP_Rocket\Admin\Database\Optimization', + 'WP_Rocket\Admin\Database\Optimization_Process', + 'WP_Rocket\Admin\Options', + 'WP_Rocket\Admin\Options_Data', )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); @@ -446,8 +448,9 @@ class MainWP_Child_WP_Rocket { function get_optimize_info() { - MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization', - 'WP_Rocket\Admin\Database\Optimization_Process', + MainWP_Helper::check_classes_exists( array( + 'WP_Rocket\Admin\Database\Optimization', + 'WP_Rocket\Admin\Database\Optimization_Process', )); $process = new WP_Rocket\Admin\Database\Optimization_Process(); @@ -455,10 +458,10 @@ class MainWP_Child_WP_Rocket { MainWP_Helper::check_methods($optimization, 'count_cleanup_items'); $information['optimize_info'] = array( - 'total_revisions' => $optimization->count_cleanup_items( 'database_revisions' ), + 'total_revisions' => $optimization->count_cleanup_items( 'database_revisions' ), 'total_auto_draft' => $optimization->count_cleanup_items( 'database_auto_drafts' ), 'total_trashed_posts' => $optimization->count_cleanup_items( 'database_trashed_posts' ), - 'total_spam_comments' => $optimization->count_cleanup_items( 'database_spam_comments' ), + 'total_spam_comments' => $optimization->count_cleanup_items( 'database_spam_comments' ), 'total_trashed_comments' => $optimization->count_cleanup_items( 'database_trashed_comments' ), 'total_expired_transients' => $optimization->count_cleanup_items( 'database_expired_transients' ), 'total_all_transients' => $optimization->count_cleanup_items( 'database_all_transients' ), @@ -471,7 +474,10 @@ class MainWP_Child_WP_Rocket { function load_existing_settings() { $options = get_option( WP_ROCKET_SLUG ); - return array('result' => 'SUCCESS', 'options' => $options); + return array( + 'result' => 'SUCCESS', + 'options' => $options, + ); } } diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index 3e2444f..a51a57b 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -129,7 +129,7 @@ class MainWP_Child_WPvivid_BackupRestore { break; } } catch (Exception $e) { - $information = array('error' => $e->getMessage()); + $information = array( 'error' => $e->getMessage() ); } MainWP_Helper::write($information); diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 8f6d272..ba147d8 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -63,7 +63,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus // To fix verify nonce conflict #1 // this is fake post field to fix some conflict of wp_verify_nonce() // just return false to unverify nonce, does not exit - if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) { + if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) { return false; } @@ -71,7 +71,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus @ob_start(); @debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $stackTrace = "\n" . @ob_get_clean(); - die( '' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '
    Trace: ' . $stackTrace) ) ) . '
    ' ); + die( '' . base64_encode( json_encode( array( 'error' => 'You dont send nonce: ' . $action . '
    Trace: ' . $stackTrace ) ) ) . '
    ' ); } // To fix verify nonce conflict #2 @@ -99,7 +99,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus // To fix verify nonce conflict #3 // this is fake post field to fix some conflict of wp_verify_nonce() // just return false to unverify nonce, does not exit - if ( isset($_POST[$action]) && ($_POST[$action] == 'mainwp-bsm-unverify-nonce')) { + if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) { return false; } @@ -108,7 +108,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus $stackTrace = "\n" . @ob_get_clean(); // Invalid nonce - die( '' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '
    Trace: ' . $stackTrace) ) ) . '
    ' ); + die( '' . base64_encode( json_encode( array( 'error' => 'Invalid nonce! Try to use: ' . $action . '
    Trace: ' . $stackTrace ) ) ) . '
    ' ); } endif; } @@ -177,7 +177,7 @@ class MainWP_Child { 'wp_rocket' => 'wp_rocket', 'settings_tools' => 'settings_tools', 'skeleton_key' => 'skeleton_key', - 'custom_post_type' => 'custom_post_type', + 'custom_post_type' => 'custom_post_type', 'backup_buddy' => 'backup_buddy', 'get_site_icon' => 'get_site_icon', 'vulner_checker' => 'vulner_checker', @@ -185,8 +185,8 @@ class MainWP_Child { 'disconnect' => 'disconnect', 'time_capsule' => 'time_capsule', 'extra_excution' => 'extra_execution', // deprecated - 'extra_execution' => 'extra_execution', - 'wpvivid_backuprestore'=>'wpvivid_backuprestore', + 'extra_execution' => 'extra_execution', + 'wpvivid_backuprestore' =>'wpvivid_backuprestore', ); private $FTP_ERROR = 'Failed! Please, add FTP details for automatic updates.'; @@ -259,7 +259,7 @@ class MainWP_Child { //WP-Cron if ( defined( 'DOING_CRON' ) && DOING_CRON ) { - if ( isset($_GET[ 'mainwp_child_run' ]) && ! empty( $_GET[ 'mainwp_child_run' ] ) ) { + if ( isset($_GET['mainwp_child_run']) && ! empty( $_GET['mainwp_child_run'] ) ) { add_action( 'init', array( $this, 'cron_active' ), PHP_INT_MAX ); } } @@ -333,7 +333,7 @@ class MainWP_Child { if ( is_array( $alloptions_db ) ) { foreach ( (array) $alloptions_db as $o ) { $alloptions[ $o->option_name ] = $o->option_value; - unset($options[array_search($o->option_name, $options)]); + unset($options[ array_search($o->option_name, $options) ]); } foreach ($options as $option ) { $notoptions[ $option ] = true; @@ -479,30 +479,30 @@ class MainWP_Child { if ( ! is_array( get_option( 'mainwp_child_branding_settings' ) ) ) { // to fix: reduce number of options $brandingOptions = array( - 'hide' => 'mainwp_branding_child_hide', - 'extra_settings' => 'mainwp_branding_extra_settings', - 'branding_disconnected' => 'mainwp_child_branding_disconnected', - 'preserve_branding' => 'mainwp_branding_preserve_branding', - 'branding_header' => 'mainwp_branding_plugin_header', - 'support_email' => 'mainwp_branding_support_email', - 'support_message' => 'mainwp_branding_support_message', - 'remove_restore' => 'mainwp_branding_remove_restore', - 'remove_setting' => 'mainwp_branding_remove_setting', - 'remove_server_info' => 'mainwp_branding_remove_server_info', - 'remove_connection_detail' => 'mainwp_branding_remove_connection_detail', - 'remove_wp_tools' => 'mainwp_branding_remove_wp_tools', - 'remove_wp_setting' => 'mainwp_branding_remove_wp_setting', - 'remove_permalink' => 'mainwp_branding_remove_permalink', - 'contact_label' => 'mainwp_branding_button_contact_label', - 'email_message' => 'mainwp_branding_send_email_message', - 'message_return_sender' => 'mainwp_branding_message_return_sender', + 'hide' => 'mainwp_branding_child_hide', + 'extra_settings' => 'mainwp_branding_extra_settings', + 'branding_disconnected' => 'mainwp_child_branding_disconnected', + 'preserve_branding' => 'mainwp_branding_preserve_branding', + 'branding_header' => 'mainwp_branding_plugin_header', + 'support_email' => 'mainwp_branding_support_email', + 'support_message' => 'mainwp_branding_support_message', + 'remove_restore' => 'mainwp_branding_remove_restore', + 'remove_setting' => 'mainwp_branding_remove_setting', + 'remove_server_info' => 'mainwp_branding_remove_server_info', + 'remove_connection_detail' => 'mainwp_branding_remove_connection_detail', + 'remove_wp_tools' => 'mainwp_branding_remove_wp_tools', + 'remove_wp_setting' => 'mainwp_branding_remove_wp_setting', + 'remove_permalink' => 'mainwp_branding_remove_permalink', + 'contact_label' => 'mainwp_branding_button_contact_label', + 'email_message' => 'mainwp_branding_send_email_message', + 'message_return_sender' => 'mainwp_branding_message_return_sender', 'submit_button_title' => 'mainwp_branding_submit_button_title', 'disable_wp_branding' => 'mainwp_branding_disable_wp_branding', - 'show_support' => 'mainwp_branding_show_support', - 'disable_change' => 'mainwp_branding_disable_change', - 'disable_switching_theme' => 'mainwp_branding_disable_switching_theme', + 'show_support' => 'mainwp_branding_show_support', + 'disable_change' => 'mainwp_branding_disable_change', + 'disable_switching_theme' => 'mainwp_branding_disable_switching_theme', //'hide_child_reports' => 'mainwp_creport_branding_stream_hide', - 'branding_ext_enabled' => 'mainwp_branding_ext_enabled', + 'branding_ext_enabled' => 'mainwp_branding_ext_enabled', ); $convertBranding = array(); @@ -522,7 +522,7 @@ class MainWP_Child { if ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) { return; } - if ( empty( $_GET[ 'mainwp_child_run' ] ) || 'test' !== $_GET[ 'mainwp_child_run' ] ) { + if ( empty( $_GET['mainwp_child_run'] ) || 'test' !== $_GET['mainwp_child_run'] ) { return; } @session_write_close(); @@ -530,7 +530,7 @@ class MainWP_Child { @header( 'X-Robots-Tag: noindex, nofollow', true ); @header( 'X-MainWP-Child-Version: ' . self::$version, true ); nocache_headers(); - if ( $_GET[ 'mainwp_child_run' ] == 'test' ) { + if ( $_GET['mainwp_child_run'] == 'test' ) { die( 'MainWP Test' ); } die( '' ); @@ -720,8 +720,8 @@ class MainWP_Child { add_action( 'admin_print_scripts-' . $settingsPage, array( 'MainWP_Clone', 'print_scripts' ) ); $subpageargs = array( - 'child_slug' => 'options-general.php', // to backwards compatible - 'branding' => (self::$brandingTitle === null) ? 'MainWP' : self::$brandingTitle, + 'child_slug' => 'options-general.php', // to backwards compatible + 'branding' => ( self::$brandingTitle === null ) ? 'MainWP' : self::$brandingTitle, 'parent_menu' => $settingsPage, ); do_action( 'mainwp-child-subpages', $subpageargs ); // to compatible @@ -801,7 +801,7 @@ class MainWP_Child { self::render_header($shownPage, false); ?> -
    > +
    > settings(); ?>
    @@ -828,13 +828,13 @@ class MainWP_Child { -
    > +
    >
    -
    > +
    >
    @@ -1746,7 +1746,10 @@ class MainWP_Child { remove_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99 ); } - $args = array( 'success' => 1, 'action' => 'install' ); + $args = array( + 'success' => 1, + 'action' => 'install', + ); if ( 'plugin' === $_POST['type'] ) { $path = $result['destination']; $fileName = ''; @@ -1935,10 +1938,10 @@ class MainWP_Child { $result = count( $language_updates ) == 0 ? false : $upgrader->bulk_upgrade( $language_updates ); if ( ! empty( $result ) ) { for ( $i = 0; $i < count( $result ); $i++ ) { - if ( empty( $result[$i] ) || is_wp_error( $result[$i] ) ) { - $information['upgrades'][ $language_updates[$i]->slug ] = false; + if ( empty( $result[ $i ] ) || is_wp_error( $result[ $i ] ) ) { + $information['upgrades'][ $language_updates[ $i ]->slug ] = false; } else { - $information['upgrades'][ $language_updates[$i]->slug ] = true; + $information['upgrades'][ $language_updates[ $i ]->slug ] = true; } } } else { @@ -2061,7 +2064,7 @@ class MainWP_Child { if ( !is_wp_error( $api ) && !empty($api)) { if ( isset($api->download_link) ) { $res = $upgrader->install($api->download_link); - if ( !is_wp_error( $res ) && !(is_null( $res )) ) { + if ( !is_wp_error( $res ) && !( is_null( $res ) ) ) { $information['upgrades'][ $plugin ] = true; } } @@ -2508,13 +2511,17 @@ class MainWP_Child { } else { if ( 'future' == $post_current->post_status ) { wp_publish_post( $postId ); // to fix: fail when publish future page - wp_update_post(array('ID' => $postId, - 'post_date' => current_time( 'mysql', false ), - 'post_date_gmt' => current_time( 'mysql', true ), + wp_update_post(array( + 'ID' => $postId, + 'post_date' => current_time( 'mysql', false ), + 'post_date_gmt' => current_time( 'mysql', true ), )); } else { // to fix error post slug - wp_update_post(array('ID' => $postId, 'post_status' => 'publish' )); + wp_update_post(array( + 'ID' => $postId, + 'post_status' => 'publish', + )); } } } elseif ( 'update' === $action ) { @@ -2601,12 +2608,12 @@ class MainWP_Child { $attachment = get_post( $attachment_id ); if ( $attachment ) { $post_gallery_images[] = array( - 'id' => $attachment_id, - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), - 'caption' => $attachment->post_excerpt, + 'id' => $attachment_id, + 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), + 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, - 'src' => $attachment->guid, - 'title' => $attachment->post_title, + 'src' => $attachment->guid, + 'title' => $attachment->post_title, ); } } @@ -2644,7 +2651,7 @@ class MainWP_Child { 'post_category' => base64_encode( $post_category ), 'post_featured_image' => base64_encode( $post_featured_image ), 'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ), - 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), + 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), ); return $post_data; @@ -2663,16 +2670,16 @@ class MainWP_Child { $new_post = array( 'edit_id' => $id, - 'post_title' => $post->post_title, - 'post_content' => $post->post_content, - 'post_status' => $post->post_status, - 'post_date' => $post->post_date, - 'post_date_gmt' => $post->post_date_gmt, - 'post_type' => 'page', - 'post_name' => $post->post_name, - 'post_excerpt' => $post->post_excerpt, + 'post_title' => $post->post_title, + 'post_content' => $post->post_content, + 'post_status' => $post->post_status, + 'post_date' => $post->post_date, + 'post_date_gmt' => $post->post_date_gmt, + 'post_type' => 'page', + 'post_name' => $post->post_name, + 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, - 'ping_status' => $post->ping_status, + 'ping_status' => $post->ping_status, ); if ( $post_featured_image != null ) { //Featured image is set, retrieve URL @@ -2689,12 +2696,12 @@ class MainWP_Child { $attachment = get_post( $attachment_id ); if ( $attachment ) { $post_gallery_images[] = array( - 'id' => $attachment_id, - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), - 'caption' => $attachment->post_excerpt, + 'id' => $attachment_id, + 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), + 'caption' => $attachment->post_excerpt, 'description' => $attachment->post_content, - 'src' => $attachment->guid, - 'title' => $attachment->post_title, + 'src' => $attachment->guid, + 'title' => $attachment->post_title, ); } } @@ -2704,11 +2711,11 @@ class MainWP_Child { wp_set_post_lock($id); $post_data = array( - 'new_post' => base64_encode( serialize( $new_post ) ), - 'post_custom' => base64_encode( serialize( $post_custom ) ), + 'new_post' => base64_encode( serialize( $new_post ) ), + 'post_custom' => base64_encode( serialize( $post_custom ) ), 'post_featured_image' => base64_encode( $post_featured_image ), 'post_gallery_images' => base64_encode( serialize( $post_gallery_images ) ), - 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), + 'child_upload_dir' => base64_encode( serialize( $child_upload_dir ) ), ); return $post_data; } @@ -2751,8 +2758,8 @@ class MainWP_Child { $my_user = $_POST['extra']; if (is_array($my_user)) { foreach($my_user as $idx => $val) { - if ($val === 'donotupdate' || (empty($val) && $idx !== 'role')) { - unset($my_user[$idx]); + if ($val === 'donotupdate' || ( empty($val) && $idx !== 'role' )) { + unset($my_user[ $idx ]); } } $result = $this->edit_user( $userId, $my_user ); @@ -2791,7 +2798,7 @@ class MainWP_Child { $userdata = get_userdata( $user_id ); $user->user_login = wp_slash( $userdata->user_login ); } else { - return array('error' => 'ERROR: Empty user id.'); + return array( 'error' => 'ERROR: Empty user id.' ); } $pass1 = $pass2 = ''; @@ -2804,17 +2811,17 @@ class MainWP_Child { if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) { $new_role = sanitize_text_field( $data['role'] ); - $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; + $potential_role = isset($wp_roles->role_objects[ $new_role ]) ? $wp_roles->role_objects[ $new_role ] : false; // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. // Multisite super admins can freely edit their blog roles -- they possess all caps. - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { + if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ( $potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { $user->role = $new_role; } // If the new role isn't editable by the logged-in user die with error $editable_roles = get_editable_roles(); - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) { - return array('error' => 'You can’t give users that role.'); + if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) { + return array( 'error' => 'You can’t give users that role.' ); } } @@ -2963,7 +2970,7 @@ class MainWP_Child { $edit_data['user_email'] = $profileuser->user_email; $edit_data['user_url'] = $profileuser->user_url; foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { - $edit_data['contact_methods'][$name] = $profileuser->$name; + $edit_data['contact_methods'][ $name ] = $profileuser->$name; } $edit_data['description'] = $profileuser->description; } @@ -3039,7 +3046,10 @@ class MainWP_Child { $user = get_user_by( 'login', $_POST['user'] ); require_once ABSPATH . WPINC . '/registration.php'; - $id = wp_update_user( array( 'ID' => $user->ID, 'user_pass' => $new_password['user_pass'] ) ); + $id = wp_update_user( array( + 'ID' => $user->ID, + 'user_pass' => $new_password['user_pass'], + ) ); if ( $id !== $user->ID ) { if ( is_wp_error( $id ) ) { MainWP_Helper::error( $id->get_error_message() ); @@ -3660,14 +3670,14 @@ class MainWP_Child { $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0; $theme_name = wp_get_theme()->get( 'Name' ); $information['site_info'] = array( - 'wpversion' => $wp_version, - 'debug_mode' => (defined('WP_DEBUG') && true === WP_DEBUG) ? true : false, - 'phpversion' => phpversion(), - 'child_version' => self::$version, - 'memory_limit' => MainWP_Child_Server_Information::getPHPMemoryLimit(), - 'mysql_version' => MainWP_Child_Server_Information::getMySQLVersion(), + 'wpversion' => $wp_version, + 'debug_mode' => ( defined('WP_DEBUG') && true === WP_DEBUG ) ? true : false, + 'phpversion' => phpversion(), + 'child_version' => self::$version, + 'memory_limit' => MainWP_Child_Server_Information::getPHPMemoryLimit(), + 'mysql_version' => MainWP_Child_Server_Information::getMySQLVersion(), 'themeactivated' => $theme_name, - 'ip' => $_SERVER['SERVER_ADDR'], + 'ip' => $_SERVER['SERVER_ADDR'], ); //Try to switch to SSL if SSL is enabled in between! @@ -3876,10 +3886,12 @@ class MainWP_Child { $information['translation_updates'] = array(); foreach ($translation_updates as $translation_update) { - $new_translation_update = array('type' => $translation_update->type, - 'slug' => $translation_update->slug, - 'language' => $translation_update->language, - 'version' => $translation_update->version, ); + $new_translation_update = array( + 'type' => $translation_update->type, + 'slug' => $translation_update->slug, + 'language' => $translation_update->language, + 'version' => $translation_update->version, + ); if ( 'plugin' === $translation_update->type ) { $all_plugins = get_plugins(); foreach ( $all_plugins as $file => $plugin ) { @@ -3965,7 +3977,11 @@ class MainWP_Child { //Directory listings! $information['directories'] = $this->scanDir( ABSPATH, 3 ); - $cats = get_categories( array( 'hide_empty' => 0, 'hierarchical' => true, 'number' => 300 ) ); + $cats = get_categories( array( + 'hide_empty' => 0, + 'hierarchical' => true, + 'number' => 300, + ) ); $categories = array(); foreach ( $cats as $cat ) { $categories[] = $cat->name; @@ -4324,9 +4340,9 @@ class MainWP_Child { if ($wp_seo_enabled) { $post_id = $post->ID; $outPost['seo_data'] = array( - 'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ), - 'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ), - 'seo_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score($post_id), + 'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ), + 'count_seo_linked' => $link_count->get( $post_id, 'incoming_link_count' ), + 'seo_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score($post_id), 'readability_score' => MainWP_Wordpress_SEO::Instance()->parse_column_score_readability($post_id), ); } @@ -4345,7 +4361,7 @@ class MainWP_Child { } function get_all_posts() { - $post_type = (isset($_POST['post_type']) ? $_POST['post_type'] : 'post'); + $post_type = ( isset($_POST['post_type']) ? $_POST['post_type'] : 'post' ); $this->get_all_posts_by_type( $post_type ); } @@ -4709,7 +4725,10 @@ class MainWP_Child { if ( null !== $theTheme && '' !== $theTheme ) { $tmp['theme'] = $theTheme['Template']; if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) { - $args = array( 'action' => 'delete', 'Name' => $theTheme['Name'] ); + $args = array( + 'action' => 'delete', + 'Name' => $theTheme['Name'], + ); do_action( 'mainwp_child_theme_action', $args ); } } @@ -4830,7 +4849,10 @@ class MainWP_Child { } $tmp['plugin'] = $plugin; if ( true === $pluginUpgrader->delete_old_plugin( null, null, null, $tmp ) ) { - $args = array( 'action' => 'delete', 'Name' => $all_plugins[ $plugin ]['Name'] ); + $args = array( + 'action' => 'delete', + 'Name' => $all_plugins[ $plugin ]['Name'], + ); do_action( 'mainwp_child_plugin_action', $args ); } } @@ -4867,7 +4889,7 @@ class MainWP_Child { foreach ( $plugins as $pluginslug => $plugin ) { $out = array(); - $out['mainwp'] = ($pluginslug == $this->plugin_slug ? 'T' : 'F'); + $out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' ); $out['name'] = $plugin['Name']; $out['slug'] = $pluginslug; $out['description'] = $plugin['Description']; @@ -4889,7 +4911,7 @@ class MainWP_Child { if ( is_array( $muplugins ) ) { foreach ( $muplugins as $pluginslug => $plugin ) { $out = array(); - $out['mainwp'] = ($pluginslug == $this->plugin_slug ? 'T' : 'F'); + $out['mainwp'] = ( $pluginslug == $this->plugin_slug ? 'T' : 'F' ); $out['name'] = $plugin['Name']; $out['slug'] = $pluginslug; $out['description'] = $plugin['Description']; diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index 24c7cc2..6b16bad 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -675,7 +675,7 @@ class MainWP_Clone_Install { unset( $_tmp ); } elseif (is_serialized_string($data) && is_serialized($data)) { // TODO: apply solution like phpmyadmin project have! - if ( ($data = @unserialize( $data )) !== false ) { + if ( ( $data = @unserialize( $data ) ) !== false ) { $data = str_replace( $from, $to, $data ); $data = serialize( $data ); } diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 3f7c36f..a1c284a 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -1210,11 +1210,11 @@ class MainWP_Clone { global $wp_version; $method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' ); $result = MainWP_Helper::fetchUrl( $url, array( - 'cloneFunc' => 'createCloneBackup', - 'key' => $key, - 'f' => $rand, - 'wpversion' => $wp_version, - 'zipmethod' => $method, + 'cloneFunc' => 'createCloneBackup', + 'key' => $key, + 'f' => $rand, + 'wpversion' => $wp_version, + 'zipmethod' => $method, 'json_result' => true, ) ); @@ -1226,7 +1226,10 @@ class MainWP_Clone { MainWP_Helper::update_option( 'mainwp_temp_clone_plugins', $result['plugins'] ); MainWP_Helper::update_option( 'mainwp_temp_clone_themes', $result['themes'] ); - $output = array( 'url' => $result['backup'], 'size' => round( $result['size'] / 1024, 0 ) ); + $output = array( + 'url' => $result['backup'], + 'size' => round( $result['size'] / 1024, 0 ), + ); } catch ( Exception $e ) { $output = array( 'error' => $e->getMessage() ); } @@ -1257,9 +1260,9 @@ class MainWP_Clone { MainWP_Helper::endSession(); //Send request to the childsite! $result = MainWP_Helper::fetchUrl( $url, array( - 'cloneFunc' => 'createCloneBackupPoll', - 'key' => $key, - 'f' => $rand, + 'cloneFunc' => 'createCloneBackupPoll', + 'key' => $key, + 'f' => $rand, 'json_result' => true, ) ); @@ -1320,7 +1323,11 @@ class MainWP_Clone { $filename = $backupdir . $filename; - $response = wp_remote_get( $url, array( 'timeout' => 300000, 'stream' => true, 'filename' => $filename ) ); + $response = wp_remote_get( $url, array( + 'timeout' => 300000, + 'stream' => true, + 'filename' => $filename, + ) ); if ( is_wp_error( $response ) ) { unlink( $filename ); @@ -1345,9 +1352,9 @@ class MainWP_Clone { $siteToClone = $sitesToClone[ $siteId ]; MainWP_Helper::fetchUrl( $siteToClone['url'], array( - 'cloneFunc' => 'deleteCloneBackup', - 'key' => $siteToClone['extauth'], - 'f' => $_POST['file'], + 'cloneFunc' => 'deleteCloneBackup', + 'key' => $siteToClone['extauth'], + 'f' => $_POST['file'], 'json_result' => true, ) ); } diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php index 449d338..bd2bea6 100755 --- a/class/class-mainwp-custom-post-type.php +++ b/class/class-mainwp-custom-post-type.php @@ -67,7 +67,7 @@ class MainWP_Custom_Post_Type { if ( empty( $data ) || ! is_array( $data ) || ! isset( $data['post'] ) ) { return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) ); } - $edit_id = (isset($_POST['post_id']) && !empty($_POST['post_id'])) ? $_POST['post_id'] : 0; + $edit_id = ( isset($_POST['post_id']) && !empty($_POST['post_id']) ) ? $_POST['post_id'] : 0; $return = $this->_insert_post($data, $edit_id, $parent_id = 0); if (isset($return['success']) && $return['success'] == 1) { if (isset($data['product_variation']) && is_array($data['product_variation'])) { @@ -177,7 +177,7 @@ class MainWP_Custom_Post_Type { //$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] ); $is_woocomerce = false; - if ( ($data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' )&& function_exists( 'wc_product_has_unique_sku' ) ) { + if ( ( $data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' )&& function_exists( 'wc_product_has_unique_sku' ) ) { $is_woocomerce = true; } @@ -337,6 +337,9 @@ class MainWP_Custom_Post_Type { } } - return array( 'success' => 1, 'post_id' => $post_id ); + return array( + 'success' => 1, + 'post_id' => $post_id, + ); } } diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 9fd4387..aa7537b 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -15,7 +15,7 @@ class MainWP_Helper { public static function utf8ize( $mixed) { if (is_array($mixed)) { foreach ($mixed as $key => $value) { - $mixed[$key] = self::utf8ize($value); + $mixed[ $key ] = self::utf8ize($value); } } elseif (is_string($mixed)) { if ( function_exists( 'mb_convert_encoding' )) { @@ -83,24 +83,24 @@ class MainWP_Helper { $ordered = array(); for($i=0;$i $attach->ID, 'url' => $local_img_url ); + return array( + 'id' => $attach->ID, + 'url' => $local_img_url, + ); } } } @@ -202,12 +205,15 @@ class MainWP_Helper { $basedir = $upload_dir['basedir']; $baseurl = $upload_dir['baseurl']; $local_img_path = str_replace( $baseurl, $basedir, $attach->guid ); - if ( file_exists($local_img_path) && (filesize( $local_img_path ) == filesize( $temporary_file )) ) { // file exited + if ( file_exists($local_img_path) && ( filesize( $local_img_path ) == filesize( $temporary_file ) ) ) { // file exited if ( file_exists( $temporary_file ) ) { unlink( $temporary_file ); } - return array( 'id' => $attach->ID, 'url' => $attach->guid ); + return array( + 'id' => $attach->ID, + 'url' => $attach->guid, + ); } } } @@ -227,9 +233,9 @@ class MainWP_Helper { 'post_mime_type' => $wp_filetype['type'], 'post_title' => isset( $img_data['title'] ) && !empty( $img_data['title'] ) ? $img_data['title'] : preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ), 'post_content' => isset( $img_data['description'] ) && !empty( $img_data['description'] ) ? $img_data['description'] : '', - 'post_excerpt' => isset( $img_data['caption'] ) && !empty( $img_data['caption'] ) ? $img_data['caption'] : '', + 'post_excerpt' => isset( $img_data['caption'] ) && !empty( $img_data['caption'] ) ? $img_data['caption'] : '', 'post_status' => 'inherit', - 'guid' => $local_img_url, // to fix + 'guid' => $local_img_url, // to fix ); // for post attachments, thumbnail @@ -244,7 +250,10 @@ class MainWP_Helper { if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) { update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] ); } - return array( 'id' => $attach_id, 'url' => $local_img_url ); + return array( + 'id' => $attach_id, + 'url' => $local_img_url, + ); } } if ( file_exists( $temporary_file ) ) { @@ -425,7 +434,7 @@ class MainWP_Helper { if ( $user_id = wp_check_post_lock( $edit_post_id ) ) { $user = get_userdata( $user_id ); $error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name ); - return array( 'error' => $error); + return array( 'error' => $error ); } } @@ -496,7 +505,7 @@ class MainWP_Helper { try { $upload = self::uploadImage( $gallery['src'], $gallery ); //Upload image to WP if ( null !== $upload ) { - $replaceAttachedIds[$gallery['id']] = $upload['id']; + $replaceAttachedIds[ $gallery['id'] ] = $upload['id']; } } catch ( Exception $e ) { @@ -511,8 +520,8 @@ class MainWP_Helper { $idsToReplaceWith = ''; $originalIds = explode(',', $idsToReplace); foreach($originalIds as $attached_id) { - if (!empty($originalIds) && isset($replaceAttachedIds[$attached_id])) { - $idsToReplaceWith .= $replaceAttachedIds[$attached_id] . ','; + if (!empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) { + $idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ','; } } $idsToReplaceWith = rtrim($idsToReplaceWith, ','); @@ -587,11 +596,14 @@ class MainWP_Helper { return $wp_error->get_error_message(); } if ( empty( $new_post_id ) ) { - return array( 'error' => 'Empty post id'); + return array( 'error' => 'Empty post id' ); } if ( !$edit_post_id ) { - wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) ); + wp_update_post( array( + 'ID' => $new_post_id, + 'post_status' => $post_status, + ) ); } if ( ! empty( $terms ) ) { @@ -732,10 +744,11 @@ class MainWP_Helper { if (isset($others['featured_image_data'])) { $_image_data = $others['featured_image_data']; update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] ); - wp_update_post( array( 'ID' => $upload['id'], - 'post_excerpt' => $_image_data['caption'], - 'post_content' => $_image_data['description'], - 'post_title' => $_image_data['title'], + wp_update_post( array( + 'ID' => $upload['id'], + 'post_excerpt' => $_image_data['caption'], + 'post_content' => $_image_data['description'], + 'post_title' => $_image_data['title'], ) ); } @@ -767,14 +780,20 @@ class MainWP_Helper { if ( count( $random_post_authors ) > 0 ) { shuffle( $random_post_authors ); $key = array_rand( $random_post_authors ); - wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $random_post_authors[ $key ] ) ); + wp_update_post( array( + 'ID' => $new_post_id, + 'post_author' => $random_post_authors[ $key ], + ) ); } } $random_category = isset( $post_custom['_saved_draft_random_category'] ) ? $post_custom['_saved_draft_random_category'] : false; $random_category = is_array( $random_category ) ? current( $random_category ) : null; if ( ! empty( $random_category ) ) { - $cats = get_categories( array( 'type' => 'post', 'hide_empty' => 0 ) ); + $cats = get_categories( array( + 'type' => 'post', + 'hide_empty' => 0, + ) ); $random_cats = array(); if ( is_array( $cats ) ) { foreach ( $cats as $cat ) { @@ -793,7 +812,10 @@ class MainWP_Helper { // to support custom post author $custom_post_author = apply_filters('mainwp_create_post_custom_author', false, $new_post_id); if ( !empty( $custom_post_author ) ) { - wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $custom_post_author ) ); + wp_update_post( array( + 'ID' => $new_post_id, + 'post_author' => $custom_post_author, + ) ); } // MainWP Robot @@ -1242,7 +1264,7 @@ class MainWP_Helper { } static function update_lasttime_backup( $by, $time ) { - $backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule'); + $backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' ); if (!in_array($by, $backup_by)) { return false; @@ -1707,7 +1729,7 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name = } if (isset($_POST['function']) && isset($_POST['mainwpsignature']) && - (isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function']) // wordpress_seo for WordPress SEO + ( isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function'] ) // wordpress_seo for WordPress SEO ) { register_shutdown_function( 'handle_shutdown' ); } diff --git a/class/class-mainwp-keyword-links.php b/class/class-mainwp-keyword-links.php index 99b77a9..dc298fb 100644 --- a/class/class-mainwp-keyword-links.php +++ b/class/class-mainwp-keyword-links.php @@ -344,7 +344,7 @@ class MainWP_Keyword_Links { $this->link_case_sensitive = $link->case_sensitive; $keywords = $this->explode_multi( $link->keyword ); //usort( $keywords, create_function( '$a,$b', 'return strlen($a)case_sensitive ? 's' : 'is'; //print_r($keywords); foreach ( $keywords as $keyword ) { diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index c194475..1e4c969 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -181,15 +181,15 @@ class MainWP_Security { private static function init_permission_checks() { if ( null === self::$permission_checks ) { self::$permission_checks = array( - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../' => '0755', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../' => '0755', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-includes' => '0755', - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644', - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php' => '0644', - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'js/' => '0755', - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'themes' => '0755', - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' => '0755', - WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-admin' => '0755', - WP_CONTENT_DIR => '0755', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php' => '0644', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'js/' => '0755', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'themes' => '0755', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' => '0755', + WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-admin' => '0755', + WP_CONTENT_DIR => '0755', ); } } @@ -365,7 +365,7 @@ class MainWP_Security { public static function update_security_option( $key, $value ) { $security = get_option( 'mainwp_security' ); if ( !empty($key) ) { - $security[$key] = $value; + $security[ $key ] = $value; } MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' ); } From 055f7232cd33b2986c2877a37835963a1b43a687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 16:46:30 +0100 Subject: [PATCH 73/98] Update phpcs.xml --- phpcs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 2fd0fb9..bc86b17 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -37,8 +37,8 @@ - - + + From ea0f76014350642f52d2bb7b2bfcc43a80f74378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 17:04:08 +0100 Subject: [PATCH 74/98] Update phpcs.xml --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index bc86b17..a2e1b64 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -37,7 +37,7 @@ - + From e34765b099d91a854e142f52d52c48c0469c577c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 17:29:23 +0100 Subject: [PATCH 75/98] Update phpcs.xml --- phpcs.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index a2e1b64..2c0d621 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -32,13 +32,13 @@ - + - + From 7318bb4ffe1d64bb84049be867513e2d44184f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 17:44:28 +0100 Subject: [PATCH 76/98] Update phpcs.xml --- phpcs.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 2c0d621..21a8504 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -33,12 +33,12 @@ - - - - - - + + + + + From 44cdebaf44abed090a88faad36e22220492f82f7 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 17:03:00 +0000 Subject: [PATCH 77/98] [CodeFactor] Apply fixes --- class/class-mainwp-backup.php | 4 +- class/class-mainwp-child-back-up-buddy.php | 300 ++++++++++-------- .../class-mainwp-child-back-up-wordpress.php | 36 ++- class/class-mainwp-child-back-wp-up.php | 31 +- class/class-mainwp-child-branding.php | 70 ++-- class/class-mainwp-child-ithemes-security.php | 42 +-- class/class-mainwp-child-links-checker.php | 16 +- class/class-mainwp-child-pagespeed.php | 62 ++-- class/class-mainwp-child-plugins-check.php | 13 +- .../class-mainwp-child-server-information.php | 10 +- class/class-mainwp-child-skeleton-key.php | 12 +- class/class-mainwp-child-staging.php | 33 +- class/class-mainwp-child-themes-check.php | 3 +- class/class-mainwp-child-timecapsule.php | 114 +++---- ...lass-mainwp-child-updraft-plus-backups.php | 183 ++++++----- ...ass-mainwp-child-vulnerability-checker.php | 28 +- .../class-mainwp-child-woocommerce-status.php | 2 +- class/class-mainwp-child-wordfence.php | 276 ++++++++-------- class/class-mainwp-child-wp-rocket.php | 16 +- ...ass-mainwp-child-wpvivid-backuprestore.php | 31 +- class/class-mainwp-child.php | 254 ++++++++------- class/class-mainwp-clone-install.php | 4 +- class/class-mainwp-clone.php | 3 +- class/class-mainwp-custom-post-type.php | 8 +- class/class-mainwp-helper.php | 152 ++++----- class/class-mainwp-keyword-links.php | 4 +- class/class-mainwp-security.php | 7 +- class/class-mainwp-wordpress-seo.php | 6 +- 28 files changed, 891 insertions(+), 829 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 504cab5..06f8851 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -118,7 +118,7 @@ class MainWP_Backup { @ini_set( 'max_execution_time', $this->timeout ); // @codingStandardsIgnoreEnd - if ( !is_array( $files ) ) { + if ( ! is_array( $files ) ) { $files = array( $files ); } @@ -168,7 +168,7 @@ class MainWP_Backup { } } - return !$error; + return ! $error; } /** diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index bebcc11..4824508 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -34,7 +34,7 @@ class MainWP_Child_Back_Up_Buddy { $this->is_backupbuddy_installed = true; } - if (!$this->is_backupbuddy_installed) { + if ( ! $this->is_backupbuddy_installed) { return; } @@ -61,7 +61,7 @@ class MainWP_Child_Back_Up_Buddy { return $value; } - if (! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update()) { return $value; } @@ -109,7 +109,7 @@ class MainWP_Child_Back_Up_Buddy { return; } - if (!$this->is_backupbuddy_installed) { + if ( ! $this->is_backupbuddy_installed) { return; } @@ -132,14 +132,14 @@ class MainWP_Child_Back_Up_Buddy { // Backup type. $pretty_type = array( - 'full' => 'Full', - 'db' => 'Database', - 'files' => 'Files', + 'full' => 'Full', + 'db' => 'Database', + 'files' => 'Files', ); $recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' ); - foreach( $recentBackups_list as $backup_fileoptions ) { + foreach ( $recentBackups_list as $backup_fileoptions ) { $backup = new pb_backupbuddy_fileoptions( $backup_fileoptions, $read_only = true ); if ( method_exists($backup, 'is_ok') && true !== ( $result = $backup->is_ok() ) ) { @@ -148,7 +148,7 @@ class MainWP_Child_Back_Up_Buddy { $backup = &$backup->options; - if ( !isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) { + if ( ! isset( $backup['serial'] ) || ( $backup['serial'] == '' ) ) { continue; } @@ -177,7 +177,7 @@ class MainWP_Child_Back_Up_Buddy { $finish_time = $backup['finish_time']; $message = 'BackupBuddy ' . $backupType . ' finished'; - if (!empty($finish_time)) { + if ( ! empty($finish_time)) { do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); } } @@ -198,7 +198,7 @@ class MainWP_Child_Back_Up_Buddy { $finish_time = $state['stats']['last_remote_snapshot']; $backupType = 'Live Backup to cloud'; $message = 'BackupBuddy ' . $backupType . ' finished'; - if (!empty($finish_time)) { + if ( ! empty($finish_time)) { do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); } @@ -208,7 +208,7 @@ class MainWP_Child_Back_Up_Buddy { } } - } catch( Exception $e ) { + } catch ( Exception $e ) { } } @@ -223,7 +223,7 @@ class MainWP_Child_Back_Up_Buddy { require_once pb_backupbuddy::plugin_path() . '/classes/core.php'; } - if ( !isset( pb_backupbuddy::$options ) ) { + if ( ! isset( pb_backupbuddy::$options ) ) { pb_backupbuddy::load(); } @@ -489,26 +489,26 @@ class MainWP_Child_Back_Up_Buddy { if (is_array($settings)) { if ($type === 'all' || 'general_settings' === $type) { - foreach($filter_general_settings as $field) { - if(isset($settings[ $field ])) { + foreach ($filter_general_settings as $field) { + if (isset($settings[ $field ])) { $save_settings[ $field ] = $settings[ $field ]; } } } if ($type === 'all' || 'advanced_settings' === $type) { - foreach($filter_advanced_settings as $field) { - if(isset($settings[ $field ])) { + foreach ($filter_advanced_settings as $field) { + if (isset($settings[ $field ])) { $save_settings[ $field ] = $settings[ $field ]; } } } } - if (!empty($save_settings)) { + if ( ! empty($save_settings)) { $newOptions = pb_backupbuddy::$options; - foreach($newOptions as $key => $val) { + foreach ($newOptions as $key => $val) { if (isset($save_settings[ $key ])) { $newOptions[ $key ] = $save_settings[ $key ]; } @@ -632,7 +632,7 @@ class MainWP_Child_Back_Up_Buddy { $schedule_id = (int) $_POST['schedule_id']; - if ( !isset( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) || ! is_array( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) ) { + if ( ! isset( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) || ! is_array( pb_backupbuddy::$options['schedules'][ $schedule_id ] ) ) { return array( 'error' => __( 'Error: not found the backup schedule or invalid data', 'mainwp-child' ) ); } @@ -650,12 +650,12 @@ class MainWP_Child_Back_Up_Buddy { $schedule_id = intval($_POST['schedule_id']); $schedule = unserialize(base64_decode($_POST['data'])); - if (!is_array($schedule)) { + if ( ! is_array($schedule)) { return array( 'error' => __( 'Invalid schedule data', 'mainwp-child' ) ); } $information = array(); // add new - if (!isset(pb_backupbuddy::$options['schedules'][ $schedule_id ])) { + if ( ! isset(pb_backupbuddy::$options['schedules'][ $schedule_id ])) { $next_index = pb_backupbuddy::$options['next_schedule_index']; pb_backupbuddy::$options['next_schedule_index']++; // This change will be saved in savesettings function below. pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule; @@ -683,7 +683,7 @@ class MainWP_Child_Back_Up_Buddy { $profile_id = $_POST['profile_id']; $profile = unserialize(base64_decode($_POST['data'])); - if (!is_array($profile)) { + if ( ! is_array($profile)) { return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) ); } @@ -714,7 +714,7 @@ class MainWP_Child_Back_Up_Buddy { if ( is_array( $item_ids ) && count( $item_ids ) > 0 ) { $needs_save = false; $deleted_files = array(); - foreach( $item_ids as $item ) { + foreach ( $item_ids as $item ) { if ( file_exists( backupbuddy_core::getBackupDirectory() . $item ) ) { if ( @unlink( backupbuddy_core::getBackupDirectory() . $item ) === true ) { $deleted_files[] = $item; @@ -755,7 +755,7 @@ class MainWP_Child_Back_Up_Buddy { if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) { try { $information['syncBackupBuddy'] = $this->get_sync_data(); - } catch(Exception $e) { + } catch (Exception $e) { } } @@ -781,14 +781,14 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods('backupbuddy_api', array( 'getOverview' ) ); $data = array(); - $data['plugins_root'] = backupbuddy_core::get_plugins_root(); - $data['themes_root'] = backupbuddy_core::get_themes_root(); - $data['media_root'] = backupbuddy_core::get_media_root(); + $data['plugins_root'] = backupbuddy_core::get_plugins_root(); + $data['themes_root'] = backupbuddy_core::get_themes_root(); + $data['media_root'] = backupbuddy_core::get_media_root(); $data['additional_tables'] = $this->pb_additional_tables(); - $data['abspath'] = ABSPATH; + $data['abspath'] = ABSPATH; $getOverview = backupbuddy_api::getOverview(); - $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup']; + $data['editsSinceLastBackup'] = $getOverview['editsSinceLastBackup']; if ( isset( $getOverview['lastBackupStats']['finish'] ) ) { $finish_time = $getOverview['lastBackupStats']['finish']; @@ -801,7 +801,7 @@ class MainWP_Child_Back_Up_Buddy { } return $data; - } catch(Exception $e) { + } catch (Exception $e) { // not exit here } @@ -832,7 +832,7 @@ class MainWP_Child_Back_Up_Buddy { } function save_note() { - if ( !isset( pb_backupbuddy::$classes['zipbuddy'] ) ) { + if ( ! isset( pb_backupbuddy::$classes['zipbuddy'] ) ) { require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy( backupbuddy_core::getBackupDirectory() ); } @@ -874,11 +874,11 @@ class MainWP_Child_Back_Up_Buddy { $file = backupbuddy_core::getBackupDirectory() . $callback_data; if (file_exists($file)) { return array( - 'result' =>'SUCCESS', + 'result' => 'SUCCESS', 'hash' => md5_file( $file ), ); } else { - return array( 'error' =>'Not found the file' ); + return array( 'error' => 'Not found the file' ); } } @@ -929,7 +929,7 @@ class MainWP_Child_Back_Up_Buddy { $subdirs = array(); // Strip out any files/subdirs that are not actually directly under the given root - foreach( $files as $key => $file ) { + foreach ( $files as $key => $file ) { // If shorter than root length then certainly is not within this (root) directory. // It's a quick test that is more effective the longer the root (the deeper you go @@ -976,7 +976,7 @@ class MainWP_Child_Back_Up_Buddy { $subdir = substr( $unrooted_file, 0, ( $pos + 1 ) ); // Have we already seen it - if ( !in_array( $subdir, $subdirs ) ) { + if ( ! in_array( $subdir, $subdirs ) ) { // Not already seen so record we have seen it and modify this entry to be // specific for the subdir/ @@ -1012,7 +1012,7 @@ class MainWP_Child_Back_Up_Buddy { function exclude_tree() { $root = substr( ABSPATH, 0, strlen( ABSPATH ) - 1 ) . '/' . ltrim( urldecode( $_POST['dir'] ), '/\\' ); - if( file_exists( $root ) ) { + if ( file_exists( $root ) ) { $files = scandir( $root ); natcasesort( $files ); @@ -1020,11 +1020,11 @@ class MainWP_Child_Back_Up_Buddy { // Sort with directories first. $sorted_files = array(); // Temporary holder for sorting files. $sorted_directories = array(); // Temporary holder for sorting directories. - foreach( $files as $file ) { + foreach ( $files as $file ) { if ( ( $file == '.' ) || ( $file == '..' ) ) { continue; } - if( is_file( str_replace( '//', '/', $root . $file ) ) ) { + if ( is_file( str_replace( '//', '/', $root . $file ) ) ) { array_push( $sorted_files, $file ); } else { array_unshift( $sorted_directories, $file ); @@ -1037,10 +1037,10 @@ class MainWP_Child_Back_Up_Buddy { ob_start(); - if( count( $files ) > 0 ) { // Files found. + if ( count( $files ) > 0 ) { // Files found. echo '
    @@ -2391,43 +2391,43 @@ echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; }
    ', __('none', 'it-l10n-backupbuddy' ),'
    '; } -?> + if ( ! empty( $scan['WEBAPP']['INFO'] ) ) { + echo lined_array( $scan['WEBAPP']['INFO'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ),'
    '; } + ?>
    ',__('none', 'it-l10n-backupbuddy' ),'
    '; } -?> + if ( ! empty( $scan['WEBAPP']['VERSION'] ) ) { + echo lined_array( $scan['WEBAPP']['VERSION'] ); + } else { + echo '',__('none', 'it-l10n-backupbuddy' ),'
    '; } + ?>
    ', __('none', 'it-l10n-backupbuddy' ), '
    '; } -?> + if ( ! empty( $scan['WEBAPP']['NOTICE'] ) ) { + echo lined_array( $scan['WEBAPP']['NOTICE'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; } + ?>
    ',__('none', 'it-l10n-backupbuddy' ),'
    '; } -?> + if ( ! empty( $scan['WEBAPP']['ERROR'] ) ) { + echo lined_array( $scan['WEBAPP']['ERROR'] ); + } else { + echo '',__('none', 'it-l10n-backupbuddy' ),'
    '; } + ?>
    ', __('none', 'it-l10n-backupbuddy' ), '
    '; } -?> + if ( ! empty( $scan['WEBAPP']['WARN'] ) ) { + echo lined_array( $scan['WEBAPP']['WARN'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; } + ?>
    @@ -2438,10 +2438,10 @@ echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; }
    ', __('none', 'it-l10n-backupbuddy' ), '
    '; } -?> + echo lined_array( $scan['LINKS']['URL'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; } + ?>
    @@ -2451,10 +2451,10 @@ echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; }
    ', __('none', 'it-l10n-backupbuddy' ),'
    '; } -?> + echo lined_array( $scan['LINKS']['JSLOCAL'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ),'
    '; } + ?>
    @@ -2464,10 +2464,10 @@ echo '', __('none', 'it-l10n-backupbuddy' ),'
    '; }
    ', __('none', 'it-l10n-backupbuddy' ), '
    '; } -?> + echo lined_array( $scan['LINKS']['JSEXTERNAL'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; } + ?>
    @@ -2477,10 +2477,10 @@ echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; }
    ', __('none', 'it-l10n-backupbuddy' ), '
    '; } -?> + echo lined_array( $scan['LINKS']['IFRAME'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; } + ?>
    @@ -2490,10 +2490,10 @@ echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; }
    ', __('none', 'it-l10n-backupbuddy' ), '
    '; } -?> + echo lined_array( $scan['BLACKLIST']['INFO'] ); + } else { + echo '', __('none', 'it-l10n-backupbuddy' ), '
    '; } + ?>
    diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index a20add2..19e24ea 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -44,7 +44,7 @@ class MainWP_Child_Back_Up_Wordpress { } if ( ! $this->is_plugin_installed) { -return; + return; } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -204,10 +204,10 @@ return; // ok public function do_reports_log( $ext = '') { if ( $ext !== 'backupwordpress' ) { -return; + return; } if ( ! $this->is_plugin_installed) { -return; + return; } try { @@ -477,7 +477,7 @@ return; } } else { - ?> + ?> | - ', get_id() ); ?>, this);" class="download-action"> | - @@ -560,7 +560,7 @@ return; - + ?> @@ -695,7 +695,7 @@ return; } if ( $files ) { - ?> + ?> @@ -729,7 +729,7 @@ return; $parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) ); foreach ( $parents as $directory_basename ) { - ?> + ?> @@ -857,7 +857,7 @@ return; + ?> getBasename() ); ?> @@ -873,11 +873,11 @@ return; onclick="event.preventDefault(); mainwp_backupwp_directory_browse('getPathname()) ); ?>', this)">getBasename() ); ?> - + ?> getBasename() ); ?> @@ -887,7 +887,7 @@ return; getBasename() ); ?> - isDir() ) { //echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) ); ?> @@ -895,7 +895,7 @@ return; href="#" onclick="event.preventDefault(); mainwp_backupwp_directory_browse('getPathname() ); ?>', this)">getBasename() ); ?> - @@ -944,7 +944,7 @@ return; -- - @@ -962,7 +962,7 @@ return; - isDir() ) : esc_html_e( 'Folder', 'backupwordpress' ); @@ -1136,16 +1136,16 @@ return; $exclude_rule_to_remove = trim($exclude_rule_to_remove); $exclude_rule_to_remove = trim($exclude_rule_to_remove, '/'); - if (empty($exclude_rule_to_remove)) { - continue; - } + if (empty($exclude_rule_to_remove)) { + continue; + } $excludes = $schedule->get_excludes(); - if (method_exists($excludes, 'get_user_excludes')) { - $schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) ); - } else { - $schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) ); - } + if (method_exists($excludes, 'get_user_excludes')) { + $schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) ); + } else { + $schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) ); + } $schedule->save(); } } @@ -1163,11 +1163,11 @@ return; return array( 'error' => 'Error: Schedule data' ); } -// $current_value = get_option( 'hmbkp_schedule_' . $sch_id ); -// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) { -// // do not update 'excludes' value -// $options['excludes'] = $current_value['excludes']; -// } + // $current_value = get_option( 'hmbkp_schedule_' . $sch_id ); + // if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) { + // // do not update 'excludes' value + // $options['excludes'] = $current_value['excludes']; + // } $filter_opts = array( 'type', diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 2fc9e00..09bfe88 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -240,7 +240,7 @@ class MainWP_Child_Back_WP_Up { // ok public function do_reports_log( $ext = '') { if ( $ext !== 'backwpup' ) { -return; + return; } if ( ! $this->is_backwpup_installed) { return; @@ -846,10 +846,10 @@ return; $dest_class->file_download( (int) $_GET['jobid'], $_GET['file'] ); } else { die( '-5' ); - } + } die(); - } + } protected function create_nonce_without_session( $action = - 1 ) { $user = wp_get_current_user(); diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 90a1809..8252f53 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -187,22 +187,22 @@ class MainWP_Child_Branding { MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible -// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] ); -// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' ); -// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' ); -// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' ); -// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] ); -// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] ); -// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] ); -// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) { -// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] ); -// } + // MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] ); + // MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' ); + // MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' ); + // MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' ); + // MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] ); + // MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] ); + // MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] ); + // if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) { + // MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] ); + // } $current_settings['preserve_branding'] = $settings['child_preserve_branding']; $current_settings['branding_header'] = $header; @@ -322,24 +322,24 @@ class MainWP_Child_Branding { } else { MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' ); } -// -// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) { -// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' ); -// } else { -// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' ); -// } + // + // if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) { + // MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' ); + // } else { + // MainWP_Helper::update_option( 'mainwp_branding_show_support', '' ); + // } -// if ( $settings['child_disable_change'] ) { -// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' ); -// } else { -// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' ); -// } + // if ( $settings['child_disable_change'] ) { + // MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' ); + // } else { + // MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' ); + // } -// if ( $settings['child_disable_switching_theme'] ) { -// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' ); -// } else { -// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' ); -// } + // if ( $settings['child_disable_switching_theme'] ) { + // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' ); + // } else { + // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' ); + // } $current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : ''; $current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : ''; @@ -426,15 +426,15 @@ class MainWP_Child_Branding { // Disable the WordPress theme update notifications remove_action('load-update-core.php', 'wp_update_themes'); add_filter('pre_site_transient_update_themes', ( $func = function( $a) { - return null; -} )); + return null; + } )); // Disable the WordPress core update notifications add_action('after_setup_theme', 'remove_core_updates'); function remove_core_updates() { add_action('init', ( $func = function( $a) { - remove_action( 'wp_version_check', 'wp_version_check' ); -} ), 2); + remove_action( 'wp_version_check', 'wp_version_check' ); + } ), 2); add_filter('pre_option_update_core', '__return_null'); add_filter('pre_site_transient_update_core', '__return_null'); } @@ -926,7 +926,7 @@ class MainWP_Child_Branding { value=""/> - ' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '

    ' ); + // ITSEC_Response::set_response( '

    ' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '

    ' ); } } if ($nbf_settings !== null) { @@ -409,15 +409,15 @@ class MainWP_Child_iThemes_Security { $key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] ); if ( is_wp_error( $key ) ) { return false; -// $this->set_can_save( false ); -// $this->add_error( $key ); + // $this->set_can_save( false ); + // $this->add_error( $key ); } else { $secret = ITSEC_Network_Brute_Force_Utilities::activate_api_key( $key ); if ( is_wp_error( $secret ) ) { return false; -// $this->set_can_save( false ); -// $this->add_error( $secret ); + // $this->set_can_save( false ); + // $this->add_error( $secret ); } else { $settings['api_key'] = $key; $settings['api_secret'] = $secret; @@ -634,8 +634,8 @@ class MainWP_Child_iThemes_Security { } $class = 'entry-row'; - ob_start(); - ?> + ob_start(); + ?>

    @@ -668,7 +668,7 @@ class MainWP_Child_iThemes_Security {

    - $html ); } @@ -723,13 +723,13 @@ class MainWP_Child_iThemes_Security { $msg .= __( 'Admin user ID already changes.', 'mainwp-child' ); } -// if ( $change_id ) { -// $user = get_user_by( 'login', $new_username ); -// if ( $user && 1 === (int) $user->ID ) { -// $return['result'] = 'CHILD_ADMIN'; -// return $return; -// } -// } + // if ( $change_id ) { + // $user = get_user_by( 'login', $new_username ); + // if ( $user && 1 === (int) $user->ID ) { + // $return['result'] = 'CHILD_ADMIN'; + // return $return; + // } + // } $admin_success = true; $return = array(); @@ -763,79 +763,79 @@ class MainWP_Child_iThemes_Security { //Get the full user object $user_object = get_user_by( 'id', '1' ); - if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { //there is a valid username to change + if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { //there is a valid username to change - if ( true === $id ) { //we're changing the id too so we'll set the username + if ( true === $id ) { //we're changing the id too so we'll set the username - $user_login = $new_user; + $user_login = $new_user; - } else { // we're only changing the username + } else { // we're only changing the username - //query main user table - $wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); + //query main user table + $wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); - if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation - - $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); - $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = %s WHERE meta_key = 'site_admins'", $newAdmins ) ); - } - - wp_clear_auth_cookie(); - $itsec_files->release_file_lock( 'admin_user' ); - - return true; - - } - } elseif ( null !== $username ) { //username didn't validate - - $itsec_files->release_file_lock( 'admin_user' ); - - return false; - - } else { //only changing the id - - $user_login = $user_object->user_login; - - } - - if ( true === $id ) { //change the user id - - $wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' ); - - $wpdb->insert( $wpdb->users, array( - 'user_login' => $user_login, - 'user_pass' => $user_object->user_pass, - 'user_nicename' => $user_object->user_nicename, - 'user_email' => $user_object->user_email, - 'user_url' => $user_object->user_url, - 'user_registered' => $user_object->user_registered, - 'user_activation_key' => $user_object->user_activation_key, - 'user_status' => $user_object->user_status, - 'display_name' => $user_object->display_name, - ) ); - - if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { //process sitemeta if we're in a multi-site situation + if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); - $wpdb->query( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = '" . esc_sql( $newAdmins ) . "' WHERE meta_key = 'site_admins'" ); - + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = %s WHERE meta_key = 'site_admins'", $newAdmins ) ); } - $new_user = $wpdb->insert_id; - - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . '` SET post_author = %s WHERE post_author = 1;', $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . '` SET link_owner = %s WHERE link_owner = 1;', $new_user ) ); - wp_clear_auth_cookie(); $itsec_files->release_file_lock( 'admin_user' ); return true; } + } elseif ( null !== $username ) { //username didn't validate + + $itsec_files->release_file_lock( 'admin_user' ); + + return false; + + } else { //only changing the id + + $user_login = $user_object->user_login; + + } + + if ( true === $id ) { //change the user id + + $wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' ); + + $wpdb->insert( $wpdb->users, array( + 'user_login' => $user_login, + 'user_pass' => $user_object->user_pass, + 'user_nicename' => $user_object->user_nicename, + 'user_email' => $user_object->user_email, + 'user_url' => $user_object->user_url, + 'user_registered' => $user_object->user_registered, + 'user_activation_key' => $user_object->user_activation_key, + 'user_status' => $user_object->user_status, + 'display_name' => $user_object->display_name, + ) ); + + if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { //process sitemeta if we're in a multi-site situation + + $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); + $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); + $wpdb->query( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = '" . esc_sql( $newAdmins ) . "' WHERE meta_key = 'site_admins'" ); + + } + + $new_user = $wpdb->insert_id; + + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . '` SET post_author = %s WHERE post_author = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . '` SET link_owner = %s WHERE link_owner = 1;', $new_user ) ); + + wp_clear_auth_cookie(); + $itsec_files->release_file_lock( 'admin_user' ); + + return true; + + } //} return false; diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index 86c253f..bc20009 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -232,7 +232,7 @@ class MainWP_Child_Links_Checker { function get_links_data() { if ( ! defined('BLC_DIRECTORY')) { -return; + return; } $file_path1 = BLC_DIRECTORY . '/includes/link-query.php'; @@ -293,7 +293,7 @@ return; function get_count_links() { if ( ! defined('BLC_DIRECTORY')) { -return; + return; } $file_path1 = BLC_DIRECTORY . '/includes/link-query.php'; diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index 39c8a45..31c3d2c 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -240,17 +240,17 @@ class MainWP_Child_Pagespeed { $result = $this->get_sync_data( $strategy ); -// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) { -// if ( 'recheck_all_pages' === $_POST['doaction'] ) { -// $recheck = true; -// } else { -// $recheck = false; -// } -// -// -// if ($this->do_check_pages($recheck)) -// $information['checked_pages'] = 1; -// } + // if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) { + // if ( 'recheck_all_pages' === $_POST['doaction'] ) { + // $recheck = true; + // } else { + // $recheck = false; + // } + // + // + // if ($this->do_check_pages($recheck)) + // $information['checked_pages'] = 1; + // } $information['data'] = $result['data']; return $information; } diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index 8157ee4..760fc51 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -19,11 +19,11 @@ class MainWP_Child_Server_Information { } if ( $_POST['what'] == 'warning' ) { - if (isset($_POST['warnings'])) { - $warnings = intval($_POST['warnings']); - } else { - $warnings = self::getWarnings(); - } + if (isset($_POST['warnings'])) { + $warnings = intval($_POST['warnings']); + } else { + $warnings = self::getWarnings(); + } $dismissWarnings['warnings'] = $warnings; } MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings ); @@ -476,8 +476,8 @@ class MainWP_Child_Server_Information {

    + self::render(); + ?>

    get_branding_title(); - if ($branding_title == '') { - $branding_title = 'MainWP'; - } + public static function renderConnectionDetails() { + $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); + if ($branding_title == '') { + $branding_title = 'MainWP'; + } - global $current_user; - $uniqueId = get_option('mainwp_child_uniqueId'); - $details = array( - 'siteurl' => array( - 'title' => __('Site URL', 'mainwp-child'), - 'value' => get_bloginfo( 'url' ), - 'desc' => get_bloginfo( 'url' ), - ), - 'adminuser' => array( - 'title' => __('Administrator name', 'mainwp-child'), - 'value' => $current_user->user_login, - 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), - ), - 'friendly_name' => array( - 'title' => __('Friendly site name', 'mainwp-child'), - 'value' => get_bloginfo( 'name' ), - 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), - ), - 'uniqueid' => array( - 'title' => __('Child unique security id', 'mainwp-child'), - 'value' => ! empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), - 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), - ), - 'verify_ssl' => array( - 'title' => __('Verify certificate', 'mainwp-child'), - 'value' => __('Yes', 'mainwp-child'), - 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), - ), - 'ssl_version' => array( - 'title' => __('SSL version', 'mainwp-child'), - 'value' => __('Auto Detect', 'mainwp-child'), - 'desc' => __('Auto Detect', 'mainwp-child'), - ), + global $current_user; + $uniqueId = get_option('mainwp_child_uniqueId'); + $details = array( + 'siteurl' => array( + 'title' => __('Site URL', 'mainwp-child'), + 'value' => get_bloginfo( 'url' ), + 'desc' => get_bloginfo( 'url' ), + ), + 'adminuser' => array( + 'title' => __('Administrator name', 'mainwp-child'), + 'value' => $current_user->user_login, + 'desc' => __('This is your Administrator username, however, you can use any existing Administrator username.', 'mainwp-child'), + ), + 'friendly_name' => array( + 'title' => __('Friendly site name', 'mainwp-child'), + 'value' => get_bloginfo( 'name' ), + 'desc' => __('For the friendly site name, you can use any name, this is just a suggestion.', 'mainwp-child'), + ), + 'uniqueid' => array( + 'title' => __('Child unique security id', 'mainwp-child'), + 'value' => ! empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'), + 'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ), + ), + 'verify_ssl' => array( + 'title' => __('Verify certificate', 'mainwp-child'), + 'value' => __('Yes', 'mainwp-child'), + 'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'), + ), + 'ssl_version' => array( + 'title' => __('SSL version', 'mainwp-child'), + 'value' => __('Auto Detect', 'mainwp-child'), + 'desc' => __('Auto Detect', 'mainwp-child'), + ), - ); + ); ?>

    - +
    - + - +
    diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php index fc40816..2d4a632 100644 --- a/class/class-mainwp-child-skeleton-key.php +++ b/class/class-mainwp-child-skeleton-key.php @@ -23,9 +23,9 @@ class MainWP_Child_Skeleton_Key { MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); } // to fix issue double header in response -// else { -// MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information ); -// } + // else { + // MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information ); + // } } register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' ); diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index 9783fff..2b11591 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -77,75 +77,75 @@ class MainWP_Child_Staging { } public function action() { - if ( ! $this->is_plugin_installed) { - MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) ); - } + if ( ! $this->is_plugin_installed) { + MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) ); + } - if ( ! class_exists( 'WPStaging\WPStaging' )) { - require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php'; - } + if ( ! class_exists( 'WPStaging\WPStaging' )) { + require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php'; + } \WPStaging\WPStaging::getInstance(); $information = array(); - if (get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y') { - MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' ); - } + if (get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y') { + MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' ); + } - if ( isset( $_POST['mwp_action'] ) ) { - switch ( $_POST['mwp_action'] ) { - case 'set_showhide': - $information = $this->set_showhide(); - break; - case 'save_settings': - $information = $this->save_settings(); - break; - case 'get_overview': - $information = $this->get_overview(); - break; - case 'get_scan': - $information = $this->get_scan(); - break; - case 'check_disk_space': - $information = $this->ajaxCheckFreeSpace(); - break; - case 'check_clone': - $information = $this->ajaxCheckCloneName(); - break; - case 'start_clone': - $information = $this->ajaxStartClone(); - break; - case 'clone_database': - $information = $this->ajaxCloneDatabase(); - break; - case 'prepare_directories': - $information = $this->ajaxPrepareDirectories(); - break; - case 'copy_files': - $information = $this->ajaxCopyFiles(); - break; - case 'replace_data': - $information = $this->ajaxReplaceData(); - break; - case 'clone_finish': - $information = $this->ajaxFinish(); - break; - case 'delete_confirmation': - $information = $this->ajaxDeleteConfirmation(); - break; - case 'delete_clone': - $information = $this->ajaxDeleteClone(); - break; - case 'cancel_clone': - $information = $this->ajaxCancelClone(); - break; - case 'staging_update': - $information = $this->ajaxUpdateProcess(); - break; - case 'cancel_update': - $information = $this->ajaxCancelUpdate(); - break; - } - } + if ( isset( $_POST['mwp_action'] ) ) { + switch ( $_POST['mwp_action'] ) { + case 'set_showhide': + $information = $this->set_showhide(); + break; + case 'save_settings': + $information = $this->save_settings(); + break; + case 'get_overview': + $information = $this->get_overview(); + break; + case 'get_scan': + $information = $this->get_scan(); + break; + case 'check_disk_space': + $information = $this->ajaxCheckFreeSpace(); + break; + case 'check_clone': + $information = $this->ajaxCheckCloneName(); + break; + case 'start_clone': + $information = $this->ajaxStartClone(); + break; + case 'clone_database': + $information = $this->ajaxCloneDatabase(); + break; + case 'prepare_directories': + $information = $this->ajaxPrepareDirectories(); + break; + case 'copy_files': + $information = $this->ajaxCopyFiles(); + break; + case 'replace_data': + $information = $this->ajaxReplaceData(); + break; + case 'clone_finish': + $information = $this->ajaxFinish(); + break; + case 'delete_confirmation': + $information = $this->ajaxDeleteConfirmation(); + break; + case 'delete_clone': + $information = $this->ajaxDeleteClone(); + break; + case 'cancel_clone': + $information = $this->ajaxCancelClone(); + break; + case 'staging_update': + $information = $this->ajaxUpdateProcess(); + break; + case 'cancel_update': + $information = $this->ajaxCancelUpdate(); + break; + } + } MainWP_Helper::write( $information ); } @@ -206,176 +206,176 @@ class MainWP_Child_Staging { 'prefix' => WPStaging\WPStaging::getTablePrefix(), ); return $return; - } + } public function ajaxCheckCloneName() { - $cloneName = sanitize_key( $_POST['cloneID'] ); - $cloneNameLength = strlen( $cloneName ); - $clones = get_option( 'wpstg_existing_clones_beta', array() ); + $cloneName = sanitize_key( $_POST['cloneID'] ); + $cloneNameLength = strlen( $cloneName ); + $clones = get_option( 'wpstg_existing_clones_beta', array() ); - // Check clone name length - if ( $cloneNameLength < 1 || $cloneNameLength > 16 ) { - echo array( - 'status' => 'failed', - 'message' => 'Clone name must be between 1 - 16 characters', - ); - } elseif ( array_key_exists( $cloneName, $clones ) ) { - return array( - 'status' => 'failed', - 'message' => 'Clone name is already in use, please choose an another clone name', - ); - } + // Check clone name length + if ( $cloneNameLength < 1 || $cloneNameLength > 16 ) { + echo array( + 'status' => 'failed', + 'message' => 'Clone name must be between 1 - 16 characters', + ); + } elseif ( array_key_exists( $cloneName, $clones ) ) { + return array( + 'status' => 'failed', + 'message' => 'Clone name is already in use, please choose an another clone name', + ); + } - return array( 'status' => 'success' ); - } + return array( 'status' => 'success' ); + } - public function ajaxStartClone() { + public function ajaxStartClone() { - $this->url = ''; // to fix warning - $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); + $this->url = ''; // to fix warning + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - if ( ! $cloning->save() ) { - return; - } + if ( ! $cloning->save() ) { + return; + } - ob_start(); - require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/start.php'; - $result = ob_get_clean(); - return $result; - } + ob_start(); + require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/start.php'; + $result = ob_get_clean(); + return $result; + } public function ajaxCloneDatabase() { - $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - return $cloning->start(); - } + return $cloning->start(); + } - /** - * Ajax Prepare Directories (get listing of files) - */ - public function ajaxPrepareDirectories() { + /** + * Ajax Prepare Directories (get listing of files) + */ + public function ajaxPrepareDirectories() { - $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - return $cloning->start(); - } + return $cloning->start(); + } - /** - * Ajax Clone Files - */ - public function ajaxCopyFiles() { + /** + * Ajax Clone Files + */ + public function ajaxCopyFiles() { - $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - return $cloning->start(); - } + return $cloning->start(); + } - /** - * Ajax Replace Data - */ - public function ajaxReplaceData() { - $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - return $cloning->start(); - } + /** + * Ajax Replace Data + */ + public function ajaxReplaceData() { + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); + return $cloning->start(); + } - /** - * Ajax Finish - */ - public function ajaxFinish() { + /** + * Ajax Finish + */ + public function ajaxFinish() { - $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); - $this->url = ''; // to fix warning - $return = $cloning->start(); - $return->blogInfoName = get_bloginfo('name'); + $cloning = new WPStaging\Backend\Modules\Jobs\Cloning(); + $this->url = ''; // to fix warning + $return = $cloning->start(); + $return->blogInfoName = get_bloginfo('name'); - return $return; - } + return $return; + } - /** - * Ajax Delete Confirmation - */ - public function ajaxDeleteConfirmation() { + /** + * Ajax Delete Confirmation + */ + public function ajaxDeleteConfirmation() { - $delete = new WPStaging\Backend\Modules\Jobs\Delete(); - $delete->setData(); - $clone = $delete->getClone(); - $result = array( - 'clone' => $clone, - 'deleteTables' => $delete->getTables(), - ); - return $result; - } + $delete = new WPStaging\Backend\Modules\Jobs\Delete(); + $delete->setData(); + $clone = $delete->getClone(); + $result = array( + 'clone' => $clone, + 'deleteTables' => $delete->getTables(), + ); + return $result; + } - /** - * Delete clone - */ - public function ajaxDeleteClone() { + /** + * Delete clone + */ + public function ajaxDeleteClone() { - $delete = new WPStaging\Backend\Modules\Jobs\Delete(); - return $delete->start(); - } + $delete = new WPStaging\Backend\Modules\Jobs\Delete(); + return $delete->start(); + } - /** - * Delete clone - */ - public function ajaxCancelClone() { - $cancel = new WPStaging\Backend\Modules\Jobs\Cancel(); - return $cancel->start(); - } + /** + * Delete clone + */ + public function ajaxCancelClone() { + $cancel = new WPStaging\Backend\Modules\Jobs\Cancel(); + return $cancel->start(); + } public function ajaxCancelUpdate() { - $cancel = new WPStaging\Backend\Modules\Jobs\CancelUpdate(); - return $cancel->start(); - } + $cancel = new WPStaging\Backend\Modules\Jobs\CancelUpdate(); + return $cancel->start(); + } - public function ajaxUpdateProcess() { + public function ajaxUpdateProcess() { $cloning = new WPStaging\Backend\Modules\Jobs\Updating(); if ( ! $cloning->save() ) { - return; + return; } ob_start(); require_once WPSTG_PLUGIN_DIR . 'apps/Backend/views/clone/ajax/update.php'; $result = ob_get_clean(); return $result; - } + } public function ajaxCheckFreeSpace() { - return $this->hasFreeDiskSpace(); + return $this->hasFreeDiskSpace(); } // from wp-staging plugin public function hasFreeDiskSpace() { - if ( ! function_exists( 'disk_free_space' ) ) { - return null; - } - $freeSpace = @disk_free_space( ABSPATH ); - if ( false === $freeSpace ) { - $data = array( - 'freespace' => false, - 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)), - ); - return $data; - } - $data = array( - 'freespace' => $this->formatSize($freeSpace), - 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)), - ); - return $data; - } + if ( ! function_exists( 'disk_free_space' ) ) { + return null; + } + $freeSpace = @disk_free_space( ABSPATH ); + if ( false === $freeSpace ) { + $data = array( + 'freespace' => false, + 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)), + ); + return $data; + } + $data = array( + 'freespace' => $this->formatSize($freeSpace), + 'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)), + ); + return $data; + } // from wp-staging plugin function getDirectorySizeInclSubdirs( $dir ) { - $size = 0; - foreach ( glob( rtrim( $dir, '/' ) . '/*', GLOB_NOSORT ) as $each ) { - $size += is_file( $each ) ? filesize( $each ) : $this->getDirectorySizeInclSubdirs( $each ); - } - return $size; - } + $size = 0; + foreach ( glob( rtrim( $dir, '/' ) . '/*', GLOB_NOSORT ) as $each ) { + $size += is_file( $each ) ? filesize( $each ) : $this->getDirectorySizeInclSubdirs( $each ); + } + return $size; + } // from wp-staging plugin public function formatSize( $bytes, $precision = 2) { diff --git a/class/class-mainwp-child-themes-check.php b/class/class-mainwp-child-themes-check.php index a7cfc9f..547b22f 100644 --- a/class/class-mainwp-child-themes-check.php +++ b/class/class-mainwp-child-themes-check.php @@ -178,7 +178,7 @@ class MainWP_Child_Themes_Check { foreach ( $themes_to_scan as $slug => $v ) { if ( in_array( $slug, $avoid_themes ) ) { -continue; + continue; } $body = $this->try_get_response_body( $slug, false ); diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index a0fb9fa..4e95a07 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -40,9 +40,9 @@ class MainWP_Child_Timecapsule { public function init() { - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed) { return; - } + } if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) { return; @@ -60,16 +60,16 @@ class MainWP_Child_Timecapsule { public function action() { - if ( ! $this->is_plugin_installed) { - MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) ); - } + if ( ! $this->is_plugin_installed) { + MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) ); + } - try { - $this->require_files(); - } catch ( Exception $e) { - $error = $e->getMessage(); - MainWP_Helper::write( array( 'error' => $error ) ); - } + try { + $this->require_files(); + } catch ( Exception $e) { + $error = $e->getMessage(); + MainWP_Helper::write( array( 'error' => $error ) ); + } $information = array(); @@ -78,158 +78,158 @@ class MainWP_Child_Timecapsule { $is_user_logged_in = $options->get_option('is_user_logged_in'); $privileges_wptc = $options_helper->get_unserialized_privileges(); - if ( isset( $_POST['mwp_action'] ) ) { + if ( isset( $_POST['mwp_action'] ) ) { - if (( - $_POST['mwp_action'] == 'save_settings' || - $_POST['mwp_action'] == 'get_staging_details_wptc' || - $_POST['mwp_action'] == 'progress_wptc' - ) && ( ! $is_user_logged_in || ! $privileges_wptc ) - ) { - MainWP_Helper::write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) ); - } + if (( + $_POST['mwp_action'] == 'save_settings' || + $_POST['mwp_action'] == 'get_staging_details_wptc' || + $_POST['mwp_action'] == 'progress_wptc' + ) && ( ! $is_user_logged_in || ! $privileges_wptc ) + ) { + MainWP_Helper::write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) ); + } - switch ( $_POST['mwp_action'] ) { - case 'set_showhide': - $information = $this->set_showhide(); - break; - case 'get_root_files': - $information = $this->get_root_files(); - break; - case 'get_tables': - $information = $this->get_tables(); - break; - case 'exclude_file_list': - $information = $this->exclude_file_list(); - break; - case 'exclude_table_list': - $information = $this->exclude_table_list(); - break; - case 'include_table_list': - $information = $this->include_table_list(); - break; - case 'include_table_structure_only': - $information = $this->include_table_structure_only(); - break; - case 'include_file_list': - $information = $this->include_file_list(); - break; - case 'get_files_by_key': - $information = $this->get_files_by_key(); - break; - case 'wptc_login': - $information = $this->process_wptc_login(); - break; - case 'get_installed_plugins': - $information = $this->get_installed_plugins(); - break; - case 'get_installed_themes': - $information = $this->get_installed_themes(); - break; - case 'is_staging_need_request': - $information = $this->is_staging_need_request(); - break; - case 'get_staging_details_wptc': - $information = $this->get_staging_details_wptc(); - break; - case 'start_fresh_staging_wptc': - $information = $this->start_fresh_staging_wptc(); - break; - case 'get_staging_url_wptc': - $information = $this->get_staging_url_wptc(); - break; - case 'stop_staging_wptc': - $information = $this->stop_staging_wptc(); - break; - case 'continue_staging_wptc': - $information = $this->continue_staging_wptc(); - break; - case 'delete_staging_wptc': - $information = $this->delete_staging_wptc(); - break; - case 'copy_staging_wptc': - $information = $this->copy_staging_wptc(); - break; - case 'get_staging_current_status_key': - $information = $this->get_staging_current_status_key(); - break; - case 'wptc_sync_purchase': - $information = $this->wptc_sync_purchase(); - break; - case 'init_restore': - $information = $this->init_restore(); - break; - case 'save_settings': - $information = $this->save_settings_wptc(); - break; - case 'analyze_inc_exc': - $information = $this->analyze_inc_exc(); - break; - case 'get_enabled_plugins': - $information = $this->get_enabled_plugins(); - break; - case 'get_enabled_themes': - $information = $this->get_enabled_themes(); - break; - case 'get_system_info': - $information = $this->get_system_info(); - break; - case 'update_vulns_settings': - $information = $this->update_vulns_settings(); - break; - case 'start_fresh_backup': - $information = $this->start_fresh_backup_tc_callback_wptc(); - break; - case 'save_manual_backup_name': - $information = $this->save_manual_backup_name_wptc(); - break; - case 'progress_wptc': - $information = $this->progress_wptc(); - break; - case 'stop_fresh_backup': - $information = $this->stop_fresh_backup_tc_callback_wptc(); - break; - case 'wptc_cron_status': - $information = $this->wptc_cron_status(); - break; - case 'get_this_backups_html': - $information = $this->get_this_backups_html(); - break; - case 'start_restore_tc_wptc': - $information = $this->start_restore_tc_callback_wptc(); - break; - case 'get_sibling_files': - $information = $this->get_sibling_files_callback_wptc(); - break; - case 'get_logs_rows': - $information = $this->get_logs_rows(); - break; - case 'clear_logs': - $information = $this->clear_wptc_logs(); - break; - case 'send_issue_report': - $information = $this->send_issue_report(); - break; - case 'lazy_load_activity_log': - $information = $this->lazy_load_activity_log_wptc(); - break; - } - } + switch ( $_POST['mwp_action'] ) { + case 'set_showhide': + $information = $this->set_showhide(); + break; + case 'get_root_files': + $information = $this->get_root_files(); + break; + case 'get_tables': + $information = $this->get_tables(); + break; + case 'exclude_file_list': + $information = $this->exclude_file_list(); + break; + case 'exclude_table_list': + $information = $this->exclude_table_list(); + break; + case 'include_table_list': + $information = $this->include_table_list(); + break; + case 'include_table_structure_only': + $information = $this->include_table_structure_only(); + break; + case 'include_file_list': + $information = $this->include_file_list(); + break; + case 'get_files_by_key': + $information = $this->get_files_by_key(); + break; + case 'wptc_login': + $information = $this->process_wptc_login(); + break; + case 'get_installed_plugins': + $information = $this->get_installed_plugins(); + break; + case 'get_installed_themes': + $information = $this->get_installed_themes(); + break; + case 'is_staging_need_request': + $information = $this->is_staging_need_request(); + break; + case 'get_staging_details_wptc': + $information = $this->get_staging_details_wptc(); + break; + case 'start_fresh_staging_wptc': + $information = $this->start_fresh_staging_wptc(); + break; + case 'get_staging_url_wptc': + $information = $this->get_staging_url_wptc(); + break; + case 'stop_staging_wptc': + $information = $this->stop_staging_wptc(); + break; + case 'continue_staging_wptc': + $information = $this->continue_staging_wptc(); + break; + case 'delete_staging_wptc': + $information = $this->delete_staging_wptc(); + break; + case 'copy_staging_wptc': + $information = $this->copy_staging_wptc(); + break; + case 'get_staging_current_status_key': + $information = $this->get_staging_current_status_key(); + break; + case 'wptc_sync_purchase': + $information = $this->wptc_sync_purchase(); + break; + case 'init_restore': + $information = $this->init_restore(); + break; + case 'save_settings': + $information = $this->save_settings_wptc(); + break; + case 'analyze_inc_exc': + $information = $this->analyze_inc_exc(); + break; + case 'get_enabled_plugins': + $information = $this->get_enabled_plugins(); + break; + case 'get_enabled_themes': + $information = $this->get_enabled_themes(); + break; + case 'get_system_info': + $information = $this->get_system_info(); + break; + case 'update_vulns_settings': + $information = $this->update_vulns_settings(); + break; + case 'start_fresh_backup': + $information = $this->start_fresh_backup_tc_callback_wptc(); + break; + case 'save_manual_backup_name': + $information = $this->save_manual_backup_name_wptc(); + break; + case 'progress_wptc': + $information = $this->progress_wptc(); + break; + case 'stop_fresh_backup': + $information = $this->stop_fresh_backup_tc_callback_wptc(); + break; + case 'wptc_cron_status': + $information = $this->wptc_cron_status(); + break; + case 'get_this_backups_html': + $information = $this->get_this_backups_html(); + break; + case 'start_restore_tc_wptc': + $information = $this->start_restore_tc_callback_wptc(); + break; + case 'get_sibling_files': + $information = $this->get_sibling_files_callback_wptc(); + break; + case 'get_logs_rows': + $information = $this->get_logs_rows(); + break; + case 'clear_logs': + $information = $this->clear_wptc_logs(); + break; + case 'send_issue_report': + $information = $this->send_issue_report(); + break; + case 'lazy_load_activity_log': + $information = $this->lazy_load_activity_log_wptc(); + break; + } + } MainWP_Helper::write( $information ); } public function require_files() { - if ( ! class_exists('WPTC_Base_Factory') && defined('WPTC_PLUGIN_DIR') ) { - if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Base/Factory.php') ) { - include_once WPTC_PLUGIN_DIR . 'Base/Factory.php'; - } - } - if ( ! class_exists('Wptc_Options_Helper') && defined('WPTC_PLUGIN_DIR') ) { - if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php') ) { - include_once WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php'; - } - } + if ( ! class_exists('WPTC_Base_Factory') && defined('WPTC_PLUGIN_DIR') ) { + if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Base/Factory.php') ) { + include_once WPTC_PLUGIN_DIR . 'Base/Factory.php'; + } + } + if ( ! class_exists('Wptc_Options_Helper') && defined('WPTC_PLUGIN_DIR') ) { + if ( MainWP_Helper::check_files_exists(WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php') ) { + include_once WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php'; + } + } } function set_showhide() { @@ -272,7 +272,7 @@ class MainWP_Child_Timecapsule { $backups_count = 0; if (is_array($all_backups)) { $formatted_backups = array(); - foreach ($all_backups as $key => $value) { + foreach ($all_backups as $key => $value) { $value_array = (array) $value; $formatted_backups[ $value_array['backupID'] ][] = $value_array; } @@ -414,31 +414,31 @@ class MainWP_Child_Timecapsule { } -function start_restore_tc_callback_wptc() { + function start_restore_tc_callback_wptc() { - if (apply_filters('is_restore_to_staging_wptc', '')) { - $request = apply_filters('get_restore_to_staging_request_wptc', ''); - } else { - $request = $_POST['data']; + if (apply_filters('is_restore_to_staging_wptc', '')) { + $request = apply_filters('get_restore_to_staging_request_wptc', ''); + } else { + $request = $_POST['data']; + } + + include_once WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php'; + + new WPTC_Prepare_Restore_Bridge($request); } - include_once WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php'; + function get_sibling_files_callback_wptc() { + //note that we are getting the ajax function data via $_POST. + $file_name = $_POST['data']['file_name']; + $file_name = wp_normalize_path($file_name); + $backup_id = $_POST['data']['backup_id']; + $recursive_count = $_POST['data']['recursive_count']; + // //getting the backups - new WPTC_Prepare_Restore_Bridge($request); -} - -function get_sibling_files_callback_wptc() { - //note that we are getting the ajax function data via $_POST. - $file_name = $_POST['data']['file_name']; - $file_name = wp_normalize_path($file_name); - $backup_id = $_POST['data']['backup_id']; - $recursive_count = $_POST['data']['recursive_count']; - // //getting the backups - - $processed_files = WPTC_Factory::get('processed-files'); - echo $processed_files->get_this_backups_html($backup_id, $file_name, $type = 'sibling', (int) $recursive_count); - die(); -} + $processed_files = WPTC_Factory::get('processed-files'); + echo $processed_files->get_this_backups_html($backup_id, $file_name, $type = 'sibling', (int) $recursive_count); + die(); + } function send_issue_report() { WPTC_Base_Factory::get('Wptc_App_Functions')->send_report(); @@ -458,26 +458,26 @@ function get_sibling_files_callback_wptc() { if (isset($_POST['type'])) { $type = $_POST['type']; switch ($type) { - case 'backups': - $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id"; + case 'backups': + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id"; break; - case 'restores': - $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'restore%' GROUP BY action_id"; + case 'restores': + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'restore%' GROUP BY action_id"; break; - case 'staging': - $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'staging%' GROUP BY action_id"; + case 'staging': + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'staging%' GROUP BY action_id"; break; - case 'backup_and_update': - $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'backup_and_update%' GROUP BY action_id"; + case 'backup_and_update': + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'backup_and_update%' GROUP BY action_id"; break; - case 'auto_update': - $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'auto_update%' GROUP BY action_id"; + case 'auto_update': + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE 'auto_update%' GROUP BY action_id"; break; - case 'others': - $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type NOT LIKE 'restore%' AND type NOT LIKE 'backup%' AND show_user = 1"; + case 'others': + $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type NOT LIKE 'restore%' AND type NOT LIKE 'backup%' AND show_user = 1"; break; - default: - $query = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log GROUP BY action_id UNION SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE action_id='' AND show_user = 1"; + default: + $query = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log GROUP BY action_id UNION SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE action_id='' AND show_user = 1"; break; } } else { @@ -491,7 +491,7 @@ function get_sibling_files_callback_wptc() { $orderby = ! empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id'; $order = ! empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC'; if ( ! empty($orderby) & ! empty($order)) { -$query .= ' ORDER BY ' . $orderby . ' ' . $order;} + $query .= ' ORDER BY ' . $orderby . ' ' . $order;} /* -- Pagination parameters -- */ @@ -502,7 +502,7 @@ $query .= ' ORDER BY ' . $orderby . ' ' . $order;} //Which page is this? $paged = ! empty($_POST['paged']) ? $_POST['paged'] : ''; if (empty($paged) || ! is_numeric($paged) || $paged <= 0) { -$paged = 1;} //Page Number + $paged = 1;} //Page Number //How many pages do we have in total? $totalpages = ceil($totalitems / $perpage); //Total number of pages //adjust the query to take pagination into account @@ -712,7 +712,7 @@ $paged = 1;} //Page Number public function do_reports_log( $ext = '') { if ( $ext !== 'wptimecapsule' ) { -return; + return; } if ( ! $this->is_plugin_installed) { diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 4c8a5fa..324ccf0 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -47,9 +47,9 @@ class MainWP_Child_Updraft_Plus_Backups { if (isset($last_backup['backup_time'])) { $backup_time = $last_backup['backup_time']; - if ($last_backup['success']) { + if ($last_backup['success']) { MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time); - } + } } return $last_backup; } @@ -61,9 +61,9 @@ class MainWP_Child_Updraft_Plus_Backups { $with_hist = true; if ( version_compare( $info, '1.7', '>=' ) ) { $with_hist = false; - } + } $information['syncUpdraftData'] = $this->get_sync_data( $with_hist ); - } + } } if ( isset( $data['sync_Updraftvault_quota_text'] ) && $data['sync_Updraftvault_quota_text'] ) { if ( $this->is_plugin_installed ) { @@ -319,7 +319,7 @@ class MainWP_Child_Updraft_Plus_Backups { ); if ( is_wp_error( $result ) || ( false === $result ) ) { -return $result; + return $result; } $response = json_decode( $result['body'], true ); @@ -338,14 +338,14 @@ return $result; // Store it $vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' ); if ( ! is_array( $vault_settings ) ) { -$vault_settings = array(); + $vault_settings = array(); } $vault_settings['email'] = $email; $vault_settings['token'] = (string) $response['token']; $vault_settings['quota'] = -1; unset( $vault_settings['last_config'] ); if ( isset($response['quota'] ) ) { -$vault_settings['quota'] = $response['quota']; + $vault_settings['quota'] = $response['quota']; } UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings ); } elseif ( isset( $response['quota'] ) && ! $response['quota'] ) { @@ -400,7 +400,7 @@ $vault_settings['quota'] = $response['quota']; ); if ( ! empty( $vault_settings['token'] ) ) { -$post_body['token'] = (string) $vault_settings['token']; + $post_body['token'] = (string) $vault_settings['token']; } // Use SSL to prevent snooping @@ -444,75 +444,75 @@ $post_body['token'] = (string) $vault_settings['token']; if (isset($settings['is_general']) && ! empty($settings['is_general'])) { $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } else { -// $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey']; -// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; + // $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey']; + // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } } else { if (isset($settings['is_general']) && ! empty($settings['is_general'])) { $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } else { -// $opts['appkey'] = $settings[ $key ]['appkey']; -// $opts['secret'] = $settings[ $key ]['secret']; + // $opts['appkey'] = $settings[ $key ]['appkey']; + // $opts['secret'] = $settings[ $key ]['secret']; $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } } UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_googledrive' === $key ) { // do not saving from dashboard -// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' ); -// if (!is_array($opts)) -// $opts = array(); -// if(is_array($opts) && isset($opts['settings'])) { -// $settings_key = key($opts['settings']); -//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; -//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; -// $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); -// } else { -//// $opts['clientid'] = $settings[ $key ]['clientid']; -//// $opts['secret'] = $settings[ $key ]['secret']; -// $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); -// } -// UpdraftPlus_Options::update_updraft_option( $key, $opts ); + // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' ); + // if (!is_array($opts)) + // $opts = array(); + // if(is_array($opts) && isset($opts['settings'])) { + // $settings_key = key($opts['settings']); + //// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; + //// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; + // $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); + // } else { + //// $opts['clientid'] = $settings[ $key ]['clientid']; + //// $opts['secret'] = $settings[ $key ]['secret']; + // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); + // } + // UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_googlecloud' === $key ) { // do not saving from dashboard -// $opts = UpdraftPlus_Options::get_updraft_option( $key ); -// if (!is_array($opts)) -// $opts = array(); -// if(is_array($opts) && isset($opts['settings'])) { -// $settings_key = key($opts['settings']); -//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; -//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; -//// $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id']; -//// $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path']; -// $opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class']; -// $opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location']; -// } else { -//// $opts['clientid'] = $settings[ $key ]['clientid']; -//// $opts['secret'] = $settings[ $key ]['secret']; -//// $opts['project_id'] = $settings[ $key ]['project_id']; -//// $opts['bucket_path'] = $settings[ $key ]['bucket_path']; -// $opts['storage_class'] = $settings[ $key ]['storage_class']; -// $opts['bucket_location'] = $settings[ $key ]['bucket_location']; -// } -// UpdraftPlus_Options::update_updraft_option( $key, $opts ); + // $opts = UpdraftPlus_Options::get_updraft_option( $key ); + // if (!is_array($opts)) + // $opts = array(); + // if(is_array($opts) && isset($opts['settings'])) { + // $settings_key = key($opts['settings']); + //// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; + //// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; + //// $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id']; + //// $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path']; + // $opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class']; + // $opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location']; + // } else { + //// $opts['clientid'] = $settings[ $key ]['clientid']; + //// $opts['secret'] = $settings[ $key ]['secret']; + //// $opts['project_id'] = $settings[ $key ]['project_id']; + //// $opts['bucket_path'] = $settings[ $key ]['bucket_path']; + // $opts['storage_class'] = $settings[ $key ]['storage_class']; + // $opts['bucket_location'] = $settings[ $key ]['bucket_location']; + // } + // UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_onedrive' === $key ) { // do not saving from dashboard -// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' ); -// if (!is_array($opts)) -// $opts = array(); -// if(is_array($opts) && isset($opts['settings'])) { -// $settings_key = key($opts['settings']); -//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; -//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; -// $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); -// } else { -//// $opts['clientid'] = $settings[ $key ]['clientid']; -//// $opts['secret'] = $settings[ $key ]['secret']; -// $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); -// } -// -// UpdraftPlus_Options::update_updraft_option( $key, $opts ); + // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' ); + // if (!is_array($opts)) + // $opts = array(); + // if(is_array($opts) && isset($opts['settings'])) { + // $settings_key = key($opts['settings']); + //// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid']; + //// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret']; + // $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); + // } else { + //// $opts['clientid'] = $settings[ $key ]['clientid']; + //// $opts['secret'] = $settings[ $key ]['secret']; + // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); + // } + // + // UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_email' === $key ) { $value = $settings[ $key ]; // free version @@ -729,7 +729,7 @@ $post_body['token'] = (string) $vault_settings['token']; function addons_connect() { if ( ! defined( 'UDADDONS2_SLUG' ) ) { if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) { -require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; + require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; } if ( ! defined( 'UDADDONS2_SLUG' ) ) { return array( 'error' => 'NO_PREMIUM' ); @@ -990,9 +990,9 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; // //echo htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.','updraftplus'))."
    ".__('Nothing happening? Follow this link for help.','updraftplus')."
    "; // $updraftplus->log("A backup run has been scheduled"); // } -// $out = array( 'result' => 'OK' ); -// -// return $out; + // $out = array( 'result' => 'OK' ); + // + // return $out; } function activejobs_list() { @@ -1169,7 +1169,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; // to fix performance issue if ( $with_hist ) { - $out['updraft_historystatus'] = $bh['h']; + $out['updraft_historystatus'] = $bh['h']; } $out['updraft_count_backups'] = $bh['c']; @@ -1194,7 +1194,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; $next_scheduled_backup_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup); // Convert to blog time zone $next_scheduled_backup = get_date_from_gmt($next_scheduled_backup_gmt, 'D, F j, Y H:i'); -// $next_scheduled_backup = date_i18n('D, F j, Y H:i', $next_scheduled_backup); + // $next_scheduled_backup = date_i18n('D, F j, Y H:i', $next_scheduled_backup); } else { $next_scheduled_backup = __('Nothing currently scheduled', 'updraftplus'); $files_not_scheduled = true; @@ -1215,7 +1215,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; $next_scheduled_backup_database_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup_database); // Convert to blog time zone $next_scheduled_backup_database = get_date_from_gmt($next_scheduled_backup_database_gmt, 'D, F j, Y H:i'); -// $next_scheduled_backup_database = date_i18n('D, F j, Y H:i', $next_scheduled_backup_database); + // $next_scheduled_backup_database = date_i18n('D, F j, Y H:i', $next_scheduled_backup_database); } else { $next_scheduled_backup_database = __('Nothing currently scheduled', 'updraftplus'); $database_not_scheduled = true; @@ -1242,8 +1242,8 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; '; - MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ); - MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable'); + MainWP_Helper::check_classes_exists( array( 'UpdraftPlus_Filesystem_Functions' ) ); + MainWP_Helper::check_methods('UpdraftPlus_Filesystem_Functions', 'really_is_writable'); $updraft_dir = $updraftplus->backups_dir_location(); $backup_disabled = ( UpdraftPlus_Filesystem_Functions::really_is_writable($updraft_dir) ) ? 0 : 1; @@ -1863,7 +1863,7 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; @set_time_limit( 900 ); global $wp_filesystem, $updraftplus; -// $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' ); + // $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' ); $backup_history = UpdraftPlus_Backup_History::get_history(); if ( ! is_array( $backup_history[ $timestamp ] ) ) { echo wp_kses_post( '

    ' . esc_html__( 'This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus' ) . " $timestamp


    " ); @@ -2615,14 +2615,14 @@ require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; $backup = UpdraftPlus_Backup_History::get_history($timestamp); if ( ! isset($backup['nonce']) || ! isset($backup['db'])) { -return array( $mess, $warn, $err, $info ); + return array( $mess, $warn, $err, $info ); } $db_file = ( is_string($backup['db']) ) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; } if ( ! is_readable($db_file)) { -return array( $mess, $warn, $err, $info ); + return array( $mess, $warn, $err, $info ); } // Encrypted - decrypt it @@ -2768,7 +2768,7 @@ return array( $mess, $warn, $err, $info ); $migration_warning = true; $powarn = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_home, $res); if ( ! empty($powarn)) { -$warn[] = $powarn; + $warn[] = $powarn; } } } elseif ( ! isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) { @@ -2776,7 +2776,7 @@ $warn[] = $powarn; } elseif ('' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches)) { $old_wp_version = $matches[1]; if ( ! empty($matches[3])) { -$old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1); + $old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1); } if (version_compare($old_wp_version, $wp_version, '>')) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); @@ -2792,7 +2792,7 @@ $old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1); } } elseif ('' == $old_table_prefix && ( preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches) )) { $old_table_prefix = $matches[1]; -// echo ''.__('Old table prefix:', 'updraftplus').' '.htmlspecialchars($old_table_prefix).'
    '; + // echo ''.__('Old table prefix:', 'updraftplus').' '.htmlspecialchars($old_table_prefix).'
    '; } elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) { $info['label'] = $matches[1]; $mess[] = __('Backup label:', 'updraftplus') . ' ' . htmlspecialchars($info['label']); @@ -2822,7 +2822,7 @@ $old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1); if ('multisite' == $key) { $info['multisite'] = $val ? true : false; if ($val) { -$mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; + $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; } } $old_siteinfo[ $key ] = $val; @@ -2921,7 +2921,7 @@ $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . ' } $charset_select_html .= ''; if (empty($info['addui'])) { -$info['addui'] = ''; + $info['addui'] = ''; } $info['addui'] .= $charset_select_html; } @@ -3008,7 +3008,7 @@ $info['addui'] = ''; CREATE TABLE $wpdb->signups ( */ if ( ! isset($skipped_tables)) { -$skipped_tables = array(); + $skipped_tables = array(); } $missing_tables = array(); if ($old_table_prefix) { @@ -3179,17 +3179,17 @@ $skipped_tables = array(); $non = $backup['nonce']; -// $rawbackup = "

    $esc_pretty_date ($key)

    " . esc_attr( print_r( $backup, true ) ); -// if ( ! empty( $non ) ) { -// $jd = $updraftplus->jobdata_getarray( $non ); -// if ( ! empty( $jd ) && is_array( $jd ) ) { -// $rawbackup .= '

    ' . esc_attr( print_r( $jd, true ) ); -// } -// } -// $rawbackup .= '

    '; + // $rawbackup = "

    $esc_pretty_date ($key)

    " . esc_attr( print_r( $backup, true ) ); + // if ( ! empty( $non ) ) { + // $jd = $updraftplus->jobdata_getarray( $non ); + // if ( ! empty( $jd ) && is_array( $jd ) ) { + // $rawbackup .= '

    ' . esc_attr( print_r( $jd, true ) ); + // } + // } + // $rawbackup .= '

    '; - // to fix - $rawbackup = ''; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); + // to fix + $rawbackup = ''; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); $jobdata = $updraftplus->jobdata_getarray( $non ); @@ -3199,16 +3199,16 @@ $skipped_tables = array(); $service_title = ''; if ( ! isset($backup['service'])) { -$backup['service'] = array(); + $backup['service'] = array(); } if ( ! is_array($backup['service'])) { -$backup['service'] = array( $backup['service'] ); + $backup['service'] = array( $backup['service'] ); } foreach ($backup['service'] as $service) { if ('none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) )) { // Do nothing } else { -// $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png'; + // $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png'; $remote_storage = ( 'remotesend' === $service ) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[ $service ]; @@ -3235,7 +3235,7 @@ ENDHERE; if ( class_exists( 'UpdraftPlus_Encryption')) { if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) { if (UpdraftPlus_Encryption::is_file_encrypted($db)) { -$entities .= '/dbcrypted=1/'; + $entities .= '/dbcrypted=1/'; } } } elseif ( method_exists($updraftplus, 'is_db_encrypted') && $updraftplus->is_db_encrypted( $db ) ) { diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php index ec9b170..8830422 100644 --- a/class/class-mainwp-child-vulnerability-checker.php +++ b/class/class-mainwp-child-vulnerability-checker.php @@ -23,9 +23,9 @@ class MainWP_Child_Vulnerability_Checker { private $wpvulndb_token = false; static function Instance() { - if ( null === self::$instance ) { - self::$instance = new MainWP_Child_Vulnerability_Checker(); - } + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_Vulnerability_Checker(); + } return self::$instance; } @@ -36,15 +36,15 @@ class MainWP_Child_Vulnerability_Checker { public function action() { $information = array(); - if ( ! empty( $this->wpvulndb_token ) ) { - if ( isset( $_POST['mwp_action'] ) ) { - switch ( $_POST['mwp_action'] ) { - case 'vulner_recheck': - $information = $this->vulner_recheck(); - break; - } + if ( ! empty( $this->wpvulndb_token ) ) { + if ( isset( $_POST['mwp_action'] ) ) { + switch ( $_POST['mwp_action'] ) { + case 'vulner_recheck': + $information = $this->vulner_recheck(); + break; } } + } MainWP_Helper::write( $information ); } @@ -66,67 +66,67 @@ class MainWP_Child_Vulnerability_Checker { $result = array(); $active_plugins = get_option('active_plugins'); - if ( ! empty($active_plugins) ) { - foreach ($active_plugins as $plug) { + if ( ! empty($active_plugins) ) { + foreach ($active_plugins as $plug) { - $plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug; - $plugin_info = get_plugin_data($plugin_file); - $plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : ''; - $string = explode('/', $plug); - $plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]); - if (false === $plug_vuln || $force) { - $plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]); - set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS); - } - if ($plug_vuln) { - $plug_vuln = json_decode($plug_vuln, true); - $plug_vuln_filter = $plug_vuln; + $plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug; + $plugin_info = get_plugin_data($plugin_file); + $plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : ''; + $string = explode('/', $plug); + $plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]); + if (false === $plug_vuln || $force) { + $plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]); + set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS); + } + if ($plug_vuln) { + $plug_vuln = json_decode($plug_vuln, true); + $plug_vuln_filter = $plug_vuln; - foreach ($plug_vuln as $slug => $pl_data) { - if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) { - $plug_vulner_data = array(); - foreach ($pl_data['vulnerabilities'] as $vuln_data) { - if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) { - continue; - } - $plug_vulner_data[] = $vuln_data; - } + foreach ($plug_vuln as $slug => $pl_data) { + if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) { + $plug_vulner_data = array(); + foreach ($pl_data['vulnerabilities'] as $vuln_data) { + if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) { + continue; + } + $plug_vulner_data[] = $vuln_data; + } - if (count($plug_vulner_data) == 0) { - unset($plug_vuln_filter[ $slug ]); - } else { - $plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data; - $plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version; - $plug_vuln_filter[ $slug ]['plugin_slug'] = $plug; - } + if (count($plug_vulner_data) == 0) { + unset($plug_vuln_filter[ $slug ]); + } else { + $plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data; + $plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version; + $plug_vuln_filter[ $slug ]['plugin_slug'] = $plug; + } - } else { - unset($plug_vuln_filter[ $slug ]); - } + } else { + unset($plug_vuln_filter[ $slug ]); + } - } + } - if (count($plug_vuln_filter) == 0) { - continue; - } - $plug_vuln = json_encode($plug_vuln_filter); + if (count($plug_vuln_filter) == 0) { + continue; + } + $plug_vuln = json_encode($plug_vuln_filter); - } else { - continue; - } - $result[ $plug ] = $plug_vuln; - } - } + } else { + continue; + } + $result[ $plug ] = $plug_vuln; + } + } return $result; } function check_wp( $force = false) { $wp_vuln = get_transient('mainwp_vulnche_trans_wp_json'); $wp_version = str_replace('.', '', get_bloginfo('version')); - if (false === $wp_vuln || $force) { - $wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version); - set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS); - } + if (false === $wp_vuln || $force) { + $wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version); + set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS); + } return $wp_vuln; } diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 4724946..9dbd5aa 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -81,9 +81,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= %s @@ -103,9 +103,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' @@ -202,9 +202,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') @@ -224,9 +224,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index 18744f5..c8c44ec 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -394,7 +394,7 @@ class MainWP_Child_Wordfence { case 'misconfigured_howget_ips_choice': $information = $this->misconfiguredHowGetIPsChoice(); break; - case 'delete_admin_user': + case 'delete_admin_user': $information = $this->deleteAdminUser(); break; case 'revoke_admin_user': @@ -428,13 +428,13 @@ class MainWP_Child_Wordfence { $information = $this->whitelistBulkEnable(); break; case 'whitelist_bulk_disable': - $information = $this->whitelistBulkDisable(); + $information = $this->whitelistBulkDisable(); break; - case 'update_config': - $information = $this->updateConfig(); + case 'update_config': + $information = $this->updateConfig(); break; - case 'save_country_blocking': - $information = $this->saveCountryBlocking(); + case 'save_country_blocking': + $information = $this->saveCountryBlocking(); break; } } @@ -655,7 +655,7 @@ class MainWP_Child_Wordfence { public function wordfence_init() { if ( ! $this->is_wordfence_installed ) { -return; + return; } add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -673,10 +673,10 @@ return; // ok public function do_reports_log( $ext = '') { if ( $ext !== 'wordfence' ) { -return; + return; } if ( ! $this->is_wordfence_installed ) { -return; + return; } global $wpdb; @@ -860,7 +860,7 @@ FROM {$table_wfBlockedIPLog} WHERE unixday >= {$interval} SQL ); - } + } function get_lastscan() { @@ -1183,35 +1183,35 @@ SQL } } -// $to_fix_boolean_values = array( -// 'scansEnabled_checkGSB', -// 'spamvertizeCheck', -// 'checkSpamIP', -// 'scansEnabled_checkHowGetIPs', -// 'scansEnabled_checkReadableConfig', -// 'scansEnabled_suspectedFiles', -// 'scansEnabled_core', -// 'scansEnabled_themes', -// 'scansEnabled_plugins', -// 'scansEnabled_coreUnknown', -// 'scansEnabled_malware', -// 'scansEnabled_fileContents', -// 'scansEnabled_fileContentsGSB', -// 'scansEnabled_posts', -// 'scansEnabled_comments', -// 'scansEnabled_suspiciousOptions', -// 'scansEnabled_oldVersions', -// 'scansEnabled_suspiciousAdminUsers', -// 'scansEnabled_passwds', -// 'scansEnabled_diskSpace', -// 'scansEnabled_dns', -// 'other_scanOutside', -// 'scansEnabled_scanImages', -// 'scansEnabled_highSense', -// 'scheduledScansEnabled', -// 'lowResourceScansEnabled', -// ); -// + // $to_fix_boolean_values = array( + // 'scansEnabled_checkGSB', + // 'spamvertizeCheck', + // 'checkSpamIP', + // 'scansEnabled_checkHowGetIPs', + // 'scansEnabled_checkReadableConfig', + // 'scansEnabled_suspectedFiles', + // 'scansEnabled_core', + // 'scansEnabled_themes', + // 'scansEnabled_plugins', + // 'scansEnabled_coreUnknown', + // 'scansEnabled_malware', + // 'scansEnabled_fileContents', + // 'scansEnabled_fileContentsGSB', + // 'scansEnabled_posts', + // 'scansEnabled_comments', + // 'scansEnabled_suspiciousOptions', + // 'scansEnabled_oldVersions', + // 'scansEnabled_suspiciousAdminUsers', + // 'scansEnabled_passwds', + // 'scansEnabled_diskSpace', + // 'scansEnabled_dns', + // 'other_scanOutside', + // 'scansEnabled_scanImages', + // 'scansEnabled_highSense', + // 'scheduledScansEnabled', + // 'lowResourceScansEnabled', + // ); + // // save the settings foreach ( $opts as $key => $val ) { // check saving section fields @@ -1296,116 +1296,116 @@ SQL $existingAPIKey = wfConfig::get('apiKey', ''); $ping = false; - if ( empty( $apiKey ) && empty($existingAPIKey) ) { // then try to get one. + if ( empty( $apiKey ) && empty($existingAPIKey) ) { // then try to get one. - $api = new wfAPI( '', wfUtils::getWPVersion() ); - try { - $keyData = $api->call( 'get_anon_api_key' ); - if ( $keyData['ok'] && $keyData['apiKey'] ) { - wfConfig::set( 'apiKey', $keyData['apiKey'] ); - wfConfig::set( 'isPaid', 0 ); - wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE); - wordfence::licenseStatusChanged(); - $result['apiKey'] = $apiKey = $keyData['apiKey']; - $result['isPaid'] = 0; - $reload = 'reload'; - } else { - throw new Exception("The Wordfence server's response did not contain the expected elements."); - } - } catch ( Exception $e ) { - $result['error'] = 'Your options have been saved, but you left your license key blank, so we tried to get you a free license key from the Wordfence servers. There was a problem fetching the free key: ' . wp_kses( $e->getMessage(), array() ); - return $result; - } - - } elseif ( ! empty( $apiKey ) && $existingAPIKey != $apiKey ) { - $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); - try { - $res = $api->call('check_api_key', array(), array( 'previousLicense' => $existingAPIKey )); - if ( $res['ok'] && isset( $res['isPaid'] ) ) { - -// wfConfig::set( 'apiKey', $apiKey ); -// wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. -// $result['apiKey'] = $apiKey; -// $result['isPaid'] = $res['isPaid']; -// if ( $res['isPaid'] ) { -// $result['paidKeyMsg'] = true; -// } - - $isPaid = wfUtils::truthyToBoolean($res['isPaid']); - wfConfig::set('apiKey', $apiKey); - wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. - wordfence::licenseStatusChanged(); - if ( ! $isPaid) { - wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE); - } - - $result['apiKey'] = $apiKey; - $result['isPaid'] = $isPaid; - if ( $isPaid ) { - $result['paidKeyMsg'] = true; - } - - $ping = true; - $reload = 'reload'; - } else { - throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' ); - } - } catch ( Exception $e ) { - $result['error'] = 'Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() ); - return $result; - } - } else { - $ping = true; - $apiKey = $existingAPIKey; + $api = new wfAPI( '', wfUtils::getWPVersion() ); + try { + $keyData = $api->call( 'get_anon_api_key' ); + if ( $keyData['ok'] && $keyData['apiKey'] ) { + wfConfig::set( 'apiKey', $keyData['apiKey'] ); + wfConfig::set( 'isPaid', 0 ); + wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE); + wordfence::licenseStatusChanged(); + $result['apiKey'] = $apiKey = $keyData['apiKey']; + $result['isPaid'] = 0; + $reload = 'reload'; + } else { + throw new Exception("The Wordfence server's response did not contain the expected elements."); + } + } catch ( Exception $e ) { + $result['error'] = 'Your options have been saved, but you left your license key blank, so we tried to get you a free license key from the Wordfence servers. There was a problem fetching the free key: ' . wp_kses( $e->getMessage(), array() ); + return $result; } - if ( $ping ) { + } elseif ( ! empty( $apiKey ) && $existingAPIKey != $apiKey ) { + $api = new wfAPI( $apiKey, wfUtils::getWPVersion() ); + try { + $res = $api->call('check_api_key', array(), array( 'previousLicense' => $existingAPIKey )); + if ( $res['ok'] && isset( $res['isPaid'] ) ) { - $api = new wfAPI($apiKey, wfUtils::getWPVersion()); - try { - $keyType = wfAPI::KEY_TYPE_FREE; - $keyData = $api->call('ping_api_key', array(), array( - 'supportHash' => wfConfig::get('supportHash', ''), - 'whitelistHash' => wfConfig::get('whitelistHash', ''), - )); - if (isset($keyData['_isPaidKey'])) { - $keyType = wfConfig::get('keyType'); - } - if (isset($keyData['dashboard'])) { - wfConfig::set('lastDashboardCheck', time()); - wfDashboard::processDashboardResponse($keyData['dashboard']); - } - if (isset($keyData['support']) && isset($keyData['supportHash'])) { - wfConfig::set('supportContent', $keyData['support']); - wfConfig::set('supportHash', $keyData['supportHash']); - } - if (isset($keyData['_whitelist']) && isset($keyData['_whitelistHash'])) { - wfConfig::setJSON('whitelistPresets', $keyData['_whitelist']); - wfConfig::set('whitelistHash', $keyData['_whitelistHash']); - } - if (isset($keyData['scanSchedule']) && is_array($keyData['scanSchedule'])) { - wfConfig::set_ser('noc1ScanSchedule', $keyData['scanSchedule']); - if (wfScanner::shared()->schedulingMode() == wfScanner::SCAN_SCHEDULING_MODE_AUTOMATIC) { - wfScanner::shared()->scheduleScans(); - } + // wfConfig::set( 'apiKey', $apiKey ); + // wfConfig::set( 'isPaid', $res['isPaid'] ); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. + // $result['apiKey'] = $apiKey; + // $result['isPaid'] = $res['isPaid']; + // if ( $res['isPaid'] ) { + // $result['paidKeyMsg'] = true; + // } + + $isPaid = wfUtils::truthyToBoolean($res['isPaid']); + wfConfig::set('apiKey', $apiKey); + wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools. + wordfence::licenseStatusChanged(); + if ( ! $isPaid) { + wfConfig::set('keyType', wfAPI::KEY_TYPE_FREE); } - wfConfig::set('keyType', $keyType); - - if ( ! isset($result['apiKey'])) { - $isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true; - $result['apiKey'] = $apiKey; - $result['isPaid'] = $isPaid; - if ( $isPaid ) { - $result['paidKeyMsg'] = true; - } + $result['apiKey'] = $apiKey; + $result['isPaid'] = $isPaid; + if ( $isPaid ) { + $result['paidKeyMsg'] = true; } - } catch ( Exception $e ) { - $result['error'] = 'Your options have been saved. However we tried to verify your license key with the Wordfence servers and received an error: ' . wp_kses($e->getMessage(), array()); - return $result; - } - } + $ping = true; + $reload = 'reload'; + } else { + throw new Exception( 'We could not understand the Wordfence API server reply when updating your API key.' ); + } + } catch ( Exception $e ) { + $result['error'] = 'Your options have been saved. However we noticed you changed your API key and we tried to verify it with the Wordfence servers and received an error: ' . htmlentities( $e->getMessage() ); + return $result; + } + } else { + $ping = true; + $apiKey = $existingAPIKey; + } + + if ( $ping ) { + + $api = new wfAPI($apiKey, wfUtils::getWPVersion()); + try { + $keyType = wfAPI::KEY_TYPE_FREE; + $keyData = $api->call('ping_api_key', array(), array( + 'supportHash' => wfConfig::get('supportHash', ''), + 'whitelistHash' => wfConfig::get('whitelistHash', ''), + )); + if (isset($keyData['_isPaidKey'])) { + $keyType = wfConfig::get('keyType'); + } + if (isset($keyData['dashboard'])) { + wfConfig::set('lastDashboardCheck', time()); + wfDashboard::processDashboardResponse($keyData['dashboard']); + } + if (isset($keyData['support']) && isset($keyData['supportHash'])) { + wfConfig::set('supportContent', $keyData['support']); + wfConfig::set('supportHash', $keyData['supportHash']); + } + if (isset($keyData['_whitelist']) && isset($keyData['_whitelistHash'])) { + wfConfig::setJSON('whitelistPresets', $keyData['_whitelist']); + wfConfig::set('whitelistHash', $keyData['_whitelistHash']); + } + if (isset($keyData['scanSchedule']) && is_array($keyData['scanSchedule'])) { + wfConfig::set_ser('noc1ScanSchedule', $keyData['scanSchedule']); + if (wfScanner::shared()->schedulingMode() == wfScanner::SCAN_SCHEDULING_MODE_AUTOMATIC) { + wfScanner::shared()->scheduleScans(); + } + } + + wfConfig::set('keyType', $keyType); + + if ( ! isset($result['apiKey'])) { + $isPaid = ( $keyType == wfAPI::KEY_TYPE_FREE ) ? false : true; + $result['apiKey'] = $apiKey; + $result['isPaid'] = $isPaid; + if ( $isPaid ) { + $result['paidKeyMsg'] = true; + } + } + + } catch ( Exception $e ) { + $result['error'] = 'Your options have been saved. However we tried to verify your license key with the Wordfence servers and received an error: ' . wp_kses($e->getMessage(), array()); + return $result; + } + } } $result['ok'] = 1; @@ -1785,57 +1785,57 @@ SQL return $return; } - public static function permanentlyBlockAllIPs() { - $return = wordfence::ajax_permanentlyBlockAllIPs_callback(); - return $return; - } + public static function permanentlyBlockAllIPs() { + $return = wordfence::ajax_permanentlyBlockAllIPs_callback(); + return $return; + } - public static function unlockOutIP() { - $return = wordfence::ajax_unlockOutIP_callback(); - return $return; - } + public static function unlockOutIP() { + $return = wordfence::ajax_unlockOutIP_callback(); + return $return; + } - public static function unblockRange() { - $return = wordfence::ajax_unblockRange_callback(); - return $return; - } + public static function unblockRange() { + $return = wordfence::ajax_unblockRange_callback(); + return $return; + } - public static function blockIPUARange() { - $return = wordfence::ajax_blockIPUARange_callback(); - return $return; - } + public static function blockIPUARange() { + $return = wordfence::ajax_blockIPUARange_callback(); + return $return; + } - public static function loadBlockRanges() { - $return = wordfence::ajax_loadBlockRanges_callback(); - return $return; - } + public static function loadBlockRanges() { + $return = wordfence::ajax_loadBlockRanges_callback(); + return $return; + } - public static function saveWAFConfig() { - $return = wordfence::ajax_saveWAFConfig_callback(); - if (is_array($return) && isset($return['data'])) { - $return['learningModeGracePeriod'] = wfWAF::getInstance()->getStorageEngine()->getConfig('learningModeGracePeriod'); - } - return $return; - } + public static function saveWAFConfig() { + $return = wordfence::ajax_saveWAFConfig_callback(); + if (is_array($return) && isset($return['data'])) { + $return['learningModeGracePeriod'] = wfWAF::getInstance()->getStorageEngine()->getConfig('learningModeGracePeriod'); + } + return $return; + } - public static function whitelistBulkDelete() { - $return = wordfence::ajax_whitelistBulkDelete_callback(); - return $return; - } + public static function whitelistBulkDelete() { + $return = wordfence::ajax_whitelistBulkDelete_callback(); + return $return; + } - public static function whitelistBulkEnable() { - $return = wordfence::ajax_whitelistBulkEnable_callback(); - return $return; - } + public static function whitelistBulkEnable() { + $return = wordfence::ajax_whitelistBulkEnable_callback(); + return $return; + } - public static function whitelistBulkDisable() { - $return = wordfence::ajax_whitelistBulkDisable_callback(); - return $return; - } - public static function updateConfig() { - $return = wordfence::ajax_updateConfig_callback(); - return $return; - } + public static function whitelistBulkDisable() { + $return = wordfence::ajax_whitelistBulkDisable_callback(); + return $return; + } + public static function updateConfig() { + $return = wordfence::ajax_updateConfig_callback(); + return $return; + } // credit of Wordfence private static function _getWAFData( $updated = null) { @@ -2416,7 +2416,7 @@ SQL $inEmail = false; ob_start(); -?> + ?>
    @@ -2432,7 +2432,7 @@ SQL } if ($inEmail) : - ?> + ?> @@ -2445,13 +2445,13 @@ SQL @@ -3053,19 +3053,19 @@ SQL + ?> - $readable) : - ?> + ?> - @@ -3148,9 +3148,9 @@ SQL public static function save_debugging_config() { $settings = $_POST['settings']; foreach (self::$diagnosticParams as $param) { - if (isset($settings[ $param ])) { - wfConfig::set( $param, $settings[ $param ] ); - } + if (isset($settings[ $param ])) { + wfConfig::set( $param, $settings[ $param ] ); + } } return array( 'ok' => 1 ); } diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index b67646c..b5c8afe 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -34,9 +34,9 @@ class MainWP_Child_WP_Rocket { } public function init() { -// if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) { -// return; -// } + // if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) { + // return; + // } if ( ! $this->is_plugin_installed ) { return; @@ -207,9 +207,9 @@ class MainWP_Child_WP_Rocket { if ( ! $this->is_plugin_installed ) { return false; } -// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) { -// return false; -// } + // if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) { + // return false; + // } return true; } @@ -252,7 +252,7 @@ class MainWP_Child_WP_Rocket { $information = array(); if ( isset( $_POST['mwp_action'] ) ) { -// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' ); + // MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' ); try { switch ( $_POST['mwp_action'] ) { case 'set_showhide': diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index 6689092..0a3dc8d 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -143,7 +143,7 @@ class MainWP_Child_WPvivid_BackupRestore { $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->prepare_backup($_POST['backup']); return $ret; - } + } public function backup_now() { global $wpvivid_plugin; @@ -164,112 +164,112 @@ class MainWP_Child_WPvivid_BackupRestore { $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_backup_schedule(); return $ret; - } + } public function get_backup_list() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_backup_list(); return $ret; - } + } public function get_default_remote() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_default_remote(); return $ret; - } + } public function delete_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']); return $ret; - } + } public function delete_backup_array() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->delete_backup_array($_POST['backup_id']); return $ret; - } + } public function set_security_lock() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']); return $ret; - } + } public function view_log() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->view_log($_POST['id']); return $ret; - } + } public function read_last_backup_log() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']); return $ret; - } + } public function view_backup_task_log() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->view_backup_task_log($_POST['id']); return $ret; - } + } public function backup_cancel() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->backup_cancel($_POST['task_id']); return $ret; - } + } public function init_download_page() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->init_download_page($_POST['backup_id']); return $ret; - } + } public function prepare_download_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']); return $ret; - } + } public function get_download_task() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->get_download_task($_POST['backup_id']); return $ret; - } + } public function download_backup() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']); return $ret; - } + } public function set_general_setting() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_general_setting($_POST['setting']); return $ret; - } + } public function set_schedule() { global $wpvivid_plugin; $wpvivid_plugin->ajax_check_security(); $ret = $this->public_intetface->set_schedule($_POST['schedule']); return $ret; - } + } public function set_remote() { global $wpvivid_plugin; diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 2cdf739..359afec 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -7,7 +7,7 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) { if (isset($_REQUEST['mainwpsignature'])) { @ini_set( 'display_errors', false ); @error_reporting( 0 ); -} + } } define( 'MAINWP_CHILD_NR_OF_COMMENTS', 50 ); @@ -213,7 +213,7 @@ class MainWP_Child { $this->load_all_options(); $this->filterFunction = function( $a) { if ($a == null) { -return false; } + return false; } if (is_object($a) && property_exists($a, 'last_checked') && ! property_exists($a, 'checked')) { return false; } @@ -330,7 +330,7 @@ return false; } $alloptions_db = $wpdb->get_results( $query ); $wpdb->suppress_errors($suppress); if ( ! is_array( $alloptions ) ) { -$alloptions = array(); + $alloptions = array(); } if ( is_array( $alloptions_db ) ) { foreach ( (array) $alloptions_db as $o ) { @@ -401,24 +401,24 @@ $alloptions = array(); 'mainwp_kwl_statistic_data_', 'mainwp_kwl_enable_statistic', 'mainwpKeywordLinks', -// 'mainwp_branding_ext_enabled', -// 'mainwp_branding_plugin_header', -// 'mainwp_branding_support_email', -// 'mainwp_branding_support_message', -// 'mainwp_branding_remove_restore', -// 'mainwp_branding_remove_setting', -// 'mainwp_branding_remove_wp_tools', -// 'mainwp_branding_remove_wp_setting', -// 'mainwp_branding_remove_permalink', -// 'mainwp_branding_button_contact_label', -// 'mainwp_branding_send_email_message', -// 'mainwp_branding_message_return_sender', -// 'mainwp_branding_submit_button_title', -// 'mainwp_branding_disable_wp_branding', -// 'mainwp_branding_extra_settings', -// 'mainwp_branding_child_hide', -// 'mainwp_branding_show_support', -// 'mainwp_branding_disable_change', + // 'mainwp_branding_ext_enabled', + // 'mainwp_branding_plugin_header', + // 'mainwp_branding_support_email', + // 'mainwp_branding_support_message', + // 'mainwp_branding_remove_restore', + // 'mainwp_branding_remove_setting', + // 'mainwp_branding_remove_wp_tools', + // 'mainwp_branding_remove_wp_setting', + // 'mainwp_branding_remove_permalink', + // 'mainwp_branding_button_contact_label', + // 'mainwp_branding_send_email_message', + // 'mainwp_branding_message_return_sender', + // 'mainwp_branding_submit_button_title', + // 'mainwp_branding_disable_wp_branding', + // 'mainwp_branding_extra_settings', + // 'mainwp_branding_child_hide', + // 'mainwp_branding_show_support', + // 'mainwp_branding_disable_change', ); foreach ( $options as $option ) { MainWP_Helper::fix_option( $option ); @@ -929,32 +929,32 @@ $alloptions = array(); + echo 'nav-tab-active'; } + ?> " tab-slug="" href="options-general.php?page="> + if ( '' != get_option( 'mainwp_child_uniqueId' ) ) { + echo 'checked'; } + ?> /> @@ -1563,9 +1563,9 @@ echo 'checked'; } //Call the function required if ( $auth && isset( $_POST['function'] ) && isset( $this->callableFunctions[ $_POST['function'] ] ) ) { define( 'DOING_CRON', true ); -// ob_start(); -// require_once( ABSPATH . 'wp-admin/admin.php' ); -// ob_end_clean(); + // ob_start(); + // require_once( ABSPATH . 'wp-admin/admin.php' ); + // ob_end_clean(); MainWP_Helper::handle_fatal_error(); self::fix_for_custom_themes(); @@ -2019,7 +2019,7 @@ echo 'checked'; } if ( isset( $_POST['type'] ) && 'plugin' === $_POST['type'] ) { include_once ABSPATH . '/wp-admin/includes/update.php'; if ( null !== $this->filterFunction ) { -// ET_Automatic_Updates + // ET_Automatic_Updates add_filter( 'pre_site_transient_update_plugins', $this->filterFunction, 99 ); } @@ -2105,17 +2105,17 @@ echo 'checked'; } } else { $information['upgrades'][ $plugin ] = true; // to fix logging update -// if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) { -// $plugin_info = $information['plugin_updates'][$plugin]; -// $args = array(); -// $args['type'] = 'plugin'; -// $args['slug'] = $plugin; -// $args['name'] = $plugin_info->Name; -// $args['version'] = $plugin_info->update->new_version; -// $args['old_version'] = $plugin_info->Version; -// $args['action'] = 'update'; -// //do_action( 'mainwp_child_upgradePluginTheme', $args ); -// } + // if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) { + // $plugin_info = $information['plugin_updates'][$plugin]; + // $args = array(); + // $args['type'] = 'plugin'; + // $args['slug'] = $plugin; + // $args['name'] = $plugin_info->Name; + // $args['version'] = $plugin_info->update->new_version; + // $args['old_version'] = $plugin_info->Version; + // $args['action'] = 'update'; + // //do_action( 'mainwp_child_upgradePluginTheme', $args ); + // } } } $failed = false; @@ -2162,8 +2162,8 @@ echo 'checked'; } add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 ); } -// $last_update = get_site_transient( 'update_themes' ); -// $originalLastChecked = !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ? $last_update->last_checked : 0; + // $last_update = get_site_transient( 'update_themes' ); + // $originalLastChecked = !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ? $last_update->last_checked : 0; @wp_update_themes(); include_once ABSPATH . '/wp-admin/includes/theme.php'; @@ -2202,12 +2202,12 @@ echo 'checked'; } $last_update2 = get_site_transient( 'update_themes' ); set_site_transient( 'update_themes', $last_update ); -// if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { -// $last_update->last_checked = $originalLastChecked; -// set_site_transient( 'update_themes', $last_update ); -// } + // if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { + // $last_update->last_checked = $originalLastChecked; + // set_site_transient( 'update_themes', $last_update ); + // } -// @wp_update_themes(); + // @wp_update_themes(); $failed = true; $upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) ); $result = $upgrader->bulk_upgrade( $themes ); @@ -2218,17 +2218,17 @@ echo 'checked'; } } else { $information['upgrades'][ $theme ] = true; // to fix logging update -// if (isset($information['theme_updates']) && isset($information['theme_updates'][$theme])) { -// $theme_info = $information['theme_updates'][$theme]; -// $args = array(); -// $args['type'] = 'theme'; -// $args['slug'] = $theme; -// $args['name'] = $theme_info['Name']; -// $args['version'] = $theme_info['update']['new_version']; -// $args['old_version'] = $theme_info['Version']; -// $args['action'] = 'update'; -// //do_action( 'mainwp_child_upgradePluginTheme', $args ); -// } + // if (isset($information['theme_updates']) && isset($information['theme_updates'][$theme])) { + // $theme_info = $information['theme_updates'][$theme]; + // $args = array(); + // $args['type'] = 'theme'; + // $args['slug'] = $theme; + // $args['name'] = $theme_info['Name']; + // $args['version'] = $theme_info['update']['new_version']; + // $args['old_version'] = $theme_info['Version']; + // $args['action'] = 'update'; + // //do_action( 'mainwp_child_upgradePluginTheme', $args ); + // } } } @@ -2257,13 +2257,13 @@ echo 'checked'; } remove_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ), 10 ); delete_site_transient( 'mainwp_update_themes_cached' ); // to fix cached update info -// $last_update = get_site_transient( 'update_themes' ); -// if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { -// $last_update->last_checked = $originalLastChecked; -// set_site_transient( 'update_themes', $last_update ); -// } + // $last_update = get_site_transient( 'update_themes' ); + // if ( !empty( $last_update ) && property_exists( $last_update, 'last_checked' ) ) { + // $last_update->last_checked = $originalLastChecked; + // set_site_transient( 'update_themes', $last_update ); + // } -// @wp_update_themes(); + // @wp_update_themes(); if ( count( $premiumThemes ) > 0 ) { $mwp_premium_updates = apply_filters( 'mwp_premium_perform_update', array() ); @@ -2724,19 +2724,19 @@ echo 'checked'; } if ( is_array($galleries) && isset($galleries['ids']) ) { $attached_images = explode( ',', $galleries['ids'] ); - foreach ( $attached_images as $attachment_id ) { - $attachment = get_post( $attachment_id ); - if ( $attachment ) { - $post_gallery_images[] = array( - 'id' => $attachment_id, - 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), - 'caption' => $attachment->post_excerpt, - 'description' => $attachment->post_content, - 'src' => $attachment->guid, - 'title' => $attachment->post_title, - ); - } - } + foreach ( $attached_images as $attachment_id ) { + $attachment = get_post( $attachment_id ); + if ( $attachment ) { + $post_gallery_images[] = array( + 'id' => $attachment_id, + 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), + 'caption' => $attachment->post_excerpt, + 'description' => $attachment->post_content, + 'src' => $attachment->guid, + 'title' => $attachment->post_title, + ); + } + } } require_once ABSPATH . 'wp-admin/includes/post.php'; @@ -2781,233 +2781,233 @@ echo 'checked'; } wp_update_user( $my_user ); } elseif ( 'edit' === $action ) { $user_data = $this->get_user_to_edit($userId); - if ( ! empty($user_data)) { - $information['user_data'] = $user_data; - } else { - $failed = true; - } + if ( ! empty($user_data)) { + $information['user_data'] = $user_data; + } else { + $failed = true; + } } elseif ( 'update_user' === $action ) { $my_user = $_POST['extra']; - if (is_array($my_user)) { - foreach ($my_user as $idx => $val) { - if ($val === 'donotupdate' || ( empty($val) && $idx !== 'role' )) { - unset($my_user[ $idx ]); - } - } - $result = $this->edit_user( $userId, $my_user ); - if (is_array($result) && isset($result['error'])) { - $information['error'] = $result['error']; - } - } else { - $failed = true; - } + if (is_array($my_user)) { + foreach ($my_user as $idx => $val) { + if ($val === 'donotupdate' || ( empty($val) && $idx !== 'role' )) { + unset($my_user[ $idx ]); + } + } + $result = $this->edit_user( $userId, $my_user ); + if (is_array($result) && isset($result['error'])) { + $information['error'] = $result['error']; + } + } else { + $failed = true; + } } else { $failed = true; } - if ($failed) { - $information['status'] = 'FAIL'; - } + if ($failed) { + $information['status'] = 'FAIL'; + } if ( ! isset( $information['status'] ) && ! isset($information['error']) ) { $information['status'] = 'SUCCESS'; - if ('update_user' === $action && isset($_POST['optimize']) && ! empty($_POST['optimize'])) { - $information['users'] = $this->get_all_users_int(500); // to fix - } + if ('update_user' === $action && isset($_POST['optimize']) && ! empty($_POST['optimize'])) { + $information['users'] = $this->get_all_users_int(500); // to fix + } } MainWP_Helper::write( $information ); } - function edit_user( $user_id, $data) { - $wp_roles = wp_roles(); - $user = new stdClass(); + function edit_user( $user_id, $data) { + $wp_roles = wp_roles(); + $user = new stdClass(); - $update = true; + $update = true; - if ( $user_id ) { - $user->ID = (int) $user_id; - $userdata = get_userdata( $user_id ); - $user->user_login = wp_slash( $userdata->user_login ); - } else { - return array( 'error' => 'ERROR: Empty user id.' ); - } + if ( $user_id ) { + $user->ID = (int) $user_id; + $userdata = get_userdata( $user_id ); + $user->user_login = wp_slash( $userdata->user_login ); + } else { + return array( 'error' => 'ERROR: Empty user id.' ); + } - $pass1 = $pass2 = ''; - if ( isset( $data['pass1'] ) ) { - $pass1 = $data['pass1']; - } - if ( isset( $data['pass2'] ) ) { - $pass2 = $data['pass2']; - } + $pass1 = $pass2 = ''; + if ( isset( $data['pass1'] ) ) { + $pass1 = $data['pass1']; + } + if ( isset( $data['pass2'] ) ) { + $pass2 = $data['pass2']; + } - if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) { - $new_role = sanitize_text_field( $data['role'] ); - $potential_role = isset($wp_roles->role_objects[ $new_role ]) ? $wp_roles->role_objects[ $new_role ] : false; - // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. - // Multisite super admins can freely edit their blog roles -- they possess all caps. - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ( $potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { - $user->role = $new_role; - } + if ( isset( $data['role'] ) && current_user_can( 'edit_users' ) ) { + $new_role = sanitize_text_field( $data['role'] ); + $potential_role = isset($wp_roles->role_objects[ $new_role ]) ? $wp_roles->role_objects[ $new_role ] : false; + // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. + // Multisite super admins can freely edit their blog roles -- they possess all caps. + if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ( $potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { + $user->role = $new_role; + } - // If the new role isn't editable by the logged-in user die with error - $editable_roles = get_editable_roles(); - if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) { - return array( 'error' => 'You can’t give users that role.' ); - } - } + // If the new role isn't editable by the logged-in user die with error + $editable_roles = get_editable_roles(); + if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) { + return array( 'error' => 'You can’t give users that role.' ); + } + } - $email = ''; - if ( isset( $data['email'] ) ) { - $email = trim( $data['email'] ); - } + $email = ''; + if ( isset( $data['email'] ) ) { + $email = trim( $data['email'] ); + } - if ( ! empty( $email ) ) { - $user->user_email = sanitize_text_field( wp_unslash( $email ) ); - } else { - $user->user_email = $userdata->user_email; - } + if ( ! empty( $email ) ) { + $user->user_email = sanitize_text_field( wp_unslash( $email ) ); + } else { + $user->user_email = $userdata->user_email; + } - if ( isset( $data['url'] ) ) { - if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) { - $user->user_url = ''; - } else { - $user->user_url = esc_url_raw( $data['url'] ); - $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); - $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url; - } - } + if ( isset( $data['url'] ) ) { + if ( empty ( $data['url'] ) || $data['url'] == 'http://' ) { + $user->user_url = ''; + } else { + $user->user_url = esc_url_raw( $data['url'] ); + $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); + $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url; + } + } - if ( isset( $data['first_name'] ) ) { - $user->first_name = sanitize_text_field( $data['first_name'] ); - } - if ( isset( $data['last_name'] ) ) { - $user->last_name = sanitize_text_field( $data['last_name'] ); - } - if ( isset( $data['nickname'] ) && ! empty($data['nickname'])) { - $user->nickname = sanitize_text_field( $data['nickname'] ); - } - if ( isset( $data['display_name'] ) ) { - $user->display_name = sanitize_text_field( $data['display_name'] ); - } - if ( isset( $data['description'] ) ) { - $user->description = trim( $data['description'] ); - } + if ( isset( $data['first_name'] ) ) { + $user->first_name = sanitize_text_field( $data['first_name'] ); + } + if ( isset( $data['last_name'] ) ) { + $user->last_name = sanitize_text_field( $data['last_name'] ); + } + if ( isset( $data['nickname'] ) && ! empty($data['nickname'])) { + $user->nickname = sanitize_text_field( $data['nickname'] ); + } + if ( isset( $data['display_name'] ) ) { + $user->display_name = sanitize_text_field( $data['display_name'] ); + } + if ( isset( $data['description'] ) ) { + $user->description = trim( $data['description'] ); + } - $errors = new WP_Error(); + $errors = new WP_Error(); - /* checking that username has been typed */ - if ( $user->user_login == '' ) { - $errors->add( 'user_login', __( 'ERROR: Please enter a username.' ) ); - } + /* checking that username has been typed */ + if ( $user->user_login == '' ) { + $errors->add( 'user_login', __( 'ERROR: Please enter a username.' ) ); + } - do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); + do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); - if ( ! empty($pass1) || ! empty($pass2)) { - // Check for blank password when adding a user. - if ( ! $update && empty( $pass1 ) ) { - $errors->add( 'pass', __( 'ERROR: Please enter a password.' ), array( 'form-field' => 'pass1' ) ); - } + if ( ! empty($pass1) || ! empty($pass2)) { + // Check for blank password when adding a user. + if ( ! $update && empty( $pass1 ) ) { + $errors->add( 'pass', __( 'ERROR: Please enter a password.' ), array( 'form-field' => 'pass1' ) ); + } - // Check for "\" in password. - if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) { - $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); - } + // Check for "\" in password. + if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) { + $errors->add( 'pass', __( 'ERROR: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); + } - // Checking the password has been typed twice the same. - if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) { - $errors->add( 'pass', __( 'ERROR: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); - } + // Checking the password has been typed twice the same. + if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) { + $errors->add( 'pass', __( 'ERROR: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); + } - if ( ! empty( $pass1 ) ) { - $user->user_pass = $pass1; - } - } else { - $user->user_pass = $userdata->user_pass; - } + if ( ! empty( $pass1 ) ) { + $user->user_pass = $pass1; + } + } else { + $user->user_pass = $userdata->user_pass; + } - /** This filter is documented in wp-includes/user.php */ - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); + /** This filter is documented in wp-includes/user.php */ + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); - if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) { - $errors->add( 'invalid_username', __( 'ERROR: Sorry, that username is not allowed.' ) ); - } + if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) { + $errors->add( 'invalid_username', __( 'ERROR: Sorry, that username is not allowed.' ) ); + } - /* checking email address */ - if ( empty( $user->user_email ) ) { - $errors->add( 'empty_email', __( 'ERROR: Please enter an email address.' ), array( 'form-field' => 'email' ) ); - } elseif ( ! is_email( $user->user_email ) ) { - $errors->add( 'invalid_email', __( 'ERROR: The email address isn’t correct.' ), array( 'form-field' => 'email' ) ); - } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( ! $update || ( $owner_id != $user->ID ) ) ) { - $errors->add( 'email_exists', __('ERROR: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); - } + /* checking email address */ + if ( empty( $user->user_email ) ) { + $errors->add( 'empty_email', __( 'ERROR: Please enter an email address.' ), array( 'form-field' => 'email' ) ); + } elseif ( ! is_email( $user->user_email ) ) { + $errors->add( 'invalid_email', __( 'ERROR: The email address isn’t correct.' ), array( 'form-field' => 'email' ) ); + } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( ! $update || ( $owner_id != $user->ID ) ) ) { + $errors->add( 'email_exists', __('ERROR: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); + } - do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); + do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); - if ( $errors->get_error_codes() ) { - $error_str = ''; - foreach ( $errors->get_error_messages() as $message ) { - if ( is_string( $message ) ) { - $error_str .= ' ' . esc_html( strip_tags( $message ) ); - } + if ( $errors->get_error_codes() ) { + $error_str = ''; + foreach ( $errors->get_error_messages() as $message ) { + if ( is_string( $message ) ) { + $error_str .= ' ' . esc_html( strip_tags( $message ) ); + } - } - return array( 'error' => $error_str ); - } + } + return array( 'error' => $error_str ); + } - $user_id = wp_update_user( $user ); + $user_id = wp_update_user( $user ); - return $user_id; - } + return $user_id; + } - function get_user_to_edit( $user_id ) { - require_once ABSPATH . 'wp-admin/includes/user.php'; - $profileuser = get_user_to_edit($user_id); + function get_user_to_edit( $user_id ) { + require_once ABSPATH . 'wp-admin/includes/user.php'; + $profileuser = get_user_to_edit($user_id); - $edit_data = array(); - if (is_object($profileuser)) { - $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); - $user_role = reset( $user_roles ); - $edit_data['role'] = $user_role; - $edit_data['first_name'] = $profileuser->first_name; - $edit_data['last_name'] = $profileuser->last_name; - $edit_data['nickname'] = $profileuser->nickname; + $edit_data = array(); + if (is_object($profileuser)) { + $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); + $user_role = reset( $user_roles ); + $edit_data['role'] = $user_role; + $edit_data['first_name'] = $profileuser->first_name; + $edit_data['last_name'] = $profileuser->last_name; + $edit_data['nickname'] = $profileuser->nickname; - $public_display = array(); - $public_display['display_nickname'] = $profileuser->nickname; - $public_display['display_username'] = $profileuser->user_login; + $public_display = array(); + $public_display['display_nickname'] = $profileuser->nickname; + $public_display['display_username'] = $profileuser->user_login; - if ( ! empty($profileuser->first_name) ) { - $public_display['display_firstname'] = $profileuser->first_name; - } + if ( ! empty($profileuser->first_name) ) { + $public_display['display_firstname'] = $profileuser->first_name; + } - if ( ! empty($profileuser->last_name) ) { - $public_display['display_lastname'] = $profileuser->last_name; - } + if ( ! empty($profileuser->last_name) ) { + $public_display['display_lastname'] = $profileuser->last_name; + } - if ( ! empty($profileuser->first_name) && ! empty($profileuser->last_name) ) { - $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; - $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; - } + if ( ! empty($profileuser->first_name) && ! empty($profileuser->last_name) ) { + $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; + $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; + } - if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere - $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; - } + if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere + $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; + } - $public_display = array_map( 'trim', $public_display ); - $public_display = array_unique( $public_display ); + $public_display = array_map( 'trim', $public_display ); + $public_display = array_unique( $public_display ); - $edit_data['public_display'] = $public_display; - $edit_data['display_name'] = $profileuser->display_name; - $edit_data['user_email'] = $profileuser->user_email; - $edit_data['user_url'] = $profileuser->user_url; - foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { - $edit_data['contact_methods'][ $name ] = $profileuser->$name; - } - $edit_data['description'] = $profileuser->description; - } - return $edit_data; - } + $edit_data['public_display'] = $public_display; + $edit_data['display_name'] = $profileuser->display_name; + $edit_data['user_email'] = $profileuser->user_email; + $edit_data['user_url'] = $profileuser->user_url; + foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { + $edit_data['contact_methods'][ $name ] = $profileuser->$name; + } + $edit_data['description'] = $profileuser->description; + } + return $edit_data; + } //todo: backwards compatible: wp_set_comment_status ? function comment_action() { @@ -3858,8 +3858,8 @@ echo 'checked'; } // to fix for some premiums update info if ( property_exists( $plugin_update, 'update' ) ) { if ( ! property_exists( $plugin_update->update, 'new_version' ) || empty( $plugin_update->update->new_version ) ) { - continue; - } + continue; + } } else { continue; } @@ -4112,9 +4112,9 @@ echo 'checked'; } $favi = ''; // to compatible $site_url = get_option( 'siteurl' ); - if ( substr( $site_url, - 1 ) != '/' ) { - $site_url .= '/'; - } + if ( substr( $site_url, - 1 ) != '/' ) { + $site_url .= '/'; + } if ( function_exists( 'get_site_icon_url' ) && has_site_icon() ) { $favi = $favi_url = get_site_icon_url(); @@ -4138,28 +4138,28 @@ echo 'checked'; } $request = wp_remote_get( $site_url, array( 'timeout' => 50 ) ); $favi = ''; if ( is_array( $request ) && isset( $request['body'] ) ) { - // to fix bug - $preg_str1 = '/(]*)(?:rel="shortcut\s+icon"\s*)(?:[^>]*)?href="([^"]+)"(?:[^>]*)?>)/is'; - $preg_str2 = '/(]*)(?:rel="(?:shortcut\s+)?icon"\s*)(?:[^>]*)?href="([^"]+)"(?:[^>]*)?>)/is'; + // to fix bug + $preg_str1 = '/(]*)(?:rel="shortcut\s+icon"\s*)(?:[^>]*)?href="([^"]+)"(?:[^>]*)?>)/is'; + $preg_str2 = '/(]*)(?:rel="(?:shortcut\s+)?icon"\s*)(?:[^>]*)?href="([^"]+)"(?:[^>]*)?>)/is'; - if ( preg_match( $preg_str1, $request['body'], $matches ) ) { - $favi = $matches[2]; - } elseif ( preg_match( $preg_str2, $request['body'], $matches ) ) { - $favi = $matches[2]; - } + if ( preg_match( $preg_str1, $request['body'], $matches ) ) { + $favi = $matches[2]; + } elseif ( preg_match( $preg_str2, $request['body'], $matches ) ) { + $favi = $matches[2]; + } } if ( ! empty( $favi ) ) { if ( false === strpos( $favi, 'http' )) { - if (0 === strpos( $favi, '//' )) { - if (0 === strpos( $site_url, 'https' )) { - $favi_url = 'https:' . $favi; - } else { - $favi_url = 'http:' . $favi; - } - } else { + if (0 === strpos( $favi, '//' )) { + if (0 === strpos( $site_url, 'https' )) { + $favi_url = 'https:' . $favi; + } else { + $favi_url = 'http:' . $favi; + } + } else { $favi_url = $site_url . $favi; - } + } } else { $favi_url = $favi; } @@ -4294,13 +4294,13 @@ echo 'checked'; } * The code is used for the MainWP WordPress SEO Extension * Extension URL: https://mainwp.com/extension/wordpress-seo/ * - */ + */ $wp_seo_enabled = false; if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled']) { - if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta')) { + if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta')) { $wp_seo_enabled = true; - } + } } $posts = get_posts( $args ); @@ -4987,9 +4987,9 @@ echo 'checked'; } } } } - if ($return) { - return $allusers; - } + if ($return) { + return $allusers; + } MainWP_Helper::write( $allusers ); } @@ -5056,11 +5056,11 @@ echo 'checked'; } ) ); if ( ! empty( $user_query->results ) ) { foreach ( $user_query->results as $new_user ) { - if ($check_users_role) { - if ( ! in_array($new_user->ID, $search_user_role )) { - continue; - } - } + if ($check_users_role) { + if ( ! in_array($new_user->ID, $search_user_role )) { + continue; + } + } $exclude[] = $new_user->ID; $usr = array(); $usr['id'] = $new_user->ID; @@ -5201,34 +5201,34 @@ echo 'checked'; } function getTotalFileSize( $directory = WP_CONTENT_DIR ) { try { -// function continueFileSize( $dir, $limit ) { -// $dirs = array( $dir ); -// $cnt = 0; -// while ( isset( $dirs[0] ) ) { -// $path = array_shift( $dirs ); -// if ( stristr( $path, WP_CONTENT_DIR . '/uploads/mainwp' ) ) { -// continue; -// } -// $uploadDir = MainWP_Helper::getMainWPDir(); -// $uploadDir = $uploadDir[0]; -// if ( stristr( $path, $uploadDir ) ) { -// continue; -// } -// $res = @glob( $path . '/*' ); -// if ( is_array( $res ) ) { -// foreach ( $res as $next ) { -// if ( is_dir( $next ) ) { -// $dirs[] = $next; -// } else { -// if ($cnt++ > $limit) return false;; -// } -// } -// } -// } -// return true; -// } -// -// if ( !continueFilesize( $directory, 20000 ) ) return 0; + // function continueFileSize( $dir, $limit ) { + // $dirs = array( $dir ); + // $cnt = 0; + // while ( isset( $dirs[0] ) ) { + // $path = array_shift( $dirs ); + // if ( stristr( $path, WP_CONTENT_DIR . '/uploads/mainwp' ) ) { + // continue; + // } + // $uploadDir = MainWP_Helper::getMainWPDir(); + // $uploadDir = $uploadDir[0]; + // if ( stristr( $path, $uploadDir ) ) { + // continue; + // } + // $res = @glob( $path . '/*' ); + // if ( is_array( $res ) ) { + // foreach ( $res as $next ) { + // if ( is_dir( $next ) ) { + // $dirs[] = $next; + // } else { + // if ($cnt++ > $limit) return false;; + // } + // } + // } + // } + // return true; + // } + // + // if ( !continueFilesize( $directory, 20000 ) ) return 0; if ( MainWP_Helper::function_exists( 'popen' ) ) { $uploadDir = MainWP_Helper::getMainWPDir(); @@ -5280,36 +5280,36 @@ echo 'checked'; } } } -// function dirsize( $dir ) { -// $dirs = array( $dir ); -// $size = 0; -// while ( isset( $dirs[0] ) ) { -// $path = array_shift( $dirs ); -// if ( stristr( $path, WP_CONTENT_DIR . '/uploads/mainwp' ) ) { -// continue; -// } -// $uploadDir = MainWP_Helper::getMainWPDir(); -// $uploadDir = $uploadDir[0]; -// if ( stristr( $path, $uploadDir ) ) { -// continue; -// } -// $res = @glob( $path . '/*' ); -// if ( is_array( $res ) ) { -// foreach ( $res as $next ) { -// if ( is_dir( $next ) ) { -// $dirs[] = $next; -// } else { -// $fs = filesize( $next ); -// $size += $fs; -// } -// } -// } -// } -// -// return $size / 1024 / 1024; -// } -// -// return dirsize( $directory ); + // function dirsize( $dir ) { + // $dirs = array( $dir ); + // $size = 0; + // while ( isset( $dirs[0] ) ) { + // $path = array_shift( $dirs ); + // if ( stristr( $path, WP_CONTENT_DIR . '/uploads/mainwp' ) ) { + // continue; + // } + // $uploadDir = MainWP_Helper::getMainWPDir(); + // $uploadDir = $uploadDir[0]; + // if ( stristr( $path, $uploadDir ) ) { + // continue; + // } + // $res = @glob( $path . '/*' ); + // if ( is_array( $res ) ) { + // foreach ( $res as $next ) { + // if ( is_dir( $next ) ) { + // $dirs[] = $next; + // } else { + // $fs = filesize( $next ); + // $size += $fs; + // } + // } + // } + // } + // + // return $size / 1024 / 1024; + // } + // + // return dirsize( $directory ); return 0; } catch ( Exception $e ) { return 0; @@ -5379,17 +5379,17 @@ echo 'checked'; } $maint_options = array(); } -// $this->options = array( -// 'revisions' => __( 'Delete all post revisions', 'mainwp-maintenance-extension' ), -// 'autodraft' => __( 'Delete all auto draft posts', 'mainwp-maintenance-extension' ), -// 'trashpost' => __( 'Delete trash posts', 'mainwp-maintenance-extension' ), -// 'spam' => __( 'Delete spam comments', 'mainwp-maintenance-extension' ), -// 'pending' => __( 'Delete pending comments', 'mainwp-maintenance-extension' ), -// 'trashcomment' => __( 'Delete trash comments', 'mainwp-maintenance-extension' ), -// 'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-maintenance-extension' ), -// 'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-maintenance-extension' ), -// 'optimize' => __( 'Optimize database tables', 'mainwp-maintenance-extension' ) -// ); + // $this->options = array( + // 'revisions' => __( 'Delete all post revisions', 'mainwp-maintenance-extension' ), + // 'autodraft' => __( 'Delete all auto draft posts', 'mainwp-maintenance-extension' ), + // 'trashpost' => __( 'Delete trash posts', 'mainwp-maintenance-extension' ), + // 'spam' => __( 'Delete spam comments', 'mainwp-maintenance-extension' ), + // 'pending' => __( 'Delete pending comments', 'mainwp-maintenance-extension' ), + // 'trashcomment' => __( 'Delete trash comments', 'mainwp-maintenance-extension' ), + // 'tags' => __( 'Delete tags with 0 posts associated', 'mainwp-maintenance-extension' ), + // 'categories' => __( 'Delete categories with 0 posts associated', 'mainwp-maintenance-extension' ), + // 'optimize' => __( 'Optimize database tables', 'mainwp-maintenance-extension' ) + // ); $performed_what = array(); if ( empty( $max_revisions ) ) { diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 309513d..e44ffaf 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -281,10 +281,10 @@ class MainWP_Clone { is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) { - echo '
    ' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')
    '; - $error = true; - } + if ( ( ! empty( $wp_filesystem ) && ! $wp_filesystem->is_writable( WP_CONTENT_DIR ) ) || ( empty( $wp_filesystem ) && ! is_writable( WP_CONTENT_DIR ) ) ) { + echo '
    ' . esc_html__( 'Your content directory is not writable. Please set 0755 permission to ', 'mainwp-child' ) . esc_html( basename( WP_CONTENT_DIR ) ) . '. (' . esc_html( WP_CONTENT_DIR ) . ')
    '; + $error = true; + } ?> getSecurityNonces(); - foreach ($security_nonces as $k => $v) { - echo 'child_security_nonces[' . "'" . $k . "'" . '] = ' . "'" . $v . "';\n"; - } + foreach ($security_nonces as $k => $v) { + echo 'child_security_nonces[' . "'" . $k . "'" . '] = ' . "'" . $v . "';\n"; + } ?> mainwpchild_secure_data = function(data, includeDts) @@ -1575,10 +1575,10 @@ class MainWP_Clone { + } + ?> . diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php index 0849858..3a4ee40 100755 --- a/class/class-mainwp-custom-post-type.php +++ b/class/class-mainwp-custom-post-type.php @@ -20,10 +20,10 @@ class MainWP_Custom_Post_Type { $error = error_get_last(); if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { $data = array( 'error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ); -// die( '' . base64_encode( serialize( ) ) . '' ); + // die( '' . base64_encode( serialize( ) ) . '' ); } else { $data = self::$information; -// die( '' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '' ); + // die( '' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '' ); } if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] ) { diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 76ccd56..37cf97b 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -108,7 +108,7 @@ class MainWP_Helper { if ( ! empty($selector)) { if ( ! isset($new[ $selector ])) { -$new[ $selector ] = array(); + $new[ $selector ] = array(); } $rules = explode(';', $val[ ++$i ]); foreach ($rules as $rule) { @@ -119,9 +119,9 @@ $new[ $selector ] = array(); $value = implode(':', array_reverse($rule)); if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ])) { -$new[ $selector ][ $property ] = $value; + $new[ $selector ][ $property ] = $value; } elseif (preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value)) { -$new[ $selector ][ $property ] = $value; + $new[ $selector ][ $property ] = $value; } } } @@ -137,7 +137,7 @@ $new[ $selector ][ $property ] = $value; $output .= $media . " {\n"; $prefix = "\t"; } else { -$prefix = ''; + $prefix = ''; } foreach ($content as $selector => $rules) { @@ -413,9 +413,9 @@ $prefix = ''; $new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp ); //$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; } -// else { -// $new_post['post_status'] = 'publish'; -// } + // else { + // $new_post['post_status'] = 'publish'; + // } } $wpr_options = isset( $_POST['wpr_options'] ) ? $_POST['wpr_options'] : array(); @@ -476,12 +476,12 @@ $prefix = ''; $new_post['post_content'] = str_replace( $serverHref, $replaceServerHref, $new_post['post_content'] ); } // To fix bug -// else if ( strpos( $hrefLink, 'http' ) !== false ) { -// $lnkToReplace = dirname( $hrefLink ); -// if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { -// $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] ); -// } -// } + // else if ( strpos( $hrefLink, 'http' ) !== false ) { + // $lnkToReplace = dirname( $hrefLink ); + // if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { + // $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] ); + // } + // } } $lnkToReplace = dirname( $imgUrl ); if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) { @@ -563,8 +563,8 @@ $prefix = ''; } $random_timestamp = rand( $random_date_from, $random_date_to ); -// $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; -// $new_post['post_status'] = $post_status; + // $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future'; + // $new_post['post_status'] = $post_status; $new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp ); } } @@ -599,10 +599,10 @@ $prefix = ''; } if ( ! $edit_post_id ) { - wp_update_post( array( - 'ID' => $new_post_id, - 'post_status' => $post_status, - ) ); + wp_update_post( array( + 'ID' => $new_post_id, + 'post_status' => $post_status, + ) ); } if ( ! empty( $terms ) ) { @@ -658,33 +658,33 @@ $prefix = ''; if (is_array($post_custom)) { foreach ( $post_custom as $meta_key => $meta_values ) { - if ( ! in_array( $meta_key, $not_allowed ) ) { - foreach ( $meta_values as $meta_value ) { - if (strpos($meta_key, '_mainwp_spinner_') === 0) { - continue; // not save - } + if ( ! in_array( $meta_key, $not_allowed ) ) { + foreach ( $meta_values as $meta_value ) { + if (strpos($meta_key, '_mainwp_spinner_') === 0) { + continue; // not save + } - if ( ! $seo_ext_activated ) { - // if WordPress SEO plugin is not activated do not save yoast post meta - if ( strpos( $meta_key, '_yoast_wpseo_' ) === false ) { + if ( ! $seo_ext_activated ) { + // if WordPress SEO plugin is not activated do not save yoast post meta + if ( strpos( $meta_key, '_yoast_wpseo_' ) === false ) { + update_post_meta( $new_post_id, $meta_key, $meta_value ); + } + } else { update_post_meta( $new_post_id, $meta_key, $meta_value ); } - } else { - update_post_meta( $new_post_id, $meta_key, $meta_value ); } - } - } elseif ( '_sticky' === $meta_key ) { - foreach ( $meta_values as $meta_value ) { - if ( 'sticky' === base64_decode( $meta_value ) ) { - stick_post( $new_post_id ); + } elseif ( '_sticky' === $meta_key ) { + foreach ( $meta_values as $meta_value ) { + if ( 'sticky' === base64_decode( $meta_value ) ) { + stick_post( $new_post_id ); + } + } + } elseif ( '_post_to_only_existing_categories' === $meta_key ) { + if ( isset( $meta_values[0] ) && $meta_values[0] ) { + $post_to_only_existing_categories = true; } - } - } elseif ( '_post_to_only_existing_categories' === $meta_key ) { - if ( isset( $meta_values[0] ) && $meta_values[0] ) { - $post_to_only_existing_categories = true; } } - } } // yoast seo extension @@ -949,9 +949,9 @@ $prefix = ''; if ( empty( $wp_filesystem ) ) { ob_start(); -// if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) { -// include_once( ABSPATH . '/wp-admin/includes/deprecated.php' ); -// } + // if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) { + // include_once( ABSPATH . '/wp-admin/includes/deprecated.php' ); + // } if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { include_once ABSPATH . '/wp-admin/includes/screen.php'; } @@ -1451,34 +1451,34 @@ $prefix = ''; * Credit to the : wp-filters-extras */ -static function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) { + static function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) { - global $wp_filter; - // Take only filters on right hook name and priority - if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) { - return false; - } - // Loop on filters registered - foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) { - // Test if filter is an array ! (always for class/method) - if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) { - // Test if object is a class and method is equal to param ! - if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && $filter_array['function'][1] == $method_name ) { - // Test for WordPress >= 4.7 WP_Hook class - if ( is_a( $wp_filter[ $hook_name ], 'WP_Hook' ) ) { - unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] ); - } else { - unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] ); + global $wp_filter; + // Take only filters on right hook name and priority + if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) { + return false; + } + // Loop on filters registered + foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) { + // Test if filter is an array ! (always for class/method) + if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) { + // Test if object is a class and method is equal to param ! + if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && $filter_array['function'][1] == $method_name ) { + // Test for WordPress >= 4.7 WP_Hook class + if ( is_a( $wp_filter[ $hook_name ], 'WP_Hook' ) ) { + unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] ); + } else { + unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] ); + } } } } + return false; } - return false; -} public static function sanitize_filename( $filename ) { if ( ! function_exists('mb_ereg_replace')) { -return sanitize_file_name($filename); + return sanitize_file_name($filename); } // Remove anything which isn't a word, whitespace, number @@ -1551,7 +1551,7 @@ return sanitize_file_name($filename); public static function isSSLEnabled() { if ( defined( 'MAINWP_NOSSL' ) ) { -return ! MAINWP_NOSSL; + return ! MAINWP_NOSSL; } return function_exists( 'openssl_verify' ); } @@ -1579,132 +1579,132 @@ return ! MAINWP_NOSSL; public static function check_files_exists( $files = array(), $return = false ) { $missing = array(); - if (is_array($files)) { - foreach ($files as $name) { - if ( ! file_exists( $name )) { - $missing[] = $name; - } - } - } else { - if ( ! file_exists( $files )) { - $missing[] = $files; - } - } + if (is_array($files)) { + foreach ($files as $name) { + if ( ! file_exists( $name )) { + $missing[] = $name; + } + } + } else { + if ( ! file_exists( $files )) { + $missing[] = $files; + } + } - if ( ! empty($missing)) { - $message = 'Missing file(s): ' . implode(',', $missing); - if ($return) { - return $message; - } else { - throw new Exception( $message ); - } - } + if ( ! empty($missing)) { + $message = 'Missing file(s): ' . implode(',', $missing); + if ($return) { + return $message; + } else { + throw new Exception( $message ); + } + } return true; } public static function check_classes_exists( $classes = array(), $return = false) { $missing = array(); - if (is_array($classes)) { - foreach ($classes as $name) { - if ( ! class_exists( $name )) { - $missing[] = $name; - } - } - } else { - if ( ! class_exists($classes) ) { - $missing[] = $classes; - } - } + if (is_array($classes)) { + foreach ($classes as $name) { + if ( ! class_exists( $name )) { + $missing[] = $name; + } + } + } else { + if ( ! class_exists($classes) ) { + $missing[] = $classes; + } + } - if ( ! empty($missing) ) { - $message = 'Missing classes: ' . implode(',', $missing); - if ($return) { - return $message; - } else { - throw new Exception( $message ); - } - } + if ( ! empty($missing) ) { + $message = 'Missing classes: ' . implode(',', $missing); + if ($return) { + return $message; + } else { + throw new Exception( $message ); + } + } return true; } public static function check_methods( $object, $methods = array(), $return = false) { $missing = array(); - if (is_array($methods)) { - $missing = array(); - foreach ($methods as $name) { - if ( ! method_exists($object, $name) ) { - $missing[] = $name; - } - } - } elseif ( ! empty($methods)) { - if ( ! method_exists($object, $methods) ) { - $missing[] = $methods; - } + if (is_array($methods)) { + $missing = array(); + foreach ($methods as $name) { + if ( ! method_exists($object, $name) ) { + $missing[] = $name; + } + } + } elseif ( ! empty($methods)) { + if ( ! method_exists($object, $methods) ) { + $missing[] = $methods; + } - } + } - if ( ! empty($missing) ) { - $message = 'Missing method: ' . implode(',', $missing); - if ($return) { - return $message; - } else { - throw new Exception( $message ); - } - } + if ( ! empty($missing) ) { + $message = 'Missing method: ' . implode(',', $missing); + if ($return) { + return $message; + } else { + throw new Exception( $message ); + } + } return true; } public static function check_properties( $object, $properties = array(), $return = false) { $missing = array(); - if (is_array($properties)) { - foreach ($properties as $name) { - if ( ! property_exists($object, $name) ) { - $missing[] = $name; - } - } - } elseif ( ! empty($properties)) { - if ( ! property_exists($object, $properties) ) { - $missing[] = $properties; - } + if (is_array($properties)) { + foreach ($properties as $name) { + if ( ! property_exists($object, $name) ) { + $missing[] = $name; + } + } + } elseif ( ! empty($properties)) { + if ( ! property_exists($object, $properties) ) { + $missing[] = $properties; + } - } + } - if ( ! empty($missing) ) { - $message = 'Missing properties: ' . implode(',', $missing); - if ($return) { - return $message; - } else { - throw new Exception( $message ); - } - } + if ( ! empty($missing) ) { + $message = 'Missing properties: ' . implode(',', $missing); + if ($return) { + return $message; + } else { + throw new Exception( $message ); + } + } return true; } public static function check_functions( $funcs = array(), $return = false) { $missing = array(); - if (is_array($funcs)) { - foreach ($funcs as $name) { - if ( ! function_exists( $name) ) { - $missing[] = $name; - } - } - } elseif ( ! empty($funcs)) { - if ( ! function_exists($funcs) ) { - $missing[] = $funcs; - } + if (is_array($funcs)) { + foreach ($funcs as $name) { + if ( ! function_exists( $name) ) { + $missing[] = $name; + } + } + } elseif ( ! empty($funcs)) { + if ( ! function_exists($funcs) ) { + $missing[] = $funcs; + } - } + } - if ( ! empty($missing) ) { - $message = 'Missing functions: ' . implode(',', $missing); - if ($return) { - return $message; - } else { - throw new Exception( $message ); - } - } + if ( ! empty($missing) ) { + $message = 'Missing functions: ' . implode(',', $missing); + if ($return) { + return $message; + } else { + throw new Exception( $message ); + } + } return true; } @@ -1724,7 +1724,7 @@ return ! MAINWP_NOSSL; if ( isset( $error['type'] ) && isset( $error['message'] ) && ( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] ) ) { - self::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); + self::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); } } diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index cb07009..d716092 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -353,7 +353,7 @@ class MainWP_Security { public static function admin_user_ok() { $user = get_user_by( 'login', 'admin' ); if ( ! $user ) { -return true; + return true; } if ( 10 !== $user->wp_user_level && ( ! isset( $user->user_level ) || 10 !== $user->user_level ) && ! user_can( $user, 'level_10' ) ) { diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index 4f6beba..771a0b4 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -86,24 +86,24 @@ class MainWP_Wordpress_SEO { if ( is_array( $options ) && array() !== $options ) { $old_wpseo_version = null; - if ( isset( $options['wpseo']['version'] ) && '' !== $options['wpseo']['version'] ) { - $old_wpseo_version = $options['wpseo']['version']; - } - foreach ( $options as $name => $optgroup ) { - if ( 'wpseo_taxonomy_meta' === $name ) { - $optgroup = json_decode( urldecode( $optgroup['wpseo_taxonomy_meta'] ), true ); - } - // Make sure that the imported options are cleaned/converted on import - $option_instance = WPSEO_Options::get_option_instance( $name ); - if ( is_object( $option_instance ) && method_exists( $option_instance, 'import' ) ) { - $optgroup = $option_instance->import( $optgroup, $old_wpseo_version, $options ); - } - } + if ( isset( $options['wpseo']['version'] ) && '' !== $options['wpseo']['version'] ) { + $old_wpseo_version = $options['wpseo']['version']; + } + foreach ( $options as $name => $optgroup ) { + if ( 'wpseo_taxonomy_meta' === $name ) { + $optgroup = json_decode( urldecode( $optgroup['wpseo_taxonomy_meta'] ), true ); + } + // Make sure that the imported options are cleaned/converted on import + $option_instance = WPSEO_Options::get_option_instance( $name ); + if ( is_object( $option_instance ) && method_exists( $option_instance, 'import' ) ) { + $optgroup = $option_instance->import( $optgroup, $old_wpseo_version, $options ); + } + } $information['success'] = true; - } else { - throw new Exception( __( 'Settings could not be imported:', 'wordpress-seo' ) ); - } + } else { + throw new Exception( __( 'Settings could not be imported:', 'wordpress-seo' ) ); + } } catch ( Exception $e ) { $information['error'] = $e->getMessage(); } From d483eefd3a28cf714b158ecdc8839bae4702126e Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 19:53:21 +0000 Subject: [PATCH 92/98] [CodeFactor] Apply fixes to commit ef3192b [ci skip] [skip ci] --- .../class-mainwp-child-woocommerce-status.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 9dbd5aa..4724946 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -81,9 +81,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= %s @@ -103,9 +103,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' @@ -202,9 +202,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') @@ -224,9 +224,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' From 2570117255a5c5cae61e83d16797886c790b44aa Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 19:54:05 +0000 Subject: [PATCH 93/98] [CodeFactor] Apply fixes to commit 5033b57 [ci skip] [skip ci] --- .../class-mainwp-child-woocommerce-status.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 4724946..9dbd5aa 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -81,9 +81,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= %s @@ -103,9 +103,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' @@ -202,9 +202,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') @@ -224,9 +224,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' From 794f4e57965818c3a8d43a4f669fc2b87e0e2669 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 19:55:26 +0000 Subject: [PATCH 94/98] [CodeFactor] Apply fixes to commit 2b5b713 [ci skip] [skip ci] --- .../class-mainwp-child-woocommerce-status.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 9dbd5aa..4724946 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -81,9 +81,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= %s @@ -103,9 +103,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' @@ -202,9 +202,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND postmeta.meta_key = '_order_total' AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') @@ -224,9 +224,9 @@ class MainWP_Child_WooCommerce_Status { AND posts.post_status = 'publish' AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( - 'completed', - 'processing', - 'on-hold', + 'completed', + 'processing', + 'on-hold', ) ) ) . "' ) AND order_item_meta.meta_key = '_qty' AND order_item_meta_2.meta_key = '_product_id' From 6b31a10814c2e2d2f16e29fbdbf363bd9ec8f5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 26 Mar 2020 20:57:55 +0100 Subject: [PATCH 95/98] Update phpcs.xml --- phpcs.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index fb85f3c..8ff4610 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -34,7 +34,6 @@ - From 908e352467723e4ed6a13ea407715bf338632cf7 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 26 Mar 2020 20:01:04 +0000 Subject: [PATCH 96/98] [CodeFactor] Apply fixes to commit 6b31a10 [ci skip] [skip ci] --- class/class-mainwp-backup.php | 28 +- class/class-mainwp-child-back-up-buddy.php | 46 +- .../class-mainwp-child-back-up-wordpress.php | 16 +- class/class-mainwp-child-back-wp-up.php | 20 +- class/class-mainwp-child-branding.php | 85 ++- class/class-mainwp-child-db.php | 2 +- class/class-mainwp-child-ithemes-security.php | 58 +- class/class-mainwp-child-links-checker.php | 46 +- class/class-mainwp-child-pagespeed.php | 28 +- class/class-mainwp-child-plugins-check.php | 98 +-- .../class-mainwp-child-server-information.php | 4 +- class/class-mainwp-child-skeleton-key.php | 10 +- class/class-mainwp-child-staging.php | 4 +- class/class-mainwp-child-themes-check.php | 36 +- class/class-mainwp-child-timecapsule.php | 40 +- ...lass-mainwp-child-updraft-plus-backups.php | 304 ++++----- class/class-mainwp-child-wordfence.php | 144 ++-- class/class-mainwp-child-wp-rocket.php | 26 +- class/class-mainwp-child.php | 626 +++++++++--------- class/class-mainwp-clone-install.php | 24 +- class/class-mainwp-clone.php | 40 +- class/class-mainwp-custom-post-type.php | 8 +- class/class-mainwp-debug.php | 2 +- class/class-mainwp-helper.php | 82 +-- class/class-mainwp-keyword-links.php | 122 ++-- class/class-mainwp-security.php | 214 +++--- class/class-mainwp-wordpress-seo.php | 2 +- class/class-tar-archiver.php | 116 ++-- mainwp-child.php | 2 +- 29 files changed, 1115 insertions(+), 1118 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 9a076c4..20e21d2 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -69,7 +69,7 @@ class MainWP_Backup { } if ( ( false !== $fileSuffix ) && ! empty( $fileSuffix ) ) { - //Append already contains extension! + // Append already contains extension! $file = $fileSuffix . ( true === $append ? '' : $ext ); } else { $file = 'backup-' . $filePrefix . $timestamp . $ext; @@ -157,7 +157,7 @@ class MainWP_Backup { } public function _zipFilePcl( $files, $archive ) { - //Zip this backup folder.. + // Zip this backup folder.. require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $archive ); @@ -469,16 +469,16 @@ class MainWP_Backup { } public function createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) { - //Create backup folder + // Create backup folder $backupFolder = dirname( $filepath ) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR; // @codingStandardsIgnoreStart @mkdir( $backupFolder ); // @codingStandardsIgnoreEnd - //Create DB backup + // Create DB backup $db_files = $this->createBackupDB( $backupFolder . 'dbBackup' ); - //Copy installation to backup folder + // Copy installation to backup folder $nodes = glob( ABSPATH . '*' ); if ( ! $includeCoreFiles ) { $coreFiles = array( @@ -530,7 +530,7 @@ class MainWP_Backup { // @codingStandardsIgnoreEnd unset( $nodes ); - //Zip this backup folder.. + // Zip this backup folder.. require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $this->zip = new PclZip( $filepath ); $this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder ); @@ -546,7 +546,7 @@ class MainWP_Backup { $this->addFileFromStringToPCLZip( 'clone/config.txt', $string, $filepath ); } - //Remove backup folder + // Remove backup folder MainWP_Helper::delete_dir( $backupFolder ); return true; @@ -660,7 +660,7 @@ class MainWP_Backup { $this->zipArchiveSizeCount += filesize( $path ); $this->gcCnt ++; - //5 mb limit! + // 5 mb limit! if ( ! $this->loadFilesBeforeZip || ( filesize( $path ) > 5 * 1024 * 1024 ) ) { $this->zipArchiveFileCount ++; $added = $this->zip->addFile( $path, $zipEntryName ); @@ -686,7 +686,7 @@ class MainWP_Backup { $this->gcCnt = 0; } - //Over limits? + // Over limits? if ( ( ( $this->file_descriptors > 0 ) && ( $this->zipArchiveFileCount > $this->file_descriptors ) ) ) { // || $this->zipArchiveSizeCount >= (31457280 * 2)) $this->zip->close(); $this->zip = null; @@ -725,7 +725,7 @@ class MainWP_Backup { global $wpdb; $db_files = array(); - //Get all the tables + // Get all the tables $tables_db = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N ); foreach ( $tables_db as $curr_table ) { if ( null !== $archiver ) { @@ -739,11 +739,11 @@ class MainWP_Backup { if ( file_exists( $currentfile ) ) { continue; } - $fh = fopen( $currentfile . '.tmp', 'w' ); //or error; + $fh = fopen( $currentfile . '.tmp', 'w' ); // or error; fwrite( $fh, "\n\n" . 'DROP TABLE IF EXISTS ' . $table . ';' ); - //todo fix this - //$table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N ); + // todo fix this + // $table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N ); $table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); fwrite( $fh, "\n" . $table_create[1] . ";\n\n" ); @@ -804,7 +804,7 @@ class MainWP_Backup { @unlink( $db_file ); } } else { - //todo: throw exception! + // todo: throw exception! } } diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index afa2d78..d4e12e4 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -29,7 +29,7 @@ class MainWP_Child_Back_Up_Buddy { public function __construct() { // To fix bug run dashboard on local machine - //if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) { + // if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) { if ( class_exists('pb_backupbuddy')) { $this->is_backupbuddy_installed = true; } @@ -822,7 +822,7 @@ class MainWP_Child_Back_Up_Buddy { $information = array(); $information['backup_list'] = $this->get_backup_list(); $information['recent_backup_list'] = $this->get_recent_backup_list(); - //$information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list(); + // $information['destinations_list'] = pb_backupbuddy_destinations::get_destinations_list(); $backup_directory = backupbuddy_core::getBackupDirectory(); $backup_directory = str_replace( '\\', '/', $backup_directory ); $backup_directory = rtrim( $backup_directory, '/\\' ) . '/'; @@ -847,7 +847,7 @@ class MainWP_Child_Back_Up_Buddy { $comment = backupbuddy_core::normalize_comment_data( $old_comment ); $comment['note'] = $note; - //$new_comment = base64_encode( serialize( $comment ) ); + // $new_comment = base64_encode( serialize( $comment ) ); $comment_result = pb_backupbuddy::$classes['zipbuddy']->set_comment( $backup_file, $comment ); @@ -1149,16 +1149,16 @@ class MainWP_Child_Back_Up_Buddy { unset( $temp_dir ); $message = 'Extracting "' . $file . '" from archive "' . $archive_file . '" into temporary file "' . $destination . '". '; - //echo ''; + // echo ' -->'; $error = 'Error #584984458. Unable to extract.'; pb_backupbuddy::status( 'error', $error ); return array( 'error' => $error ); @@ -1539,7 +1539,7 @@ class MainWP_Child_Back_Up_Buddy { Integrity Technical Details'; echo '
    array(), - 'strong' => array(), - 'em' => array(), - 'a' => array( 'href' => true ), - )) - ?> + echo wp_kses($result['label'], array( + 'code' => array(), + 'strong' => array(), + 'em' => array(), + 'a' => array( 'href' => true ), + )) + ?> @@ -2469,7 +2469,7 @@ SQL isActive($key) ? ' wf-active' : '' ) . ( $hasFailingTest ? ' wf-diagnostic-fail' : '' ) - ?> + ?> " data-persistence-key="">
    @@ -2489,13 +2489,13 @@ SQL
    array(), - 'strong' => array(), - 'em' => array(), - 'a' => array( 'href' => true ), - )) - ?> + echo wp_kses($result['label'], array( + 'code' => array(), + 'strong' => array(), + 'em' => array(), + 'a' => array( 'href' => true ), + )) + ?>
    @@ -2558,44 +2558,44 @@ SQL 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', ) as $variable => $label) : - ?> + ?>
    $i) { - foreach ($trustedProxies as $proxy) { - if ( ! empty($proxy)) { - if (wfUtils::subnetContainsIP($proxy, $i) && $index < count($items) - 1) { - $output = esc_html($i) . ', ' . $output; - continue 2; - } + if ( ! array_key_exists($variable, $_SERVER)) { + echo '(not set)'; + } else { + if (strpos($_SERVER[ $variable ], ',') !== false) { + $trustedProxies = explode("\n", wfConfig::get('howGetIPs_trusted_proxies', '')); + $items = preg_replace('/[\s,]/', '', explode(',', $_SERVER[ $variable ])); + $items = array_reverse($items); + $output = ''; + $markedSelectedAddress = false; + foreach ($items as $index => $i) { + foreach ($trustedProxies as $proxy) { + if ( ! empty($proxy)) { + if (wfUtils::subnetContainsIP($proxy, $i) && $index < count($items) - 1) { + $output = esc_html($i) . ', ' . $output; + continue 2; } } - - if ( ! $markedSelectedAddress) { - $output = '' . esc_html($i) . ', ' . $output; - $markedSelectedAddress = true; - } else { - $output = esc_html($i) . ', ' . $output; - } } - echo substr($output, 0, -2); - } else { - echo esc_html($_SERVER[ $variable ]); + if ( ! $markedSelectedAddress) { + $output = '' . esc_html($i) . ', ' . $output; + $markedSelectedAddress = true; + } else { + $output = esc_html($i) . ', ' . $output; + } } + + echo substr($output, 0, -2); + } else { + echo esc_html($_SERVER[ $variable ]); } - ?> + } + ?> In use
    No log files found.
    Download' : 'Requires downloading from the server directly' ); ?>