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.
|
||||
|
|
|
@ -43,7 +43,7 @@ class MainWP_Backup {
|
|||
$pid = trailingslashit( $backupdir ) . 'backup-' . $pid . '.pid';
|
||||
}
|
||||
|
||||
//Verify if another backup is running, if so, return an error
|
||||
// Verify if another backup is running, if so, return an error
|
||||
$files = glob( $backupdir . '*.pid' );
|
||||
foreach ( $files as $file ) {
|
||||
if ( basename( $file ) == basename( $pid ) ) {
|
||||
|
@ -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 );
|
||||
|
@ -109,9 +94,9 @@ class MainWP_Backup {
|
|||
|
||||
if ( null !== $this->archiver ) {
|
||||
$success = $this->archiver->createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append );
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$success = $this->createZipFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp );
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
$success = $this->createZipConsoleFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp );
|
||||
} else {
|
||||
$success = $this->createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp );
|
||||
|
@ -125,7 +110,7 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function zipFile( $files, $archive ) {
|
||||
$this->timeout = 20 * 60 * 60; /*20 minutes*/
|
||||
$this->timeout = 20 * 60 * 60;
|
||||
$mem = '512M';
|
||||
// @codingStandardsIgnoreStart
|
||||
@ini_set( 'memory_limit', $mem );
|
||||
|
@ -133,15 +118,15 @@ class MainWP_Backup {
|
|||
@ini_set( 'max_execution_time', $this->timeout );
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
if ( !is_array( $files ) ) {
|
||||
$files = array ($files );
|
||||
if ( ! is_array( $files ) ) {
|
||||
$files = array( $files );
|
||||
}
|
||||
|
||||
if ( null !== $this->archiver ) {
|
||||
$success = $this->archiver->zipFile( $files, $archive );
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$success = $this->_zipFile( $files, $archive );
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
$success = $this->_zipFileConsole( $files, $archive );
|
||||
} else {
|
||||
$success = $this->_zipFilePcl( $files, $archive );
|
||||
|
@ -172,8 +157,8 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function _zipFilePcl( $files, $archive ) {
|
||||
//Zip this backup folder..
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
// Zip this backup folder..
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
$this->zip = new PclZip( $archive );
|
||||
|
||||
$error = false;
|
||||
|
@ -183,7 +168,7 @@ class MainWP_Backup {
|
|||
}
|
||||
}
|
||||
|
||||
return !$error;
|
||||
return ! $error;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,7 +187,6 @@ class MainWP_Backup {
|
|||
*/
|
||||
public function checkZipConsole() {
|
||||
return false;
|
||||
// return function_exists('system');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,7 +232,7 @@ class MainWP_Backup {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -280,7 +264,7 @@ class MainWP_Backup {
|
|||
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
|
||||
if ( is_dir( $node ) ) {
|
||||
$this->zipAddDir( $node, $excludes );
|
||||
} else if ( is_file( $node ) ) {
|
||||
} elseif ( is_file( $node ) ) {
|
||||
$this->addFileToZip( $node, str_replace( ABSPATH, '', $node ) );
|
||||
}
|
||||
}
|
||||
|
@ -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 ) {
|
||||
|
@ -382,7 +366,7 @@ class MainWP_Backup {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -408,13 +392,13 @@ 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;
|
||||
break;
|
||||
}
|
||||
} else if ( is_file( $node ) ) {
|
||||
} elseif ( is_file( $node ) ) {
|
||||
if ( 0 === ( $rslt = $this->zip->add( $node, PCLZIP_OPT_REMOVE_PATH, ABSPATH ) ) ) {
|
||||
$error = true;
|
||||
break;
|
||||
|
@ -471,7 +455,7 @@ class MainWP_Backup {
|
|||
$newnodes = glob( $node . DIRECTORY_SEPARATOR . '*' );
|
||||
$this->copy_dir( $newnodes, $excludes, $backupfolder, $excludenonwp, false );
|
||||
unset( $newnodes );
|
||||
} else if ( is_file( $node ) ) {
|
||||
} elseif ( is_file( $node ) ) {
|
||||
if ( $this->excludeZip && MainWP_Helper::endsWith( $node, '.zip' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -485,16 +469,16 @@ class MainWP_Backup {
|
|||
}
|
||||
|
||||
public function createZipPclFullBackup2( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) {
|
||||
//Create backup folder
|
||||
// Create backup folder
|
||||
$backupFolder = dirname( $filepath ) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR;
|
||||
// @codingStandardsIgnoreStart
|
||||
@mkdir( $backupFolder );
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
//Create DB backup
|
||||
// Create DB backup
|
||||
$db_files = $this->createBackupDB( $backupFolder . 'dbBackup' );
|
||||
|
||||
//Copy installation to backup folder
|
||||
// Copy installation to backup folder
|
||||
$nodes = glob( ABSPATH . '*' );
|
||||
if ( ! $includeCoreFiles ) {
|
||||
$coreFiles = array(
|
||||
|
@ -523,7 +507,7 @@ class MainWP_Backup {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -546,8 +530,8 @@ class MainWP_Backup {
|
|||
// @codingStandardsIgnoreEnd
|
||||
unset( $nodes );
|
||||
|
||||
//Zip this backup folder..
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
// Zip this backup folder..
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
$this->zip = new PclZip( $filepath );
|
||||
$this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder );
|
||||
if ( $addConfig ) {
|
||||
|
@ -562,7 +546,7 @@ class MainWP_Backup {
|
|||
|
||||
$this->addFileFromStringToPCLZip( 'clone/config.txt', $string, $filepath );
|
||||
}
|
||||
//Remove backup folder
|
||||
// Remove backup folder
|
||||
MainWP_Helper::delete_dir( $backupFolder );
|
||||
|
||||
return true;
|
||||
|
@ -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,13 +593,13 @@ 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;
|
||||
break;
|
||||
}
|
||||
} else if ( is_file( $node ) ) {
|
||||
} elseif ( is_file( $node ) ) {
|
||||
if ( 0 === ( $rslt = $this->zip->add( $node, PCLZIP_OPT_REMOVE_PATH, ABSPATH ) ) ) {
|
||||
$error = true;
|
||||
break;
|
||||
|
@ -657,7 +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;
|
||||
|
@ -693,7 +660,7 @@ class MainWP_Backup {
|
|||
$this->zipArchiveSizeCount += filesize( $path );
|
||||
$this->gcCnt ++;
|
||||
|
||||
//5 mb limit!
|
||||
// 5 mb limit!
|
||||
if ( ! $this->loadFilesBeforeZip || ( filesize( $path ) > 5 * 1024 * 1024 ) ) {
|
||||
$this->zipArchiveFileCount ++;
|
||||
$added = $this->zip->addFile( $path, $zipEntryName );
|
||||
|
@ -719,7 +686,7 @@ class MainWP_Backup {
|
|||
$this->gcCnt = 0;
|
||||
}
|
||||
|
||||
//Over limits?
|
||||
// Over limits?
|
||||
if ( ( ( $this->file_descriptors > 0 ) && ( $this->zipArchiveFileCount > $this->file_descriptors ) ) ) { // || $this->zipArchiveSizeCount >= (31457280 * 2))
|
||||
$this->zip->close();
|
||||
$this->zip = null;
|
||||
|
@ -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 );
|
||||
|
@ -760,7 +725,7 @@ class MainWP_Backup {
|
|||
global $wpdb;
|
||||
|
||||
$db_files = array();
|
||||
//Get all the tables
|
||||
// Get all the tables
|
||||
$tables_db = $wpdb->get_results( 'SHOW TABLES FROM `' . DB_NAME . '`', ARRAY_N );
|
||||
foreach ( $tables_db as $curr_table ) {
|
||||
if ( null !== $archiver ) {
|
||||
|
@ -774,11 +739,11 @@ class MainWP_Backup {
|
|||
if ( file_exists( $currentfile ) ) {
|
||||
continue;
|
||||
}
|
||||
$fh = fopen( $currentfile . '.tmp', 'w' ); //or error;
|
||||
$fh = fopen( $currentfile . '.tmp', 'w' ); // or error;
|
||||
|
||||
fwrite( $fh, "\n\n" . 'DROP TABLE IF EXISTS ' . $table . ';' );
|
||||
//todo fix this
|
||||
//$table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N );
|
||||
// todo fix this
|
||||
// $table_create = $wpdb->get_row( $wpdb->prepare( 'SHOW CREATE TABLE %s', $table ), ARRAY_N );
|
||||
$table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N );
|
||||
fwrite( $fh, "\n" . $table_create[1] . ";\n\n" );
|
||||
|
||||
|
@ -839,11 +804,10 @@ class MainWP_Backup {
|
|||
@unlink( $db_file );
|
||||
}
|
||||
} else {
|
||||
//todo: throw exception!
|
||||
// todo: throw exception!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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' ) );
|
||||
|
||||
|
@ -66,7 +67,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
if ( ! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
if ( isset( $value->response['backupwordpress/backupwordpress.php'] ) ) {
|
||||
|
@ -154,7 +155,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) {
|
||||
try {
|
||||
$information['syncBackUpWordPress'] = $this->get_sync_data();
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -201,9 +202,13 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
|
||||
// ok
|
||||
public function do_reports_log($ext = '') {
|
||||
if ( $ext !== 'backupwordpress' ) return;
|
||||
if (!$this->is_plugin_installed) return;
|
||||
public function do_reports_log( $ext = '') {
|
||||
if ( $ext !== 'backupwordpress' ) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->is_plugin_installed) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
MainWP_Helper::check_classes_exists('HM\BackUpWordPress\Schedules');
|
||||
|
@ -216,22 +221,22 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$check = current($schedules);
|
||||
MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' ));
|
||||
|
||||
foreach($schedules as $schedule) {
|
||||
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 );
|
||||
if ( ! empty( $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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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() ) ) {
|
||||
|
@ -316,14 +320,15 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$schedule_id = $this->check_schedule();
|
||||
if (function_exists('hmbkp_run_schedule_async')) {
|
||||
hmbkp_run_schedule_async($schedule_id);
|
||||
} else if (function_exists('\HM\BackUpWordPress\run_schedule_async')) {
|
||||
} elseif (function_exists('\HM\BackUpWordPress\run_schedule_async')) {
|
||||
HM\BackUpWordPress\Path::get_instance()->cleanup();
|
||||
// Fixes an issue on servers which only allow a single session per client
|
||||
session_write_close();
|
||||
$task = new \HM\Backdrop\Task( '\HM\BackUpWordPress\run_schedule_async', $schedule_id );
|
||||
$task->schedule();
|
||||
} else
|
||||
} else {
|
||||
return array( 'error' => __('Error while trying to trigger the schedule', 'mainwp-child') );
|
||||
}
|
||||
return array( 'result' => 'SUCCESS' );
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
} else if (function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
||||
<?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 ) {
|
||||
|
||||
|
@ -575,7 +586,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
?>
|
||||
<div class="hmbkp-exclude-settings">
|
||||
|
||||
<?php //if ( $schedule->get_excludes() ) : ?>
|
||||
<?php // if ( $schedule->get_excludes() ) : ?>
|
||||
|
||||
<h3>
|
||||
<?php esc_html_e( 'Currently Excluded', 'backupwordpress' ); ?>
|
||||
|
@ -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
|
||||
$is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ) ;
|
||||
} 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 ) ) : ?>
|
||||
|
@ -645,7 +658,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
</table>
|
||||
|
||||
<?php //endif; ?>
|
||||
<?php // endif; ?>
|
||||
|
||||
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'backupwordpress' ); ?></h3>
|
||||
|
||||
|
@ -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() ) {
|
||||
//echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
|
||||
<?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')) {
|
||||
|
@ -1123,7 +1150,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
}
|
||||
}
|
||||
|
||||
return array('result' => 'SUCCESS');
|
||||
return array( 'result' => 'SUCCESS' );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1136,11 +1163,11 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
return array( 'error' => 'Error: Schedule data' );
|
||||
}
|
||||
|
||||
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
|
||||
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
|
||||
// // do not update 'excludes' value
|
||||
// $options['excludes'] = $current_value['excludes'];
|
||||
// }
|
||||
// $current_value = get_option( 'hmbkp_schedule_' . $sch_id );
|
||||
// if ( is_array( $current_value ) && isset( $current_value['excludes'] ) ) {
|
||||
// do not update 'excludes' value
|
||||
// $options['excludes'] = $current_value['excludes'];
|
||||
// }
|
||||
|
||||
$filter_opts = array(
|
||||
'type',
|
||||
|
@ -1194,9 +1221,10 @@ 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'] ) )
|
||||
foreach ($schedules as $sch_id => $sch) {
|
||||
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;
|
||||
} else if ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
||||
} elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
|
||||
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
|
||||
MainWP_Helper::check_files_exists(array( $file_path ));
|
||||
require_once( $file_path );
|
||||
require_once $file_path;
|
||||
$this->is_backwpup_installed = true;
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
MainWP_Helper::check_methods('get_instance');
|
||||
BackWPup::get_instance();
|
||||
|
||||
//add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
||||
// add_action( 'wp_ajax_mainwp_backwpup_download_backup', array( $this, 'download_backup' ) );
|
||||
add_action( 'admin_init', array( $this, 'init_download_backup' ) );
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
error_reporting( 0 );
|
||||
function mainwp_backwpup_handle_fatal_error() {
|
||||
$error = error_get_last();
|
||||
$info = MainWP_Child_Back_WP_Up::$information;
|
||||
$info = self::$information;
|
||||
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
|
||||
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
|
||||
} else if ( ! empty( $info ) ) {
|
||||
MainWP_Helper::write( MainWP_Child_Back_WP_Up::$information );
|
||||
} elseif ( ! empty( $info ) ) {
|
||||
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' ) );
|
||||
|
||||
|
@ -237,14 +238,17 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
// ok
|
||||
public function do_reports_log($ext = '') {
|
||||
if ( $ext !== 'backwpup' ) return;
|
||||
if (!$this->is_backwpup_installed)
|
||||
public function do_reports_log( $ext = '') {
|
||||
if ( $ext !== 'backwpup' ) {
|
||||
return;
|
||||
}
|
||||
if ( ! $this->is_backwpup_installed) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
MainWP_Helper::check_classes_exists(array('BackWPup_File', 'BackWPup_Job'));
|
||||
MainWP_Helper::check_classes_exists(array( 'BackWPup_File', 'BackWPup_Job' ));
|
||||
MainWP_Helper::check_methods('BackWPup_File', array( 'get_absolute_path' ));
|
||||
MainWP_Helper::check_methods('BackWPup_Job', array( 'read_logheader' ));
|
||||
|
||||
|
@ -254,12 +258,12 @@ class MainWP_Child_Back_WP_Up {
|
|||
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
|
||||
$log_folder = untrailingslashit( $log_folder );
|
||||
|
||||
//load logs
|
||||
// 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,39 +273,40 @@ 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'])) {
|
||||
if (isset($meta['errors']) && ! empty($meta['errors'])) {
|
||||
continue; // do not logging backups have errors
|
||||
}
|
||||
|
||||
$log_items[$mtime] = $meta;
|
||||
$log_items[$mtime]['file'] = $logfile;
|
||||
$log_items[ $mtime ] = $meta;
|
||||
$log_items[ $mtime ]['file'] = $logfile;
|
||||
}
|
||||
|
||||
if ( !empty( $log_items ) ) {
|
||||
if ( ! empty( $log_items ) ) {
|
||||
$job_types = array(
|
||||
'DBDUMP' => __('Database backup', 'mainwp-child'),
|
||||
'FILE' => __('File backup', 'mainwp-child'),
|
||||
'WPEXP' => __('WordPress XML export', 'mainwp-child'),
|
||||
'WPPLUGIN' => __('Installed plugins list', 'mainwp-child'),
|
||||
'DBCHECK' => __('Check database tables', 'mainwp-child')
|
||||
'DBCHECK' => __('Check database tables', 'mainwp-child'),
|
||||
);
|
||||
|
||||
$new_lasttime_logged = $lasttime_logged;
|
||||
|
||||
foreach ($log_items as $log) {
|
||||
$backup_time = $log[ "logtime" ];
|
||||
$backup_time = $log['logtime'];
|
||||
if ($backup_time < $lasttime_logged) {
|
||||
// small than last backup time then skip
|
||||
continue;
|
||||
}
|
||||
$job_job_types = explode('+', $log['type']);
|
||||
$backup_type = '';
|
||||
foreach($job_job_types as $typeid) {
|
||||
if (isset( $job_types[$typeid] )) {
|
||||
$backup_type .= ' + ' . $job_types[$typeid];
|
||||
foreach ($job_job_types as $typeid) {
|
||||
if (isset( $job_types[ $typeid ] )) {
|
||||
$backup_type .= ' + ' . $job_types[ $typeid ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -329,12 +335,12 @@ class MainWP_Child_Back_WP_Up {
|
|||
// ok
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
|
||||
try{
|
||||
try {
|
||||
$lastbackup = MainWP_Helper::get_lasttime_backup('backwpup');
|
||||
$information['syncBackwpupData'] = array(
|
||||
'lastbackup' => $lastbackup
|
||||
'lastbackup' => $lastbackup,
|
||||
);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +348,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
|
||||
function get_destinations_list() {
|
||||
MainWP_Helper::check_classes_exists(array('BackWPup', 'BackWPup_Option'));
|
||||
MainWP_Helper::check_classes_exists(array( 'BackWPup', 'BackWPup_Option' ));
|
||||
MainWP_Helper::check_methods('BackWPup', array( 'get_registered_destinations', 'get_destination' ));
|
||||
MainWP_Helper::check_methods('BackWPup_Option', array( 'get_job_ids', 'get' ));
|
||||
|
||||
|
@ -355,7 +361,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
$dests = BackWPup_Option::get( $jobid, 'destinations' );
|
||||
foreach ( $dests as $dest ) {
|
||||
if ( ! $destinations[ $dest ][ 'class' ] ) {
|
||||
if ( ! $destinations[ $dest ]['class'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -363,7 +369,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ($dest_class && method_exists($dest_class, 'file_get_list')) {
|
||||
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
|
||||
if ( ! empty( $can_do_dest ) ) {
|
||||
$jobdest[ ] = $jobid . '_' . $dest;
|
||||
$jobdest[] = $jobid . '_' . $dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -512,7 +518,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
echo '<tr title="WP_MEMORY_LIMIT"><td>' . __( 'WP memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MEMORY_LIMIT ) . '</td></tr>';
|
||||
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __( 'WP maximum memory limit', 'backwpup' ) . '</td><td>' . esc_html( WP_MAX_MEMORY_LIMIT ) . '</td></tr>';
|
||||
echo '<tr title=""><td>' . __( 'Memory in use', 'backwpup' ) . '</td><td>' . esc_html( size_format( @memory_get_usage( true ), 2 ) ) . '</td></tr>';
|
||||
//disabled PHP functions
|
||||
// disabled PHP functions
|
||||
$disabled = ini_get( 'disable_functions' );
|
||||
if ( ! empty( $disabled ) ) {
|
||||
$disabledarry = explode( ',', $disabled );
|
||||
|
@ -520,7 +526,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
echo esc_html( implode( ', ', $disabledarry ) );
|
||||
echo '</td></tr>';
|
||||
}
|
||||
//Loaded PHP Extensions
|
||||
// Loaded PHP Extensions
|
||||
echo '<tr title=""><td>' . __( 'Loaded PHP Extensions:', 'backwpup' ) . '</td><td>';
|
||||
$extensions = get_loaded_extensions();
|
||||
sort( $extensions );
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -744,7 +765,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$temp_array['website_id'] = $website_id;
|
||||
$array[] = $temp_array;
|
||||
}
|
||||
} else if ( $type == 'backups' ) {
|
||||
} elseif ( $type == 'backups' ) {
|
||||
$without_dupes = array();
|
||||
foreach ( $output->items as $key ) {
|
||||
$temp_array = $key;
|
||||
|
@ -758,7 +779,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
$temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups';
|
||||
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches )) {
|
||||
if ( !empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
|
||||
if ( ! empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
|
||||
$temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1];
|
||||
}
|
||||
error_log('did match' . print_r($matches, true));
|
||||
|
@ -780,11 +801,14 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
return array( 'success' => 1, 'response' => $array );
|
||||
return array(
|
||||
'success' => 1,
|
||||
'response' => $array,
|
||||
);
|
||||
}
|
||||
|
||||
public function init_download_backup() {
|
||||
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || !isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] )) {
|
||||
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || ! isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] )) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
@ -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' );
|
||||
}
|
||||
|
@ -1014,7 +1049,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
// From BackWPup_Destination_Email::edit_ajax
|
||||
if ( $emailmethod ) {
|
||||
//do so if i'm the wp_mail to get the settings
|
||||
// do so if i'm the wp_mail to get the settings
|
||||
global $phpmailer;
|
||||
// (Re)create it, if it's gone missing
|
||||
if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
|
||||
|
@ -1022,10 +1057,10 @@ class MainWP_Child_Back_WP_Up {
|
|||
require_once ABSPATH . WPINC . '/class-smtp.php';
|
||||
$phpmailer = new PHPMailer( true );
|
||||
}
|
||||
//only if PHPMailer really used
|
||||
// only if PHPMailer really used
|
||||
if ( is_object( $phpmailer ) ) {
|
||||
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
|
||||
//get settings from PHPMailer
|
||||
// get settings from PHPMailer
|
||||
$emailmethod = $phpmailer->Mailer;
|
||||
$emailsendmail = $phpmailer->Sendmail;
|
||||
$emailhost = $phpmailer->Host;
|
||||
|
@ -1036,7 +1071,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
}
|
||||
}
|
||||
|
||||
//Generate mail with Swift Mailer
|
||||
// Generate mail with Swift Mailer
|
||||
if ( ! class_exists( 'Swift', false ) ) {
|
||||
require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -1294,7 +1342,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$to_exclude_parsed = array();
|
||||
foreach ( $to_exclude as $key => $value ) {
|
||||
$normalized = wp_normalize_path( trim( $value ) );
|
||||
$normalized and $to_exclude_parsed[$key] = $normalized;
|
||||
$normalized and $to_exclude_parsed[ $key ] = $normalized;
|
||||
}
|
||||
sort( $to_exclude_parsed );
|
||||
BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) );
|
||||
|
@ -1309,7 +1357,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
$normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
|
||||
$normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
|
||||
$realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false;
|
||||
$realpath and $to_include_parsed[$key] = $realpath;
|
||||
$realpath and $to_include_parsed[ $key ] = $realpath;
|
||||
}
|
||||
sort( $to_include_parsed );
|
||||
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
|
||||
|
@ -1327,19 +1375,34 @@ class MainWP_Child_Back_WP_Up {
|
|||
'backupuploads' => FILTER_VALIDATE_BOOLEAN,
|
||||
);
|
||||
|
||||
foreach( $boolean_fields_def as $key => $value ) {
|
||||
BackWPup_Option::update( $id, $key, ! empty( $post_data[$key] ) );
|
||||
foreach ( $boolean_fields_def as $key => $value ) {
|
||||
BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) );
|
||||
}
|
||||
// Parse and save directories to exclude
|
||||
$exclude_dirs_def = array(
|
||||
'backuprootexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backuppluginsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backupcontentexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backupthemesexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backupuploadsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
|
||||
'backuprootexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backuppluginsexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backupcontentexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backupthemesexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
'backupuploadsexcludedirs' => array(
|
||||
'filter' => FILTER_SANITIZE_URL,
|
||||
'flags' => FILTER_FORCE_ARRAY,
|
||||
),
|
||||
);
|
||||
foreach( $exclude_dirs_def as $key => $filter ) {
|
||||
$value = ! empty( $post_data[$key] ) && is_array( $post_data[$key] ) ? $post_data[$key] : array();
|
||||
foreach ( $exclude_dirs_def as $key => $filter ) {
|
||||
$value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array();
|
||||
BackWPup_Option::update( $id, $key, $value );
|
||||
}
|
||||
}
|
||||
|
@ -1367,7 +1430,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ( $settings['job_id'] > 0 ) {
|
||||
$job_id = intval( $settings['job_id'] );
|
||||
} else {
|
||||
//generate jobid if not exists
|
||||
// generate jobid if not exists
|
||||
$newjobid = BackWPup_Option::get_job_ids();
|
||||
sort( $newjobid );
|
||||
$job_id = end( $newjobid ) + 1;
|
||||
|
@ -1376,8 +1439,8 @@ class MainWP_Child_Back_WP_Up {
|
|||
update_site_option( 'backwpup_messages', array() );
|
||||
|
||||
if (isset($settings['value']['backupdir']) && empty($settings['value']['backupdir'])) {
|
||||
$backupdir = BackWPup_Option::get( (int)$job_id, 'backupdir' );
|
||||
if (!empty($backupdir)) {
|
||||
$backupdir = BackWPup_Option::get( (int) $job_id, 'backupdir' );
|
||||
if ( ! empty($backupdir)) {
|
||||
$settings['value']['backupdir'] = $backupdir;
|
||||
}
|
||||
}
|
||||
|
@ -1389,13 +1452,13 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ($settings['tab'] == 'jobtype-FILE') {
|
||||
// to fix
|
||||
$this->edit_form_post_save($settings['value'], $job_id);
|
||||
//saved message
|
||||
// saved message
|
||||
$messages = BackWPup_Admin::get_messages();
|
||||
if ( empty( $messages['error'] ) ) {
|
||||
$url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id );
|
||||
BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
|
||||
}
|
||||
} else if ($settings['tab'] == 'dest-DROPBOX') {
|
||||
} elseif ($settings['tab'] == 'dest-DROPBOX') {
|
||||
unset($settings['value']); // do not save dropbox settings
|
||||
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
|
||||
} else {
|
||||
|
@ -1437,7 +1500,7 @@ class MainWP_Child_Back_WP_Up {
|
|||
if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) {
|
||||
$changes_array[ $key ] = $temp_value;
|
||||
}
|
||||
} else if ( strcmp( $temp_value, $val ) != 0 ) {
|
||||
} elseif ( strcmp( $temp_value, $val ) != 0 ) {
|
||||
$changes_array[ $key ] = $temp_value;
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -1519,12 +1586,11 @@ class MainWP_Child_Back_WP_Up {
|
|||
|
||||
if ( isset( $message['error'] ) ) {
|
||||
return array( 'error' => implode( ', ', $message['error'] ) );
|
||||
} else if ( isset( $message['updated'] ) ) {
|
||||
} elseif ( isset( $message['updated'] ) ) {
|
||||
return array( 'message' => $message['updated'] );
|
||||
} else {
|
||||
return array( 'error' => 'Generic error' );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ class MainWP_Child_Branding {
|
|||
public $child_branding_options = null;
|
||||
|
||||
static function Instance() {
|
||||
if ( null === MainWP_Child_Branding::$instance ) {
|
||||
MainWP_Child_Branding::$instance = new MainWP_Child_Branding();
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Branding();
|
||||
}
|
||||
return MainWP_Child_Branding::$instance;
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
|
@ -20,11 +20,11 @@ class MainWP_Child_Branding {
|
|||
$this->child_branding_options = $this->init_options();
|
||||
}
|
||||
|
||||
function init_options(){
|
||||
function init_options() {
|
||||
|
||||
$opts = get_option( 'mainwp_child_branding_settings' );
|
||||
|
||||
if ( !is_array( $opts ) ) {
|
||||
if ( ! is_array( $opts ) ) {
|
||||
// compatible with old code
|
||||
$opts = array();
|
||||
|
||||
|
@ -38,7 +38,7 @@ class MainWP_Child_Branding {
|
|||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
|
||||
}
|
||||
|
||||
if ( !isset($opts['contact_label']) || empty($opts['contact_label']) ) {
|
||||
if ( ! isset($opts['contact_label']) || empty($opts['contact_label']) ) {
|
||||
$opts['contact_label'] = 'Contact Support';
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -109,7 +110,7 @@ class MainWP_Child_Branding {
|
|||
'mainwp_branding_remove_wp_tools',
|
||||
'mainwp_branding_remove_wp_setting',
|
||||
'mainwp_branding_remove_permalink',
|
||||
//'mainwp_branding_plugin_header', // don't remove header
|
||||
// 'mainwp_branding_plugin_header', // don't remove header
|
||||
'mainwp_branding_button_contact_label',
|
||||
'mainwp_branding_send_email_message',
|
||||
'mainwp_branding_message_return_sender',
|
||||
|
@ -135,7 +136,7 @@ class MainWP_Child_Branding {
|
|||
'remove_wp_tools',
|
||||
'remove_wp_setting',
|
||||
'remove_permalink',
|
||||
//'branding_header', // don't remove header
|
||||
// 'branding_header', // don't remove header
|
||||
'contact_label',
|
||||
'email_message',
|
||||
'message_return_sender',
|
||||
|
@ -144,13 +145,12 @@ class MainWP_Child_Branding {
|
|||
'branding_ext_enabled',
|
||||
);
|
||||
|
||||
foreach($brandingOptions_empty as $opt) {
|
||||
if (isset($this->child_branding_options[$opt])) {
|
||||
$this->child_branding_options[$opt] = '';
|
||||
foreach ($brandingOptions_empty as $opt) {
|
||||
if (isset($this->child_branding_options[ $opt ])) {
|
||||
$this->child_branding_options[ $opt ] = '';
|
||||
}
|
||||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,7 +174,7 @@ class MainWP_Child_Branding {
|
|||
$current_settings = $this->child_branding_options;
|
||||
$current_extra_setting = $this->child_branding_options['extra_settings'];
|
||||
|
||||
//MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
|
||||
$current_settings['branding_ext_enabled'] = 'Y';
|
||||
|
||||
$header = array(
|
||||
|
@ -187,22 +187,22 @@ class MainWP_Child_Branding {
|
|||
|
||||
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin
|
||||
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
|
||||
// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
|
||||
// }
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
|
||||
// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
|
||||
// }
|
||||
|
||||
$current_settings['preserve_branding'] = $settings['child_preserve_branding'];
|
||||
$current_settings['branding_header'] = $header;
|
||||
|
@ -211,7 +211,7 @@ class MainWP_Child_Branding {
|
|||
$current_settings['remove_restore'] = $settings['child_remove_restore'];
|
||||
$current_settings['remove_setting'] = $settings['child_remove_setting'];
|
||||
$current_settings['remove_server_info'] = $settings['child_remove_server_info'];
|
||||
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0 ;
|
||||
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
|
||||
$current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
|
||||
$current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
|
||||
$current_settings['remove_permalink'] = $settings['child_remove_permalink'];
|
||||
|
@ -266,9 +266,12 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['login_image'] = array();
|
||||
} else {
|
||||
try {
|
||||
$upload = $this->uploadImage( $settings['child_login_image_url'] ); //Upload image to WP
|
||||
$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 ) ) {
|
||||
|
@ -280,7 +283,7 @@ class MainWP_Child_Branding {
|
|||
$information['error']['login_image'] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
} else if ( isset( $current_extra_setting['login_image'] ) ) {
|
||||
} elseif ( isset( $current_extra_setting['login_image'] ) ) {
|
||||
$extra_setting['login_image'] = $current_extra_setting['login_image'];
|
||||
}
|
||||
|
||||
|
@ -289,9 +292,12 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['favico_image'] = array();
|
||||
} else {
|
||||
try {
|
||||
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); //Upload image to WP
|
||||
$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 ) ) {
|
||||
|
@ -303,11 +309,11 @@ class MainWP_Child_Branding {
|
|||
$information['error']['favico_image'] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
} else if ( isset( $current_extra_setting['favico_image'] ) ) {
|
||||
} elseif ( isset( $current_extra_setting['favico_image'] ) ) {
|
||||
$extra_setting['favico_image'] = $current_extra_setting['favico_image'];
|
||||
}
|
||||
|
||||
//MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
|
||||
$current_settings['extra_settings'] = $extra_setting;
|
||||
|
||||
// keep it to compatible with old version of child reports plugin
|
||||
|
@ -316,27 +322,27 @@ class MainWP_Child_Branding {
|
|||
} else {
|
||||
MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
|
||||
}
|
||||
//
|
||||
// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
|
||||
// }
|
||||
//
|
||||
// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
|
||||
// }
|
||||
|
||||
// if ( $settings['child_disable_change'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
|
||||
// }
|
||||
// if ( $settings['child_disable_change'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
|
||||
// }
|
||||
|
||||
// if ( $settings['child_disable_switching_theme'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
|
||||
// }
|
||||
// if ( $settings['child_disable_switching_theme'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
|
||||
// }
|
||||
|
||||
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
|
||||
$current_settings['show_support'] = ( $settings['child_show_support_button'] && !empty($settings['child_support_email']) ) ? 'T' : '';
|
||||
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
|
||||
$current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
|
||||
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
|
||||
|
||||
|
@ -348,10 +354,10 @@ 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
|
||||
// Download $img_url
|
||||
$temporary_file = download_url( $img_url );
|
||||
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
|
@ -359,12 +365,15 @@ class MainWP_Child_Branding {
|
|||
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
||||
} else {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); //Local name
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); // Local name
|
||||
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
|
||||
$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 ) ) {
|
||||
|
@ -383,7 +392,7 @@ class MainWP_Child_Branding {
|
|||
if (is_admin()) {
|
||||
// back end
|
||||
add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
|
||||
} else if (is_user_logged_in()) {
|
||||
} elseif (is_user_logged_in()) {
|
||||
// front end
|
||||
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ));
|
||||
}
|
||||
|
@ -402,7 +411,7 @@ class MainWP_Child_Branding {
|
|||
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
|
||||
}
|
||||
|
||||
if ( !isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -410,29 +419,32 @@ 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');
|
||||
}
|
||||
|
||||
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
||||
add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
|
||||
add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9);
|
||||
}
|
||||
|
||||
// to fix
|
||||
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
|
||||
|
@ -448,13 +460,13 @@ class MainWP_Child_Branding {
|
|||
add_filter( 'login_headertext', array( &$this, 'custom_login_headertitle' ) );
|
||||
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
||||
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
||||
//remove_filter( 'update_footer', 'core_update_footer' );
|
||||
// remove_filter( 'update_footer', 'core_update_footer' );
|
||||
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
||||
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
||||
}
|
||||
|
||||
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
||||
add_action( 'admin_init', array($this, 'admin_init'));
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ));
|
||||
}
|
||||
|
||||
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
||||
|
@ -470,9 +482,8 @@ 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
|
||||
} else if ( !current_user_can( 'administrator' ) ) {
|
||||
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,9 +934,8 @@ class MainWP_Child_Branding {
|
|||
*/
|
||||
public function add_support_button_in_top_admin_bar( $wp_admin_bar ) {
|
||||
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
||||
if ( $allow_contact ) {
|
||||
; // ok
|
||||
} else if ( !current_user_can( 'administrator' ) ) {
|
||||
if ( $allow_contact ) {; // ok
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -951,7 +963,7 @@ class MainWP_Child_Branding {
|
|||
public function is_branding() {
|
||||
$opts = $this->child_branding_options;
|
||||
|
||||
if (!isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y') {
|
||||
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -966,7 +978,7 @@ class MainWP_Child_Branding {
|
|||
if ( 'T' === $is_hide ) {
|
||||
return true;
|
||||
}
|
||||
if ( is_array( $branding_header ) && !empty( $branding_header['name'] ) ) {
|
||||
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -985,30 +997,31 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
public function save_branding_options( $name, $val ) {
|
||||
$this->child_branding_options[$name] = $val;
|
||||
$this->child_branding_options[ $name ] = $val;
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
|
||||
}
|
||||
|
||||
public function after_admin_bar_render() {
|
||||
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice' , array());
|
||||
$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' );
|
||||
if ( ! function_exists('get_plugin_updates')) {
|
||||
include_once ABSPATH . '/wp-admin/includes/update.php';
|
||||
}
|
||||
|
||||
$count_hide = 0;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if (is_array($updates)) {
|
||||
foreach($updates as $slug => $data) {
|
||||
foreach ($updates as $slug => $data) {
|
||||
if (in_array($slug, $hide_slugs)) {
|
||||
$count_hide++;
|
||||
}
|
||||
|
@ -1037,22 +1050,23 @@ 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());
|
||||
$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;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if (is_array($updates)) {
|
||||
foreach($updates as $slug => $data) {
|
||||
foreach ($updates as $slug => $data) {
|
||||
if (in_array($slug, $hide_slugs)) {
|
||||
$count_hide++;
|
||||
}
|
||||
|
@ -1115,7 +1129,8 @@ class MainWP_Child_Branding {
|
|||
});
|
||||
}
|
||||
});
|
||||
</script><?php
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
||||
|
@ -1170,7 +1185,7 @@ class MainWP_Child_Branding {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
if ( ! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,32 +20,33 @@ 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 );
|
||||
}
|
||||
// ok
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
|
||||
try{
|
||||
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) {
|
||||
} catch (Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
public function action() {
|
||||
$information = array();
|
||||
if ( ! class_exists( 'ITSEC_Core' ) || !class_exists('ITSEC_Modules')) {
|
||||
if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists('ITSEC_Modules')) {
|
||||
$information['error'] = 'NO_ITHEME';
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
@ -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,15 +131,16 @@ 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' ) );
|
||||
add_action( 'admin_menu', array( $this, 'remove_menu' ) );
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
||||
add_action( 'admin_head', array( &$this, 'custom_admin_css' ) );
|
||||
if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check') ) {
|
||||
if ( isset($_GET['page']) && ( $_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check' ) ) {
|
||||
wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' );
|
||||
exit();
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -193,14 +194,14 @@ class MainWP_Child_iThemes_Security {
|
|||
'404-detection',
|
||||
'network-brute-force',
|
||||
'ssl',
|
||||
//'strong-passwords',
|
||||
// 'strong-passwords',
|
||||
'password-requirements',
|
||||
'system-tweaks',
|
||||
'wordpress-tweaks',
|
||||
'multisite-tweaks',
|
||||
'notification-center',
|
||||
//'salts',
|
||||
//'content-directory',
|
||||
// 'salts',
|
||||
// 'content-directory',
|
||||
);
|
||||
|
||||
$require_permalinks = false;
|
||||
|
@ -210,18 +211,18 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||
|
||||
foreach($update_settings as $module => $settings) {
|
||||
foreach ($update_settings as $module => $settings) {
|
||||
$do_not_save = false;
|
||||
if (in_array($module, $_itsec_modules)) {
|
||||
if ($module == 'wordpress-salts') {
|
||||
$settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update
|
||||
} else if ($module == 'global') {
|
||||
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check' , 'nginx_file' );
|
||||
foreach($keep_olds as $key) {
|
||||
$settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update
|
||||
} elseif ($module == 'global') {
|
||||
$keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' );
|
||||
foreach ($keep_olds as $key) {
|
||||
$settings[ $key ] = ITSEC_Modules::get_setting( $module, $key ); // not update
|
||||
}
|
||||
|
||||
if (!isset($settings['log_location']) || empty($settings['log_location']) ) {
|
||||
if ( ! isset($settings['log_location']) || empty($settings['log_location']) ) {
|
||||
$settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' );
|
||||
} else {
|
||||
$result = $this->validate_directory('log_location', $settings['log_location']);
|
||||
|
@ -231,8 +232,8 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
} else if ($module == 'backup') {
|
||||
if (!isset($settings['location']) || empty($settings['location']) ) {
|
||||
} elseif ($module == 'backup') {
|
||||
if ( ! isset($settings['location']) || empty($settings['location']) ) {
|
||||
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' );
|
||||
} else {
|
||||
$result = $this->validate_directory('location', $settings['location']);
|
||||
|
@ -241,11 +242,12 @@ class MainWP_Child_iThemes_Security {
|
|||
$settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change
|
||||
}
|
||||
}
|
||||
if (!isset($settings['exclude']) ) {
|
||||
$settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );;
|
||||
if ( ! isset($settings['exclude']) ) {
|
||||
$settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );
|
||||
|
||||
}
|
||||
} else if ($module == 'hide-backend') {
|
||||
if (isset($settings['enabled']) && !empty($settings['enabled'])) {
|
||||
} elseif ($module == 'hide-backend') {
|
||||
if (isset($settings['enabled']) && ! empty($settings['enabled'])) {
|
||||
$permalink_structure = get_option( 'permalink_structure', false );
|
||||
if ( empty( $permalink_structure ) && ! is_multisite() ) {
|
||||
$errors[] = __( 'You must change <strong>WordPress permalinks</strong> to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' );
|
||||
|
@ -253,7 +255,7 @@ class MainWP_Child_iThemes_Security {
|
|||
$do_not_save = true;
|
||||
}
|
||||
}
|
||||
} else if ($module == 'network-brute-force') {
|
||||
} elseif ($module == 'network-brute-force') {
|
||||
|
||||
if ( isset( $settings['email'] ) ) {
|
||||
$result = $this->activate_api_key($settings);
|
||||
|
@ -275,17 +277,17 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
}
|
||||
$settings = $nbf_settings;
|
||||
} else if ($module == 'notification-center') {
|
||||
} elseif ($module == 'notification-center') {
|
||||
$current_settings = ITSEC_Modules::get_settings( $module );
|
||||
if (isset($settings['notifications'])) {
|
||||
$update_fields = array( 'schedule', 'enabled', 'subject');
|
||||
$update_fields = array( 'schedule', 'enabled', 'subject' );
|
||||
if (isset($_POST['is_individual']) && $_POST['is_individual']) {
|
||||
$update_fields = array_merge($update_fields, array('user_list', 'email_list'));
|
||||
$update_fields = array_merge($update_fields, array( 'user_list', 'email_list' ));
|
||||
}
|
||||
foreach ($settings['notifications'] as $key => $val) {
|
||||
foreach ($update_fields as $field) {
|
||||
if(isset($val[$field])) {
|
||||
$current_settings['notifications'][$key][$field] = $val[$field];
|
||||
if (isset($val[ $field ])) {
|
||||
$current_settings['notifications'][ $key ][ $field ] = $val[ $field ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +297,7 @@ class MainWP_Child_iThemes_Security {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !$do_not_save ) {
|
||||
if ( ! $do_not_save ) {
|
||||
ITSEC_Modules::set_settings( $module, $settings );
|
||||
$updated = true;
|
||||
}
|
||||
|
@ -305,12 +307,12 @@ class MainWP_Child_iThemes_Security {
|
|||
if ( isset( $update_settings['itsec_active_modules'] ) ) {
|
||||
$current_val = get_site_option( 'itsec_active_modules', array() );
|
||||
foreach ($update_settings['itsec_active_modules'] as $mod => $val) {
|
||||
$current_val[$mod] = $val;
|
||||
$current_val[ $mod ] = $val;
|
||||
}
|
||||
update_site_option( 'itsec_active_modules', $current_val );
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -340,14 +342,15 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
$return['nbf_settings'] = $nbf_settings;
|
||||
|
||||
if (!empty($errors)) {
|
||||
if ( ! empty($errors)) {
|
||||
$return['extra_message'] = $errors;
|
||||
}
|
||||
|
||||
if ($updated)
|
||||
if ($updated) {
|
||||
$return['result'] = 'success';
|
||||
else
|
||||
} else {
|
||||
$return['error'] = __('Not Updated', 'mainwp-child' );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -363,10 +366,10 @@ class MainWP_Child_iThemes_Security {
|
|||
$results = ITSEC_Modules::set_settings( 'network-brute-force', $settings );
|
||||
if ( is_wp_error( $results ) ) {
|
||||
$information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key';
|
||||
} else if ( $results['saved'] ) {
|
||||
} elseif ( $results['saved'] ) {
|
||||
ITSEC_Modules::activate( 'network-brute-force' );
|
||||
$nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' );
|
||||
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
||||
// ITSEC_Response::set_response( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
||||
}
|
||||
}
|
||||
if ($nbf_settings !== null) {
|
||||
|
@ -376,8 +379,8 @@ class MainWP_Child_iThemes_Security {
|
|||
return $information;
|
||||
}
|
||||
|
||||
private function validate_directory($name, $folder) {
|
||||
require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' );
|
||||
private function validate_directory( $name, $folder) {
|
||||
require_once ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php';
|
||||
$error = null;
|
||||
if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) {
|
||||
$result = ITSEC_Lib_Directory::create( $folder );
|
||||
|
@ -399,22 +402,22 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
private function activate_api_key($settings) {
|
||||
private function activate_api_key( $settings) {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once ( $mainwp_itsec_modules_path . 'ipcheck/utilities.php' );
|
||||
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 ) ) {
|
||||
return false;
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $key );
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $key );
|
||||
} else {
|
||||
$secret = ITSEC_Network_Brute_Force_Utilities::activate_api_key( $key );
|
||||
|
||||
if ( is_wp_error( $secret ) ) {
|
||||
return false;
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $secret );
|
||||
// $this->set_can_save( false );
|
||||
// $this->add_error( $secret );
|
||||
} else {
|
||||
$settings['api_key'] = $key;
|
||||
$settings['api_secret'] = $secret;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -512,14 +514,14 @@ class MainWP_Child_iThemes_Security {
|
|||
foreach ( $errors as $error ) {
|
||||
$str_error .= $error . '<br />';
|
||||
}
|
||||
} else if ( is_string( $result ) ) {
|
||||
} elseif ( is_string( $result ) ) {
|
||||
$return['result'] = 'success';
|
||||
$return['message'] = $result;
|
||||
} else {
|
||||
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) ) ;
|
||||
$str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type <code>%1$s</code>.', 'better-wp-security' ), gettype( $result ) );
|
||||
}
|
||||
|
||||
if (!empty($str_error)) {
|
||||
if ( ! empty($str_error)) {
|
||||
$return['error'] = $str_error;
|
||||
}
|
||||
|
||||
|
@ -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 = '';
|
||||
|
@ -542,18 +544,18 @@ class MainWP_Child_iThemes_Security {
|
|||
}
|
||||
} else {
|
||||
$return['result'] = 'success';
|
||||
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ) ;
|
||||
$return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' );
|
||||
$last_generated = ITSEC_Core::get_current_time_gmt();
|
||||
ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated );
|
||||
}
|
||||
if (!empty($str_error)) {
|
||||
if ( ! empty($str_error)) {
|
||||
$return['error'] = $str_error;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
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();
|
||||
?>
|
||||
|
@ -670,13 +670,13 @@ class MainWP_Child_iThemes_Security {
|
|||
<br />
|
||||
<?php
|
||||
$html = ob_get_clean();
|
||||
return array('html' => $html);
|
||||
return array( 'html' => $html );
|
||||
}
|
||||
|
||||
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
|
||||
// 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' );
|
||||
|
@ -710,13 +710,12 @@ class MainWP_Child_iThemes_Security {
|
|||
global $current_user;
|
||||
if ( ! $username_exists ) {
|
||||
$msg = __( 'Admin user already changes.', 'mainwp-child' );
|
||||
} else if ($current_user->user_login == 'admin') {
|
||||
} elseif ($current_user->user_login == 'admin') {
|
||||
$return['result'] = 'CHILD_ADMIN';
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( true === $change_id && ! $user_id_exists ) {
|
||||
if ( ! empty( $msg ) ) {
|
||||
$msg .= '<br/>';
|
||||
|
@ -724,13 +723,13 @@ class MainWP_Child_iThemes_Security {
|
|||
$msg .= __( 'Admin user ID already changes.', 'mainwp-child' );
|
||||
}
|
||||
|
||||
// if ( $change_id ) {
|
||||
// $user = get_user_by( 'login', $new_username );
|
||||
// if ( $user && 1 === (int) $user->ID ) {
|
||||
// $return['result'] = 'CHILD_ADMIN';
|
||||
// return $return;
|
||||
// }
|
||||
// }
|
||||
// if ( $change_id ) {
|
||||
// $user = get_user_by( 'login', $new_username );
|
||||
// if ( $user && 1 === (int) $user->ID ) {
|
||||
// $return['result'] = 'CHILD_ADMIN';
|
||||
// return $return;
|
||||
// }
|
||||
// }
|
||||
|
||||
$admin_success = true;
|
||||
$return = array();
|
||||
|
@ -756,26 +755,26 @@ class MainWP_Child_iThemes_Security {
|
|||
$itsec_files = ITSEC_Core::get_itsec_files();
|
||||
|
||||
// do not need to check this
|
||||
//if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
|
||||
// if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running
|
||||
|
||||
//sanitize the username
|
||||
// sanitize the username
|
||||
$new_user = sanitize_text_field( $username );
|
||||
|
||||
//Get the full user object
|
||||
// Get the full user object
|
||||
$user_object = get_user_by( 'id', '1' );
|
||||
|
||||
if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { //there is a valid username to change
|
||||
if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { // there is a valid username to change
|
||||
|
||||
if ( true === $id ) { //we're changing the id too so we'll set the username
|
||||
if ( true === $id ) { // we're changing the id too so we'll set the username
|
||||
|
||||
$user_login = $new_user;
|
||||
|
||||
} else { // we're only changing the username
|
||||
|
||||
//query main user table
|
||||
$wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
|
||||
// query main user table
|
||||
$wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" );
|
||||
|
||||
if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation
|
||||
if ( is_multisite() ) { // process sitemeta if we're in a multi-site situation
|
||||
|
||||
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
|
||||
$newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins );
|
||||
|
@ -788,19 +787,19 @@ class MainWP_Child_iThemes_Security {
|
|||
return true;
|
||||
|
||||
}
|
||||
} elseif ( null !== $username ) { //username didn't validate
|
||||
} elseif ( null !== $username ) { // username didn't validate
|
||||
|
||||
$itsec_files->release_file_lock( 'admin_user' );
|
||||
|
||||
return false;
|
||||
|
||||
} else { //only changing the id
|
||||
} else { // only changing the id
|
||||
|
||||
$user_login = $user_object->user_login;
|
||||
|
||||
}
|
||||
|
||||
if ( true === $id ) { //change the user id
|
||||
if ( true === $id ) { // change the user id
|
||||
|
||||
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
|
||||
|
||||
|
@ -816,7 +815,7 @@ class MainWP_Child_iThemes_Security {
|
|||
'display_name' => $user_object->display_name,
|
||||
) );
|
||||
|
||||
if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { //process sitemeta if we're in a multi-site situation
|
||||
if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { // process sitemeta if we're in a multi-site situation
|
||||
|
||||
$oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" );
|
||||
$newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins );
|
||||
|
@ -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' );
|
||||
|
@ -837,14 +836,13 @@ class MainWP_Child_iThemes_Security {
|
|||
return true;
|
||||
|
||||
}
|
||||
//}
|
||||
// }
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function build_wpconfig_rules( $rules_array, $input = null ) {
|
||||
//Get the rules from the database if input wasn't sent
|
||||
// Get the rules from the database if input wasn't sent
|
||||
if ( null === $input ) {
|
||||
return $rules_array;
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -936,7 +937,7 @@ class MainWP_Child_iThemes_Security {
|
|||
if ( $results['saved'] ) {
|
||||
$information['result'] = 'success';
|
||||
$information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force');
|
||||
} else if ( empty( $results['errors'] ) ) {
|
||||
} elseif ( empty( $results['errors'] ) ) {
|
||||
$information['error_reset_api'] = 1;
|
||||
}
|
||||
return $information;
|
||||
|
@ -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,11 +966,11 @@ 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();
|
||||
$results = ITSEC_Malware_Scanner::scan();
|
||||
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
|
||||
return $response;
|
||||
}
|
||||
|
@ -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,28 +1111,28 @@ 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) {
|
||||
$current_val[$mod] = $val;
|
||||
$current_val[ $mod ] = $val;
|
||||
}
|
||||
|
||||
update_site_option( 'itsec_active_modules', $current_val );
|
||||
return array('result' => 'success');
|
||||
|
||||
return array( 'result' => 'success' );
|
||||
}
|
||||
|
||||
private function reload_backup_exclude( ) {
|
||||
private function reload_backup_exclude() {
|
||||
return array(
|
||||
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
|
||||
'excludable_tables' => $this->get_excludable_tables(),
|
||||
'result' => 'success'
|
||||
'result' => 'success',
|
||||
);
|
||||
}
|
||||
|
||||
private function get_excludable_tables( ) {
|
||||
private function get_excludable_tables() {
|
||||
global $wpdb;
|
||||
$all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
|
||||
$ignored_tables = array(
|
||||
|
@ -1164,21 +1165,24 @@ class MainWP_Child_iThemes_Security {
|
|||
continue;
|
||||
}
|
||||
|
||||
$excludes[$short_table] = $table[0];
|
||||
$excludes[ $short_table ] = $table[0];
|
||||
}
|
||||
|
||||
return $excludes ;
|
||||
return $excludes;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -1195,7 +1199,7 @@ class MainWP_Child_iThemes_Security {
|
|||
|
||||
foreach ( $roles->roles as $role => $details ) {
|
||||
if ( isset( $details['capabilities']['manage_options'] ) && ( true === $details['capabilities']['manage_options'] ) ) {
|
||||
$available_roles["role:$role"] = translate_user_role( $details['name'] );
|
||||
$available_roles[ "role:$role" ] = translate_user_role( $details['name'] );
|
||||
|
||||
$users = get_users( array( 'role' => $role ) );
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
@ -82,8 +82,8 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
}
|
||||
MainWP_Helper::write( $information );
|
||||
} catch(Exception $e) {
|
||||
MainWP_Helper::write( array('error' => $e->getMessage()) );
|
||||
} catch (Exception $e) {
|
||||
MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,13 +137,13 @@ class MainWP_Child_Links_Checker {
|
|||
global $wpdb;
|
||||
/** @var wpdb $wpdb */
|
||||
|
||||
//Delete all discovered instances
|
||||
// Delete all discovered instances
|
||||
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_instances" );
|
||||
|
||||
//Delete all discovered links
|
||||
// Delete all discovered links
|
||||
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_links" );
|
||||
|
||||
//Mark all posts, custom fields and bookmarks for processing.
|
||||
// Mark all posts, custom fields and bookmarks for processing.
|
||||
blc_resynch( true );
|
||||
}
|
||||
|
||||
|
@ -158,18 +158,18 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
blc_init();
|
||||
|
||||
//Get the container type matching the type of the deleted post
|
||||
// Get the container type matching the type of the deleted post
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
//Get the associated container object
|
||||
// Get the associated container object
|
||||
$post_container = blcContainerHelper::get_container( array( $post->post_type, intval( $post_id ) ) );
|
||||
|
||||
if ( $post_container ) {
|
||||
//Delete it
|
||||
// Delete it
|
||||
$post_container->delete();
|
||||
//Clean up any dangling links
|
||||
// Clean up any dangling links
|
||||
blc_cleanup_links();
|
||||
}
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ class MainWP_Child_Links_Checker {
|
|||
// ok
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
|
||||
try{
|
||||
try {
|
||||
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -266,12 +268,12 @@ class MainWP_Child_Links_Checker {
|
|||
$link_data = $this->links_checker_data($params);
|
||||
|
||||
$total_sync = 0;
|
||||
if ($offset){
|
||||
if ($offset) {
|
||||
$total_sync = $offset;
|
||||
}
|
||||
$total_sync += (is_array($link_data) ? count($link_data) : 0);
|
||||
$total_sync += ( is_array($link_data) ? count($link_data) : 0 );
|
||||
|
||||
$information = array('links_data' => $link_data);
|
||||
$information = array( 'links_data' => $link_data );
|
||||
|
||||
if ($first_sync) {
|
||||
$information['data'] = $this->get_count_links();
|
||||
|
@ -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';
|
||||
|
@ -316,7 +320,7 @@ class MainWP_Child_Links_Checker {
|
|||
return $data;
|
||||
}
|
||||
|
||||
function links_checker_data($params) {
|
||||
function links_checker_data( $params) {
|
||||
|
||||
MainWP_Helper::check_functions('blc_get_links');
|
||||
MainWP_Helper::check_classes_exists('blcLink');
|
||||
|
@ -341,11 +345,11 @@ class MainWP_Child_Links_Checker {
|
|||
'last_success',
|
||||
'may_recheck',
|
||||
'false_positive',
|
||||
//'result_hash',
|
||||
// 'result_hash',
|
||||
'dismissed',
|
||||
'status_text',
|
||||
'status_code',
|
||||
'log'
|
||||
'log',
|
||||
);
|
||||
$return = array();
|
||||
|
||||
|
@ -370,7 +374,7 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
$days_broken = 0;
|
||||
if ( $link->broken ) {
|
||||
//Add a highlight to broken links that appear to be permanently broken
|
||||
// Add a highlight to broken links that appear to be permanently broken
|
||||
$days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) );
|
||||
if ( $days_broken >= $blc_option['failure_duration_threshold'] ) {
|
||||
$extra_info['permanently_broken'] = 1;
|
||||
|
@ -391,7 +395,7 @@ class MainWP_Child_Links_Checker {
|
|||
if ( ! empty( $instances ) ) {
|
||||
$first_instance = reset( $instances );
|
||||
|
||||
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable') );
|
||||
MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) );
|
||||
|
||||
$new_link->link_text = $first_instance->ui_get_link_text();
|
||||
$extra_info['count_instance'] = count( $instances );
|
||||
|
@ -429,7 +433,7 @@ class MainWP_Child_Links_Checker {
|
|||
$link_texts = $can_edit_text ? $editable_link_texts : $non_editable_link_texts;
|
||||
$data_link_text = '';
|
||||
if ( count( $link_texts ) === 1 ) {
|
||||
//All instances have the same text - use it.
|
||||
// All instances have the same text - use it.
|
||||
$link_text = key( $link_texts );
|
||||
$data_link_text = esc_attr( $link_text );
|
||||
}
|
||||
|
@ -449,7 +453,6 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function edit_link() {
|
||||
|
@ -459,14 +462,14 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
return $information;
|
||||
}
|
||||
//Load the link
|
||||
// Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
if ( ! $link->valid() ) {
|
||||
$information['error'] = 'NOTFOUNDLINK'; // Oops, I can't find the link
|
||||
return $information;
|
||||
}
|
||||
|
||||
//Validate the new URL.
|
||||
// Validate the new URL.
|
||||
$new_url = stripslashes( $_POST['new_url'] );
|
||||
$parsed = @parse_url( $new_url );
|
||||
if ( ! $parsed ) {
|
||||
|
@ -479,7 +482,7 @@ class MainWP_Child_Links_Checker {
|
|||
$new_text = null;
|
||||
}
|
||||
if ( ! empty( $new_text ) && ! current_user_can( 'unfiltered_html' ) ) {
|
||||
$new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); //wp_filter_post_kses expects slashed data.
|
||||
$new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); // wp_filter_post_kses expects slashed data.
|
||||
}
|
||||
|
||||
$rez = $link->edit( $new_url, $new_text );
|
||||
|
@ -512,7 +515,7 @@ class MainWP_Child_Links_Checker {
|
|||
'ui_link_text' => isset( $new_text ) ? $ui_link_text : null,
|
||||
'errors' => array(),
|
||||
);
|
||||
//url, status text, status code, link text, editable link text
|
||||
// url, status text, status code, link text, editable link text
|
||||
|
||||
foreach ( $rez['errors'] as $error ) {
|
||||
/** @var $error WP_Error */
|
||||
|
@ -532,7 +535,7 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
if ( isset( $_POST['link_id'] ) ) {
|
||||
//Load the link
|
||||
// Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
|
||||
if ( ! $link->valid() ) {
|
||||
|
@ -540,7 +543,7 @@ class MainWP_Child_Links_Checker {
|
|||
return $information;
|
||||
}
|
||||
|
||||
//Try and unlink it
|
||||
// Try and unlink it
|
||||
$rez = $link->unlink();
|
||||
|
||||
if ( false === $rez ) {
|
||||
|
@ -577,7 +580,7 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
if ( isset( $_POST['link_id'] ) ) {
|
||||
//Load the link
|
||||
// Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
|
||||
if ( ! $link->valid() ) {
|
||||
|
@ -587,7 +590,7 @@ class MainWP_Child_Links_Checker {
|
|||
|
||||
$link->dismissed = $dismiss;
|
||||
|
||||
//Save the changes
|
||||
// Save the changes
|
||||
if ( $link->save() ) {
|
||||
$information = 'OK';
|
||||
} else {
|
||||
|
@ -610,7 +613,7 @@ class MainWP_Child_Links_Checker {
|
|||
return $information;
|
||||
}
|
||||
if ( isset( $_POST['link_id'] ) ) {
|
||||
//Load the link
|
||||
// Load the link
|
||||
$link = new blcLink( intval( $_POST['link_id'] ) );
|
||||
|
||||
if ( ! $link->valid() ) {
|
||||
|
@ -618,13 +621,13 @@ class MainWP_Child_Links_Checker {
|
|||
return $information;
|
||||
}
|
||||
|
||||
//Make it appear "not broken"
|
||||
// Make it appear "not broken"
|
||||
$link->broken = false;
|
||||
$link->false_positive = true;
|
||||
$link->last_check_attempt = time();
|
||||
$link->log = __( 'This link was manually marked as working by the user.', 'mainwp-child' );
|
||||
|
||||
//Save the changes
|
||||
// Save the changes
|
||||
if ( $link->save() ) {
|
||||
$information['status'] = 'OK';
|
||||
$information['last_check_attempt'] = $link->last_check_attempt;
|
||||
|
@ -641,7 +644,7 @@ class MainWP_Child_Links_Checker {
|
|||
function ui_get_source( $container, $container_field = '' ) {
|
||||
if ( 'comment' === $container->container_type ) {
|
||||
return $this->ui_get_source_comment( $container, $container_field );
|
||||
} else if ( $container instanceof blcAnyPostContainer ) {
|
||||
} elseif ( $container instanceof blcAnyPostContainer ) {
|
||||
return $this->ui_get_source_post( $container, $container_field );
|
||||
}
|
||||
|
||||
|
@ -649,19 +652,20 @@ class MainWP_Child_Links_Checker {
|
|||
}
|
||||
|
||||
function ui_get_source_comment( $container, $container_field = '' ) {
|
||||
//Display a comment icon.
|
||||
// Display a comment icon.
|
||||
if ( 'comment_author_url' === $container_field ) {
|
||||
$image = 'font-awesome/font-awesome-user.png';
|
||||
} else {
|
||||
$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();
|
||||
|
||||
//Display a small text sample from the comment
|
||||
// Display a small text sample from the comment
|
||||
$text_sample = strip_tags( $comment->comment_content );
|
||||
$text_sample = blcUtility::truncate( $text_sample, 65 );
|
||||
|
||||
|
|
|
@ -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,12 +76,13 @@ 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' ) );
|
||||
add_action('admin_menu', array($this, 'hide_menu'), 999);
|
||||
add_action('admin_menu', array( $this, 'hide_menu' ), 999);
|
||||
}
|
||||
$this->init_cron();
|
||||
}
|
||||
|
@ -126,9 +128,9 @@ class MainWP_Child_Pagespeed {
|
|||
public function hide_menu() {
|
||||
global $submenu;
|
||||
if (isset($submenu['tools.php'])) {
|
||||
foreach($submenu['tools.php'] as $key => $menu) {
|
||||
foreach ($submenu['tools.php'] as $key => $menu) {
|
||||
if ($menu[2] == 'google-pagespeed-insights') {
|
||||
unset($submenu['tools.php'][$key]);
|
||||
unset($submenu['tools.php'][ $key ]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -238,24 +240,24 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
$result = $this->get_sync_data( $strategy );
|
||||
|
||||
// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
|
||||
// if ( 'recheck_all_pages' === $_POST['doaction'] ) {
|
||||
// $recheck = true;
|
||||
// } else {
|
||||
// $recheck = false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if ($this->do_check_pages($recheck))
|
||||
// $information['checked_pages'] = 1;
|
||||
// }
|
||||
// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
|
||||
// if ( 'recheck_all_pages' === $_POST['doaction'] ) {
|
||||
// $recheck = true;
|
||||
// } else {
|
||||
// $recheck = false;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if ($this->do_check_pages($recheck))
|
||||
// $information['checked_pages'] = 1;
|
||||
// }
|
||||
$information['data'] = $result['data'];
|
||||
return $information;
|
||||
}
|
||||
|
||||
|
||||
function check_pages() {
|
||||
if (isset($_POST['force_recheck']) && !empty($_POST['force_recheck'])) {
|
||||
if (isset($_POST['force_recheck']) && ! empty($_POST['force_recheck'])) {
|
||||
$recheck = true;
|
||||
} else {
|
||||
$recheck = false;
|
||||
|
@ -267,14 +269,14 @@ class MainWP_Child_Pagespeed {
|
|||
return $information;
|
||||
}
|
||||
|
||||
function do_check_pages($forceRecheck = false) {
|
||||
function do_check_pages( $forceRecheck = false) {
|
||||
$information = array();
|
||||
if ( defined( 'GPI_DIRECTORY' ) ) {
|
||||
$checkstatus = apply_filters( 'gpi_check_status', false );
|
||||
if ( $checkstatus ) {
|
||||
$information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
|
||||
} else {
|
||||
//do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
|
||||
// do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
|
||||
do_action( 'run_gpi', $forceRecheck ); // to fix
|
||||
$information['checked_pages'] = 1;
|
||||
}
|
||||
|
@ -284,9 +286,9 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
|
||||
try{
|
||||
try {
|
||||
$information['syncPageSpeedData'] = $this->get_sync_data();
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +312,7 @@ class MainWP_Child_Pagespeed {
|
|||
|
||||
if ( 'both' === $strategy || 'desktop' === $strategy ) {
|
||||
$result = self::cal_pagespeed_data( 'desktop' );
|
||||
if ( !empty($result) && is_array($result) ) {
|
||||
if ( ! empty($result) && is_array($result) ) {
|
||||
$data['desktop_score'] = $result['average_score'];
|
||||
$data['desktop_total_pages'] = $result['total_pages'];
|
||||
$data['desktop_last_modified'] = $result['last_modified'];
|
||||
|
@ -318,7 +320,7 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
if ( 'both' === $strategy || 'mobile' === $strategy ) {
|
||||
$result = self::cal_pagespeed_data( 'mobile' );
|
||||
if ( !empty($result) && is_array($result) ) {
|
||||
if ( ! empty($result) && is_array($result) ) {
|
||||
$data['mobile_score'] = $result['average_score'];
|
||||
$data['mobile_total_pages'] = $result['total_pages'];
|
||||
$data['mobile_last_modified'] = $result['last_modified'];
|
||||
|
@ -341,8 +343,7 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
|
||||
$score_column = $strategy . '_score';
|
||||
//$page_stats_column = $strategy . '_page_stats';
|
||||
|
||||
// $page_stats_column = $strategy . '_page_stats';
|
||||
|
||||
$data_typestocheck = self::get_filter_options( 'all' );
|
||||
|
||||
|
@ -437,61 +438,59 @@ class MainWP_Child_Pagespeed {
|
|||
);
|
||||
}
|
||||
|
||||
static function get_filter_options($restrict_type = 'all') {
|
||||
static function get_filter_options( $restrict_type = 'all') {
|
||||
|
||||
$types = array();
|
||||
$gpi_options = get_option('gpagespeedi_options');
|
||||
$typestocheck = array();
|
||||
|
||||
if($gpi_options['check_pages']) {
|
||||
if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') {
|
||||
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') {
|
||||
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') {
|
||||
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']) {
|
||||
if($restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts')) {
|
||||
if ($gpi_options['cpt_whitelist']) {
|
||||
if ($restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts')) {
|
||||
|
||||
$cpt_whitelist_arr = false;
|
||||
if(!empty($gpi_options['cpt_whitelist'])) {
|
||||
if ( ! empty($gpi_options['cpt_whitelist'])) {
|
||||
$cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']);
|
||||
}
|
||||
$args=array(
|
||||
$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') {
|
||||
$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)
|
||||
{
|
||||
if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
|
||||
if($post_type == $restrict_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';
|
||||
$types[1][] = $custom_post_types[$post_type];
|
||||
$types[1][] = $custom_post_types[ $post_type ];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($custom_post_types as $post_type)
|
||||
{
|
||||
if($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) {
|
||||
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];
|
||||
$types[1][] = $custom_post_types[ $post_type ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,15 +516,13 @@ class MainWP_Child_Pagespeed {
|
|||
}
|
||||
}
|
||||
|
||||
if(!empty($typestocheck)) {
|
||||
if ( ! empty($typestocheck)) {
|
||||
$types[0] = '';
|
||||
foreach($typestocheck as $type)
|
||||
{
|
||||
if(!is_array($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() {
|
||||
|
@ -45,7 +45,7 @@ class MainWP_Child_Plugins_Check {
|
|||
|
||||
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
|
||||
|
||||
//add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
|
||||
// add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
|
||||
|
||||
add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
|
||||
|
||||
|
@ -97,7 +97,7 @@ class MainWP_Child_Plugins_Check {
|
|||
$last_run = new \DateTime( '@' . $last_run );
|
||||
}
|
||||
|
||||
//Get now
|
||||
// Get now
|
||||
$now = new \DateTime();
|
||||
|
||||
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
|
||||
|
@ -112,14 +112,13 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
public function schedule_watchdog() {
|
||||
//For testing
|
||||
//$this->cleanup_deactivation();
|
||||
// For testing
|
||||
// $this->cleanup_deactivation();
|
||||
|
||||
//Schedule a global watching cron just in case both other crons get killed
|
||||
// Schedule a global watching cron just in case both other crons get killed
|
||||
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
|
||||
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_plugins_outdate_info() {
|
||||
|
@ -143,44 +142,38 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
return $plugins_outdate;
|
||||
|
||||
}
|
||||
|
||||
// for testing
|
||||
public function change_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
|
||||
//Grab our previously stored array of known last modified dates
|
||||
//Requires WP 2.8.0
|
||||
// Grab our previously stored array of known last modified dates
|
||||
// Requires WP 2.8.0
|
||||
$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 ) )
|
||||
{
|
||||
// Sanity check the response
|
||||
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 ) )
|
||||
{
|
||||
//Get now
|
||||
// See if this specific plugin is in the known list
|
||||
if ( array_key_exists( $plugin_file, $plugin_info ) ) {
|
||||
// Get now
|
||||
$now = new \DateTime();
|
||||
$last_updated = $plugin_info[ $plugin_file ]['last_updated'];
|
||||
|
||||
//Last updated is stored as timestamp, get a real date
|
||||
// Last updated is stored as timestamp, get a real date
|
||||
$plugin_last_updated_date = new \DateTime( '@' . $last_updated );
|
||||
|
||||
//Compute days between now and plugin last updated
|
||||
// Compute days between now and plugin last updated
|
||||
$diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' );
|
||||
|
||||
//Customizable number of days for tolerance
|
||||
// Customizable number of days for tolerance
|
||||
$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 we're outside the window for tolerance show a message
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
@ -193,17 +186,17 @@ class MainWP_Child_Plugins_Check {
|
|||
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
//Get our previous results
|
||||
// Get our previous results
|
||||
$responses = get_transient( $this->tran_name_plugin_timestamps );
|
||||
|
||||
if ( false === $responses || ! is_array( $responses ) ) {
|
||||
$responses = array();
|
||||
}
|
||||
|
||||
//Get our previous cache of plugins for batching
|
||||
// Get our previous cache of plugins for batching
|
||||
$all_plugins = get_transient( $this->tran_name_plugins_to_batch );
|
||||
|
||||
//If there wasn't a previous cache
|
||||
// If there wasn't a previous cache
|
||||
if ( false === $all_plugins || ! is_array( $all_plugins ) ) {
|
||||
$plugins = get_plugins();
|
||||
if ( is_array( $plugins ) ) {
|
||||
|
@ -222,29 +215,29 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
$avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' );
|
||||
//Grab a small number of plugins to scan
|
||||
// Grab a small number of plugins to scan
|
||||
$plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
|
||||
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
|
||||
|
||||
//Loop through each known plugin
|
||||
// Loop through each known plugin
|
||||
foreach ( $plugins_to_scan as $slug => $v ) {
|
||||
if ( in_array( $slug, $avoid_plugins ) ) {
|
||||
continue;
|
||||
}
|
||||
//Try to get the raw information for this plugin
|
||||
// Try to get the raw information for this plugin
|
||||
$body = $this->try_get_response_body( $slug, false );
|
||||
|
||||
//We couldn't get any information, skip this plugin
|
||||
// We couldn't get any information, skip this plugin
|
||||
if ( false === $body ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Deserialize the response
|
||||
// Deserialize the response
|
||||
$obj = maybe_unserialize( $body );
|
||||
|
||||
$now = new \DateTime();
|
||||
|
||||
//Sanity check that deserialization worked and that our property exists
|
||||
// Sanity check that deserialization worked and that our property exists
|
||||
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
|
||||
if ( version_compare( $v['Version'], $obj->version, '>' ) ) {
|
||||
continue;
|
||||
|
@ -266,7 +259,7 @@ class MainWP_Child_Plugins_Check {
|
|||
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
||||
}
|
||||
|
||||
//Store the master response for usage in the plugin table
|
||||
// Store the master response for usage in the plugin table
|
||||
set_transient( $this->tran_name_plugin_timestamps, $responses, DAY_IN_SECONDS );
|
||||
|
||||
if ( 0 === count( $all_plugins ) ) {
|
||||
|
@ -278,26 +271,26 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
|
||||
private function try_get_response_body( $plugin, $second_pass ) {
|
||||
//Some of this code is lifted from class-wp-upgrader
|
||||
// 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' );
|
||||
// Get the WordPress current version to be polite in the API call
|
||||
include ABSPATH . WPINC . '/version.php';
|
||||
|
||||
global $wp_version;
|
||||
|
||||
//General options to be passed to wp_remote_get
|
||||
// General options to be passed to wp_remote_get
|
||||
$options = array(
|
||||
'timeout' => 60 * 60, //HOUR_IN_SECONDS
|
||||
'timeout' => 60 * 60, // HOUR_IN_SECONDS
|
||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
||||
);
|
||||
|
||||
//The URL for the endpoint
|
||||
// The URL for the endpoint
|
||||
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
|
||||
|
||||
//If we support SSL
|
||||
//Requires WP 3.2.0
|
||||
// If we support SSL
|
||||
// Requires WP 3.2.0
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||
//Requires WP 3.4.0
|
||||
// Requires WP 3.4.0
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
|
@ -306,27 +299,27 @@ class MainWP_Child_Plugins_Check {
|
|||
$plugin_dir = dirname( $plugin );
|
||||
}
|
||||
|
||||
//Try to get the response (usually the SSL version)
|
||||
//Requires WP 2.7.0
|
||||
// Try to get the response (usually the SSL version)
|
||||
// Requires WP 2.7.0
|
||||
$raw_response = wp_remote_get( $url . $plugin_dir, $options );
|
||||
|
||||
//If we don't have an error and we received a valid response code
|
||||
//Requires WP 2.7.0
|
||||
// If we don't have an error and we received a valid response code
|
||||
// Requires WP 2.7.0
|
||||
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
|
||||
//Get the actual body
|
||||
//Requires WP 2.7.0
|
||||
// Get the actual body
|
||||
// Requires WP 2.7.0
|
||||
$body = wp_remote_retrieve_body( $raw_response );
|
||||
|
||||
//Make sure that it isn't empty and also not an empty serialized object
|
||||
// Make sure that it isn't empty and also not an empty serialized object
|
||||
if ( '' !== $body && 'N;' !== $body ) {
|
||||
//If valid, return that
|
||||
// If valid, return that
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
||||
//The above valid
|
||||
//If we previously tried an SSL version try without SSL
|
||||
//Code below same as above block
|
||||
// The above valid
|
||||
// If we previously tried an SSL version try without SSL
|
||||
// Code below same as above block
|
||||
if ( $ssl ) {
|
||||
$raw_response = wp_remote_get( $http_url . $plugin, $options );
|
||||
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
|
||||
|
@ -337,22 +330,22 @@ class MainWP_Child_Plugins_Check {
|
|||
}
|
||||
}
|
||||
|
||||
//The above failed
|
||||
//If we're on a second pass already then there's nothing left to do but bail
|
||||
// The above failed
|
||||
// If we're on a second pass already then there's nothing left to do but bail
|
||||
if ( true === $second_pass ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//We're still on the first pass, try to get just the name of the directory of the plugin
|
||||
// We're still on the first pass, try to get just the name of the directory of the plugin
|
||||
$parts = explode( '/', $plugin );
|
||||
|
||||
//Sanity check that we have two parts, a directory and a file name
|
||||
// Sanity check that we have two parts, a directory and a file name
|
||||
if ( 2 === count( $parts ) ) {
|
||||
//Try this entire function using just the directory name
|
||||
// Try this entire function using just the directory name
|
||||
return $this->try_get_response_body( $parts[0], true );
|
||||
}
|
||||
|
||||
//Everything above failed, bail
|
||||
// Everything above failed, bail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
@ -817,7 +827,7 @@ class MainWP_Child_Server_Information {
|
|||
if ( $isBranding ) {
|
||||
if ( $slug == 'mainwp-child/mainwp-child.php' ) {
|
||||
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
|
||||
} else if ($slug == 'mainwp-child-reports/mainwp-child-reports.php') {
|
||||
} elseif ($slug == 'mainwp-child-reports/mainwp-child-reports.php') {
|
||||
$plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports';
|
||||
}
|
||||
}
|
||||
|
@ -869,7 +879,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
|
||||
public static function mainwpRequiredFunctions() {
|
||||
//error_reporting(E_ALL);
|
||||
// error_reporting(E_ALL);
|
||||
$disabled_functions = ini_get( 'disable_functions' );
|
||||
if ( '' !== $disabled_functions ) {
|
||||
$arr = explode( ',', $disabled_functions );
|
||||
|
@ -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';
|
||||
|
||||
|
@ -1043,19 +1054,18 @@ class MainWP_Child_Server_Information {
|
|||
<td><?php echo( $currentVersion === true ? 'true' : $currentVersion ); ?></td>
|
||||
<?php if ( $whatType == 'filesize' ) { ?>
|
||||
<td><?php echo( self::filesize_compare( $currentVersion, $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } else if ( $whatType == 'curlssl' ) { ?>
|
||||
<?php } elseif ( $whatType == 'curlssl' ) { ?>
|
||||
<td><?php echo( self::curlssl_compare( $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } else if (($pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime') && $currentVersion == -1) { ?>
|
||||
<?php } elseif (( $pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime' ) && $currentVersion == -1) { ?>
|
||||
<td><?php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>'; ?></td>
|
||||
<?php } else { ?>
|
||||
<td><?php echo (version_compare($currentVersion, $pVersion, $pCompare) || (($pExtraCompare != null) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare)) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType )); ?></td>
|
||||
<td><?php echo ( version_compare($currentVersion, $pVersion, $pCompare) || ( ( $pExtraCompare != null ) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare) ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?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() {
|
||||
|
@ -1316,31 +1329,33 @@ class MainWP_Child_Server_Information {
|
|||
|
||||
protected static function serverSelfConnect() {
|
||||
$url = site_url( 'wp-cron.php' );
|
||||
$query_args = array('mainwp_child_run' => 'test');
|
||||
$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 = '';
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"','mainwp-child' ), $response->get_error_message() );
|
||||
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() );
|
||||
}
|
||||
$response_code = wp_remote_retrieve_response_code( $response );
|
||||
if ( $response_code < 200 && $response_code > 204 ) {
|
||||
$test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)','mainwp-child' ), wp_remote_retrieve_response_code( $response ) );
|
||||
$test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), wp_remote_retrieve_response_code( $response ) );
|
||||
} else {
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
if ( FALSE === strstr( $response_body, 'MainWP Test' ) ) {
|
||||
$test_result .= sprintf( __( 'Not expected HTTP response body: %s','mainwp-child' ), esc_attr( strip_tags( $response_body ) ) );
|
||||
if ( false === strstr( $response_body, 'MainWP Test' ) ) {
|
||||
$test_result .= sprintf( __( 'Not expected HTTP response body: %s', 'mainwp-child' ), esc_attr( strip_tags( $response_body ) ) );
|
||||
}
|
||||
}
|
||||
if ( empty( $test_result ) ) {
|
||||
_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 ) {
|
||||
|
@ -1589,7 +1602,7 @@ class MainWP_Child_Server_Information {
|
|||
}
|
||||
}
|
||||
|
||||
if ( !$configFound ) {
|
||||
if ( ! $configFound ) {
|
||||
_e( 'wp-config.php not found', 'mainwp' );
|
||||
}
|
||||
}
|
||||
|
@ -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 ) )
|
||||
'value' => ! empty($uniqueId) ? $uniqueId : __('Leave the field blank', 'mainwp-child'),
|
||||
'desc' => sprintf(__('Child unique security id is not required, however, since you have enabled it, you need to add it to your %s dashboard.', 'mainwp-child'), stripslashes( $branding_title ) ),
|
||||
),
|
||||
'verify_ssl' => array(
|
||||
'title' => __('Verify certificate', 'mainwp-child'),
|
||||
'value' => __('Yes', 'mainwp-child'),
|
||||
'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child')
|
||||
'desc' => __('If there is an issue with SSL certificate on this site, try to set this option to No.', 'mainwp-child'),
|
||||
),
|
||||
'ssl_version' => array(
|
||||
'title' => __('SSL version', 'mainwp-child'),
|
||||
|
@ -1659,7 +1673,7 @@ class MainWP_Child_Server_Information {
|
|||
<div class="inside">
|
||||
<div class="mainwp-postbox-actions-top mainwp-padding-5">
|
||||
<?php
|
||||
echo sprintf(__('If you are trying to connect this child site to your %s Dashboard, you can use following details to do that. Please note that these are only suggested values.', 'mainwp-child') , stripslashes( $branding_title ));
|
||||
echo sprintf(__('If you are trying to connect this child site to your %s Dashboard, you can use following details to do that. Please note that these are only suggested values.', 'mainwp-child'), stripslashes( $branding_title ));
|
||||
?>
|
||||
</div>
|
||||
<table id="mainwp-table" class="wp-list-table widefat" cellspacing="0" style="border: 0">
|
||||
|
|
|
@ -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() {
|
||||
|
@ -19,13 +19,13 @@ class MainWP_Child_Skeleton_Key {
|
|||
error_reporting( 0 );
|
||||
function mainwp_skeleton_key_handle_fatal_error() {
|
||||
$error = error_get_last();
|
||||
if ( isset( $error['type'] ) && in_array($error['type'], array(1, 4, 16, 64, 256) ) && isset( $error['message'] ) ) {
|
||||
if ( isset( $error['type'] ) && in_array($error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) {
|
||||
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
|
||||
}
|
||||
// to fix issue double <mainwp></mainwp> header in response
|
||||
// else {
|
||||
// MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
|
||||
// }
|
||||
// else {
|
||||
// MainWP_Helper::write( MainWP_Child_Skeleton_Key::$information );
|
||||
// }
|
||||
}
|
||||
|
||||
register_shutdown_function( 'mainwp_skeleton_key_handle_fatal_error' );
|
||||
|
@ -42,7 +42,7 @@ class MainWP_Child_Skeleton_Key {
|
|||
}
|
||||
|
||||
MainWP_Helper::write( $information );
|
||||
//MainWP_Child_Skeleton_Key::$information = $information;
|
||||
// MainWP_Child_Skeleton_Key::$information = $information;
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -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,30 +195,33 @@ class MainWP_Child_Skeleton_Key {
|
|||
public function save_settings() {
|
||||
$settings = isset($_POST['settings']) ? $_POST['settings'] : array();
|
||||
|
||||
if (!is_array($settings) || empty($settings))
|
||||
return array('error' => 'Invalid data. Please check and try again.');
|
||||
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 ( ! is_multisite() ) {
|
||||
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';
|
||||
$whitelist_options['general'][] = 'default_role';
|
||||
}
|
||||
|
||||
//$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
|
||||
$whitelist_general = $whitelist_options[ 'general' ];
|
||||
// $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
|
||||
$whitelist_general = $whitelist_options['general'];
|
||||
|
||||
// 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 ) {
|
||||
|
@ -223,20 +231,22 @@ class MainWP_Child_Skeleton_Key {
|
|||
}
|
||||
|
||||
$updated = false;
|
||||
foreach($settings as $option => $value) {
|
||||
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');
|
||||
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;
|
||||
} else if ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) {
|
||||
} elseif ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
|
||||
if (!$this->is_plugin_installed)
|
||||
if ( ! $this->is_plugin_installed) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
|
||||
}
|
||||
|
||||
|
||||
public function init() {
|
||||
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' )
|
||||
if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->is_plugin_installed)
|
||||
if ( ! $this->is_plugin_installed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_option( 'mainwp_wp_staging_hide_plugin' ) === 'hide' ) {
|
||||
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
|
||||
|
@ -60,9 +63,9 @@ class MainWP_Child_Staging {
|
|||
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) {
|
||||
try{
|
||||
try {
|
||||
$information['syncWPStaging'] = $this->get_sync_data();
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// do not exit
|
||||
}
|
||||
}
|
||||
|
@ -74,12 +77,12 @@ class MainWP_Child_Staging {
|
|||
}
|
||||
|
||||
public function action() {
|
||||
if (!$this->is_plugin_installed) {
|
||||
MainWP_Helper::write( array('error' => 'Please install WP Staging plugin on child website') );
|
||||
if ( ! $this->is_plugin_installed) {
|
||||
MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) );
|
||||
}
|
||||
|
||||
if (!class_exists( 'WPStaging\WPStaging' )){
|
||||
require_once WPSTG_PLUGIN_DIR . "apps/Core/WPStaging.php";
|
||||
if ( ! class_exists( 'WPStaging\WPStaging' )) {
|
||||
require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php';
|
||||
}
|
||||
\WPStaging\WPStaging::getInstance();
|
||||
|
||||
|
@ -164,27 +167,27 @@ class MainWP_Child_Staging {
|
|||
'disableAdminLogin',
|
||||
'querySRLimit',
|
||||
'maxFileSize',
|
||||
//'wpSubDirectory', // removed
|
||||
// 'wpSubDirectory', // removed
|
||||
'debugMode',
|
||||
'unInstallOnDelete',
|
||||
'checkDirectorySize',
|
||||
'optimizer',
|
||||
//'loginSlug' // removed
|
||||
// 'loginSlug' // removed
|
||||
);
|
||||
|
||||
$save_fields = array();
|
||||
foreach($filters as $field) {
|
||||
if (isset($settings[$field])) {
|
||||
$save_fields[$field] = $settings[$field];
|
||||
foreach ($filters as $field) {
|
||||
if (isset($settings[ $field ])) {
|
||||
$save_fields[ $field ] = $settings[ $field ];
|
||||
}
|
||||
}
|
||||
update_option('wpstg_settings', $save_fields );
|
||||
return array('result' => 'success');
|
||||
return array( 'result' => 'success' );
|
||||
}
|
||||
|
||||
public function get_overview() {
|
||||
$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 ) {
|
||||
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 ) ) {
|
||||
} 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() ) {
|
||||
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;
|
||||
}
|
||||
|
@ -332,12 +334,12 @@ class MainWP_Child_Staging {
|
|||
|
||||
$cloning = new WPStaging\Backend\Modules\Jobs\Updating();
|
||||
|
||||
if( !$cloning->save() ) {
|
||||
if ( ! $cloning->save() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
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 ) {
|
||||
if ( false === $freeSpace ) {
|
||||
$data = array(
|
||||
'freespace' => false,
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH))
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
$data = array(
|
||||
'freespace' => $this->formatSize($freeSpace),
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH))
|
||||
'usedspace' => $this->formatSize($this->getDirectorySizeInclSubdirs(ABSPATH)),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
@ -376,20 +378,18 @@ class MainWP_Child_Staging {
|
|||
}
|
||||
|
||||
// from wp-staging plugin
|
||||
public function formatSize($bytes, $precision = 2)
|
||||
{
|
||||
if ((double) $bytes < 1)
|
||||
{
|
||||
public function formatSize( $bytes, $precision = 2) {
|
||||
if ( (float) $bytes < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$units = array('B', "KB", "MB", "GB", "TB");
|
||||
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
|
||||
|
||||
$bytes = (double) $bytes;
|
||||
$bytes = (float) $bytes;
|
||||
$base = log($bytes) / log(1000); // 1024 would be for MiB KiB etc
|
||||
$pow = pow(1000, $base - floor($base)); // Same rule for 1000
|
||||
|
||||
return round($pow, $precision) . ' ' . $units[(int) floor($base)];
|
||||
return round($pow, $precision) . ' ' . $units[ (int) floor($base) ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -423,7 +423,7 @@ class MainWP_Child_Staging {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
if ( ! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
@ -96,7 +95,7 @@ class MainWP_Child_Themes_Check {
|
|||
$last_run = new \DateTime( '@' . $last_run );
|
||||
}
|
||||
|
||||
//Get now
|
||||
// Get now
|
||||
$now = new \DateTime();
|
||||
|
||||
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
|
||||
|
@ -111,14 +110,13 @@ class MainWP_Child_Themes_Check {
|
|||
}
|
||||
|
||||
public function schedule_watchdog() {
|
||||
//For testing
|
||||
//$this->cleanup_deactivation();
|
||||
// For testing
|
||||
// $this->cleanup_deactivation();
|
||||
|
||||
//Schedule a global watching cron just in case both other crons get killed
|
||||
// Schedule a global watching cron just in case both other crons get killed
|
||||
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
|
||||
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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,10 +144,10 @@ 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
|
||||
// Get our previous results
|
||||
$responses = get_transient( $this->tran_name_theme_timestamps );
|
||||
|
||||
if ( false === $responses || ! is_array( $responses ) ) {
|
||||
|
@ -157,7 +155,7 @@ class MainWP_Child_Themes_Check {
|
|||
}
|
||||
|
||||
$all_themes = get_transient( $this->tran_name_themes_to_batch );
|
||||
//If there wasn't a previous cache
|
||||
// If there wasn't a previous cache
|
||||
if ( false === $all_themes || ! is_array( $all_themes ) ) {
|
||||
$all_themes = array();
|
||||
$themes = wp_get_themes();
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -187,19 +187,18 @@ class MainWP_Child_Themes_Check {
|
|||
continue;
|
||||
}
|
||||
|
||||
//Deserialize the response
|
||||
// Deserialize the response
|
||||
$obj = maybe_unserialize( $body );
|
||||
|
||||
$now = new \DateTime();
|
||||
|
||||
//Sanity check that deserialization worked and that our property exists
|
||||
// Sanity check that deserialization worked and that our property exists
|
||||
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
|
||||
$last_updated = strtotime( $obj->last_updated );
|
||||
$theme_last_updated_date = new \DateTime( '@' . $last_updated );
|
||||
|
||||
$diff_in_days = $now->diff( $theme_last_updated_date )->format( '%a' );
|
||||
|
||||
|
||||
if ( $diff_in_days < $tolerance_in_days ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -214,7 +213,7 @@ class MainWP_Child_Themes_Check {
|
|||
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
|
||||
}
|
||||
|
||||
//Store the master response for usage in the plugin table
|
||||
// Store the master response for usage in the plugin table
|
||||
set_transient( $this->tran_name_theme_timestamps, $responses, DAY_IN_SECONDS );
|
||||
|
||||
if ( 0 === count( $all_themes ) ) {
|
||||
|
@ -228,15 +227,21 @@ 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' );
|
||||
// Get the WordPress current version to be polite in the API call
|
||||
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(
|
||||
|
@ -249,20 +254,20 @@ class MainWP_Child_Themes_Check {
|
|||
$raw_response = wp_remote_post( $url, $http_args );
|
||||
|
||||
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
|
||||
//Get the actual body
|
||||
//Requires WP 2.7.0
|
||||
// Get the actual body
|
||||
// Requires WP 2.7.0
|
||||
$body = wp_remote_retrieve_body( $raw_response );
|
||||
|
||||
//Make sure that it isn't empty and also not an empty serialized object
|
||||
// Make sure that it isn't empty and also not an empty serialized object
|
||||
if ( '' !== $body && 'N;' !== $body ) {
|
||||
//If valid, return that
|
||||
// If valid, return that
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
||||
//The above valid
|
||||
//If we previously tried an SSL version try without SSL
|
||||
//Code below same as above block
|
||||
// The above valid
|
||||
// If we previously tried an SSL version try without SSL
|
||||
// Code below same as above block
|
||||
if ( $ssl ) {
|
||||
$raw_response = wp_remote_post( $http_url, $http_args );
|
||||
|
||||
|
@ -274,7 +279,7 @@ class MainWP_Child_Themes_Check {
|
|||
}
|
||||
}
|
||||
|
||||
//Everything above failed, bail
|
||||
// Everything above failed, bail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
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() {
|
||||
|
@ -49,31 +49,34 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
function vulner_recheck(){
|
||||
function vulner_recheck() {
|
||||
$result = array();
|
||||
$force = (isset($_POST['force']) && !empty($_POST['force'])) ? true : false;
|
||||
$force = ( isset($_POST['force']) && ! empty($_POST['force']) ) ? true : false;
|
||||
$result['plugin'] = $this->check_plugins($force);
|
||||
$result['wp'] = $this->check_wp($force);
|
||||
$result['theme'] = $this->check_themes($force);
|
||||
$information = array( 'result' => $result, 'ok' => 1);
|
||||
$information = array(
|
||||
'result' => $result,
|
||||
'ok' => 1,
|
||||
);
|
||||
return $information;
|
||||
}
|
||||
|
||||
function check_plugins($force = false){
|
||||
function check_plugins( $force = false) {
|
||||
$result = array();
|
||||
$active_plugins = get_option('active_plugins');
|
||||
|
||||
if( !empty($active_plugins) ){
|
||||
foreach($active_plugins as $plug){
|
||||
if ( ! empty($active_plugins) ) {
|
||||
foreach ($active_plugins as $plug) {
|
||||
|
||||
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
|
||||
$plugin_info = get_plugin_data($plugin_file);
|
||||
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
|
||||
$string = explode('/',$plug);
|
||||
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_'.$string[0]);
|
||||
if(false === $plug_vuln || $force) {
|
||||
$string = explode('/', $plug);
|
||||
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]);
|
||||
if (false === $plug_vuln || $force) {
|
||||
$plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]);
|
||||
set_transient('mainwp_vulnche_trans_plug_'.$string[0],$plug_vuln, 1 * DAY_IN_SECONDS);
|
||||
set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
if ($plug_vuln) {
|
||||
$plug_vuln = json_decode($plug_vuln, true);
|
||||
|
@ -82,23 +85,23 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
foreach ($plug_vuln as $slug => $pl_data) {
|
||||
if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) {
|
||||
$plug_vulner_data = array();
|
||||
foreach($pl_data['vulnerabilities'] as $vuln_data) {
|
||||
foreach ($pl_data['vulnerabilities'] as $vuln_data) {
|
||||
if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
continue;
|
||||
}
|
||||
$plug_vulner_data[] = $vuln_data;
|
||||
}
|
||||
|
||||
if(count($plug_vulner_data) == 0) {
|
||||
unset($plug_vuln_filter[$slug]);
|
||||
if (count($plug_vulner_data) == 0) {
|
||||
unset($plug_vuln_filter[ $slug ]);
|
||||
} else {
|
||||
$plug_vuln_filter[$slug]['vulnerabilities'] = $plug_vulner_data;
|
||||
$plug_vuln_filter[$slug]['detected_version'] = $plugin_version;
|
||||
$plug_vuln_filter[$slug]['plugin_slug'] = $plug;
|
||||
$plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data;
|
||||
$plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version;
|
||||
$plug_vuln_filter[ $slug ]['plugin_slug'] = $plug;
|
||||
}
|
||||
|
||||
} else {
|
||||
unset($plug_vuln_filter[$slug]);
|
||||
unset($plug_vuln_filter[ $slug ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -111,26 +114,26 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
$result[$plug] = $plug_vuln;
|
||||
$result[ $plug ] = $plug_vuln;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function check_wp($force = false){
|
||||
function check_wp( $force = false) {
|
||||
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
|
||||
$wp_version = str_replace('.', '', get_bloginfo('version'));
|
||||
if(false === $wp_vuln || $force) {
|
||||
if (false === $wp_vuln || $force) {
|
||||
$wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version);
|
||||
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
return $wp_vuln;
|
||||
}
|
||||
|
||||
function check_themes($force = false){
|
||||
function check_themes( $force = false) {
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/includes/misc.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/theme.php' );
|
||||
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();
|
||||
|
@ -139,9 +142,9 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
wp_reset_vars( array( 'theme', 'search' ) );
|
||||
$result = array();
|
||||
if(!empty($themes)){
|
||||
foreach($themes as $th){
|
||||
if(empty($th['parent'])) {
|
||||
if ( ! empty($themes)) {
|
||||
foreach ($themes as $th) {
|
||||
if (empty($th['parent'])) {
|
||||
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
|
||||
if (false === $th_vuln || $force) {
|
||||
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id']);
|
||||
|
@ -155,9 +158,10 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
|
||||
|
||||
$th_vulner_data = array();
|
||||
foreach($th_data['vulnerabilities'] as $vuln_data) {
|
||||
if (empty($vuln_data))
|
||||
foreach ($th_data['vulnerabilities'] as $vuln_data) {
|
||||
if (empty($vuln_data)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset($vuln_data['fixed_in']) && version_compare( $th['version'], $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
continue;
|
||||
|
@ -166,13 +170,13 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
$th_vulner_data[] = $vuln_data;
|
||||
}
|
||||
|
||||
if(count($th_vulner_data) == 0) {
|
||||
unset($th_vuln_filter[$slug]);
|
||||
if (count($th_vulner_data) == 0) {
|
||||
unset($th_vuln_filter[ $slug ]);
|
||||
} else {
|
||||
$th_vuln_filter[$slug]['vulnerabilities'] = $th_vulner_data;
|
||||
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
|
||||
}
|
||||
} else {
|
||||
unset($th_vuln_filter[$slug]);
|
||||
unset($th_vuln_filter[ $slug ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,10 +189,10 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
continue;
|
||||
}
|
||||
|
||||
$result[$th['id']]['vulner_data'] = $th_vuln;
|
||||
$result[$th['id']]['name'] = $th['name'];
|
||||
$result[$th['id']]['author'] = $th['author'];
|
||||
$result[$th['id']]['detected_version'] = $th['version'];
|
||||
$result[ $th['id'] ]['vulner_data'] = $th_vuln;
|
||||
$result[ $th['id'] ]['name'] = $th['name'];
|
||||
$result[ $th['id'] ]['author'] = $th['author'];
|
||||
$result[ $th['id'] ]['detected_version'] = $th['version'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,9 +206,9 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token token=' . $this->wpvulndb_token));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Token token=' . $this->wpvulndb_token ));
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $this->get_random_user_agent());
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$output = curl_exec($ch);
|
||||
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
@ -217,25 +221,25 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
|
||||
|
||||
function get_random_user_agent ( ) {
|
||||
function get_random_user_agent () {
|
||||
|
||||
$someUA = array (
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1",
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.0",
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/0.4.154.18 Safari/525.19",
|
||||
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13",
|
||||
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322)",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
|
||||
"Mozilla/45.0 (compatible; MSIE 6.0; Windows NT 5.1)",
|
||||
"Mozilla/4.08 (compatible; MSIE 6.0; Windows NT 5.1)",
|
||||
"Mozilla/4.01 (compatible; MSIE 6.0; Windows NT 5.1)"
|
||||
$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)',
|
||||
);
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
srand( (float) microtime() * 1000000);
|
||||
|
||||
return $someUA[rand(0,count($someUA)-1)];
|
||||
return $someUA[ rand(0, count($someUA) - 1) ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,25 +18,23 @@ 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() {
|
||||
$information = array();
|
||||
if ( ! class_exists( 'WooCommerce' ) || !defined('WC_VERSION')) {
|
||||
if ( ! class_exists( 'WooCommerce' ) || ! defined('WC_VERSION')) {
|
||||
$information['error'] = 'NO_WOOCOMMERCE';
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -86,14 +84,12 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND postmeta.meta_key = '_order_total'
|
||||
AND posts.post_date >= %s
|
||||
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
|
||||
|
@ -110,7 +106,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND order_item_meta.meta_key = '_qty'
|
||||
AND order_item_meta_2.meta_key = '_product_id'
|
||||
AND posts.post_date >= %s
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -209,15 +205,12 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND postmeta.meta_key = '_order_total'
|
||||
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||
" );
|
||||
|
||||
|
||||
|
||||
|
||||
// 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
|
||||
|
@ -234,7 +227,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
'completed',
|
||||
'processing',
|
||||
'on-hold',
|
||||
) ) ) . "' )
|
||||
) ) ) . "' )
|
||||
AND order_item_meta.meta_key = '_qty'
|
||||
AND order_item_meta_2.meta_key = '_product_id'
|
||||
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
|
||||
|
@ -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' );
|
||||
|
@ -473,7 +465,7 @@ class MainWP_Child_WooCommerce_Status {
|
|||
$background_updater->save()->dispatch();
|
||||
}
|
||||
|
||||
return array('result' => 'success');
|
||||
return array( 'result' => 'success' );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
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() {
|
||||
|
@ -34,9 +34,9 @@ class MainWP_Child_WP_Rocket {
|
|||
}
|
||||
|
||||
public function init() {
|
||||
// if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) {
|
||||
// return;
|
||||
// }
|
||||
// if ( get_option( 'mainwp_wprocket_ext_enabled' ) !== 'Y' ) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
|
@ -99,18 +99,18 @@ class MainWP_Child_WP_Rocket {
|
|||
'deferred_js_files' => array(),
|
||||
'lazyload' => 0,
|
||||
'lazyload_iframes' => 0,
|
||||
'lazyload_youtube' =>0,
|
||||
'lazyload_youtube' => 0,
|
||||
'minify_css' => 0,
|
||||
// 'minify_css_key' => $minify_css_key,
|
||||
// 'minify_css_key' => $minify_css_key,
|
||||
'minify_concatenate_css' => 0,
|
||||
//'minify_css_combine_all' => 0,
|
||||
// 'minify_css_combine_all' => 0,
|
||||
'minify_css_legacy' => 0,
|
||||
'minify_js' => 0,
|
||||
// 'minify_js_key' => $minify_js_key,
|
||||
// 'minify_js_key' => $minify_js_key,
|
||||
'minify_js_in_footer' => array(),
|
||||
'minify_concatenate_js' => 0,
|
||||
'minify_js_combine_all' => 0,
|
||||
//'minify_js_legacy' => 0,
|
||||
// 'minify_js_legacy' => 0,
|
||||
'minify_google_fonts' => 0,
|
||||
'minify_html' => 0,
|
||||
'remove_query_strings' => 0,
|
||||
|
@ -118,13 +118,13 @@ class MainWP_Child_WP_Rocket {
|
|||
'cdn' => 0,
|
||||
'cdn_cnames' => array(),
|
||||
'cdn_zone' => array(),
|
||||
//'cdn_ssl' => 0,
|
||||
// 'cdn_ssl' => 0,
|
||||
'cdn_reject_files' => array(),
|
||||
'do_cloudflare' => 0,
|
||||
'cloudflare_email' => '',
|
||||
'cloudflare_api_key' => '',
|
||||
'cloudflare_domain' => '',
|
||||
//'cloudflare_zone_id' => '',
|
||||
// 'cloudflare_zone_id' => '',
|
||||
'cloudflare_devmode' => 0,
|
||||
'cloudflare_protocol_rewrite' => 0,
|
||||
'cloudflare_auto_settings' => 0,
|
||||
|
@ -137,10 +137,10 @@ class MainWP_Child_WP_Rocket {
|
|||
// ok
|
||||
public function syncOthersData( $information, $data = array() ) {
|
||||
if ( isset( $data['syncWPRocketData'] ) && ( 'yes' === $data['syncWPRocketData'] ) ) {
|
||||
try{
|
||||
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ));
|
||||
try {
|
||||
$data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) );
|
||||
$information['syncWPRocketData'] = $data;
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
}
|
||||
return $information;
|
||||
|
@ -192,7 +192,7 @@ class MainWP_Child_WP_Rocket {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
if ( ! MainWP_Helper::is_screen_with_update()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -207,9 +207,9 @@ class MainWP_Child_WP_Rocket {
|
|||
if ( ! $this->is_plugin_installed ) {
|
||||
return false;
|
||||
}
|
||||
// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) {
|
||||
// return false;
|
||||
// }
|
||||
// if ( ! defined( 'WP_ROCKET_VERSION' ) || ! defined( 'WP_ROCKET_SLUG' ) ) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -251,9 +251,8 @@ class MainWP_Child_WP_Rocket {
|
|||
|
||||
$information = array();
|
||||
|
||||
|
||||
if ( isset( $_POST['mwp_action'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' );
|
||||
// MainWP_Helper::update_option( 'mainwp_wprocket_ext_enabled', 'Y' );
|
||||
try {
|
||||
switch ( $_POST['mwp_action'] ) {
|
||||
case 'set_showhide':
|
||||
|
@ -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':
|
||||
|
@ -287,7 +286,7 @@ class MainWP_Child_WP_Rocket {
|
|||
$information = $this->do_admin_post_rocket_purge_opcache();
|
||||
break;
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$information = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
@ -306,9 +305,9 @@ class MainWP_Child_WP_Rocket {
|
|||
if ( function_exists( 'opcache_reset' ) ) {
|
||||
@opcache_reset();
|
||||
} else {
|
||||
return array('error' => 'The host do not support the function reset opcache.');
|
||||
return array( 'error' => 'The host do not support the function reset opcache.' );
|
||||
}
|
||||
return array('result' => 'SUCCESS');
|
||||
return array( 'result' => 'SUCCESS' );
|
||||
}
|
||||
|
||||
function purge_cloudflare() {
|
||||
|
@ -336,12 +335,12 @@ class MainWP_Child_WP_Rocket {
|
|||
rocket_clean_cache_busting();
|
||||
}
|
||||
|
||||
if ( !function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH')) {
|
||||
if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH')) {
|
||||
require_once WP_ROCKET_ADMIN_PATH . 'admin.php';
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
@ -362,7 +361,7 @@ class MainWP_Child_WP_Rocket {
|
|||
MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process');
|
||||
|
||||
$preload_process = new WP_Rocket\Preload\Full_Process();
|
||||
MainWP_Helper::check_methods($preload_process, array( 'is_process_running'));
|
||||
MainWP_Helper::check_methods($preload_process, array( 'is_process_running' ));
|
||||
|
||||
if ( $preload_process->is_process_running() ) {
|
||||
return array( 'result' => 'RUNNING' );
|
||||
|
@ -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,10 +411,9 @@ class MainWP_Child_WP_Rocket {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
update_option( WP_ROCKET_SLUG, $options );
|
||||
|
||||
if (isset($_POST['do_database_optimization']) && !empty($_POST['do_database_optimization'])) {
|
||||
if (isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization'])) {
|
||||
$this->optimize_database();
|
||||
}
|
||||
|
||||
|
@ -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,9 +436,9 @@ 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 ) ) {
|
||||
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,72 +1,62 @@
|
|||
<?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() )
|
||||
{
|
||||
try{
|
||||
function syncOthersData( $information, $data = array() ) {
|
||||
try {
|
||||
|
||||
if ( isset( $data['syncWPvividData'] ))
|
||||
{
|
||||
$information['syncWPvividData']=1;
|
||||
if ( isset( $data['syncWPvividData'] )) {
|
||||
$information['syncWPvividData'] = 1;
|
||||
$data = WPvivid_Setting::get_sync_data();
|
||||
$information['syncWPvividSettingData']=$data['setting'];
|
||||
$information['syncWPvividRemoteData']=$data['remote'];
|
||||
$information['syncWPvividScheduleData']=$data['schedule'];
|
||||
$information['syncWPvividSettingData'] = $data['setting'];
|
||||
$information['syncWPvividRemoteData'] = $data['remote'];
|
||||
$information['syncWPvividScheduleData'] = $data['schedule'];
|
||||
$information['syncWPvividSetting'] = $data;
|
||||
}
|
||||
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
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':
|
||||
|
@ -134,174 +124,154 @@ class MainWP_Child_WPvivid_BackupRestore
|
|||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$information = array('error' => $e->getMessage());
|
||||
$information = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
|
||||
MainWP_Helper::write($information);
|
||||
}
|
||||
}
|
||||
|
||||
public function post_mainwp_data($data){
|
||||
public function post_mainwp_data( $data) {
|
||||
global $wpvivid_plugin;
|
||||
|
||||
$ret =$wpvivid_plugin->wpvivid_handle_mainwp_action($data);
|
||||
$ret = $wpvivid_plugin->wpvivid_handle_mainwp_action($data);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function prepare_backup()
|
||||
{
|
||||
public function prepare_backup() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->prepare_backup($_POST['backup']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function backup_now()
|
||||
{
|
||||
public function backup_now() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->backup_now($_POST['task_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_status()
|
||||
{
|
||||
public function get_status() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_status();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_backup_schedule()
|
||||
{
|
||||
public function get_backup_schedule() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_backup_schedule();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_backup_list()
|
||||
{
|
||||
public function get_backup_list() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_backup_list();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_default_remote()
|
||||
{
|
||||
public function get_default_remote() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_default_remote();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete_backup()
|
||||
{
|
||||
public function delete_backup() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->delete_backup($_POST['backup_id'], $_POST['force']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete_backup_array()
|
||||
{
|
||||
public function delete_backup_array() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->delete_backup_array($_POST['backup_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_security_lock()
|
||||
{
|
||||
public function set_security_lock() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_security_lock($_POST['backup_id'], $_POST['lock']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function view_log()
|
||||
{
|
||||
public function view_log() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->view_log($_POST['id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function read_last_backup_log()
|
||||
{
|
||||
public function read_last_backup_log() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->read_last_backup_log($_POST['log_file_name']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function view_backup_task_log()
|
||||
{
|
||||
public function view_backup_task_log() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->view_backup_task_log($_POST['id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function backup_cancel()
|
||||
{
|
||||
public function backup_cancel() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->backup_cancel($_POST['task_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function init_download_page()
|
||||
{
|
||||
public function init_download_page() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->init_download_page($_POST['backup_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function prepare_download_backup()
|
||||
{
|
||||
public function prepare_download_backup() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->prepare_download_backup($_POST['backup_id'], $_POST['file_name']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function get_download_task()
|
||||
{
|
||||
public function get_download_task() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->get_download_task($_POST['backup_id']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function download_backup()
|
||||
{
|
||||
public function download_backup() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->download_backup($_POST['backup_id'], $_POST['file_name']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_general_setting()
|
||||
{
|
||||
public function set_general_setting() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_general_setting($_POST['setting']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_schedule()
|
||||
{
|
||||
public function set_schedule() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_schedule($_POST['schedule']);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function set_remote()
|
||||
{
|
||||
public function set_remote() {
|
||||
global $wpvivid_plugin;
|
||||
$wpvivid_plugin->ajax_check_security();
|
||||
$ret = $this->public_intetface->set_remote($_POST['remote']);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,15 +5,15 @@ 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() {
|
||||
add_filter( 'wp_mainwp_stream_current_agent', array($this, 'current_agent' ), 10, 1 );
|
||||
add_filter( 'wp_mainwp_stream_current_agent', array( $this, 'current_agent' ), 10, 1 );
|
||||
}
|
||||
|
||||
public function init() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,7 @@ class MainWP_Client_Report {
|
|||
if ( ( $firsttime = get_option( 'mainwp_creport_first_time_activated' ) ) !== false ) {
|
||||
$creport_sync_data['firsttime_activated'] = $firsttime;
|
||||
}
|
||||
if ( !empty( $creport_sync_data ) ) {
|
||||
if ( ! empty( $creport_sync_data ) ) {
|
||||
$information['syncClientReportData'] = $creport_sync_data;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +43,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
public static function do_reports_log( $ext = '' ) {
|
||||
switch( $ext ) {
|
||||
switch ( $ext ) {
|
||||
case 'backupbuddy':
|
||||
MainWP_Child_Back_Up_Buddy::Instance()->do_reports_log( $ext );
|
||||
break;
|
||||
|
@ -65,7 +66,7 @@ class MainWP_Client_Report {
|
|||
|
||||
$information = array();
|
||||
|
||||
if ( !function_exists( 'wp_mainwp_stream_get_instance' ) ) {
|
||||
if ( ! function_exists( 'wp_mainwp_stream_get_instance' ) ) {
|
||||
$information['error'] = __( 'Error: No MainWP Client Reports plugin installed.' );
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
@ -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";
|
||||
} else if ( $context == 'profiles' ) {
|
||||
$connector = "users";
|
||||
} else if ( $context == 'comments' ) { // multi values
|
||||
$connector = "comments";
|
||||
$connector = '';
|
||||
if ( $context == 'plugins' || $context == 'themes' || $context == 'WordPress' ) {
|
||||
$connector = 'installer';
|
||||
} elseif ( $context == 'profiles' ) {
|
||||
$connector = 'users';
|
||||
} elseif ( $context == 'comments' ) { // multi values
|
||||
$connector = 'comments';
|
||||
}
|
||||
// else if ( $context == 'sessions' ) {
|
||||
// $connector = "users";
|
||||
// }
|
||||
else if ( $context == 'settings' ) {
|
||||
$connector = "settings";
|
||||
} else if ( $context == 'post' || $context == 'page') {
|
||||
$connector = "posts";
|
||||
} else if ( $context == 'widgets' ) {
|
||||
$connector = "widgets";
|
||||
} else if ( $context == 'menus' ) {
|
||||
$connector = "menus";
|
||||
} else if ( $context == 'backups' ) {
|
||||
$connector = "mainwp_backups";
|
||||
} else if ( $context == 'sucuri_scan' ) {
|
||||
$connector = "mainwp_sucuri";
|
||||
} else if ( $context == 'mainwp_maintenance' ) {
|
||||
$connector = "mainwp_maintenance";
|
||||
} else if ( $context == 'wordfence_scan' ) {
|
||||
$connector = "mainwp_wordfence";
|
||||
} else if ( $context == 'media' ) {
|
||||
$connector = "media";
|
||||
// else if ( $context == 'sessions' ) {
|
||||
// $connector = "users";
|
||||
// }
|
||||
elseif ( $context == 'settings' ) {
|
||||
$connector = 'settings';
|
||||
} elseif ( $context == 'post' || $context == 'page' ) {
|
||||
$connector = 'posts';
|
||||
} elseif ( $context == 'widgets' ) {
|
||||
$connector = 'widgets';
|
||||
} elseif ( $context == 'menus' ) {
|
||||
$connector = 'menus';
|
||||
} elseif ( $context == 'backups' ) {
|
||||
$connector = 'mainwp_backups';
|
||||
} elseif ( $context == 'sucuri_scan' ) {
|
||||
$connector = 'mainwp_sucuri';
|
||||
} elseif ( $context == 'mainwp_maintenance' ) {
|
||||
$connector = 'mainwp_maintenance';
|
||||
} elseif ( $context == 'wordfence_scan' ) {
|
||||
$connector = 'mainwp_wordfence';
|
||||
} elseif ( $context == 'media' ) {
|
||||
$connector = 'media';
|
||||
}
|
||||
|
||||
return $connector;
|
||||
|
@ -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';
|
||||
} else if ( $context == 'sucuri_scan' ) {
|
||||
if ( $action == 'checks')
|
||||
}
|
||||
} elseif ( $context == 'sucuri_scan' ) {
|
||||
if ( $action == 'checks' ) {
|
||||
$action = 'sucuri_scan';
|
||||
} else if ($context == 'wordfence_scan') {
|
||||
if ( $action == 'scan')
|
||||
}
|
||||
} elseif ( $context == 'wordfence_scan' ) {
|
||||
if ( $action == 'scan' ) {
|
||||
$action = 'wordfence_scan';
|
||||
}
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
|
||||
|
@ -219,13 +225,13 @@ class MainWP_Client_Report {
|
|||
if ( ! is_array( $sections ) ) {
|
||||
$sections = array();
|
||||
}
|
||||
//return $sections;
|
||||
// return $sections;
|
||||
|
||||
$other_tokens = isset( $_POST['other_tokens'] ) ? maybe_unserialize( base64_decode( $_POST['other_tokens'] ) ) : array();
|
||||
if ( ! is_array( $other_tokens ) ) {
|
||||
$other_tokens = array();
|
||||
}
|
||||
//return $other_tokens;
|
||||
// return $other_tokens;
|
||||
|
||||
unset( $_POST['sections'] );
|
||||
unset( $_POST['other_tokens'] );
|
||||
|
@ -247,66 +253,67 @@ class MainWP_Client_Report {
|
|||
// to fix bug
|
||||
$exclude_connector_posts = true;
|
||||
if ( isset( $sections['body'] ) && isset( $sections['body']['section_token'] ) && is_array($sections['body']['section_token']) ) {
|
||||
foreach ($sections['body']['section_token'] as $sec) {
|
||||
if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) {
|
||||
foreach ( $sections['body']['section_token'] as $sec ) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts) {
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ( isset( $sections['header'] ) && isset( $sections['header']['section_token'] ) && is_array($sections['header']['section_token']) ) {
|
||||
foreach ($sections['header']['section_token'] as $sec) {
|
||||
if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) {
|
||||
foreach ( $sections['header']['section_token'] as $sec ) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts) {
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ( isset( $sections['footer'] ) && isset( $sections['footer']['section_token'] ) && is_array($sections['footer']['section_token']) ) {
|
||||
foreach ($sections['footer']['section_token'] as $sec) {
|
||||
if (strpos($sec, "[section.posts") !== false || strpos($sec, "[section.pages") !== false) {
|
||||
foreach ( $sections['footer']['section_token'] as $sec ) {
|
||||
if ( strpos($sec, '[section.posts') !== false || strpos($sec, '[section.pages') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts) {
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ( isset( $other_tokens['body'] ) && is_array( $other_tokens['body'] ) ) {
|
||||
foreach ( $other_tokens['body'] as $sec ) {
|
||||
if ( strpos( $sec, "[post." ) !== false || strpos($sec, "[page.") !== false) {
|
||||
if ( strpos( $sec, '[post.' ) !== false || strpos($sec, '[page.') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts) {
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ( isset( $other_tokens['header'] ) && is_array($other_tokens['header']) ) {
|
||||
foreach ($other_tokens['header'] as $sec) {
|
||||
if (strpos($sec, "[post.") !== false || strpos($sec, "[page.") !== false) {
|
||||
foreach ( $other_tokens['header'] as $sec ) {
|
||||
if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts) {
|
||||
if ( $exclude_connector_posts ) {
|
||||
if ( isset( $other_tokens['footer'] ) && is_array($other_tokens['footer']) ) {
|
||||
foreach ($other_tokens['footer'] as $sec) {
|
||||
if (strpos($sec, "[post.") !== false || strpos($sec, "[page.") !== false) {
|
||||
foreach ( $other_tokens['footer'] as $sec ) {
|
||||
if ( strpos($sec, '[post.') !== false || strpos($sec, '[page.') !== false ) {
|
||||
$exclude_connector_posts = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($exclude_connector_posts)
|
||||
$args['connector__not_in'] = array('posts');
|
||||
///// end fix /////
|
||||
if ( $exclude_connector_posts ) {
|
||||
$args['connector__not_in'] = array( 'posts' );
|
||||
}
|
||||
// end fix /////
|
||||
|
||||
$args['action__not_in'] = array( 'login' );
|
||||
|
||||
|
@ -326,7 +333,7 @@ class MainWP_Client_Report {
|
|||
|
||||
$args['records_per_page'] = 9999;
|
||||
|
||||
// $records = mainwp_wp_stream_query( $args );
|
||||
// $records = mainwp_wp_stream_query( $args );
|
||||
$records = wp_mainwp_stream_get_instance()->db->query( $args );
|
||||
|
||||
if ( ! is_array( $records ) ) {
|
||||
|
@ -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 );
|
||||
|
@ -453,7 +461,7 @@ class MainWP_Client_Report {
|
|||
$context = $action = $data = '';
|
||||
if ( 2 === count( $array_tmp ) ) {
|
||||
list( $context, $data ) = $array_tmp;
|
||||
} else if ( 3 === count( $array_tmp ) ) {
|
||||
} elseif ( 3 === count( $array_tmp ) ) {
|
||||
list( $context, $action, $data ) = $array_tmp;
|
||||
}
|
||||
|
||||
|
@ -471,19 +479,18 @@ 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;
|
||||
} else if ( $connector !== $record->connector ) {
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -499,23 +506,22 @@ class MainWP_Client_Report {
|
|||
}
|
||||
} else if ( $context == "menus") {
|
||||
// ok, pass, don't check context
|
||||
} else if ( $record->connector == 'editor' ) {
|
||||
} elseif ( $record->connector == 'editor' ) {
|
||||
// ok, pass, checked above
|
||||
} else if ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
} elseif ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
// ok, pass, do not check context
|
||||
} else if ( $connector == "widgets" && $record->connector == 'widgets') {
|
||||
} elseif ( $connector == 'widgets' && $record->connector == 'widgets' ) {
|
||||
// ok, pass, don't check context
|
||||
} else if ( $context !== strtolower( $record->context )) {
|
||||
} elseif ( $context !== strtolower( $record->context ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// custom action value
|
||||
if ( $connector == "widgets" ) {
|
||||
if ( $action == "deleted" ) {
|
||||
$action = "removed"; // action saved in database
|
||||
if ( $connector == 'widgets' ) {
|
||||
if ( $action == 'deleted' ) {
|
||||
$action = 'removed'; // action saved in database
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
// check action
|
||||
if ( 'backups' === $context ) {
|
||||
|
@ -541,18 +547,20 @@ class MainWP_Client_Report {
|
|||
if ( 'draft' === $new_status ) { // avoid auto save post
|
||||
continue;
|
||||
}
|
||||
} else if ( 'updated' === $action && ('themes' === $context || 'plugins' === $context)) {
|
||||
} elseif ( 'updated' === $action && ( 'themes' === $context || 'plugins' === $context ) ) {
|
||||
$name = $this->get_stream_meta_data( $record, 'name' );
|
||||
if ( empty($name) ) { // to fix empty value
|
||||
if (!in_array($record->ID, $skip_records))
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
$skip_records[] = $record->ID;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
$old_version = $this->get_stream_meta_data( $record, 'old_version' );
|
||||
$version = $this->get_stream_meta_data( $record, 'version' );
|
||||
if (version_compare($version, $old_version, '<=')) { // to fix
|
||||
if (!in_array($record->ID, $skip_records))
|
||||
if ( version_compare($version, $old_version, '<=') ) { // to fix
|
||||
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 = '';
|
||||
|
@ -592,7 +599,7 @@ class MainWP_Client_Report {
|
|||
if ( is_array( $array_tmp ) ) {
|
||||
if ( 2 === count( $array_tmp ) ) {
|
||||
list( $str1, $context ) = $array_tmp;
|
||||
} else if ( 3 === count( $array_tmp ) ) {
|
||||
} elseif ( 3 === count( $array_tmp ) ) {
|
||||
list( $str1, $context, $action ) = $array_tmp;
|
||||
}
|
||||
}
|
||||
|
@ -623,45 +630,45 @@ 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;
|
||||
} else if ( $connector !== $record->connector ) {
|
||||
}
|
||||
} elseif ( $connector !== $record->connector ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check context
|
||||
if ( $context == "comments" ) { // multi values
|
||||
$comment_contexts = array('post', 'page');
|
||||
if ( $context == 'comments' ) { // multi values
|
||||
$comment_contexts = array( 'post', 'page' );
|
||||
if ( ! in_array( $record->context, $comment_contexts ) ) {
|
||||
continue;
|
||||
}
|
||||
} else if ( $context == "menus") {
|
||||
} elseif ( $context == 'menus' ) {
|
||||
// ok, pass, don't check context
|
||||
} else if ( $record->connector == 'editor' ) {
|
||||
} elseif ( $record->connector == 'editor' ) {
|
||||
// ok, pass, checked above
|
||||
} else if ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
} elseif ( $connector == 'media' && $record->connector == 'media' ) {
|
||||
// ok, pass, do not check context
|
||||
} else if ( $connector == "widgets" && $record->connector == 'widgets') {
|
||||
} elseif ( $connector == 'widgets' && $record->connector == 'widgets' ) {
|
||||
// ok, pass, don't check context
|
||||
//
|
||||
} else if ( $context !== strtolower( $record->context ) ) {
|
||||
} elseif ( $context !== strtolower( $record->context ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// custom action value
|
||||
if ( $connector == "widgets" ) {
|
||||
if ( $action == "deleted" ) {
|
||||
$action = "removed"; // action saved in database
|
||||
if ( $connector == 'widgets' ) {
|
||||
if ( $action == 'deleted' ) {
|
||||
$action = 'removed'; // action saved in database
|
||||
}
|
||||
}
|
||||
////
|
||||
|
||||
// check action
|
||||
if ( $context == 'backups' ) {
|
||||
if ( ! $this->is_backup_action($record->action) ) {
|
||||
continue;
|
||||
}
|
||||
} else if ( $action !== $record->action ) {
|
||||
} elseif ( $action !== $record->action ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -672,7 +679,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
}
|
||||
|
||||
//$skip_this_loop = false;
|
||||
// $skip_this_loop = false;
|
||||
$token_values = array();
|
||||
|
||||
foreach ( $tokens as $token ) {
|
||||
|
@ -686,16 +693,16 @@ class MainWP_Client_Report {
|
|||
} else {
|
||||
if ( 1 === count( $array_tmp ) ) {
|
||||
list( $data ) = $array_tmp;
|
||||
} else if ( 2 === count( $array_tmp ) ) {
|
||||
} elseif ( 2 === count( $array_tmp ) ) {
|
||||
list( $str1, $data ) = $array_tmp;
|
||||
} else if ( 3 === count( $array_tmp ) ) {
|
||||
} elseif ( 3 === count( $array_tmp ) ) {
|
||||
list( $str1, $str2, $data ) = $array_tmp;
|
||||
}
|
||||
|
||||
if ( 'version' === $data ) {
|
||||
if ( 'old' === $str2 ) {
|
||||
$data = 'old_version';
|
||||
} else if ( 'current' === $str2 && 'wordpress' === $str1 ) {
|
||||
} elseif ( 'current' === $str2 && 'WordPress' === $str1 ) {
|
||||
$data = 'new_version';
|
||||
}
|
||||
}
|
||||
|
@ -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':
|
||||
|
@ -737,14 +745,14 @@ class MainWP_Client_Report {
|
|||
} else {
|
||||
if ( 'page' === $context || 'post' === $context ) {
|
||||
$data = 'post_title';
|
||||
} else if ( 'menus' === $record->connector ) {
|
||||
} elseif ( 'menus' === $record->connector ) {
|
||||
$data = 'name';
|
||||
}
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
}
|
||||
break;
|
||||
case 'author':
|
||||
if ( $connector == "comment" ) {
|
||||
if ( $connector == 'comment' ) {
|
||||
$data = 'user_name';
|
||||
} else {
|
||||
$data = 'user_meta';
|
||||
|
@ -757,7 +765,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
|
||||
// to check may compatible with old meta data
|
||||
if ( empty( $value )) {
|
||||
if ( empty( $value ) ) {
|
||||
$value = $this->get_stream_meta_data( $record, 'author_meta' );
|
||||
}
|
||||
|
||||
|
@ -767,7 +775,7 @@ class MainWP_Client_Report {
|
|||
case 'webtrust':
|
||||
if ( 'sucuri_scan' === $context ) {
|
||||
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
|
||||
if (!empty($scan_data)) {
|
||||
if ( ! empty($scan_data) ) {
|
||||
$scan_data = maybe_unserialize( base64_decode( $scan_data ) );
|
||||
if ( is_array( $scan_data ) ) {
|
||||
|
||||
|
@ -780,13 +788,12 @@ class MainWP_Client_Report {
|
|||
if ( $malware_exists ) {
|
||||
$status[] = __( 'Site With Warnings', 'mainwp-child' ); }
|
||||
|
||||
if ($data == 'status') {
|
||||
if ( $data == 'status' ) {
|
||||
$tok_value = count( $status ) > 0 ? implode( ', ', $status ) : __( 'Verified Clear', 'mainwp-child' );
|
||||
} else if ($data == 'webtrust') {
|
||||
} elseif ( $data == 'webtrust' ) {
|
||||
$tok_value = $blacklisted ? __( 'Site Blacklisted', 'mainwp-child' ) : __( 'Trusted', 'mainwp-child' );
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
}
|
||||
|
@ -796,32 +803,31 @@ class MainWP_Client_Report {
|
|||
break;
|
||||
case 'details':
|
||||
case 'result':
|
||||
|
||||
if ('mainwp_maintenance' === $context && 'details' == $data) {
|
||||
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();
|
||||
|
||||
if ( is_array( $meta_value) ) {
|
||||
foreach($meta_value as $mt) {
|
||||
if ( isset($maintenance_details[$mt]) ) {
|
||||
$details[] = $maintenance_details[$mt];
|
||||
foreach ( $meta_value as $mt ) {
|
||||
if ( isset($maintenance_details[ $mt ]) ) {
|
||||
$details[] = $maintenance_details[ $mt ];
|
||||
}
|
||||
}
|
||||
}
|
||||
$tok_value = implode(", ", $details);
|
||||
$tok_value = implode(', ', $details);
|
||||
|
||||
} else if ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
|
||||
} elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
|
||||
$meta_value = $this->get_stream_meta_data( $record, $data );
|
||||
// to fix
|
||||
if ('wordfence_scan' === $context && $data == 'result') {
|
||||
if ( 'wordfence_scan' === $context && $data == 'result' ) {
|
||||
// SUM_FINAL:Scan complete. You have xxx new issues to fix. See below.
|
||||
// SUM_FINAL:Scan complete. Congratulations, no new problems found
|
||||
if (stripos($meta_value, 'Congratulations')) {
|
||||
if ( stripos($meta_value, 'Congratulations') ) {
|
||||
$meta_value = 'No issues detected';
|
||||
} else if (stripos($meta_value, 'You have')) {
|
||||
} elseif ( stripos($meta_value, 'You have') ) {
|
||||
$meta_value = 'Issues Detected';
|
||||
} else {
|
||||
$meta_value = '';
|
||||
|
@ -830,7 +836,7 @@ class MainWP_Client_Report {
|
|||
$tok_value = $meta_value;
|
||||
}
|
||||
break;
|
||||
//case 'destination': // for backup tokens
|
||||
// case 'destination': // for backup tokens
|
||||
case 'type':
|
||||
if ( 'backups' === $context ) {
|
||||
$tok_value = $this->get_stream_meta_data( $record, $data );
|
||||
|
@ -846,20 +852,18 @@ class MainWP_Client_Report {
|
|||
$token_values[ $token ] = $tok_value;
|
||||
|
||||
if ( empty( $tok_value ) ) {
|
||||
//$skip_this_loop = true;
|
||||
if ( defined( 'MAINWP_CHILD_DEBUG' ) && MAINWP_CHILD_DEBUG === TRUE ) {
|
||||
error_log("MainWP Child Report:: skip empty value :: token :: " . $token . " :: record :: " . print_r( $record, true ));
|
||||
// $skip_this_loop = true;
|
||||
if ( defined( 'MAINWP_CHILD_DEBUG' ) && MAINWP_CHILD_DEBUG === true ) {
|
||||
error_log('MainWP Child Report:: skip empty value :: token :: ' . $token . ' :: record :: ' . print_r( $record, true ));
|
||||
}
|
||||
//break;
|
||||
// break;
|
||||
}
|
||||
|
||||
} // foreach $tokens
|
||||
|
||||
if ( ! empty( $token_values ) ) {
|
||||
$loops[ $loop_count ] = $token_values;
|
||||
$loop_count ++;
|
||||
}
|
||||
|
||||
} // foreach $records
|
||||
return $loops;
|
||||
}
|
||||
|
@ -885,16 +889,16 @@ class MainWP_Client_Report {
|
|||
// to compatible with old meta data
|
||||
if ( 'author_meta' === $meta_key ) {
|
||||
$value = maybe_unserialize( $value );
|
||||
if (is_array($value)) {
|
||||
if ( is_array($value) ) {
|
||||
$value = $value['display_name'];
|
||||
// to fix empty author value
|
||||
if ( empty($value) ) {
|
||||
if (isset($value['agent']) && !empty($value['agent'])) {
|
||||
if ( isset($value['agent']) && ! empty($value['agent']) ) {
|
||||
$value = $value['agent'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_string($value)) {
|
||||
if ( ! is_string($value) ) {
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
|
@ -908,7 +912,7 @@ class MainWP_Client_Report {
|
|||
function set_showhide() {
|
||||
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
||||
MainWP_Child_Branding::Instance()->save_branding_options('hide_child_reports', $hide);
|
||||
//MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports
|
||||
// MainWP_Helper::update_option( 'mainwp_creport_branding_stream_hide', $hide, 'yes' ); // to compatible with old child reports
|
||||
$information['result'] = 'SUCCESS';
|
||||
|
||||
return $information;
|
||||
|
@ -933,7 +937,7 @@ class MainWP_Client_Report {
|
|||
}
|
||||
}
|
||||
|
||||
if ($hide_nag) {
|
||||
if ( $hide_nag ) {
|
||||
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
|
||||
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
|
||||
}
|
||||
|
@ -949,7 +953,7 @@ class MainWP_Client_Report {
|
|||
return $value;
|
||||
}
|
||||
|
||||
if (! MainWP_Helper::is_screen_with_update()) {
|
||||
if ( ! MainWP_Helper::is_screen_with_update() ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,16 +12,16 @@ class MainWP_Clone_Install {
|
|||
* @param string $file The zip backup file path
|
||||
*/
|
||||
public function __construct( $file ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||
|
||||
$this->file = $file;
|
||||
if ( '.zip' === substr( $this->file, - 4 ) ) {
|
||||
$this->archiver = null;
|
||||
} else if ( '.tar.gz' === substr( $this->file, - 7 ) ) {
|
||||
} elseif ( '.tar.gz' === substr( $this->file, - 7 ) ) {
|
||||
$this->archiver = new Tar_Archiver( null, 'tar.gz' );
|
||||
} else if ( '.tar.bz2' === substr( $this->file, - 8 ) ) {
|
||||
} elseif ( '.tar.bz2' === substr( $this->file, - 8 ) ) {
|
||||
$this->archiver = new Tar_Archiver( null, 'tar.bz2' );
|
||||
} else if ( '.tar' === substr( $this->file, - 4 ) ) {
|
||||
} elseif ( '.tar' === substr( $this->file, - 4 ) ) {
|
||||
$this->archiver = new Tar_Archiver( null, 'tar' );
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class MainWP_Clone_Install {
|
|||
* @return bool
|
||||
*/
|
||||
public function checkZipConsole() {
|
||||
//todo: implement
|
||||
// todo: implement
|
||||
// return function_exists('system');
|
||||
return false;
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class MainWP_Clone_Install {
|
|||
|
||||
if ( null !== $this->archiver ) {
|
||||
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
//todo: implement
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
// todo: implement
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
if ( $zipRes ) {
|
||||
|
@ -73,7 +73,7 @@ class MainWP_Clone_Install {
|
|||
|
||||
return false;
|
||||
} else {
|
||||
//use pclzip
|
||||
// use pclzip
|
||||
$zip = new PclZip( $this->file );
|
||||
$list = $zip->delete( PCLZIP_OPT_BY_NAME, 'wp-config.php' );
|
||||
$list2 = $zip->delete( PCLZIP_OPT_BY_NAME, 'clone' );
|
||||
|
@ -114,9 +114,9 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
|
||||
return $this->archiver->file_exists( $file );
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
//todo: implement
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
// todo: implement
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
if ( $zipRes ) {
|
||||
|
@ -236,7 +236,7 @@ class MainWP_Clone_Install {
|
|||
$readline = '';
|
||||
while ( ( $line = fgets( $handle, 81920 ) ) !== false ) {
|
||||
if ( time() - $lastRun > 20 ) {
|
||||
@set_time_limit( 0 ); //reset timer..
|
||||
@set_time_limit( 0 ); // reset timer..
|
||||
$lastRun = time();
|
||||
}
|
||||
|
||||
|
@ -331,16 +331,16 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
$token = $data[0];
|
||||
switch ( $token ) {
|
||||
case 's' :
|
||||
case 's':
|
||||
if ( '"' !== $data[ $length - 2 ] ) {
|
||||
return false;
|
||||
}
|
||||
case 'a' :
|
||||
case 'O' :
|
||||
case 'a':
|
||||
case 'O':
|
||||
return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
|
||||
case 'b' :
|
||||
case 'i' :
|
||||
case 'd' :
|
||||
case 'b':
|
||||
case 'i':
|
||||
case 'd':
|
||||
return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data );
|
||||
}
|
||||
|
||||
|
@ -373,8 +373,8 @@ class MainWP_Clone_Install {
|
|||
return $content;
|
||||
} else {
|
||||
if ( $this->checkZipConsole() ) {
|
||||
//todo: implement
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
// todo: implement
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
$zip = new ZipArchive();
|
||||
$zipRes = $zip->open( $this->file );
|
||||
if ( $zipRes ) {
|
||||
|
@ -388,7 +388,7 @@ class MainWP_Clone_Install {
|
|||
|
||||
return false;
|
||||
} else {
|
||||
//use pclzip
|
||||
// use pclzip
|
||||
$zip = new PclZip( $this->file );
|
||||
$content = $zip->extract( PCLZIP_OPT_BY_NAME, 'clone/config.txt',
|
||||
PCLZIP_OPT_EXTRACT_AS_STRING );
|
||||
|
@ -419,13 +419,13 @@ class MainWP_Clone_Install {
|
|||
}
|
||||
|
||||
return $this->archiver->extractTo( ABSPATH );
|
||||
} else if ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) {
|
||||
} elseif ( ( filesize( $this->file ) >= 50000000 ) && $this->checkWPZip() ) {
|
||||
return $this->extractWPZipBackup();
|
||||
} else if ( $this->checkZipConsole() ) {
|
||||
} elseif ( $this->checkZipConsole() ) {
|
||||
return $this->extractZipConsoleBackup();
|
||||
} else if ( $this->checkZipSupport() ) {
|
||||
} elseif ( $this->checkZipSupport() ) {
|
||||
return $this->extractZipBackup();
|
||||
} else if ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) {
|
||||
} elseif ( ( filesize( $this->file ) < 50000000 ) && $this->checkWPZip() ) {
|
||||
return $this->extractWPZipBackup();
|
||||
} else {
|
||||
return $this->extractZipPclBackup();
|
||||
|
@ -484,8 +484,8 @@ class MainWP_Clone_Install {
|
|||
* @return bool
|
||||
*/
|
||||
public function extractZipConsoleBackup() {
|
||||
//todo implement
|
||||
//system('zip');
|
||||
// todo implement
|
||||
// system('zip');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ class MainWP_Clone_Install {
|
|||
// some unseriliased data cannot be re-serialised eg. SimpleXMLElements
|
||||
try {
|
||||
|
||||
if ( is_string( $data ) && is_serialized( $data ) && !is_serialized_string( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
|
||||
if ( is_string( $data ) && is_serialized( $data ) && ! is_serialized_string( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
|
||||
$data = $this->recursive_unserialize_replace( $from, $to, $unserialized, true );
|
||||
} elseif ( is_array( $data ) ) {
|
||||
$_tmp = array();
|
||||
|
@ -675,7 +675,7 @@ class MainWP_Clone_Install {
|
|||
unset( $_tmp );
|
||||
} elseif (is_serialized_string($data) && is_serialized($data)) {
|
||||
// TODO: apply solution like phpmyadmin project have!
|
||||
if ( ($data = @unserialize( $data )) !== false ) {
|
||||
if ( ( $data = @unserialize( $data ) ) !== false ) {
|
||||
$data = str_replace( $from, $to, $data );
|
||||
$data = serialize( $data );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class MainWP_Clone {
|
|||
$ajaxPosts = array();
|
||||
}
|
||||
|
||||
//If already processed, just quit!
|
||||
// If already processed, just quit!
|
||||
if ( isset( $ajaxPosts[ $action ] ) && ( $ajaxPosts[ $action ] == $_POST['dts'] ) ) {
|
||||
die( json_encode( array( 'error' => __( 'Double request!', 'mainwp-child' ) ) ) );
|
||||
}
|
||||
|
@ -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 ) {
|
||||
?>
|
||||
|
@ -307,7 +314,7 @@ class MainWP_Clone {
|
|||
$branding_msg = esc_html__( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' );
|
||||
}
|
||||
?>
|
||||
<em> <?php echo $branding_msg ; ?> <br/>
|
||||
<em> <?php echo $branding_msg; ?> <br/>
|
||||
<?php esc_html_e( 'A database only backup will not work.', 'mainwp-child' ); ?></em><br/><br/>
|
||||
<form action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
|
||||
method="post"
|
||||
|
@ -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,10 +517,9 @@ class MainWP_Clone {
|
|||
<script language="javascript">
|
||||
var child_security_nonces = [];
|
||||
<?php
|
||||
$security_nonces = MainWP_Clone::get()->getSecurityNonces();
|
||||
foreach ($security_nonces as $k => $v)
|
||||
{
|
||||
echo 'child_security_nonces['."'" .$k . "'". '] = ' . "'" . $v . "';\n";
|
||||
$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' ); ?>";
|
||||
|
@ -1199,7 +1205,7 @@ class MainWP_Clone {
|
|||
$key = $siteToClone['extauth'];
|
||||
|
||||
MainWP_Helper::endSession();
|
||||
//Send request to the childsite!
|
||||
// Send request to the childsite!
|
||||
global $wp_version;
|
||||
$method = ( function_exists( 'gzopen' ) ? 'tar.gz' : 'zip' );
|
||||
$result = MainWP_Helper::fetchUrl( $url, array(
|
||||
|
@ -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() );
|
||||
}
|
||||
|
@ -1248,12 +1257,12 @@ class MainWP_Clone {
|
|||
$key = $siteToClone['extauth'];
|
||||
|
||||
MainWP_Helper::endSession();
|
||||
//Send request to the childsite!
|
||||
// Send request to the childsite!
|
||||
$result = MainWP_Helper::fetchUrl( $url, array(
|
||||
'cloneFunc' => 'createCloneBackupPoll',
|
||||
'key' => $key,
|
||||
'f' => $rand,
|
||||
'json_result' => true
|
||||
'json_result' => true,
|
||||
) );
|
||||
|
||||
if ( ! isset( $result['size'] ) ) {
|
||||
|
@ -1264,7 +1273,7 @@ class MainWP_Clone {
|
|||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
//Return size in kb
|
||||
// Return size in kb
|
||||
die( json_encode( $output ) );
|
||||
}
|
||||
|
||||
|
@ -1295,7 +1304,7 @@ class MainWP_Clone {
|
|||
$url = $file;
|
||||
}
|
||||
MainWP_Helper::endSession();
|
||||
//Send request to the childsite!
|
||||
// Send request to the childsite!
|
||||
$split = explode( '=', $file );
|
||||
$file = urldecode( $split[ count( $split ) - 1 ] );
|
||||
$filename = 'download-' . basename( $file );
|
||||
|
@ -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 );
|
||||
|
@ -1329,7 +1342,7 @@ class MainWP_Clone {
|
|||
|
||||
$output = array( 'done' => $filename );
|
||||
|
||||
//Delete backup on child
|
||||
// Delete backup on child
|
||||
try {
|
||||
if ( isset( $_POST['siteId'] ) ) {
|
||||
$siteId = $_POST['siteId'];
|
||||
|
@ -1341,7 +1354,7 @@ class MainWP_Clone {
|
|||
'cloneFunc' => 'deleteCloneBackup',
|
||||
'key' => $siteToClone['extauth'],
|
||||
'f' => $_POST['file'],
|
||||
'json_result' => true
|
||||
'json_result' => true,
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
@ -1379,7 +1392,7 @@ class MainWP_Clone {
|
|||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
//return size in kb
|
||||
// return size in kb
|
||||
die( json_encode( $output ) );
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1420,7 @@ class MainWP_Clone {
|
|||
throw new Exception( __( 'No download file found', 'mainwp-child' ) );
|
||||
}
|
||||
$file = $archiveFile;
|
||||
} else if ( file_exists( $file ) ) {
|
||||
} elseif ( file_exists( $file ) ) {
|
||||
$testFull = true;
|
||||
} else {
|
||||
$file = ABSPATH . $file;
|
||||
|
@ -1416,10 +1429,10 @@ class MainWP_Clone {
|
|||
}
|
||||
$testFull = true;
|
||||
}
|
||||
//return size in kb
|
||||
// return size in kb
|
||||
$cloneInstall = new MainWP_Clone_Install( $file );
|
||||
|
||||
//todo: RS: refactor to get those plugins after install (after .18 release)
|
||||
// todo: RS: refactor to get those plugins after install (after .18 release)
|
||||
$cloneInstall->readConfigurationFile();
|
||||
|
||||
$plugins = get_option( 'mainwp_temp_clone_plugins' );
|
||||
|
@ -1520,14 +1533,14 @@ class MainWP_Clone {
|
|||
delete_option( 'mainwp_temp_clone_themes' );
|
||||
}
|
||||
$output = array( 'result' => 'ok' );
|
||||
//todo: remove old tables if other prefix?
|
||||
// todo: remove old tables if other prefix?
|
||||
|
||||
wp_logout();
|
||||
wp_set_current_user( 0 );
|
||||
} catch ( Exception $e ) {
|
||||
$output = array( 'error' => $e->getMessage() );
|
||||
}
|
||||
//return size in kb
|
||||
// return size in kb
|
||||
die( json_encode( $output ) );
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
} 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() {
|
||||
|
@ -20,10 +20,10 @@ class MainWP_Custom_Post_Type {
|
|||
$error = error_get_last();
|
||||
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
|
||||
$data = array( 'error' => 'MainWPChild fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] );
|
||||
// die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' );
|
||||
// die( '<mainwp>' . base64_encode( serialize( ) ) . '</mainwp>' );
|
||||
} else {
|
||||
$data = MainWP_Custom_Post_Type::$information;
|
||||
// die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' );
|
||||
$data = self::$information;
|
||||
// die( '<mainwp>' . base64_encode( serialize( MainWP_Custom_Post_Type::$information ) ) . '</mainwp>' );
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] ) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class MainWP_Custom_Post_Type {
|
|||
if ( empty( $data ) || ! is_array( $data ) || ! isset( $data['post'] ) ) {
|
||||
return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) );
|
||||
}
|
||||
$edit_id = (isset($_POST['post_id']) && !empty($_POST['post_id'])) ? $_POST['post_id'] : 0;
|
||||
$edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0;
|
||||
$return = $this->_insert_post($data, $edit_id, $parent_id = 0);
|
||||
if (isset($return['success']) && $return['success'] == 1) {
|
||||
if (isset($data['product_variation']) && is_array($data['product_variation'])) {
|
||||
|
@ -104,7 +104,7 @@ class MainWP_Custom_Post_Type {
|
|||
}
|
||||
|
||||
try {
|
||||
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl , array(), $check_image );
|
||||
$downloadfile = MainWP_Helper::uploadImage( $originalImgUrl, array(), $check_image );
|
||||
$localUrl = $downloadfile['url'];
|
||||
$linkToReplaceWith = dirname( $localUrl );
|
||||
if ( '' !== $hrefLink ) {
|
||||
|
@ -114,7 +114,7 @@ class MainWP_Custom_Post_Type {
|
|||
$serverHref = 'href="' . $serverHost;
|
||||
$replaceServerHref = 'href="' . parse_url( $localUrl, PHP_URL_SCHEME ) . '://' . parse_url( $localUrl, PHP_URL_HOST );
|
||||
$post_content = str_replace( $serverHref, $replaceServerHref, $post_content );
|
||||
} else if ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
} elseif ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
$lnkToReplace = dirname( $hrefLink );
|
||||
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
$post_content = str_replace( $lnkToReplace, $linkToReplaceWith, $post_content );
|
||||
|
@ -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 ) {
|
||||
|
@ -174,23 +174,23 @@ class MainWP_Custom_Post_Type {
|
|||
return array( 'error' => __( 'Please install', $this->plugin_translate ) . ' ' . $data_insert['post_type'] . ' ' . __( 'on child and try again', $this->plugin_translate ) );
|
||||
}
|
||||
|
||||
//$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] );
|
||||
// $data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'] );
|
||||
|
||||
$is_woocomerce = false;
|
||||
if ( ($data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' )&& function_exists( 'wc_product_has_unique_sku' ) ) {
|
||||
if ( ( $data_insert['post_type'] == 'product' || $data_insert['post_type'] == 'product_variation' ) && function_exists( 'wc_product_has_unique_sku' ) ) {
|
||||
$is_woocomerce = true;
|
||||
}
|
||||
|
||||
$check_image_existed = false;
|
||||
|
||||
// Support post_edit
|
||||
if ( !empty( $edit_id ) ) {
|
||||
if ( ! empty( $edit_id ) ) {
|
||||
$old_post_id = (int) $edit_id;
|
||||
$old_post = get_post( $old_post_id, ARRAY_A );
|
||||
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 ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ class MainWP_Custom_Post_Type {
|
|||
|
||||
$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed );
|
||||
|
||||
if (!empty($parent_id)) {
|
||||
if ( ! empty($parent_id)) {
|
||||
$data_insert['post_parent'] = $parent_id; // for product variation
|
||||
}
|
||||
$post_id = wp_insert_post( $data_insert, true );
|
||||
|
@ -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 );
|
||||
|
@ -303,7 +303,7 @@ class MainWP_Custom_Post_Type {
|
|||
}
|
||||
}
|
||||
|
||||
//Insert post terms except categories
|
||||
// Insert post terms except categories
|
||||
if ( ! empty( $data['terms'] ) && is_array( $data['terms'] ) ) {
|
||||
foreach ( $data['terms'] as $key ) {
|
||||
if ( ! taxonomy_exists( $key['taxonomy'] ) ) {
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ class MainWP_Debug {
|
|||
/**
|
||||
* @param $mainwpChild MainWP_Child
|
||||
*/
|
||||
public static function process(&$mainwpChild) {
|
||||
public static function process( &$mainwpChild) {
|
||||
if ( ! isset( $_GET['mainwpdebug'] ) || ! defined( 'MAINWP_DEBUG' ) || ( MAINWP_DEBUG !== true ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class MainWP_Debug {
|
|||
$start = microtime( true );
|
||||
|
||||
if ( 'fullbackup' == $_GET['mainwpdebug'] ) {
|
||||
//Full backup
|
||||
// Full backup
|
||||
$_POST['type'] = 'full';
|
||||
$_POST['excludebackup'] = '1';
|
||||
$_POST['excludecache'] = '1';
|
||||
|
@ -21,13 +21,12 @@ class MainWP_Debug {
|
|||
$_POST['excludenonwp'] = '1';
|
||||
$_POST['ext'] = 'tar.gz';
|
||||
print_r( $mainwpChild->backup( false ) );
|
||||
} else if ( 'test' == $_GET['mainwpdebug'] ) {
|
||||
} elseif ( 'test' == $_GET['mainwpdebug'] ) {
|
||||
print_r( get_included_files() );
|
||||
} else {
|
||||
print_r( $mainwpChild->getSiteStats( array(), false ) );
|
||||
}
|
||||
|
||||
|
||||
$stop = microtime( true );
|
||||
die( "\n\n\n" . 'duration: ' . ( $stop - $start ) . 's</pre>' );
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ class MainWP_Helper {
|
|||
static function write( $val ) {
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else:
|
||||
else :
|
||||
$output = serialize( $val );
|
||||
endif;
|
||||
|
||||
|
@ -69,7 +69,7 @@ class MainWP_Helper {
|
|||
return $str;
|
||||
}
|
||||
|
||||
public static function safe_json_encode($value, $options = 0, $depth = 512) {
|
||||
public static function safe_json_encode( $value, $options = 0, $depth = 512) {
|
||||
$encoded = @json_encode($value, $options, $depth);
|
||||
if ($encoded === false && !empty( $value ) && json_last_error() == JSON_ERROR_UTF8 ) {
|
||||
$encoded = @json_encode(self::json_valid_check($value), $options, $depth);
|
||||
|
@ -81,7 +81,7 @@ class MainWP_Helper {
|
|||
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else:
|
||||
else :
|
||||
$output = serialize( $val );
|
||||
endif;
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,105 +114,107 @@ class MainWP_Helper {
|
|||
* CSSPARSER
|
||||
* Copyright (C) 2009 Peter Kröner
|
||||
*/
|
||||
public static function parse_css($css){
|
||||
public static function parse_css( $css) {
|
||||
|
||||
// Remove CSS-Comments
|
||||
$css = preg_replace('/\/\*.*?\*\//ms', '', $css);
|
||||
// Remove HTML-Comments
|
||||
$css = preg_replace('/([^\'"]+?)(\<!--|--\>)([^\'"]+?)/ms', '$1$3', $css);
|
||||
// Extract @media-blocks into $blocks
|
||||
preg_match_all('/@.+?\}[^\}]*?\}/ms',$css, $blocks);
|
||||
preg_match_all('/@.+?\}[^\}]*?\}/ms', $css, $blocks);
|
||||
// Append the rest to $blocks
|
||||
array_push($blocks[0],preg_replace('/@.+?\}[^\}]*?\}/ms','',$css));
|
||||
array_push($blocks[0], preg_replace('/@.+?\}[^\}]*?\}/ms', '', $css));
|
||||
$ordered = array();
|
||||
for($i=0;$i<count($blocks[0]);$i++){
|
||||
for ($i = 0;$i < count($blocks[0]);$i++) {
|
||||
// If @media-block, strip declaration and parenthesis
|
||||
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]);
|
||||
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) === '@')
|
||||
{
|
||||
$ordered_key = $blocks[0][$i];
|
||||
$ordered_value = $blocks[0][$i];
|
||||
}
|
||||
else
|
||||
{
|
||||
elseif (substr($blocks[0][ $i ], 0, 1) === '@') {
|
||||
$ordered_key = $blocks[0][ $i ];
|
||||
$ordered_value = $blocks[0][ $i ];
|
||||
} else {
|
||||
$ordered_key = 'main';
|
||||
$ordered_value = $blocks[0][$i];
|
||||
$ordered_value = $blocks[0][ $i ];
|
||||
}
|
||||
// Split by parenthesis, ignoring those inside content-quotes
|
||||
$ordered[$ordered_key] = preg_split('/([^\'"\{\}]*?[\'"].*?(?<!\\\)[\'"][^\'"\{\}]*?)[\{\}]|([^\'"\{\}]*?)[\{\}]/',trim($ordered_value," \r\n\t"),-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
|
||||
$ordered[ $ordered_key ] = preg_split('/([^\'"\{\}]*?[\'"].*?(?<!\\\)[\'"][^\'"\{\}]*?)[\{\}]|([^\'"\{\}]*?)[\{\}]/', trim($ordered_value, " \r\n\t"), -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
|
||||
}
|
||||
|
||||
// Beginning to rebuild new slim CSS-Array
|
||||
foreach($ordered as $key => $val){
|
||||
foreach ($ordered as $key => $val) {
|
||||
$new = array();
|
||||
for($i = 0; $i<count($val); $i++){
|
||||
for ($i = 0; $i < count($val); $i++) {
|
||||
// Split selectors and rules and split properties and values
|
||||
$selector = trim($val[$i]," \r\n\t");
|
||||
$selector = trim($val[ $i ], " \r\n\t");
|
||||
|
||||
if(!empty($selector)){
|
||||
if(!isset($new[$selector])) $new[$selector] = array();
|
||||
$rules = explode(';',$val[++$i]);
|
||||
foreach($rules as $rule){
|
||||
$rule = trim($rule," \r\n\t");
|
||||
if(!empty($rule)){
|
||||
if ( ! empty($selector)) {
|
||||
if ( ! isset($new[ $selector ])) {
|
||||
$new[ $selector ] = array();
|
||||
}
|
||||
$rules = explode(';', $val[ ++$i ]);
|
||||
foreach ($rules as $rule) {
|
||||
$rule = trim($rule, " \r\n\t");
|
||||
if ( ! empty($rule)) {
|
||||
$rule = array_reverse(explode(':', $rule));
|
||||
$property = trim(array_pop($rule)," \r\n\t");
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$ordered[$key] = $new;
|
||||
}
|
||||
$ordered[ $key ] = $new;
|
||||
}
|
||||
$parsed = $ordered;
|
||||
|
||||
$output = '';
|
||||
foreach($parsed as $media => $content){
|
||||
if(substr($media,0,6) === '@media'){
|
||||
foreach ($parsed as $media => $content) {
|
||||
if (substr($media, 0, 6) === '@media') {
|
||||
$output .= $media . " {\n";
|
||||
$prefix = "\t";
|
||||
} else {
|
||||
$prefix = '';
|
||||
}
|
||||
else $prefix = "";
|
||||
|
||||
foreach($content as $selector => $rules){
|
||||
$output .= $prefix.$selector . " {\n";
|
||||
foreach($rules as $property => $value){
|
||||
$output .= $prefix."\t".$property.': '.$value;
|
||||
foreach ($content as $selector => $rules) {
|
||||
$output .= $prefix . $selector . " {\n";
|
||||
foreach ($rules as $property => $value) {
|
||||
$output .= $prefix . "\t" . $property . ': ' . $value;
|
||||
$output .= ";\n";
|
||||
}
|
||||
$output .= $prefix."}\n\n";
|
||||
$output .= $prefix . "}\n\n";
|
||||
}
|
||||
if(substr($media,0,6) === '@media'){
|
||||
if (substr($media, 0, 6) === '@media') {
|
||||
$output .= "}\n\n";
|
||||
}
|
||||
}
|
||||
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) )
|
||||
static function uploadImage( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) {
|
||||
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
|
||||
// Download $img_url
|
||||
$temporary_file = download_url( $img_url );
|
||||
|
||||
if ( is_wp_error( $temporary_file ) ) {
|
||||
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
||||
} else {
|
||||
$filename = basename( $img_url );
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; //Local name
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; // Local name
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
|
||||
//$gen_unique_fn = true;
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,12 +248,15 @@ class MainWP_Helper {
|
|||
$basedir = $upload_dir['basedir'];
|
||||
$baseurl = $upload_dir['baseurl'];
|
||||
$local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
|
||||
if ( file_exists($local_img_path) && (filesize( $local_img_path ) == filesize( $temporary_file )) ) { // file exited
|
||||
if ( file_exists($local_img_path) && ( filesize( $local_img_path ) == filesize( $temporary_file ) ) ) { // file exited
|
||||
|
||||
if ( file_exists( $temporary_file ) ) {
|
||||
unlink( $temporary_file );
|
||||
}
|
||||
return array( 'id' => $attach->ID, 'url' => $attach->guid );
|
||||
return array(
|
||||
'id' => $attach->ID,
|
||||
'url' => $attach->guid,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,14 +273,14 @@ class MainWP_Helper {
|
|||
$moved = @rename( $temporary_file, $local_img_path );
|
||||
|
||||
if ( $moved ) {
|
||||
$wp_filetype = wp_check_filetype( basename( $img_url ), null ); //Get the filetype to set the mimetype
|
||||
$wp_filetype = wp_check_filetype( basename( $img_url ), null ); // Get the filetype to set the mimetype
|
||||
$attachment = array(
|
||||
'post_mime_type' => $wp_filetype['type'],
|
||||
'post_title' => isset( $img_data['title'] ) && !empty( $img_data['title'] ) ? $img_data['title'] : preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ),
|
||||
'post_content' => isset( $img_data['description'] ) && !empty( $img_data['description'] ) ? $img_data['description'] : '',
|
||||
'post_excerpt' => isset( $img_data['caption'] ) && !empty( $img_data['caption'] ) ? $img_data['caption'] : '',
|
||||
'post_title' => isset( $img_data['title'] ) && ! empty( $img_data['title'] ) ? $img_data['title'] : preg_replace( '/\.[^.]+$/', '', basename( $img_url ) ),
|
||||
'post_content' => isset( $img_data['description'] ) && ! empty( $img_data['description'] ) ? $img_data['description'] : '',
|
||||
'post_excerpt' => isset( $img_data['caption'] ) && ! empty( $img_data['caption'] ) ? $img_data['caption'] : '',
|
||||
'post_status' => 'inherit',
|
||||
'guid' => $local_img_url // to fix
|
||||
'guid' => $local_img_url, // to fix
|
||||
);
|
||||
|
||||
// for post attachments, thumbnail
|
||||
|
@ -279,13 +288,17 @@ class MainWP_Helper {
|
|||
$attachment['post_parent'] = $parent_id;
|
||||
}
|
||||
|
||||
$attach_id = wp_insert_attachment( $attachment, $local_img_path ); //Insert the image in the database
|
||||
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
||||
$attach_id = wp_insert_attachment( $attachment, $local_img_path ); // Insert the image in the database
|
||||
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'] ) )
|
||||
wp_update_attachment_metadata( $attach_id, $attach_data ); // Update generated metadata
|
||||
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 ) ) {
|
||||
|
@ -314,7 +327,7 @@ class MainWP_Helper {
|
|||
$file_name = sanitize_file_name( $file_name );
|
||||
}
|
||||
|
||||
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; //Local name
|
||||
$full_file_name = $path . DIRECTORY_SEPARATOR . $file_name; // Local name
|
||||
|
||||
$response = wp_remote_get( $file_url, array(
|
||||
'timeout' => 10 * 60 * 60,
|
||||
|
@ -398,9 +411,9 @@ class MainWP_Helper {
|
|||
|
||||
// current user may be connected admin or alternative admin
|
||||
$current_uid = $current_user->ID;
|
||||
//Set up a new post (adding addition information)
|
||||
//$usr = get_user_by( 'login', $_POST['user'] );
|
||||
//$new_post['post_author'] = $current_user->ID;
|
||||
// Set up a new post (adding addition information)
|
||||
// $usr = get_user_by( 'login', $_POST['user'] );
|
||||
// $new_post['post_author'] = $current_user->ID;
|
||||
|
||||
$is_robot_post = false; // retirement soon
|
||||
if ( isset( $_POST['isMainWPRobot'] ) && ! empty( $_POST['isMainWPRobot'] ) ) {
|
||||
|
@ -411,7 +424,7 @@ class MainWP_Helper {
|
|||
if ( $is_robot_post ) { // retirement soon
|
||||
if ( 1 === $post_author ) {
|
||||
$new_post['post_author'] = $current_uid;
|
||||
} else if ( ! is_numeric( $post_author ) ) {
|
||||
} elseif ( ! is_numeric( $post_author ) ) {
|
||||
$user_author = get_user_by( 'login', $post_author );
|
||||
if ( $user_author ) {
|
||||
$post_author = $user_author->ID;
|
||||
|
@ -420,7 +433,7 @@ class MainWP_Helper {
|
|||
$post_author = wp_create_user( $post_author, $random_password, $post_author . '@asdf.com' );
|
||||
}
|
||||
}
|
||||
} else if ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) {
|
||||
} elseif ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) {
|
||||
$_author = get_user_by( 'login', $new_post['custom_post_author'] );
|
||||
if ( ! empty( $_author ) ) {
|
||||
$new_post['post_author'] = $_author->ID;
|
||||
|
@ -434,7 +447,7 @@ class MainWP_Helper {
|
|||
$new_post['post_author'] = $post_author;
|
||||
|
||||
$is_ezine_post = ! empty( $post_custom['_ezine_post_article_source'] ) ? true : false;
|
||||
$terms = isset( $new_post['_ezin_post_category'] ) ? $new_post['_ezin_post_category'] : false ;
|
||||
$terms = isset( $new_post['_ezin_post_category'] ) ? $new_post['_ezin_post_category'] : false;
|
||||
unset( $new_post['_ezin_post_category'] );
|
||||
$is_post_plus = isset( $post_custom['_mainwp_post_plus'] ) ? true : false;
|
||||
|
||||
|
@ -444,11 +457,11 @@ class MainWP_Helper {
|
|||
if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && $new_post['post_date_gmt'] != '0000-00-00 00:00:00' ) {
|
||||
$post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60;
|
||||
$new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp );
|
||||
//$new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
|
||||
// $new_post['post_status'] = ( $post_date_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
|
||||
}
|
||||
// else {
|
||||
// $new_post['post_status'] = 'publish';
|
||||
// }
|
||||
// else {
|
||||
// $new_post['post_status'] = 'publish';
|
||||
// }
|
||||
}
|
||||
|
||||
$wpr_options = isset( $_POST['wpr_options'] ) ? $_POST['wpr_options'] : array();
|
||||
|
@ -457,29 +470,29 @@ class MainWP_Helper {
|
|||
|
||||
if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) {
|
||||
$edit_post_id = current($post_custom['_mainwp_edit_post_id']);
|
||||
} else if (isset( $new_post['ID'] ) && $new_post['ID']) {
|
||||
} elseif (isset( $new_post['ID'] ) && $new_post['ID']) {
|
||||
$edit_post_id = $new_post['ID'];
|
||||
}
|
||||
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/post.php';
|
||||
if ($edit_post_id) {
|
||||
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
|
||||
$user = get_userdata( $user_id );
|
||||
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
|
||||
return array( 'error' => $error);
|
||||
return array( 'error' => $error );
|
||||
}
|
||||
}
|
||||
|
||||
$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
|
||||
// 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
|
||||
$foundMatches = preg_match_all( '/(<a[^>]+href=\"(.*?)\"[^>]*>)?(<img[^>\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $new_post['post_content'], $matches, PREG_SET_ORDER );
|
||||
if ( ( $foundMatches > 0 || ( $is_robot_post && isset( $wpr_options['wpr_save_images'] ) && 'Yes' === $wpr_options['wpr_save_images'] ) ) && ( ! $is_ezine_post ) ) {
|
||||
//We found images, now to download them so we can start balbal
|
||||
// We found images, now to download them so we can start balbal
|
||||
foreach ( $matches as $match ) {
|
||||
$hrefLink = $match[2];
|
||||
$imgUrl = $match[4];
|
||||
|
@ -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 ) {
|
||||
|
@ -509,12 +522,12 @@ class MainWP_Helper {
|
|||
$new_post['post_content'] = str_replace( $serverHref, $replaceServerHref, $new_post['post_content'] );
|
||||
}
|
||||
// To fix bug
|
||||
// else if ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
// $lnkToReplace = dirname( $hrefLink );
|
||||
// if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
// $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
|
||||
// }
|
||||
// }
|
||||
// else if ( strpos( $hrefLink, 'http' ) !== false ) {
|
||||
// $lnkToReplace = dirname( $hrefLink );
|
||||
// if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
// $new_post['post_content'] = str_replace( $lnkToReplace, $linkToReplaceWith, $new_post['post_content'] );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
$lnkToReplace = dirname( $imgUrl );
|
||||
if ( 'http:' !== $lnkToReplace && 'https:' !== $lnkToReplace ) {
|
||||
|
@ -532,12 +545,12 @@ class MainWP_Helper {
|
|||
if ( isset( $_POST['post_gallery_images'] ) ) {
|
||||
$post_gallery_images = unserialize(base64_decode( $_POST['post_gallery_images'] ));
|
||||
if (is_array($post_gallery_images)) {
|
||||
foreach($post_gallery_images as $gallery){
|
||||
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'];
|
||||
$replaceAttachedIds[ $gallery['id'] ] = $upload['id'];
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
|
@ -549,16 +562,16 @@ 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].",";
|
||||
foreach ($originalIds as $attached_id) {
|
||||
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) {
|
||||
$idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ',';
|
||||
}
|
||||
}
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith,",");
|
||||
if (!empty($idsToReplaceWith)) {
|
||||
$new_post['post_content'] = str_replace( '"' . $idsToReplace . '"', '"'.$idsToReplaceWith.'"', $new_post['post_content'] );
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith, ',');
|
||||
if ( ! empty($idsToReplaceWith)) {
|
||||
$new_post['post_content'] = str_replace( '"' . $idsToReplace . '"', '"' . $idsToReplaceWith . '"', $new_post['post_content'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -596,8 +609,8 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
$random_timestamp = rand( $random_date_from, $random_date_to );
|
||||
// $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
|
||||
// $new_post['post_status'] = $post_status;
|
||||
// $post_status = ( $random_timestamp <= current_time( 'timestamp' ) ) ? 'publish' : 'future';
|
||||
// $new_post['post_status'] = $post_status;
|
||||
$new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp );
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +619,7 @@ class MainWP_Helper {
|
|||
$new_post['tags_input'] = $post_tags;
|
||||
}
|
||||
|
||||
//Save the post to the wp
|
||||
// Save the post to the wp
|
||||
remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); // to fix brake scripts or html
|
||||
$post_status = $new_post['post_status'];
|
||||
$new_post['post_status'] = 'auto-draft'; // child reports: to logging as created post
|
||||
|
@ -615,7 +628,7 @@ class MainWP_Helper {
|
|||
if ( $edit_post_id ) {
|
||||
// check if post existed
|
||||
$current_post = get_post($edit_post_id);
|
||||
if ( $current_post && ( ( !isset( $new_post['post_type'] ) && $current_post->post_type == 'post' ) || ( isset( $new_post['post_type'] ) && $new_post['post_type'] == $current_post->post_type ) ) ) {
|
||||
if ( $current_post && ( ( ! isset( $new_post['post_type'] ) && $current_post->post_type == 'post' ) || ( isset( $new_post['post_type'] ) && $new_post['post_type'] == $current_post->post_type ) ) ) {
|
||||
$new_post['ID'] = $edit_post_id;
|
||||
}
|
||||
$new_post['post_status'] = $post_status; // child reports: to logging as update post
|
||||
|
@ -623,16 +636,20 @@ class MainWP_Helper {
|
|||
|
||||
$new_post_id = wp_insert_post( $new_post, $wp_error );
|
||||
|
||||
//Show errors if something went wrong
|
||||
// Show errors if something went wrong
|
||||
if ( is_wp_error( $wp_error ) ) {
|
||||
return $wp_error->get_error_message();
|
||||
}
|
||||
if ( empty( $new_post_id ) ) {
|
||||
return array( 'error' => 'Empty post id');
|
||||
return array( 'error' => 'Empty post id' );
|
||||
}
|
||||
|
||||
if ( !$edit_post_id )
|
||||
wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
|
||||
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' );
|
||||
|
@ -645,7 +662,7 @@ class MainWP_Helper {
|
|||
$seo_ext_activated = true;
|
||||
}
|
||||
|
||||
//Set custom fields
|
||||
// Set custom fields
|
||||
$not_allowed = array(
|
||||
'_slug',
|
||||
'_tags',
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -701,13 +719,13 @@ class MainWP_Helper {
|
|||
update_post_meta( $new_post_id, $meta_key, $meta_value );
|
||||
}
|
||||
}
|
||||
} else if ( '_sticky' === $meta_key ) {
|
||||
} elseif ( '_sticky' === $meta_key ) {
|
||||
foreach ( $meta_values as $meta_value ) {
|
||||
if ( 'sticky' === base64_decode( $meta_value ) ) {
|
||||
stick_post( $new_post_id );
|
||||
}
|
||||
}
|
||||
} else if ( '_post_to_only_existing_categories' === $meta_key ) {
|
||||
} elseif ( '_post_to_only_existing_categories' === $meta_key ) {
|
||||
if ( isset( $meta_values[0] ) && $meta_values[0] ) {
|
||||
$post_to_only_existing_categories = true;
|
||||
}
|
||||
|
@ -728,9 +746,9 @@ 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!
|
||||
update_post_meta( $new_post_id, WPSEO_Meta::$meta_prefix . 'opengraph-image', $upload['url'] ); // Add the image to the post!
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
|
@ -739,8 +757,8 @@ 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
|
||||
// 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
|
||||
if ( isset( $post_category ) && '' !== $post_category ) {
|
||||
$categories = explode( ',', $post_category );
|
||||
if ( count( $categories ) > 0 ) {
|
||||
|
@ -761,20 +779,21 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
$featured_image_exist = false;
|
||||
//If featured image exists - set it
|
||||
// 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!
|
||||
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'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -784,7 +803,7 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
|
||||
if ( !$featured_image_exist ) {
|
||||
if ( ! $featured_image_exist ) {
|
||||
delete_post_meta( $new_post_id, '_thumbnail_id' );
|
||||
}
|
||||
|
||||
|
@ -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 ) {
|
||||
|
@ -831,8 +856,11 @@ 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 ) );
|
||||
if ( ! empty( $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 ) {
|
||||
|
||||
}
|
||||
|
@ -967,14 +995,14 @@ class MainWP_Helper {
|
|||
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
ob_start();
|
||||
// if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) {
|
||||
// include_once( ABSPATH . '/wp-admin/includes/deprecated.php' );
|
||||
// }
|
||||
// if ( file_exists( ABSPATH . '/wp-admin/includes/deprecated.php' ) ) {
|
||||
// include_once( ABSPATH . '/wp-admin/includes/deprecated.php' );
|
||||
// }
|
||||
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
||||
include_once( ABSPATH . '/wp-admin/includes/screen.php' );
|
||||
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();
|
||||
|
@ -1012,7 +1040,7 @@ class MainWP_Helper {
|
|||
if ( ! $showHttp ) {
|
||||
$url = substr( $url, 7 );
|
||||
}
|
||||
} else if ( self::startsWith( $pUrl, 'https://' ) ) {
|
||||
} elseif ( self::startsWith( $pUrl, 'https://' ) ) {
|
||||
if ( ! $showHttp ) {
|
||||
$url = substr( $url, 8 );
|
||||
}
|
||||
|
@ -1067,11 +1095,12 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
public static function _fetchUrl( $url, $postdata ) {
|
||||
//$agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
// $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
|
||||
|
||||
|
@ -1089,14 +1118,14 @@ class MainWP_Helper {
|
|||
|
||||
if ( ( false === $data ) && ( 0 === $http_status ) ) {
|
||||
throw new Exception( 'Http Error: ' . $err );
|
||||
} else if ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) {
|
||||
} elseif ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $data, $results ) > 0 ) {
|
||||
$result = $results[1];
|
||||
$result_base = base64_decode( $result );
|
||||
//$information = maybe_unserialize( $result_base );
|
||||
// $information = maybe_unserialize( $result_base );
|
||||
$information = json_decode( $result_base, true ); // it is json_encode result
|
||||
|
||||
return $information;
|
||||
} else if ( '' === $data ) {
|
||||
} elseif ( '' === $data ) {
|
||||
throw new Exception( __( 'Something went wrong while contacting the child site. Please check if there is an error on the child site. This error could also be caused by trying to clone or restore a site to large for your server settings.', 'mainwp-child' ) );
|
||||
} else {
|
||||
throw new Exception( __( 'Child plugin is disabled or the security key is incorrect. Please resync with your main installation.', 'mainwp-child' ) );
|
||||
|
@ -1280,10 +1309,11 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
static function update_lasttime_backup( $by, $time ) {
|
||||
$backup_by = array('backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule');
|
||||
$backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' );
|
||||
|
||||
if (!in_array($by, $backup_by))
|
||||
if ( ! in_array($by, $backup_by)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lasttime = get_option('mainwp_lasttime_backup_' . $by);
|
||||
if ( $time > $lasttime ) {
|
||||
|
@ -1294,31 +1324,32 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
static function get_lasttime_backup( $by ) {
|
||||
if ($by == 'backupwp') // to compatible
|
||||
if ($by == 'backupwp') { // to compatible
|
||||
$by = 'backupwordpress';
|
||||
switch($by) {
|
||||
}
|
||||
switch ($by) {
|
||||
case 'backupbuddy':
|
||||
if ( !is_plugin_active( 'backupbuddy/backupbuddy.php' ) && !is_plugin_active( 'Backupbuddy/backupbuddy.php' )) {
|
||||
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' )) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'backupwordpress':
|
||||
if ( !is_plugin_active( 'backupwordpress/backupwordpress.php' )) {
|
||||
if ( ! is_plugin_active( 'backupwordpress/backupwordpress.php' )) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'backwpup':
|
||||
if ( !is_plugin_active( 'backwpup/backwpup.php' ) && !is_plugin_active( 'backwpup-pro/backwpup.php' ) ) {
|
||||
if ( ! is_plugin_active( 'backwpup/backwpup.php' ) && ! is_plugin_active( 'backwpup-pro/backwpup.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'updraftplus':
|
||||
if ( !is_plugin_active( 'updraftplus/updraftplus.php' )) {
|
||||
if ( ! is_plugin_active( 'updraftplus/updraftplus.php' )) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'wptimecapsule':
|
||||
if ( !is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' )) {
|
||||
if ( ! is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' )) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -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;
|
||||
}
|
||||
} else if ( $value == $exclude ) {
|
||||
} elseif ( $value == $exclude ) {
|
||||
return true;
|
||||
} else if ( MainWP_Helper::startsWith( $value, $exclude . '/' ) ) {
|
||||
} elseif ( self::startsWith( $value, $exclude . '/' ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1466,7 +1497,7 @@ class MainWP_Helper {
|
|||
* Credit to the : wp-filters-extras
|
||||
*/
|
||||
|
||||
static function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) {
|
||||
static function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) {
|
||||
|
||||
global $wp_filter;
|
||||
// Take only filters on right hook name and priority
|
||||
|
@ -1489,19 +1520,21 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -1591,41 +1626,43 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
public static function check_files_exists( $files = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($files)) {
|
||||
foreach($files as $name) {
|
||||
if (!file_exists( $name )) {
|
||||
foreach ($files as $name) {
|
||||
if ( ! file_exists( $name )) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!file_exists( $files )) {
|
||||
if ( ! file_exists( $files )) {
|
||||
$missing[] = $files;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($missing)) {
|
||||
if ( ! empty($missing)) {
|
||||
$message = 'Missing file(s): ' . implode(',', $missing);
|
||||
if ($return)
|
||||
if ($return) {
|
||||
return $message;
|
||||
else
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function check_classes_exists($classes = array(), $return = false) {
|
||||
public static function check_classes_exists( $classes = array(), $return = false) {
|
||||
$missing = array();
|
||||
if (is_array($classes)) {
|
||||
foreach($classes as $name) {
|
||||
if (!class_exists( $name )) {
|
||||
foreach ($classes as $name) {
|
||||
if ( ! class_exists( $name )) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( !class_exists($classes) )
|
||||
if ( ! class_exists($classes) ) {
|
||||
$missing[] = $classes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty($missing) ) {
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing classes: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
return $message;
|
||||
|
@ -1636,22 +1673,23 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_methods($object, $methods = array(), $return = false) {
|
||||
public static function check_methods( $object, $methods = array(), $return = false) {
|
||||
$missing = array();
|
||||
if (is_array($methods)) {
|
||||
$missing = array();
|
||||
foreach($methods as $name) {
|
||||
if ( !method_exists($object, $name) ) {
|
||||
foreach ($methods as $name) {
|
||||
if ( ! method_exists($object, $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else if (!empty($methods)) {
|
||||
if ( !method_exists($object, $methods) )
|
||||
} elseif ( ! empty($methods)) {
|
||||
if ( ! method_exists($object, $methods) ) {
|
||||
$missing[] = $methods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !empty($missing) ) {
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing method: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
return $message;
|
||||
|
@ -1663,21 +1701,22 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_properties($object, $properties = array(), $return = false) {
|
||||
public static function check_properties( $object, $properties = array(), $return = false) {
|
||||
$missing = array();
|
||||
if (is_array($properties)) {
|
||||
foreach($properties as $name) {
|
||||
if ( !property_exists($object, $name) ) {
|
||||
foreach ($properties as $name) {
|
||||
if ( ! property_exists($object, $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else if (!empty($properties)) {
|
||||
if ( !property_exists($object, $properties) )
|
||||
} elseif ( ! empty($properties)) {
|
||||
if ( ! property_exists($object, $properties) ) {
|
||||
$missing[] = $properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !empty($missing) ) {
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing properties: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
return $message;
|
||||
|
@ -1689,21 +1728,22 @@ static function remove_filters_with_method_name( $hook_name = '', $method_name =
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_functions($funcs = array(), $return = false) {
|
||||
public static function check_functions( $funcs = array(), $return = false) {
|
||||
$missing = array();
|
||||
if (is_array($funcs)) {
|
||||
foreach($funcs as $name) {
|
||||
if ( !function_exists( $name) ) {
|
||||
foreach ($funcs as $name) {
|
||||
if ( ! function_exists( $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else if (!empty($funcs)) {
|
||||
if ( !function_exists($funcs) )
|
||||
} elseif ( ! empty($funcs)) {
|
||||
if ( ! function_exists($funcs) ) {
|
||||
$missing[] = $funcs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !empty($missing) ) {
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing functions: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
return $message;
|
||||
|
@ -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() {
|
||||
|
@ -31,14 +31,14 @@ class MainWP_Keyword_Links {
|
|||
if ( empty( $this->keyword_links ) ) {
|
||||
$this->keyword_links = array();
|
||||
}
|
||||
//print_r($this->keyword_links);
|
||||
// print_r($this->keyword_links);
|
||||
$this->siteurl = get_option( 'home' );
|
||||
add_action( 'permalink_structure_changed', array( &$this, 'permalinkChanged' ), 10, 2 );
|
||||
}
|
||||
|
||||
|
||||
public function keywordLinksJS() {
|
||||
if ( ! is_admin() && get_option( 'mainwp_kwl_enable_statistic' ) && !empty($this->keyword_links) ) {
|
||||
if ( ! is_admin() && get_option( 'mainwp_kwl_enable_statistic' ) && ! empty($this->keyword_links) ) {
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'keywordLinks', plugins_url( '/js/keywordlinks.js', dirname( __FILE__ ) ) );
|
||||
add_action( 'wp_head', array( $this, 'head_loading' ), 1 );
|
||||
|
@ -79,7 +79,7 @@ class MainWP_Keyword_Links {
|
|||
$rules .= "RewriteEngine On\n";
|
||||
$rules .= "RewriteBase $home_root\n";
|
||||
|
||||
//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
|
||||
// add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
|
||||
foreach ( $pRules as $match => $query ) {
|
||||
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
|
||||
$match = str_replace( '.+?', '.+', $match );
|
||||
|
@ -95,13 +95,13 @@ class MainWP_Keyword_Links {
|
|||
function update_htaccess( $force_update = false, $force_clear = false ) {
|
||||
if ( $force_clear ) {
|
||||
$this->do_update_htaccess( true );
|
||||
} else if ( $force_update ) {
|
||||
} elseif ( $force_update ) {
|
||||
return $this->do_update_htaccess();
|
||||
} else {
|
||||
if ( '' == get_option( 'permalink_structure' ) && 'yes' !== get_option( 'mainwp_keyword_links_htaccess_set' ) ) {
|
||||
$this->do_update_htaccess();
|
||||
} // need to update
|
||||
else if ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) {
|
||||
elseif ( '' != get_option( 'permalink_structure' ) && 'yes' === get_option( 'mainwp_keyword_links_htaccess_set' ) ) {
|
||||
$this->do_update_htaccess();
|
||||
} // need to update
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
|
||||
public static function clear_htaccess() {
|
||||
include_once( ABSPATH . '/wp-admin/includes/misc.php' );
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php';
|
||||
$home_path = ABSPATH;
|
||||
$htaccess_file = $home_path . '.htaccess';
|
||||
if ( function_exists( 'save_mod_rewrite_rules' ) ) {
|
||||
|
@ -125,15 +125,15 @@ class MainWP_Keyword_Links {
|
|||
self::clear_htaccess();
|
||||
|
||||
return true;
|
||||
} else if ( '' === get_option( 'permalink_structure' ) ) {
|
||||
include_once( ABSPATH . '/wp-admin/includes/misc.php' );
|
||||
} elseif ( '' === get_option( 'permalink_structure' ) ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php';
|
||||
$redirection_folder = $this->get_option( 'redirection_folder', '' );
|
||||
if ( empty( $redirection_folder ) ) {
|
||||
$rules = $this->get_cloak_rules();
|
||||
$rules = $this->mod_rewrite_rules( $rules );
|
||||
//self::clear_htaccess();
|
||||
// self::clear_htaccess();
|
||||
} else {
|
||||
//Create rewrite ruler
|
||||
// Create rewrite ruler
|
||||
$rules = $this->mod_rewrite_rules( array( $redirection_folder . '/' => 'index.php' ) );
|
||||
}
|
||||
$home_path = ABSPATH;
|
||||
|
@ -297,7 +297,7 @@ class MainWP_Keyword_Links {
|
|||
if ( is_array( $specific_link ) && count( $specific_link ) > 0 ) {
|
||||
$specific_link = current( $specific_link );
|
||||
$specific_link->post_id = $post->ID;
|
||||
//update_post_meta($post->ID, '_mainwp_kwl_specific_link_save', array($specific_link->id => $specific_link));
|
||||
// update_post_meta($post->ID, '_mainwp_kwl_specific_link_save', array($specific_link->id => $specific_link));
|
||||
update_post_meta( $post->ID, '_mainwp_kwl_specific_link_id', $specific_link->id );
|
||||
if ( $this->set_link( $specific_link->id, $specific_link ) ) {
|
||||
update_post_meta( $post->ID, '_mainwp_kwl_specific_link', '<saved>' );
|
||||
|
@ -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);
|
||||
// }
|
||||
|
@ -343,10 +343,10 @@ class MainWP_Keyword_Links {
|
|||
$this->link_exact_match = $link->exact_match;
|
||||
$this->link_case_sensitive = $link->case_sensitive;
|
||||
$keywords = $this->explode_multi( $link->keyword );
|
||||
//usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
||||
usort( $keywords, array($this, 'usort_callback_func') );
|
||||
// usort( $keywords, create_function( '$a,$b', 'return strlen($a)<strlen($b);' ) );
|
||||
usort( $keywords, array( $this, 'usort_callback_func' ) );
|
||||
$replace_cs = $link->case_sensitive ? 's' : 'is';
|
||||
//print_r($keywords);
|
||||
// print_r($keywords);
|
||||
foreach ( $keywords as $keyword ) {
|
||||
$keyword = trim( $keyword );
|
||||
if ( empty( $keyword ) ) {
|
||||
|
@ -361,15 +361,15 @@ class MainWP_Keyword_Links {
|
|||
$keyword = preg_replace( '/([$^\/?+.*\]\[)(}{])/is', '\\\\\1', $keyword );
|
||||
|
||||
if ( ( $link->case_sensitive && strpos( $content, $keyword ) !== false ) || ( ! $link->case_sensitive && stripos( $content, $keyword ) !== false ) ) {
|
||||
//Replace keyword in H tag
|
||||
// Replace keyword in H tag
|
||||
if ( $this->get_option( 'replace_keyword_in_h_tag' ) ) {
|
||||
//$content = preg_replace_callback('/(<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
// $content = preg_replace_callback('/(<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
$content = preg_replace_callback( '/(<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array(
|
||||
&$this,
|
||||
'keyword_mark',
|
||||
), $content );
|
||||
} else {
|
||||
//$content = preg_replace_callback('/(<h[123456][^>]*>.*?'.$keyword.'.*?<\/h[123456]>|<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
// $content = preg_replace_callback('/(<h[123456][^>]*>.*?'.$keyword.'.*?<\/h[123456]>|<a[^>]*>.*?'.$keyword.'.*?<\/a>|<[^>]*'.$keyword.'[^>]*>|\{[^}]*'.$keyword.'[^}]*\}|\w*('.$keyword.')\w*)/is', array(&$this, 'keyword_mark'), $content);
|
||||
$content = preg_replace_callback( '/(<h[123456][^>]*>[^<]*?' . $keyword . '[^<]*?<\/h[123456]>|<a[^>]*>[^<]*?' . $keyword . '[^<]*?<\/a>|<[^>]*' . $keyword . '[^>]*>|\{[^\}]*' . $keyword . '[^\}]*\}|\w*(' . $keyword . ')\w*)/' . $replace_cs, array(
|
||||
&$this,
|
||||
'keyword_mark',
|
||||
|
@ -378,7 +378,7 @@ class MainWP_Keyword_Links {
|
|||
}
|
||||
}
|
||||
}
|
||||
//$content = preg_replace_callback('/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" *\}/is', array(&$this, 'keyword_replace'), $content);
|
||||
// $content = preg_replace_callback('/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" *\}/is', array(&$this, 'keyword_replace'), $content);
|
||||
$content = preg_replace_callback( '/\{MAINWP_LINK +HREF="(.*?)" +TARGET="(.*?)" +REL="(.*?)" +LINK-ID="(.*?)" +CLASS="(.*?)" +TEXT="(.*?)" +FULL_TEXT="(.*?)" *\}/is', array(
|
||||
&$this,
|
||||
'keyword_replace',
|
||||
|
@ -387,8 +387,8 @@ class MainWP_Keyword_Links {
|
|||
return $content;
|
||||
}
|
||||
|
||||
private function usort_callback_func($a, $b) {
|
||||
return strlen($a)<strlen($b);
|
||||
private function usort_callback_func( $a, $b) {
|
||||
return strlen($a) < strlen($b);
|
||||
}
|
||||
|
||||
public function keyword_mark( $matches ) {
|
||||
|
@ -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);
|
||||
|
@ -456,7 +456,7 @@ class MainWP_Keyword_Links {
|
|||
$class .= ' kwl-regular-link';
|
||||
}
|
||||
|
||||
//return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}';
|
||||
// return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . (isset($this->link_temp->id) ? $this->link_temp->id : 0) . '" CLASS="' . $class . '" TEXT="' . $matches[1] . '"}';
|
||||
return '{MAINWP_LINK HREF="' . ( $this->link_temp->cloak_path ? $this->siteurl . $redirection_folder . '/' . $this->link_temp->cloak_path : $this->link_temp->destination_url ) . '" TARGET="' . $target . '" REL="' . $rel . '" LINK-ID="' . ( isset( $this->link_temp->id ) ? $this->link_temp->id : 0 ) . '" CLASS="' . $class . '" TEXT="' . $matches[2] . '" FULL_TEXT="' . $matches[1] . '"}';
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
// }
|
||||
|
@ -514,7 +514,7 @@ class MainWP_Keyword_Links {
|
|||
} else {
|
||||
$links_post_type = (array) $this->get_post_keywords( $post_type );
|
||||
}
|
||||
//print_r($links_post_type);
|
||||
// print_r($links_post_type);
|
||||
if ( count( $links_post_type ) > 0 ) {
|
||||
$links = array_merge( $links, $links_post_type );
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ class MainWP_Keyword_Links {
|
|||
} else {
|
||||
$links[] = $link;
|
||||
}
|
||||
} else if ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link
|
||||
} elseif ( $spec_link_id && $spec_link_id === $link->id ) { // type 2 is specific link
|
||||
if ( $link->check_post_date ) {
|
||||
if ( $post_timestamp < $link->check_post_date ) {
|
||||
$links[] = $link;
|
||||
|
@ -557,7 +557,7 @@ class MainWP_Keyword_Links {
|
|||
$join = "JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID";
|
||||
$where = " AND (tr.term_taxonomy_id = '" . implode( "' OR tr.term_taxonomy_id = '", $cats ) . "')";
|
||||
}
|
||||
//$results = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta as pm ON p.ID=pm.post_id $join WHERE p.post_status='publish' AND p.post_type='%s' AND pm.meta_key='_mainwp_kl_post_keyword' $where", $post_type));
|
||||
// $results = $wpdb->get_results(sprintf("SELECT * FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta as pm ON p.ID=pm.post_id $join WHERE p.post_status='publish' AND p.post_type='%s' AND pm.meta_key='_mainwp_kl_post_keyword' $where", $post_type));
|
||||
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts as p $join WHERE p.post_status='publish' AND p.post_type= %s $where", $post_type ) );
|
||||
$links = array();
|
||||
if ( ! is_array( $results ) ) {
|
||||
|
@ -571,13 +571,13 @@ 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->id = $result->ID;
|
||||
$link->name = $result->post_title;
|
||||
//if ($result->post_type == 'page')
|
||||
// if ($result->post_type == 'page')
|
||||
// $link->destination_url = get_permalink($result->ID);
|
||||
//else
|
||||
// else
|
||||
// $link->destination_url = $result->guid;
|
||||
$link->destination_url = get_permalink( $result->ID );
|
||||
$link->cloak_path = '';
|
||||
|
@ -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 );
|
||||
|
@ -625,7 +625,7 @@ class MainWP_Keyword_Links {
|
|||
$redirection_folder = $this->get_option( 'redirection_folder', '' );
|
||||
|
||||
if ( ! empty( $redirection_folder ) ) {
|
||||
//if the request doesn't' containt the redirection folder we will return immediately
|
||||
// if the request doesn't' containt the redirection folder we will return immediately
|
||||
if ( strpos( $filter_request, $redirection_folder . '/' ) === false ) {
|
||||
return;
|
||||
}
|
||||
|
@ -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';
|
||||
|
@ -741,7 +741,7 @@ class MainWP_Keyword_Links {
|
|||
if ( $remove_settings ) {
|
||||
$this->clear_settings();
|
||||
$return['status'] = 'SUCCESS';
|
||||
} else if ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) {
|
||||
} elseif ( is_array( $remove_kws ) && is_array( $this->keyword_links ) ) {
|
||||
$new_keyword_links = array();
|
||||
foreach ( $this->keyword_links as $link_id => $link ) {
|
||||
$lnk_kws = $link->keyword;
|
||||
|
@ -853,7 +853,7 @@ class MainWP_Keyword_Links {
|
|||
if ( 3 === (int) $clear_link->type ) {
|
||||
$clear_link->type = 2;
|
||||
$cleared = $this->set_link( $clear_link->id, $clear_link );
|
||||
} else if ( 1 === (int) $clear_link->type ) {
|
||||
} elseif ( 1 === (int) $clear_link->type ) {
|
||||
$cleared = $this->set_link( $clear_link->id, '' ); // delete link
|
||||
}
|
||||
$this->update_htaccess_for_change_cloak_links( $clear_link );
|
||||
|
@ -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'] );
|
||||
|
@ -901,7 +901,7 @@ class MainWP_Keyword_Links {
|
|||
if ( 2 === (int) $link->type || 3 === (int) $link->type ) {
|
||||
if ( intval( $_POST['post_id'] ) ) {
|
||||
$link->post_id = intval( $_POST['post_id'] );
|
||||
} else if ( $old && $old->post_id ) {
|
||||
} elseif ( $old && $old->post_id ) {
|
||||
$link->post_id = $old->post_id;
|
||||
}
|
||||
if ( $link->post_id ) {
|
||||
|
|
|
@ -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 );
|
||||
|
@ -19,13 +19,13 @@ class MainWP_Security {
|
|||
add_filter( 'script_loader_src', array( 'MainWP_Security', 'remove_theme_versions' ), PHP_INT_MAX );
|
||||
}
|
||||
|
||||
//Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads
|
||||
// Prevent listing wp-content, wp-content/plugins, wp-content/themes, wp-content/uploads
|
||||
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' );
|
||||
|
@ -66,7 +66,7 @@ class MainWP_Security {
|
|||
return ! empty( $security ) && isset( $security[ $option ] ) && ( true === $security[ $option ] );
|
||||
}
|
||||
|
||||
//Removed wp-version
|
||||
// Removed wp-version
|
||||
public static function remove_wp_version_ok() {
|
||||
return ! ( has_action( 'wp_head', 'wp_generator' ) || has_filter( 'wp_head', 'wp_generator' ) );
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
//Removed Really Simple Discovery meta tag
|
||||
// Removed Really Simple Discovery meta tag
|
||||
public static function remove_rsd_ok() {
|
||||
return ( ! has_action( 'wp_head', 'rsd_link' ) );
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
//Removed Windows Live Writer meta tag
|
||||
// Removed Windows Live Writer meta tag
|
||||
public static function remove_wlw_ok() {
|
||||
return ( ! has_action( 'wp_head', 'wlwmanifest_link' ) );
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
//Removed core update information for non-admins
|
||||
// Removed core update information for non-admins
|
||||
// public static function remove_core_update_ok()
|
||||
// {
|
||||
// return self::get_security_option('core_updates');
|
||||
|
@ -125,7 +125,7 @@ class MainWP_Security {
|
|||
// }
|
||||
// }
|
||||
|
||||
//Removed plugin-update information for non-admins
|
||||
// Removed plugin-update information for non-admins
|
||||
// public static function remove_plugin_update_ok()
|
||||
// {
|
||||
// return self:get_security_option('plugin_updates');
|
||||
|
@ -153,7 +153,7 @@ class MainWP_Security {
|
|||
// }
|
||||
// }
|
||||
|
||||
//Removed theme-update information for non-admins
|
||||
// Removed theme-update information for non-admins
|
||||
// public static function remove_theme_update_ok()
|
||||
// {
|
||||
// return self::get_security_option('theme_updates');
|
||||
|
@ -175,12 +175,12 @@ class MainWP_Security {
|
|||
// }
|
||||
// }
|
||||
|
||||
//File permissions not secure
|
||||
// File permissions not secure
|
||||
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',
|
||||
|
@ -225,7 +225,7 @@ class MainWP_Security {
|
|||
// return $success;
|
||||
// }
|
||||
|
||||
//Database error reporting turned on/off
|
||||
// Database error reporting turned on/off
|
||||
public static function remove_database_reporting_ok() {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -239,7 +239,7 @@ class MainWP_Security {
|
|||
$wpdb->suppress_errors();
|
||||
}
|
||||
|
||||
//PHP error reporting turned on/off
|
||||
// PHP error reporting turned on/off
|
||||
public static function remove_php_reporting_ok() {
|
||||
return ! ( ( ( 0 != ini_get( 'display_errors' ) ) && ( 'off' != ini_get( 'display_errors' ) ) ) || ( ( 0 != ini_get( 'display_startup_errors' ) ) && ( 'off' != ini_get( 'display_startup_errors' ) ) ) );
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class MainWP_Security {
|
|||
}
|
||||
}
|
||||
|
||||
//Removed version information for scripts/stylesheets
|
||||
// Removed version information for scripts/stylesheets
|
||||
public static function remove_scripts_version_ok() {
|
||||
return self::get_security_option( 'scripts_version' );
|
||||
}
|
||||
|
@ -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' ) ) {
|
||||
|
@ -348,10 +349,12 @@ class MainWP_Security {
|
|||
return self::get_security_option( 'styles_version' );
|
||||
}
|
||||
|
||||
//Admin user name is not admin
|
||||
// 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) )
|
||||
$security[$key] = $value;
|
||||
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 ) ) {
|
||||
|
@ -78,7 +78,7 @@ class MainWP_Wordpress_SEO {
|
|||
unlink( $temporary_file );
|
||||
}
|
||||
|
||||
} else if ( isset( $_POST['settings'] ) ) {
|
||||
} elseif ( isset( $_POST['settings'] ) ) {
|
||||
try {
|
||||
$settings = base64_decode( $_POST['settings'] );
|
||||
// @codingStandardsIgnoreLine
|
||||
|
@ -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();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
//todo: BZ2; support fseek!
|
||||
// todo: BZ2; support fseek!
|
||||
|
||||
class Tar_Archiver {
|
||||
const IDLE = 0;
|
||||
|
@ -16,16 +16,16 @@ class Tar_Archiver {
|
|||
|
||||
protected $debug;
|
||||
|
||||
protected $chunk = ''; //1024 * 1024 * 4
|
||||
protected $chunkSize = 4194304; //1024 * 1024 * 4
|
||||
protected $chunk = ''; // 1024 * 1024 * 4
|
||||
protected $chunkSize = 4194304; // 1024 * 1024 * 4
|
||||
|
||||
/** @var $backup MainWP_Backup */
|
||||
protected $backup;
|
||||
|
||||
protected $type;
|
||||
protected $pidFile; //filepath of pid file
|
||||
protected $pidContent; //content of pid file
|
||||
protected $pidUpdated; //last updated pid file
|
||||
protected $pidFile; // filepath of pid file
|
||||
protected $pidContent; // content of pid file
|
||||
protected $pidUpdated; // last updated pid file
|
||||
|
||||
protected $mode = self::IDLE;
|
||||
|
||||
|
@ -127,7 +127,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
public function createFullBackup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append = false ) {
|
||||
//$this->logHandle = fopen($filepath . ".log", "a+");
|
||||
// $this->logHandle = fopen($filepath . ".log", "a+");
|
||||
$this->createPidFile( $filepath );
|
||||
|
||||
$this->excludeZip = $excludezip;
|
||||
|
@ -139,7 +139,7 @@ class Tar_Archiver {
|
|||
// $this->limit = true;
|
||||
// }
|
||||
|
||||
if ( $append && @file_exists( $filepath ) ) { //todo: use wpFS
|
||||
if ( $append && @file_exists( $filepath ) ) { // todo: use wpFS
|
||||
$this->mode = self::APPEND;
|
||||
$this->prepareAppend( $filepath );
|
||||
} else {
|
||||
|
@ -176,7 +176,7 @@ class Tar_Archiver {
|
|||
foreach ( $nodes as $key => $node ) {
|
||||
if ( MainWP_Helper::startsWith( $node, ABSPATH . WPINC ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else if ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
} elseif ( MainWP_Helper::startsWith( $node, ABSPATH . basename( admin_url( '' ) ) ) ) {
|
||||
unset( $nodes[ $key ] );
|
||||
} else {
|
||||
foreach ( $coreFiles as $coreFile ) {
|
||||
|
@ -209,7 +209,7 @@ class Tar_Archiver {
|
|||
if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) {
|
||||
if ( is_dir( $node ) ) {
|
||||
$this->addDir( $node, $excludes );
|
||||
} else if ( is_file( $node ) ) {
|
||||
} elseif ( is_file( $node ) ) {
|
||||
$this->addFile( $node, str_replace( ABSPATH, '', $node ) );
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
) ) );
|
||||
|
@ -328,12 +328,12 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
//if (@fwrite($this->archive, $data, strlen($data)) === false)
|
||||
// if (@fwrite($this->archive, $data, strlen($data)) === false)
|
||||
if ( false === @gzwrite( $this->archive, $data, strlen( $data ) ) ) {
|
||||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
//@fflush($this->archive);
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
// @fflush($this->archive);
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) {
|
||||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ class Tar_Archiver {
|
|||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
@fflush( $this->archive );
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
if ( false === @bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) {
|
||||
throw new Exception( 'Could not write to archive' );
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ class Tar_Archiver {
|
|||
$stat = @stat( $path );
|
||||
$fp = @fopen( $path, 'rb' );
|
||||
if ( ! $fp ) {
|
||||
//todo: add some error feedback!
|
||||
// todo: add some error feedback!
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
while ( ! feof( $fp ) ) {
|
||||
//0.1MB = 1024 000
|
||||
// 0.1MB = 1024 000
|
||||
$this->tempContent = fread( $fp, 1024000 * 5 );
|
||||
|
||||
$read = strlen( $this->tempContent );
|
||||
|
@ -725,14 +725,14 @@ class Tar_Archiver {
|
|||
private function checkBeforeAppend( $entryName ) {
|
||||
$rslt = $this->isNextFile( $entryName );
|
||||
|
||||
//Correct file
|
||||
// Correct file
|
||||
if ( true === $rslt ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$out = false;
|
||||
|
||||
//close, reopen with append & ftruncate
|
||||
// close, reopen with append & ftruncate
|
||||
$this->close( false );
|
||||
$this->log( 'Reopen archive to append from here' );
|
||||
$this->append( $this->archivePath );
|
||||
|
@ -741,19 +741,19 @@ class Tar_Archiver {
|
|||
$startOffset = $rslt['startOffset'];
|
||||
@fseek( $this->archive, $startOffset );
|
||||
@ftruncate( $this->archive, $startOffset );
|
||||
} else if ( 'tar.gz' == $this->type ) {
|
||||
} elseif ( 'tar.gz' == $this->type ) {
|
||||
$readOffset = $rslt['readOffset'];
|
||||
$bytesRead = $rslt['bytesRead'];
|
||||
//@fseek($this->archive, $readOffset + $bytesRead);
|
||||
// @fseek($this->archive, $readOffset + $bytesRead);
|
||||
|
||||
$out = array( 'bytesRead' => $bytesRead );
|
||||
}
|
||||
} else if ( false === $rslt ) {
|
||||
} elseif ( false === $rslt ) {
|
||||
if ( 'tar' == $this->type ) {
|
||||
@fseek( $this->archive, 0, SEEK_END );
|
||||
}
|
||||
} else {
|
||||
//todo: check for tar.gz & tar!
|
||||
// todo: check for tar.gz & tar!
|
||||
@fseek( $this->archive, $rslt );
|
||||
@ftruncate( $this->archive, $rslt );
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
//Check for long file!!
|
||||
// Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -820,7 +820,7 @@ class Tar_Archiver {
|
|||
} else {
|
||||
throw new Exception( 'Unexpected directory [' . $file['name'] . ']' );
|
||||
}
|
||||
} else if ( 0 == $file['type'] ) {
|
||||
} elseif ( 0 == $file['type'] ) {
|
||||
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
|
||||
$previousFtell = @ftell( $this->archive );
|
||||
|
||||
|
@ -862,7 +862,7 @@ class Tar_Archiver {
|
|||
|
||||
return $rslt;
|
||||
}
|
||||
} else if ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) {
|
||||
} elseif ( ( 'tar' == $this->type ) && ( ( false === $ftell ) || ( -1 == $ftell ) ) ) {
|
||||
$this->log( 'Will append this: ' . print_r( $rslt, 1 ) );
|
||||
|
||||
return $rslt;
|
||||
|
@ -904,9 +904,9 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
// $this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
$this->archive = @gzopen( $filepath, 'wb' );
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
$this->archive = @bzopen( $filepath, 'w' );
|
||||
} else {
|
||||
$this->archive = @fopen( $filepath, 'wb+' );
|
||||
|
@ -926,9 +926,9 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
//$this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
// $this->archive = @fopen('compress.zlib://' . $filepath, 'ab');
|
||||
$this->archive = @gzopen( $filepath, 'ab' );
|
||||
} else if ( $this->type == 'tar.bz2' ) {
|
||||
} elseif ( $this->type == 'tar.bz2' ) {
|
||||
$this->archive = @bzopen( $filepath, 'a' );
|
||||
} else {
|
||||
$this->archive = @fopen( $filepath, 'ab+' );
|
||||
|
@ -942,9 +942,9 @@ class Tar_Archiver {
|
|||
function prepareAppend( $filepath ) {
|
||||
if ( $this->debug ) {
|
||||
if ( 'tar.gz' == substr( $filepath, - 6 ) ) {
|
||||
$text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); //magic header!!
|
||||
$text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); // magic header!!
|
||||
|
||||
//Check if valid, if not, crop to valid!
|
||||
// Check if valid, if not, crop to valid!
|
||||
$fh = @fopen( $filepath, 'rb' );
|
||||
$read = '';
|
||||
$lastCorrect = 0;
|
||||
|
@ -972,7 +972,7 @@ class Tar_Archiver {
|
|||
@fclose( $fh );
|
||||
} catch ( Exception $e ) {
|
||||
@fclose( $fh );
|
||||
//reopen & truncate
|
||||
// reopen & truncate
|
||||
$fh = @fopen( $filepath, 'ab+' );
|
||||
@fseek( $fh, $lastCorrect );
|
||||
@ftruncate( $fh, $lastCorrect );
|
||||
|
@ -992,7 +992,7 @@ class Tar_Archiver {
|
|||
$this->type = 'tar.gz';
|
||||
// $this->archive = @fopen('compress.zlib://' . $filepath, 'rb');
|
||||
$this->archive = @gzopen( $filepath, 'r' );
|
||||
} else if ( 'tar.bz2' == substr( $filepath, - 7 ) ) {
|
||||
} elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) {
|
||||
$this->type = 'tar.bz2';
|
||||
$this->archive = @bzopen( $filepath, 'r' );
|
||||
} else {
|
||||
|
@ -1009,7 +1009,7 @@ class Tar_Archiver {
|
|||
}
|
||||
|
||||
function close( $closeLog = true ) {
|
||||
//Write chunk if it's not empty..
|
||||
// Write chunk if it's not empty..
|
||||
$this->writeChunk();
|
||||
|
||||
$this->log( 'Closing archive' );
|
||||
|
@ -1020,9 +1020,9 @@ class Tar_Archiver {
|
|||
|
||||
if ( $this->archive ) {
|
||||
if ( 'tar.gz' == $this->type ) {
|
||||
//@fclose($this->archive);
|
||||
// @fclose($this->archive);
|
||||
@gzclose( $this->archive );
|
||||
} else if ( 'tar.bz2' == $this->type ) {
|
||||
} elseif ( 'tar.bz2' == $this->type ) {
|
||||
@bzclose( $this->archive );
|
||||
} else {
|
||||
@fclose( $this->archive );
|
||||
|
@ -1041,7 +1041,7 @@ class Tar_Archiver {
|
|||
@fseek( $this->archive, 0 );
|
||||
while ( $block = @fread( $this->archive, 512 ) ) {
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
//Check for long file!!
|
||||
// Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -1065,7 +1065,7 @@ class Tar_Archiver {
|
|||
|
||||
if ( $file['checksum'] == 0x00000000 ) {
|
||||
break;
|
||||
} else if ( substr( $file['magic'], 0, 5 ) != 'ustar' ) {
|
||||
} elseif ( substr( $file['magic'], 0, 5 ) != 'ustar' ) {
|
||||
// $this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ class Tar_Archiver {
|
|||
@fseek( $this->archive, 0 );
|
||||
while ( $block = @fread( $this->archive, 512 ) ) {
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
//Check for long file!!
|
||||
// Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -1134,7 +1134,7 @@ class Tar_Archiver {
|
|||
|
||||
if ( $file['checksum'] == 0x00000000 ) {
|
||||
break;
|
||||
} else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
} elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
// $this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
|
@ -1151,7 +1151,7 @@ class Tar_Archiver {
|
|||
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
|
||||
return true;
|
||||
}
|
||||
} else if ( 0 == $file['type'] ) {
|
||||
} elseif ( 0 == $file['type'] ) {
|
||||
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1174,7 +1174,7 @@ class Tar_Archiver {
|
|||
@fseek( $this->archive, 0 );
|
||||
while ( $block = fread( $this->archive, 512 ) ) {
|
||||
$temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block );
|
||||
//Check for long file!!
|
||||
// Check for long file!!
|
||||
if ( 'L' == $temp['type'] ) {
|
||||
$fname = trim( @fread( $this->archive, 512 ) );
|
||||
$block = @fread( $this->archive, 512 );
|
||||
|
@ -1198,7 +1198,7 @@ class Tar_Archiver {
|
|||
|
||||
if ( $file['checksum'] == 0x00000000 ) {
|
||||
break;
|
||||
} else if ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
} elseif ( 'ustar' != substr( $file['magic'], 0, 5 ) ) {
|
||||
// $this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
|
@ -1217,7 +1217,7 @@ class Tar_Archiver {
|
|||
mkdir( $to . $file['name'], 0777, true );
|
||||
}
|
||||
}
|
||||
} else if ( 0 == $file['type'] ) {
|
||||
} elseif ( 0 == $file['type'] ) {
|
||||
if ( ! is_dir( dirname( $to . $file['name'] ) ) ) {
|
||||
if ( ! empty( $wp_filesystem ) ) {
|
||||
$wp_filesystem->mkdir( dirname( $to . $file['name'] ), FS_CHMOD_DIR );
|
||||
|
@ -1302,20 +1302,20 @@ if ( class_exists( 'SplHeap' ) ) {
|
|||
$dirnameA = ( is_file( $pathA ) ? dirname( $pathA ) : $pathA );
|
||||
$dirnameB = ( is_file( $pathB ) ? dirname( $pathB ) : $pathB );
|
||||
|
||||
//if both are in the same folder, first show the files, then the directories
|
||||
// if both are in the same folder, first show the files, then the directories
|
||||
if ( dirname( $pathA ) == dirname( $pathB ) ) {
|
||||
if ( is_file( $pathA ) && ! is_file( $pathB ) ) {
|
||||
return - 1;
|
||||
} else if ( ! is_file( $pathA ) && is_file( $pathB ) ) {
|
||||
} elseif ( ! is_file( $pathA ) && is_file( $pathB ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return strcmp( $pathA, $pathB );
|
||||
} else if ( $dirnameA == $dirnameB ) {
|
||||
} elseif ( $dirnameA == $dirnameB ) {
|
||||
return strcmp( $pathA, $pathB );
|
||||
} else if ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) {
|
||||
} elseif ( MainWP_Helper::startsWith( $dirnameA, $dirnameB ) ) {
|
||||
return 1;
|
||||
} else if ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) {
|
||||
} elseif ( MainWP_Helper::startsWith( $dirnameB, $dirnameA ) ) {
|
||||
return - 1;
|
||||
} else {
|
||||
$cmp = strcmp( $dirnameA, $dirnameB );
|
||||
|
|
|
@ -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