Use new code style
This commit is contained in:
@ -66,17 +66,20 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
|
||||
wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), array('jquery', 'wu-sweet-alert'));
|
||||
|
||||
wp_localize_script('wu-webhook-page', 'wu_webhook_page', array(
|
||||
'i18n' => array(
|
||||
'error_title' => __('Webhook Test', 'wp-ultimo'),
|
||||
'error_message' => __('An error occurred when sending the test webhook, please try again.', 'wp-ultimo'),
|
||||
'copied' => __('Copied!', 'wp-ultimo'),
|
||||
),
|
||||
));
|
||||
wp_localize_script(
|
||||
'wu-webhook-page',
|
||||
'wu_webhook_page',
|
||||
array(
|
||||
'i18n' => array(
|
||||
'error_title' => __('Webhook Test', 'wp-ultimo'),
|
||||
'error_message' => __('An error occurred when sending the test webhook, please try again.', 'wp-ultimo'),
|
||||
'copied' => __('Copied!', 'wp-ultimo'),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_script('wu-webhook-page');
|
||||
|
||||
} // end register_scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register ajax forms that we use for add new webhooks.
|
||||
@ -88,13 +91,15 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
/*
|
||||
* Add new webhook.
|
||||
*/
|
||||
wu_register_form('add_new_webhook_modal', array(
|
||||
'render' => array($this, 'render_add_new_webhook_modal'),
|
||||
'handler' => array($this, 'handle_add_new_webhook_modal'),
|
||||
'capability' => 'wu_edit_webhooks',
|
||||
));
|
||||
|
||||
} // end register_forms;
|
||||
wu_register_form(
|
||||
'add_new_webhook_modal',
|
||||
array(
|
||||
'render' => array($this, 'render_add_new_webhook_modal'),
|
||||
'handler' => array($this, 'handle_add_new_webhook_modal'),
|
||||
'capability' => 'wu_edit_webhooks',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the add new webhook modal.
|
||||
@ -109,10 +114,8 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
$event_options = array();
|
||||
|
||||
foreach ($events as $slug => $event) {
|
||||
|
||||
$event_options[$slug] = $event['name'];
|
||||
|
||||
} // end foreach;
|
||||
$event_options[ $slug ] = $event['name'];
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'name' => array(
|
||||
@ -125,7 +128,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
'title' => __('Event', 'wp-ultimo'),
|
||||
'type' => 'select',
|
||||
'desc' => __('The event that will trigger the webhook.', 'wp-ultimo'),
|
||||
'options' => $event_options
|
||||
'options' => $event_options,
|
||||
),
|
||||
'webhook_url' => array(
|
||||
'type' => 'url',
|
||||
@ -145,21 +148,26 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
),
|
||||
);
|
||||
|
||||
$form = new \WP_Ultimo\UI\Form('edit_line_item', $fields, array(
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'data-wu-app' => 'edit_line_item',
|
||||
'data-state' => json_encode(array(
|
||||
'event' => ''
|
||||
)),
|
||||
),
|
||||
));
|
||||
$form = new \WP_Ultimo\UI\Form(
|
||||
'edit_line_item',
|
||||
$fields,
|
||||
array(
|
||||
'views' => 'admin-pages/fields',
|
||||
'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0',
|
||||
'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid',
|
||||
'html_attr' => array(
|
||||
'data-wu-app' => 'edit_line_item',
|
||||
'data-state' => json_encode(
|
||||
array(
|
||||
'event' => '',
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$form->render();
|
||||
|
||||
} // end render_add_new_webhook_modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the add new webhook modal.
|
||||
@ -172,20 +180,20 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
$status = wu_create_webhook($_POST);
|
||||
|
||||
if (is_wp_error($status)) {
|
||||
|
||||
wp_send_json_error($status);
|
||||
|
||||
} else {
|
||||
|
||||
wp_send_json_success(array(
|
||||
'redirect_url' => wu_network_admin_url('wp-ultimo-edit-webhook', array(
|
||||
'id' => $status->get_id()
|
||||
))
|
||||
));
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end handle_add_new_webhook_modal;
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'redirect_url' => wu_network_admin_url(
|
||||
'wp-ultimo-edit-webhook',
|
||||
array(
|
||||
'id' => $status->get_id(),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow child classes to register widgets, if they need them.
|
||||
@ -193,7 +201,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {} // end register_widgets;
|
||||
public function register_widgets() {}
|
||||
|
||||
/**
|
||||
* Returns an array with the labels for the edit page.
|
||||
@ -207,8 +215,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
'deleted_message' => __('Webhook removed successfully.', 'wp-ultimo'),
|
||||
'search_label' => __('Search Webhook', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end get_labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of the page.
|
||||
@ -219,8 +226,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
public function get_title() {
|
||||
|
||||
return __('Webhooks', 'wp-ultimo');
|
||||
|
||||
} // end get_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of menu for this page.
|
||||
@ -231,8 +237,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
public function get_menu_title() {
|
||||
|
||||
return __('Webhooks', 'wp-ultimo');
|
||||
|
||||
} // end get_menu_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows admins to rename the sub-menu (first item) for a top-level page.
|
||||
@ -243,8 +248,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
public function get_submenu_title() {
|
||||
|
||||
return __('Webhooks', 'wp-ultimo');
|
||||
|
||||
} // end get_submenu_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action links for that page.
|
||||
@ -262,8 +266,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
'url' => wu_get_form_url('add_new_webhook_modal'),
|
||||
),
|
||||
);
|
||||
|
||||
} // end action_links;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -275,7 +278,5 @@ class Webhook_List_Admin_Page extends List_Admin_Page {
|
||||
public function table() {
|
||||
|
||||
return new \WP_Ultimo\List_Tables\Webhook_List_Table();
|
||||
|
||||
} // end table;
|
||||
|
||||
} // end class Webhook_List_Admin_Page;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user