From ad2aa48b972b544d7d3c02393659471fbe9a0ad0 Mon Sep 17 00:00:00 2001 From: idtemankampus-creator Date: Fri, 18 Sep 2026 08:22:45 +0700 Subject: [PATCH] feat(ux): add activation redirect, loading state overlay, and direct view list button in notice --- dummylab.php | 88 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 14 deletions(-) diff --git a/dummylab.php b/dummylab.php index c86102d..ba253c5 100644 --- a/dummylab.php +++ b/dummylab.php @@ -3,7 +3,7 @@ * Plugin Name: DummyLab โ€“ Dummy Post & Content Generator * Plugin URI: https://apps.masbudikusuma.my.id/dummylab-wp * Description: Advanced dummy content generator for WordPress development with safety controls and bulk purge features. - * Version: 1.1.0 + * Version: 1.2.0 * Author: masbudikusuma * Author URI: https://masbudi.my.id * Text Domain: dummylab @@ -28,10 +28,25 @@ class DummyLab { private function __construct() { add_action('admin_menu', [$this, 'add_admin_menu']); + add_action('admin_init', [$this, 'handle_activation_redirect']); add_action('admin_post_dummylab_generate', [$this, 'handle_generate']); add_action('admin_post_dummylab_purge', [$this, 'handle_purge']); } + public static function activate_plugin() { + add_option('dummylab_do_activation_redirect', true); + } + + public function handle_activation_redirect() { + if (get_option('dummylab_do_activation_redirect', false)) { + delete_option('dummylab_do_activation_redirect'); + if (!isset($_GET['activate-multi'])) { + wp_safe_redirect(admin_url('tools.php?page=dummylab')); + exit; + } + } + } + public function add_admin_menu() { add_management_page( 'DummyLab Generator', @@ -99,21 +114,33 @@ class DummyLab { .dummylab-badge-count { display: inline-block; background: #fcf0f0; color: #d63638; font-weight: 700; font-size: 16px; padding: 4px 12px; border-radius: 20px; border: 1px solid #f5c6cb; margin-left: 6px; } .dummylab-guide-list { margin: 0; padding-left: 20px; color: #3c434a; font-size: 13px; line-height: 1.6; } .dummylab-guide-list li { margin-bottom: 8px; } - .dummylab-guide-list li:last-child { margin-bottom: 0; } - .dummylab-safety-list { margin: 0; padding-left: 18px; color: #3c434a; font-size: 13px; line-height: 1.6; list-style-type: square; } .dummylab-safety-list li { margin-bottom: 6px; } - .dummylab-btn-primary { background: #2271b1 !important; border-color: #2271b1 !important; border-radius: 6px !important; padding: 6px 18px !important; font-size: 14px !important; height: auto !important; } + .dummylab-btn-primary { background: #2271b1 !important; border-color: #2271b1 !important; border-radius: 6px !important; padding: 8px 20px !important; font-size: 14px !important; height: auto !important; cursor: pointer; } .dummylab-btn-danger { background: #d63638 !important; border-color: #d63638 !important; color: #fff !important; border-radius: 6px !important; padding: 6px 18px !important; font-size: 13px !important; height: auto !important; width: 100%; text-align: center; } .dummylab-btn-danger:disabled { background: #f6f7f7 !important; border-color: #dcdcde !important; color: #a7aaad !important; cursor: not-allowed; } + + /* Loading Overlay Styles */ + .dummylab-loading-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); z-index: 999999; align-items: center; justify-content: center; flex-direction: column; color: #fff; } + .dummylab-spinner { width: 50px; height: 50px; border: 5px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: #38bdf8; animation: dummylab-spin 1s ease-in-out infinite; margin-bottom: 16px; } + @keyframes dummylab-spin { to { transform: rotate(360deg); } } + .dummylab-loading-text { font-size: 18px; font-weight: 600; text-align: center; } + .dummylab-loading-subtext { font-size: 13px; color: #cbd5e1; margin-top: 6px; text-align: center; } + +
+
+
+
+
+
-

๐Ÿงช DummyLab v1.1.0

