Skip to content

Commit a6adbe1

Browse files
committed
Add shortcode copy button to lists table
- Add new Shortcode column to lists table with copy button for each list - Show shortcode with copy button for editable lists only - Display dash for automated/external lists with helpful tooltip - Add inline shortcode styling with code box and copy button - Add translations for BG/DE: Shortcode, Copy shortcode, tooltip text This allows users to quickly copy the subscription form shortcode directly from the lists page without navigating to the Shortcodes page.
1 parent 6a14c1b commit a6adbe1

5 files changed

Lines changed: 92 additions & 2 deletions

File tree

admin/partials/lists.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ class="button button-primary"
9494
$all_lists = MSKD_List_Provider::get_all_lists();
9595
?>
9696

97-
<table class="wp-list-table widefat fixed striped">
97+
<table class="wp-list-table widefat fixed striped mskd-lists-table">
9898
<thead>
9999
<tr>
100100
<th scope="col"><?php _e( 'Name', 'mail-system-by-katsarov-design' ); ?></th>
101101
<th scope="col"><?php _e( 'Subscribers', 'mail-system-by-katsarov-design' ); ?></th>
102+
<th scope="col" class="mskd-shortcode-col"><?php _e( 'Shortcode', 'mail-system-by-katsarov-design' ); ?></th>
102103
<th scope="col"><?php _e( 'Actions', 'mail-system-by-katsarov-design' ); ?></th>
103104
</tr>
104105
</thead>
@@ -173,6 +174,22 @@ class="button button-primary"
173174
<span class="mskd-subscriber-count-empty">0</span>
174175
<?php endif; ?>
175176
</td>
177+
<td class="mskd-shortcode-col">
178+
<?php if ( ! $is_external ) : ?>
179+
<?php
180+
$shortcode = sprintf( '[mskd_subscribe_form list_id="%d"]', absint( $item->id ) );
181+
$shortcode_id = 'shortcode-list-' . absint( $item->id );
182+
?>
183+
<div class="mskd-shortcode-inline">
184+
<code class="mskd-shortcode-code" id="<?php echo esc_attr( $shortcode_id ); ?>"><?php echo esc_html( $shortcode ); ?></code>
185+
<button type="button" class="button button-small mskd-copy-btn" data-target="<?php echo esc_attr( $shortcode_id ); ?>" title="<?php esc_attr_e( 'Copy shortcode', 'mail-system-by-katsarov-design' ); ?>">
186+
<?php esc_html_e( 'Copy', 'mail-system-by-katsarov-design' ); ?>
187+
</button>
188+
</div>
189+
<?php else : ?>
190+
<span class="mskd-shortcode-na" title="<?php esc_attr_e( 'Automated lists do not have subscription forms', 'mail-system-by-katsarov-design' ); ?>">—</span>
191+
<?php endif; ?>
192+
</td>
176193
<td>
177194
<a href="<?php echo esc_url( admin_url( 'admin.php?page=mskd-compose&list_id=' . rawurlencode( $item->id ) ) ); ?>">
178195
<?php _e( 'Send email', 'mail-system-by-katsarov-design' ); ?>
@@ -191,7 +208,7 @@ class="mskd-delete-link" style="color: #a00;">
191208
<?php endforeach; ?>
192209
<?php else : ?>
193210
<tr>
194-
<td colspan="3"><?php _e( 'No lists created.', 'mail-system-by-katsarov-design' ); ?></td>
211+
<td colspan="4"><?php _e( 'No lists created.', 'mail-system-by-katsarov-design' ); ?></td>
195212
</tr>
196213
<?php endif; ?>
197214
</tbody>

admin/scss/components/_lists.scss

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,40 @@
130130
color: $color-wp-text-light;
131131
font-style: italic;
132132
}
133+
134+
// Shortcode column in lists table
135+
.mskd-lists-table {
136+
.mskd-shortcode-col {
137+
width: 280px;
138+
}
139+
}
140+
141+
.mskd-shortcode-inline {
142+
display: flex;
143+
align-items: center;
144+
gap: $spacing-2;
145+
146+
.mskd-shortcode-code {
147+
flex: 1;
148+
font-family: $font-family-code;
149+
font-size: $font-size-xs;
150+
color: $color-gray-700;
151+
background: $color-gray-100;
152+
padding: $spacing-1 $spacing-2;
153+
border-radius: $border-radius;
154+
word-break: break-all;
155+
overflow: hidden;
156+
text-overflow: ellipsis;
157+
white-space: nowrap;
158+
max-width: 180px;
159+
}
160+
161+
.button-small {
162+
flex-shrink: 0;
163+
}
164+
}
165+
166+
.mskd-shortcode-na {
167+
color: $color-wp-text-light;
168+
cursor: help;
169+
}

languages/mail-system-by-katsarov-design-bg_BG.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,18 @@ msgstr "Изпрати имейл"
942942
msgid "... and %d more"
943943
msgstr "... и още %d"
944944

945+
#: admin/partials/lists.php
946+
msgid "Shortcode"
947+
msgstr "Шорткод"
948+
949+
#: admin/partials/lists.php
950+
msgid "Copy shortcode"
951+
msgstr "Копирай шорткод"
952+
953+
#: admin/partials/lists.php
954+
msgid "Automated lists do not have subscription forms"
955+
msgstr "Автоматичните списъци нямат формуляри за абонамент"
956+
945957
#: admin/class-admin.php
946958
msgid "Processing..."
947959
msgstr "Обработка..."

languages/mail-system-by-katsarov-design-de_DE.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,18 @@ msgstr "E-Mail senden"
951951
msgid "... and %d more"
952952
msgstr "... und %d weitere"
953953

954+
#: admin/partials/lists.php
955+
msgid "Shortcode"
956+
msgstr "Shortcode"
957+
958+
#: admin/partials/lists.php
959+
msgid "Copy shortcode"
960+
msgstr "Shortcode kopieren"
961+
962+
#: admin/partials/lists.php
963+
msgid "Automated lists do not have subscription forms"
964+
msgstr "Automatisierte Listen haben keine Abonnement-Formulare"
965+
954966
#: admin/class-admin.php
955967
msgid "Processing..."
956968
msgstr "Verarbeitung..."

languages/mail-system-by-katsarov-design.pot

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,18 @@ msgstr ""
913913
msgid "... and %d more"
914914
msgstr ""
915915

916+
#: admin/partials/lists.php
917+
msgid "Shortcode"
918+
msgstr ""
919+
920+
#: admin/partials/lists.php
921+
msgid "Copy shortcode"
922+
msgstr ""
923+
924+
#: admin/partials/lists.php
925+
msgid "Automated lists do not have subscription forms"
926+
msgstr ""
927+
916928
#: admin/class-admin.php
917929
msgid "Processing..."
918930
msgstr ""

0 commit comments

Comments
 (0)