| 1 |
<?php |
| 2 |
/** |
| 3 |
* Webhook management settings section. |
| 4 |
* |
| 5 |
* @var LP_Admin_Webhooks_Table_List $table |
| 6 |
* @var array<string, string> $events |
| 7 |
*/ |
| 8 |
|
| 9 |
defined( 'ABSPATH' ) || exit; |
| 10 |
?> |
| 11 |
|
| 12 |
<div class="lp-webhooks-section"> |
| 13 |
<div id="lp-webhook-editor-holder" style="display:none;"> |
| 14 |
<div id="lp-webhook-editor" class="lp-webhook-editor" style="max-height:70vh; overflow:auto; padding:4px 6px 0; text-align:left;"> |
| 15 |
<h2 id="lp-webhook-editor-title" style="margin-top: 0;"><?php esc_html_e( 'Create Webhook', 'learnpress' ); ?></h2> |
| 16 |
<input type="hidden" id="lp-webhook-id" value="0" /> |
| 17 |
|
| 18 |
<table id="lp-webhook-editor-fields" class="form-table" role="presentation"> |
| 19 |
<tbody> |
| 20 |
<tr> |
| 21 |
<th scope="row"><label for="lp-webhook-name"><?php esc_html_e( 'Name', 'learnpress' ); ?></label></th> |
| 22 |
<td><input type="text" id="lp-webhook-name" class="regular-text" maxlength="200" required disabled /></td> |
| 23 |
</tr> |
| 24 |
<tr> |
| 25 |
<th scope="row"><label for="lp-webhook-delivery-url"><?php esc_html_e( 'URL callback', 'learnpress' ); ?></label></th> |
| 26 |
<td><input type="url" id="lp-webhook-delivery-url" class="regular-text code" required disabled /></td> |
| 27 |
</tr> |
| 28 |
<tr> |
| 29 |
<th scope="row"><label for="lp-webhook-secret"><?php esc_html_e( 'Secret', 'learnpress' ); ?></label></th> |
| 30 |
<td> |
| 31 |
<input type="password" id="lp-webhook-secret" class="regular-text code" maxlength="255" autocomplete="new-password" placeholder="<?php esc_attr_e( 'Leave blank to auto-generate a secret.', 'learnpress' ); ?>" disabled /> |
| 32 |
<p class="description"><?php esc_html_e( 'Leave blank to generate a secret for a new webhook or keep the existing secret when editing.', 'learnpress' ); ?></p> |
| 33 |
</td> |
| 34 |
</tr> |
| 35 |
<tr> |
| 36 |
<th scope="row"><label for="lp-webhook-status"><?php esc_html_e( 'Status', 'learnpress' ); ?></label></th> |
| 37 |
<td> |
| 38 |
<select id="lp-webhook-status" disabled> |
| 39 |
<option value="active"><?php esc_html_e( 'Active', 'learnpress' ); ?></option> |
| 40 |
<option value="paused"><?php esc_html_e( 'Paused', 'learnpress' ); ?></option> |
| 41 |
</select> |
| 42 |
</td> |
| 43 |
</tr> |
| 44 |
<tr> |
| 45 |
<th scope="row"><?php esc_html_e( 'Events tracked', 'learnpress' ); ?></th> |
| 46 |
<td> |
| 47 |
<select |
| 48 |
id="lp-webhook-events" |
| 49 |
name="lp_webhook_events[]" |
| 50 |
class="lp-tom-select" |
| 51 |
multiple="multiple" |
| 52 |
placeholder="<?php esc_attr_e( 'Select events', 'learnpress' ); ?>" |
| 53 |
style="width:100%; max-width:900px;" |
| 54 |
disabled |
| 55 |
> |
| 56 |
<?php foreach ( $events as $event_key => $event_label ) : ?> |
| 57 |
<option value="<?php echo esc_attr( $event_key ); ?>"> |
| 58 |
<?php echo esc_html( sprintf( '%1$s (%2$s)', $event_label, $event_key ) ); ?> |
| 59 |
</option> |
| 60 |
<?php endforeach; ?> |
| 61 |
</select> |
| 62 |
</td> |
| 63 |
</tr> |
| 64 |
</tbody> |
| 65 |
</table> |
| 66 |
|
| 67 |
<p id="lp-webhook-editor-actions"> |
| 68 |
<button type="button" class="button button-primary" id="lp-webhook-submit" disabled><?php esc_html_e( 'Create Webhook', 'learnpress' ); ?></button> |
| 69 |
<button type="button" class="button" id="lp-webhook-cancel" style="display:none;" disabled><?php esc_html_e( 'Cancel edit', 'learnpress' ); ?></button> |
| 70 |
<button type="button" class="button" id="lp-webhook-regenerate-editor" style="display:none;" disabled><?php esc_html_e( 'Regenerate secret', 'learnpress' ); ?></button> |
| 71 |
<span id="lp-webhook-status-message" style="margin-left:10px;"></span> |
| 72 |
</p> |
| 73 |
|
| 74 |
<div id="lp-webhook-secret-reveal" style="display:none; margin-top:12px; padding:12px; border:1px solid #2271b1; background:#f0f6fc;"> |
| 75 |
<p style="margin-top:0;"><strong><?php esc_html_e( 'Copy this secret now.', 'learnpress' ); ?></strong></p> |
| 76 |
<input type="text" readonly id="lp-webhook-secret-value" class="regular-text code" /> |
| 77 |
<button type="button" class="button" id="lp-webhook-copy-secret"><?php esc_html_e( 'Copy', 'learnpress' ); ?></button> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
|
| 82 |
<div class="lp-webhook-list" style="background:#fff; padding:16px; border:1px solid #dcdcde;"> |
| 83 |
<div style="display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px;"> |
| 84 |
<h2 style="margin:0;"><?php esc_html_e( 'Webhooks', 'learnpress' ); ?></h2> |
| 85 |
<button type="button" class="button button-primary" id="lp-webhook-open-create"><?php esc_html_e( 'Add Webhook', 'learnpress' ); ?></button> |
| 86 |
</div> |
| 87 |
<input type="hidden" name="page" value="learn-press-settings" /> |
| 88 |
<input type="hidden" name="tab" value="advanced" /> |
| 89 |
<input type="hidden" name="section" value="webhook" /> |
| 90 |
<?php $table->search_box( __( 'Search webhooks', 'learnpress' ), 'lp-webhooks-search' ); ?> |
| 91 |
<?php $table->display(); ?> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
|