Plugin Directory

Changeset 2182172


Ignore:
Timestamp:
10/29/2019 10:15:50 AM (6 years ago)
Author:
wpvivid
Message:

update for 0.9.27

Location:
wpvivid-backuprestore/trunk
Files:
4 added
24 edited

Legend:

Unmodified
Added
Removed
  • wpvivid-backuprestore/trunk/admin/class-wpvivid-admin.php

    r2172717 r2182172  
    6161        add_filter('wpvivid_get_toolbar_menus',array($this,'get_toolbar_menus'),10);
    6262        add_filter('wpvivid_get_admin_menus',array($this,'get_admin_menus'),10);
     63
     64        add_action('wpvivid_before_setup_page',array($this,'migrate_notice'));
     65        add_action('wpvivid_before_setup_page',array($this,'show_add_my_review'));
     66        add_action('wpvivid_before_setup_page',array($this,'check_extensions'));
     67        add_action('wpvivid_before_setup_page',array($this,'check_amazons3'));
     68        add_action('wpvivid_before_setup_page',array($this,'init_js_var'));
     69
    6370        $this->plugin_name = $plugin_name;
    6471        $this->version = $version;
     
    95102        $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    96103
    97         $menu['id']='wpvivid_admin_menu_schedule';
    98         $menu['parent']='wpvivid_admin_menu';
    99         $menu['title']='Schedule';
    100         $menu['tab']='admin.php?page=WPvivid&tab-schedule';
    101         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-schedule';
    102         $menu['index']=2;
    103         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    104 
    105         $menu['id']='wpvivid_admin_menu_transfer';
    106         $menu['parent']='wpvivid_admin_menu';
    107         $menu['title']='Auto-Migration';
    108         $menu['tab']='admin.php?page=WPvivid&tab-transfer';
    109         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-transfer';
    110         $menu['index']=3;
    111         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    112 
    113         $menu['id']='wpvivid_admin_menu_remote';
    114         $menu['parent']='wpvivid_admin_menu';
    115         $menu['title']='Remote Storage';
    116         $menu['tab']='admin.php?page=WPvivid&tab-remote-storage';
    117         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-remote-storage';
    118         $menu['index']=4;
    119         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    120 
    121         $menu['id']='wpvivid_admin_menu_settings';
    122         $menu['parent']='wpvivid_admin_menu';
    123         $menu['title']='Settings';
    124         $menu['tab']= 'admin.php?page=WPvivid&tab-settings';
    125         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-settings';
    126         $menu['index']=5;
    127         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    128 
    129         $menu['id']='wpvivid_admin_menu_debug';
    130         $menu['parent']='wpvivid_admin_menu';
    131         $menu['title']='Debug';
    132         $menu['tab']= 'admin.php?page=WPvivid&tab-website-info';
    133         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-website-info';
    134         $menu['index']=6;
    135         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    136 
    137         $menu['id']='wpvivid_admin_menu_logs';
    138         $menu['parent']='wpvivid_admin_menu';
    139         $menu['title']='Logs';
    140         $menu['tab']='admin.php?page=WPvivid&tab-logs';
    141         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-logs';
    142         $menu['index']=7;
    143         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    144 
    145         $menu['id']='wpvivid_admin_menu_key';
    146         $menu['parent']='wpvivid_admin_menu';
    147         $menu['title']='Key';
    148         $menu['tab']= 'admin.php?page=WPvivid&tab-key';
    149         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-key';
    150         $menu['index']=8;
    151         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    152 
    153         $menu['id']='wpvivid_admin_menu_mwp';
    154         $menu['parent']='wpvivid_admin_menu';
    155         $menu['title']='MainWP';
    156         $menu['tab']= 'admin.php?page=WPvivid&tab-mainwp';
    157         $menu['href']=$admin_url . 'admin.php?page=WPvivid&tab-mainwp';
    158         $menu['index']=30;
    159         $toolbar_menus[$menu['parent']]['child'][$menu['id']]=$menu;
    160 
    161104        return $toolbar_menus;
    162105    }
     
    165108    {
    166109        $submenu['parent_slug']=$this->plugin_name;
    167         $submenu['page_title']= __('WPvivid Backup');
     110        $submenu['page_title']=__('WPvivid Backup');
    168111        $submenu['menu_title']=__('Backup & Restore', 'wpvivid');
    169112        $submenu['capability']='administrator';
    170113        $submenu['menu_slug']=$this->plugin_name;
    171         $submenu['function']=array($this, 'display_plugin_backup_page');
     114        $submenu['function']=array($this, 'display_plugin_setup_page');
    172115        $submenu['index']=1;
    173116        $submenus[$submenu['menu_slug']]=$submenu;
    174117
    175118        $submenu['parent_slug']=$this->plugin_name;
    176         $submenu['page_title']= __('WPvivid Backup');
    177         $submenu['menu_title']=__('Schedule', 'wpvivid');
    178         $submenu['capability']='administrator';
    179         $submenu['menu_slug']='wpvivid-schedule';
    180         $submenu['function']=array($this, 'display_plugin_schedule_page');
    181         $submenu['index']=2;
    182         $submenus[$submenu['menu_slug']]=$submenu;
    183 
    184         $submenu['parent_slug']=$this->plugin_name;
    185         $submenu['page_title']= __('WPvivid Backup');
    186         $submenu['menu_title']=__('Auto-Migration', 'wpvivid');
    187         $submenu['capability']='administrator';
    188         $submenu['menu_slug']='wpvivid-transfer';
    189         $submenu['function']=array($this, 'display_plugin_transfer_page');
    190         $submenu['index']=3;
    191         $submenus[$submenu['menu_slug']]=$submenu;
    192 
    193         $submenu['parent_slug']=$this->plugin_name;
    194         $submenu['page_title']= __('WPvivid Backup');
    195         $submenu['menu_title']=__('Remote Storage', 'wpvivid');
    196         $submenu['capability']='administrator';
    197         $submenu['menu_slug']='wpvivid-remote';
    198         $submenu['function']=array($this, 'display_plugin_remote_page');
    199         $submenu['index']=4;
    200         $submenus[$submenu['menu_slug']]=$submenu;
    201 
    202         $submenu['parent_slug']=$this->plugin_name;
    203         $submenu['page_title']= __('WPvivid Backup');
     119        $submenu['page_title']=__('WPvivid Backup');
    204120        $submenu['menu_title']=__('Settings', 'wpvivid');
    205121        $submenu['capability']='administrator';
    206122        $submenu['menu_slug']='wpvivid-setting';
    207         $submenu['function']=array($this, 'display_plugin_setting_page');
     123        $submenu['function']=array($this, 'display_plugin_setup_page');
    208124        $submenu['index']=5;
    209         $submenus[$submenu['menu_slug']]=$submenu;
    210 
    211         $submenu['parent_slug']=$this->plugin_name;
    212         $submenu['page_title']= __('WPvivid Backup');
    213         $submenu['menu_title']=__('Debug', 'wpvivid');
    214         $submenu['capability']='administrator';
    215         $submenu['menu_slug']='wpvivid-website';
    216         $submenu['function']=array($this, 'display_plugin_website_page');
    217         $submenu['index']=6;
    218         $submenus[$submenu['menu_slug']]=$submenu;
    219 
    220         $submenu['parent_slug']=$this->plugin_name;
    221         $submenu['page_title']= __('WPvivid Backup');
    222         $submenu['menu_title']=__('Logs', 'wpvivid');
    223         $submenu['capability']='administrator';
    224         $submenu['menu_slug']='wpvivid-log';
    225         $submenu['function']=array($this, 'display_plugin_log_page');
    226         $submenu['index']=7;
    227         $submenus[$submenu['menu_slug']]=$submenu;
    228 
    229         $submenu['parent_slug']=$this->plugin_name;
    230         $submenu['page_title']= __('WPvivid Backup');
    231         $submenu['menu_title']=__('Key', 'wpvivid');
    232         $submenu['capability']='administrator';
    233         $submenu['menu_slug']='wpvivid-key';
    234         $submenu['function']=array($this, 'display_plugin_key_page');
    235         $submenu['index']=8;
    236         $submenus[$submenu['menu_slug']]=$submenu;
    237 
    238         $submenu['parent_slug']=$this->plugin_name;
    239         $submenu['page_title']= __('WPvivid Backup');
    240         $submenu['menu_title']=__('MainWP', 'wpvivid');
    241         $submenu['capability']='administrator';
    242         $submenu['menu_slug']='wpvivid-mainwp';
    243         $submenu['function']=array($this, 'display_plugin_mainwp_page');
    244         $submenu['index']=30;
    245125        $submenus[$submenu['menu_slug']]=$submenu;
    246126
     
    260140        {
    261141            wp_enqueue_style($this->plugin_name, WPVIVID_PLUGIN_DIR_URL . 'css/wpvivid-admin.css', array(), $this->version, 'all');
     142            do_action('wpvivid_do_enqueue_styles');
    262143        }
    263144    }
     
    278159
    279160            wp_enqueue_script('plupload-all');
     161            do_action('wpvivid_do_enqueue_scripts');
    280162        }
    281163    }
     
    296178         *
    297179         */
    298         add_menu_page(__('WPvivid Backup'), __('WPvivid Backup'), 'administrator', $this->plugin_name, array($this, 'display_plugin_backup_page'), 'dashicons-cloud', 100);
    299         $general_setting=WPvivid_Setting::get_setting(true, "");
    300         if(!isset($general_setting['options']['wpvivid_common_setting']['show_tab_menu'])){
    301             $wpvivid_show_tab_menu=true;
    302         }
    303         else {
    304             if ($general_setting['options']['wpvivid_common_setting']['show_tab_menu']) {
    305                 $wpvivid_show_tab_menu=true;
    306             } else {
    307                 $wpvivid_show_tab_menu=false;
    308             }
    309         }
    310         if($wpvivid_show_tab_menu)
    311         {
    312             $this->submenus = apply_filters('wpvivid_get_admin_menus', $this->submenus);
    313 
    314             usort($this->submenus, function ($a, $b)
    315             {
    316                 if($a['index']==$b['index'])
    317                     return 0;
    318 
    319                 if($a['index']>$b['index'])
    320                     return 1;
    321                 else
    322                     return -1;
    323             });
    324 
    325             foreach ($this->submenus as $submenu)
    326             {
    327                 add_submenu_page(
    328                         $submenu['parent_slug'],
    329                         $submenu['page_title'],
    330                         $submenu['menu_title'],
    331                         $submenu['capability'],
    332                         $submenu['menu_slug'],
    333                         $submenu['function'], false, 100);
    334             }
     180        add_menu_page(__('WPvivid Backup'), __('WPvivid Backup'), 'administrator', $this->plugin_name, array($this, 'display_plugin_setup_page'), 'dashicons-cloud', 100);
     181
     182        $this->submenus = apply_filters('wpvivid_get_admin_menus', $this->submenus);
     183
     184        usort($this->submenus, function ($a, $b) {
     185            if ($a['index'] == $b['index'])
     186                return 0;
     187
     188            if ($a['index'] > $b['index'])
     189                return 1;
     190            else
     191                return -1;
     192        });
     193
     194        foreach ($this->submenus as $submenu) {
     195            add_submenu_page(
     196                $submenu['parent_slug'],
     197                $submenu['page_title'],
     198                $submenu['menu_title'],
     199                $submenu['capability'],
     200                $submenu['menu_slug'],
     201                $submenu['function'], false, 100);
    335202        }
    336203    }
     
    339206    {
    340207        global $wpvivid_plugin;
    341         if(is_admin() && current_user_can('administrator')) {
     208        if(is_admin() && current_user_can('administrator'))
     209        {
    342210            $show_admin_bar = $wpvivid_plugin->get_admin_bar_setting();
    343211            if ($show_admin_bar === true)
     
    376244    }
    377245
    378     public function add_action_links( $links ) {
     246    public function add_action_links( $links )
     247    {
    379248        $settings_link = array(
    380249            '<a href="' . admin_url( 'admin.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
     
    397266    public function display_plugin_setup_page()
    398267    {
    399         if(isset($_REQUEST['tab-backup']))
    400         {
    401             self::wpvivid_set_page_request('backup');
    402         }
    403         else if(isset($_REQUEST['tab-transfer'])){
    404             self::wpvivid_set_page_request('transfer');
    405         }
    406         else if(isset($_REQUEST['tab-settings'])){
    407             self::wpvivid_set_page_request('settings');
    408         }
    409         else if(isset($_REQUEST['tab-schedule'])){
    410             self::wpvivid_set_page_request('schedule');
    411         }
    412         else if(isset($_REQUEST['tab-remote-storage'])){
    413             self::wpvivid_set_page_request('remote');
    414         }
    415         else if(isset($_REQUEST['tab-website-info'])){
    416             self::wpvivid_set_page_request('website');
    417         }
    418         else if(isset($_REQUEST['tab-logs'])){
    419             self::wpvivid_set_page_request('log');
    420         }
    421         else if(isset($_REQUEST['tab-key'])){
    422             self::wpvivid_set_page_request('key');
    423         }
    424         else if(isset($_REQUEST['tab-mainwp'])){
    425             self::wpvivid_set_page_request('mainwp');
    426         }
    427         else
    428         {
    429             global $request_page;
    430             $request_page=apply_filters('wpvivid_set_page_request',$request_page);
    431         }
    432 
    433         global $wpvivid_plugin;
    434         $wpvivid_plugin->clean_cache();
    435 
    436         //
     268        do_action('wpvivid_before_setup_page');
     269
     270        add_action('wpvivid_display_page',array($this,'display'));
     271
     272        do_action('wpvivid_display_page');
     273    }
     274
     275    public function migrate_notice()
     276    {
    437277        $migrate_notice=false;
    438278        $migrate_status=WPvivid_Setting::get_option('wpvivid_migrate_status');
    439         if(!empty($migrate_status) && $migrate_status == 'completed'){
     279        if(!empty($migrate_status) && $migrate_status == 'completed')
     280        {
    440281            $migrate_notice=true;
    441282            _e('<div class="notice notice-warning is-dismissible"><p>Migration is complete and htaccess file is replaced. In order to successfully complete the migration, you\'d better reinstall 301 redirect plugin, firewall and security plugin, and caching plugin if they exist.</p></div>');
    442283            WPvivid_Setting::delete_option('wpvivid_migrate_status');
    443284        }
    444 
    445 
    446285        $restore = new WPvivid_restore_data();
    447         if ($restore->has_restore()) {
     286        if ($restore->has_restore())
     287        {
    448288            $restore_status = $restore->get_restore_status();
    449             if ($restore_status === WPVIVID_RESTORE_COMPLETED) {
     289            if ($restore_status === WPVIVID_RESTORE_COMPLETED)
     290            {
    450291                $restore->clean_restore_data();
    451292                $need_review=WPvivid_Setting::get_option('wpvivid_need_review');
     
    457298                }
    458299                else{
    459                     if(!$migrate_notice) {
     300                    if(!$migrate_notice)
     301                    {
    460302                        _e('<div class="notice notice-success is-dismissible"><p>Restore completed successfully.</p></div>');
    461303                    }
     
    463305            }
    464306        }
    465 
    466         $this->wpvivid_show_add_my_review();
    467         $this->wpvivid_check_extensions();
    468         $this->wpvivid_check_amazons3();
     307    }
     308
     309    public function display()
     310    {
     311        include_once('partials/wpvivid-admin-display.php');
     312    }
     313
     314    public static function wpvivid_get_page_request()
     315    {
     316        $request_page='wpvivid_tab_general';
     317
     318        if(isset($_REQUEST['tab-backup']))
     319        {
     320            $request_page='wpvivid_tab_general';
     321        }
     322        else if(isset($_REQUEST['tab-schedule']))
     323        {
     324            $request_page='wpvivid_tab_schedule';
     325        }
     326        else if(isset($_REQUEST['tab-transfer']))
     327        {
     328            $request_page='wpvivid_tab_migrate';
     329        }
     330        else if(isset($_REQUEST['tab-remote-storage']))
     331        {
     332            $request_page='wpvivid_tab_remote_storage';
     333        }
     334        else if(isset($_REQUEST['tab-settings']))
     335        {
     336            $request_page='wpvivid_tab_setting';
     337        }
     338        else if(isset($_REQUEST['tab-website-info']))
     339        {
     340            $request_page='wpvivid_tab_debug';
     341        }
     342        else if(isset($_REQUEST['tab-logs']))
     343        {
     344            $request_page='wpvivid_tab_log';
     345        }
     346        else if(isset($_REQUEST['tab-key']))
     347        {
     348            $request_page='wpvivid_tab_key';
     349        }
     350        else if(isset($_REQUEST['tab-mainwp']))
     351        {
     352            $request_page='wpvivid_tab_mainwp';
     353        }
     354        else if(isset($_REQUEST['page'])&&$_REQUEST['page']=='wpvivid-pro')
     355        {
     356            $request_page='wpvivid_tab_pro';
     357        }
     358        else if(isset($_REQUEST['page'])&&$_REQUEST['page']=='wpvivid-setting')
     359        {
     360            $request_page='wpvivid_tab_setting';
     361        }
     362
     363        $request_page=apply_filters('wpvivid_set_page_request',$request_page);
     364
     365        return $request_page;
     366    }
     367
     368    public static function show_add_my_review()
     369    {
     370        $review = WPvivid_Setting::get_option('wpvivid_need_review');
     371        $review_msg = WPvivid_Setting::get_option('wpvivid_review_msg');
     372        if (empty($review))
     373        {
     374            WPvivid_Setting::update_option('wpvivid_need_review', 'not');
     375        } else {
     376            if ($review == 'not')
     377            {
     378            }
     379            else if ($review == 'show')
     380            {
     381                if(!empty($review_msg))
     382                {
     383                    _e('<div class="notice notice-info is-dismissible" id="wpvivid_notice_rate">
     384                    <p>' . $review_msg . '</p>
     385                    <div style="padding-bottom: 10px;">
     386                    <span><input type="button" class="button-primary" option="review" name="rate-now" value="Rate Us" /></span>
     387                    <span><input type="button" class="button-secondary" option="review" name="ask-later" value="Maybe Later" /></span>
     388                    <span><input type="button" class="button-secondary" option="review" name="never-ask" value="Never" /></span>
     389                    </div>
     390                    </div>');
     391                }
     392            } else if ($review == 'do_not_ask')
     393            {
     394            } else
     395                {
     396                if (time() > $review)
     397                {
     398                    if(!empty($review_msg))
     399                    {
     400                        _e('<div class="notice notice-info is-dismissible" id="wpvivid_notice_rate">
     401                        <p>' . $review_msg . '</p>
     402                        <div style="padding-bottom: 10px;">
     403                        <span><input type="button" class="button-primary" option="review" name="rate-now" value="Rate Us" /></span>   
     404                        <span><input type="button" class="button-secondary" option="review" name="ask-later" value="Maybe Later" /></span>
     405                        <span><input type="button" class="button-secondary" option="review" name="never-ask" value="Never" /></span>
     406                        </div>
     407                        </div>');
     408                    }
     409                }
     410            }
     411        }
     412    }
     413
     414    public function check_amazons3()
     415    {
     416        $remoteslist=WPvivid_Setting::get_all_remote_options();
     417        $need_amazons3_notice = false;
     418        if(isset($remoteslist) && !empty($remoteslist))
     419        {
     420            foreach ($remoteslist as $remote_id => $value)
     421            {
     422                if($remote_id === 'remote_selected')
     423                {
     424                    continue;
     425                }
     426                if($value['type'] == 'amazons3' && isset($value['s3Path']))
     427                {
     428                    $need_amazons3_notice = true;
     429                }
     430                if($value['type'] == 's3compat' && isset($value['s3directory']))
     431                {
     432                    $need_amazons3_notice = true;
     433                }
     434            }
     435        }
     436        if($need_amazons3_notice)
     437        {
     438            $amazons3_notice = WPvivid_Setting::get_option('wpvivid_amazons3_notice', 'not init');
     439            if($amazons3_notice === 'not init')
     440            {
     441                $notice_message = 'As Amazon S3 and DigitalOcean Space have upgraded their connection methods, please delete the previous connections and re-add your Amazon S3/DigitalOcean Space accounts to make sure the connections work.';
     442                _e('<div class="notice notice-warning" id="wpvivid_amazons3_notice">
     443                        <p>' . $notice_message . '</p>
     444                        <div style="padding-bottom: 10px;">
     445                        <span><input type="button" class="button-secondary" value="I Understand" onclick="wpvivid_click_amazons3_notice();" /></span>
     446                        </div>
     447                        </div>');
     448            }
     449        }
     450    }
     451
     452    public function check_extensions()
     453    {
     454        $need_php_extensions = array();
     455        $need_extensions_count = 0;
     456        $extensions=get_loaded_extensions();
     457        if(!function_exists("curl_init")){
     458            $need_php_extensions[$need_extensions_count] = 'curl';
     459            $need_extensions_count++;
     460        }
     461        if(!class_exists('PDO')){
     462            $need_php_extensions[$need_extensions_count] = 'PDO';
     463            $need_extensions_count++;
     464        }
     465        if(!function_exists("gzopen"))
     466        {
     467            $need_php_extensions[$need_extensions_count] = 'zlib';
     468            $need_extensions_count++;
     469        }
     470        if(!array_search('pdo_mysql',$extensions))
     471        {
     472            $need_php_extensions[$need_extensions_count] = 'pdo_mysql';
     473            $need_extensions_count++;
     474        }
     475        if(!empty($need_php_extensions)){
     476            $msg = '';
     477            $figure = 0;
     478            foreach ($need_php_extensions as $extension){
     479                $figure++;
     480                if($figure == 1){
     481                    $msg .= $extension;
     482                }
     483                else if($figure < $need_extensions_count) {
     484                    $msg .= ', '.$extension;
     485                }
     486                else if($figure == $need_extensions_count){
     487                    $msg .= ' and '.$extension;
     488                }
     489            }
     490            if($figure == 1){
     491                _e('<div class="notice notice-error"><p>The '.$msg.' extension is not detected. Please install the extension first.</p></div>');
     492            }
     493            else{
     494                _e('<div class="notice notice-error"><p>The '.$msg.' extensions are not detected. Please install the extensions first.</p></div>');
     495            }
     496        }
     497
     498        if (!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
     499        if (!class_exists('PclZip')) {
     500            _e('<div class="notice notice-error"><p>Class PclZip is not detected. Please update or reinstall your WordPress.</p></div>');
     501        }
     502
     503        $hide_notice = get_option('wpvivid_hide_wp_cron_notice', false);
     504        if(defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && $hide_notice === false){
     505            _e('<div class="notice notice-error notice-wp-cron is-dismissible"><p>In order to execute the scheduled backups properly, please set the DISABLE_WP_CRON constant to false.</p></div>');
     506        }
     507    }
     508
     509    public function init_js_var()
     510    {
     511        global $wpvivid_plugin;
    469512
    470513        $loglist=$wpvivid_plugin->get_log_list_ex();
    471514        $remoteslist=WPvivid_Setting::get_all_remote_options();
    472515        $default_remote_storage='';
    473         foreach ($remoteslist['remote_selected'] as $value) {
     516        foreach ($remoteslist['remote_selected'] as $value)
     517        {
    474518            $default_remote_storage=$value;
    475519        }
     
    499543        </script>
    500544        <?php
    501 
    502         do_action('wpvivid_before_setup_page');
    503         include_once('partials/wpvivid-admin-display.php');
    504     }
    505    
    506     public function display_plugin_backup_page(){
    507         self::wpvivid_set_page_request('backup');
    508         $this->display_plugin_setup_page();
    509     }
    510 
    511     public function display_plugin_transfer_page(){
    512         self::wpvivid_set_page_request('transfer');
    513         $this->display_plugin_setup_page();
    514     }
    515 
    516     public function display_plugin_setting_page(){
    517         self::wpvivid_set_page_request('settings');
    518         $this->display_plugin_setup_page();
    519     }
    520 
    521     public function display_plugin_schedule_page(){
    522         self::wpvivid_set_page_request('schedule');
    523         $this->display_plugin_setup_page();
    524     }
    525 
    526     public function display_plugin_remote_page(){
    527         self::wpvivid_set_page_request('remote');
    528         $this->display_plugin_setup_page();
    529     }
    530 
    531     public function display_plugin_website_page(){
    532         self::wpvivid_set_page_request('website');
    533         $this->display_plugin_setup_page();
    534     }
    535 
    536     public function display_plugin_log_page(){
    537         self::wpvivid_set_page_request('log');
    538         $this->display_plugin_setup_page();
    539     }
    540 
    541     public function display_plugin_key_page(){
    542         self::wpvivid_set_page_request('key');
    543         $this->display_plugin_setup_page();
    544     }
    545 
    546     public function display_plugin_mainwp_page(){
    547         self::wpvivid_set_page_request('mainwp');
    548         $this->display_plugin_setup_page();
    549     }
    550 
    551     public function wpvivid_set_page_request($page){
    552         global $request_page;
    553         switch($page)
    554         {
    555             case "backup":
    556                 $request_page='wpvivid_tab_general';
    557                 break;
    558             case "transfer":
    559                 $request_page='wpvivid_tab_migrate';
    560                 break;
    561             case "settings":
    562                 $request_page='wpvivid_tab_setting';
    563                 break;
    564             case "schedule":
    565                 $request_page='wpvivid_tab_schedule';
    566                 break;
    567             case "remote":
    568                 $request_page='wpvivid_tab_remote_storage';
    569                 break;
    570             case "website":
    571                 $request_page='wpvivid_tab_debug';
    572                 break;
    573             case "log":
    574                 $request_page='wpvivid_tab_log';
    575                 break;
    576             case "key":
    577                 $request_page='wpvivid_tab_key';
    578                 break;
    579             case "mainwp":
    580                 $request_page='wpvivid_tab_mainwp';
    581                 break;
    582             default:
    583                 $request_page='wpvivid_tab_general';
    584                 break;
    585         }
    586     }
    587 
    588     public static function wpvivid_get_page_request(){
    589         global $request_page;
    590         return $request_page;
    591     }
    592 
    593     public static function wpvivid_show_add_my_review()
    594     {
    595         $review = WPvivid_Setting::get_option('wpvivid_need_review');
    596         $review_msg = WPvivid_Setting::get_option('wpvivid_review_msg');
    597         if (empty($review)) {
    598             WPvivid_Setting::update_option('wpvivid_need_review', 'not');
    599         } else {
    600             if ($review == 'not') {
    601             } else if ($review == 'show') {
    602                 if(!empty($review_msg)) {
    603                     _e('<div class="notice notice-info is-dismissible" id="wpvivid_notice_rate">
    604                     <p>' . $review_msg . '</p>
    605                     <div style="padding-bottom: 10px;">
    606                     <span><input type="button" class="button-primary" option="review" name="rate-now" value="Rate Us" /></span>
    607                     <span><input type="button" class="button-secondary" option="review" name="ask-later" value="Maybe Later" /></span>
    608                     <span><input type="button" class="button-secondary" option="review" name="never-ask" value="Never" /></span>
    609                     </div>
    610                     </div>');
    611                 }
    612             } else if ($review == 'do_not_ask') {
    613             } else {
    614                 if (time() > $review) {
    615                     if(!empty($review_msg)) {
    616                         _e('<div class="notice notice-info is-dismissible" id="wpvivid_notice_rate">
    617                         <p>' . $review_msg . '</p>
    618                         <div style="padding-bottom: 10px;">
    619                         <span><input type="button" class="button-primary" option="review" name="rate-now" value="Rate Us" /></span>   
    620                         <span><input type="button" class="button-secondary" option="review" name="ask-later" value="Maybe Later" /></span>
    621                         <span><input type="button" class="button-secondary" option="review" name="never-ask" value="Never" /></span>
    622                         </div>
    623                         </div>');
    624                     }
    625                 }
    626             }
    627         }
    628     }
    629 
    630     public function wpvivid_check_amazons3(){
    631         $remoteslist=WPvivid_Setting::get_all_remote_options();
    632         $need_amazons3_notice = false;
    633         if(isset($remoteslist) && !empty($remoteslist)){
    634             foreach ($remoteslist as $remote_id => $value){
    635                 if($remote_id === 'remote_selected') {
    636                     continue;
    637                 }
    638                 if($value['type'] == 'amazons3' && isset($value['s3Path'])){
    639                     $need_amazons3_notice = true;
    640                 }
    641                 if($value['type'] == 's3compat' && isset($value['s3directory'])){
    642                     $need_amazons3_notice = true;
    643                 }
    644             }
    645         }
    646         if($need_amazons3_notice){
    647             $amazons3_notice = WPvivid_Setting::get_option('wpvivid_amazons3_notice', 'not init');
    648             if($amazons3_notice === 'not init') {
    649                 $notice_message = 'As Amazon S3 and DigitalOcean Space have upgraded their connection methods, please delete the previous connections and re-add your Amazon S3/DigitalOcean Space accounts to make sure the connections work.';
    650                 _e('<div class="notice notice-warning" id="wpvivid_amazons3_notice">
    651                         <p>' . $notice_message . '</p>
    652                         <div style="padding-bottom: 10px;">
    653                         <span><input type="button" class="button-secondary" value="I Understand" onclick="wpvivid_click_amazons3_notice();" /></span>
    654                         </div>
    655                         </div>');
    656             }
    657         }
    658     }
    659 
    660     public static function wpvivid_check_extensions(){
    661         $need_php_extensions = array();
    662         $need_extensions_count = 0;
    663         $extensions=get_loaded_extensions();
    664         if(!function_exists("curl_init")){
    665             $need_php_extensions[$need_extensions_count] = 'curl';
    666             $need_extensions_count++;
    667         }
    668         if(!class_exists('PDO')){
    669             $need_php_extensions[$need_extensions_count] = 'PDO';
    670             $need_extensions_count++;
    671         }
    672         if(!function_exists("gzopen"))
    673         {
    674             $need_php_extensions[$need_extensions_count] = 'zlib';
    675             $need_extensions_count++;
    676         }
    677         if(!array_search('pdo_mysql',$extensions))
    678         {
    679             $need_php_extensions[$need_extensions_count] = 'pdo_mysql';
    680             $need_extensions_count++;
    681         }
    682         if(!empty($need_php_extensions)){
    683             $msg = '';
    684             $figure = 0;
    685             foreach ($need_php_extensions as $extension){
    686                 $figure++;
    687                 if($figure == 1){
    688                     $msg .= $extension;
    689                 }
    690                 else if($figure < $need_extensions_count) {
    691                     $msg .= ', '.$extension;
    692                 }
    693                 else if($figure == $need_extensions_count){
    694                     $msg .= ' and '.$extension;
    695                 }
    696             }
    697             if($figure == 1){
    698                 _e('<div class="notice notice-error"><p>The '.$msg.' extension is not detected. Please install the extension first.</p></div>');
    699             }
    700             else{
    701                 _e('<div class="notice notice-error"><p>The '.$msg.' extensions are not detected. Please install the extensions first.</p></div>');
    702             }
    703         }
    704 
    705         if (!class_exists('PclZip')) include_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
    706         if (!class_exists('PclZip')) {
    707             _e('<div class="notice notice-error"><p>Class PclZip is not detected. Please update or reinstall your WordPress.</p></div>');
    708         }
    709 
    710         if(defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON){
    711             _e('<div class="notice notice-error is-dismissible"><p>In order to execute the scheduled backups properly, please set the DISABLE_WP_CRON constant to false.</p></div>');
    712         }
    713545    }
    714546
     
    721553        $page_array['log'] = array('index' => '7', 'tab_func' => array($this, 'wpvivid_add_tab_log'), 'page_func' => array($this, 'wpvivid_add_page_log'));
    722554        $page_array['read_log'] = array('index' => '9', 'tab_func' => array($this, 'wpvivid_add_tab_read_log'), 'page_func' => array($this, 'wpvivid_add_page_read_log'));
    723         $page_array['mwp'] = array('index' => '30', 'tab_func' => array($this, 'wpvivid_add_tab_mwp'), 'page_func' => array($this, 'wpvivid_add_page_mwp'));
     555        $hide_mwp_tab_page = get_option('wpvivid_hide_mwp_tab_page', false);
     556        if($hide_mwp_tab_page === false) {
     557            $page_array['mwp'] = array('index' => '30', 'tab_func' => array($this, 'wpvivid_add_tab_mwp'), 'page_func' => array($this, 'wpvivid_add_page_mwp'));
     558        }
    724559        return $page_array;
    725560    }
     
    774609    public function wpvivid_add_tab_mwp(){
    775610        ?>
    776         <a href="#" id="wpvivid_tab_mainwp" class="nav-tab wrap-nav-tab" onclick="switchTabs(event, 'mwp-page')"><?php _e('MainWP', 'wpvivid'); ?></a>
    777         <?php
    778     }
    779 
    780     public function wpvivid_add_page_backup(){
    781         $html_progress = '';
    782         $html_backup = '';
    783         $html_schedule = '';
     611        <a href="#" id="wpvivid_tab_mainwp" class="nav-tab wrap-nav-tab delete" onclick="switchTabs(event, 'mwp-page')">
     612            <div style="margin-right: 15px;"><?php _e('MainWP', 'wpvivid'); ?></div>
     613            <div class="nav-tab-delete-img">
     614                <img src="<?php echo esc_url(WPVIVID_PLUGIN_URL.'/admin/partials/images/delete-tab.png'); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_mainwp', 'wrap', 'wpvivid_tab_general');" />
     615            </div>
     616        </a>
     617        <?php
     618    }
     619
     620    public function wpvivid_add_page_backup()
     621    {
    784622        ?>
    785623        <div id="general-page" class="wrap-tab-content wpvivid_tab_general" name="tab-backup" style="width:100%;">
     
    808646    }
    809647
    810     public function wpvivid_add_page_schedule(){
     648    public function wpvivid_add_page_schedule()
     649    {
    811650        ?>
    812651        <div id="schedule-page" class="wrap-tab-content wpvivid_tab_schedule" name="tab-schedule" style="display: none;">
     
    865704    }
    866705
    867     public function wpvivid_add_page_remote_storage(){
     706    public function wpvivid_add_page_remote_storage()
     707    {
    868708        ?>
    869709        <div id="storage-page" class="wrap-tab-content wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
     
    886726    }
    887727
    888     public function wpvivid_add_page_setting(){
     728    public function wpvivid_add_page_setting()
     729    {
    889730        ?>
    890731        <div id="settings-page" class="wrap-tab-content wpvivid_tab_setting" name="tab-setting" style="display:none;">
     
    902743                </h2>
    903744                <?php do_action('wpvivid_settingpage_add_page'); ?>
    904                 <div><input class="button-primary" id="wpvivid_setting_general_save" type="submit" value="<?php esc_attr_e( 'Save Changes', 'wpvivid' ); ?>" style="float: right;" /></div>
     745                <div><input class="button-primary" id="wpvivid_setting_general_save" type="submit" value="<?php esc_attr_e( 'Save Changes', 'wpvivid' ); ?>" /></div>
    905746            </div>
    906747        </div>
     
    945786    }
    946787
    947     public function wpvivid_add_page_website_info(){
     788    public function wpvivid_add_page_website_info()
     789    {
    948790        ?>
    949791        <div id="debug-page" class="wrap-tab-content wpvivid_tab_debug" name="tab-debug" style="display:none;">
     
    1053895    }
    1054896
    1055     public function wpvivid_add_page_log(){
     897    public function wpvivid_add_page_log()
     898    {
    1056899        global $wpvivid_plugin;
    1057900        $display_log_count=array(0=>"10",1=>"20",2=>"30",3=>"40",4=>"50");
     
    1152995            }
    1153996
    1154             function wpvivid_retrieve_log_list(){
     997            function wpvivid_retrieve_log_list()
     998            {
    1155999                var ajax_data = {
    11561000                    'action': 'wpvivid_get_log_list'
     
    11791023    }
    11801024
    1181     public function wpvivid_add_page_read_log(){
     1025    public function wpvivid_add_page_read_log()
     1026    {
    11821027        ?>
    11831028        <div id="log-read-page" class="wrap-tab-content wpvivid_tab_read_log" style="display:none;">
     
    11891034    }
    11901035
    1191     public function wpvivid_add_page_mwp(){
     1036    public function wpvivid_add_page_mwp()
     1037    {
    11921038        ?>
    11931039        <div id="mwp-page" class="wrap-tab-content wpvivid_tab_mainwp" name="tab-mwp" style="display:none;">
  • wpvivid-backuprestore/trunk/admin/css/wpvivid-admin.css

    r2172717 r2182172  
    7272@media only screen and (max-width: 1350px){
    7373    #poststuff #post-body.columns-2 {
    74     margin:0;
     74        margin:0;
    7575    }
    7676    #wpbody-content #post-body.columns-2 #postbox-container-1 {
     
    7878        width: 100%;
    7979    }
    80    
     80
    8181}
    8282
  • wpvivid-backuprestore/trunk/admin/js/wpvivid-admin.js

    r2161394 r2182172  
    6363            var name = jQuery(this).prop('name');
    6464            wpvivid_add_review_info(name);
     65        });
     66
     67        $(document).on('click', '.notice-wp-cron .notice-dismiss', function(){
     68            var ajax_data = {
     69                'action': 'wpvivid_hide_wp_cron_notice'
     70            };
     71            wpvivid_post_request(ajax_data, function(res){
     72            }, function(XMLHttpRequest, textStatus, errorThrown) {
     73            });
    6574        });
    6675    });
     
    590599    event.stopPropagation();
    591600    jQuery('#'+hide_tab).hide();
     601    if(hide_tab === 'wpvivid_tab_mainwp'){
     602        wpvivid_hide_mainwp_tab_page();
     603    }
    592604    wpvivid_click_switch_page(type, show_tab, true);
     605}
     606
     607function wpvivid_hide_mainwp_tab_page(){
     608    var ajax_data = {
     609        'action': 'wpvivid_hide_mainwp_tab_page'
     610    };
     611    wpvivid_post_request(ajax_data, function(res){
     612    }, function(XMLHttpRequest, textStatus, errorThrown) {
     613    });
    593614}
    594615
  • wpvivid-backuprestore/trunk/admin/partials/wpvivid-admin-display.php

    r2172717 r2182172  
    2626
    2727global $wpvivid_plugin;
    28 $select=WPvivid_Setting::get_user_history('remote_selected');
    2928$schedule=WPvivid_Schedule::get_schedule();
    30 $backupdir=WPvivid_Setting::get_backupdir();
    31 $general_setting=WPvivid_Setting::get_setting(true, "");
    32 $last_msg=WPvivid_Setting::get_last_backup_message('wpvivid_last_msg');
    33 $out_of_date=$wpvivid_plugin->_get_out_of_date_info();
    34 $junk_file=$wpvivid_plugin->_junk_files_info();
    35 $website_info=$wpvivid_plugin->get_website_info();
    36 $wpvivid_version=WPVIVID_PLUGIN_VERSION;
    3729
    3830do_action('show_notice');
    39 
    40 function wpvivid_schedule_module($html){
    41     $html = '';
    42     return $html;
    43 }
    44 
    45 function wpvivid_join_pro_testing($html){
    46     $html = '';
    47     $html = '<div class="postbox">
    48                 <h2><a href="https://wpvivid.com/pro-version-beta-testing?utm_source=client_beta_testing&utm_medium=inner_link&utm_campaign=access" style="text-decoration: none;">WPvivid Backup Pro Beta Testing</a></h2>
    49              </div>';
    50     return $html;
    51 }
    52 
    53 add_filter('wpvivid_schedule_module', 'wpvivid_schedule_module', 10);
    54 add_filter('wpvivid_join_pro_testing', 'wpvivid_join_pro_testing', 10);
    5531
    5632?>
     
    6440    add_action('wpvivid_backuprestore_add_page', $page_name['page_func'], $page_name['index']);
    6541}
     42
     43function wpvivid_add_side_bar($html){
     44    $wpvivid_version = WPVIVID_PLUGIN_VERSION;
     45    $wpvivid_version = apply_filters('wpvivid_display_pro_version', $wpvivid_version);
     46    $join_pro_testing = '<div class="postbox">
     47                            <h2><a href="https://wpvivid.com/pro-version-beta-testing?utm_source=client_beta_testing&utm_medium=inner_link&utm_campaign=access" style="text-decoration: none;">WPvivid Backup Pro Beta Testing</a></h2>
     48                         </div>';
     49    $join_pro_testing = apply_filters('wpvivid_join_pro_testing', $join_pro_testing);
     50
     51    $schedule_html = '';
     52    $schedule_html = apply_filters('wpvivid_schedule_module', $schedule_html);
     53
     54    $html = '<div class="postbox">
     55                <h2><span>Current Version: '.$wpvivid_version.'</span></h2>
     56             </div>
     57             <div id="wpvivid_backup_schedule_part"></div>
     58             '.$join_pro_testing.$schedule_html.'
     59             <div class="postbox">
     60                <h2><span>Troubleshooting</span></h2>
     61                <div class="inside">
     62                    <table class="widefat" cellpadding="0">
     63                        <tbody>
     64                        <tr class="alternate">
     65                            <td class="row-title">Read <a href="https://wpvivid.com/troubleshooting-issues-wpvivid-backup-plugin" target="_blank">Troubleshooting page</a> for faster solutions.</td>
     66                        </tr>
     67                        <tr>
     68                            <td class="row-title">Adjust <a href="https://wpvivid.com/wpvivid-backup-plugin-advanced-settings.html" target="_blank">Advanced Settings</a> for higher task success rate.</td>
     69                        </tr>
     70                        </tbody>
     71                    </table>
     72                </div>
     73             </div>
     74             <div class="postbox">
     75                <h2><span>How-to</span></h2>
     76                <div class="inside">
     77                    <table class="widefat" cellpadding="0">
     78                        <tbody>
     79                            <tr class="alternate"><td class="row-title"><a href="https://wpvivid.com/get-started-settings.html" target="_blank">WPvivid Backup Settings</a></td></tr>
     80                            <tr><td class="row-title"><a href="https://wpvivid.com/get-started-create-a-manual-backup.html" target="_blank">Create a Manual Backup</a></td></tr>
     81                            <tr class="alternate"><td class="row-title"><a href="https://wpvivid.com/get-started-restore-site.html" target="_blank">Restore Your Site from a Backup</a></td></tr>
     82                            <tr><td class="row-title"><a href="https://wpvivid.com/get-started-transfer-site.html" target="_blank">Migrate WordPress</a></td></tr>
     83                        </tbody>
     84                    </table>
     85                </div>
     86             </div>';
     87    return $html;
     88}
     89
     90add_filter('wpvivid_add_side_bar', 'wpvivid_add_side_bar', 10);
    6691
    6792?>
     
    78103            if($schedule['backup']['remote'] === 1)
    79104            {
     105                $remoteslist=WPvivid_Setting::get_all_remote_options();
     106                $default_remote_storage='';
     107                foreach ($remoteslist['remote_selected'] as $value)
     108                {
     109                    $default_remote_storage=$value;
     110                }
    80111                if($default_remote_storage == ''){
    81112                    _e('<div class="notice notice-warning is-dismissible"><p>Warning: There is no default remote storage available for the scheduled backups, please set up it first.</p></div>');
     
    102133                    ?>
    103134                </div>
    104 
    105135            </div>
    106136
    107137            <div id="postbox-container-1" class="postbox-container">
    108138                <div class="meta-box-sortables">
    109                     <div class="postbox">
    110                         <h2><span>Current Version: <?php
    111                                 $wpvivid_version = apply_filters('wpvivid_display_pro_version', $wpvivid_version);
    112                                 _e($wpvivid_version, 'wpvivid');
    113                                 ?></span></h2>
    114                     </div>
    115                     <div id="wpvivid_backup_schedule_part">
    116                         <?php
    117                         $schedule_html = '';
    118                         echo apply_filters('wpvivid_schedule_module', $schedule_html);
    119                         ?>
    120                     </div>
    121139                    <?php
    122                     $join_pro_testing = '';
    123                     echo apply_filters('wpvivid_join_pro_testing', $join_pro_testing);
     140                    $html = '';
     141                    echo apply_filters('wpvivid_add_side_bar' ,$html);
    124142                    ?>
    125                     <div class="postbox">
    126                         <h2><span>Troubleshooting</span></h2>
    127                         <div class="inside">
    128                             <table class="widefat" cellpadding="0">
    129                                 <tbody>
    130                                     <tr class="alternate">
    131                                         <td class="row-title">Read <a href="https://wpvivid.com/troubleshooting-issues-wpvivid-backup-plugin" target="_blank">Troubleshooting page</a> for faster solutions.</td>
    132                                     </tr>
    133                                     <tr>
    134                                         <td class="row-title">Adjust <a href="https://wpvivid.com/wpvivid-backup-plugin-advanced-settings.html" target="_blank">Advanced Settings</a> for higher task success rate.</td>
    135                                     </tr>
    136                                 </tbody>
    137                             </table>
    138                         </div>
    139                     </div>
    140                     <div class="postbox">
    141                         <h2><span>How-to</span></h2>
    142                         <div class="inside">
    143                             <table class="widefat" cellpadding="0">
    144                                 <tbody>
    145                                 <tr class="alternate"><td class="row-title"><a href="https://wpvivid.com/get-started-settings.html" target="_blank">WPvivid Backup Settings</a></td></tr>
    146                                 <tr><td class="row-title"><a href="https://wpvivid.com/get-started-create-a-manual-backup.html" target="_blank">Create a Manual Backup</a></td></tr>
    147                                 <tr class="alternate"><td class="row-title"><a href="https://wpvivid.com/get-started-restore-site.html" target="_blank">Restore Your Site from a Backup</a></td></tr>
    148                                 <tr><td class="row-title"><a href="https://wpvivid.com/get-started-transfer-site.html" target="_blank">Migrate WordPress</a></td></tr>
    149                                 </tbody>
    150                             </table>
    151                         </div>
    152                     </div>
    153143                </div>
    154144            </div>
  • wpvivid-backuprestore/trunk/admin/partials/wpvivid-backup-restore-page-display.php

    r2172717 r2182172  
    558558            jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
    559559            jQuery('#wpvivid_download_'+restore_method+'part').hide();
    560             /*if(wpvivid_restore_backup_type == 'Migration' || wpvivid_restore_backup_type == 'Upload') {
    561                 jQuery('#wpvivid_restore_is_migrate').show();
    562                 jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'none', 'opacity': '0.4'});
    563             }
    564             else{
    565                 jQuery('#wpvivid_restore_is_migrate').hide();
    566             }*/
     560
    567561            jQuery('#wpvivid_init_restore_data').addClass('is-active');
    568562            var ajax_data = {
     
    617611                                    output += "<p>" + jsonarray.max_allow_packet_warning + "</p>";
    618612                                }
    619                                 if(jsonarray.memory_limit != false){
     613                                if(jsonarray.memory_limit_warning != false){
    620614                                    output += "<p>" + jsonarray.memory_limit_warning + "</p>";
    621615                                }
  • wpvivid-backuprestore/trunk/admin/partials/wpvivid-remote-storage-page-display.php

    r2161394 r2182172  
    267267                            var key = jQuery(this).prop('name');
    268268                            jQuery(this).val(jsonarray[key]);
    269                             /*var key = jQuery(this).prop('name');
    270                             if(key == 's3Path' && jsonarray.type == 'amazons3'){
    271                                 var iLength = jsonarray[key].lastIndexOf('/wpvivid_backup');
    272                                 if(iLength != -1) {
    273                                     jsonarray[key] = jsonarray[key].substring(0, iLength);
    274                                 }
    275                                 jQuery(this).val(jsonarray[key]);
    276                             }
    277                             else {
    278                                 jQuery(this).val(jsonarray[key]);
    279                             }*/
    280269                        });
    281270                        jQuery('input:password[option=edit-'+jsonarray.type+']').each(function(){
     
    294283                            jQuery(this).prop('checked', value);
    295284                        });
    296                         /*if(jsonarray.type == 'amazons3'){
    297                             var amazons3_edit_value = jQuery('input:text[option=edit-'+jsonarray.type+'][name=s3Path]').val();
    298                             if(amazons3_edit_value == ''){
    299                                 amazons3_edit_value = '*';
    300                             }
    301                             amazons3_edit_value = amazons3_edit_value + '/wpvivid_backup';
    302                             jQuery('#wpvivid_edit_amazons3_root_path').html(amazons3_edit_value);
    303                         }
    304                         if(jsonarray.type == 's3compat'){
    305                             var dos_edit_value = jQuery('input:text[option=edit-'+jsonarray.type+'][name=s3directory]').val();
    306                             if(dos_edit_value == ''){
    307                                 dos_edit_value = '*';
    308                             }
    309                             dos_edit_value = dos_edit_value + '/wpvivid_backup';
    310                             jQuery('#wpvivid_edit_dos_root_path').html(dos_edit_value);
    311                         }*/
    312285                    }
    313286                    else
  • wpvivid-backuprestore/trunk/admin/partials/wpvivid-settings-page-display.php

    r2172717 r2182172  
    66    $display_backup_count = $general_setting['options']['wpvivid_common_setting']['max_backup_count'];
    77    $display_backup_count=intval($display_backup_count);
     8    if($display_backup_count > 7){
     9        $display_backup_count = 7;
     10    }
    811    if($general_setting['options']['wpvivid_common_setting']['estimate_backup']){
    912        $wpvivid_setting_estimate_backup='checked';
     
    132135        <div class="setting-tab-block" style="padding: 10px 10px 0 0;">
    133136            <input class="button-primary" id="wpvivid_delete_out_of_backup" style="margin-right:10px;" type="submit" name="delete-out-of-backup" value="<?php esc_attr_e( 'Remove', 'wpvivid' ); ?>" />
    134             <p><?php _e('The action is irreversible! It will remove all backups which is(are) out-of-date (including local web server and remote storage) if they exist.', 'wpvivid'); ?> </p>
     137            <p><?php _e('The action is irreversible! It will remove all backups are out-of-date (including local web server and remote storage) if they exist.', 'wpvivid'); ?> </p>
    135138        </div>
    136139    </div>
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-backup-database.php

    r2134102 r2182172  
    1414    }
    1515
     16    public function wpvivid_archieve_database_info($databases, $data){
     17        if(isset($data['dump_db'])){
     18            $sql_info['file_name'] =$data['sql_file_name'];
     19            $sql_info['database'] = DB_NAME;
     20            $sql_info['host'] = DB_HOST;
     21            $sql_info['user'] = DB_USER;
     22            $sql_info['pass'] = DB_PASSWORD;
     23            $databases[] = $sql_info;
     24        }
     25        return $databases;
     26    }
     27
    1628    public function backup_database($data,$task_id = '')
    1729    {
     
    2335            $this->task_id=$task_id;
    2436
    25             $backup_file =$data['sql_file_name'];
     37            //$backup_file =$data['sql_file_name'];
    2638
    2739            require_once 'class-wpvivid-mysqldump-method.php';
     
    4557            $exclude = apply_filters('wpvivid_exclude_db_table',$exclude, $data);
    4658
    47             //$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
    48             $dump = new WPvivid_Mysqldump(DB_HOST,DB_NAME, DB_USER, DB_PASSWORD , array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
     59            add_filter('wpvivid_archieve_database_info', array($this, 'wpvivid_archieve_database_info'), 10, 2);
     60            $databases=array();
     61            $databases = apply_filters('wpvivid_archieve_database_info', $databases, $data);
    4962
    50             if(file_exists($backup_file))
    51                 @unlink($backup_file);
     63            $backup_files = array();
     64            foreach ($databases as $sql_info) {
     65                $database_name = $sql_info['database'];
     66                $backup_file = $sql_info['file_name'];
     67                $backup_files[] = $backup_file;
     68                $host = $sql_info['host'];
     69                $user = $sql_info['user'];
     70                $pass = $sql_info['pass'];
     71                $dump = new WPvivid_Mysqldump($host, $database_name, $user, $pass, array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
    5272
    53             $dump->task_id=$task_id;
    54             $dump->start($backup_file);
     73                if (file_exists($backup_file))
     74                    @unlink($backup_file);
     75
     76                $dump->task_id=$task_id;
     77                $dump->start($backup_file);
     78            }
     79
    5580            unset($pdo);
    5681        }
     
    7196
    7297        $files = array();
    73         $files[] = $backup_file;
     98        $files = $backup_files;
    7499        return array('result'=>WPVIVID_SUCCESS,'files'=>$files);
    75100    }
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-backup.php

    r2161394 r2182172  
    276276                $backup_data['json_info']['file_type']='databases';
    277277                $backup_data['prefix']=$this->get_prefix().'_backup_db';
    278                 $this->task['options']['backup_options']['backup'][$backup_data['key']]=$backup_data;
    279278            }
    280279            else if($backup==WPVIVID_BACKUP_TYPE_THEMES)
     
    10661065                    }
    10671066                    else{
    1068                         $descript = 'Strat uploading.';
     1067                        $descript = 'Start uploading.';
    10691068                        $speed = '0kb/s';
    10701069                        $list_tasks['task_info']['total'] = 'N/A';
     
    17301729            $file_added=array();
    17311730            $child_packages=array();
     1731
    17321732            foreach ($packages as $key=>$package)
    17331733            {
     
    18811881
    18821882        $ret=$zip->get_json_data($path);
     1883
    18831884        if($ret['result'] === WPVIVID_SUCCESS) {
    18841885            $json=$ret['json_data'];
     
    18881889            }
    18891890        }
    1890 
    18911891        return $files;
    18921892    }
     
    21912191        $result['result']=WPVIVID_FAILED;
    21922192        $result['error']='test error';
    2193         if(isset($data['dump_db']))
    2194         {
     2193
     2194        $is_type_db = false;
     2195        $is_type_db = apply_filters('wpvivid_check_type_database', $is_type_db, $data);
     2196        if($is_type_db){
    21952197            include_once WPVIVID_PLUGIN_DIR .'/includes/class-wpvivid-backup-database.php';
    21962198            $wpvivid_plugin->wpvivid_log->WriteLog('Start exporting database.','notice');
     
    22462248            $result['result']=WPVIVID_SUCCESS;
    22472249            $result['files']=array();
    2248 
    22492250            foreach ($packages as $package)
    22502251            {
     
    22772278        else
    22782279        {
    2279             $result =$zip->compress($data);
    2280 
    2281             if(isset($data['dump_db']))
    2282             {
     2280            $is_additional_db = false;
     2281            $is_additional_db = apply_filters('wpvivid_check_additional_database', $is_additional_db, $data);
     2282            if($is_additional_db){
     2283                $result =$zip->compress_additional_database($data);
     2284            }
     2285            else{
     2286                $result =$zip->compress($data);
     2287            }
     2288
     2289            if($is_type_db){
    22832290                foreach ($data['files'] as $sql_file)
    22842291                {
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-db-method.php

    r2134102 r2182172  
    1414    public function connect_db()
    1515    {
     16        $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
     17        if($client_flags)
     18        {
     19            global $wpdb;
     20            $this->db_handle=$wpdb;
     21            $this->type='wpdb';
     22
     23            return array('result'=>WPVIVID_SUCCESS);
     24        }
     25
    1626        if(class_exists('PDO'))
    1727        {
     
    2232                $db_host = $res[0];
    2333                $db_port = empty($res[1])?'':$res[1];
     34
    2435                if(!empty($db_port)) {
    2536                    $dsn='mysql:host=' . $db_host . ';port=' . $db_port . ';dbname=' . DB_NAME;
     
    2839                    $dsn='mysql:host=' . $db_host . ';dbname=' . DB_NAME;
    2940                }
     41
    3042                $this->db_handle=new PDO($dsn, DB_USER, DB_PASSWORD);
     43
    3144                $this->type='pdo_mysql';
    32                 return;
     45                return array('result'=>WPVIVID_SUCCESS);
    3346            }
    3447        }
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-mysqldump-wpdb.php

    r2134102 r2182172  
    122122        );
    123123
     124        if(defined('DB_CHARSET'))
     125        {
     126            $dumpSettingsDefault['default-character-set']=DB_CHARSET;
     127        }
     128
    124129        $this->dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dumpSettings);
    125130
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-mysqldump.php

    r2134102 r2182172  
    134134        );
    135135
     136        if(defined('DB_CHARSET'))
     137        {
     138            $dumpSettingsDefault['default-character-set']=DB_CHARSET;
     139        }
     140
    136141        $this->dbType=$this->get_db_type();
    137142        $this->user = $user;
     
    168173    public function get_db_type()
    169174    {
     175        $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
     176        if($client_flags)
     177        {
     178            return 'wpdb';
     179        }
     180
    170181        if(class_exists('PDO'))
    171182        {
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-public-interface.php

    r2172717 r2182172  
    2929            case 'set_schedule_addon':
    3030                $ret = apply_filters('wpvivid_sync_schedule_addon_mainwp', $data['schedule']);
     31                break;
     32            case 'get_database_tables':
     33                $ret = apply_filters('wpvivid_get_database_tables_mainwp', array());
     34                break;
     35            case 'get_themes_plugins':
     36                $ret = apply_filters('wpvivid_get_themes_plugins_mainwp', array());
    3137                break;
    3238            default:
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-restore-database.php

    r2161394 r2182172  
    5050
    5151        global $wpvivid_plugin;
    52 
    53         if(file_exists($path.$sql_file))
    54         {
     52        if(file_exists($path.$sql_file)) {
    5553            if(!isset($options['skip_backup_old_database']))
    5654            {
     
    6361                {
    6462                    $wpvivid_plugin->restore_data->write_log('Backing up current site\'s database failed.error:'.$result['error'],'warning');
    65                 }
    66             }
    67 
    68             $this->current_setting = WPvivid_Setting::export_setting_to_json();
    69             $ret=$this->db_method->connect_db();
    70             if($ret['result']==WPVIVID_FAILED)
    71             {
    72                 return $ret;
    73             }
    74 
    75             $this->db_method->test_db();
    76             $this->db_method->check_max_allow_packet();
    77 
    78             $this->db_method->init_sql_mode();
    79             $result=$this->execute_sql_file($path.$sql_file,$options);
    80             $this->enable_plugins();
    81             unset($this->db_method);
     63                    return $result;
     64                }
     65            }
     66
     67            $is_additional_db = false;
     68            $is_additional_db = apply_filters('wpvivid_check_additional_database', $is_additional_db, $options);
     69            if($is_additional_db){
     70                $result = $this->execute_extra_sql_file($path . $sql_file, $options);
     71            }
     72            else{
     73                $this->current_setting = WPvivid_Setting::export_setting_to_json();
     74                $ret=$this->db_method->connect_db();
     75                if($ret['result']==WPVIVID_FAILED)
     76                {
     77                    return $ret;
     78                }
     79
     80                $this->db_method->test_db();
     81                $this->db_method->check_max_allow_packet();
     82                $this->db_method->init_sql_mode();
     83
     84                $result = $this->execute_sql_file($path . $sql_file, $options);
     85
     86                $this->enable_plugins();
     87                unset($this->db_method);
     88                do_action('wpvivid_restore_database_finish',$options);
     89            }
    8290            return $result;
    83         }else {
     91        }
     92        else {
    8493            return array('result'=>'failed','error'=>'Database\'s .sql file not found. Please try again.');
    8594        }
     95    }
     96
     97    private function execute_extra_sql_file($file, $options){
     98        global $wpvivid_plugin;
     99        $wpvivid_plugin->restore_data->write_log('Start import additional sql file.','notice');
     100        $dbhost = '';
     101        $dbuser = '';
     102        $dbpassword = '';
     103        $dbname = '';
     104        foreach ($options['additional_database'] as $db_name => $db_info){
     105            if($options['database'] === $db_name){
     106                $dbhost = $db_info['db_host'];
     107                $dbuser = $db_info['db_user'];
     108                $dbpassword = $db_info['db_pass'];
     109                $dbname = $db_info['db_name'];
     110                break;
     111            }
     112        }
     113
     114        $restore_extra_db=new WPvivid_Restore_DB_Extra($dbhost, $dbuser, $dbpassword, $dbname);
     115        $ret = $restore_extra_db->execute_extra_sql_file($file, $options);
     116        return $ret;
    86117    }
    87118
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-restore-db-method.php

    r2134102 r2182172  
    11<?php
    2 /**
    3  * Created by PhpStorm.
    4  * User: alienware`x
    5  * Date: 2019/6/11
    6  * Time: 13:26
    7  */
    82
    93include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore-db-pdo-mysql-method.php';
     
    1812    {
    1913        global $wpvivid_plugin;
     14        $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
     15        if($client_flags)
     16        {
     17            $wpvivid_plugin->restore_data->write_log('wpdb', 'Warning');
     18            $this->db =new WPvivid_Restore_DB_WPDB_Method();
     19            $this->type='wpdb';
     20            return;
     21        }
     22
    2023        if(class_exists('PDO'))
    2124        {
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-restore-db-pdo-mysql-method.php

    r2134102 r2182172  
    11<?php
    2 /**
    3  * Created by PhpStorm.
    4  * User: alienware`x
    5  * Date: 2019/6/12
    6  * Time: 15:46
    7  */
    8 
    9 
    102
    113class WPvivid_Restore_DB_PDO_Mysql_Method
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-restore-db-wpdb-method.php

    r2134102 r2182172  
    11<?php
    2 /**
    3  * Created by PhpStorm.
    4  * User: alienware`x
    5  * Date: 2019/6/12
    6  * Time: 15:49
    7  */
    82
    93class WPvivid_Restore_DB_WPDB_Method
     
    159153    {
    160154        global $wpdb;
    161         return $wpdb->last_error;;
     155        return $wpdb->last_error;
    162156    }
    163157}
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-restore-site.php

    r2161394 r2182172  
    1313    {
    1414        global $wpvivid_plugin;
    15 
    1615        if(isset($option['has_child']))
    1716        {
     
    3938            }
    4039        }
    41         else if(isset($option['dump_db']))
    42         {
    43             $path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.'wpvivid_old_database';
    44             if(file_exists($path))
    45             {
    46                 @mkdir($path);
    47             }
    48 
    49             $zip = new WPvivid_ZipClass();
    50             $all_files = array();
    51             foreach ($files as $file)
    52             {
    53                 $all_files[] = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$file;
    54             }
    55 
    56             $ret= $zip -> extract($all_files,$path);
    57 
    58             unset($zip);
    59 
    60             return $ret;
    61         }
    6240        else
    6341        {
    64             $root_path='';
    65             if(isset($option['root']))
    66             {
    67                 $root_path=$this->transfer_path(get_home_path().$option['root']);
    68             }
    69             else if(isset($option['root_flag']))
    70             {
    71                 if($option['root_flag']==WPVIVID_BACKUP_ROOT_WP_CONTENT)
    72                 {
    73                     $root_path=$this->transfer_path(WP_CONTENT_DIR);
    74                 }
    75                 else if($option['root_flag']==WPVIVID_BACKUP_ROOT_CUSTOM)
    76                 {
    77                     $root_path=$this->transfer_path(WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir());
    78                 }
    79                 else if($option['root_flag']==WPVIVID_BACKUP_ROOT_WP_ROOT)
    80                 {
    81                     $root_path=$this->transfer_path(ABSPATH);
    82                 }
    83             }
    84 
    85             $root_path = rtrim($root_path, '/');
    86             $root_path = rtrim($root_path, DIRECTORY_SEPARATOR);
    87 
    88             $exclude_path[]=$this->transfer_path(WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir());
    89 
    90             if(isset($option['include_path']))
    91             {
    92                 $include_path=$option['include_path'];
    93             }
    94             else
    95             {
    96                 $include_path=array();
    97             }
    98 
    99             $zip = new WPvivid_ZipClass();
    100             $all_files = array();
    101             foreach ($files as $file)
    102             {
    103                 $all_files[] = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$file;
    104             }
    105 
    106             $wpvivid_plugin->restore_data->write_log('restore from files:'.json_encode($all_files),'notice');
    107 
    108             $ret= $zip->extract($all_files,$root_path);
    109 
    110             if(isset($option['file_type']))
    111             {
    112                 if($option['file_type']=='themes')
    113                 {
    114                     if(isset($option['remove_themes']))
    115                     {
    116                         foreach ($option['remove_themes'] as $slug=>$themes)
    117                         {
    118                             if(empty($slug))
    119                                 continue;
    120                             $wpvivid_plugin->restore_data->write_log('remove '.get_theme_root().DIRECTORY_SEPARATOR.$slug,'notice');
    121                             $this->delTree(get_theme_root().DIRECTORY_SEPARATOR.$slug);
    122                         }
    123                     }
    124 
    125                 }
    126                 else if($option['file_type']=='plugin')
    127                 {
    128                     if(isset($option['remove_plugin']))
    129                     {
    130                         foreach ($option['remove_plugin'] as $slug=>$plugin)
    131                         {
    132                             if(empty($slug))
    133                                 continue;
    134                             $wpvivid_plugin->restore_data->write_log('remove '.WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.$slug,'notice');
    135                             $this->delTree(WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.$slug);
    136                         }
    137                     }
    138                 }
    139             }
    140 
    141 
    142             unset($zip);
    143 
    144             if(isset($option['wp_core'])&&isset($option['is_migrate']))
    145             {
    146                 if($option['is_migrate'] == 1)
    147                 {
    148                     if (function_exists('save_mod_rewrite_rules'))
    149                     {
    150                         if(file_exists(get_home_path() . '.htaccess'))
    151                         {
    152                             $htaccess_data=file_get_contents(get_home_path() . '.htaccess');
    153                             $line='';
    154                             if(preg_match('#AddHandler application/x-httpd-php.*#',$htaccess_data,$matcher))
    155                             {
    156                                 $line = PHP_EOL.$matcher[0];
    157 
    158                                 if(preg_match('#<IfModule mod_suphp.c>#',$htaccess_data,$matcher))
    159                                 {
    160                                     $line.= PHP_EOL.'<IfModule mod_suphp.c>';
    161                                     if(preg_match('#suPHP_ConfigPath .*#',$htaccess_data,$matcher))
    162                                     {
    163                                         $line.= PHP_EOL.$matcher[0];
     42            $is_type_db = false;
     43            $is_type_db = apply_filters('wpvivid_check_type_database', $is_type_db, $option);
     44            if($is_type_db){
     45                $path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.'wpvivid_old_database';
     46                if(file_exists($path))
     47                {
     48                    @mkdir($path);
     49                }
     50
     51                $zip = new WPvivid_ZipClass();
     52                $all_files = array();
     53                foreach ($files as $file)
     54                {
     55                    $all_files[] = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.$file;
     56                }
     57
     58                $ret= $zip -> extract($all_files,$path);
     59
     60                unset($zip);
     61            }
     62            else {
     63                $root_path = '';
     64                if (isset($option['root'])) {
     65                    $root_path = $this->transfer_path(get_home_path() . $option['root']);
     66                } else if (isset($option['root_flag'])) {
     67                    if ($option['root_flag'] == WPVIVID_BACKUP_ROOT_WP_CONTENT) {
     68                        $root_path = $this->transfer_path(WP_CONTENT_DIR);
     69                    } else if ($option['root_flag'] == WPVIVID_BACKUP_ROOT_CUSTOM) {
     70                        $root_path = $this->transfer_path(WP_CONTENT_DIR . DIRECTORY_SEPARATOR . WPvivid_Setting::get_backupdir());
     71                    } else if ($option['root_flag'] == WPVIVID_BACKUP_ROOT_WP_ROOT) {
     72                        $root_path = $this->transfer_path(ABSPATH);
     73                    }
     74                }
     75
     76                $root_path = rtrim($root_path, '/');
     77                $root_path = rtrim($root_path, DIRECTORY_SEPARATOR);
     78
     79                $exclude_path[] = $this->transfer_path(WP_CONTENT_DIR . DIRECTORY_SEPARATOR . WPvivid_Setting::get_backupdir());
     80
     81                if (isset($option['include_path'])) {
     82                    $include_path = $option['include_path'];
     83                } else {
     84                    $include_path = array();
     85                }
     86
     87                $zip = new WPvivid_ZipClass();
     88                $all_files = array();
     89                foreach ($files as $file) {
     90                    $all_files[] = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . WPvivid_Setting::get_backupdir() . DIRECTORY_SEPARATOR . $file;
     91                }
     92
     93                $wpvivid_plugin->restore_data->write_log('restore from files:' . json_encode($all_files), 'notice');
     94
     95                $ret = $zip->extract($all_files, $root_path);
     96
     97                if (isset($option['file_type'])) {
     98                    if ($option['file_type'] == 'themes') {
     99                        if (isset($option['remove_themes'])) {
     100                            foreach ($option['remove_themes'] as $slug => $themes) {
     101                                if (empty($slug))
     102                                    continue;
     103                                $wpvivid_plugin->restore_data->write_log('remove ' . get_theme_root() . DIRECTORY_SEPARATOR . $slug, 'notice');
     104                                $this->delTree(get_theme_root() . DIRECTORY_SEPARATOR . $slug);
     105                            }
     106                        }
     107                    } else if ($option['file_type'] == 'plugin') {
     108                        if (isset($option['remove_plugin'])) {
     109                            foreach ($option['remove_plugin'] as $slug => $plugin) {
     110                                if (empty($slug))
     111                                    continue;
     112                                $wpvivid_plugin->restore_data->write_log('remove ' . WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $slug, 'notice');
     113                                $this->delTree(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $slug);
     114                            }
     115                        }
     116                    }
     117                }
     118
     119
     120                unset($zip);
     121
     122                if (isset($option['wp_core']) && isset($option['is_migrate'])) {
     123                    if ($option['is_migrate'] == 1) {
     124                        if (function_exists('save_mod_rewrite_rules')) {
     125                            if (file_exists(get_home_path() . '.htaccess')) {
     126                                $htaccess_data = file_get_contents(get_home_path() . '.htaccess');
     127                                $line = '';
     128                                if (preg_match('#AddHandler application/x-httpd-php.*#', $htaccess_data, $matcher)) {
     129                                    $line = PHP_EOL . $matcher[0];
     130
     131                                    if (preg_match('#<IfModule mod_suphp.c>#', $htaccess_data, $matcher)) {
     132                                        $line .= PHP_EOL . '<IfModule mod_suphp.c>';
     133                                        if (preg_match('#suPHP_ConfigPath .*#', $htaccess_data, $matcher)) {
     134                                            $line .= PHP_EOL . $matcher[0];
     135                                        }
     136                                        $line .= PHP_EOL . '</IfModule>';
    164137                                    }
    165                                     $line.= PHP_EOL.'</IfModule>';
     138                                    $wpvivid_plugin->restore_data->write_log('find php selector:' . $line, 'notice');
    166139                                }
    167                                 $wpvivid_plugin->restore_data->write_log('find php selector:'.$line,'notice');
     140                                @rename(get_home_path() . '.htaccess', get_home_path() . '.htaccess_old');
     141                                save_mod_rewrite_rules();
     142                                if (!empty($line))
     143                                    file_put_contents(get_home_path() . '.htaccess', $line, FILE_APPEND);
    168144                            }
    169                             @rename(get_home_path() . '.htaccess', get_home_path() . '.htaccess_old');
    170                             save_mod_rewrite_rules();
    171                             if(!empty($line))
    172                                 file_put_contents(get_home_path() . '.htaccess',$line,FILE_APPEND);
    173                         }
    174                     }
    175                     WPvivid_Setting::update_option('wpvivid_migrate_status', 'completed');
    176                 }
    177             }
    178 
     145                        }
     146                        WPvivid_Setting::update_option('wpvivid_migrate_status', 'completed');
     147                    }
     148                }
     149            }
    179150            return $ret;
    180151        }
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-restore.php

    r2161394 r2182172  
    6363        }
    6464        $option=array_merge($option,$restore_task['option']);
    65 
    66         if(isset($option['dump_db']))
    67         {
     65        $is_type_db = false;
     66        $is_type_db = apply_filters('wpvivid_check_type_database', $is_type_db, $option);
     67        if($is_type_db){
    6868            $restore_site = new WPvivid_RestoreSite();
    6969            $wpvivid_plugin->restore_data->write_log('Start restoring '.$restore_task['files'][0],'notice');
    7070            $ret= $restore_site -> restore($option,$restore_task['files']);
    71             if($ret['result']==WPVIVID_SUCCESS)
    72             {
     71            if($ret['result']==WPVIVID_SUCCESS){
    7372                $path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR.WPVIVID_DEFAULT_ROLLBACK_DIR.DIRECTORY_SEPARATOR.'wpvivid_old_database'.DIRECTORY_SEPARATOR;
    7473                $sql_file = $backup_item->get_sql_file($restore_task['files'][0]);
    7574                $wpvivid_plugin->restore_data->write_log('sql file: '.$sql_file,'notice');
    7675                $restore_db=new WPvivid_RestoreDB();
    77                 $restore_db->restore($path,$sql_file,$option);
    78                 $wpvivid_plugin->restore_data->write_log('Finished restoring '.$restore_task['files'][0],'notice');
    79                 $wpvivid_plugin->restore_data->update_need_unzip_file($restore_task['index'],$restore_task['files']);
    80                 return array('result'=>WPVIVID_SUCCESS);
     76                $check_is_remove = false;
     77                $check_is_remove = apply_filters('wpvivid_check_remove_restore_database', $check_is_remove, $option);
     78                if(!$check_is_remove) {
     79                    $ret = $restore_db->restore($path, $sql_file, $option);
     80                    $wpvivid_plugin->restore_data->write_log('Finished restoring '.$restore_task['files'][0],'notice');
     81                    $wpvivid_plugin->restore_data->update_need_unzip_file($restore_task['index'],$restore_task['files']);
     82                }
     83                else{
     84                    $wpvivid_plugin->restore_data->write_log('Remove file: '.$path.$sql_file, 'notice');
     85                    $wpvivid_plugin->restore_data->update_need_unzip_file($restore_task['index'],$restore_task['files']);
     86                    $ret['result']=WPVIVID_SUCCESS;
     87                }
     88                return $ret;
    8189            }
    82             else
    83             {
     90            else{
    8491                return $ret;
    8592            }
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-setting.php

    r2172717 r2182172  
    346346
    347347        $options=array();
    348         $upload_options=self::get_option('wpvivid_upload_setting');
     348        $upload_options=WPvivid_Setting::get_option('wpvivid_upload_setting');
    349349        foreach ($remote_ids as $id)
    350350        {
     
    452452    }
    453453
    454     public static function export_setting_to_json($setting=true,$history=true,$review=true)
     454    public static function export_setting_to_json($setting=true,$history=true,$review=true,$backup_list=true)
    455455    {
    456456        global $wpvivid_plugin;
     
    502502        if($history)
    503503        {
    504             $json['data']['wpvivid_backup_list']=self::get_option('wpvivid_backup_list');
    505504            $json['data']['wpvivid_task_list']=self::get_option('wpvivid_task_list');
    506505            $json['data']['wpvivid_last_msg']=self::get_option('wpvivid_last_msg');
    507506            $json['data']['wpvivid_user_history']=self::get_option('wpvivid_user_history');
     507        }
     508
     509        if($backup_list){
     510            $json['data']['wpvivid_backup_list']=self::get_option('wpvivid_backup_list');
    508511        }
    509512
  • wpvivid-backuprestore/trunk/includes/class-wpvivid-zipclass.php

    r2161394 r2182172  
    216216        $ret['packages']=$packages;
    217217        $ret['temp_dir']=$temp_dir;
     218        return $ret;
     219    }
     220
     221    public function compress_additional_database($data){
     222        if(!function_exists('get_home_path'))
     223            require_once(ABSPATH . 'wp-admin/includes/file.php');
     224        global $wpvivid_plugin;
     225        $wpvivid_plugin->wpvivid_log->WriteLog('Start compressing '.$data['key'],'notice');
     226        $files = $data['files'];
     227        $temp_dir = $data['path'].'temp-'.$data['prefix'].DIRECTORY_SEPARATOR;
     228        if(!file_exists($temp_dir))
     229            @mkdir($temp_dir);
     230
     231        $package_file = array();
     232
     233        $ret['result']=WPVIVID_SUCCESS;
     234        $ret['files']=array();
     235
     236        foreach ($files as $file){
     237            $file_name = $file;
     238            $file_name = str_replace($data['path'], '', $file_name);
     239            $file_name = str_replace('.sql', '', $file_name);
     240            $path = $data['path'].$file_name.'.zip';
     241            if(isset($data['json_info']))
     242            {
     243                $package_file['json']=$data['json_info'];
     244                foreach ($data['sql_file_name'] as $sql_info){
     245                    if($file === $sql_info['file_name']){
     246                        $package_file['json']['database'] = $sql_info['database'];
     247                    }
     248                }
     249            }
     250            $package_file['json']['root_flag'] = $data['root_flag'];
     251            $package_file['json']['file']=basename($path);
     252            $package_file['path'] = $path;
     253            $package_file['files'] = $file;
     254            $wpvivid_plugin->set_time_limit($wpvivid_plugin->current_task['id']);
     255            $zip_ret=$this -> _zip($package_file['path'],$package_file['files'], $data, $package_file['json']);
     256            if($zip_ret['result']==WPVIVID_SUCCESS)
     257            {
     258                $ret['files'][] = $zip_ret['file_data'];
     259            }
     260            else
     261            {
     262                $ret=$zip_ret;
     263                break;
     264            }
     265        }
     266
     267        $wpvivid_plugin->wpvivid_log->WriteLog('Compressing '.$data['key'].' completed','notice');
    218268        return $ret;
    219269    }
  • wpvivid-backuprestore/trunk/includes/class-wpvivid.php

    r2172717 r2182172  
    123123        add_action('plugins_loaded', array($this, 'load_remote_storage'),10);
    124124
     125        add_action('wpvivid_before_setup_page',array($this,'clean_cache'));
     126        add_filter('wpvivid_check_type_database', array($this, 'wpvivid_check_type_database'), 10, 2);
    125127        //Initialisation schedule hook
    126128        $this->init_cron();
     
    173175
    174176        include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-public-interface.php';
     177
     178        include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-additional-db-method.php';
     179        include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore-db-extra.php';
    175180
    176181        $this->function_realize=new WPvivid_Function_Realize();
     
    354359        add_action('wp_ajax_wpvivid_task_monitor', array($this, 'task_monitor_ex'));
    355360        add_action('wp_ajax_wpvivid_amazons3_notice', array($this, 'amazons3_notice'));
     361
     362        add_action('wp_ajax_wpvivid_hide_mainwp_tab_page', array($this, 'hide_mainwp_tab_page'));
     363        add_action('wp_ajax_wpvivid_hide_wp_cron_notice', array($this, 'hide_wp_cron_notice'));
    356364        //wpvivid_task_monitor
    357365    }
     
    32243232    public function download_restore_progress()
    32253233    {
    3226         try {
     3234        try
     3235        {
    32273236            if (!isset($_POST['file_name'])) {
    32283237                die();
     
    32343243            $task = WPvivid_taskmanager::get_download_task_v2($_POST['file_name']);
    32353244
    3236             if ($task === false) {
     3245            if ($task === false)
     3246            {
    32373247                $check_status = false;
    32383248                $backupdir=WPvivid_Setting::get_backupdir();
     
    47494759                }
    47504760
    4751                 $json = WPvivid_Setting::export_setting_to_json($setting, $history, $review);
     4761                $backup_list = false;
     4762
     4763                $json = WPvivid_Setting::export_setting_to_json($setting, $history, $review, $backup_list);
    47524764                if (!headers_sent()) {
    47534765                    header('Content-Disposition: attachment; filename=wpvivid_setting.json');
     
    57145726        die();
    57155727    }
     5728
     5729    public function wpvivid_check_type_database($is_type_db, $data){
     5730        if(isset($data['dump_db'])){
     5731            $is_type_db = true;
     5732        }
     5733        return $is_type_db;
     5734    }
     5735
     5736    public function hide_mainwp_tab_page(){
     5737        update_option('wpvivid_hide_mwp_tab_page', true);
     5738        $ret['result']=WPVIVID_SUCCESS;
     5739        echo json_encode($ret);
     5740        die();
     5741    }
     5742
     5743    public function hide_wp_cron_notice(){
     5744        update_option('wpvivid_hide_wp_cron_notice', true);
     5745        $ret['result']=WPVIVID_SUCCESS;
     5746        echo json_encode($ret);
     5747        die();
     5748    }
    57165749}
  • wpvivid-backuprestore/trunk/wpvivid-backuprestore.php

    r2172717 r2182172  
    88 * Plugin Name:       WPvivid Backup Plugin
    99 * Description:       Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
    10  * Version:           0.9.26
     10 * Version:           0.9.27
    1111 * Author:            WPvivid Team
    1212 * Author URI:        https://wpvivid.com
     
    2222}
    2323
    24 define( 'WPVIVID_PLUGIN_VERSION', '0.9.26' );
     24define( 'WPVIVID_PLUGIN_VERSION', '0.9.27' );
    2525//
    2626define('WPVIVID_RESTORE_INIT','init');
Note: See TracChangeset for help on using the changeset viewer.