model = new Model\Security(); $this->request = new Model\Request(); add_action( 'admin_init', array( &$this, 'verify_vulnerabilities' ) ); add_action( 'activated_plugin', array( &$this, 'verify_all' ) ); add_action( 'deactivated_plugin', array( &$this, 'verify_deactivated_plugin' ) ); add_action( 'after_switch_theme', array( &$this, 'verify_all' ) ); add_action( 'deleted_plugin', array( &$this, 'verify_deleted_plugin' ), 10, 2 ); add_action( 'admin_notices', array( &$this, 'show_notices' ) ); add_action( 'admin_menu', array( &$this, 'add_menu_controls' ) ); add_action( 'admin_menu', array( &$this, 'add_menu_bubble' ) ); add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu' ), 95 ); } public function request_send( $data, $show_success = false ) { $messages = new Model\Messages(); $status = $this->request->send( $data ); if ( ! $status['success'] ) { $messages->error( $status['error']['message'] ); return; } if ( $show_success ) { $messages->success( esc_html__( 'A new report was requested, soon we will have its result.', Core::SLUG ) ); } } public function verify_deleted_plugin( $plugin, $deleted ) { if ( $deleted ) { $this->request_send( $this->model->get_data_removed_plugin( $plugin ) ); } } public function verify_deactivated_plugin( $plugin ) { $this->request_send( $this->model->get_data_deactivated_plugin( $plugin ) ); } public function verify_vulnerabilities() { if ( ! Utils::get( 'care-verify' ) ) { return; } $this->request_send( $this->model->get_data(), true ); } public function verify_plugin( $plugin, $network_activation ) { $info = $this->model->get_single_plugin( $plugin ); if ( $info && strpos( $plugin, Core::SLUG ) === false ) { $this->request_send( $info ); } } public function verify_theme() { $info = $this->model->get_single_theme( get_stylesheet() ); if ( $info ) { $this->request_send( $info ); } } public function verify_all() { $this->request_send( $this->model->get_data() ); } public function show_notices() { $viewed = get_option( 'apiki_wp_care_response_viewed' ); $response = get_option( 'apiki_wp_care_response' ); $pages = array( Core::SLUG . '-stats-checker', Core::SLUG . '-stats-dashboard', Core::SLUG . '-stats-credits', ); if ( in_array( Utils::get( 'page' ), $pages, true ) ) { return; } if ( $response && ! $viewed ) : ?>
get_icon_svg(), self::MENU_POSITION ); add_submenu_page( Core::SLUG . '-stats-dashboard', esc_html__( 'Dashboard', Core::SLUG ), esc_html__( 'Dashboard', Core::SLUG ), 'manage_options', Core::SLUG . '-stats-dashboard', array( 'Apiki\Care\View\Dashboard', 'render_page' ) ); add_submenu_page( Core::SLUG . '-stats-dashboard', esc_html__( 'Security Alerts', Core::SLUG ), esc_html__( 'Security Alerts', Core::SLUG ), 'manage_options', Core::SLUG . '-stats-checker', array( 'Apiki\Care\View\Security', 'render_stats' ) ); add_submenu_page( Core::SLUG . '-stats-dashboard', esc_html__( 'Credits', Core::SLUG ), esc_html__( 'Credits', Core::SLUG ), 'manage_options', Core::SLUG . '-stats-credits', array( 'Apiki\Care\View\Credit', 'render_page' ) ); } public function admin_bar_menu() { if ( ! current_user_can( 'edit_posts' ) ) { return; } global $wp_admin_bar; $user_is_admin_or_networkadmin = current_user_can( 'manage_options' ); if ( ! $user_is_admin_or_networkadmin && is_multisite() ) { $user_is_admin_or_networkadmin = ( $options['access'] === 'superadmin' && is_super_admin() ); } if ( ! $user_is_admin_or_networkadmin ) { return; } $awpc_url = get_admin_url( null, 'admin.php?page=' . Core::SLUG . '-stats-checker' ); $report = new Report(); $resume = $report->get_resume_vulnerabilities(); $counter = $resume['total']; $_icon = sprintf( '