is_tools_page() ) { $this->init_view(); $this->hooks(); } elseif ( wp_doing_ajax() ) { ( new Importers() )->load(); } } /** * Check if we're on tools page. * * @since 1.6.6 * * @return bool */ private function is_tools_page() { $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; //phpcs:ignore WordPress.Security // Only load if we are actually on the settings page. return $page === self::SLUG; } /** * Init current view. * * @since 1.6.6 */ private function init_view() { $view_ids = array_keys( $this->get_views() ); // Determine the current active settings tab. $this->active_view_slug = ! empty( $_GET['view'] ) ? sanitize_key( $_GET['view'] ) : 'import'; //phpcs:ignore WordPress.Security.NonceVerification.Recommended // If the user tries to load an invalid view - fallback to the first available. if ( ! in_array( $this->active_view_slug, $view_ids, true ) && ! has_action( 'wpforms_tools_display_tab_' . $this->active_view_slug ) ) { $this->active_view_slug = reset( $view_ids ); } if ( isset( $this->views[ $this->active_view_slug ] ) ) { $this->view = $this->views[ $this->active_view_slug ]; $this->view->init(); } } /** * Get Views. * * @since 1.6.6 * * @return array */ public function get_views() { if ( empty( $this->views ) ) { $this->views = [ 'import' => new Views\Import(), 'importer' => new Views\Importer(), 'export' => new Views\Export(), 'system' => new Views\System(), 'action-scheduler' => new Views\ActionScheduler(), 'logs' => new Views\Logs(), ]; } $this->views = apply_filters( 'wpforms_tools_views', $this->views ); return array_filter( $this->views, static function ( $view ) { return $view->check_capability(); } ); } /** * Register hooks. * * @since 1.6.6 */ public function hooks() { add_action( 'wpforms_admin_page', [ $this, 'output' ] ); // Hook for addons. do_action( 'wpforms_tools_init' ); } /** * Build the output for the Tools admin page. * * @since 1.6.6 */ public function output() { ?>
view && $this->view->show_nav() ) { echo ''; } ?>

view ) { $this->view->display(); } else { do_action( 'wpforms_tools_display_tab_' . $this->active_view_slug ); } ?>