false, 'message' => esc_html__( 'Access Denied.', 'wp-security-audit-log' ), ) ); die(); } $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : false; $token = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : false; if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'wsal-verify-wizard-page' ) ) { echo wp_json_encode( array( 'success' => false, 'message' => esc_html__( 'Nonce verification failed.', 'wp-security-audit-log' ), ) ); die(); } if ( empty( $token ) ) { echo wp_json_encode( array( 'success' => false, 'message' => esc_html__( 'Invalid input.', 'wp-security-audit-log' ), ) ); die(); } echo wp_json_encode( array( 'success' => true, 'token' => $token, 'tokenType' => esc_html( Plugin_Settings_Helper::get_token_type( $token ) ), ) ); die(); } /** * Add setup admin page. * * @since 5.0.0 */ public static function admin_menus() { // this is an empty title because we do not want it to display. add_dashboard_page( '', '', 'manage_options', 'wsal-setup', '' ); // hide it via CSS as well so screen readers pass over it. add_action( 'admin_head', function () { ?> array( 'name' => __( 'Welcome', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'wsal_step_welcome' ), ), 'log_details' => array( 'name' => __( 'Log Details', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'wsal_step_log_details' ), 'save' => array( __CLASS__, 'wsal_step_log_details_save' ), ), 'login' => array( 'name' => __( 'Log In', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'wsal_step_login' ), 'save' => array( __CLASS__, 'wsal_step_login_save' ), ), 'register' => array( 'name' => __( 'User Registrations', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'wsal_step_register' ), 'save' => array( __CLASS__, 'wsal_step_register_save' ), ), 'log_retention' => array( 'name' => __( 'Log Retention', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'wsal_step_log_retention' ), 'save' => array( __CLASS__, 'wsal_step_log_retention_save' ), ), 'finish' => array( 'name' => __( 'Finish', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'wsal_step_finish' ), 'save' => array( __CLASS__, 'wsal_step_finish_save' ), ), ); /** * Filter: `Wizard Default Steps` * * WSAL filter to filter wizard steps before they are displayed. * * @param array $wizard_steps – Wizard Steps. */ self::$wizard_steps = apply_filters( 'wsal_wizard_default_steps', $wizard_steps ); // Set current step. $current_step = ( isset( $_GET['current-step'] ) ) ? \sanitize_text_field( \wp_unslash( $_GET['current-step'] ) ) : null; self::$current_step = ! empty( $current_step ) ? $current_step : current( array_keys( self::$wizard_steps ) ); // check if current step is a valid one. if ( ! array_key_exists( self::$current_step, self::$wizard_steps ) ) { self::$current_step = 'invalid-step'; } /** * Enqueue Styles. */ $wizard_css = View_Manager::get_asset_path( 'css/dist/', 'wsal-wizard', 'css', false ); wp_enqueue_style( 'wsal-wizard-css', WSAL_BASE_URL . '/' . $wizard_css, array( 'dashicons', 'install', 'forms' ), WSAL_VERSION ); /** * Enqueue Scripts. */ $wizard_js = View_Manager::get_asset_path( 'js/dist/', 'wsal-wizard', 'js', false ); wp_register_script( 'wsal-wizard-js', WSAL_BASE_URL . '/' . $wizard_js, array( 'jquery' ), WSAL_VERSION, false ); $common_js = '/js/common.js'; wp_register_script( 'wsal-common', WSAL_BASE_URL . $common_js, array( 'jquery' ), WSAL_VERSION, true ); // Data array. $data_array = array( 'ajaxURL' => admin_url( 'admin-ajax.php' ), 'nonce' => ( ( ! Settings_Helper::current_user_can( 'edit' ) ) && ! 'invalid-step' === self::$current_step ) ? wp_create_nonce( 'wsal-verify-wizard-page' ) : '', 'usersError' => esc_html__( 'Specified value in not a user.', 'wp-security-audit-log' ), 'rolesError' => esc_html__( 'Specified value in not a role.', 'wp-security-audit-log' ), 'ipError' => esc_html__( 'Specified value in not an IP address.', 'wp-security-audit-log' ), ); wp_localize_script( 'wsal-wizard-js', 'wsalData', $data_array ); $installer_script_data = array( 'ajaxURL' => admin_url( 'admin-ajax.php' ), 'installing' => esc_html__( 'Installing, please wait', 'wp-security-audit-log' ), 'already_installed' => esc_html__( 'Already installed', 'wp-security-audit-log' ), 'installed' => esc_html__( 'Extension installed', 'wp-security-audit-log' ), 'activated' => esc_html__( 'Extension activated', 'wp-security-audit-log' ), 'failed' => esc_html__( 'Install failed', 'wp-security-audit-log' ), 'reloading_page' => esc_html__( 'Reloading page', 'wp-security-audit-log' ), ); wp_localize_script( 'wsal-common', 'wsalCommonData', $installer_script_data ); /** * Save Wizard Settings. */ $save_step = ( isset( $_POST['save_step'] ) ) ? \sanitize_text_field( \wp_unslash( $_POST['save_step'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( ! empty( $save_step ) && ! empty( self::$wizard_steps[ self::$current_step ]['save'] ) ) { call_user_func( self::$wizard_steps[ self::$current_step ]['save'] ); } self::setup_page_header(); self::setup_page_steps(); self::setup_page_content(); self::setup_page_footer(); exit; } /** * Setup Page Header. * * @since 5.0.0 */ private static function setup_page_header() { ?> > <?php esc_html_e( 'WP Activity Log › Setup Wizard', 'wp-security-audit-log' ); ?>

WP Activity Log

'; printf( /* translators: 1 - an opening link tag, 2 - a closing link tag. */ esc_html__( 'You have reached an invaild step - %1$sreturn to the start of the wizard%2$s.', 'wp-security-audit-log' ), '', '' ); echo '

'; } /** * Step View: `Welcome` * * @since 5.0.0 */ private static function wsal_step_welcome() { // Dismiss the setup modal in case if not already done. if ( ! Settings_Helper::get_boolean_option_value( 'setup-modal-dismissed', false ) ) { Settings_Helper::set_boolean_option_value( 'setup-modal-dismissed', true, true ); } ?>






upgrade to Premium and use the Database tools to store the WordPress activity log in an external database.', 'wp-security-audit-log' ); echo wp_kses( $step_help, Plugin_Settings_Helper::get_allowed_html_tags() ); ?>

array( 'name' => __( 'Third Party Extensions', 'wp-security-audit-log' ), 'content' => array( __CLASS__, 'addons_step' ), 'save' => array( __CLASS__, 'addons_step_save' ), ), ); // Count number of items in the array. $number_of_steps = count( $wizard_steps ); // Subtract 1, as we want to insert our step one before the last item. --$number_of_steps; // Slice the steps up, so we have 2 parts we can insert our slide between. $first_part = array_slice( $wizard_steps, 0, $number_of_steps, true ); $last_part = array_slice( $wizard_steps, -1, 1, true ); // combine the two arrays. $wizard_steps = $first_part + $new_wizard_steps + $last_part; return $wizard_steps; } /** * Renders wizard step showing available add-ons. * * @since 5.0.0 */ private static function addons_step() { $our_plugins = Plugins_Helper::get_installable_plugins(); // Grab list of installed plugins. $all_plugins = get_plugins(); $plugin_filenames = array(); foreach ( $all_plugins as $plugin => $info ) { $plugin_info = pathinfo( $plugin ); $plugin_filenames[] = $plugin_info['filename']; } // Grab list of plugins we have addons for. $predefined_plugins = array_column( $our_plugins, 'addon_for' ); // Loop through plugins and create an array of slugs, we will compare these against the plugins we have addons for. $we_have_addon = array_intersect( $plugin_filenames, $predefined_plugins ); ?>