Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes/admin
File: class-wc-admin-webhooks.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WooCommerce Admin Webhooks Class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WooCommerce\Admin
[4] Fix | Delete
* @version 3.3.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
defined( 'ABSPATH' ) || exit;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* WC_Admin_Webhooks.
[11] Fix | Delete
*/
[12] Fix | Delete
class WC_Admin_Webhooks {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Initialize the webhooks admin actions.
[16] Fix | Delete
*/
[17] Fix | Delete
public function __construct() {
[18] Fix | Delete
add_action( 'admin_init', array( $this, 'actions' ) );
[19] Fix | Delete
add_action( 'woocommerce_settings_page_init', array( $this, 'screen_option' ) );
[20] Fix | Delete
add_filter( 'woocommerce_save_settings_advanced_webhooks', array( $this, 'allow_save_settings' ) );
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Check if should allow save settings.
[25] Fix | Delete
* This prevents "Your settings have been saved." notices on the table list.
[26] Fix | Delete
*
[27] Fix | Delete
* @param bool $allow If allow save settings.
[28] Fix | Delete
* @return bool
[29] Fix | Delete
*/
[30] Fix | Delete
public function allow_save_settings( $allow ) {
[31] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[32] Fix | Delete
if ( ! isset( $_GET['edit-webhook'] ) ) {
[33] Fix | Delete
return false;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
return $allow;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Check if is webhook settings page.
[41] Fix | Delete
*
[42] Fix | Delete
* @return bool
[43] Fix | Delete
*/
[44] Fix | Delete
private function is_webhook_settings_page() {
[45] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[46] Fix | Delete
return is_wc_admin_settings_page() && isset( $_GET['tab'], $_GET['section'] ) && 'advanced' === $_GET['tab'] && 'webhooks' === $_GET['section'];
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Save method.
[51] Fix | Delete
*/
[52] Fix | Delete
private function save() {
[53] Fix | Delete
check_admin_referer( 'woocommerce-settings' );
[54] Fix | Delete
[55] Fix | Delete
if ( ! current_user_can( 'manage_woocommerce' ) ) {
[56] Fix | Delete
wp_die( esc_html__( 'You do not have permission to update Webhooks', 'woocommerce' ) );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
$errors = array();
[60] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[61] Fix | Delete
$webhook_id = isset( $_POST['webhook_id'] ) ? absint( $_POST['webhook_id'] ) : 0;
[62] Fix | Delete
$webhook = new WC_Webhook( $webhook_id );
[63] Fix | Delete
[64] Fix | Delete
// Name.
[65] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[66] Fix | Delete
if ( ! empty( $_POST['webhook_name'] ) ) {
[67] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[68] Fix | Delete
$name = sanitize_text_field( wp_unslash( $_POST['webhook_name'] ) );
[69] Fix | Delete
} else {
[70] Fix | Delete
$name = sprintf(
[71] Fix | Delete
/* translators: %s: date */
[72] Fix | Delete
__( 'Webhook created on %s', 'woocommerce' ),
[73] Fix | Delete
// @codingStandardsIgnoreStart
[74] Fix | Delete
(new DateTime('now'))->format( _x( 'M d, Y @ h:i A', 'Webhook created on date parsed by DateTime::format', 'woocommerce' ) )
[75] Fix | Delete
// @codingStandardsIgnoreEnd
[76] Fix | Delete
);
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
$webhook->set_name( $name );
[80] Fix | Delete
[81] Fix | Delete
if ( ! $webhook->get_user_id() ) {
[82] Fix | Delete
$webhook->set_user_id( get_current_user_id() );
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
// Status.
[86] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[87] Fix | Delete
$webhook->set_status( ! empty( $_POST['webhook_status'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_status'] ) ) : 'disabled' );
[88] Fix | Delete
[89] Fix | Delete
// Delivery URL.
[90] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[91] Fix | Delete
$delivery_url = ! empty( $_POST['webhook_delivery_url'] ) ? esc_url_raw( wp_unslash( $_POST['webhook_delivery_url'] ) ) : '';
[92] Fix | Delete
[93] Fix | Delete
if ( wc_is_valid_url( $delivery_url ) ) {
[94] Fix | Delete
$webhook->set_delivery_url( $delivery_url );
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
// Secret.
[98] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[99] Fix | Delete
$secret = ! empty( $_POST['webhook_secret'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_secret'] ) ) : wp_generate_password( 50, true, true );
[100] Fix | Delete
$webhook->set_secret( $secret );
[101] Fix | Delete
[102] Fix | Delete
// Topic.
[103] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[104] Fix | Delete
if ( ! empty( $_POST['webhook_topic'] ) ) {
[105] Fix | Delete
$resource = '';
[106] Fix | Delete
$event = '';
[107] Fix | Delete
[108] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[109] Fix | Delete
switch ( $_POST['webhook_topic'] ) {
[110] Fix | Delete
case 'action':
[111] Fix | Delete
$resource = 'action';
[112] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[113] Fix | Delete
$event = ! empty( $_POST['webhook_action_event'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_action_event'] ) ) : '';
[114] Fix | Delete
break;
[115] Fix | Delete
[116] Fix | Delete
default:
[117] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[118] Fix | Delete
list( $resource, $event ) = explode( '.', sanitize_text_field( wp_unslash( $_POST['webhook_topic'] ) ) );
[119] Fix | Delete
break;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
$topic = $resource . '.' . $event;
[123] Fix | Delete
[124] Fix | Delete
if ( wc_is_webhook_valid_topic( $topic ) ) {
[125] Fix | Delete
$webhook->set_topic( $topic );
[126] Fix | Delete
} else {
[127] Fix | Delete
$errors[] = __( 'Webhook topic unknown. Please select a valid topic.', 'woocommerce' );
[128] Fix | Delete
}
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
// API version.
[132] Fix | Delete
$rest_api_versions = wc_get_webhook_rest_api_versions();
[133] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[134] Fix | Delete
$webhook->set_api_version( ! empty( $_POST['webhook_api_version'] ) ? sanitize_text_field( wp_unslash( $_POST['webhook_api_version'] ) ) : end( $rest_api_versions ) );
[135] Fix | Delete
[136] Fix | Delete
$webhook->save();
[137] Fix | Delete
[138] Fix | Delete
// Run actions.
[139] Fix | Delete
do_action( 'woocommerce_webhook_options_save', $webhook->get_id() );
[140] Fix | Delete
if ( $errors ) {
[141] Fix | Delete
// Redirect to webhook edit page to avoid settings save actions.
[142] Fix | Delete
wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( implode( '|', $errors ) ) ) );
[143] Fix | Delete
exit();
[144] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[145] Fix | Delete
} elseif ( isset( $_POST['webhook_status'] ) && 'active' === $_POST['webhook_status'] && $webhook->get_pending_delivery() ) {
[146] Fix | Delete
// Ping the webhook at the first time that is activated.
[147] Fix | Delete
$result = $webhook->deliver_ping();
[148] Fix | Delete
[149] Fix | Delete
if ( is_wp_error( $result ) ) {
[150] Fix | Delete
// Redirect to webhook edit page to avoid settings save actions.
[151] Fix | Delete
wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&error=' . rawurlencode( $result->get_error_message() ) ) );
[152] Fix | Delete
exit();
[153] Fix | Delete
}
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
// Redirect to webhook edit page to avoid settings save actions.
[157] Fix | Delete
wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=' . $webhook->get_id() . '&updated=1' ) );
[158] Fix | Delete
exit();
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Bulk delete.
[163] Fix | Delete
*
[164] Fix | Delete
* @param array $webhooks List of webhooks IDs.
[165] Fix | Delete
*/
[166] Fix | Delete
public static function bulk_delete( $webhooks ) {
[167] Fix | Delete
foreach ( $webhooks as $webhook_id ) {
[168] Fix | Delete
$webhook = new WC_Webhook( (int) $webhook_id );
[169] Fix | Delete
$webhook->delete( true );
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
$qty = count( $webhooks );
[173] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[174] Fix | Delete
$status = isset( $_GET['status'] ) ? '&status=' . sanitize_text_field( wp_unslash( $_GET['status'] ) ) : '';
[175] Fix | Delete
[176] Fix | Delete
// Redirect to webhooks page.
[177] Fix | Delete
wp_safe_redirect( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' . $status . '&deleted=' . $qty ) );
[178] Fix | Delete
exit();
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* Delete webhook.
[183] Fix | Delete
*/
[184] Fix | Delete
private function delete() {
[185] Fix | Delete
check_admin_referer( 'delete-webhook' );
[186] Fix | Delete
[187] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[188] Fix | Delete
if ( isset( $_GET['delete'] ) ) {
[189] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[190] Fix | Delete
$webhook_id = absint( $_GET['delete'] );
[191] Fix | Delete
[192] Fix | Delete
if ( $webhook_id ) {
[193] Fix | Delete
self::bulk_delete( array( $webhook_id ) );
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Webhooks admin actions.
[200] Fix | Delete
*/
[201] Fix | Delete
public function actions() {
[202] Fix | Delete
if ( $this->is_webhook_settings_page() ) {
[203] Fix | Delete
// Save.
[204] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Missing
[205] Fix | Delete
if ( isset( $_POST['save'] ) && isset( $_POST['webhook_id'] ) ) {
[206] Fix | Delete
$this->save();
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
// Delete webhook.
[210] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[211] Fix | Delete
if ( isset( $_GET['delete'] ) ) {
[212] Fix | Delete
$this->delete();
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* Page output.
[219] Fix | Delete
*/
[220] Fix | Delete
public static function page_output() {
[221] Fix | Delete
// Hide the save button.
[222] Fix | Delete
$GLOBALS['hide_save_button'] = true;
[223] Fix | Delete
[224] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[225] Fix | Delete
if ( isset( $_GET['edit-webhook'] ) ) {
[226] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[227] Fix | Delete
$webhook_id = absint( $_GET['edit-webhook'] );
[228] Fix | Delete
$webhook = new WC_Webhook( $webhook_id );
[229] Fix | Delete
[230] Fix | Delete
include __DIR__ . '/settings/views/html-webhooks-edit.php';
[231] Fix | Delete
return;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
self::table_list_output();
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* Notices.
[239] Fix | Delete
*/
[240] Fix | Delete
public static function notices() {
[241] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[242] Fix | Delete
if ( isset( $_GET['deleted'] ) ) {
[243] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[244] Fix | Delete
$deleted = absint( $_GET['deleted'] );
[245] Fix | Delete
[246] Fix | Delete
/* translators: %d: count */
[247] Fix | Delete
WC_Admin_Settings::add_message( sprintf( _n( '%d webhook permanently deleted.', '%d webhooks permanently deleted.', $deleted, 'woocommerce' ), $deleted ) );
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[251] Fix | Delete
if ( isset( $_GET['updated'] ) ) {
[252] Fix | Delete
WC_Admin_Settings::add_message( __( 'Webhook updated successfully.', 'woocommerce' ) );
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[256] Fix | Delete
if ( isset( $_GET['created'] ) ) {
[257] Fix | Delete
WC_Admin_Settings::add_message( __( 'Webhook created successfully.', 'woocommerce' ) );
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[261] Fix | Delete
if ( isset( $_GET['error'] ) ) {
[262] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[263] Fix | Delete
foreach ( explode( '|', sanitize_text_field( wp_unslash( $_GET['error'] ) ) ) as $message ) {
[264] Fix | Delete
WC_Admin_Settings::add_error( trim( $message ) );
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
/**
[270] Fix | Delete
* Add screen option.
[271] Fix | Delete
*/
[272] Fix | Delete
public function screen_option() {
[273] Fix | Delete
global $webhooks_table_list;
[274] Fix | Delete
[275] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[276] Fix | Delete
if ( ! isset( $_GET['edit-webhook'] ) && $this->is_webhook_settings_page() ) {
[277] Fix | Delete
$webhooks_table_list = new WC_Admin_Webhooks_Table_List();
[278] Fix | Delete
[279] Fix | Delete
// Add screen option.
[280] Fix | Delete
add_screen_option(
[281] Fix | Delete
'per_page',
[282] Fix | Delete
array(
[283] Fix | Delete
'default' => 10,
[284] Fix | Delete
'option' => 'woocommerce_webhooks_per_page',
[285] Fix | Delete
)
[286] Fix | Delete
);
[287] Fix | Delete
}
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Table list output.
[292] Fix | Delete
*/
[293] Fix | Delete
private static function table_list_output() {
[294] Fix | Delete
global $webhooks_table_list;
[295] Fix | Delete
[296] Fix | Delete
echo '<h2 class="wc-table-list-header">' . esc_html__( 'Webhooks', 'woocommerce' ) . ' <a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ) . '" class="page-title-action">' . esc_html__( 'Add webhook', 'woocommerce' ) . '</a></h2>';
[297] Fix | Delete
[298] Fix | Delete
// Get the webhooks count.
[299] Fix | Delete
$data_store = WC_Data_Store::load( 'webhook' );
[300] Fix | Delete
$num_webhooks = $data_store->get_count_webhooks_by_status();
[301] Fix | Delete
$count = array_sum( $num_webhooks );
[302] Fix | Delete
[303] Fix | Delete
if ( $count > 0 ) {
[304] Fix | Delete
$webhooks_table_list->process_bulk_action();
[305] Fix | Delete
$webhooks_table_list->prepare_items();
[306] Fix | Delete
[307] Fix | Delete
echo '<input type="hidden" name="page" value="wc-settings" />';
[308] Fix | Delete
echo '<input type="hidden" name="tab" value="advanced" />';
[309] Fix | Delete
echo '<input type="hidden" name="section" value="webhooks" />';
[310] Fix | Delete
[311] Fix | Delete
self::maybe_display_legacy_rest_api_warning();
[312] Fix | Delete
[313] Fix | Delete
$webhooks_table_list->views();
[314] Fix | Delete
$webhooks_table_list->search_box( __( 'Search webhooks', 'woocommerce' ), 'webhook' );
[315] Fix | Delete
$webhooks_table_list->display();
[316] Fix | Delete
} else {
[317] Fix | Delete
echo '<div class="woocommerce-BlankState woocommerce-BlankState--webhooks">';
[318] Fix | Delete
?>
[319] Fix | Delete
<h2 class="woocommerce-BlankState-message"><?php esc_html_e( 'Webhooks are event notifications sent to URLs of your choice. They can be used to integrate with third-party services which support them.', 'woocommerce' ); ?></h2>
[320] Fix | Delete
<a class="woocommerce-BlankState-cta button-primary button" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks&edit-webhook=0' ) ); ?>"><?php esc_html_e( 'Create a new webhook', 'woocommerce' ); ?></a>
[321] Fix | Delete
<style type="text/css">#posts-filter .wp-list-table, #posts-filter .tablenav.top, .tablenav.bottom .actions { display: none; }</style>
[322] Fix | Delete
<?php
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
/**
[327] Fix | Delete
* Display a warning message if the Legacy REST API extension is not installed
[328] Fix | Delete
* and there are webhooks configured to use the legacy payload format.
[329] Fix | Delete
*/
[330] Fix | Delete
private static function maybe_display_legacy_rest_api_warning() {
[331] Fix | Delete
global $webhooks_table_list;
[332] Fix | Delete
[333] Fix | Delete
if ( WC()->legacy_rest_api_is_available() ) {
[334] Fix | Delete
return;
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
$legacy_api_webhooks_count = $webhooks_table_list->get_legacy_api_webhooks_count();
[338] Fix | Delete
if ( 0 === $legacy_api_webhooks_count ) {
[339] Fix | Delete
return;
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
?>
[343] Fix | Delete
<div class='error inline'>
[344] Fix | Delete
<p><strong>
[345] Fix | Delete
<?php echo esc_html__( 'Incompatible webhooks warning', 'woocommerce' ); ?>
[346] Fix | Delete
</strong></p>
[347] Fix | Delete
<p>
[348] Fix | Delete
<?php
[349] Fix | Delete
echo wp_kses_data(
[350] Fix | Delete
sprintf(
[351] Fix | Delete
/* translators: %s = webhooks count */
[352] Fix | Delete
_n(
[353] Fix | Delete
"There's %d webhook that is configured to be delivered using the Legacy REST API, which has been removed from WooCommerce. This webhook will fail to be sent.",
[354] Fix | Delete
'There are %d webhooks that are configured to be delivered using the Legacy REST API, which has been removed from WooCommerce. These webhooks will fail to be sent.',
[355] Fix | Delete
$legacy_api_webhooks_count,
[356] Fix | Delete
'woocommerce'
[357] Fix | Delete
),
[358] Fix | Delete
$legacy_api_webhooks_count,
[359] Fix | Delete
'woocommerce'
[360] Fix | Delete
)
[361] Fix | Delete
);
[362] Fix | Delete
?>
[363] Fix | Delete
</p>
[364] Fix | Delete
<p>
[365] Fix | Delete
<?php
[366] Fix | Delete
echo wp_kses(
[367] Fix | Delete
sprintf(
[368] Fix | Delete
/* translators: %s = URL */
[369] Fix | Delete
_n(
[370] Fix | Delete
'This webhook has the ⚠️ symbol in front of its name in the list below. Please either edit the webhook to use a different delivery format, or install and activate <a href="%s" target="_blank">the WooCommerce Legacy REST API extension</a>.',
[371] Fix | Delete
'These webhooks have the ⚠️ symbol in front of their names in the list below. Please either edit the webhooks to use a different delivery format, or install and activate <a href="%s" target="_blank">the WooCommerce Legacy REST API extension</a>.',
[372] Fix | Delete
$legacy_api_webhooks_count,
[373] Fix | Delete
'woocommerce'
[374] Fix | Delete
),
[375] Fix | Delete
'https://wordpress.org/plugins/woocommerce-legacy-rest-api/'
[376] Fix | Delete
),
[377] Fix | Delete
array(
[378] Fix | Delete
'a' => array(
[379] Fix | Delete
'href' => array(),
[380] Fix | Delete
'target' => array(),
[381] Fix | Delete
),
[382] Fix | Delete
)
[383] Fix | Delete
);
[384] Fix | Delete
?>
[385] Fix | Delete
</p>
[386] Fix | Delete
<p><strong>
[387] Fix | Delete
<?php
[388] Fix | Delete
echo wp_kses_data(
[389] Fix | Delete
sprintf(
[390] Fix | Delete
/* translators: %s is an URL */
[391] Fix | Delete
__( "<a href='%s'>More information</a>", 'woocommerce' ),
[392] Fix | Delete
'https://developer.woocommerce.com/2023/10/03/the-legacy-rest-api-will-move-to-a-dedicated-extension-in-woocommerce-9-0/'
[393] Fix | Delete
)
[394] Fix | Delete
);
[395] Fix | Delete
?>
[396] Fix | Delete
</strong></p>
[397] Fix | Delete
</div>
[398] Fix | Delete
<?php
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
/**
[402] Fix | Delete
* Logs output.
[403] Fix | Delete
*
[404] Fix | Delete
* @deprecated 3.3.0
[405] Fix | Delete
* @param WC_Webhook $webhook Deprecated.
[406] Fix | Delete
*/
[407] Fix | Delete
public static function logs_output( $webhook = 'deprecated' ) {
[408] Fix | Delete
wc_deprecated_function( 'WC_Admin_Webhooks::logs_output', '3.3' );
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
/**
[412] Fix | Delete
* Get the webhook topic data.
[413] Fix | Delete
*
[414] Fix | Delete
* @param WC_Webhook $webhook Webhook instance.
[415] Fix | Delete
*
[416] Fix | Delete
* @return array
[417] Fix | Delete
*/
[418] Fix | Delete
public static function get_topic_data( $webhook ) {
[419] Fix | Delete
$topic = $webhook->get_topic();
[420] Fix | Delete
$event = '';
[421] Fix | Delete
$resource = '';
[422] Fix | Delete
[423] Fix | Delete
if ( $topic ) {
[424] Fix | Delete
list( $resource, $event ) = explode( '.', $topic );
[425] Fix | Delete
[426] Fix | Delete
if ( 'action' === $resource ) {
[427] Fix | Delete
$topic = 'action';
[428] Fix | Delete
} elseif ( ! in_array( $resource, array( 'coupon', 'customer', 'order', 'product' ), true ) ) {
[429] Fix | Delete
$topic = 'custom';
[430] Fix | Delete
}
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
return array(
[434] Fix | Delete
'topic' => $topic,
[435] Fix | Delete
'event' => $event,
[436] Fix | Delete
'resource' => $resource,
[437] Fix | Delete
);
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
/**
[441] Fix | Delete
* Get the logs navigation.
[442] Fix | Delete
*
[443] Fix | Delete
* @deprecated 3.3.0
[444] Fix | Delete
* @param int $total Deprecated.
[445] Fix | Delete
* @param WC_Webhook $webhook Deprecated.
[446] Fix | Delete
*/
[447] Fix | Delete
public static function get_logs_navigation( $total, $webhook ) {
[448] Fix | Delete
wc_deprecated_function( 'WC_Admin_Webhooks::get_logs_navigation', '3.3' );
[449] Fix | Delete
}
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
new WC_Admin_Webhooks();
[453] Fix | Delete
[454] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function