Skip to content

Commit

Permalink
Merge pull request #1166 from themeum/sazedul-haque
Browse files Browse the repository at this point in the history
webhook_url field added for settings
  • Loading branch information
harunollyo authored Sep 30, 2024
2 parents 21756a5 + 97ddbee commit 6e9af71
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
6 changes: 4 additions & 2 deletions ecommerce/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public static function add_ecommerce_settings( $fields ) {
'label' => __( 'Refund Policy', 'tutor' ),
'default' => 0,
'options' => $pages,
'desc' => __( 'Choose the page for instructor registration.', 'tutor' ),
'desc' => __( 'Choose the page for refund policy.', 'tutor' ),
'searchable' => true,
),
array(
Expand All @@ -209,7 +209,7 @@ public static function add_ecommerce_settings( $fields ) {
'label' => __( 'Privacy Policy', 'tutor' ),
'default' => 0,
'options' => $pages,
'desc' => __( 'Choose the page for student registration.', 'tutor' ),
'desc' => __( 'Choose the page for privacy policy.', 'tutor' ),
'searchable' => true,
),
),
Expand Down Expand Up @@ -602,6 +602,7 @@ public static function get_paypal_config_keys() {
'paypal_client_id' => 'text',
'paypal_client_secret' => 'password',
'paypal_webhook_id' => 'password',
'paypal_webhook_url' => 'webhook_url',
);
}

Expand All @@ -618,6 +619,7 @@ public static function get_stripe_config_keys() {
'stripe_secret_key' => 'password',
'stripe_public_key' => 'password',
'stripe_webhook_signature_key' => 'password',
'stripe_webhook_url' => 'webhook_url',
);
}

Expand Down
22 changes: 0 additions & 22 deletions views/options/field-types/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
* @since 3.0.0
*/

use Tutor\Ecommerce\Settings;

$webhook_fields = Settings::get_webhook_fields();


$field_key = $field['key'];
$default = isset( $field['default'] ) ? $field['default'] : false;
$value = $this->get( $field_key, $default );
Expand All @@ -40,20 +35,3 @@ class="tutor-form-control <?php echo esc_attr( $field_classes ); ?>" <?php echo

</div>
</div>
<?php if ( in_array( $field_key, $webhook_fields ) ) : ?>
<div class="tutor-fs-7 tutor-mt-8">
<div class="tutor-fs-6 tutor-fw-medium">
<?php esc_html_e( 'Webhook URL', 'tutor' ); ?>
</div>
<?php
$method = explode( '_', $field_key )[0];
$url = site_url( 'wp-json/tutor/v1/ecommerce-webhook?payment_method=' . $method );
?>
<div class="tutor-d-flex tutor-justify-between tutor-align-center tutor-gap-1">
<span class="tutor-color-muted">
<?php echo esc_url( $url ); ?>
</span>
<a class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-copy-text" data-text="<?php echo esc_url( $url ); ?>"><span class="tutor-icon-copy tutor-mr-8"></span><span><?php esc_html_e( 'Copy', 'tutor' ); ?></span></a>
</div>
</div>
<?php endif; ?>
32 changes: 32 additions & 0 deletions views/options/field-types/webhook_url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Input filed type webhook_url for settings.
*
* @package Tutor\Views
* @subpackage Tutor\Settings
* @author Themeum <[email protected]>
* @link https://themeum.com
* @since 3.0.0
*/

$field_key = $field['key'];
$field_id = esc_attr( 'field_' . $field_key );
?>
<div class="tutor-mt-16" id="<?php echo esc_attr( $field_id ); ?>">
<div class="tutor-fs-6 tutor-fw-medium">
<?php esc_html_e( 'Webhook URL', 'tutor' ); ?>
</div>
<?php
$method = explode( '_', $field_key )[0];
$url = site_url( 'wp-json/tutor/v1/ecommerce-webhook?payment_method=' . $method );
?>
<div class="tutor-d-flex tutor-justify-between tutor-align-center tutor-gap-1">
<span class="tutor-color-muted">
<?php echo esc_url( $url ); ?>
</span>
<a class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-copy-text" data-text="<?php echo esc_url( $url ); ?>">
<span class="tutor-icon-copy tutor-mr-8"></span>
<span><?php esc_html_e( 'Copy', 'tutor' ); ?></span>
</a>
</div>
</div>

0 comments on commit 6e9af71

Please sign in to comment.