Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 259d171

Browse files
committed
🎨 Enhances modal customization options
Improves the admin settings page with new modal customization options. Adds sections for customizing the sharing and wallet login modals, including title and text fields. Sanitizes and processes modal i18n settings, ensuring data integrity. Also sets a default text for referred users.
1 parent 48bce94 commit 259d171

3 files changed

Lines changed: 132 additions & 31 deletions

File tree

‎admin/class-frak-admin.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,25 @@ private function save_settings() {
183183
// Handle modal i18n
184184
$modal_i18n = isset($_POST['frak_modal_i18n']) ? $_POST['frak_modal_i18n'] : array();
185185
if (is_array($modal_i18n)) {
186+
// Sanitize each value
187+
foreach ($modal_i18n as $key => $value) {
188+
// For text areas, preserve line breaks but sanitize content
189+
if (in_array($key, ['sharing.text', 'sdk.wallet.login.text_sharing', 'sdk.wallet.login.text_referred'])) {
190+
$modal_i18n[$key] = sanitize_textarea_field($value);
191+
} else {
192+
$modal_i18n[$key] = sanitize_text_field($value);
193+
}
194+
}
195+
196+
// Remove empty values
186197
$modal_i18n = array_filter($modal_i18n, function($value) {
187198
return $value !== '';
188199
});
200+
201+
// Handle special case: if text_referred is set, also set it as text
202+
if (isset($modal_i18n['sdk.wallet.login.text_referred'])) {
203+
$modal_i18n['sdk.wallet.login.text'] = $modal_i18n['sdk.wallet.login.text_referred'];
204+
}
189205
}
190206

191207
update_option('frak_app_name', $app_name);

‎admin/css/admin.css‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
}
150150

151151
.frak-i18n-table td:first-child {
152-
width: 150px;
152+
width: 250px;
153153
font-weight: 600;
154154
color: #23282d;
155155
}
@@ -158,6 +158,40 @@
158158
width: 100%;
159159
}
160160

