Merge with branch01

This commit is contained in:
ruben- 2017-07-11 14:10:22 +02:00
parent 57b229fe3d
commit 0335237fe2
8 changed files with 456 additions and 238 deletions

View file

@ -75,7 +75,7 @@ class MainWP_Child_Back_WP_Up {
return;
}
error_reporting( 0 );
function mainwp_backwpup_handle_fatal_error() {
$error = error_get_last();
@ -96,7 +96,7 @@ class MainWP_Child_Back_WP_Up {
if ( ! isset( $_POST['action'] ) ) {
$information = array( 'error' => __( 'Missing action.', $this->plugin_translate ) );
} else {
MainWP_Helper::update_option( 'mainwp_backwpup_ext_enabled', 'Y' );
MainWP_Helper::update_option( 'mainwp_backwpup_ext_enabled', 'Y' );
switch ( $_POST['action'] ) {
case 'backwpup_update_settings':
$information = $this->update_settings();
@ -179,15 +179,15 @@ class MainWP_Child_Back_WP_Up {
exit();
}
public function init() {
public function init() {
if ( get_option( 'mainwp_backwpup_ext_enabled' ) !== 'Y' ) {
return;
}
if (!$this->is_backwpup_installed)
return;
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
if (!$this->is_backwpup_installed)
return;
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
if ( get_option( 'mainwp_backwpup_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
@ -195,53 +195,53 @@ class MainWP_Child_Back_WP_Up {
}
}
function do_site_stats() {
if (has_action('mainwp_child_reports_log')) {
do_action( 'mainwp_child_reports_log', 'backwpup');
} else {
$this->do_reports_log('backwpup');
}
}
public function do_reports_log($ext = '') {
if ( $ext !== 'backwpup' ) return;
if (!$this->is_backwpup_installed)
return;
function do_site_stats() {
if (has_action('mainwp_child_reports_log')) {
do_action( 'mainwp_child_reports_log', 'backwpup');
} else {
$this->do_reports_log('backwpup');
}
}
$destinations = BackWPup::get_registered_destinations();
$jobdests = $this->get_destinations_list();
public function do_reports_log($ext = '') {
if ( $ext !== 'backwpup' ) return;
if (!$this->is_backwpup_installed)
return;
if ( !empty( $jobdests ) ) {
foreach ($jobdests as $jobdest) {
list( $jobid, $dest ) = explode( '_', $jobdest );
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
$dest_object = BackWPup::get_destination( $dest );
$items = $dest_object->file_get_list( $jobdest );
//if no items brake
if ( $items ) {
foreach ( $items as $ma ) {
if (isset($ma['time'])) {
$backup_time = $ma[ "time" ];
$message = 'BackWPup backup finished';
$backup_type = 'BackWPup';
$destination = "N/A";
if (!empty($backup_time)) {
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
MainWP_Helper::update_lasttime_backup( 'backwpup', $backup_time ); // to support backup before update feature
}
}
}
}
}
}
}
}
$destinations = BackWPup::get_registered_destinations();
$jobdests = $this->get_destinations_list();
function get_destinations_list() {
if ( !empty( $jobdests ) ) {
foreach ($jobdests as $jobdest) {
list( $jobid, $dest ) = explode( '_', $jobdest );
if ( ! empty( $destinations[ $dest ][ 'class' ] ) ) {
$dest_object = BackWPup::get_destination( $dest );
$items = $dest_object->file_get_list( $jobdest );
//if no items brake
if ( $items ) {
foreach ( $items as $ma ) {
if (isset($ma['time'])) {
$backup_time = $ma[ "time" ];
$message = 'BackWPup backup finished';
$backup_type = 'BackWPup';
$destination = "N/A";
if (!empty($backup_time)) {
do_action( 'mainwp_backwpup_backup', $message, $backup_type, $backup_time );
MainWP_Helper::update_lasttime_backup( 'backwpup', $backup_time ); // to support backup before update feature
}
}
}
}
}
}
}
}
function get_destinations_list() {
$jobdest = array();
$jobids = BackWPup_Option::get_job_ids();
$destinations = BackWPup::get_registered_destinations();
$destinations = BackWPup::get_registered_destinations();
foreach ( $jobids as $jobid ) {
if ( BackWPup_Option::get( $jobid, 'backuptype' ) === 'sync' ) {
continue;
@ -261,7 +261,7 @@ class MainWP_Child_Back_WP_Up {
return $jobdest;
}
public function all_plugins( $plugins ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename( $key, '.php' );
@ -290,10 +290,10 @@ class MainWP_Child_Back_WP_Up {
}
protected function show_hide() {
$hide = isset( $_POST['show_hide'] ) && ( '1' === $_POST['show_hide'] ) ? 'hide' : '';
MainWP_Helper::update_option( 'mainwp_backwpup_hide_plugin', $hide );
MainWP_Helper::update_option( 'mainwp_backwpup_hide_plugin', $hide, 'yes' );
return array( 'success' => 1 );
}
@ -1060,9 +1060,9 @@ class MainWP_Child_Back_WP_Up {
$return['tables'] = $tables_temp;
}
if (isset($settings['job_id'])) {
$return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' );
$return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' );
}
return array( 'success' => 1, 'return' => $return );
}
@ -1135,7 +1135,68 @@ class MainWP_Child_Back_WP_Up {
);
}
// From BackWPup_JobType_File::edit_form_post_save with some tweaks
public function edit_form_post_save( $post_data, $id ) {
// Parse and save files to exclude
$exclude_input = $post_data['fileexclude'];
$to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array();
$to_exclude_list and $to_exclude_list = sanitize_text_field( stripslashes( $to_exclude_list ) );
$to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array();
$to_exclude_parsed = array();
foreach ( $to_exclude as $key => $value ) {
$normalized = wp_normalize_path( trim( $value ) );
$normalized and $to_exclude_parsed[$key] = $normalized;
}
sort( $to_exclude_parsed );
BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) );
unset( $exclude_input, $to_exclude_list, $to_exclude, $to_exclude_parsed, $normalized );
// Parse and save folders to include
$include_input = $post_data['dirinclude'];
$include_list = $include_input ? str_replace( array( "\r\n", "\r" ), ',', $include_input ) : array();
$to_include = $include_list ? explode( ',', $include_list ) : array();
$to_include_parsed = array();
foreach ( $to_include as $key => $value ) {
$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;
}
sort( $to_include_parsed );
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
unset( $include_input, $include_list, $to_include, $to_include_parsed, $normalized, $realpath );
// Parse and save boolean fields
$boolean_fields_def = array(
'backupexcludethumbs' => FILTER_VALIDATE_BOOLEAN,
'backupspecialfiles' => FILTER_VALIDATE_BOOLEAN,
'backuproot' => FILTER_VALIDATE_BOOLEAN,
'backupabsfolderup' => FILTER_VALIDATE_BOOLEAN,
'backupcontent' => FILTER_VALIDATE_BOOLEAN,
'backupplugins' => FILTER_VALIDATE_BOOLEAN,
'backupthemes' => FILTER_VALIDATE_BOOLEAN,
'backupuploads' => FILTER_VALIDATE_BOOLEAN,
);
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 ),
);
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 );
}
}
protected function insert_or_update_jobs() {
$settings = $_POST['settings'];
if ( ! is_array( $settings ) || ! isset( $settings['value'] ) ) {
@ -1165,18 +1226,29 @@ 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)) {
$settings['value']['backupdir'] = $backupdir;
}
}
if (isset($settings['value']['backupdir']) && empty($settings['value']['backupdir'])) {
$backupdir = BackWPup_Option::get( (int)$job_id, 'backupdir' );
if (!empty($backupdir)) {
$settings['value']['backupdir'] = $backupdir;
}
}
foreach ( $settings['value'] as $key => $val ) {
$_POST[ $key ] = $val;
}
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
if ($settings['tab'] == 'jobtype-FILE') {
// to fix
$this->edit_form_post_save($settings['value'], $job_id);
//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 {
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
}
$return = $this->check_backwpup_messages();

View file

@ -38,7 +38,7 @@ class MainWP_Child_Branding {
if ( ! self::is_branding() ) {
return $plugin_meta;
}
// hide View details links
// hide View details links
$meta_total = count( $plugin_meta );
for ( $i = 0; $i < $meta_total; $i++ ) {
$str_meta = $plugin_meta[ $i ];
@ -107,17 +107,17 @@ class MainWP_Child_Branding {
'authoruri' => $settings['child_plugin_author_uri'],
'pluginuri' => $settings['child_plugin_uri'],
);
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'] );
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' );
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' );
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'] );
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'] );
MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'] );
MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'] );
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'] );
@ -210,7 +210,7 @@ class MainWP_Child_Branding {
MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
if ( $settings['child_plugin_hide'] ) {
MainWP_Helper::update_option( 'mainwp_branding_child_hide', 'T' );
MainWP_Helper::update_option( 'mainwp_branding_child_hide', 'T', 'yes' );
} else {
MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
}
@ -275,9 +275,9 @@ class MainWP_Child_Branding {
// enable branding in case child plugin is deactive
add_filter( 'all_plugins', array( $this, 'branding_child_plugin' ) );
if ( self::is_branding() ) {
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
}
if ( self::is_branding() ) {
add_filter( 'site_transient_update_plugins', array( &$this, 'remove_update_nag' ) );
}
if ( get_option( 'mainwp_branding_ext_enabled' ) !== 'Y' ) {
return;
@ -285,24 +285,26 @@ class MainWP_Child_Branding {
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
$title = $this->settings['contact_support_label'];
if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
$title = $this->settings['contact_support_label'];
add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
$this,
'contact_support',
), '', '2.0001' );
}
if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
$this,
'contact_support',
) );
add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
}
}
// to fix
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
// if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
// $title = $this->settings['contact_support_label'];
// if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
// $title = $this->settings['contact_support_label'];
// add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
// $this,
// 'contact_support',
// ), '', '2.0001' );
// }
//
// if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
// add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
// $this,
// 'contact_support',
// ) );
// add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
// }
// }
if ( get_option( 'mainwp_branding_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 );
@ -330,6 +332,33 @@ class MainWP_Child_Branding {
}
}
// to fix conflict with other plugin
function admin_menu() {
$extra_setting = $this->settings['extra_settings'];
if ( ! is_array( $extra_setting ) ) {
$extra_setting = array();
}
if ( 'T' === get_option( 'mainwp_branding_show_support' ) ) {
$title = $this->settings['contact_support_label'];
if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
$title = $this->settings['contact_support_label'];
add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
$this,
'contact_support',
), '', '2.0001' );
}
if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
add_submenu_page( null, $title, $this->settings['contact_support_label'], 'read', 'ContactSupport', array(
$this,
'contact_support',
) );
add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
}
}
}
function remove_default_post_metaboxes() {
$extra_setting = $this->settings['extra_settings'];
if ( ! is_array( $extra_setting ) ) {
@ -615,7 +644,7 @@ class MainWP_Child_Branding {
}
function contact_support() {
if ( current_user_can( 'subscriber' ) ) {
if ( !current_user_can('administrator') ) {
return false;
}
?>
@ -710,7 +739,7 @@ class MainWP_Child_Branding {
* @param WP_Admin_Bar $wp_admin_bar
*/
public function add_support_button_in_top_admin_bar( $wp_admin_bar ) {
if ( current_user_can( 'subscriber' ) ) {
if ( !current_user_can( 'administrator' ) ) {
return false;
}
@ -800,7 +829,7 @@ class MainWP_Child_Branding {
}
}
function remove_update_nag( $value ) {
function remove_update_nag( $value ) {
if ( isset( $_POST['mainwpsignature'] ) ) {
return $value;
}

View file

@ -3,9 +3,9 @@
class MainWP_Child_Pagespeed {
public static $instance = null;
public $is_plugin_installed = false;
public $is_plugin_installed = false;
static function Instance() {
static function Instance() {
if ( null === MainWP_Child_Pagespeed::$instance ) {
MainWP_Child_Pagespeed::$instance = new MainWP_Child_Pagespeed();
}
@ -14,9 +14,9 @@ class MainWP_Child_Pagespeed {
}
public function __construct() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) {
$this->is_plugin_installed = true;
$this->is_plugin_installed = true;
}
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
@ -24,8 +24,8 @@ class MainWP_Child_Pagespeed {
public function action() {
$information = array();
if ( ! defined( 'GPI_ACTIVE' ) ) {
$information['error'] = 'NO_GOOGLEPAGESPEED';
if ( ! defined( 'GPI_DIRECTORY' ) ) {
$information['error'] = 'Please install Google Pagespeed Insights plugin on child website';
MainWP_Helper::write( $information );
}
if ( isset( $_POST['mwp_action'] ) ) {
@ -61,8 +61,8 @@ class MainWP_Child_Pagespeed {
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
//add_action('admin_menu', array($this, 'hide_menu'), 999);
add_filter( 'update_footer', array( &$this, 'update_footer' ), 15 );
add_action('admin_menu', array($this, 'hide_menu'), 999);
//add_filter( 'update_footer', array( &$this, 'update_footer' ), 15 );
}
$this->init_cron();
}
@ -104,17 +104,18 @@ class MainWP_Child_Pagespeed {
return $plugins;
}
// public function hide_menu() {
// global $submenu;
// if (isset($submenu['tools.php'])) {
// foreach($submenu['tools.php'] as $key => $menu) {
// if ($menu[2] == 'google-pagespeed-insights') {
// unset($submenu['tools.php'][$key]);
// break;
// }
// }
// }
// }
public function hide_menu() {
global $submenu;
if (isset($submenu['tools.php'])) {
foreach($submenu['tools.php'] as $key => $menu) {
if ($menu[2] == 'google-pagespeed-insights') {
unset($submenu['tools.php'][$key]);
break;
}
}
}
}
function update_footer( $text ) {
?>
@ -138,10 +139,8 @@ class MainWP_Child_Pagespeed {
function save_settings() {
$current_values = get_option( 'gpagespeedi_options' );
require_once GPI_DIRECTORY . '/core/core.php';
$googlePagespeedInsights = new googlePagespeedInsights( $current_values );
$worker_status = $googlePagespeedInsights->google_pagespeed_insights_Check_Status();
if ( $worker_status ) {
$checkstatus = apply_filters( 'gpi_check_status', false );
if ( $checkstatus ) {
return array( 'result' => 'RUNNING' );
}
@ -166,6 +165,14 @@ class MainWP_Child_Pagespeed {
$current_values['max_execution_time'] = $settings['max_execution_time'];
}
if ( isset( $settings['max_run_time'] ) ) {
$current_values['max_run_time'] = $settings['max_run_time'];
}
if ( isset( $settings['heartbeat'] ) ) {
$current_values['heartbeat'] = $settings['heartbeat'];
}
if ( isset( $settings['delay_time'] ) ) {
$current_values['sleep_time'] = $settings['delay_time'];
}
@ -229,24 +236,25 @@ class MainWP_Child_Pagespeed {
} else {
$recheck = false;
}
$information = array();
$information['result'] = 'SUCCESS';
if ($this->do_check_pages($recheck))
$information['checked_pages'] = 1;
$information = $this->do_check_pages($recheck);
if (isset($information['checked_pages']) && $information['checked_pages']) {
$information['result'] = 'SUCCESS';
}
return $information;
}
function do_check_pages($forceRecheck = false) {
$information = array();
if ( defined( 'GPI_DIRECTORY' ) ) {
$options = get_option( 'gpagespeedi_options' );
require_once GPI_DIRECTORY . '/core/core.php';
$googlePagespeedInsights = new googlePagespeedInsights( $options );
if ( $googlePagespeedInsights ) {
$googlePagespeedInsights->googlepagespeedinsightsworker( array(), true, $forceRecheck );
return true;
$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(), true );
$information['checked_pages'] = 1;
}
}
return false;
return $information;
}
public function sync_data( $strategy = '' ) {
@ -255,10 +263,8 @@ class MainWP_Child_Pagespeed {
}
$current_values = get_option( 'gpagespeedi_options' );
require_once GPI_DIRECTORY . '/core/core.php';
$googlePagespeedInsights = new googlePagespeedInsights( $current_values );
$worker_status = $googlePagespeedInsights->google_pagespeed_insights_Check_Status();
if ( $worker_status ) {
$checkstatus = apply_filters( 'gpi_check_status', false );
if ( $checkstatus ) {
return array( 'result' => 'RUNNING' );
}
@ -294,17 +300,11 @@ class MainWP_Child_Pagespeed {
return 0;
}
require_once( GPI_DIRECTORY . '/includes/helper.php' );
$options = get_option( 'gpagespeedi_options' );
$score_column = $strategy . '_score';
$page_stats_column = $strategy . '_page_stats';
require_once( ABSPATH . 'wp-admin/includes/template.php' );
require_once( GPI_DIRECTORY . '/core/init.php' );
$GPI_ListTable = new GPI_List_Table();
$data_typestocheck = $GPI_ListTable->getTypesToCheck( 'all' );
$data_typestocheck = self::getTypesToCheck( 'all' );
$gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';
if ( ! empty( $data_typestocheck ) ) {
@ -312,8 +312,8 @@ class MainWP_Child_Pagespeed {
$allpagedata = $wpdb->get_results(
$wpdb->prepare(
"SELECT ID, URL, $score_column, $page_stats_column
FROM $gpi_page_stats
WHERE ($data_typestocheck[0])",
FROM $gpi_page_stats
WHERE ($data_typestocheck[0])",
$data_typestocheck[1]
),
ARRAY_A
@ -322,7 +322,7 @@ class MainWP_Child_Pagespeed {
$allpagedata = array();
}
$reports_typestocheck = $GPI_ListTable->getTypesToCheck( 'all' );
$reports_typestocheck = self::getTypesToCheck( 'all' );
$gpi_page_reports = $wpdb->prefix . 'gpi_page_reports';
if ( ! empty( $reports_typestocheck ) ) {
@ -398,6 +398,87 @@ class MainWP_Child_Pagespeed {
);
}
static function getTypesToCheck($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') {
$typestocheck[] = 'type = %s';
$types[1][] = "page";
}
}
if($gpi_options['check_posts']) {
if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') {
$typestocheck[] = 'type = %s';
$types[1][] = "post";
}
}
if($gpi_options['check_categories']) {
if($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') {
$typestocheck[] = 'type = %s';
$types[1][] = "category";
}
}
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'])) {
$cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']);
}
$args=array(
'public' => true,
'_builtin' => false
);
$custom_post_types = get_post_types($args,'names','and');
if($restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored') {
$restrict_type = str_replace('gpi_custom_posts-', '', $restrict_type);
foreach($custom_post_types as $post_type)
{
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];
}
}
}
} else {
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];
}
}
}
}
}
if(!empty($typestocheck)) {
$types[0] = '';
foreach($typestocheck as $type)
{
if(!is_array($type)) {
$types[0] .= $type . ' OR ';
} else {
foreach($type as $custom_post_type)
{
$types[0] .= 'type = %s OR ';
$types[1][] = $custom_post_type;
}
}
}
$types[0] = rtrim($types[0], ' OR ');
return $types;
}
return null;
}
function delete_data( $what ) {
global $wpdb;
$gpi_page_stats = $wpdb->prefix . 'gpi_page_stats';

View file

@ -16,10 +16,7 @@ class MainWP_Child_Vulnerability_Checker {
}
public function action() {
$information = array();
if (get_option( 'mainwp_vulnerability_ext_enabled' ) !== 'Y')
MainWP_Helper::update_option( 'mainwp_vulnerability_ext_enabled', 'Y' );
$information = array();
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'vulner_recheck':

View file

@ -145,6 +145,9 @@ class MainWP_Child_WP_Rocket {
case 'get_optimize_info':
$information = $this->get_optimize_info();
break;
case 'purge_opcache':
$information = $this->do_admin_post_rocket_purge_opcache();
break;
}
}
MainWP_Helper::write( $information );
@ -158,6 +161,15 @@ class MainWP_Child_WP_Rocket {
return $information;
}
function do_admin_post_rocket_purge_opcache() {
if ( function_exists( 'opcache_reset' ) ) {
@opcache_reset();
} else {
return array('error' => 'The host do not support the function reset opcache.');
}
return array('result' => 'SUCCESS');
}
function purge_cloudflare() {
if ( function_exists( 'rocket_purge_cloudflare' ) ) {
// Purge CloudFlare
@ -257,70 +269,74 @@ class MainWP_Child_WP_Rocket {
}
function get_rocket_default_options() {
return array(
// 'secret_cache_key' => $secret_cache_key,
'cache_mobile' => 0,
'do_caching_mobile_files' => 0,
'cache_feed' => 0,
'cache_logged_user' => 0,
'cache_ssl' => 0,
'emoji' => 0,
'varnish_auto_purge' => 0,
'manual_preload' => 0,
'automatic_preload' => 0,
'sitemap_preload' => 0,
'sitemap_preload_url_crawl' => 500000,
'sitemaps' => '',
'database_revisions' => 0,
'database_auto_drafts' => 0,
'database_trashed_posts' => 0,
'database_spam_comments' => 0,
'database_trashed_comments' => 0,
'database_expired_transients' => 0,
'database_all_transients' => 0,
'database_optimize_tables' => 0,
'schedule_automatic_cleanup' => 0,
'automatic_cleanup_frequency' => 'daily',
'cache_reject_uri' => array(),
'cache_reject_cookies' => array(),
'cache_reject_ua' => array(),
'cache_query_strings' => array(),
'cache_purge_pages' => array(),
'purge_cron_interval' => 24,
'purge_cron_unit' => 'HOUR_IN_SECONDS',
'exclude_css' => array(),
'exclude_js' => array(),
'deferred_js_files' => array(),
'deferred_js_wait' => array(),
'lazyload' => 0,
'lazyload_iframes' => 0,
'minify_css' => 0,
// 'minify_css_key' => $minify_css_key,
'minify_css_combine_all' => 0,
'minify_js' => 0,
// 'minify_js_key' => $minify_js_key,
'minify_js_in_footer' => array(),
'minify_js_combine_all' => 0,
'minify_google_fonts' => 0,
'minify_html' => 0,
'minify_html_inline_css' => 0,
'minify_html_inline_js' => 0,
'remove_query_strings' => 0,
'dns_prefetch' => 0,
'cdn' => 0,
'cdn_cnames' => array(),
'cdn_zone' => array(),
'cdn_ssl' => 0,
'cdn_reject_files' => array(),
'do_cloudflare' => 0,
'cloudflare_email' => '',
'cloudflare_api_key' => '',
'cloudflare_domain' => '',
'cloudflare_devmode' => 0,
'cloudflare_auto_settings' => 0,
'cloudflare_old_settings' => 0,
'do_beta' => 0,
);
return array(
'cache_mobile' => 1,
'do_caching_mobile_files' => 0,
'cache_logged_user' => 0,
'cache_ssl' => 0,
'emoji' => 0,
'embeds' => 1,
'varnish_auto_purge' => 0,
'manual_preload' => 0,
'automatic_preload' => 0,
'sitemap_preload' => 0,
'sitemap_preload_url_crawl' => 500000,
'sitemaps' => array(),
'database_revisions' => 0,
'database_auto_drafts' => 0,
'database_trashed_posts' => 0,
'database_spam_comments' => 0,
'database_trashed_comments' => 0,
'database_expired_transients' => 0,
'database_all_transients' => 0,
'database_optimize_tables' => 0,
'schedule_automatic_cleanup' => 0,
'automatic_cleanup_frequency' => '',
'cache_reject_uri' => array(),
'cache_reject_cookies' => array(),
'cache_reject_ua' => array(),
'cache_query_strings' => array(),
'cache_purge_pages' => array(),
'purge_cron_interval' => 10,
'purge_cron_unit' => 'HOUR_IN_SECONDS',
'exclude_css' => array(),
'exclude_js' => array(),
'defer_all_js' => 0,
'critical_css' => '',
'deferred_js_files' => array(),
'lazyload' => 0,
'lazyload_iframes' => 0,
'minify_css' => 0,
// 'minify_css_key' => $minify_css_key,
'minify_concatenate_css' => 0,
'minify_css_combine_all' => 0,
'minify_css_legacy' => 0,
'minify_js' => 0,
// 'minify_js_key' => $minify_js_key,
'minify_js_in_footer' => array(),
'minify_concatenate_js' => 0,
'minify_js_combine_all' => 0,
//'minify_js_legacy' => 0,
'minify_google_fonts' => 0,
'minify_html' => 0,
'remove_query_strings' => 0,
'dns_prefetch' => 0,
'cdn' => 0,
'cdn_cnames' => array(),
'cdn_zone' => array(),
'cdn_ssl' => 0,
'cdn_reject_files' => array(),
'do_cloudflare' => 0,
'cloudflare_email' => '',
'cloudflare_api_key' => '',
'cloudflare_domain' => '',
//'cloudflare_zone_id' => '',
'cloudflare_devmode' => 0,
'cloudflare_protocol_rewrite' => 0,
'cloudflare_auto_settings' => 0,
'cloudflare_old_settings' => 0,
'do_beta' => 0,
);
}
}

View file

@ -84,7 +84,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
}
class MainWP_Child {
public static $version = '3.4';
public static $version = '3.4.2';
private $update_version = '1.3';
private $callableFunctions = array(
@ -1782,21 +1782,31 @@ class MainWP_Child {
if ( count( $plugins ) > 0 ) {
//@see wp-admin/update.php
$failed = true;
// to fix logging update
foreach($plugins as $plugin) {
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$result = $upgrader->bulk_upgrade( array($plugin) );
if ( ! empty( $result ) ) {
foreach ( $result as $plugin => $info ) {
if ( empty( $info ) ) {
$information['upgrades'][ $plugin ] = false;
} else {
$information['upgrades'][ $plugin ] = true;
$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$result = $upgrader->bulk_upgrade( $plugins );
if ( ! empty( $result ) ) {
foreach ( $result as $plugin => $info ) {
if ( empty( $info ) ) {
$information['upgrades'][ $plugin ] = false;
} else {
$information['upgrades'][ $plugin ] = true;
// to fix logging update
if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) {
$plugin_info = $information['plugin_updates'][$plugin];
$args = array();
$args['type'] = 'plugin';
$args['name'] = $plugin_info->Name;
$args['version'] = $plugin_info->update->new_version;
$args['old_version'] = $plugin_info->Version;
$args['action'] = 'update';
do_action( 'mainwp_child_upgradePluginTheme', $args );
}
}
$failed = false;
}
$failed = false;
}
if ($failed) {
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
}
@ -1877,21 +1887,32 @@ class MainWP_Child {
// @wp_update_themes();
$failed = true;
// to fix logging update
foreach($themes as $theme) {
$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$result = $upgrader->bulk_upgrade( array($theme) );
if ( ! empty( $result ) ) {
foreach ( $result as $theme => $info ) {
if ( empty( $info ) ) {
$information['upgrades'][ $theme ] = false;
} else {
$information['upgrades'][ $theme ] = true;
$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
$result = $upgrader->bulk_upgrade( $themes );
if ( ! empty( $result ) ) {
foreach ( $result as $theme => $info ) {
if ( empty( $info ) ) {
$information['upgrades'][ $theme ] = false;
} else {
$information['upgrades'][ $theme ] = true;
// to fix logging update
if (isset($information['theme_updates']) && isset($information['theme_updates'][$theme])) {
$theme_info = $information['theme_updates'][$theme];
$args = array();
$args['type'] = 'theme';
$args['slug'] = $theme;
$args['name'] = $theme_info['Name'];
$args['version'] = $theme_info['update']['new_version'];
$args['old_version'] = $theme_info['Version'];
$args['action'] = 'update';
do_action( 'mainwp_child_upgradePluginTheme', $args );
}
}
$failed = false;
}
$failed = false;
}
if ($failed) {
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
}
@ -4336,7 +4357,7 @@ class MainWP_Child {
$out['slug'] = $pluginslug;
$out['description'] = $plugin['Description'];
$out['version'] = $plugin['Version'];
$out['active'] = ( is_array( $active_plugins ) && in_array( $pluginslug, $active_plugins ) ) ? 1 : 0;
$out['active'] = is_plugin_active($pluginslug) ? 1 : 0; // ( is_array( $active_plugins ) && in_array( $pluginslug, $active_plugins ) ) ? 1 : 0; // to fix for multisites
if ( ! $filter ) {
if ( '' == $keyword || stristr( $out['name'], $keyword ) ) {
$rslt[] = $out;
@ -4551,6 +4572,7 @@ class MainWP_Child {
foreach ( $to_delete as $delete ) {
if ( get_option( $delete ) ) {
delete_option( $delete );
wp_cache_delete( $delete, 'options' );
}
}
do_action( 'mainwp_child_deactivation' );

View file

@ -220,7 +220,7 @@ class MainWP_Clone {
<br/>
<br/>
<form
action="<?php echo esc_attr( admin_url( 'admin.php?page=' . ( 0 !== $sitesToClone ? 'MainWP_Clone' : 'MainWPRestore' ) . '&upload=yes' ) ); ?>"
action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
method="post"
enctype="multipart/form-data">
<input type="file" name="file" id="file"/>
@ -314,7 +314,7 @@ class MainWP_Clone {
?>
<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( 'admin.php?page=MainWPRestore&upload=yes' ) ); ?>"
<form action="<?php echo esc_attr( admin_url( 'options-general.php?page=mainwp_child_tab&tab=restore-clone&upload=yes' ) ); ?>"
method="post"
enctype="multipart/form-data">
<input type="file" name="file" id="file"/>
@ -326,10 +326,11 @@ class MainWP_Clone {
value="<?php esc_html_e( 'Restore Website', 'mainwp-child' ); ?>"/>
<input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( 'cloneRestore' ); ?>" />
</form>
<?php } ?>
</div>
</div>
<?php
}
self::renderCloneFromServer();
self::renderJavaScript();
}

View file

@ -6,7 +6,7 @@
Author: MainWP
Author URI: https://mainwp.com
Text Domain: mainwp-child
Version: 3.4
Version: 3.4.2-alpha
*/
if ( ( isset( $_REQUEST['heatmap'] ) && '1' === $_REQUEST['heatmap'] ) || ( isset( $_REQUEST['mainwpsignature'] ) && ( ! empty( $_REQUEST['mainwpsignature'] ) ) ) ) {
header( 'X-Frame-Options: ALLOWALL' );