' . $donate_label . ''; } return $links; } public function add_admin_menu() { add_management_page( 'DummyLab Generator', 'DummyLab', 'manage_options', 'dummylab', [$this, 'render_admin_page'] ); } public function render_admin_page() { if (!current_user_can('manage_options')) { return; } $ui_lang = isset($_GET['ui_lang']) && $_GET['ui_lang'] === 'en' ? 'en' : 'id'; $current_tab = isset($_GET['tab']) && $_GET['tab'] === 'history' ? 'history' : 'generator'; $users = get_users(['fields' => ['ID', 'display_name']]); $query = new WP_Query([ 'post_type' => ['post', 'page', 'attachment'], 'posts_per_page' => -1, 'meta_key' => $this->meta_key, 'meta_value' => '1', 'fields' => 'ids', 'post_status' => 'any', ]); $dummy_count = $query->found_posts; $t = $this->get_translations($ui_lang); ?>

๐Ÿงช DummyLab v1.5.0

masbudikusumaโ˜•

๐Ÿš€ ๐Ÿ“œ ()

๐ŸŽ‰ ' . 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']) . ''; } elseif ($_GET['status'] === 'deleted_single') { echo '๐Ÿ—‘๏ธ ' . esc_html($t['msg_deleted_single']) . ''; } ?>

โš™๏ธ
๐Ÿท๏ธ

๐Ÿ“

๐Ÿ—‘๏ธ

:

($dummy_count === 0)]); ?>

๐Ÿ“˜

๐Ÿ›ก๏ธ

๐Ÿ“œ

['post', 'page'], 'posts_per_page' => 50, 'meta_key' => $this->meta_key, 'meta_value' => '1', 'post_status' => 'any', ]); ?> have_posts()): ?> have_posts()): $history_query->the_post(); $item_id = get_the_ID(); $item_type = get_post_type($item_id); $edit_link = get_edit_post_link($item_id); $view_link = get_permalink($item_id); ?>
๐Ÿ–ผ๏ธ Image

