Refact and fix.

This commit is contained in:
thanghv 2020-05-28 01:12:59 +07:00
parent 7ad5c0c958
commit 584e4a4050
4 changed files with 25 additions and 29 deletions

View file

@ -93,8 +93,8 @@ class MainWP_Child_Back_WP_Up {
}
if ( $this->is_backwpup_installed ) {
MainWP_Helper::instance()->check_classes_exists( '\BackWPup' );
MainWP_Helper::instance()->check_methods( 'get_instance' );
MainWP_Helper::check_classes_exists( '\BackWPup' );
MainWP_Helper::check_methods( 'get_instance' );
\BackWPup::get_instance();
add_action( 'admin_init', array( $this, 'init_download_backup' ) );
@ -245,9 +245,9 @@ class MainWP_Child_Back_WP_Up {
try {
MainWP_Helper::instance()->check_classes_exists( array( '\BackWPup_File', '\BackWPup_Job' ) );
MainWP_Helper::instance()->check_methods( '\BackWPup_File', array( 'get_absolute_path' ) );
MainWP_Helper::instance()->check_methods( '\BackWPup_Job', array( 'read_logheader' ) );
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' ) );
$lasttime_logged = MainWP_Utility::get_lasttime_backup( 'backwpup' );
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = \BackWPup_File::get_absolute_path( $log_folder );
@ -341,9 +341,9 @@ class MainWP_Child_Back_WP_Up {
}
public function get_destinations_list() {
MainWP_Helper::instance()->check_classes_exists( array( '\BackWPup', '\BackWPup_Option' ) );
MainWP_Helper::instance()->check_methods( '\BackWPup', array( 'get_registered_destinations', 'get_destination' ) );
MainWP_Helper::instance()->check_methods( '\BackWPup_Option', array( 'get_job_ids', 'get' ) );
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' ) );
$jobdest = array();
$jobids = \BackWPup_Option::get_job_ids();

View file

@ -162,7 +162,7 @@ class MainWP_Child_Branding {
$current_settings['remove_permalink'] = $settings['child_remove_permalink'];
$current_settings['contact_label'] = $settings['child_button_contact_label'];
$current_settings['email_message'] = $settings['child_send_email_message'];
$current_settings['return_sender'] = $settings['child_message_return_sender'];
$current_settings['message_return_sender'] = $settings['child_message_return_sender'];
$current_settings['submit_button_title'] = $settings['child_submit_button_title'];
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) ? 'T' : '';
@ -171,7 +171,7 @@ class MainWP_Child_Branding {
if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
$current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding'];
}
$current_settings['extra_settings'] = self::get_extra_settings( $current_extra_setting, $settings, $information );
$current_settings['extra_settings'] = $this->get_extra_settings( $current_extra_setting, $settings, $information );
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings );
$information['result'] = 'SUCCESS';
@ -179,7 +179,7 @@ class MainWP_Child_Branding {
return $information;
}
public static function get_extra_settings( $current_extra_setting, $settings, &$information ) {
public function get_extra_settings( $current_extra_setting, $settings, &$information ) {
$extra_setting = array(
'show_button_in' => $settings['child_show_support_button_in'],
@ -272,7 +272,7 @@ class MainWP_Child_Branding {
return $extra_setting;
}
public static function branding_upload_image( $img_url ) {
public function branding_upload_image( $img_url ) {
include_once ABSPATH . 'wp-admin/includes/file.php';
add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 );
@ -865,7 +865,7 @@ class MainWP_Child_Branding {
return true;
}
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) && is_array( $plugins ) ) {
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
return true;
}

View file

@ -486,11 +486,9 @@ class MainWP_Child_Server_Information extends MainWP_Child_Server_Information_Ba
private static function render_server_infor() {
$branding_title = MainWP_Child_Branding::instance()->get_branding_title();
$isBranding = true;
$branding_title = MainWP_Child_Branding::instance()->get_branding_title();
if ( '' == $branding_title ) {
$branding_title = 'MainWP Child';
$isBranding = false;
$branding_title = 'MainWP Child';
}
?>
<table id="mainwp-table" class="wp-list-table widefat" cellspacing="0">
@ -509,7 +507,7 @@ class MainWP_Child_Server_Information extends MainWP_Child_Server_Information_Ba
<?php self::render_mysql_infor_rows(); ?>
<?php self::render_server_infor_rows(); ?>
<?php self::render_php_infor_rows(); ?>
<?php self::render_plugins_infor_rows( $isBranding ); ?>
<?php self::render_plugins_infor_rows( $branding_title ); ?>
</tbody>
</table>
<br/>
@ -619,21 +617,19 @@ class MainWP_Child_Server_Information extends MainWP_Child_Server_Information_Ba
<?php
}
private static function render_plugins_infor_rows( $isBranding ) {
private static function render_plugins_infor_rows( $branding_title ) {
?>
<tr>
<td style="background: #333; color: #fff;" colspan="5"><?php _e( 'WordPress PLUGINS', 'mainwp-child' ); ?></td>
</tr>
<?php
$all_plugins = get_plugins();
foreach ( $all_plugins as $slug => $plugin ) {
if ( 'mainwp-child/mainwp-child.php' == $slug || 'mainwp-child-reports/mainwp-child-reports.php' == $slug ) {
if ( $isBranding ) {
if ( 'mainwp-child/mainwp-child.php' == $slug ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
} elseif ( 'mainwp-child-reports/mainwp-child-reports.php' == $slug ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports';
}
foreach ( $all_plugins as $slug => $plugin ) {
if ( ! empty( $branding_title ) && ( 'mainwp-child/mainwp-child.php' == $slug || 'mainwp-child-reports/mainwp-child-reports.php' == $slug ) ) {
if ( 'mainwp-child/mainwp-child.php' == $slug ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) );
} elseif ( 'mainwp-child-reports/mainwp-child-reports.php' == $slug ) {
$plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports';
}
}
?>

View file

@ -423,7 +423,7 @@ class MainWP_Helper {
return true;
}
public 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 ) {
@ -447,7 +447,7 @@ class MainWP_Helper {
return true;
}
public 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();