161+
.frak-i18n-table textarea {
162+
width: 100%;
163+
resize: vertical;
164+
}
165+
166+
/* i18n group styling */
167+
.frak-i18n-group {
168+
margin-bottom: 20px;
169+
padding: 15px;
170+
background: #f5f5f5;
171+
border: 1px solid #e0e0e0;
172+
border-radius: 3px;
173+
}
174+
175+
.frak-i18n-group h4 {
176+
margin: 0 0 10px 0;
177+
color: #23282d;
178+
font-size: 14px;
179+
font-weight: 600;
180+
}
181+
182+
.frak-i18n-group .description {
183+
font-size: 13px;
184+
color: #666;
185+
line-height: 1.5;
186+
}
187+
188+
.frak-i18n-group .description code {
189+
background: #e0e0e0;
190+
padding: 2px 4px;
191+
border-radius: 3px;
192+
font-size: 12px;
193+
}
194+
161195
/* Logo preview */
162196
.frak-logo-preview {
163197
margin-top: 10px;

‎admin/views/settings-page.php‎

Lines changed: 81 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -151,36 +151,87 @@ class="regular-text"
151151
<th scope="row">Custom Translations</th>
152152
<td>
153153
<p class="description" style="margin-bottom: 10px;">Override default text in the modal (leave empty to use defaults)</p>
154-
<table class="frak-i18n-table">
155-
<tr>
156-
<td><label for="frak_modal_i18n_login_text">Login Text:</label></td>
157-
<td><input type="text" id="frak_modal_i18n_login_text"
158-
name="frak_modal_i18n[sdk.wallet.login.text]"
159-
value="<?php echo isset($modal_i18n['sdk.wallet.login.text']) ? esc_attr($modal_i18n['sdk.wallet.login.text']) : ''; ?>"
160-
class="regular-text"></td>
161-
</tr>
162-
<tr>
163-
<td><label for="frak_modal_i18n_login_text_sharing">Sharing Login Text:</label></td>
164-
<td><input type="text" id="frak_modal_i18n_login_text_sharing"
165-
name="frak_modal_i18n[sdk.wallet.login.text_sharing]"
166-
value="<?php echo isset($modal_i18n['sdk.wallet.login.text_sharing']) ? esc_attr($modal_i18n['sdk.wallet.login.text_sharing']) : ''; ?>"
167-
class="regular-text"></td>
168-
</tr>
169-
<tr>
170-
<td><label for="frak_modal_i18n_login_cta">Login Button:</label></td>
171-
<td><input type="text" id="frak_modal_i18n_login_cta"
172-
name="frak_modal_i18n[sdk.wallet.login.cta]"
173-
value="<?php echo isset($modal_i18n['sdk.wallet.login.cta']) ? esc_attr($modal_i18n['sdk.wallet.login.cta']) : ''; ?>"
174-
class="regular-text"></td>
175-
</tr>
176-
<tr>
177-
<td><label for="frak_modal_i18n_reward_text">Reward Text:</label></td>
178-
<td><input type="text" id="frak_modal_i18n_reward_text"
179-
name="frak_modal_i18n[sdk.wallet.reward.text]"
180-
value="<?php echo isset($modal_i18n['sdk.wallet.reward.text']) ? esc_attr($modal_i18n['sdk.wallet.reward.text']) : ''; ?>"
181-
class="regular-text"></td>
182-
</tr>
183-
</table>
154+
155+
<!-- Sharing Modal Customization -->
156+
<div class="frak-i18n-group">
157+
<h4 style="margin: 15px 0 10px 0;">Sharing Modal</h4>
158+
<table class="frak-i18n-table">
159+
<tr>
160+
<td style="vertical-align: top; padding-bottom: 15px;">
161+
<label for="frak_modal_i18n_sharing_title">Sharing Modal Title:</label>
162+
<p class="description" style="margin-top: 5px;">The title that appears when users share your content on social media or messaging apps</p>
163+
</td>
164+
<td style="padding-bottom: 15px;">
165+
<input type="text" id="frak_modal_i18n_sharing_title"
166+
name="frak_modal_i18n[sharing.title]"
167+
value="<?php echo isset($modal_i18n['sharing.title']) ? esc_attr($modal_i18n['sharing.title']) : ''; ?>"
168+
class="large-text"
169+
placeholder="Example: 'Share this amazing product with your friends!'">
170+
</td>
171+
</tr>
172+
<tr>
173+
<td style="vertical-align: top; padding-bottom: 15px;">
174+
<label for="frak_modal_i18n_sharing_text">Sharing Message Text:</label>
175+
<p class="description" style="margin-top: 5px;">The default message that will be shared along with your product link</p>
176+
</td>
177+
<td style="padding-bottom: 15px;">
178+
<textarea id="frak_modal_i18n_sharing_text"
179+
name="frak_modal_i18n[sharing.text]"
180+
class="large-text"
181+
rows="3"
182+
placeholder="Example: 'Check out this amazing product I found!'"><?php echo isset($modal_i18n['sharing.text']) ? esc_textarea($modal_i18n['sharing.text']) : ''; ?></textarea>
183+
</td>
184+
</tr>
185+
</table>
186+
</div>
187+
188+
<!-- Wallet Login Modal Customization -->
189+
<div class="frak-i18n-group">
190+
<h4 style="margin: 15px 0 10px 0;">Wallet Login Modal</h4>
191+
<table class="frak-i18n-table">
192+
<tr>
193+
<td style="vertical-align: top; padding-bottom: 15px;">
194+
<label for="frak_modal_i18n_login_primary_action">Wallet Login Button Text:</label>
195+
<p class="description" style="margin-top: 5px;">The text displayed on the main action button in the wallet login modal</p>
196+
</td>
197+
<td style="padding-bottom: 15px;">
198+
<input type="text" id="frak_modal_i18n_login_primary_action"
199+
name="frak_modal_i18n[sdk.wallet.login.primaryAction]"
200+
value="<?php echo isset($modal_i18n['sdk.wallet.login.primaryAction']) ? esc_attr($modal_i18n['sdk.wallet.login.primaryAction']) : ''; ?>"
201+
class="large-text"
202+
placeholder="Example: 'Create your wallet in 2 seconds!'">
203+
</td>
204+
</tr>
205+
<tr>
206+
<td style="vertical-align: top; padding-bottom: 15px;">
207+
<label for="frak_modal_i18n_login_text_sharing">Login Text for Sharing:</label>
208+
<p class="description" style="margin-top: 5px;">Message shown to users when they need to login to share content and earn rewards.<br>
209+
You can use <strong>**bold text**</strong>, <em>*italic text*</em>, and <code>{{ estimatedReward }}</code> to show the reward amount.</p>
210+
</td>
211+
<td style="padding-bottom: 15px;">
212+
<textarea id="frak_modal_i18n_login_text_sharing"
213+
name="frak_modal_i18n[sdk.wallet.login.text_sharing]"
214+
class="large-text"
215+
rows="3"
216+
placeholder="Example: 'Share, Refer, Earn up to **{{ estimatedReward }}** per successful referral'"><?php echo isset($modal_i18n['sdk.wallet.login.text_sharing']) ? esc_textarea($modal_i18n['sdk.wallet.login.text_sharing']) : ''; ?></textarea>
217+
</td>
218+
</tr>
219+
<tr>
220+
<td style="vertical-align: top; padding-bottom: 15px;">
221+
<label for="frak_modal_i18n_login_text_referred">Welcome Text for Referred Users:</label>
222+
<p class="description" style="margin-top: 5px;">Message shown to users who clicked on a shared link.<br>
223+
You can use <strong>**bold text**</strong>, <em>*italic text*</em>, and <code>{{ estimatedReward }}</code> to show the reward amount.</p>
224+
</td>
225+
<td style="padding-bottom: 15px;">
226+
<textarea id="frak_modal_i18n_login_text_referred"
227+
name="frak_modal_i18n[sdk.wallet.login.text_referred]"
228+
class="large-text"
229+
rows="3"
230+
placeholder="Example: 'Welcome! Receive **{{ estimatedReward }}** when you make a purchase'"><?php echo isset($modal_i18n['sdk.wallet.login.text_referred']) ? esc_textarea($modal_i18n['sdk.wallet.login.text_referred']) : ''; ?></textarea>
231+
</td>
232+
</tr>
233+
</table>
234+
</div>
184235
</td>
185236
</tr>
186237
</table>

0 commit comments

Comments
 (0)