commit fc6e5083d3282fb6daa29364964ecbddd7fab337 Author: idtemankampus-creator Date: Thu Sep 17 22:31:38 2026 +0700 feat(core): initialize DummyLab plugin boilerplate with generator and purge functionality diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcc9342 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +*.log diff --git a/dummylab.php b/dummylab.php new file mode 100644 index 0000000..af64214 --- /dev/null +++ b/dummylab.php @@ -0,0 +1,190 @@ + 'post', + 'posts_per_page' => -1, + 'meta_key' => $this->meta_key, + 'meta_value' => '1', + 'fields' => 'ids', + ]); + $dummy_count = $query->found_posts; + ?> +
+

๐Ÿงช DummyLab โ€“ Post Generator

+

Generate dummy posts safely for design testing and layout development.

+
+ + +
+

+ +

+
+ + +
+ +
+

Generate Dummy Posts

+
+ + + +

+
+ +

+

+
+ +

+ + + +
+ + +
+

Cleanup / Purge Data

+

Currently active dummy posts:

+
+ + + +

This action will permanently delete all posts created by DummyLab.

+ ($dummy_count === 0)]); ?> +
+
+
+
+ ' . $paragraphs[array_rand($paragraphs)] . '

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

'; + + $post_id = wp_insert_post([ + 'post_title' => $random_title, + 'post_content' => $random_content, + 'post_status' => $status, + 'post_type' => 'post', + 'post_author' => get_current_user_id(), + ]); + + if ($post_id && !is_wp_error($post_id)) { + update_post_meta($post_id, $this->meta_key, '1'); + } + } + + wp_redirect(admin_url('tools.php?page=dummylab&status=generated&count=' . $count)); + exit; + } + + public function handle_purge() { + if (!current_user_can('manage_options') || !check_admin_referer('dummylab_purge_action', 'dummylab_nonce')) { + wp_die('Unauthorized request.'); + } + + $query = new WP_Query([ + 'post_type' => 'post', + 'posts_per_page' => -1, + 'meta_key' => $this->meta_key, + 'meta_value' => '1', + 'fields' => 'ids', + ]); + + $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&status=purged&count=' . $purged_count)); + exit; + } +} + +DummyLab::get_instance();