Skip to content

Commit d4bd4f1

Browse files
xecdevxecdev
andauthored
make public key field mandatory (#102)
* make public key field mandatory * responding to the bot's feedback --------- Co-authored-by: xecdev <ecashinformer@gmail.com>
1 parent 3ab169a commit d4bd4f1

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

includes/class-paybutton-admin.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class PayButton_Admin {
1414
public function __construct() {
1515
add_action( 'admin_menu', array( $this, 'add_admin_menus' ) );
1616
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
17-
add_action( 'admin_notices', array( $this, 'admin_notice_missing_wallet_address' ) );
17+
add_action( 'admin_notices', array( $this, 'admin_notice_missing_required_inputs' ) );
1818
// Process form submissions early
1919
add_action( 'admin_init', array( $this, 'handle_save_settings' ) );
2020

@@ -228,7 +228,7 @@ public function paywall_settings_page() {
228228
$this->load_admin_template( 'paywall-settings', $args );
229229
}
230230

231-
public function admin_notice_missing_wallet_address() {
231+
public function admin_notice_missing_required_inputs() {
232232
if (isset($_GET['settings-updated']) && $_GET['settings-updated'] === 'true') {
233233
return;
234234
}
@@ -242,6 +242,13 @@ public function admin_notice_missing_wallet_address() {
242242
echo '<p><strong>NOTICE:</strong> Please set your wallet address in <a href="' . esc_url(admin_url('admin.php?page=paybutton-paywall')) . '">Paywall Settings</a>. If you don\'t have an address yet, create a wallet using <a href="https://cashtab.com" target="_blank">Cashtab</a>, <a href="https://www.bitcoinabc.org/electrum/" target="_blank">Electrum ABC</a> or <a href="https://electroncash.org/" target="_blank">Electron Cash</a>.</p>';
243243
echo '</div>';
244244
}
245+
246+
$public_key = get_option('paybutton_public_key', '');
247+
if (empty($public_key)) {
248+
echo '<div class="notice notice-error">';
249+
echo '<p><strong>NOTICE:</strong> Please set your public key in <a href="' . esc_url(admin_url('admin.php?page=paybutton-paywall')) . '">Paywall Settings</a>.</p>';
250+
echo '</div>';
251+
}
245252
}
246253

247254
/**

templates/admin/paywall-settings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@
197197
<!--NEW Public Key input field-->
198198
<tr>
199199
<th scope="row">
200-
<label for="paybutton_public_key">PayButton Public Key (optional)</label>
200+
<label for="paybutton_public_key">PayButton Public Key (required)</label>
201201
</th>
202202
<td>
203-
<input type="text" name="paybutton_public_key" id="paybutton_public_key" class="regular-text" value="<?php echo esc_attr( $paybutton_public_key ); ?>">
203+
<input type="text" name="paybutton_public_key" id="paybutton_public_key" class="regular-text" value="<?php echo esc_attr( $paybutton_public_key ); ?>" required>
204204
<p class="description">
205205
Enter your PayButton public key to verify Payment Trigger requests.
206206
</p>
@@ -239,7 +239,7 @@
239239
6. Save your button settings after pasting these values, and you're all set!
240240
</p>
241241
<p>
242-
<strong>Note:</strong> Enabling this feature is strongly recommended as it improves payment reliability, leveraging secure server-to-server messaging to record paywall transactions to your database.
242+
<strong>Note:</strong> Enabling this feature is required as it improves payment reliability, leveraging secure server-to-server messaging to record paywall and login transactions to your database.
243243
</p>
244244
</div>
245245
</td>

0 commit comments

Comments
 (0)