Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes/admin/settings/views
File: html-webhooks-edit.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Admin View: Edit Webhooks
[2] Fix | Delete
*
[3] Fix | Delete
* @package WooCommerce\Admin\Webhooks\Views
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[7] Fix | Delete
exit;
[8] Fix | Delete
}
[9] Fix | Delete
?>
[10] Fix | Delete
[11] Fix | Delete
<input type="hidden" name="webhook_id" value="<?php echo esc_attr( $webhook->get_id() ); ?>" />
[12] Fix | Delete
[13] Fix | Delete
<div id="webhook-options" class="settings-panel">
[14] Fix | Delete
<h2><?php esc_html_e( 'Webhook data', 'woocommerce' ); ?></h2>
[15] Fix | Delete
<table class="form-table">
[16] Fix | Delete
<tbody>
[17] Fix | Delete
<tr valign="top">
[18] Fix | Delete
<th scope="row" class="titledesc">
[19] Fix | Delete
<label for="webhook_name">
[20] Fix | Delete
<?php esc_html_e( 'Name', 'woocommerce' ); ?>
[21] Fix | Delete
<?php
[22] Fix | Delete
/* translators: %s: date */
[23] Fix | Delete
echo wc_help_tip( sprintf( __( 'Friendly name for identifying this webhook, defaults to Webhook created on %s.', 'woocommerce' ), (new DateTime('now'))->format( _x( 'M d, Y @ h:i A', 'Webhook created on date parsed by DateTime::format', 'woocommerce' ) ) ) ); // @codingStandardsIgnoreLine
[24] Fix | Delete
?>
[25] Fix | Delete
</label>
[26] Fix | Delete
</th>
[27] Fix | Delete
<td class="forminp">
[28] Fix | Delete
<input name="webhook_name" id="webhook_name" type="text" class="input-text regular-input" value="<?php echo esc_attr( $webhook->get_name() ); ?>" />
[29] Fix | Delete
</td>
[30] Fix | Delete
</tr>
[31] Fix | Delete
<tr valign="top">
[32] Fix | Delete
<th scope="row" class="titledesc">
[33] Fix | Delete
<label for="webhook_status">
[34] Fix | Delete
<?php esc_html_e( 'Status', 'woocommerce' ); ?>
[35] Fix | Delete
<?php echo wc_help_tip( __( 'The options are &quot;Active&quot; (delivers payload), &quot;Paused&quot; (does not deliver), or &quot;Disabled&quot; (does not deliver due delivery failures).', 'woocommerce' ) ); ?>
[36] Fix | Delete
</label>
[37] Fix | Delete
</th>
[38] Fix | Delete
<td class="forminp">
[39] Fix | Delete
<select name="webhook_status" id="webhook_status" class="wc-enhanced-select">
[40] Fix | Delete
<?php
[41] Fix | Delete
$statuses = wc_get_webhook_statuses();
[42] Fix | Delete
$current_status = $webhook->get_status();
[43] Fix | Delete
[44] Fix | Delete
foreach ( $statuses as $status_slug => $status_name ) :
[45] Fix | Delete
?>
[46] Fix | Delete
<option value="<?php echo esc_attr( $status_slug ); ?>" <?php selected( $current_status, $status_slug, true ); ?>><?php echo esc_html( $status_name ); ?></option>
[47] Fix | Delete
<?php endforeach; ?>
[48] Fix | Delete
</select>
[49] Fix | Delete
</td>
[50] Fix | Delete
</tr>
[51] Fix | Delete
<tr valign="top">
[52] Fix | Delete
<th scope="row" class="titledesc">
[53] Fix | Delete
<label for="webhook_topic">
[54] Fix | Delete
<?php esc_html_e( 'Topic', 'woocommerce' ); ?>
[55] Fix | Delete
<?php echo wc_help_tip( __( 'Select when the webhook will fire.', 'woocommerce' ) ); ?>
[56] Fix | Delete
</label>
[57] Fix | Delete
</th>
[58] Fix | Delete
<td class="forminp">
[59] Fix | Delete
<select name="webhook_topic" id="webhook_topic" class="wc-enhanced-select">
[60] Fix | Delete
<?php
[61] Fix | Delete
$topic_data = WC_Admin_Webhooks::get_topic_data( $webhook );
[62] Fix | Delete
[63] Fix | Delete
$topics = apply_filters(
[64] Fix | Delete
'woocommerce_webhook_topics',
[65] Fix | Delete
array(
[66] Fix | Delete
'' => __( 'Select an option&hellip;', 'woocommerce' ),
[67] Fix | Delete
'coupon.created' => __( 'Coupon created', 'woocommerce' ),
[68] Fix | Delete
'coupon.updated' => __( 'Coupon updated', 'woocommerce' ),
[69] Fix | Delete
'coupon.deleted' => __( 'Coupon deleted', 'woocommerce' ),
[70] Fix | Delete
'coupon.restored' => __( 'Coupon restored', 'woocommerce' ),
[71] Fix | Delete
'customer.created' => __( 'Customer created', 'woocommerce' ),
[72] Fix | Delete
'customer.updated' => __( 'Customer updated', 'woocommerce' ),
[73] Fix | Delete
'customer.deleted' => __( 'Customer deleted', 'woocommerce' ),
[74] Fix | Delete
'order.created' => __( 'Order created', 'woocommerce' ),
[75] Fix | Delete
'order.updated' => __( 'Order updated', 'woocommerce' ),
[76] Fix | Delete
'order.deleted' => __( 'Order deleted', 'woocommerce' ),
[77] Fix | Delete
'order.restored' => __( 'Order restored', 'woocommerce' ),
[78] Fix | Delete
'product.created' => __( 'Product created', 'woocommerce' ),
[79] Fix | Delete
'product.updated' => __( 'Product updated', 'woocommerce' ),
[80] Fix | Delete
'product.deleted' => __( 'Product deleted', 'woocommerce' ),
[81] Fix | Delete
'product.restored' => __( 'Product restored', 'woocommerce' ),
[82] Fix | Delete
'action' => __( 'Action', 'woocommerce' ),
[83] Fix | Delete
)
[84] Fix | Delete
);
[85] Fix | Delete
[86] Fix | Delete
foreach ( $topics as $topic_slug => $topic_name ) :
[87] Fix | Delete
[88] Fix | Delete
$selected = $topic_slug === $topic_data['topic'] || $topic_slug === $topic_data['resource'] . '.' . $topic_data['event'];
[89] Fix | Delete
[90] Fix | Delete
?>
[91] Fix | Delete
<option value="<?php echo esc_attr( $topic_slug ); ?>" <?php selected( $selected, true, true ); ?>><?php echo esc_html( $topic_name ); ?></option>
[92] Fix | Delete
<?php endforeach; ?>
[93] Fix | Delete
</select>
[94] Fix | Delete
</td>
[95] Fix | Delete
</tr>
[96] Fix | Delete
<tr valign="top" id="webhook-action-event-wrap">
[97] Fix | Delete
<th scope="row" class="titledesc">
[98] Fix | Delete
<label for="webhook_action_event">
[99] Fix | Delete
<?php esc_html_e( 'Action event', 'woocommerce' ); ?>
[100] Fix | Delete
<?php echo wc_help_tip( __( 'Enter the action that will trigger this webhook.', 'woocommerce' ) ); ?>
[101] Fix | Delete
</label>
[102] Fix | Delete
</th>
[103] Fix | Delete
<td class="forminp">
[104] Fix | Delete
<input name="webhook_action_event" id="webhook_action_event" type="text" class="input-text regular-input" value="<?php echo esc_attr( $topic_data['event'] ); ?>" />
[105] Fix | Delete
</td>
[106] Fix | Delete
</tr>
[107] Fix | Delete
<tr valign="top">
[108] Fix | Delete
<th scope="row" class="titledesc">
[109] Fix | Delete
<label for="webhook_delivery_url">
[110] Fix | Delete
<?php esc_html_e( 'Delivery URL', 'woocommerce' ); ?>
[111] Fix | Delete
<?php echo wc_help_tip( __( 'URL where the webhook payload is delivered.', 'woocommerce' ) ); ?>
[112] Fix | Delete
</label>
[113] Fix | Delete
</th>
[114] Fix | Delete
<td class="forminp">
[115] Fix | Delete
<input name="webhook_delivery_url" id="webhook_delivery_url" type="text" class="input-text regular-input" value="<?php echo esc_attr( $webhook->get_delivery_url() ); ?>" />
[116] Fix | Delete
</td>
[117] Fix | Delete
</tr>
[118] Fix | Delete
<tr valign="top">
[119] Fix | Delete
<th scope="row" class="titledesc">
[120] Fix | Delete
<label for="webhook_secret">
[121] Fix | Delete
<?php esc_html_e( 'Secret', 'woocommerce' ); ?>
[122] Fix | Delete
<?php echo wc_help_tip( __( 'The secret key is used to generate a hash of the delivered webhook and provided in the request headers.', 'woocommerce' ) ); ?>
[123] Fix | Delete
</label>
[124] Fix | Delete
</th>
[125] Fix | Delete
<td class="forminp">
[126] Fix | Delete
<input name="webhook_secret" id="webhook_secret" type="text" class="input-text regular-input" value="<?php echo esc_attr( $webhook->get_secret() ); ?>" />
[127] Fix | Delete
</td>
[128] Fix | Delete
</tr>
[129] Fix | Delete
<tr valign="top">
[130] Fix | Delete
<th scope="row" class="titledesc">
[131] Fix | Delete
<label for="webhook_api_version">
[132] Fix | Delete
<?php esc_html_e( 'API Version', 'woocommerce' ); ?>
[133] Fix | Delete
<?php echo wc_help_tip( __( 'REST API version used in the webhook deliveries.', 'woocommerce' ) ); ?>
[134] Fix | Delete
</label>
[135] Fix | Delete
</th>
[136] Fix | Delete
<td class="forminp">
[137] Fix | Delete
<select name="webhook_api_version" id="webhook_api_version">
[138] Fix | Delete
<?php foreach ( array_reverse( wc_get_webhook_rest_api_versions() ) as $version ) : ?>
[139] Fix | Delete
<option value="<?php echo esc_attr( $version ); ?>" <?php selected( $version, $webhook->get_api_version(), true ); ?>>
[140] Fix | Delete
<?php
[141] Fix | Delete
/* translators: %d: rest api version number */
[142] Fix | Delete
echo esc_html( sprintf( __( 'WP REST API Integration v%d', 'woocommerce' ), str_replace( 'wp_api_v', '', $version ) ) );
[143] Fix | Delete
?>
[144] Fix | Delete
</option>
[145] Fix | Delete
<?php endforeach; ?>
[146] Fix | Delete
<?php
[147] Fix | Delete
$legacy_api_option_name =
[148] Fix | Delete
WC()->legacy_rest_api_is_available() ?
[149] Fix | Delete
__( 'Legacy API v3 (deprecated)', 'woocommerce' ) :
[150] Fix | Delete
__( 'Legacy API v3 (⚠️ NOT AVAILABLE)', 'woocommerce' );
[151] Fix | Delete
?>
[152] Fix | Delete
<option value="legacy_v3" <?php selected( 'legacy_v3', $webhook->get_api_version(), true ); ?>><?php echo esc_html( $legacy_api_option_name ); ?></option>
[153] Fix | Delete
</select>
[154] Fix | Delete
</td>
[155] Fix | Delete
</tr>
[156] Fix | Delete
</tbody>
[157] Fix | Delete
</table>
[158] Fix | Delete
[159] Fix | Delete
<?php
[160] Fix | Delete
/**
[161] Fix | Delete
* Fires within the webhook editor, after the Webhook Data fields have rendered.
[162] Fix | Delete
*
[163] Fix | Delete
* @param WC_Webhook $webhook
[164] Fix | Delete
*/
[165] Fix | Delete
do_action( 'woocommerce_webhook_options', $webhook );
[166] Fix | Delete
?>
[167] Fix | Delete
</div>
[168] Fix | Delete
[169] Fix | Delete
<div id="webhook-actions" class="settings-panel">
[170] Fix | Delete
<h2><?php esc_html_e( 'Webhook actions', 'woocommerce' ); ?></h2>
[171] Fix | Delete
<table class="form-table">
[172] Fix | Delete
<tbody>
[173] Fix | Delete
<?php if ( $webhook->get_date_created() && '0000-00-00 00:00:00' !== $webhook->get_date_created()->date( 'Y-m-d H:i:s' ) ) : ?>
[174] Fix | Delete
<?php if ( is_null( $webhook->get_date_modified() ) ) : ?>
[175] Fix | Delete
<tr valign="top">
[176] Fix | Delete
<th scope="row" class="titledesc">
[177] Fix | Delete
<?php esc_html_e( 'Created at', 'woocommerce' ); ?>
[178] Fix | Delete
</th>
[179] Fix | Delete
<td class="forminp">
[180] Fix | Delete
<?php echo esc_html( date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $webhook->get_date_created()->date( 'Y-m-d H:i:s' ) ) ) ); ?>
[181] Fix | Delete
</td>
[182] Fix | Delete
</tr>
[183] Fix | Delete
<?php else : ?>
[184] Fix | Delete
<tr valign="top">
[185] Fix | Delete
<th scope="row" class="titledesc">
[186] Fix | Delete
<?php esc_html_e( 'Created at', 'woocommerce' ); ?>
[187] Fix | Delete
</th>
[188] Fix | Delete
<td class="forminp">
[189] Fix | Delete
<?php echo esc_html( date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $webhook->get_date_created()->date( 'Y-m-d H:i:s' ) ) ) ); ?>
[190] Fix | Delete
</td>
[191] Fix | Delete
</tr>
[192] Fix | Delete
<tr valign="top">
[193] Fix | Delete
<th scope="row" class="titledesc">
[194] Fix | Delete
<?php esc_html_e( 'Updated at', 'woocommerce' ); ?>
[195] Fix | Delete
</th>
[196] Fix | Delete
<td class="forminp">
[197] Fix | Delete
<?php echo esc_html( date_i18n( __( 'M j, Y @ G:i', 'woocommerce' ), strtotime( $webhook->get_date_modified()->date( 'Y-m-d H:i:s' ) ) ) ); ?>
[198] Fix | Delete
</td>
[199] Fix | Delete
</tr>
[200] Fix | Delete
<?php endif; ?>
[201] Fix | Delete
<?php endif; ?>
[202] Fix | Delete
<tr valign="top">
[203] Fix | Delete
<td colspan="2" scope="row" style="padding-left: 0;">
[204] Fix | Delete
<p class="submit">
[205] Fix | Delete
<button type="submit" class="button button-primary button-large" name="save" id="publish" accesskey="p"><?php esc_html_e( 'Save webhook', 'woocommerce' ); ?></button>
[206] Fix | Delete
<?php
[207] Fix | Delete
if ( $webhook->get_id() ) :
[208] Fix | Delete
$delete_url = wp_nonce_url(
[209] Fix | Delete
add_query_arg(
[210] Fix | Delete
array(
[211] Fix | Delete
'delete' => $webhook->get_id(),
[212] Fix | Delete
),
[213] Fix | Delete
admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' )
[214] Fix | Delete
),
[215] Fix | Delete
'delete-webhook'
[216] Fix | Delete
);
[217] Fix | Delete
?>
[218] Fix | Delete
<a style="color: #a00; text-decoration: none; margin-left: 10px;" href="<?php echo esc_url( $delete_url ); ?>"><?php esc_html_e( 'Delete permanently', 'woocommerce' ); ?></a>
[219] Fix | Delete
<?php endif; ?>
[220] Fix | Delete
</p>
[221] Fix | Delete
</td>
[222] Fix | Delete
</tr>
[223] Fix | Delete
</tbody>
[224] Fix | Delete
</table>
[225] Fix | Delete
</div>
[226] Fix | Delete
[227] Fix | Delete
<script type="text/javascript">
[228] Fix | Delete
jQuery( function ( $ ) {
[229] Fix | Delete
$( '#webhook-options' ).find( '#webhook_topic' ).on( 'change', function() {
[230] Fix | Delete
var current = $( this ).val(),
[231] Fix | Delete
action_event_field = $( '#webhook-options' ).find( '#webhook-action-event-wrap' );
[232] Fix | Delete
[233] Fix | Delete
action_event_field.hide();
[234] Fix | Delete
[235] Fix | Delete
if ( 'action' === current ) {
[236] Fix | Delete
action_event_field.show();
[237] Fix | Delete
}
[238] Fix | Delete
}).trigger( 'change' );
[239] Fix | Delete
});
[240] Fix | Delete
</script>
[241] Fix | Delete
[242] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function