feat(i18n): add dynamic plugin row description based on site locale and donate link
This commit is contained in:
+34
-15
@@ -3,9 +3,10 @@
|
|||||||
* Plugin Name: DummyLab – Dummy Post & Content Generator
|
* Plugin Name: DummyLab – Dummy Post & Content Generator
|
||||||
* Plugin URI: https://apps.masbudikusuma.my.id/dummylab-wp
|
* Plugin URI: https://apps.masbudikusuma.my.id/dummylab-wp
|
||||||
* Description: Advanced dummy content generator for WordPress development with safety controls and bulk purge features.
|
* Description: Advanced dummy content generator for WordPress development with safety controls and bulk purge features.
|
||||||
* Version: 1.2.0
|
* Version: 1.3.0
|
||||||
* Author: masbudikusuma
|
* Author: masbudikusuma
|
||||||
* Author URI: https://masbudi.my.id
|
* Author URI: https://masbudi.my.id
|
||||||
|
* Donate link: https://saweria.co/masbudikusuma
|
||||||
* Text Domain: dummylab
|
* Text Domain: dummylab
|
||||||
* License: GPL-2.0+
|
* License: GPL-2.0+
|
||||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
@@ -31,6 +32,10 @@ class DummyLab {
|
|||||||
add_action('admin_init', [$this, 'handle_activation_redirect']);
|
add_action('admin_init', [$this, 'handle_activation_redirect']);
|
||||||
add_action('admin_post_dummylab_generate', [$this, 'handle_generate']);
|
add_action('admin_post_dummylab_generate', [$this, 'handle_generate']);
|
||||||
add_action('admin_post_dummylab_purge', [$this, 'handle_purge']);
|
add_action('admin_post_dummylab_purge', [$this, 'handle_purge']);
|
||||||
|
|
||||||
|
// Filter untuk deskripsi dinamis (ID/EN) dan Link Donasi di halaman Plugin Admin
|
||||||
|
add_filter('all_plugins', [$this, 'dynamic_plugin_description']);
|
||||||
|
add_filter('plugin_row_meta', [$this, 'add_plugin_row_meta'], 10, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function activate_plugin() {
|
public static function activate_plugin() {
|
||||||
@@ -47,6 +52,30 @@ class DummyLab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mengubah deskripsi plugin di wp-admin/plugins.php sesuai bahasa situs (ID / EN)
|
||||||
|
public function dynamic_plugin_description($all_plugins) {
|
||||||
|
$plugin_file = plugin_basename(__FILE__);
|
||||||
|
if (isset($all_plugins[$plugin_file])) {
|
||||||
|
$locale = get_locale();
|
||||||
|
if (strpos($locale, 'id') === 0) {
|
||||||
|
$all_plugins[$plugin_file]['Description'] = 'Generate post dummy (bahasa Indonesia atau Inggris) lengkap dengan judul, isi artikel, gambar unggulan, kategori, tag, penulis, tanggal, dan komentar dummy. Cocok untuk melihat simulasi tampilan tema sebelum diisi konten asli.';
|
||||||
|
} else {
|
||||||
|
$all_plugins[$plugin_file]['Description'] = 'Generate dummy posts and pages (Indonesian or English) with custom titles, article body, featured images, categories, tags, author, date, and comments. Perfect for testing theme layouts before publishing real content.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $all_plugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Menambahkan Link Donasi di sebelah "Visit plugin site"
|
||||||
|
public function add_plugin_row_meta($links, $file) {
|
||||||
|
if ($file === plugin_basename(__FILE__)) {
|
||||||
|
$locale = get_locale();
|
||||||
|
$donate_label = (strpos($locale, 'id') === 0) ? '☕ Donasi' : '☕ Donate';
|
||||||
|
$links[] = '<a href="https://saweria.co/masbudikusuma" target="_blank" style="color: #b35900; font-weight: 600;">' . $donate_label . '</a>';
|
||||||
|
}
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
|
||||||
public function add_admin_menu() {
|
public function add_admin_menu() {
|
||||||
add_management_page(
|
add_management_page(
|
||||||
'DummyLab Generator',
|
'DummyLab Generator',
|
||||||
@@ -121,7 +150,6 @@ class DummyLab {
|
|||||||
.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 { 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; }
|
.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-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; }
|
.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); } }
|
@keyframes dummylab-spin { to { transform: rotate(360deg); } }
|
||||||
@@ -129,7 +157,6 @@ class DummyLab {
|
|||||||
.dummylab-loading-subtext { font-size: 13px; color: #cbd5e1; margin-top: 6px; text-align: center; }
|
.dummylab-loading-subtext { font-size: 13px; color: #cbd5e1; margin-top: 6px; text-align: center; }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Loading Overlay Element -->
|
|
||||||
<div id="dummylab-loading-overlay" class="dummylab-loading-overlay">
|
<div id="dummylab-loading-overlay" class="dummylab-loading-overlay">
|
||||||
<div class="dummylab-spinner"></div>
|
<div class="dummylab-spinner"></div>
|
||||||
<div class="dummylab-loading-text"><?php echo $t['loading_title']; ?></div>
|
<div class="dummylab-loading-text"><?php echo $t['loading_title']; ?></div>
|
||||||
@@ -137,13 +164,11 @@ class DummyLab {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dummylab-wrap">
|
<div class="dummylab-wrap">
|
||||||
<!-- Header Banner -->
|
|
||||||
<div class="dummylab-header">
|
<div class="dummylab-header">
|
||||||
<div>
|
<div>
|
||||||
<h1>🧪 DummyLab <span style="font-size: 14px; font-weight: 400; color: #646970;">v1.2.0</span></h1>
|
<h1>🧪 DummyLab <span style="font-size: 14px; font-weight: 400; color: #646970;">v1.3.0</span></h1>
|
||||||
<p><?php echo $t['created_by']; ?> <a href="https://masbudi.my.id" target="_blank" style="text-decoration: none; font-weight: 600; color: #2271b1;">masbudikusuma</a> • <a href="https://apps.masbudikusuma.my.id/dummylab-wp" target="_blank" style="text-decoration: none; color: #2271b1;"><?php echo $t['plugin_doc']; ?></a></p>
|
<p><?php echo $t['created_by']; ?> <a href="https://masbudi.my.id" target="_blank" style="text-decoration: none; font-weight: 600; color: #2271b1;">masbudikusuma</a> • <a href="https://apps.masbudikusuma.my.id/dummylab-wp" target="_blank" style="text-decoration: none; color: #2271b1;"><?php echo $t['plugin_doc']; ?></a> • <a href="https://saweria.co/masbudikusuma" target="_blank" style="text-decoration: none; font-weight: 600; color: #b35900;">☕ <?php echo $t['link_donate']; ?></a></p>
|
||||||
</div>
|
</div>
|
||||||
<!-- UI Language Switcher -->
|
|
||||||
<div class="dummylab-lang-switch">
|
<div class="dummylab-lang-switch">
|
||||||
<a href="<?php echo esc_url(add_query_arg('ui_lang', 'id')); ?>" class="dummylab-lang-btn <?php echo $ui_lang === 'id' ? 'active' : ''; ?>">🇮🇩 ID</a>
|
<a href="<?php echo esc_url(add_query_arg('ui_lang', 'id')); ?>" class="dummylab-lang-btn <?php echo $ui_lang === 'id' ? 'active' : ''; ?>">🇮🇩 ID</a>
|
||||||
<a href="<?php echo esc_url(add_query_arg('ui_lang', 'en')); ?>" class="dummylab-lang-btn <?php echo $ui_lang === 'en' ? 'active' : ''; ?>">🇬🇧 EN</a>
|
<a href="<?php echo esc_url(add_query_arg('ui_lang', 'en')); ?>" class="dummylab-lang-btn <?php echo $ui_lang === 'en' ? 'active' : ''; ?>">🇬🇧 EN</a>
|
||||||
@@ -170,14 +195,12 @@ class DummyLab {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="dummylab-container">
|
<div class="dummylab-container">
|
||||||
<!-- Left Main Form -->
|
|
||||||
<div class="dummylab-main-card">
|
<div class="dummylab-main-card">
|
||||||
<form id="dummylab-generate-form" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
|
<form id="dummylab-generate-form" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
|
||||||
<?php wp_nonce_field('dummylab_generate_action', 'dummylab_nonce'); ?>
|
<?php wp_nonce_field('dummylab_generate_action', 'dummylab_nonce'); ?>
|
||||||
<input type="hidden" name="action" value="dummylab_generate">
|
<input type="hidden" name="action" value="dummylab_generate">
|
||||||
<input type="hidden" name="ui_lang" value="<?php echo esc_attr($ui_lang); ?>">
|
<input type="hidden" name="ui_lang" value="<?php echo esc_attr($ui_lang); ?>">
|
||||||
|
|
||||||
<!-- Section 1: Core Settings -->
|
|
||||||
<div class="dummylab-section-title">⚙️ <?php echo $t['sec_general']; ?></div>
|
<div class="dummylab-section-title">⚙️ <?php echo $t['sec_general']; ?></div>
|
||||||
<div class="dummylab-grid">
|
<div class="dummylab-grid">
|
||||||
<div class="dummylab-field">
|
<div class="dummylab-field">
|
||||||
@@ -209,7 +232,6 @@ class DummyLab {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Section 2: Taxonomy & Author -->
|
|
||||||
<div class="dummylab-section-title">🏷️ <?php echo $t['sec_taxonomy']; ?></div>
|
<div class="dummylab-section-title">🏷️ <?php echo $t['sec_taxonomy']; ?></div>
|
||||||
<div class="dummylab-grid">
|
<div class="dummylab-grid">
|
||||||
<div class="dummylab-field full-width">
|
<div class="dummylab-field full-width">
|
||||||
@@ -241,7 +263,6 @@ class DummyLab {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Section 3: Content Structure & Media -->
|
|
||||||
<div class="dummylab-section-title">📝 <?php echo $t['sec_content']; ?></div>
|
<div class="dummylab-section-title">📝 <?php echo $t['sec_content']; ?></div>
|
||||||
<div class="dummylab-grid">
|
<div class="dummylab-grid">
|
||||||
<div class="dummylab-field">
|
<div class="dummylab-field">
|
||||||
@@ -275,9 +296,7 @@ class DummyLab {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right Sidebar Column -->
|
|
||||||
<div class="dummylab-sidebar">
|
<div class="dummylab-sidebar">
|
||||||
<!-- Rollback Card -->
|
|
||||||
<div class="dummylab-side-card purge-card">
|
<div class="dummylab-side-card purge-card">
|
||||||
<h3>🗑️ <?php echo $t['purge_title']; ?></h3>
|
<h3>🗑️ <?php echo $t['purge_title']; ?></h3>
|
||||||
<p style="font-size: 13px; color: #50575e; margin: 0 0 12px 0;">
|
<p style="font-size: 13px; color: #50575e; margin: 0 0 12px 0;">
|
||||||
@@ -292,7 +311,6 @@ class DummyLab {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- How to Use Documentation Card -->
|
|
||||||
<div class="dummylab-side-card">
|
<div class="dummylab-side-card">
|
||||||
<h3>📘 <?php echo $t['guide_title']; ?></h3>
|
<h3>📘 <?php echo $t['guide_title']; ?></h3>
|
||||||
<ol class="dummylab-guide-list">
|
<ol class="dummylab-guide-list">
|
||||||
@@ -303,7 +321,6 @@ class DummyLab {
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Safety & Features Info Card -->
|
|
||||||
<div class="dummylab-side-card" style="background-color: #f8fafc;">
|
<div class="dummylab-side-card" style="background-color: #f8fafc;">
|
||||||
<h3>🛡️ <?php echo $t['safety_title']; ?></h3>
|
<h3>🛡️ <?php echo $t['safety_title']; ?></h3>
|
||||||
<ul class="dummylab-safety-list">
|
<ul class="dummylab-safety-list">
|
||||||
@@ -342,6 +359,7 @@ class DummyLab {
|
|||||||
return [
|
return [
|
||||||
'created_by' => 'Created by',
|
'created_by' => 'Created by',
|
||||||
'plugin_doc' => 'Plugin Documentation',
|
'plugin_doc' => 'Plugin Documentation',
|
||||||
|
'link_donate' => 'Donate Support',
|
||||||
'msg_generated' => 'dummy item(s) generated successfully!',
|
'msg_generated' => 'dummy item(s) generated successfully!',
|
||||||
'check_msg' => 'Please check your %s section.',
|
'check_msg' => 'Please check your %s section.',
|
||||||
'btn_view_list' => 'View List of',
|
'btn_view_list' => 'View List of',
|
||||||
@@ -402,6 +420,7 @@ class DummyLab {
|
|||||||
return [
|
return [
|
||||||
'created_by' => 'Dibuat oleh',
|
'created_by' => 'Dibuat oleh',
|
||||||
'plugin_doc' => 'Dokumentasi Plugin',
|
'plugin_doc' => 'Dokumentasi Plugin',
|
||||||
|
'link_donate' => 'Dukung Donasi',
|
||||||
'msg_generated' => 'konten dummy berhasil dibuat!',
|
'msg_generated' => 'konten dummy berhasil dibuat!',
|
||||||
'check_msg' => 'Silakan cek daftar %s Anda.',
|
'check_msg' => 'Silakan cek daftar %s Anda.',
|
||||||
'btn_view_list' => 'Lihat Daftar',
|
'btn_view_list' => 'Lihat Daftar',
|
||||||
|
|||||||
Reference in New Issue
Block a user