| @@ -6,8 +6,13 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace MainWP\Dashboard; |
| 9 | 9 | |
| 10 | +// Exit if accessed directly. | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 10 | 15 | /** |
| 11 | 16 | * Class MainWP_Post_Backup_Handler |
| 12 | 17 | * |
| 13 | 18 | * Handle Backup Post. |
| @@ -43,12 +48,12 @@ | ||
| 43 | 48 | */ |
| 44 | 49 | public function init() { |
| 45 | 50 | // Page: ManageBackups. |
| 46 | 51 | $this->add_action( 'mainwp_addbackup', array( &$this, 'mainwp_addbackup' ) ); |
| 47 | - if ( mainwp_current_user_have_right( 'dashboard', 'edit_backup_tasks' ) ) { | |
| 52 | + if ( \mainwp_current_user_can( 'dashboard', 'edit_backup_tasks' ) ) { | |
| 48 | 53 | $this->add_action( 'mainwp_updatebackup', array( &$this, 'mainwp_updatebackup' ) ); |
| 49 | 54 | } |
| 50 | - if ( mainwp_current_user_have_right( 'dashboard', 'delete_backup_tasks' ) ) { | |
| 55 | + if ( \mainwp_current_user_can( 'dashboard', 'delete_backup_tasks' ) ) { | |
| 51 | 56 | $this->add_action( 'mainwp_removebackup', array( &$this, 'mainwp_removebackup' ) ); |
| 52 | 57 | } |
| 53 | 58 | $this->add_action( 'mainwp_pausebackup', array( &$this, 'mainwp_pausebackup' ) ); |
| 54 | 59 | $this->add_action( 'mainwp_resumebackup', array( &$this, 'mainwp_resumebackup' ) ); |
| @@ -54,18 +59,18 @@ | ||
| 54 | 59 | $this->add_action( 'mainwp_resumebackup', array( &$this, 'mainwp_resumebackup' ) ); |
| 55 | 60 | |
| 56 | 61 | $this->add_action( 'mainwp_backuptask_get_sites', array( &$this, 'mainwp_backuptask_get_sites' ) ); |
| 57 | 62 | |
| 58 | - if ( mainwp_current_user_have_right( 'dashboard', 'run_backup_tasks' ) ) { | |
| 63 | + if ( \mainwp_current_user_can( 'dashboard', 'run_backup_tasks' ) ) { | |
| 59 | 64 | $this->add_action( 'mainwp_backuptask_run_site', array( &$this, 'mainwp_backuptask_run_site' ) ); |
| 60 | 65 | } |
| 61 | 66 | $this->add_action( 'mainwp_backup_upload_file', array( &$this, 'mainwp_backup_upload_file' ) ); |
| 62 | 67 | |
| 63 | 68 | // Page: backup. |
| 64 | - if ( mainwp_current_user_have_right( 'dashboard', 'run_backup_tasks' ) ) { | |
| 69 | + if ( \mainwp_current_user_can( 'dashboard', 'run_backup_tasks' ) ) { | |
| 65 | 70 | $this->add_action( 'mainwp_backup_run_site', array( &$this, 'mainwp_backup_run_site' ) ); |
| 66 | 71 | } |
| 67 | - if ( mainwp_current_user_have_right( 'dashboard', 'execute_backups' ) ) { | |
| 72 | + if ( \mainwp_current_user_can( 'dashboard', 'execute_backups' ) ) { | |
| 68 | 73 | $this->add_action( 'mainwp_backup', array( &$this, 'ajax_mainwp_backup' ) ); |
| 69 | 74 | } |
| 70 | 75 | $this->add_action( 'mainwp_checkbackups', array( &$this, 'mainwp_checkbackups' ) ); |
| 71 | 76 | $this->add_action( 'mainwp_backup_checkpid', array( &$this, 'mainwp_backup_checkpid' ) ); |
| @@ -461,9 +466,9 @@ | ||
| 461 | 466 | |
| 462 | 467 | if ( ! is_array( $array ) || ! isset( $array[ $unique ] ) ) { |
| 463 | 468 | die( wp_json_encode( array( 'result' => 0 ) ) ); |
| 464 | 469 | } elseif ( isset( $array[ $unique ]['finished'] ) ) { |
| 465 | - throw new MainWP_Exception( esc_html__( 'finished...', 'maiwnp' ) ); | |
| 470 | + throw new MainWP_Exception( esc_html__( 'finished...', 'mainwp' ) ); | |
| 466 | 471 | } else { |
| 467 | 472 | wp_send_json( array( 'result' => ( isset( $array[ $unique ]['offset'] ) ? $array[ $unique ]['offset'] : $array[ $unique ] ) ) ); |
| 468 | 473 | } |
| 469 | 474 | } catch ( MainWP_Exception $e ) { |