Skip to content

Commit

Permalink
Added webhook meta box js
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Dec 16, 2014
1 parent 1fae690 commit 9f83541
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
16 changes: 16 additions & 0 deletions assets/js/admin/meta-boxes-webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
jQuery( function ( $ ) {
$( '#webhook-options #topic' ).on( 'change', function() {
var current = $( this ).val(),
action_event_field = $( '#webhook-options .action_event_field' ),
custom_topic_field = $( '#webhook-options .custom_topic_field' );

action_event_field.hide();
custom_topic_field.hide();

if ( 'action' === current ) {
action_event_field.show();
} else if ( 'custom' === current ) {
custom_topic_field.show();
}
}).change();
});
1 change: 1 addition & 0 deletions assets/js/admin/meta-boxes-webhook.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 13 additions & 10 deletions includes/admin/class-wc-admin-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public function admin_scripts() {
if ( in_array( $screen->id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
}
if ( 'shop_webhook' == $screen->id ) {
wp_enqueue_script( 'wc-admin-webhook-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-webhook' . $suffix . '.js', array( 'jquery' ), WC_VERSION, true );
}
if ( in_array( str_replace( 'edit-', '', $screen->id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
$params = array(
'remove_item_notice' => __( 'Are you sure you want to remove the selected items? If you have previously reduced this item\'s stock, or this order was submitted by a customer, you will need to manually restore the item\'s stock.', 'woocommerce' ),
Expand Down Expand Up @@ -224,16 +227,16 @@ public function admin_scripts() {
'no_customer_selected' => __( 'No customer selected', 'woocommerce' ),
'plugin_url' => WC()->plugin_url(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'order_item_nonce' => wp_create_nonce("order-item"),
'add_attribute_nonce' => wp_create_nonce("add-attribute"),
'save_attributes_nonce' => wp_create_nonce("save-attributes"),
'calc_totals_nonce' => wp_create_nonce("calc-totals"),
'get_customer_details_nonce' => wp_create_nonce("get-customer-details"),
'search_products_nonce' => wp_create_nonce("search-products"),
'grant_access_nonce' => wp_create_nonce("grant-access"),
'revoke_access_nonce' => wp_create_nonce("revoke-access"),
'add_order_note_nonce' => wp_create_nonce("add-order-note"),
'delete_order_note_nonce' => wp_create_nonce("delete-order-note"),
'order_item_nonce' => wp_create_nonce( 'order-item' ),
'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ),
'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ),
'calc_totals_nonce' => wp_create_nonce( 'calc-totals' ),
'get_customer_details_nonce' => wp_create_nonce( 'get-customer-details' ),
'search_products_nonce' => wp_create_nonce( 'search-products' ),
'grant_access_nonce' => wp_create_nonce( 'grant-access' ),
'revoke_access_nonce' => wp_create_nonce( 'revoke-access' ),
'add_order_note_nonce' => wp_create_nonce( 'add-order-note' ),
'delete_order_note_nonce' => wp_create_nonce( 'delete-order-note' ),
'calendar_image' => WC()->plugin_url().'/assets/images/calendar.png',
'post_id' => isset( $post->ID ) ? $post->ID : '',
'base_country' => WC()->countries->get_base_country(),
Expand Down
2 changes: 2 additions & 0 deletions includes/admin/wc-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ function wc_get_screen_ids() {
'edit-product_tag',
'edit-product_shipping_class',
'profile',
'shop_webhook',
'edit-shop_webhook'
);

foreach ( wc_get_order_types() as $type ) {
Expand Down

0 comments on commit 9f83541

Please sign in to comment.