manager = $manager; $this->options = get_option( 'mainwp_module_log_settings', array() ); if ( ! is_array( $this->options ) ) { $this->options = array(); } if ( ! isset( $this->options['enabled'] ) ) { $this->options['enabled'] = 1; MainWP_Utility::update_option( 'mainwp_module_log_settings', $this->options ); } add_action( 'admin_init', array( $this, 'admin_init' ) ); add_filter( 'mainwp_getsubpages_settings', array( $this, 'add_subpage_menu_settings' ) ); add_filter( 'mainwp_init_primary_menu_items', array( $this, 'hook_init_primary_menu_items' ), 10, 2 ); } /** * Handle admin_init action. */ public function admin_init() { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized if ( isset( $_POST['mainwp_module_log_settings_nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['mainwp_module_log_settings_nonce'] ), 'logs_settings_nonce' ) ) { $this->options['enabled'] = isset( $_POST['mainwp_module_log_enabled'] ) && ! empty( $_POST['mainwp_module_log_enabled'] ) ? 1 : 0; $this->options['auto_purge'] = isset( $_POST['mainwp_module_log_enable_auto_purge'] ) && ! empty( $_POST['mainwp_module_log_enable_auto_purge'] ) ? 1 : 0; $this->options['records_ttl'] = isset( $_POST['mainwp_module_log_records_ttl'] ) ? intval( $_POST['mainwp_module_log_records_ttl'] ) : 100; MainWP_Utility::update_option( 'mainwp_module_log_settings', $this->options ); } } /** * Init sub menu logs settings. * * @param array $subpages Sub pages. * * @action init */ public function add_subpage_menu_settings( $subpages = array() ) { $subpages[] = array( 'title' => esc_html__( 'Dashboard Insights', 'mainwp' ), 'slug' => 'Insights', 'callback' => array( $this, 'render_settings_page' ), 'class' => '', ); return $subpages; } /** * Init sub menu logs settings. * * @param array $items Sub menu items. * @param string $which_menu first|second. * * @return array $tmp_items Menu items. */ public function hook_init_primary_menu_items( $items, $which_menu ) { if ( ! is_array( $items ) || 'first' !== $which_menu ) { return $items; } $items[] = array( 'slug' => 'InsightsOverview', 'menu_level' => 2, 'menu_rights' => array( 'dashboard' => array( 'access_insights_dashboard', ), ), 'init_menu_callback' => array( static::class, 'init_menu' ), 'leftbar_order' => 2.9, ); return $items; } /** * Method init_menu() * * Add Insights Overview sub menu "Insights". */ public static function init_menu() { static::$page = add_submenu_page( 'mainwp_tab', esc_html__( 'Insights', 'mainwp' ), '' . esc_html__( 'Insights', 'mainwp' ) . '', 'read', 'InsightsOverview', array( Log_Insights_Page::instance(), 'render_insights_overview', ) ); Log_Insights_Page::init_left_menu(); if ( isset( $_GET['page'] ) && 'InsightsOverview' === $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended add_filter( 'mainwp_enqueue_script_gridster', '__return_true' ); } add_action( 'load-' . static::$page, array( static::class, 'on_load_page' ) ); } /** * Method on_load_page() * * Run on page load. */ public static function on_load_page() { Log_Insights_Page::instance()->on_load_page( static::$page ); } /** * Render Insights settings page. */ public function render_settings_page() { /** This action is documented in ../pages/page-mainwp-manage-sites.php */ do_action( 'mainwp_pageheader_settings', 'Insights' ); $enabled = ! empty( $this->options['enabled'] ) ? true : false; $enabled_auto_purge = isset( $this->options['auto_purge'] ) && ! empty( $this->options['auto_purge'] ) ? true : false; ?>

/>
/>
hide-element="auto-purge">