mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-01 03:58:07 +08:00
Merge remote-tracking branch 'remotes/origin/bogdan01' into thang
This commit is contained in:
commit
8474ecc2a3
43 changed files with 6996 additions and 6465 deletions
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -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.dist export-ignore
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
|
||||
<description>Generally-applicable sniffs for WordPress plugins.</description>
|
||||
|
||||
<!-- What to scan -->
|
||||
<file>.</file>
|
||||
<exclude-pattern>/vendor/</exclude-pattern>
|
||||
<exclude-pattern>/node_modules/</exclude-pattern>
|
||||
|
||||
<!-- How to scan -->
|
||||
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
|
||||
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
||||
<arg value="sp"/> <!-- Show sniff and progress -->
|
||||
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
|
||||
<arg name="colors"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->
|
||||
|
||||
<!-- Rules: Check PHP version compatibility -->
|
||||
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
|
||||
<config name="testVersion" value="5.3-"/>
|
||||
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
|
||||
<rule ref="PHPCompatibilityWP"/>
|
||||
|
||||
<!-- Rules: WordPress Coding Standards -->
|
||||
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
|
||||
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
|
||||
<config name="minimum_supported_wp_version" value="4.6"/>
|
||||
<rule ref="WordPress">
|
||||
<exclude name="WordPress.VIP"/>
|
||||
</rule>
|
||||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
|
||||
<properties>
|
||||
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
|
||||
<property name="prefixes" type="array" value="my-plugin"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="WordPress.WP.I18n">
|
||||
<properties>
|
||||
<!-- Value: replace the text domain used. -->
|
||||
<property name="text_domain" type="array" value="my-plugin"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
|
||||
<properties>
|
||||
<property name="blank_line_check" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
|
@ -1,5 +1,5 @@
|
|||
sudo: false
|
||||
dist: trusty
|
||||
dist: xenial
|
||||
|
||||
language: php
|
||||
|
||||
|
@ -19,7 +19,7 @@ cache:
|
|||
matrix:
|
||||
include:
|
||||
- php: 7.4
|
||||
env: WP_VERSION=latest
|
||||
env: WP_TRAVISCI=phpcs WP_VERSION=latest
|
||||
- php: 7.3
|
||||
env: WP_VERSION=latest
|
||||
- php: 7.2
|
||||
|
@ -28,11 +28,6 @@ matrix:
|
|||
env: WP_VERSION=latest
|
||||
- php: 7.0
|
||||
env: WP_VERSION=latest
|
||||
- php: 5.6
|
||||
env: WP_VERSION=latest
|
||||
- php: 5.6
|
||||
env: WP_VERSION=trunk
|
||||
dist: precise
|
||||
|
||||
before_script:
|
||||
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
<a href="https://packagist.org/packages/mainwp/mainwp-child"><img src="https://poser.pugx.org/mainwp/mainwp-child/v/stable" alt="Latest Stable Version"></a>
|
||||
<img alt="WordPress Plugin Active Installs" src="https://img.shields.io/wordpress/plugin/installs/mainwp-child?label=MainWP%20Child%20Active%20Installs">
|
||||
<img alt="WordPress Plugin Rating" src="https://img.shields.io/wordpress/plugin/stars/mainwp-child?label=WP.org%20Rating">
|
||||
<a href="https://travis-ci.org/mainwp/mainwp-child"><img src="https://travis-ci.org/mainwp/mainwp-child.svg?branch=master" alt="Build Status"></a>
|
||||
</p>
|
||||
|
||||
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.
|
||||
|
|
|
@ -68,38 +68,23 @@ 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 ) ) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$this->timeout = 20 * 60 * 60; /*20 minutes*/
|
||||
$this->timeout = 20 * 60 * 60;
|
||||
$mem = '512M';
|
||||
// @codingStandardsIgnoreStart
|
||||
@ini_set( 'memory_limit', $mem );
|
||||
|
@ -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 );
|
||||
|
@ -173,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;
|
||||
|
@ -202,7 +187,6 @@ class MainWP_Backup {
|
|||
*/
|
||||
public function checkZipConsole() {
|
||||
return false;
|
||||
// return function_exists('system');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,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 ) {
|
||||
|
@ -408,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;
|
||||
|
@ -547,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 ) {
|
||||
|
@ -599,24 +583,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 ) {
|
||||
|
@ -627,7 +593,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;
|
||||
|
@ -657,7 +623,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 +709,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 );
|
||||
|
@ -843,7 +808,6 @@ class MainWP_Backup {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return ( false !== $archiveExt ? array( 'filepath' => $archivefilePath ) : $db_files );
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,22 +21,21 @@ 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() {
|
||||
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', '>=' ) ) {
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
@ -44,7 +43,9 @@ 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' ) );
|
||||
|
||||
|
@ -202,8 +203,12 @@ 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');
|
||||
|
@ -219,12 +224,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 +267,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() ) ) {
|
||||
|
@ -322,8 +326,9 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
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' );
|
||||
}
|
||||
|
||||
|
@ -394,10 +399,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;
|
||||
|
@ -445,7 +451,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<tr>
|
||||
|
||||
<th scope="col"><?php function_exists('hmbkp_backups_number') ? hmbkp_backups_number( $schedule ) : ( function_exists('backups_number') ? backups_number( $schedule ) : "" ) ; ?></th>
|
||||
<th scope="col"><?php function_exists('hmbkp_backups_number') ? hmbkp_backups_number( $schedule ) : ( function_exists('backups_number') ? backups_number( $schedule ) : '' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Size', 'mainwp-backupwordpress-extension' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Type', 'mainwp-backupwordpress-extension' ); ?></th>
|
||||
<th scope="col"><?php esc_html_e( 'Actions', 'mainwp-backupwordpress-extension' ); ?></th>
|
||||
|
@ -456,7 +462,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<tbody>
|
||||
|
||||
<?php if ( $schedule->get_backups() ) {
|
||||
<?php
|
||||
if ( $schedule->get_backups() ) {
|
||||
|
||||
$schedule->delete_old_backups();
|
||||
|
||||
|
@ -469,7 +476,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$this->hmbkp_get_backup_row( $file, $schedule );
|
||||
|
||||
}
|
||||
} else { ?>
|
||||
} else {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="hmbkp-no-backups"
|
||||
|
@ -501,7 +509,6 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
return sprintf( '(<code class="calculating" title="' . __( 'this shouldn\'t take long…', 'mainwp-backupwordpress-extension' ) . '">' . __( 'calculating the size of your backup…', 'mainwp-backupwordpress-extension' ) . '</code>)' );
|
||||
|
||||
}
|
||||
|
||||
function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
||||
|
@ -525,20 +532,23 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<td>
|
||||
|
||||
<?php if (function_exists('hmbkp_is_path_accessible')) {
|
||||
<?php
|
||||
if (function_exists('hmbkp_is_path_accessible')) {
|
||||
if ( hmbkp_is_path_accessible( hmbkp_path() ) ) {
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
||||
<?php };
|
||||
<?php
|
||||
};
|
||||
} elseif (function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
||||
if (HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path())) {
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
||||
<?php };
|
||||
<?php
|
||||
};
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -550,7 +560,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
</tr>
|
||||
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
|
||||
function get_excluded( $browse_dir = null ) {
|
||||
|
||||
|
@ -615,12 +626,14 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<td>
|
||||
<?php
|
||||
if ($new_version)
|
||||
if ($new_version) {
|
||||
$is_default_rule = ( in_array( $exclude, $excludes->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 ) : ?>
|
||||
if ( $is_default_rule ) :
|
||||
?>
|
||||
<?php esc_html_e( 'Default rule', 'backupwordpress' ); ?>
|
||||
|
||||
<?php elseif ( defined( 'HMBKP_EXCLUDE' ) && false !== strpos( HMBKP_EXCLUDE, $exclude ) ) : ?>
|
||||
|
@ -668,19 +681,21 @@ 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() );
|
||||
|
||||
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 );
|
||||
$exclude_string = $schedule->backup->exclude_string( 'regex' );
|
||||
}
|
||||
|
||||
if ( $files ) { ?>
|
||||
if ( $files ) {
|
||||
?>
|
||||
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
|
@ -702,16 +717,19 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<th scope="col">
|
||||
|
||||
<?php if ( $root_dir !== $directory ) {
|
||||
<?php
|
||||
if ( $root_dir !== $directory ) {
|
||||
// echo esc_url( remove_query_arg( 'hmbkp_directory_browse' ) );
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('', this)"><?php echo esc_html( $root_dir ); ?></a>
|
||||
<code>/</code>
|
||||
|
||||
<?php $parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
|
||||
<?php
|
||||
$parents = array_filter( explode( '/', str_replace( trailingslashit( $root_dir ), '', trailingslashit( dirname( $directory ) ) ) ) );
|
||||
|
||||
foreach ( $parents as $directory_basename ) { ?>
|
||||
foreach ( $parents as $directory_basename ) {
|
||||
?>
|
||||
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( substr( $directory, 0, strpos( $directory, $directory_basename ) ) . $directory_basename ); ?>', this)"><?php echo esc_html( $directory_basename ); ?></a>
|
||||
|
@ -793,7 +811,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<tbody>
|
||||
|
||||
<?php foreach ( $files as $size => $file ) {
|
||||
<?php
|
||||
foreach ( $files as $size => $file ) {
|
||||
|
||||
$is_excluded = $is_unreadable = false;
|
||||
|
||||
|
@ -811,7 +830,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
// Skip unreadable files
|
||||
if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) {
|
||||
$is_unreadable = true;
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
|
||||
<tr>
|
||||
|
||||
|
@ -836,7 +856,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
<td>
|
||||
<?php
|
||||
if ($new_version) {
|
||||
if ( $is_unreadable ) { ?>
|
||||
if ( $is_unreadable ) {
|
||||
?>
|
||||
|
||||
<code class="strikethrough"
|
||||
title="<?php echo esc_attr( wp_normalize_path( $file->getRealPath() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||
|
@ -852,9 +873,11 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( wp_normalize_path( $file->getPathname()) ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
||||
|
||||
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
if ( $is_unreadable ) { ?>
|
||||
if ( $is_unreadable ) {
|
||||
?>
|
||||
|
||||
<code class="strikethrough"
|
||||
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||
|
@ -864,14 +887,16 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
<code
|
||||
title="<?php echo esc_attr( $file->getRealPath() ); ?>"><?php echo esc_html( $file->getBasename() ); ?></code>
|
||||
|
||||
<?php } elseif ( $file->isDir() ) {
|
||||
<?php
|
||||
} elseif ( $file->isDir() ) {
|
||||
// echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
|
||||
?>
|
||||
<code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
|
||||
href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('<?php echo urlencode( $file->getPathname() ); ?>', this)"><?php echo esc_html( $file->getBasename() ); ?></a></code>
|
||||
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -897,7 +922,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
if ( ! $size ) {
|
||||
$size = '0 B';
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
|
||||
<code>
|
||||
|
||||
|
@ -918,7 +944,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<code>--</code>
|
||||
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
?>
|
||||
|
||||
|
@ -935,7 +962,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
<span
|
||||
title="<?php echo esc_attr( wp_normalize_path( $file->GetRealPath() ) ); ?>"><?php esc_html_e( 'Symlink', 'backupwordpress' ); ?></span>
|
||||
|
||||
<?php elseif ( $file->isDir() ) :
|
||||
<?php
|
||||
elseif ( $file->isDir() ) :
|
||||
|
||||
esc_html_e( 'Folder', 'backupwordpress' );
|
||||
|
||||
|
@ -999,7 +1027,6 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$information['e'] = $output;
|
||||
|
||||
return $information;
|
||||
|
||||
}
|
||||
|
||||
function directory_browse() {
|
||||
|
@ -1038,7 +1065,6 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$out['current_browse_dir'] = $_POST['browse_dir'];
|
||||
|
||||
return $out;
|
||||
|
||||
}
|
||||
|
||||
function hmbkp_remove_exclude_rule() {
|
||||
|
@ -1055,8 +1081,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();
|
||||
|
||||
|
@ -1087,21 +1114,20 @@ 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);
|
||||
// If it exist
|
||||
if($path !== false)
|
||||
{
|
||||
if ($path !== false) {
|
||||
$schedule->set_excludes( $exclude_rule, true );
|
||||
$schedule->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$un_exclude_paths = urldecode( $_POST['un_exclude_paths'] );
|
||||
$un_exclude_paths = explode("\n", $un_exclude_paths);
|
||||
|
||||
|
@ -1110,8 +1136,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')) {
|
||||
|
@ -1138,7 +1165,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
|
||||
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
|
||||
// // do not update 'excludes' value
|
||||
// do not update 'excludes' value
|
||||
// $options['excludes'] = $current_value['excludes'];
|
||||
// }
|
||||
|
||||
|
@ -1195,8 +1222,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',
|
||||
|
|
|
@ -58,15 +58,15 @@ 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() {
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
@ -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'] ) );
|
||||
} elseif ( ! 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,14 +212,15 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
MainWP_Child_Back_WP_Up::$information = $information;
|
||||
self::$information = $information;
|
||||
exit();
|
||||
}
|
||||
|
||||
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,12 @@ 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 {
|
||||
|
||||
|
@ -257,9 +261,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;
|
||||
}
|
||||
}
|
||||
|
@ -269,8 +273,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
|
||||
|
@ -286,13 +291,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;
|
||||
|
@ -313,9 +318,10 @@ 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 ) {
|
||||
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature
|
||||
|
@ -332,7 +338,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) {
|
||||
|
||||
|
@ -532,7 +538,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() {
|
||||
|
@ -601,11 +610,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() {
|
||||
|
@ -635,7 +650,10 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array( 'success' => 1, 'response' => $output );
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $output,
|
||||
);
|
||||
}
|
||||
|
||||
protected function tables() {
|
||||
|
@ -661,7 +679,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();
|
||||
|
@ -692,7 +713,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;
|
||||
}
|
||||
}
|
||||
|
@ -780,7 +801,10 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array( 'success' => 1, 'response' => $array );
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $array,
|
||||
);
|
||||
}
|
||||
|
||||
public function init_download_backup() {
|
||||
|
@ -897,7 +921,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() {
|
||||
|
@ -933,7 +960,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'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -955,7 +985,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'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -969,12 +1002,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
if ( ! function_exists( 'add_screen_option' ) ) {
|
||||
function add_screen_option( $option, $args = array() ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -989,7 +1021,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' );
|
||||
}
|
||||
|
@ -1088,7 +1123,10 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array( 'success' => 1, 'message' => $message );
|
||||
return array(
|
||||
'success' => 1,
|
||||
'message' => $message,
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_job_files() {
|
||||
|
@ -1154,11 +1192,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() {
|
||||
|
@ -1213,7 +1258,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() {
|
||||
|
@ -1332,11 +1380,26 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
// 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();
|
||||
|
@ -1510,7 +1573,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() {
|
||||
|
@ -1524,7 +1591,6 @@ class MainWP_Child_Back_WP_Up {
|
|||
} else {
|
||||
return array( 'error' => 'Generic error' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
@ -66,9 +66,10 @@ 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;
|
||||
}
|
||||
|
@ -150,7 +151,6 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 ) ) {
|
||||
|
@ -348,7 +354,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
|
||||
|
@ -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 ) ) {
|
||||
|
@ -410,18 +419,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');
|
||||
}
|
||||
|
@ -431,8 +444,7 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
// to fix
|
||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
|
||||
if ( !isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
|
||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); if ( ! isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
|
||||
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
||||
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
||||
// branding site generator
|
||||
|
@ -470,8 +482,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
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -500,7 +511,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 +640,8 @@ class MainWP_Child_Branding {
|
|||
el.parentElement.innerHTML = '';
|
||||
}
|
||||
});
|
||||
</script><?php
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function core_update_footer() {
|
||||
|
@ -797,22 +808,22 @@ class MainWP_Child_Branding {
|
|||
$email = $this->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";
|
||||
if ( ! empty($from)) {
|
||||
$headers .= 'From: "' . $from . '" <' . $from . ">\r\n";
|
||||
}
|
||||
$mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
|
||||
$mail .= "<p>Sent from WordPress page: " . ( ! empty( $_POST["mainwp_branding_send_from_page"] ) ? "<a href='" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "'>" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . "</a></p>\r\n\r\n" : "" );
|
||||
$mail .= "<p>Client Email: " . $current_user->user_email . " </p>\r\n\r\n";
|
||||
$mail .= '<p>Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "<a href='" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "'>" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . "</a></p>\r\n\r\n" : '' );
|
||||
$mail .= '<p>Client Email: ' . $current_user->user_email . " </p>\r\n\r\n";
|
||||
$mail .= "<p>Support Text:</p>\r\n\r\n";
|
||||
$mail .= "<p>" . $content . "</p>\r\n\r\n";
|
||||
$mail .= '<p>' . $content . "</p>\r\n\r\n";
|
||||
|
||||
if ( @wp_mail( $email, $subject, $mail, $headers ) ) {
|
||||
;
|
||||
if ( @wp_mail( $email, $subject, $mail, $headers ) ) {;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -860,7 +871,8 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
?>
|
||||
<div
|
||||
class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . "  " . $back_link; ?></div><?php
|
||||
class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . '  ' . $back_link; ?></div>
|
||||
<?php
|
||||
} else {
|
||||
$from_page = '';
|
||||
if ( isset( $_GET['from_page'] ) ) {
|
||||
|
@ -913,7 +925,8 @@ class MainWP_Child_Branding {
|
|||
value="<?php echo esc_url( $from_page ); ?>"/>
|
||||
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( '_contactNonce' ) ); ?>"/>
|
||||
</form>
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -921,8 +934,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
|
||||
if ( $allow_contact ) {; // ok
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -993,15 +1005,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;
|
||||
|
@ -1037,16 +1050,17 @@ class MainWP_Child_Branding {
|
|||
$adminBarUpdates.textContent = itemCount;
|
||||
}
|
||||
});
|
||||
</script><?php
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function in_admin_footer() {
|
||||
|
||||
$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;
|
||||
|
||||
|
@ -1115,7 +1129,8 @@ class MainWP_Child_Branding {
|
|||
});
|
||||
}
|
||||
});
|
||||
</script><?php
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class MainWP_Child_DB {
|
||||
//Support old & new versions of wordpress (3.9+)
|
||||
// Support old & new versions of WordPress (3.9+)
|
||||
public static function use_mysqli() {
|
||||
/** @var $wpdb wpdb */
|
||||
if ( ! function_exists( 'mysqli_connect' ) ) {
|
||||
|
@ -90,9 +90,9 @@ class MainWP_Child_DB {
|
|||
/** @var $wpdb wpdb */
|
||||
global $wpdb;
|
||||
|
||||
$rows = MainWP_Child_DB::_query( 'SHOW table STATUS', $wpdb->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'];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,21 +20,22 @@ 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() {
|
||||
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 );
|
||||
}
|
||||
|
@ -43,7 +44,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 +64,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':
|
||||
|
@ -131,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' ) );
|
||||
|
@ -178,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(
|
||||
|
@ -242,7 +243,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' );
|
||||
|
||||
}
|
||||
} elseif ($module == 'hide-backend') {
|
||||
if (isset($settings['enabled']) && ! empty($settings['enabled'])) {
|
||||
|
@ -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' ),
|
||||
|
@ -327,11 +329,11 @@ class MainWP_Child_iThemes_Security {
|
|||
'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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 ) ) {
|
||||
|
@ -483,7 +486,6 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function whitelist_release() {
|
||||
|
@ -496,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();
|
||||
}
|
||||
|
@ -530,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 = '';
|
||||
|
@ -553,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();
|
||||
|
||||
|
@ -584,7 +586,7 @@ class MainWP_Child_iThemes_Security {
|
|||
),
|
||||
array(
|
||||
WP_PLUGIN_DIR,
|
||||
0755
|
||||
0755,
|
||||
),
|
||||
array(
|
||||
$wp_upload_dir['basedir'],
|
||||
|
@ -600,7 +602,6 @@ class MainWP_Child_iThemes_Security {
|
|||
),
|
||||
);
|
||||
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ( $path_data as $path ) {
|
||||
|
@ -632,7 +633,6 @@ class MainWP_Child_iThemes_Security {
|
|||
$rows[] = $row;
|
||||
}
|
||||
|
||||
|
||||
$class = 'entry-row';
|
||||
ob_start();
|
||||
?>
|
||||
|
@ -676,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) {
|
||||
|
@ -690,17 +690,17 @@ 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;
|
||||
|
||||
|
||||
// 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' );
|
||||
|
@ -716,7 +716,6 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ( true === $change_id && ! $user_id_exists ) {
|
||||
if ( ! empty( $msg ) ) {
|
||||
$msg .= '<br/>';
|
||||
|
@ -773,7 +772,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 +825,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 +839,6 @@ class MainWP_Child_iThemes_Security {
|
|||
// }
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function build_wpconfig_rules( $rules_array, $input = null ) {
|
||||
|
@ -869,16 +867,19 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
@ -946,8 +947,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();
|
||||
|
@ -965,8 +966,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();
|
||||
|
@ -1068,7 +1069,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'];
|
||||
|
@ -1095,7 +1096,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 );
|
||||
|
@ -1110,8 +1111,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) {
|
||||
|
@ -1120,14 +1122,13 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
update_site_option( 'itsec_active_modules', $current_val );
|
||||
return array( 'result' => 'success' );
|
||||
|
||||
}
|
||||
|
||||
private function reload_backup_exclude() {
|
||||
return array(
|
||||
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
|
||||
'excludable_tables' => $this->get_excludable_tables(),
|
||||
'result' => 'success'
|
||||
'result' => 'success',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1172,13 +1173,16 @@ 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 );
|
||||
$response = ob_get_clean();
|
||||
return array('result' => 'success' , 'response' => $response);
|
||||
return array(
|
||||
'result' => 'success',
|
||||
'response' => $response,
|
||||
);
|
||||
}
|
||||
|
||||
// source from itheme plugin
|
||||
|
|
|
@ -19,24 +19,24 @@ 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() {
|
||||
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 );
|
||||
|
||||
}
|
||||
|
||||
public function action() {
|
||||
|
@ -223,14 +223,17 @@ 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';
|
||||
|
@ -248,13 +251,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)) {
|
||||
|
@ -290,7 +292,9 @@ 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';
|
||||
|
@ -345,7 +349,7 @@ class MainWP_Child_Links_Checker {
|
|||
'dismissed',
|
||||
'status_text',
|
||||
'status_code',
|
||||
'log'
|
||||
'log',
|
||||
);
|
||||
$return = array();
|
||||
|
||||
|
@ -449,7 +453,6 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function edit_link() {
|
||||
|
@ -656,8 +659,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();
|
||||
|
||||
|
|
|
@ -21,21 +21,22 @@ 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() {
|
||||
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 );
|
||||
|
||||
|
@ -60,7 +61,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;
|
||||
}
|
||||
|
@ -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' ) );
|
||||
|
@ -343,7 +345,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';
|
||||
|
@ -446,21 +447,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,13 +473,12 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
$args = array(
|
||||
'public' => true,
|
||||
'_builtin' => false
|
||||
'_builtin' => false,
|
||||
);
|
||||
$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)
|
||||
{
|
||||
foreach ($custom_post_types as $post_type) {
|
||||
if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
|
||||
if ($post_type == $restrict_type) {
|
||||
$typestocheck[] = 'type = %s';
|
||||
|
@ -487,8 +487,7 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
foreach($custom_post_types as $post_type)
|
||||
{
|
||||
foreach ($custom_post_types as $post_type) {
|
||||
if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
|
||||
$typestocheck[] = 'type = %s';
|
||||
$types[1][] = $custom_post_types[ $post_type ];
|
||||
|
@ -519,13 +518,11 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
if ( ! empty($typestocheck)) {
|
||||
$types[0] = '';
|
||||
foreach($typestocheck as $type)
|
||||
{
|
||||
foreach ($typestocheck as $type) {
|
||||
if ( ! is_array($type)) {
|
||||
$types[0] .= $type . ' OR ';
|
||||
} else {
|
||||
foreach($type as $custom_post_type)
|
||||
{
|
||||
foreach ($type as $custom_post_type) {
|
||||
$types[0] .= 'type = %s OR ';
|
||||
$types[1][] = $custom_post_type;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -153,14 +151,12 @@ class MainWP_Child_Plugins_Check {
|
|||
$plugin_info = get_transient( $this->tran_name_plugin_timestamps );
|
||||
|
||||
// Sanity check the response
|
||||
if( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) )
|
||||
{
|
||||
if ( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) ) {
|
||||
return $plugin_meta;
|
||||
}
|
||||
|
||||
// See if this specific plugin is in the known list
|
||||
if( array_key_exists( $plugin_file, $plugin_info ) )
|
||||
{
|
||||
if ( array_key_exists( $plugin_file, $plugin_info ) ) {
|
||||
// Get now
|
||||
$now = new \DateTime();
|
||||
$last_updated = $plugin_info[ $plugin_file ]['last_updated'];
|
||||
|
@ -175,12 +171,9 @@ class MainWP_Child_Plugins_Check {
|
|||
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
|
||||
|
||||
// If we're outside the window for tolerance show a message
|
||||
if( $diff_in_days > $tolerance_in_days )
|
||||
{
|
||||
if ( $diff_in_days > $tolerance_in_days ) {
|
||||
$plugin_meta[] = sprintf( '<strong style="color: #f00;">This plugin has not been updated by the author in %1$d days!</strong>', $diff_in_days );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$plugin_meta[] = sprintf( '<span style="color: #090;">This plugin was last updated by the author in %1$d days ago.</span>', $diff_in_days );
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +274,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;
|
||||
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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 );
|
||||
|
@ -473,12 +474,17 @@ class MainWP_Child_Server_Information {
|
|||
</div>
|
||||
<br/>
|
||||
<div class="mwp_server_info_box">
|
||||
<h2><?php esc_html_e( 'Server Information' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::render();
|
||||
?><h2><?php esc_html_e( 'Cron Schedules' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::renderCron();
|
||||
?><h2><?php esc_html_e( 'Error Log' ); ?></h2><?php
|
||||
MainWP_Child_Server_Information::renderErrorLogPage();
|
||||
<h2><?php esc_html_e( 'Server Information' ); ?></h2>
|
||||
<?php
|
||||
self::render();
|
||||
?>
|
||||
<h2><?php esc_html_e( 'Cron Schedules' ); ?></h2>
|
||||
<?php
|
||||
self::renderCron();
|
||||
?>
|
||||
<h2><?php esc_html_e( 'Error Log' ); ?></h2>
|
||||
<?php
|
||||
self::renderErrorLogPage();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -583,8 +589,9 @@ class MainWP_Child_Server_Information {
|
|||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php esc_html_e( 'WORDPRESS', 'mainwp-child' ); ?></td>
|
||||
</tr><?php
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php esc_html_e( 'WordPress', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
self::renderRow( 'WordPress Version', '>=', '3.4', 'getWordpressVersion' );
|
||||
self::renderRow( 'WordPress Memory Limit', '>=', '64M', 'getWordpressMemoryLimit' );
|
||||
self::renderRow( 'MultiSite Disabled', '=', true, 'checkIfMultisite' );
|
||||
|
@ -599,7 +606,8 @@ class MainWP_Child_Server_Information {
|
|||
<tr>
|
||||
<td style="background: #333; color: #fff;"
|
||||
colspan="5"><?php esc_html_e( 'PHP SETTINGS', 'mainwp-child' ); ?></td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
self::renderRow( 'PHP Version', '>=', '5.6', 'getPHPVersion' );
|
||||
?>
|
||||
<tr>
|
||||
|
@ -629,13 +637,15 @@ class MainWP_Child_Server_Information {
|
|||
<tr>
|
||||
<td style="background: #333; color: #fff;"
|
||||
colspan="5"><?php esc_html_e( 'MySQL SETTINGS', 'mainwp-child' ); ?></td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
self::renderRow( 'MySQL Version', '>=', '5.0', 'getMySQLVersion' );
|
||||
?>
|
||||
<tr>
|
||||
<td style="background: #333; color: #fff;"
|
||||
colspan="5"><?php esc_html_e( 'BACKUP ARCHIVE INFORMATION', 'mainwp-child' ); ?></td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
self::renderRow( 'ZipArchive enabled in PHP', '=', true, 'getZipArchiveEnabled' );
|
||||
self::renderRow( 'Tar GZip supported', '=', true, 'getGZipEnabled' );
|
||||
self::renderRow( 'Tar BZip2 supported', '=', true, 'getBZipEnabled' );
|
||||
|
@ -808,7 +818,7 @@ class MainWP_Child_Server_Information {
|
|||
<td colspan="3"><?php echo esc_html( defined( 'DB_CHARSET' ) ? DB_CHARSET : '' ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php _e( 'WORDPRESS PLUGINS', 'mainwp-child' ); ?></td>
|
||||
<td style="background: #333; color: #fff;" colspan="5"><?php _e( 'WordPress PLUGINS', 'mainwp-child' ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$all_plugins = get_plugins();
|
||||
|
@ -896,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 ),
|
||||
|
@ -957,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';
|
||||
|
||||
|
@ -1054,8 +1065,7 @@ class MainWP_Child_Server_Information {
|
|||
<?php
|
||||
}
|
||||
|
||||
private static function getWarningHTML($errorType = self::WARNING)
|
||||
{
|
||||
private static function getWarningHTML( $errorType = self::WARNING) {
|
||||
if (self::WARNING == $errorType) {
|
||||
return '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>';
|
||||
}
|
||||
|
@ -1170,7 +1180,10 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
protected static function getArchitecture() {
|
||||
echo esc_html( PHP_INT_SIZE * 8 ) ?> bit <?php
|
||||
echo esc_html( PHP_INT_SIZE * 8 )
|
||||
?>
|
||||
bit
|
||||
<?php
|
||||
}
|
||||
|
||||
protected static function memoryUsage() {
|
||||
|
@ -1318,9 +1331,10 @@ class MainWP_Child_Server_Information {
|
|||
$url = site_url( 'wp-cron.php' );
|
||||
$query_args = array( 'mainwp_child_run' => 'test' );
|
||||
$url = add_query_arg( $query_args, $url );
|
||||
$args = array( 'blocking' => TRUE,
|
||||
$args = array(
|
||||
'blocking' => true,
|
||||
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
|
||||
'timeout' => 15
|
||||
'timeout' => 15,
|
||||
);
|
||||
$response = wp_remote_post( $url, $args );
|
||||
$test_result = '';
|
||||
|
@ -1332,15 +1346,16 @@ class MainWP_Child_Server_Information {
|
|||
$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' ) ) {
|
||||
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 ) ) {
|
||||
_e( 'Response Test O.K.', 'mainwp-child' );
|
||||
} else
|
||||
} else {
|
||||
echo $test_result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static function getRemoteAddress() {
|
||||
|
@ -1411,7 +1426,6 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
return $bytes;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1504,7 +1518,6 @@ class MainWP_Child_Server_Information {
|
|||
echo wp_kses_post( "<tr><td>{$time}</td><td>{$error}</td></tr>" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static function time_compare( $a, $b ) {
|
||||
|
@ -1615,8 +1628,9 @@ 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');
|
||||
|
@ -1624,27 +1638,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'),
|
||||
|
|
|
@ -7,11 +7,11 @@ class MainWP_Child_Skeleton_Key {
|
|||
public $plugin_translate = 'mainwp-child';
|
||||
|
||||
static function Instance() {
|
||||
if ( null === MainWP_Child_Skeleton_Key::$instance ) {
|
||||
MainWP_Child_Skeleton_Key::$instance = new MainWP_Child_Skeleton_Key();
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Skeleton_Key();
|
||||
}
|
||||
|
||||
return MainWP_Child_Skeleton_Key::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function action() {
|
||||
|
@ -67,7 +67,6 @@ class MainWP_Child_Skeleton_Key {
|
|||
$manager = WP_Session_Tokens::get_instance( $current_user->ID );
|
||||
$token = $manager->create( $expiration );
|
||||
|
||||
|
||||
$secure = is_ssl();
|
||||
if ( $secure ) {
|
||||
$auth_cookie_name = SECURE_AUTH_COOKIE;
|
||||
|
@ -85,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,18 +195,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';
|
||||
|
@ -213,7 +221,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 ) {
|
||||
|
@ -225,16 +233,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' );
|
||||
}
|
||||
|
|
|
@ -22,33 +22,36 @@ 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() {
|
||||
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;
|
||||
} 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' ) );
|
||||
|
@ -79,7 +82,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 +187,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 +203,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 +235,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 +288,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 +303,7 @@ class MainWP_Child_Staging {
|
|||
$clone = $delete->getClone();
|
||||
$result = array(
|
||||
'clone' => $clone,
|
||||
'deleteTables' => $delete->getTables()
|
||||
'deleteTables' => $delete->getTables(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
@ -337,7 +339,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 +350,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,16 +378,14 @@ 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
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
@ -127,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;
|
||||
|
@ -146,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
|
||||
|
@ -179,7 +177,9 @@ 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 );
|
||||
|
||||
|
@ -199,7 +199,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;
|
||||
}
|
||||
|
@ -229,14 +228,20 @@ 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' ) ) ) {
|
||||
$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(
|
||||
|
|
|
@ -19,32 +19,34 @@ 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() {
|
||||
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' ) );
|
||||
|
||||
|
@ -76,8 +78,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 ((
|
||||
|
@ -243,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;
|
||||
}
|
||||
|
@ -285,7 +286,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) {
|
||||
|
@ -370,14 +371,13 @@ 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() {
|
||||
|
@ -422,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);
|
||||
}
|
||||
|
@ -459,46 +459,50 @@ 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";
|
||||
$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";
|
||||
$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";
|
||||
$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";
|
||||
$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";
|
||||
$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";
|
||||
$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";
|
||||
$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';
|
||||
if (!empty($orderby) & !empty($order)) {$query .= ' ORDER BY ' . $orderby . ' ' . $order;}
|
||||
$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"] : '';
|
||||
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {$paged = 1;} //Page Number
|
||||
$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
|
||||
// adjust the query to take pagination into account
|
||||
|
@ -507,9 +511,10 @@ 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,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -534,7 +539,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);
|
||||
|
@ -558,8 +563,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');
|
||||
|
@ -574,7 +580,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) {
|
||||
|
@ -600,7 +606,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 +627,14 @@ function get_sibling_files_callback_wptc() {
|
|||
if ($more_logs) {
|
||||
$html .= "    <a class='wptc-show-more' action_id='" . round($rec->action_id) . "'>View details</a></td>";
|
||||
} else {
|
||||
$html .= "</td>";
|
||||
$html .= '</td>';
|
||||
}
|
||||
$html .= '<td class="wptc-act-td"><a class="report_issue_wptc" id="' . $rec->id . '" href="#">Send report to plugin developer</a></td>';
|
||||
if ($more_logs) {
|
||||
|
||||
$html .= "</tr><tr id='" . round($rec->action_id) . "' class='wptc-more-logs'><td colspan=3>" . $detailed . "</td>";
|
||||
$html .= "</tr><tr id='" . round($rec->action_id) . "' class='wptc-more-logs'><td colspan=3>" . $detailed . '</td>';
|
||||
} else {
|
||||
$html .= "</td>";
|
||||
$html .= '</td>';
|
||||
}
|
||||
// Close the line
|
||||
$html .= '</tr>';
|
||||
|
@ -651,7 +657,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 .= '<tr><td>' . $user_tmz_now . '</td><td>' . $Moredata['msg'] . '</td><td></td></tr>';
|
||||
}
|
||||
return $detailed;
|
||||
|
@ -659,7 +665,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';
|
||||
|
@ -705,10 +711,13 @@ function get_sibling_files_callback_wptc() {
|
|||
// ok
|
||||
public function do_reports_log( $ext = '') {
|
||||
|
||||
if ( $ext !== 'wptimecapsule' ) return;
|
||||
|
||||
if (!$this->is_plugin_installed)
|
||||
if ( $ext !== 'wptimecapsule' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->is_plugin_installed) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
MainWP_Helper::check_classes_exists(array( 'WPTC_Factory' ));
|
||||
|
@ -725,8 +734,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 );
|
||||
|
||||
|
@ -746,7 +756,6 @@ function get_sibling_files_callback_wptc() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
@ -799,7 +808,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 +819,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');
|
||||
|
||||
|
@ -829,13 +837,15 @@ 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('result' => 'ok', 'sync_data' => $this->get_sync_data());
|
||||
return array(
|
||||
'result' => 'ok',
|
||||
'sync_data' => $this->get_sync_data(),
|
||||
);
|
||||
}
|
||||
|
||||
function get_installed_plugins() {
|
||||
|
@ -877,7 +887,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');
|
||||
|
@ -953,7 +966,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',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -962,7 +975,6 @@ function get_sibling_files_callback_wptc() {
|
|||
$tabName = $_POST['tabname'];
|
||||
$is_general = $_POST['is_general'];
|
||||
|
||||
|
||||
$saved = false;
|
||||
|
||||
$config = WPTC_Factory::get('config');
|
||||
|
@ -972,7 +984,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']);
|
||||
|
@ -984,9 +995,10 @@ 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', '');
|
||||
|
||||
|
@ -1013,16 +1025,18 @@ 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;
|
||||
|
||||
|
@ -1048,17 +1062,12 @@ function get_sibling_files_callback_wptc() {
|
|||
|
||||
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();
|
||||
|
@ -1157,14 +1166,13 @@ function get_sibling_files_callback_wptc() {
|
|||
}
|
||||
|
||||
echo '<tr title=">=5.3.1"><td>' . __( 'PHP version', 'wp-time-capsule' ) . '</td><td>' . esc_html( PHP_VERSION . ' ' . $bit ) . '</td></tr>';
|
||||
echo '<tr title=">=5.0.15"><td>' . __( 'MySQL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $wpdb->get_var( "SELECT VERSION() AS version" ) ) . '</td></tr>';
|
||||
echo '<tr title=">=5.0.15"><td>' . __( 'MySQL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $wpdb->get_var( 'SELECT VERSION() AS version' ) ) . '</td></tr>';
|
||||
|
||||
if ( function_exists( 'curl_version' ) ) {
|
||||
$curlversion = curl_version();
|
||||
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion['version'] ) . '</td></tr>';
|
||||
echo '<tr title=""><td>' . __( 'cURL SSL version', 'wp-time-capsule' ) . '</td><td>' . esc_html( $curlversion['ssl_version'] ) . '</td></tr>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<tr title=""><td>' . __( 'cURL version', 'wp-time-capsule' ) . '</td><td>' . __( 'unavailable', 'wp-time-capsule' ) . '</td></tr>';
|
||||
}
|
||||
|
||||
|
@ -1181,12 +1189,13 @@ function get_sibling_files_callback_wptc() {
|
|||
echo '<tr title=""><td>' . __( 'Current PHP user', 'wp-time-capsule' ) . '</td><td>' . esc_html( $php_user ) . '</td></tr>';
|
||||
echo '<tr title=">=30"><td>' . __( 'Maximum execution time', 'wp-time-capsule' ) . '</td><td>' . esc_html( ini_get( 'max_execution_time' ) ) . ' ' . __( 'seconds', 'wp-time-capsule' ) . '</td></tr>';
|
||||
|
||||
if ( defined( 'FS_CHMOD_DIR' ) )
|
||||
if ( defined( 'FS_CHMOD_DIR' ) ) {
|
||||
echo '<tr title="FS_CHMOD_DIR"><td>' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '</td><td>' . esc_html( FS_CHMOD_DIR ) . '</td></tr>';
|
||||
else
|
||||
} else {
|
||||
echo '<tr title="FS_CHMOD_DIR"><td>' . __( 'CHMOD Dir', 'wp-time-capsule' ) . '</td><td>0755</td></tr>';
|
||||
}
|
||||
|
||||
$now = localtime( time(), TRUE );
|
||||
$now = localtime( time(), true );
|
||||
echo '<tr title=""><td>' . __( 'Server Time', 'wp-time-capsule' ) . '</td><td>' . esc_html( $now['tm_hour'] . ':' . $now['tm_min'] ) . '</td></tr>';
|
||||
echo '<tr title=""><td>' . __( 'Blog Time', 'wp-time-capsule' ) . '</td><td>' . date( 'H:i', current_time( 'timestamp' ) ) . '</td></tr>';
|
||||
echo '<tr title="WPLANG"><td>' . __( 'Blog language', 'wp-time-capsule' ) . '</td><td>' . get_bloginfo( 'language' ) . '</td></tr>';
|
||||
|
@ -1197,7 +1206,7 @@ function get_sibling_files_callback_wptc() {
|
|||
echo '<tr title=">=128M"><td>' . __( 'PHP Memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( ini_get( 'memory_limit' ) ) . '</td></tr>';
|
||||
echo '<tr title="WP_MEMORY_LIMIT"><td>' . __( 'WP memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( WP_MEMORY_LIMIT ) . '</td></tr>';
|
||||
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'wp-time-capsule' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>';
|
||||
echo '<tr title=""><td>' . __( 'Memory in use', 'wp-time-capsule' ) . '</td><td>' . size_format( @memory_get_usage( TRUE ), 2 ) . '</td></tr>';
|
||||
echo '<tr title=""><td>' . __( 'Memory in use', 'wp-time-capsule' ) . '</td><td>' . size_format( @memory_get_usage( true ), 2 ) . '</td></tr>';
|
||||
|
||||
// disabled PHP functions
|
||||
$disabled = esc_html( ini_get( 'disable_functions' ) );
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,10 +23,10 @@ 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() {
|
||||
|
@ -55,7 +55,10 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
$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;
|
||||
}
|
||||
|
||||
|
@ -129,8 +132,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 +159,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;
|
||||
|
@ -220,20 +224,20 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
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) ];
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
@ -66,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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -184,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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -333,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;
|
||||
}
|
||||
|
@ -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,15 +366,14 @@ 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 ) );
|
||||
|
||||
|
||||
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();
|
||||
|
@ -449,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' );
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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() {
|
||||
|
@ -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':
|
||||
|
@ -341,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 );
|
||||
|
@ -375,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',
|
||||
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'
|
||||
'WP_Rocket\Admin\Options_Data',
|
||||
));
|
||||
|
||||
$critical_css = new WP_Rocket\Optimization\CSS\Critical_CSS( new WP_Rocket\Optimization\CSS\Critical_CSS_Generation() );
|
||||
|
@ -411,7 +411,6 @@ class MainWP_Child_WP_Rocket {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
update_option( WP_ROCKET_SLUG, $options );
|
||||
|
||||
if (isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization'])) {
|
||||
|
@ -423,10 +422,11 @@ class MainWP_Child_WP_Rocket {
|
|||
|
||||
function optimize_database() {
|
||||
|
||||
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
|
||||
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 +436,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 );
|
||||
|
@ -448,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();
|
||||
|
@ -464,7 +465,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';
|
||||
|
@ -473,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,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,46 +1,39 @@
|
|||
<?php
|
||||
|
||||
class MainWP_Child_WPvivid_BackupRestore
|
||||
{
|
||||
class MainWP_Child_WPvivid_BackupRestore {
|
||||
|
||||
public static $instance = null;
|
||||
public $is_plugin_installed = false;
|
||||
public $public_intetface;
|
||||
static function Instance()
|
||||
{
|
||||
if ( null === MainWP_Child_WPvivid_BackupRestore::$instance )
|
||||
{
|
||||
MainWP_Child_WPvivid_BackupRestore::$instance = new MainWP_Child_WPvivid_BackupRestore();
|
||||
static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_WPvivid_BackupRestore();
|
||||
}
|
||||
|
||||
return MainWP_Child_WPvivid_BackupRestore::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR'))
|
||||
{
|
||||
public function __construct() {
|
||||
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();
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
public function init() {
|
||||
}
|
||||
|
||||
function syncOthersData( $information, $data = array() )
|
||||
{
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
try {
|
||||
|
||||
if ( isset( $data['syncWPvividData'] ))
|
||||
{
|
||||
if ( isset( $data['syncWPvividData'] )) {
|
||||
$information['syncWPvividData'] = 1;
|
||||
$data = WPvivid_Setting::get_sync_data();
|
||||
$information['syncWPvividSettingData'] = $data['setting'];
|
||||
|
@ -56,17 +49,14 @@ class MainWP_Child_WPvivid_BackupRestore
|
|||
return $information;
|
||||
}
|
||||
|
||||
public function action()
|
||||
{
|
||||
public function action() {
|
||||
$information = array();
|
||||
if ( ! $this->is_plugin_installed )
|
||||
{
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
$information['error'] = 'NO_WPVIVIDBACKUP';
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['mwp_action'] ) )
|
||||
{
|
||||
if ( isset( $_POST['mwp_action'] ) ) {
|
||||
try {
|
||||
switch ($_POST['mwp_action']) {
|
||||
case 'prepare_backup':
|
||||
|
@ -148,160 +138,140 @@ class MainWP_Child_WPvivid_BackupRestore
|
|||
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']);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,11 +5,11 @@ class MainWP_Client_Report {
|
|||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === MainWP_Client_Report::$instance ) {
|
||||
MainWP_Client_Report::$instance = new MainWP_Client_Report();
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Client_Report();
|
||||
}
|
||||
|
||||
return MainWP_Client_Report::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -22,8 +22,9 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
public function current_agent( $agent ) {
|
||||
if ( isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) )
|
||||
if ( isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) ) {
|
||||
$agent = '';
|
||||
}
|
||||
return $agent;
|
||||
}
|
||||
|
||||
|
@ -102,8 +103,9 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -130,7 +132,7 @@ class MainWP_Client_Report {
|
|||
'wordfence' => 'wordfence_scan',
|
||||
'backups' => 'backups',
|
||||
'backup' => 'backups',
|
||||
'media' => 'media'
|
||||
'media' => 'media',
|
||||
);
|
||||
|
||||
$context = isset( $mapping_contexts[ $context ] ) ? $mapping_contexts[ $context ] : $context;
|
||||
|
@ -140,35 +142,35 @@ class MainWP_Client_Report {
|
|||
|
||||
public function get_connector_by_compatible_context( $context ) {
|
||||
|
||||
$connector = "";
|
||||
if ( $context == "plugins" || $context == "themes" || $context == "wordpress" ) {
|
||||
$connector = "installer";
|
||||
$connector = '';
|
||||
if ( $context == 'plugins' || $context == 'themes' || $context == 'WordPress' ) {
|
||||
$connector = 'installer';
|
||||
} elseif ( $context == 'profiles' ) {
|
||||
$connector = "users";
|
||||
$connector = 'users';
|
||||
} elseif ( $context == 'comments' ) { // multi values
|
||||
$connector = "comments";
|
||||
$connector = 'comments';
|
||||
}
|
||||
// else if ( $context == 'sessions' ) {
|
||||
// $connector = "users";
|
||||
// }
|
||||
elseif ( $context == 'settings' ) {
|
||||
$connector = "settings";
|
||||
$connector = 'settings';
|
||||
} elseif ( $context == 'post' || $context == 'page' ) {
|
||||
$connector = "posts";
|
||||
$connector = 'posts';
|
||||
} elseif ( $context == 'widgets' ) {
|
||||
$connector = "widgets";
|
||||
$connector = 'widgets';
|
||||
} elseif ( $context == 'menus' ) {
|
||||
$connector = "menus";
|
||||
$connector = 'menus';
|
||||
} elseif ( $context == 'backups' ) {
|
||||
$connector = "mainwp_backups";
|
||||
$connector = 'mainwp_backups';
|
||||
} elseif ( $context == 'sucuri_scan' ) {
|
||||
$connector = "mainwp_sucuri";
|
||||
$connector = 'mainwp_sucuri';
|
||||
} elseif ( $context == 'mainwp_maintenance' ) {
|
||||
$connector = "mainwp_maintenance";
|
||||
$connector = 'mainwp_maintenance';
|
||||
} elseif ( $context == 'wordfence_scan' ) {
|
||||
$connector = "mainwp_wordfence";
|
||||
$connector = 'mainwp_wordfence';
|
||||
} elseif ( $context == 'media' ) {
|
||||
$connector = "media";
|
||||
$connector = 'media';
|
||||
}
|
||||
|
||||
return $connector;
|
||||
|
@ -181,19 +183,23 @@ class MainWP_Client_Report {
|
|||
'spam' => 'spammed',
|
||||
);
|
||||
|
||||
if (isset($mapping_actions[ $action ]))
|
||||
if ( isset($mapping_actions[ $action ]) ) {
|
||||
return $mapping_actions[ $action ];
|
||||
}
|
||||
|
||||
if ( $context == 'mainwp_maintenance' ) {
|
||||
if ( $action == 'process')
|
||||
if ( $action == 'process' ) {
|
||||
$action = 'maintenance';
|
||||
}
|
||||
} elseif ( $context == 'sucuri_scan' ) {
|
||||
if ( $action == 'checks')
|
||||
if ( $action == 'checks' ) {
|
||||
$action = 'sucuri_scan';
|
||||
}
|
||||
} elseif ( $context == 'wordfence_scan' ) {
|
||||
if ( $action == 'scan')
|
||||
if ( $action == 'scan' ) {
|
||||
$action = 'wordfence_scan';
|
||||
}
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
|
||||
|
@ -248,7 +254,7 @@ class MainWP_Client_Report {
|
|||
$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) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
|
@ -257,7 +263,7 @@ class MainWP_Client_Report {
|
|||
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) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
|
@ -267,7 +273,7 @@ class MainWP_Client_Report {
|
|||
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) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
|
@ -277,7 +283,7 @@ class MainWP_Client_Report {
|
|||
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;
|
||||
}
|
||||
|
@ -287,7 +293,7 @@ class MainWP_Client_Report {
|
|||
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) {
|
||||
if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
|
@ -297,16 +303,17 @@ class MainWP_Client_Report {
|
|||
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) {
|
||||
if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts)
|
||||
if ( $exclude_connector_posts ) {
|
||||
$args['connector__not_in'] = array( 'posts' );
|
||||
///// end fix /////
|
||||
}
|
||||
// end fix /////
|
||||
|
||||
$args['action__not_in'] = array( 'login' );
|
||||
|
||||
|
@ -443,8 +450,9 @@ class MainWP_Client_Report {
|
|||
$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 );
|
||||
|
@ -471,18 +479,17 @@ class MainWP_Client_Report {
|
|||
$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' )
|
||||
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -503,19 +510,18 @@ class MainWP_Client_Report {
|
|||
// 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
|
||||
} 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 ) {
|
||||
|
@ -544,15 +550,17 @@ class MainWP_Client_Report {
|
|||
} 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))
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
$skip_records[] = $record->ID;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +579,6 @@ class MainWP_Client_Report {
|
|||
|
||||
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' ),
|
||||
|
@ -581,7 +588,7 @@ class MainWP_Client_Report {
|
|||
'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' )
|
||||
'optimize' => __( 'Optimize database tables', 'mainwp-child' ),
|
||||
);
|
||||
|
||||
$context = $action = '';
|
||||
|
@ -623,25 +630,26 @@ class MainWP_Client_Report {
|
|||
|
||||
// check connector
|
||||
if ( $record->connector == 'editor' ) {
|
||||
if ( !in_array( $context, array('plugins', 'themes') ) || $action !== 'updated' )
|
||||
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || $action !== 'updated' ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check context
|
||||
if ( $context == "comments" ) { // multi values
|
||||
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
|
||||
} 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
|
||||
//
|
||||
} elseif ( $context !== strtolower( $record->context ) ) {
|
||||
|
@ -649,12 +657,11 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
// 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 ( $context == 'backups' ) {
|
||||
|
@ -695,7 +702,7 @@ class MainWP_Client_Report {
|
|||
if ( 'version' === $data ) {
|
||||
if ( 'old' === $str2 ) {
|
||||
$data = 'old_version';
|
||||
} else if ( 'current' === $str2 && 'wordpress' === $str1 ) {
|
||||
} elseif ( 'current' === $str2 && 'WordPress' === $str1 ) {
|
||||
$data = 'new_version';
|
||||
}
|
||||
}
|
||||
|
@ -726,9 +733,10 @@ class MainWP_Client_Report {
|
|||
case 'display_name':
|
||||
case 'roles':
|
||||
if ( $data == 'name' ) {
|
||||
if ( $context == 'profiles' )
|
||||
if ( $context == 'profiles' ) {
|
||||
$data = 'display_name';
|
||||
}
|
||||
}
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
break;
|
||||
case 'title':
|
||||
|
@ -744,7 +752,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
break;
|
||||
case 'author':
|
||||
if ( $connector == "comment" ) {
|
||||
if ( $connector == 'comment' ) {
|
||||
$data = 'user_name';
|
||||
} else {
|
||||
$data = 'user_meta';
|
||||
|
@ -786,7 +794,6 @@ class MainWP_Client_Report {
|
|||
$tok_value = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
}
|
||||
|
@ -796,11 +803,10 @@ class MainWP_Client_Report {
|
|||
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);
|
||||
$meta_value = explode(',', $meta_value);
|
||||
|
||||
$details = array();
|
||||
|
||||
|
@ -811,7 +817,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
}
|
||||
}
|
||||
$tok_value = implode(", ", $details);
|
||||
$tok_value = implode(', ', $details);
|
||||
|
||||
} elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
|
||||
$meta_value = $this->get_stream_meta_data( $record, $data );
|
||||
|
@ -847,19 +853,17 @@ class MainWP_Client_Report {
|
|||
|
||||
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 ));
|
||||
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;
|
||||
}
|
||||
|
||||
} // foreach $tokens
|
||||
|
||||
if ( ! empty( $token_values ) ) {
|
||||
$loops[ $loop_count ] = $token_values;
|
||||
$loop_count ++;
|
||||
}
|
||||
|
||||
} // foreach $records
|
||||
return $loops;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ 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 ) ) {
|
||||
|
|
|
@ -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 );
|
||||
|
@ -153,13 +153,17 @@ class MainWP_Clone {
|
|||
|
||||
<?php
|
||||
if ( $uploadFile ) {
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#" id="mainwp-child_uploadclonebutton"
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' );
|
||||
?>
|
||||
<a href="#" id="mainwp-child_uploadclonebutton"
|
||||
class="button-primary"
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Clone/Restore website', 'mainwp-child' ); ?></a><?php
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Clone/Restore website', 'mainwp-child' ); ?></a>
|
||||
<?php
|
||||
} else {
|
||||
if ( $uploadError ) {
|
||||
?>
|
||||
<div class="mainwp-child_info-box-red"><?php echo esc_html( $uploadError ); ?></div><?php
|
||||
<div class="mainwp-child_info-box-red"><?php echo esc_html( $uploadError ); ?></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( empty( $sitesToClone ) ) {
|
||||
|
@ -250,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 );
|
||||
|
@ -287,10 +291,13 @@ class MainWP_Clone {
|
|||
</div>
|
||||
<?php
|
||||
if ( $uploadFile ) {
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' ); ?> <a href="#"
|
||||
esc_html_e( 'Upload successful.', 'mainwp-child' );
|
||||
?>
|
||||
<a href="#"
|
||||
id="mainwp-child_uploadclonebutton"
|
||||
class="button-primary"
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a><?php
|
||||
file="<?php echo esc_attr( $uploadFile ); ?>"><?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?></a>
|
||||
<?php
|
||||
} else {
|
||||
if ( $uploadError ) {
|
||||
?>
|
||||
|
@ -448,7 +455,7 @@ class MainWP_Clone {
|
|||
<div class="clonesite_select_site_item">
|
||||
<div class="mainwp-child_name_label">
|
||||
<a href="<?php echo esc_url( add_query_arg( array( 'dir' => rawurlencode( $parent ) ), $url ) ); ?>"
|
||||
title="<?php echo esc_attr( dirname( $current_dir ) ) ?>"><?php esc_html_e( 'Parent Folder', 'mainwp-child' ) ?></a>
|
||||
title="<?php echo esc_attr( dirname( $current_dir ) ); ?>"><?php esc_html_e( 'Parent Folder', 'mainwp-child' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -459,7 +466,7 @@ class MainWP_Clone {
|
|||
?>
|
||||
<div class="clonesite_select_site_item">
|
||||
<div class="mainwp-child_name_label">
|
||||
<a href="<?php echo esc_attr( $folder_url ) ?>"><?php echo esc_html( rtrim( $filename, '/' ) . DIRECTORY_SEPARATOR ); ?></a>
|
||||
<a href="<?php echo esc_attr( $folder_url ); ?>"><?php echo esc_html( rtrim( $filename, '/' ) . DIRECTORY_SEPARATOR ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -469,7 +476,7 @@ class MainWP_Clone {
|
|||
?>
|
||||
<div class="clonesite_select_site_item">
|
||||
<div class="mainwp-child_name_label">
|
||||
<span><?php echo esc_html( $file ) ?></span>
|
||||
<span><?php echo esc_html( $file ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -479,7 +486,7 @@ class MainWP_Clone {
|
|||
?>
|
||||
<div class="mainwp_rejected_files">
|
||||
<div class="mainwp-child_name_label">
|
||||
<span><?php echo esc_html( $file ) ?></span>
|
||||
<span><?php echo esc_html( $file ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -510,9 +517,8 @@ class MainWP_Clone {
|
|||
<script language="javascript">
|
||||
var child_security_nonces = [];
|
||||
<?php
|
||||
$security_nonces = MainWP_Clone::get()->getSecurityNonces();
|
||||
foreach ($security_nonces as $k => $v)
|
||||
{
|
||||
$security_nonces = self::get()->getSecurityNonces();
|
||||
foreach ($security_nonces as $k => $v) {
|
||||
echo 'child_security_nonces[' . "'" . $k . "'" . '] = ' . "'" . $v . "';\n";
|
||||
}
|
||||
?>
|
||||
|
@ -585,8 +591,8 @@ class MainWP_Clone {
|
|||
var translations = [];
|
||||
translations['large_site'] = "<?php esc_html_e( 'This is a large site (%dMB), the restore process will more than likely fail.', 'mainwp-child' ); ?>";
|
||||
translations['continue_anyway'] = "<?php esc_html_e( 'Continue Anyway?', 'mainwp-child' ); ?>";
|
||||
translations['creating_backup'] = "<?php esc_html_e( 'Creating backup on %s expected size: %dMB (estimated time: %d seconds)', 'mainwp-child' ); ?>";
|
||||
translations['backup_created'] = "<?php esc_html_e( 'Backup created on %s total size to download: %dMB', 'mainwp-child' ); ?>";
|
||||
translations['creating_backup'] = "<?php esc_html_e( 'Creating backup on %1$s expected size: %2$dMB (estimated time: %3$d seconds)', 'mainwp-child' ); ?>";
|
||||
translations['backup_created'] = "<?php esc_html_e( 'Backup created on %1$s total size to download: %2$dMB', 'mainwp-child' ); ?>";
|
||||
translations['downloading_backup'] = "<?php esc_html_e( 'Downloading backup', 'mainwp-child' ); ?>";
|
||||
translations['backup_downloaded'] = "<?php esc_html_e( 'Backup downloaded', 'mainwp-child' ); ?>";
|
||||
translations['extracting_backup'] = "<?php esc_html_e( 'Extracting backup and updating your database, this might take a while. Please be patient.', 'mainwp-child' ); ?>";
|
||||
|
@ -1208,7 +1214,7 @@ class MainWP_Clone {
|
|||
'f' => $rand,
|
||||
'wpversion' => $wp_version,
|
||||
'zipmethod' => $method,
|
||||
'json_result' => true
|
||||
'json_result' => true,
|
||||
) );
|
||||
|
||||
if ( ! $result['backup'] ) {
|
||||
|
@ -1219,7 +1225,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() );
|
||||
}
|
||||
|
@ -1253,7 +1262,7 @@ class MainWP_Clone {
|
|||
'cloneFunc' => 'createCloneBackupPoll',
|
||||
'key' => $key,
|
||||
'f' => $rand,
|
||||
'json_result' => true
|
||||
'json_result' => true,
|
||||
) );
|
||||
|
||||
if ( ! isset( $result['size'] ) ) {
|
||||
|
@ -1313,7 +1322,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 );
|
||||
|
@ -1341,7 +1354,7 @@ class MainWP_Clone {
|
|||
'cloneFunc' => 'deleteCloneBackup',
|
||||
'key' => $siteToClone['extauth'],
|
||||
'f' => $_POST['file'],
|
||||
'json_result' => true
|
||||
'json_result' => true,
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
@ -1558,11 +1571,15 @@ class MainWP_Clone {
|
|||
clear: both;
|
||||
}
|
||||
</style>
|
||||
<div class="mainwp-child_info-box-green"><?php if ( get_option( 'mainwp_child_restore_permalink' ) ) {
|
||||
<div class="mainwp-child_info-box-green">
|
||||
<?php
|
||||
if ( get_option( 'mainwp_child_restore_permalink' ) ) {
|
||||
esc_html_e( 'Restore process completed successfully! Check and re-save permalinks ', 'mainwp-child' );
|
||||
} else {
|
||||
esc_html_e( 'Cloning process completed successfully! Check and re-save permalinks ', 'mainwp-child' );
|
||||
} ?> <a
|
||||
}
|
||||
?>
|
||||
<a
|
||||
href="<?php echo esc_attr( admin_url( 'options-permalink.php' ) ); ?>"><?php esc_html_e( 'here', 'mainwp-child' ); ?></a>.
|
||||
</div>
|
||||
<?php
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
class MainWP_Custom_Post_Type {
|
||||
public static $instance = null;
|
||||
public static $information = array();
|
||||
public $plugin_translate = "mainwp-child";
|
||||
public $plugin_translate = 'mainwp-child';
|
||||
|
||||
static function Instance() {
|
||||
if ( MainWP_Custom_Post_Type::$instance == null ) {
|
||||
MainWP_Custom_Post_Type::$instance = new MainWP_Custom_Post_Type();
|
||||
if ( self::$instance == null ) {
|
||||
self::$instance = new MainWP_Custom_Post_Type();
|
||||
}
|
||||
|
||||
return MainWP_Custom_Post_Type::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function action() {
|
||||
|
@ -22,7 +22,7 @@ class MainWP_Custom_Post_Type {
|
|||
$data = array( 'error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] );
|
||||
// die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' );
|
||||
} else {
|
||||
$data = MainWP_Custom_Post_Type::$information;
|
||||
$data = self::$information;
|
||||
// die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' );
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class MainWP_Custom_Post_Type {
|
|||
die('<mainwp>' . base64_encode( $data ) . '</mainwp>');
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -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 ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ class MainWP_Debug {
|
|||
print_r( $mainwpChild->getSiteStats( array(), false ) );
|
||||
}
|
||||
|
||||
|
||||
$stop = microtime( true );
|
||||
die( "\n\n\n" . 'duration: ' . ( $stop - $start ) . 's</pre>' );
|
||||
}
|
||||
|
|
|
@ -102,9 +102,10 @@ class MainWP_Helper {
|
|||
|
||||
static function error( $error, $code = null ) {
|
||||
$information['error'] = $error;
|
||||
if (null !== $code)
|
||||
if (null !== $code) {
|
||||
$information['error_code'] = $code;
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
self::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,19 +127,15 @@ class MainWP_Helper {
|
|||
$ordered = array();
|
||||
for ($i = 0;$i < count($blocks[0]);$i++) {
|
||||
// If @media-block, strip declaration and parenthesis
|
||||
if(substr($blocks[0][$i],0,6) === '@media')
|
||||
{
|
||||
if (substr($blocks[0][ $i ], 0, 6) === '@media') {
|
||||
$ordered_key = preg_replace('/^(@media[^\{]+)\{.*\}$/ms', '$1', $blocks[0][ $i ]);
|
||||
$ordered_value = preg_replace('/^@media[^\{]+\{(.*)\}$/ms', '$1', $blocks[0][ $i ]);
|
||||
}
|
||||
// Rule-blocks of the sort @import or @font-face
|
||||
elseif(substr($blocks[0][$i],0,1) === '@')
|
||||
{
|
||||
elseif (substr($blocks[0][ $i ], 0, 1) === '@') {
|
||||
$ordered_key = $blocks[0][ $i ];
|
||||
$ordered_value = $blocks[0][ $i ];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ordered_key = 'main';
|
||||
$ordered_value = $blocks[0][ $i ];
|
||||
}
|
||||
|
@ -154,7 +151,9 @@ 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");
|
||||
|
@ -163,8 +162,11 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,8 +180,9 @@ class MainWP_Helper {
|
|||
if (substr($media, 0, 6) === '@media') {
|
||||
$output .= $media . " {\n";
|
||||
$prefix = "\t";
|
||||
} else {
|
||||
$prefix = '';
|
||||
}
|
||||
else $prefix = "";
|
||||
|
||||
foreach ($content as $selector => $rules) {
|
||||
$output .= $prefix . $selector . " {\n";
|
||||
|
@ -194,15 +197,15 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
// $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 );
|
||||
|
@ -228,7 +231,10 @@ class MainWP_Helper {
|
|||
if ( file_exists( $temporary_file ) ) {
|
||||
unlink( $temporary_file );
|
||||
}
|
||||
return array( 'id' => $attach->ID, 'url' => $local_img_url );
|
||||
return array(
|
||||
'id' => $attach->ID,
|
||||
'url' => $local_img_url,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +253,10 @@ class MainWP_Helper {
|
|||
if ( file_exists( $temporary_file ) ) {
|
||||
unlink( $temporary_file );
|
||||
}
|
||||
return array( 'id' => $attach->ID, 'url' => $attach->guid );
|
||||
return array(
|
||||
'id' => $attach->ID,
|
||||
'url' => $attach->guid,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +280,7 @@ class MainWP_Helper {
|
|||
'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_status' => 'inherit',
|
||||
'guid' => $local_img_url // to fix
|
||||
'guid' => $local_img_url, // to fix
|
||||
);
|
||||
|
||||
// for post attachments, thumbnail
|
||||
|
@ -280,12 +289,16 @@ 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 );
|
||||
}
|
||||
return array(
|
||||
'id' => $attach_id,
|
||||
'url' => $local_img_url,
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( file_exists( $temporary_file ) ) {
|
||||
|
@ -461,7 +474,6 @@ class MainWP_Helper {
|
|||
$edit_post_id = $new_post['ID'];
|
||||
}
|
||||
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/post.php';
|
||||
if ($edit_post_id) {
|
||||
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
|
||||
|
@ -472,8 +484,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
|
||||
|
@ -497,7 +510,7 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
try {
|
||||
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl, array(), $check_image_existed );
|
||||
$downloadfile = self::uploadImage( $originalImgUrl, array(), $check_image_existed );
|
||||
$localUrl = $downloadfile['url'];
|
||||
$linkToReplaceWith = dirname( $localUrl );
|
||||
if ( '' !== $hrefLink ) {
|
||||
|
@ -535,7 +548,7 @@ class MainWP_Helper {
|
|||
foreach ($post_gallery_images as $gallery) {
|
||||
if (isset($gallery['src'])) {
|
||||
try {
|
||||
$upload = MainWP_Helper::uploadImage( $gallery['src'], $gallery ); //Upload image to WP
|
||||
$upload = self::uploadImage( $gallery['src'], $gallery ); // Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
$replaceAttachedIds[ $gallery['id'] ] = $upload['id'];
|
||||
}
|
||||
|
@ -549,14 +562,14 @@ class MainWP_Helper {
|
|||
if (count($replaceAttachedIds) > 0) {
|
||||
foreach ( $matches as $match ) {
|
||||
$idsToReplace = $match[1];
|
||||
$idsToReplaceWith = "";
|
||||
$idsToReplaceWith = '';
|
||||
$originalIds = explode(',', $idsToReplace);
|
||||
foreach ($originalIds as $attached_id) {
|
||||
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) {
|
||||
$idsToReplaceWith .= $replaceAttachedIds[$attached_id].",";
|
||||
$idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ',';
|
||||
}
|
||||
}
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith,",");
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith, ',');
|
||||
if ( ! empty($idsToReplaceWith)) {
|
||||
$new_post['post_content'] = str_replace( '"' . $idsToReplace . '"', '"' . $idsToReplaceWith . '"', $new_post['post_content'] );
|
||||
}
|
||||
|
@ -631,8 +644,12 @@ class MainWP_Helper {
|
|||
return array( 'error' => 'Empty post id' );
|
||||
}
|
||||
|
||||
if ( !$edit_post_id )
|
||||
wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
|
||||
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' );
|
||||
|
@ -658,7 +675,7 @@ class MainWP_Helper {
|
|||
'_sticky',
|
||||
'_mainwp_post_dripper',
|
||||
'_bulkpost_do_not_del',
|
||||
'_mainwp_spin_me'
|
||||
'_mainwp_spin_me',
|
||||
);
|
||||
$not_allowed[] = '_mainwp_boilerplate_sites_posts';
|
||||
$not_allowed[] = '_ezine_post_keyword';
|
||||
|
@ -689,11 +706,12 @@ 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
|
||||
// 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 );
|
||||
}
|
||||
|
@ -728,7 +746,7 @@ class MainWP_Helper {
|
|||
// upload image if it on the server
|
||||
if ( ! empty( $_seo_opengraph_image ) && strpos( $_seo_opengraph_image, $_server_domain ) !== false ) {
|
||||
try {
|
||||
$upload = MainWP_Helper::uploadImage( $_seo_opengraph_image ); //Upload image to WP
|
||||
$upload = self::uploadImage( $_seo_opengraph_image ); // Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
|
||||
}
|
||||
|
@ -740,7 +758,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 ) {
|
||||
|
@ -764,17 +782,18 @@ class MainWP_Helper {
|
|||
// If featured image exists - set it
|
||||
if ( null !== $post_featured_image ) {
|
||||
try {
|
||||
$upload = MainWP_Helper::uploadImage( $post_featured_image, array(), $check_image_existed, $new_post_id); //Upload image to WP
|
||||
$upload = self::uploadImage( $post_featured_image, array(), $check_image_existed, $new_post_id); // Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post!
|
||||
$featured_image_exist = true;
|
||||
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'],
|
||||
wp_update_post( array(
|
||||
'ID' => $upload['id'],
|
||||
'post_excerpt' => $_image_data['caption'],
|
||||
'post_content' => $_image_data['description'],
|
||||
'post_title' => $_image_data['title']
|
||||
'post_title' => $_image_data['title'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -806,14 +825,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 ) {
|
||||
|
@ -832,7 +857,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
|
||||
|
@ -882,7 +910,7 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
static function checkDir( $dir, $dieOnError, $chmod = 0755 ) {
|
||||
MainWP_Helper::getWPFilesystem();
|
||||
self::getWPFilesystem();
|
||||
global $wp_filesystem;
|
||||
if ( ! file_exists( $dir ) ) {
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
|
@ -911,12 +939,12 @@ class MainWP_Helper {
|
|||
|
||||
public static function validateMainWPDir() {
|
||||
$done = false;
|
||||
$dir = MainWP_Helper::getMainWPDir();
|
||||
$dir = self::getMainWPDir();
|
||||
$dir = $dir[0];
|
||||
if ( MainWP_Helper::getWPFilesystem() ) {
|
||||
if ( self::getWPFilesystem() ) {
|
||||
global $wp_filesystem;
|
||||
try {
|
||||
MainWP_Helper::checkDir( $dir, false );
|
||||
self::checkDir( $dir, false );
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
}
|
||||
|
@ -971,10 +999,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();
|
||||
|
@ -1070,8 +1098,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
|
||||
|
||||
|
@ -1282,8 +1311,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 ) {
|
||||
|
@ -1294,8 +1324,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' )) {
|
||||
|
@ -1400,13 +1431,13 @@ class MainWP_Helper {
|
|||
|
||||
if ( null != $excludes ) {
|
||||
foreach ( $excludes as $exclude ) {
|
||||
if ( MainWP_Helper::endsWith( $exclude, '*' ) ) {
|
||||
if ( MainWP_Helper::startsWith( $value, substr( $exclude, 0, strlen( $exclude ) - 1 ) ) ) {
|
||||
if ( self::endsWith( $exclude, '*' ) ) {
|
||||
if ( self::startsWith( $value, substr( $exclude, 0, strlen( $exclude ) - 1 ) ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( $value == $exclude ) {
|
||||
return true;
|
||||
} else if ( MainWP_Helper::startsWith( $value, $exclude . '/' ) ) {
|
||||
} elseif ( self::startsWith( $value, $exclude . '/' ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1492,16 +1523,18 @@ 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 -_~,;:[]().
|
||||
// If you don't need to handle multi-byte characters
|
||||
// you can use preg_replace rather than mb_ereg_replace
|
||||
// Thanks @Łukasz Rysiak!
|
||||
$filename = mb_ereg_replace( "([^\w\s\d\-_~,;:\[\]\(\).])", '', $filename );
|
||||
$filename = mb_ereg_replace( '([^\w\s\d\-_~,;:\[\]\(\).])', '', $filename );
|
||||
// Remove any runs of periods (thanks falstro!)
|
||||
$filename = mb_ereg_replace( "([\.]{2,})", '', $filename );
|
||||
$filename = mb_ereg_replace( '([\.]{2,})', '', $filename );
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
@ -1562,16 +1595,18 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
return false;
|
||||
}
|
||||
|
||||
public static function isSSLEnabled()
|
||||
{
|
||||
if ( defined( 'MAINWP_NOSSL' ) ) return !MAINWP_NOSSL;
|
||||
public static function isSSLEnabled() {
|
||||
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();
|
||||
|
@ -1604,11 +1639,12 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -1621,9 +1657,10 @@ 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) ) {
|
||||
$message = 'Missing classes: ' . implode(',', $missing);
|
||||
|
@ -1646,8 +1683,9 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
}
|
||||
}
|
||||
} elseif ( ! empty($methods)) {
|
||||
if ( !method_exists($object, $methods) )
|
||||
if ( ! method_exists($object, $methods) ) {
|
||||
$missing[] = $methods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1672,8 +1710,9 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
}
|
||||
}
|
||||
} elseif ( ! empty($properties)) {
|
||||
if ( !property_exists($object, $properties) )
|
||||
if ( ! property_exists($object, $properties) ) {
|
||||
$missing[] = $properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1698,8 +1737,9 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
}
|
||||
}
|
||||
} elseif ( ! empty($funcs)) {
|
||||
if ( !function_exists($funcs) )
|
||||
if ( ! function_exists($funcs) ) {
|
||||
$missing[] = $funcs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1729,15 +1769,13 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
$error = error_get_last();
|
||||
if ( isset( $error['type'] ) && isset( $error['message'] ) &&
|
||||
( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] )
|
||||
)
|
||||
{
|
||||
MainWP_Helper::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'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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' );
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ class MainWP_Keyword_Links {
|
|||
protected $link_case_sensitive = 1;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === MainWP_Keyword_Links::$instance ) {
|
||||
MainWP_Keyword_Links::$instance = new MainWP_Keyword_Links();
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Keyword_Links();
|
||||
}
|
||||
|
||||
return MainWP_Keyword_Links::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -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' ) ) {
|
||||
|
@ -126,7 +126,7 @@ class MainWP_Keyword_Links {
|
|||
|
||||
return true;
|
||||
} elseif ( '' === get_option( 'permalink_structure' ) ) {
|
||||
include_once( ABSPATH . '/wp-admin/includes/misc.php' );
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php';
|
||||
$redirection_folder = $this->get_option( 'redirection_folder', '' );
|
||||
if ( empty( $redirection_folder ) ) {
|
||||
$rules = $this->get_cloak_rules();
|
||||
|
@ -313,7 +313,7 @@ class MainWP_Keyword_Links {
|
|||
|
||||
// print_r($this->keyword_links);
|
||||
// if ($post->ID == 751) {
|
||||
// //print_r($links);
|
||||
// print_r($links);
|
||||
// $custom = get_post_custom($post->ID);
|
||||
// print_r($custom);
|
||||
// }
|
||||
|
@ -416,12 +416,12 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
|
||||
// if (isset($this->link_temp->type) && $this->link_temp->type == 'post_type') {
|
||||
//// $post = get_post($this->link_temp->id);
|
||||
//// if ($post) {
|
||||
//// $disable_linking = $this->get_option('disable_linking_automatically', array());
|
||||
//// if (in_array($post->post_name, $disable_linking[$post->post_type]))
|
||||
//// return $matches[1]; // do not link to this post
|
||||
//// }
|
||||
// $post = get_post($this->link_temp->id);
|
||||
// if ($post) {
|
||||
// $disable_linking = $this->get_option('disable_linking_automatically', array());
|
||||
// if (in_array($post->post_name, $disable_linking[$post->post_type]))
|
||||
// return $matches[1]; // do not link to this post
|
||||
// }
|
||||
// $link_target = get_post_meta($this->link_temp->id, '_mainwp_kl_link_newtab', true);
|
||||
// $this->link_temp->link_target = ( $link_target != -1 && $link_target == 1 ? '_blank' : '' );
|
||||
// $link_rel = get_post_meta($this->link_temp->id, '_mainwp_kl_link_nofollow', true);
|
||||
|
@ -484,7 +484,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
$links = array();
|
||||
// $disable_add_links = $this->get_option('disable_add_links_automatically');
|
||||
// // if disabled add links automatically in this post, avoid
|
||||
// if disabled add links automatically in this post, avoid
|
||||
// if (in_array($post->post_name, (array) $disable_add_links[$post->post_type])) {
|
||||
// return $links;
|
||||
// }
|
||||
|
@ -571,7 +571,7 @@ class MainWP_Keyword_Links {
|
|||
if ( in_array( $result->post_name, (array) $paths_blocked ) ) {
|
||||
continue;
|
||||
}
|
||||
$link = new stdClass;
|
||||
$link = new stdClass();
|
||||
// This is on-fly link so have not ID
|
||||
// $link->id = $result->ID;
|
||||
$link->name = $result->post_title;
|
||||
|
@ -616,7 +616,7 @@ class MainWP_Keyword_Links {
|
|||
if ( ! preg_match( '|^[a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]+$|i', $request ) ) {
|
||||
return;
|
||||
}
|
||||
// Check to see if Wordpress is installed in sub folder
|
||||
// Check to see if WordPress is installed in sub folder
|
||||
$siteurl = parse_url( $this->siteurl );
|
||||
$sitepath = ( isset( $siteurl['path'] ) ) ? $siteurl['path'] : '';
|
||||
$filter_request = preg_replace( '|^' . $sitepath . '/?|i', '', $request );
|
||||
|
@ -684,7 +684,7 @@ class MainWP_Keyword_Links {
|
|||
// $stat_data = get_option('mainwp_kwl_statistic_data_' . $link_id, array());
|
||||
// if ($stat_data) {
|
||||
// $return['stat_data'] = $stat_data;
|
||||
// //$wpdb->query("UPDATE {$wpdb->prefix}options SET option_name = 'mainwp_kwl_statistic_data_done_" . $link_id . "' WHERE option_name = 'mainwp_kwl_statistic_data_" . $link_id . "'");
|
||||
// $wpdb->query("UPDATE {$wpdb->prefix}options SET option_name = 'mainwp_kwl_statistic_data_done_" . $link_id . "' WHERE option_name = 'mainwp_kwl_statistic_data_" . $link_id . "'");
|
||||
// update_option('mainwp_kwl_statistic_data_' . $link_id, '');
|
||||
// } else
|
||||
// $return['stat_data'] = 'EMPTY';
|
||||
|
@ -885,7 +885,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
|
||||
$old = $this->get_link( $link_id );
|
||||
$link = new stdClass;
|
||||
$link = new stdClass();
|
||||
$link->id = intval( $link_id );
|
||||
$link->name = sanitize_text_field( $_POST['name'] );
|
||||
$link->destination_url = esc_url( $_POST['destination_url'] );
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
class MainWP_Security {
|
||||
public static function fixAll() {
|
||||
MainWP_Security::remove_wp_version();
|
||||
MainWP_Security::remove_rsd();
|
||||
MainWP_Security::remove_wlw();
|
||||
self::remove_wp_version();
|
||||
self::remove_rsd();
|
||||
self::remove_wlw();
|
||||
// MainWP_Security::remove_core_update();
|
||||
// MainWP_Security::remove_plugin_update();
|
||||
// MainWP_Security::remove_theme_update();
|
||||
MainWP_Security::remove_php_reporting();
|
||||
MainWP_Security::remove_registered_versions();
|
||||
MainWP_Security::remove_generator_version();
|
||||
MainWP_Security::remove_readme();
|
||||
self::remove_php_reporting();
|
||||
self::remove_registered_versions();
|
||||
self::remove_generator_version();
|
||||
self::remove_readme();
|
||||
|
||||
add_filter( 'style_loader_src', array( 'MainWP_Security', 'remove_script_versions' ), PHP_INT_MAX );
|
||||
add_filter( 'style_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
|
@ -23,9 +23,9 @@ class MainWP_Security {
|
|||
private static $listingDirectories = null;
|
||||
|
||||
private static function init_listingDirectories() {
|
||||
if ( null === MainWP_Security::$listingDirectories ) {
|
||||
if ( null === self::$listingDirectories ) {
|
||||
$wp_upload_dir = wp_upload_dir();
|
||||
MainWP_Security::$listingDirectories = array(
|
||||
self::$listingDirectories = array(
|
||||
WP_CONTENT_DIR,
|
||||
WP_PLUGIN_DIR,
|
||||
get_theme_root(),
|
||||
|
@ -35,8 +35,8 @@ class MainWP_Security {
|
|||
}
|
||||
|
||||
public static function prevent_listing_ok() {
|
||||
MainWP_Security::init_listingDirectories();
|
||||
foreach ( MainWP_Security::$listingDirectories as $directory ) {
|
||||
self::init_listingDirectories();
|
||||
foreach ( self::$listingDirectories as $directory ) {
|
||||
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
|
||||
if ( ! file_exists( $file ) ) {
|
||||
return false;
|
||||
|
@ -47,8 +47,8 @@ class MainWP_Security {
|
|||
}
|
||||
|
||||
public static function prevent_listing() {
|
||||
MainWP_Security::init_listingDirectories();
|
||||
foreach ( MainWP_Security::$listingDirectories as $directory ) {
|
||||
self::init_listingDirectories();
|
||||
foreach ( self::$listingDirectories as $directory ) {
|
||||
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
|
||||
if ( ! file_exists( $file ) ) {
|
||||
$h = fopen( $file, 'w' );
|
||||
|
@ -179,8 +179,8 @@ class MainWP_Security {
|
|||
private static $permission_checks = null;
|
||||
|
||||
private static function init_permission_checks() {
|
||||
if ( null === MainWP_Security::$permission_checks ) {
|
||||
MainWP_Security::$permission_checks = array(
|
||||
if ( null === self::$permission_checks ) {
|
||||
self::$permission_checks = array(
|
||||
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../' => '0755',
|
||||
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-includes' => '0755',
|
||||
WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644',
|
||||
|
@ -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,9 @@ 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 +365,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' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@ class MainWP_Wordpress_SEO {
|
|||
public static $instance = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === MainWP_Wordpress_SEO::$instance ) {
|
||||
MainWP_Wordpress_SEO::$instance = new MainWP_Wordpress_SEO();
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Wordpress_SEO();
|
||||
}
|
||||
|
||||
return MainWP_Wordpress_SEO::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -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 ) ) {
|
||||
|
@ -175,12 +175,10 @@ class MainWP_Wordpress_SEO {
|
|||
$rank = new WPSEO_Rank( WPSEO_Rank::NO_INDEX );
|
||||
$title = __( 'Post is set to noindex.', 'wordpress-seo' );
|
||||
WPSEO_Meta::set_value( 'linkdex', 0, $post_id );
|
||||
}
|
||||
elseif ( '' === WPSEO_Meta::get_value( 'focuskw', $post_id ) ) {
|
||||
} elseif ( '' === WPSEO_Meta::get_value( 'focuskw', $post_id ) ) {
|
||||
$rank = new WPSEO_Rank( WPSEO_Rank::NO_FOCUS );
|
||||
$title = __( 'Focus keyword not set.', 'wordpress-seo' );
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$score = (int) WPSEO_Meta::get_value( 'linkdex', $post_id );
|
||||
$rank = WPSEO_Rank::from_numeric_score( $score );
|
||||
$title = $rank->get_label();
|
||||
|
|
|
@ -250,7 +250,7 @@ class Tar_Archiver {
|
|||
'home' => get_option( 'home' ),
|
||||
'abspath' => ABSPATH,
|
||||
'prefix' => $wpdb->prefix,
|
||||
'lang' => get_bloginfo("language"),
|
||||
'lang' => get_bloginfo('language'),
|
||||
'plugins' => $plugins,
|
||||
'themes' => $themes,
|
||||
) ) );
|
||||
|
|
|
@ -23,9 +23,8 @@
|
|||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.5",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"phpunit/phpunit": "^6.5",
|
||||
"wp-cli/wp-cli": "^2.0",
|
||||
"wp-coding-standards/wpcs": "^2.2.0"
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"wp-cli/wp-cli": "^2.0"
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
|
@ -54,7 +53,7 @@
|
|||
"prefer-stable": true,
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.3"
|
||||
"php": "7.4"
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
|
|
76
composer.lock
generated
76
composer.lock
generated
|
@ -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,
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
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 );
|
||||
define( 'MAINWP_DEBUG', false );
|
||||
|
||||
if ( ! defined( 'MAINWP_CHILD_FILE' ) ) {
|
||||
define( 'MAINWP_CHILD_FILE', __FILE__ );
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
73
phpcs.xml
Normal file
73
phpcs.xml
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0"?>
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
|
||||
|
||||
<description>The Coding standard for the MainWP Child plugin.</description>
|
||||
|
||||
<file>.</file>
|
||||
|
||||
<arg value="sp"/>
|
||||
<arg name="extensions" value="php"/>
|
||||
<arg name="basepath" value="."/>
|
||||
<arg name="parallel" value="8"/>
|
||||
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/bin/*</exclude-pattern>
|
||||
<exclude-pattern>*/.github/*</exclude-pattern>
|
||||
<exclude-pattern>*/tests/*</exclude-pattern>
|
||||
|
||||
<rule ref="WordPress">
|
||||
<exclude name="WordPress.Files.FileName"/>
|
||||
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
|
||||
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
|
||||
|
||||
<!-- Disable Nonce verification due to large number of false positives. -->
|
||||
<exclude name="WordPress.Security.NonceVerification"/>
|
||||
|
||||
<!-- Disable Escaping output check due to large number of false positives. -->
|
||||
<exclude name="WordPress.Security.EscapeOutput"/>
|
||||
|
||||
<!-- Disable Strict comparison check. Not applicable in the mojority of cases. -->
|
||||
<exclude name="WordPress.PHP.StrictComparisons"/>
|
||||
|
||||
<!-- Disable Strict comparison in array check. Not applicable in the mojority of cases. -->
|
||||
<exclude name="WordPress.PHP.StrictInArray"/>
|
||||
|
||||
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
|
||||
|
||||
<exclude name="Squiz.ControlStructures.ControlSignature"/>
|
||||
</rule>
|
||||
|
||||
<!-- Enforce PSR1 compatible namespaces. -->
|
||||
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
||||
|
||||
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
|
||||
<properties>
|
||||
<property name="alignMultilineItems" value="!=100"/>
|
||||
<property name="exact" value="false" phpcs-only="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="PSR2.Methods.FunctionClosingBrace"/>
|
||||
|
||||
<!-- Check code for cross-version PHP compatibility. -->
|
||||
<config name="testVersion" value="5.4-"/>
|
||||
<rule ref="PHPCompatibility">
|
||||
<!-- Exclude PHP constants back-filled by PHPCS. -->
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_finallyFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_yieldFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_ellipsisFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_powFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_pow_equalFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_spaceshipFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesceFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/>
|
||||
<exclude name="PHPCompatibility.Constants.NewConstants.t_yield_fromFound"/>
|
||||
</rule>
|
||||
|
||||
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.DeprecatedWhitelistCommentFound">
|
||||
<!-- False positive for whitelist comment recognition, but no use fixing this now
|
||||
as the WPCS native whitelist comments are deprecated anyhow. -->
|
||||
<exclude-pattern>/WordPress/AbstractClassRestrictionsSniff\.php$</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
bootstrap="tests/bootstrap.php"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory prefix="test-" suffix=".php">./tests/</directory>
|
||||
<exclude>./tests/test-sample.php</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
Loading…
Add table
Add a link
Reference in a new issue