WSAL_BASE_FILE_NAME, 'api' => basename( __FILE__, '.php' ), 'mainwp' => false, 'callback' => array( __CLASS__, 'display_extension' ), 'icon' => trailingslashit( self::MWPAL_BASE_URL ) . 'assets/img/activity-log-mainwp-500x500.jpg', ); return $plugins; } /** * Sets the proper view type so it can trigger the proper list of operations needed for this to work. * * @param bool $view - The boolean status of the view. * * @return boolean * * @since 5.0.0 */ public static function is_that_auditlog_view( $view ): bool { // TODO: check page and return bool based on that - that is for the search filters firing. $view = true; return $view; } /** * Extension Display on MainWP Dashboard. * * @since 5.0.0 */ public static function display_extension() { // The "mainwp_pageheader_extensions" action is used to render the tabs on the Extensions screen. // It's used together with mainwp_pagefooter_extensions and mainwp-getextensions. do_action( 'mainwp_pageheader_extensions', __FILE__ ); \WSAL_Views_AuditLog::header(); \add_filter( 'wsal_override_is_multisite', '__return_true' ); $events_list = new List_Events( \WSAL_Views_AuditLog::get_page_arguments() ); \remove_filter( 'wsal_override_is_multisite', '__return_true' ); $events_list->prepare_items(); $view_input_value = 'list'; $site_id = MainWP_Settings::get_view_site_id(); ?>
_view - Audit log view object. */ do_action( 'wsal_auditlog_before_view', $events_list ); /** * Action: `wsal_search_filters_list` * * Display list of search filters of WSAL. * * @param string $which – Navigation position; value is either top or bottom. * @since 3.2.3 */ do_action( 'wsal_search_filters_list', 'top' ); ?> display(); /** * Hook: `wsal_auditlog_after_view` * * This action hook is triggered after displaying the audit log view. * * @param WSAL_AuditLogListView $this->_view - Audit log view object. */ do_action( 'wsal_auditlog_after_view', $events_list ); ?>
__( 'Extension Settings', 'wp-security-audit-log' ), 'href' => self::$mwpal_extension_tabs['settings']['link'], 'active' => 'settings' === self::$current_tab, ), ) ); foreach ( $extension_tabs as $tab ) { $page_tabs[] = $tab; } return $page_tabs; } /** * Sets the extension tabs in the navigation. * * @return void * * @since 5.0.0 */ public static function setup_extension_tabs() { global $_mainwp_menu_active_slugs; $_mainwp_menu_active_slugs[ MWPAL_EXTENSION_NAME ] = MWPAL_EXTENSION_NAME; // Extension view URL. $extension_url = add_query_arg( 'page', MWPAL_EXTENSION_NAME, \network_admin_url( 'admin.php' ) ); // Tab links. $mwpal_extension_tabs = array( 'activity-log' => array( 'name' => __( 'Activity Log', 'wp-security-audit-log' ), 'link' => $extension_url, 'render' => array( __CLASS__, 'tab_activity_log' ), 'save' => array( __CLASS__, 'tab_activity_log_save' ), ), ); /** * `mwpal_extension_tabs` * * This filter is used to filter the tabs of WSAL settings page. * * Setting tabs structure: * $mwpal_extension_tabs['unique-tab-id'] = array( * 'name' => Name of the tab, * 'link' => Link of the tab, * 'render' => This function is used to render HTML elements in the tab, * 'name' => This function is used to save the related setting of the tab, * ); * * @param array $mwpal_extension_tabs - Array of extension tabs. * @param string $extension_url - URL of the extension. */ self::$mwpal_extension_tabs = apply_filters( 'mwpal_extension_tabs', $mwpal_extension_tabs, $extension_url ); // Get the current tab. $current_tab = ( isset( $_GET['tab'] ) ) ? \sanitize_text_field( \wp_unslash( $_GET['tab'] ) ) : null; self::$current_tab = empty( $current_tab ) ? 'activity-log' : $current_tab; } /** * Get WSAL Child Sites. * * @return array * * @since 5.0.0 */ public static function get_wsal_child_sites() { // Check if the WSAL child sites option exists. $child_sites = Settings_Helper::get_option_value( 'wsal-child-sites' ); // Get MainWP Child sites. $mwp_sites = MainWP_Settings::get_mwp_child_sites(); if ( empty( $child_sites ) && ! empty( $mwp_sites ) ) { foreach ( $mwp_sites as $site ) { // Call to child sites to check if WSAL is installed on them or not. $results[ $site['id'] ] = self::make_api_call( $site['id'], 'check_wsal' ); } if ( ! empty( $results ) && is_array( $results ) ) { $child_sites = array(); foreach ( $results as $site_id => $site_array ) { if ( empty( $site_array ) || ! is_array( $site_array ) ) { continue; } elseif ( is_array( $site_array ) && isset( $site_array['wsal_installed'] ) && true === $site_array['wsal_installed'] ) { $child_sites[ $site_id ] = $site_array; } } Settings_Helper::set_option_value( 'wsal-child-sites', $child_sites ); } } return $child_sites; } /** * Makes an API call to a child site. * * @param int $site_id Site ID. * @param string $action Action attribute. * @param array $extra_data Extra arguments. * * @return false|stdClass * * @since 2.0.0 */ public static function make_api_call( $site_id, $action, $extra_data = array() ) { // Return if site id is empty. if ( empty( $site_id ) ) { return false; } // Post data for child sites. $post_data = array( 'action' => $action, ); if ( is_array( $extra_data ) && ! empty( $extra_data ) ) { $post_data = array_merge( $post_data, $extra_data ); } // Call the child site. return apply_filters( 'mainwp_fetchurlauthed', WSAL_BASE_FILE_NAME, self::get_child_key(), $site_id, 'extra_excution', $post_data ); } } }