activity_log = $activity_log; add_action( 'admin_menu', array( $this, 'admin_menus' ), 10 ); add_action( 'admin_init', array( $this, 'setup_page' ), 10 ); } /** * Add setup admin page. */ public function admin_menus() { add_dashboard_page( '', '', 'manage_options', 'activity-log-mainwp-setup', '' ); } /** * Setup Page Start. */ public function setup_page() { // Get page argument from $_GET array. $page = null; if ( isset( $_GET['page'] ) ) { $page = \sanitize_text_field( \wp_unslash( $_GET['page'] ) ); } if ( empty( $page ) || 'activity-log-mainwp-setup' !== $page ) { return; } /** * Wizard Steps. */ $wizard_steps = array( 'welcome' => array( 'name' => __( 'Welcome', 'mwp-al-ext' ), 'content' => array( $this, 'step_welcome' ), ), 'wsal_sites' => array( 'name' => __( 'Child Sites', 'mwp-al-ext' ), 'content' => array( $this, 'step_wsal_sites' ), 'save' => array( $this, 'step_wsal_sites_save' ), ), ); /** * Filter: `Wizard Default Steps` * * Extension filter hook to filter wizard steps before they are displayed. * * @param array $wizard_steps – Wizard Steps. */ $this->wizard_steps = apply_filters( 'mwpal_wizard_default_steps', $wizard_steps ); // Set current step. $current_step = null; if ( isset( $_GET['current-step'] ) ) { $current_step = \sanitize_text_field( \wp_unslash( $_GET['current-step'] ) ); } $this->current_step = ! empty( $current_step ) ? $current_step : current( array_keys( $this->wizard_steps ) ); /** * Enqueue Styles. */ wp_enqueue_style( 'mwpal-wizard-css', trailingslashit( MWPAL_BASE_URL ) . 'assets/css/dist/mwpal-setup-wizard.build.css', array( 'dashicons', 'install', 'forms' ), filemtime( trailingslashit( MWPAL_BASE_DIR ) . 'assets/css/dist/mwpal-setup-wizard.build.css' ) ); /** * Save Wizard Settings. */ $save_step = ( isset( $_POST['save_step'] ) ) ? \sanitize_text_field( \wp_unslash( $_POST['save_step'] ) ) : \null; if ( ! empty( $save_step ) && ! empty( $this->wizard_steps[ $this->current_step ]['save'] ) ) { call_user_func( $this->wizard_steps[ $this->current_step ]['save'] ); } ob_start(); $this->setup_page_header(); $this->setup_page_steps(); $this->setup_page_content(); $this->setup_page_footer(); exit; } /** * Setup Page Header. */ private function setup_page_header() { ?> >
 ); ?>assets/img/wsal-logo-full.png)
' . esc_html__( 'Getting Started Guide', 'mwp-al-ext' ) . '' ); ?>
activity_log->settings->set_wsal_child_sites( ! empty( $selected_sites ) ? $selected_sites : false ); $this->activity_log->settings->update_option( 'setup-complete', true ); // Fetch the initial logs from the sites. if ( filter_input( INPUT_POST, 'fetch-logs-now', FILTER_VALIDATE_BOOLEAN ) && ! empty( $selected_sites ) ) { $this->fetch_initial_logs( $selected_sites ); } wp_safe_redirect( esc_url_raw( $this->get_next_step() ) ); exit(); } /** * Get initial set of logs from sites right after adding them during wizard. * * @method fetch_initial_logs * @since 1.2.0 * @param array $sites array of site ids that were just added. */ public function fetch_initial_logs( $sites ) { // get events from site. foreach ( $sites as $site ) { $sites_data[ $site ] = $this->activity_log->alerts->fetch_site_events( $site ); } // Extension is ready after retrieving. $this->activity_log->alerts->Trigger( 7712, array( 'mainwp_dash' => true, 'Username' => 'System', 'ClientIP' => $this->activity_log->settings->get_server_ip(), ) ); // Set child site events. if ( ! empty( $sites_data ) && is_array( $sites_data ) ) { $this->activity_log->alerts->set_site_events( $sites_data ); } } }