+

๐Ÿงช DummyLab v1.2.0

masbudikusuma

@@ -124,13 +151,18 @@ class DummyLab {
-
-

+

+

' . esc_html(intval($_GET['count'])) . ' ' . esc_html($t['msg_generated']); + $gen_type = isset($_GET['type']) && $_GET['type'] === 'page' ? 'page' : 'post'; + $type_label = ($gen_type === 'page') ? ($ui_lang === 'en' ? 'Pages' : 'Halaman (Page)') : ($ui_lang === 'en' ? 'Posts' : 'Post'); + $target_url = ($gen_type === 'page') ? admin_url('edit.php?post_type=page') : admin_url('edit.php'); + + echo '๐ŸŽ‰ ' . esc_html(intval($_GET['count'])) . ' ' . esc_html($t['msg_generated']) . ' ' . sprintf(esc_html($t['check_msg']), '' . esc_html($type_label) . '') . ''; + echo '' . esc_html($t['btn_view_list']) . ' ' . esc_html($type_label) . ' →'; } elseif ($_GET['status'] === 'purged') { - echo '๐Ÿงน ' . esc_html(intval($_GET['count'])) . ' ' . esc_html($t['msg_purged']); + echo '๐Ÿงน ' . esc_html(intval($_GET['count'])) . ' ' . esc_html($t['msg_purged']) . ''; } ?>

@@ -140,7 +172,7 @@ class DummyLab {
-
+ @@ -238,7 +270,7 @@ class DummyLab {
- +
@@ -283,6 +315,25 @@ class DummyLab {
+ + 'Created by', 'plugin_doc' => 'Plugin Documentation', - 'msg_generated' => 'dummy posts generated successfully!', + 'msg_generated' => 'dummy item(s) generated successfully!', + 'check_msg' => 'Please check your %s section.', + 'btn_view_list' => 'View List of', 'msg_purged' => 'dummy items deleted successfully!', + 'loading_title' => 'Generating dummy content...', + 'loading_subtitle' => 'Please wait a few moments while we create your test data and images.', 'sec_general' => 'General Settings', 'sec_taxonomy' => 'Taxonomy & Author', 'sec_content' => 'Content & Media', @@ -331,7 +386,7 @@ class DummyLab { 'purge_title' => 'Cleanup & Purge', 'purge_active' => 'Active dummy items', 'purge_desc' => 'Permanently deletes all posts, pages, and media attachments created by DummyLab.', - 'btn_purge' => 'Hapus Semua Data Dummy', + 'btn_purge' => 'Delete All Dummy Data', 'guide_title' => 'Quick Usage Guide', 'guide_step1' => 'Select total count and content type (Post/Page).', 'guide_step2' => 'Choose generated text language and length.', @@ -348,7 +403,11 @@ class DummyLab { 'created_by' => 'Dibuat oleh', 'plugin_doc' => 'Dokumentasi Plugin', 'msg_generated' => 'konten dummy berhasil dibuat!', + 'check_msg' => 'Silakan cek daftar %s Anda.', + 'btn_view_list' => 'Lihat Daftar', 'msg_purged' => 'data dummy berhasil dibersihkan!', + 'loading_title' => 'Sedang membuat konten dummy...', + 'loading_subtitle' => 'Mohon tunggu beberapa saat. Server sedang mengunduh gambar dan membuat data artikel.', 'sec_general' => 'Pengaturan Utama', 'sec_taxonomy' => 'Taksonomi & Penulis', 'sec_content' => 'Konten & Media', @@ -517,7 +576,7 @@ class DummyLab { } } - wp_redirect(admin_url('tools.php?page=dummylab&ui_lang=' . $ui_lang . '&status=generated&count=' . $count)); + wp_redirect(admin_url('tools.php?page=dummylab&ui_lang=' . $ui_lang . '&status=generated&count=' . $count . '&type=' . $post_type)); exit; } @@ -600,4 +659,5 @@ class DummyLab { } } +register_activation_hook(__FILE__, ['DummyLab', 'activate_plugin']); DummyLab::get_instance();