'Created by', 'plugin_doc' => 'Plugin Documentation', 'link_donate' => 'Donate Support', 'tab_generator' => 'Generator', 'tab_history' => 'Generated History', '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!', 'msg_deleted_single' => 'Dummy item 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', 'lbl_count' => 'Post/Page Count', 'lbl_type' => 'Content Type', 'opt_post' => 'Post', 'opt_page' => 'Page', 'lbl_content_lang' => 'Content Language', 'lbl_status' => 'Post Status', 'opt_publish' => 'Publish', 'opt_draft' => 'Draft', 'opt_pending' => 'Pending Review', 'opt_private' => 'Private', 'lbl_cats' => 'Categories', 'desc_cats' => 'Categories created automatically if not present. Comma-separated.', 'lbl_tags' => 'Additional Tags', 'desc_tags' => 'Optional, comma-separated tags.', 'lbl_author' => 'Author', 'opt_random_author' => 'Random from all users', 'lbl_date' => 'Post Date', 'opt_date_now' => 'Current time', 'opt_date_past' => 'Random in past few days', 'opt_date_future' => 'Future date (Scheduled)', 'lbl_length' => 'Article Length', 'opt_len_short' => 'Short (2-3 paragraphs)', 'opt_len_medium' => 'Medium (4-6 paragraphs + heading)', 'opt_len_long' => 'Long (7-10 paragraphs + heading, quote)', 'lbl_image_source' => 'Image Source Method', 'opt_img_picsum' => 'Picsum Photos (Online - High Quality Photos)', 'opt_img_svg' => 'SVG Placeholder (100% Offline & Fast)', 'lbl_image_size' => 'Featured Image Size', 'opt_use_img' => 'Include featured image', 'opt_img_small' => 'Small (800x600)', 'opt_img_med' => 'Medium (1200x800)', 'opt_img_large' => 'Large (1600x1000)', 'opt_comments' => 'Include dummy comments', 'opt_sticky' => 'Make first post sticky (Post type only)', 'btn_generate' => '๐Ÿš€ Generate Dummy Data', 'purge_title' => 'Cleanup & Purge', 'purge_active' => 'Active dummy items', 'purge_desc' => 'Permanently deletes all posts, pages, and media attachments created by DummyLab.', '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.', 'guide_step3' => 'Choose between online photos or offline fast SVG images.', 'guide_step4' => 'Click Purge anytime to completely clean test data.', 'safety_title' => 'Development Safety', 'safety_item1' => 'All dummy posts tracked via unique metadata key.', 'safety_item2' => 'Clean purge removes featured images from Media Library.', 'safety_item3' => 'Safe for staging and local theme testing.', 'history_title' => 'Generated Dummy Content List', 'history_desc' => 'List of all posts and pages currently generated by DummyLab.', 'th_title' => 'Title', 'th_type' => 'Type', 'th_status' => 'Status', 'th_author' => 'Author', 'th_date' => 'Date', 'th_action' => 'Actions', 'empty_history' => 'No dummy content generated yet.', ]; } return [ 'created_by' => 'Dibuat oleh', 'plugin_doc' => 'Dokumentasi Plugin', 'link_donate' => 'Dukung Donasi', 'tab_generator' => 'Generator', 'tab_history' => 'Riwayat Konten', 'msg_generated' => 'konten dummy berhasil dibuat!', 'check_msg' => 'Silakan cek daftar %s Anda.', 'btn_view_list' => 'Lihat Daftar', 'msg_purged' => 'data dummy berhasil dibersihkan!', 'msg_deleted_single' => 'Item dummy berhasil dihapus.', 'loading_title' => 'Sedang membuat konten dummy...', 'loading_subtitle' => 'Mohon tunggu beberapa saat. Server sedang memproses data artikel dan gambar.', 'sec_general' => 'Pengaturan Utama', 'sec_taxonomy' => 'Taksonomi & Penulis', 'sec_content' => 'Konten & Media', 'lbl_count' => 'Jumlah Post/Halaman', 'lbl_type' => 'Tipe Konten', 'opt_post' => 'Post', 'opt_page' => 'Halaman (Page)', 'lbl_content_lang' => 'Bahasa Konten', 'lbl_status' => 'Status Post', 'opt_publish' => 'Publish (terbit)', 'opt_draft' => 'Draft', 'opt_pending' => 'Pending Review', 'opt_private' => 'Private', 'lbl_cats' => 'Kategori', 'desc_cats' => 'Kategori dibuat otomatis jika belum ada. Pisahkan dengan koma.', 'lbl_tags' => 'Tag Tambahan', 'desc_tags' => 'Opsional, pisahkan dengan koma.', 'lbl_author' => 'Penulis', 'opt_random_author' => 'Acak dari semua pengguna', 'lbl_date' => 'Tanggal Post', 'opt_date_now' => 'Waktu sekarang', 'opt_date_past' => 'Acak dalam beberapa hari terakhir', 'opt_date_future' => 'Rentang tanggal tertentu (Scheduled)', 'lbl_length' => 'Panjang Artikel', 'opt_len_short' => 'Pendek (2-3 paragraf)', 'opt_len_medium' => 'Sedang (4-6 paragraf + heading)', 'opt_len_long' => 'Panjang (7-10 paragraf + heading, quote)', 'lbl_image_source' => 'Metode Sumber Gambar', 'opt_img_picsum' => 'Picsum Photos (Online - Foto Asli Realistis)', 'opt_img_svg' => 'SVG Placeholder (100% Offline & Super Cepat)', 'lbl_image_size' => 'Ukuran Gambar Unggulan', 'opt_use_img' => 'Sertakan gambar unggulan', 'opt_img_small' => 'Kecil (800x600)', 'opt_img_med' => 'Sedang (1200x800)', 'opt_img_large' => 'Besar (1600x1000)', 'opt_comments' => 'Sertakan komentar dummy', 'opt_sticky' => 'Jadikan post pertama sebagai sticky post (khusus Post)', 'btn_generate' => '๐Ÿš€ Generate Data Dummy', 'purge_title' => 'Pembersihan & Purge', 'purge_active' => 'Total data dummy aktif', 'purge_desc' => 'Tindakan ini akan menghapus permanen seluruh post, page, dan gambar yang dibuat oleh DummyLab.', 'btn_purge' => 'Hapus Semua Data Dummy', 'guide_title' => 'Panduan Penggunaan', 'guide_step1' => 'Pilih jumlah data dan tipe konten (Post atau Halaman).', 'guide_step2' => 'Atur bahasa dan panjang artikel yang akan dihasilkan.', 'guide_step3' => 'Pilih sumber gambar online (foto asli) atau offline (SVG instan).', 'guide_step4' => 'Gunakan tombol Purge untuk menghapus semua data pengujian.', 'safety_title' => 'Pengembangan Aman', 'safety_item1' => 'Setiap postingan dummy dilindungi metadata internal unik.', 'safety_item2' => 'Fitur Purge juga membersihkan berkas gambar dari Media Library.', 'safety_item3' => 'Aman digunakan pada lingkungan staging maupun lokal.', 'history_title' => 'Daftar Konten Dummy Dihasilkan', 'history_desc' => 'Daftar seluruh artikel dan halaman dummy yang aktif dibuat oleh DummyLab.', 'th_title' => 'Judul', 'th_type' => 'Tipe', 'th_status' => 'Status', 'th_author' => 'Penulis', 'th_date' => 'Tanggal', 'th_action' => 'Aksi', 'empty_history' => 'Belum ada konten dummy yang dibuat.', ]; } public function handle_generate() { if (!current_user_can('manage_options') || !check_admin_referer('dummylab_generate_action', 'dummylab_nonce')) { wp_die('Akses ditolak.'); } require_once(ABSPATH . 'wp-admin/includes/image.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); $ui_lang = isset($_POST['ui_lang']) ? sanitize_text_field($_POST['ui_lang']) : 'id'; $count = isset($_POST['post_count']) ? min(50, max(1, intval($_POST['post_count']))) : 5; $post_type = isset($_POST['post_type']) && in_array($_POST['post_type'], ['post', 'page']) ? $_POST['post_type'] : 'post'; $lang = isset($_POST['content_lang']) ? sanitize_text_field($_POST['content_lang']) : 'id'; $status = isset($_POST['post_status']) ? sanitize_text_field($_POST['post_status']) : 'publish'; $categories_raw = isset($_POST['categories']) ? sanitize_text_field($_POST['categories']) : ''; $tags_raw = isset($_POST['tags']) ? sanitize_text_field($_POST['tags']) : ''; $author_opt = isset($_POST['post_author']) ? sanitize_text_field($_POST['post_author']) : 'random'; $date_opt = isset($_POST['date_option']) ? sanitize_text_field($_POST['date_option']) : 'now'; $content_length = isset($_POST['content_length']) ? sanitize_text_field($_POST['content_length']) : 'medium'; $image_source = isset($_POST['image_source']) ? sanitize_text_field($_POST['image_source']) : 'picsum'; $use_image = isset($_POST['use_featured_image']) ? true : false; $image_size = isset($_POST['image_size']) ? sanitize_text_field($_POST['image_size']) : '1200/800'; $add_comments = isset($_POST['add_comments']) ? true : false; $make_sticky = isset($_POST['make_sticky']) ? true : false; $cat_ids = []; if ($post_type === 'post' && !empty($categories_raw)) { $cat_names = array_map('trim', explode(',', $categories_raw)); foreach ($cat_names as $cat_name) { if (empty($cat_name)) continue; $term = term_exists($cat_name, 'category'); if (!$term) { $term = wp_insert_term($cat_name, 'category'); } if (!is_wp_error($term)) { $cat_ids[] = (int) $term['term_id']; } } } $tag_names = !empty($tags_raw) ? array_map('trim', explode(',', $tags_raw)) : []; $user_ids = get_users(['fields' => 'ID']); for ($i = 0; $i < $count; $i++) { $author_id = ($author_opt === 'random') ? $user_ids[array_rand($user_ids)] : intval($author_opt); $post_date = current_time('mysql'); $final_status = $status; if ($date_opt === 'random_past') { $days_back = rand(1, 30); $post_date = date('Y-m-d H:i:s', strtotime("-$days_back days")); } elseif ($date_opt === 'future') { $days_ahead = rand(1, 15); $post_date = date('Y-m-d H:i:s', strtotime("+$days_ahead days")); $final_status = 'future'; } $title = $this->get_sample_title($lang, $i); $content = $this->get_sample_content($lang, $content_length); $post_data = [ 'post_title' => $title, 'post_content' => $content, 'post_status' => $final_status, 'post_type' => $post_type, 'post_author' => $author_id, 'post_date' => $post_date, ]; if ($post_type === 'post' && !empty($cat_ids)) { $post_data['post_category'] = [$cat_ids[array_rand($cat_ids)]]; } if ($post_type === 'post' && !empty($tag_names)) { $post_data['tags_input'] = $tag_names; } $post_id = wp_insert_post($post_data); if ($post_id && !is_wp_error($post_id)) { update_post_meta($post_id, $this->meta_key, '1'); if ($use_image) { if ($image_source === 'local_svg') { $size_parts = explode('/', $image_size); $w = isset($size_parts[0]) ? intval($size_parts[0]) : 1200; $h = isset($size_parts[1]) ? intval($size_parts[1]) : 800; $colors = ['#1e293b', '#0f172a', '#1e3a8a', '#14532d', '#701a75', '#312e81', '#831843', '#7c2d12']; $bg_color = $colors[array_rand($colors)]; $svg_content = '' . '' . 'DummyLab Placeholder' . '' . $w . ' x ' . $h . ' - Post #' . $post_id . '' . ''; $file_name = 'dummylab-svg-' . $post_id . '-' . rand(100, 999) . '.svg'; $upload = wp_upload_bits($file_name, null, $svg_content); if (!$upload['error']) { $attachment = [ 'post_mime_type' => 'image/svg+xml', 'post_title' => 'DummyLab SVG ' . $post_id, 'post_content' => '', 'post_status' => 'inherit' ]; $attach_id = wp_insert_attachment($attachment, $upload['file'], $post_id); if ($attach_id && !is_wp_error($attach_id)) { $attach_data = wp_generate_attachment_metadata($attach_id, $upload['file']); wp_update_attachment_metadata($attach_id, $attach_data); set_post_thumbnail($post_id, $attach_id); update_post_meta($attach_id, $this->meta_key, '1'); } } } else { $image_url = 'https://picsum.photos/' . $image_size . '?random=' . rand(1, 9999); $tmp = download_url($image_url); if (!is_wp_error($tmp)) { $file_array = [ 'name' => 'dummylab-' . $post_id . '.jpg', 'tmp_name' => $tmp ]; $attach_id = media_handle_sideload($file_array, $post_id); if (!is_wp_error($attach_id)) { set_post_thumbnail($post_id, $attach_id); update_post_meta($attach_id, $this->meta_key, '1'); } @unlink($tmp); } } } if ($i === 0 && $make_sticky && $post_type === 'post') { stick_post($post_id); } if ($add_comments) { $comment_count = rand(1, 3); for ($c = 0; $c < $comment_count; $c++) { wp_insert_comment([ 'comment_post_ID' => $post_id, 'comment_author' => 'Tester Dummy', 'comment_author_email' => 'tester@example.com', 'comment_content' => ($lang === 'id') ? 'Artikel yang sangat bermanfaat dan informatif!' : 'Great content, thanks for sharing!', 'comment_approved' => 1, ]); } } } } wp_redirect(admin_url('tools.php?page=dummylab&tab=generator&ui_lang=' . $ui_lang . '&status=generated&count=' . $count . '&type=' . $post_type)); exit; } public function handle_delete_single() { if (!current_user_can('manage_options') || !check_admin_referer('dummylab_delete_single_action', 'dummylab_nonce')) { wp_die('Akses ditolak.'); } $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0; $ui_lang = isset($_POST['ui_lang']) ? sanitize_text_field($_POST['ui_lang']) : 'id'; if ($post_id > 0) { wp_delete_post($post_id, true); } wp_redirect(admin_url('tools.php?page=dummylab&tab=history&ui_lang=' . $ui_lang . '&status=deleted_single')); exit; } public function handle_purge() { if (!current_user_can('manage_options') || !check_admin_referer('dummylab_purge_action', 'dummylab_nonce')) { wp_die('Akses ditolak.'); } $ui_lang = isset($_POST['ui_lang']) ? sanitize_text_field($_POST['ui_lang']) : 'id'; $query = new WP_Query([ 'post_type' => ['post', 'page', 'attachment'], 'posts_per_page' => -1, 'meta_key' => $this->meta_key, 'meta_value' => '1', 'fields' => 'ids', 'post_status' => 'any', ]); $purged_count = 0; if (!empty($query->posts)) { foreach ($query->posts as $post_id) { if (wp_delete_post($post_id, true)) { $purged_count++; } } } wp_redirect(admin_url('tools.php?page=dummylab&tab=generator&ui_lang=' . $ui_lang . '&status=purged&count=' . $purged_count)); exit; } private function get_sample_title($lang, $index) { $titles_id = [ 'Panduan Lengkap Pengembangan Infrastruktur Web Modern', 'Mengoptimalkan Performa Database untuk Trafik Tinggi', 'Desain Responsif dan Pengalaman Pengguna Terbaik', 'Strategi Keamanan Server dan Arsitektur Komputasi Awan', 'Manajemen Konten Efektif untuk Pertumbuhan Bisnis' ]; $titles_en = [ 'Exploring the Future of Scalable Web Architecture', '10 Essential Practices for High-Performance Servers', 'Understanding Modern UI/UX Design Principles', 'Building Secure Application Infrastructures', 'Optimizing Database Queries for Enterprise Solutions' ]; $arr = ($lang === 'id') ? $titles_id : $titles_en; return $arr[array_rand($arr)] . ' #' . rand(100, 999); } private function get_sample_content($lang, $length) { $p_id = [ 'Pengembangan aplikasi web modern memerlukan perhatian ekstra pada arsitektur sistem dasar. Komponen seperti manajemen memori, optimasi kueri, dan konfigurasi server menjadi kunci utama.', 'Dengan menerapkan standar keamanan terbaik, kita dapat mencegah potensi bahaya siber dan memastikan layanan tetap stabil di bawah beban lalu lintas data yang tinggi.', 'Pengalaman pengguna merupakan elemen krusial. Tata letak visual yang konsisten serta navigasi intuitif memudahkan pengunjung dalam menemukan informasi secara cepat.' ]; $p_en = [ 'Modern web applications require strict adherence to solid system architectures. Key aspects include efficient database queries, memory management, and caching layer implementation.', 'Ensuring continuous infrastructure security prevents vulnerabilities while guaranteeing optimal uptime during high-volume traffic spikes.', 'User experience design directly impacts engagement rates. Clean layouts, readable typography, and intuitive interfaces make content consumption seamless.' ]; $paragraphs = ($lang === 'id') ? $p_id : $p_en; $output = ''; $loops = ($length === 'short') ? 2 : (($length === 'long') ? 7 : 4); for ($k = 0; $k < $loops; $k++) { $output .= '

' . $paragraphs[array_rand($paragraphs)] . '

'; if ($length !== 'short' && $k === 1) { $output .= '

' . (($lang === 'id') ? 'Sub-judul Informasi Penting' : 'Key Technical Insights') . '

'; } if ($length === 'long' && $k === 3) { $output .= '

' . (($lang === 'id') ? 'Keamanan dan kecepatan adalah fondasi utama pengembangan web.' : 'Security and performance are the core foundations of web development.') . '

'; } } return $output; } } register_activation_hook(__FILE__, ['DummyLab', 'activate_plugin']); DummyLab::get_instance();