hook = add_submenu_page( Constants::ADPRESSO_SLUG, __( 'AdPresso Tools', 'adpresso' ), __( 'Tools', 'adpresso' ), adpresso_get_capability( 'use_tools' ), $this->get_id(), [ $this, 'render' ] ); } /** * Renders the complete Tools page, including tab navigation and content. * * @return void */ public function render(): void { // Instantiate the manager that handles the logic and UI rendering for the forms. $import_export_manager = Plugin::get()->globals[ ImportExportManager::class ] ?? new ImportExportManager(); $tabs = [ 'import' => __( 'Import', 'adpresso' ), 'export' => __( 'Export', 'adpresso' ), 'migration' => __( 'Migration Tools', 'adpresso' ), 'history' => __( 'Import History', 'adpresso' ), ]; // Allow add-ons to add their own tabs to the Tools page. $tabs = apply_filters( 'adpresso_tools_tabs', $tabs ); $current_tab = Params::get()->getKey( 'tab', 'import' ); $logo_url = ADPRESSO_BASE_URL . 'admin/assets/img/adpresso-logo.svg'; echo '
'; echo '
'; // Not an h1/h2: WP moves admin notices after the first .wrap h1/h2 (the hidden h2 stays that anchor). printf( '
%s
', /* translators: %s: tools tab title */ esc_html( sprintf( __( 'AdPresso Tools: %s', 'adpresso' ), $tabs[ $current_tab ] ?? __( 'Tools', 'adpresso' ) ) ) ); ?>
render_import_ui(); break; case 'export': $import_export_manager->render_export_ui(); break; case 'migration': $import_export_manager->render_migration_ui(); break; case 'history': $import_export_manager->render_history_tab(); echo '

' . esc_html__( 'A history of past imports with rollback options will be displayed here.', 'adpresso' ) . '

'; break; default: // Allow add-ons to render their custom tab content. do_action( 'adpresso_tools_render_tab_' . $current_tab ); break; } ?>
id !== 'admin_page_' . $this->get_id() ) { return; } $messages = get_transient( 'adpresso_import_messages' ); if ( false !== $messages && is_array( $messages ) ) { foreach ( $messages as $message ) { $type = $message['type'] ?? 'info'; $text = $message['message'] ?? ''; if ( $text ) { printf( '

%s

', esc_attr( $type ), esc_html( $text ) ); } } // Delete the transient so the messages don't show up again on refresh. delete_transient( 'adpresso_import_messages' ); } } /** * Enqueues scripts and styles for the Tools page. * * @param WP_Screen|null $current_screen The current WordPress screen object. * * @return void */ public function enqueue_assets( ?WP_Screen $current_screen = null ): void { if ( ! $current_screen ) { return; } /* @var Assets $assets_manager */ $assets_manager = Plugin::get()->globals[ Assets::class ] ?? null; if ( ! $assets_manager ) { return; } if ( $current_screen->id === $this->hook ) { $assets_manager->enqueue_script( 'header' ); $assets_manager->enqueue_style( 'header' ); wp_set_script_translations( 'adpresso-header', 'adpresso' ); } } }