Everywhere yoda conditions are
This commit is contained in:
@ -78,7 +78,7 @@ if ( ! class_exists('MUCD_Data') ) {
|
||||
$schema = DB_NAME;
|
||||
|
||||
// Get sources Tables
|
||||
if ($from_site_id == MUCD_PRIMARY_SITE_ID) {
|
||||
if (MUCD_PRIMARY_SITE_ID == $from_site_id) {
|
||||
$from_site_table = self::get_primary_tables($from_site_prefix);
|
||||
} else {
|
||||
$sql_query = $wpdb->prepare('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \'%s\' AND TABLE_NAME LIKE \'%s\'', $schema, $from_site_prefix_like . '%');
|
||||
@ -319,10 +319,11 @@ if ( ! class_exists('MUCD_Data') ) {
|
||||
$new = $val;
|
||||
if (is_string($val)) {
|
||||
$pos = strpos($val, $to_string);
|
||||
if ($pos === false) {
|
||||
if (false === $pos) {
|
||||
$new = str_replace($from_string, $to_string, $val);
|
||||
}
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
@ -398,6 +399,7 @@ if ( ! class_exists('MUCD_Data') ) {
|
||||
} else {
|
||||
$row[ $field ] = self::replace($row[ $field ], $from_string, $to_string);
|
||||
}
|
||||
|
||||
return $row[ $field ];
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
|
||||
self::bypass_server_limit();
|
||||
|
||||
// Copy Site - File
|
||||
if ($copy_file == 'yes') {
|
||||
if ('yes' == $copy_file) {
|
||||
do_action('mucd_before_copy_files', $from_site_id, $to_site_id);
|
||||
$result = MUCD_Files::copy_files($from_site_id, $to_site_id);
|
||||
do_action('mucd_after_copy_files', $from_site_id, $to_site_id);
|
||||
@ -89,7 +89,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
|
||||
do_action('mucd_after_copy_data', $from_site_id, $to_site_id);
|
||||
|
||||
// Copy Site - Users
|
||||
if ($keep_users == 'yes') {
|
||||
if ('yes' == $keep_users) {
|
||||
do_action('mucd_before_copy_users', $from_site_id, $to_site_id);
|
||||
$result = self::copy_users($from_site_id, $to_site_id);
|
||||
do_action('mucd_after_copy_users', $from_site_id, $to_site_id);
|
||||
@ -190,6 +190,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
update_user_meta($user->ID, $to_site_prefix . $raw_meta_name, maybe_unserialize($metavalue));
|
||||
}
|
||||
}
|
||||
@ -211,8 +212,9 @@ if ( ! class_exists('MUCD_Duplicate') ) {
|
||||
if (isset($data['log-path']) && ! empty($data['log-path'])) {
|
||||
$log_name = @date('Y_m_d_His') . '-' . $data['domain'] . '.log';
|
||||
if (! str_ends_with((string) $data['log-path'], '/')) {
|
||||
$data['log-path'] = $data['log-path'] . '/';
|
||||
$data['log-path'] .= '/';
|
||||
}
|
||||
|
||||
self::$log = new MUCD_Log(true, $data['log-path'], $log_name);
|
||||
}
|
||||
} else {
|
||||
@ -273,6 +275,7 @@ if ( ! class_exists('MUCD_Duplicate') ) {
|
||||
if (self::log() !== false) {
|
||||
return self::$log->file_url();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
switch_to_blog($from_site_id);
|
||||
$wp_upload_info = wp_upload_dir();
|
||||
$from_dir['path'] = $wp_upload_info['basedir'];
|
||||
$from_site_id == MUCD_PRIMARY_SITE_ID ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = [];
|
||||
MUCD_PRIMARY_SITE_ID == $from_site_id ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = [];
|
||||
|
||||
// Switch to Destination site and get uploads info
|
||||
switch_to_blog($to_site_id);
|
||||
@ -38,6 +38,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
if (isset($dir['to_dir_path']) && ! self::init_dir($dir['to_dir_path'])) {
|
||||
self::mkdir_error($dir['to_dir_path']);
|
||||
}
|
||||
|
||||
MUCD_Duplicate::write_log('Copy files from ' . $dir['from_dir_path'] . ' to ' . $dir['to_dir_path']);
|
||||
self::recurse_copy($dir['from_dir_path'], $dir['to_dir_path'], $dir['exclude_dirs']);
|
||||
}
|
||||
@ -59,7 +60,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
$dir = opendir($src);
|
||||
@mkdir($dst);
|
||||
while (false !== ($file = readdir($dir)) ) {
|
||||
if (($file != '.') && ($file != '..')) {
|
||||
if (('.' != $file) && ('..' != $file)) {
|
||||
if ( is_dir($src . '/' . $file) ) {
|
||||
if ( ! in_array($file, $exclude_dirs)) {
|
||||
self::recurse_copy($src . '/' . $file, $dst . '/' . $file);
|
||||
@ -69,6 +70,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
@ -88,6 +90,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
if ( ! is_writable($path)) {
|
||||
return chmod($path, 0777);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -106,7 +109,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != '.' && $object != '..') {
|
||||
if ('.' != $object && '..' != $object) {
|
||||
if (filetype($dir . '/' . $object) == 'dir') {
|
||||
self::rrmdir($dir . '/' . $object);
|
||||
} else {
|
||||
@ -114,6 +117,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
@ -135,6 +139,7 @@ if ( ! class_exists('MUCD_Files') ) {
|
||||
if ( $log_url = MUCD_Duplicate::log_url() ) {
|
||||
echo '<a href="' . $log_url . '">' . MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG . '</a>';
|
||||
}
|
||||
|
||||
MUCD_Functions::remove_blog(self::$to_site_id);
|
||||
wp_die();
|
||||
}
|
||||
|
@ -15,8 +15,9 @@ if ( ! class_exists('MUCD_Functions') ) {
|
||||
if (strpos($path, ':') == 1 && preg_match('/[a-zA-Z]/', $path[0])) {
|
||||
$tmp = substr($path, 2);
|
||||
$bool = preg_match('/^[^*?"<>|:]*$/', $tmp);
|
||||
return ($bool == 1); // so that it will return only true and false
|
||||
return (1 == $bool); // so that it will return only true and false
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -30,7 +31,7 @@ if ( ! class_exists('MUCD_Functions') ) {
|
||||
public static function valid_unix_dir_path($path) {
|
||||
$reg = '/^(\/([a-zA-Z0-9+$_.-])+)*\/?$/';
|
||||
$bool = preg_match($reg, $path);
|
||||
return ($bool == 1);
|
||||
return (1 == $bool);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,10 +75,7 @@ if ( ! class_exists('MUCD_Functions') ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( get_blog_option($blog_id, 'mucd_duplicable', 'no') == 'yes') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return get_blog_option($blog_id, 'mucd_duplicable', 'no') == 'yes';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,10 +107,11 @@ if ( ! class_exists('MUCD_Functions') ) {
|
||||
*/
|
||||
public static function value_in_array($value, $array, $key): bool {
|
||||
foreach ($array as $row) {
|
||||
if (isset($row[ $key ]) && $value == $row[ $key ]) {
|
||||
if (isset($row[ $key ]) && $row[ $key ] == $value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -194,6 +193,7 @@ if ( ! class_exists('MUCD_Functions') ) {
|
||||
foreach ($sites as $key => $site) {
|
||||
$sites[ $key ] = (array) $site;
|
||||
}
|
||||
|
||||
return $sites;
|
||||
} else {
|
||||
$defaults = ['limit' => MUCD_MAX_NUMBER_OF_SITE];
|
||||
|
@ -8,20 +8,24 @@ if ( ! class_exists('MUCD_Log') ) {
|
||||
* @readonly
|
||||
*/
|
||||
private string $log_file_path;
|
||||
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
private string $log_file_url;
|
||||
|
||||
private $fp;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
public $mod;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $log_dir_path = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -43,7 +47,7 @@ if ( ! class_exists('MUCD_Log') ) {
|
||||
|
||||
$this->log_file_url = str_replace(ABSPATH, get_site_url(1, '/'), $log_dir_path) . $log_file_name;
|
||||
|
||||
if ( $mod !== false) {
|
||||
if ( false !== $mod) {
|
||||
$this->init_file();
|
||||
}
|
||||
}
|
||||
@ -119,9 +123,11 @@ if ( ! class_exists('MUCD_Log') ) {
|
||||
if ( ! $this->fp = @fopen($this->log_file_path, 'a') ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
chmod($this->log_file_path, 0777);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -138,6 +144,7 @@ if ( ! class_exists('MUCD_Log') ) {
|
||||
fwrite($this->fp, "$time $message" . "\r\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ if ( ! class_exists('MUCD_Option') ) {
|
||||
$blog_id = $blog['blog_id'];
|
||||
add_blog_option($blog_id, 'mucd_duplicable', $blogs_value);
|
||||
}
|
||||
|
||||
add_site_option('mucd_duplicables', $network_value);
|
||||
}
|
||||
|
||||
@ -34,6 +35,7 @@ if ( ! class_exists('MUCD_Option') ) {
|
||||
$blog_id = $blog['blog_id'];
|
||||
delete_blog_option($blog_id, 'mucd_duplicable');
|
||||
}
|
||||
|
||||
delete_site_option('mucd_duplicables');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user