Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Internal/Admin/Settings
File: Utils.php
<?php
[0] Fix | Delete
declare( strict_types=1 );
[1] Fix | Delete
[2] Fix | Delete
namespace Automattic\WooCommerce\Internal\Admin\Settings;
[3] Fix | Delete
[4] Fix | Delete
use Automattic\WooCommerce\Internal\Jetpack\JetpackConnection;
[5] Fix | Delete
use WP_REST_Request;
[6] Fix | Delete
[7] Fix | Delete
defined( 'ABSPATH' ) || exit;
[8] Fix | Delete
/**
[9] Fix | Delete
* Payments settings utilities class.
[10] Fix | Delete
*
[11] Fix | Delete
* @internal
[12] Fix | Delete
*/
[13] Fix | Delete
class Utils {
[14] Fix | Delete
/**
[15] Fix | Delete
* Apply order mappings to a base order map.
[16] Fix | Delete
*
[17] Fix | Delete
* @param array $base_map The base order map.
[18] Fix | Delete
* @param array $new_mappings The order mappings to apply.
[19] Fix | Delete
* This can be a full or partial list of the base one,
[20] Fix | Delete
* but it can also contain (only) new IDs and their orders.
[21] Fix | Delete
*
[22] Fix | Delete
* @return array The updated base order map, normalized.
[23] Fix | Delete
*/
[24] Fix | Delete
public static function order_map_apply_mappings( array $base_map, array $new_mappings ): array {
[25] Fix | Delete
// Make sure the base map is sorted ascending by their order values.
[26] Fix | Delete
// We don't normalize first because the order values have meaning.
[27] Fix | Delete
asort( $base_map );
[28] Fix | Delete
[29] Fix | Delete
$updated_map = $base_map;
[30] Fix | Delete
// Apply the new mappings in the order they were given.
[31] Fix | Delete
foreach ( $new_mappings as $id => $order ) {
[32] Fix | Delete
// If the ID is not in the base map, we ADD it at the desired order. Otherwise, we MOVE it.
[33] Fix | Delete
if ( ! isset( $base_map[ $id ] ) ) {
[34] Fix | Delete
$updated_map = self::order_map_add_at_order( $updated_map, $id, $order );
[35] Fix | Delete
continue;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
$updated_map = self::order_map_move_at_order( $updated_map, $id, $order );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
return self::order_map_normalize( $updated_map );
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Move an id at a specific order in an order map.
[46] Fix | Delete
*
[47] Fix | Delete
* This method is used to simulate the behavior of a drag&drop sorting UI:
[48] Fix | Delete
* - When moving an id down, all the ids with an order equal or lower than the desired order
[49] Fix | Delete
* but equal or higher than the current order are decreased by 1.
[50] Fix | Delete
* - When moving an id up, all the ids with an order equal or higher than the desired order
[51] Fix | Delete
* but equal or lower than the current order are increased by 1.
[52] Fix | Delete
*
[53] Fix | Delete
* @param array $order_map The order map.
[54] Fix | Delete
* @param string $id The id to place.
[55] Fix | Delete
* @param int $order The order at which to place the id.
[56] Fix | Delete
*
[57] Fix | Delete
* @return array The updated order map. This map is not normalized.
[58] Fix | Delete
*/
[59] Fix | Delete
public static function order_map_move_at_order( array $order_map, string $id, int $order ): array {
[60] Fix | Delete
// If the id is not in the order map, return the order map as is.
[61] Fix | Delete
if ( ! isset( $order_map[ $id ] ) ) {
[62] Fix | Delete
return $order_map;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
// If the id is already at the desired order, return the order map as is.
[66] Fix | Delete
if ( $order_map[ $id ] === $order ) {
[67] Fix | Delete
return $order_map;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// If there is no id at the desired order, just place the id there.
[71] Fix | Delete
if ( ! in_array( $order, $order_map, true ) ) {
[72] Fix | Delete
$order_map[ $id ] = $order;
[73] Fix | Delete
[74] Fix | Delete
return $order_map;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
// We apply the normal behavior of a drag&drop sorting UI.
[78] Fix | Delete
$existing_order = $order_map[ $id ];
[79] Fix | Delete
if ( $order > $existing_order ) {
[80] Fix | Delete
// Moving down.
[81] Fix | Delete
foreach ( $order_map as $key => $value ) {
[82] Fix | Delete
if ( $value <= $order && $value >= $existing_order ) {
[83] Fix | Delete
--$order_map[ $key ];
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
} else {
[87] Fix | Delete
// Moving up.
[88] Fix | Delete
foreach ( $order_map as $key => $value ) {
[89] Fix | Delete
if ( $value >= $order && $value <= $existing_order ) {
[90] Fix | Delete
++$order_map[ $key ];
[91] Fix | Delete
}
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
// Place the id at the desired order.
[96] Fix | Delete
$order_map[ $id ] = $order;
[97] Fix | Delete
[98] Fix | Delete
return $order_map;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Place an id at a specific order in an order map.
[103] Fix | Delete
*
[104] Fix | Delete
* @param array $order_map The order map.
[105] Fix | Delete
* @param string $id The id to place.
[106] Fix | Delete
* @param int $order The order at which to place the id.
[107] Fix | Delete
*
[108] Fix | Delete
* @return array The updated order map.
[109] Fix | Delete
*/
[110] Fix | Delete
public static function order_map_place_at_order( array $order_map, string $id, int $order ): array {
[111] Fix | Delete
// If the id is already at the desired order, return the order map as is.
[112] Fix | Delete
if ( isset( $order_map[ $id ] ) && $order_map[ $id ] === $order ) {
[113] Fix | Delete
return $order_map;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
// If there is no id at the desired order, just place the id there.
[117] Fix | Delete
if ( ! in_array( $order, $order_map, true ) ) {
[118] Fix | Delete
$order_map[ $id ] = $order;
[119] Fix | Delete
[120] Fix | Delete
return $order_map;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
// Bump the order of everything with an order equal or higher than the desired order.
[124] Fix | Delete
foreach ( $order_map as $key => $value ) {
[125] Fix | Delete
if ( $value >= $order ) {
[126] Fix | Delete
++$order_map[ $key ];
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
// Place the id at the desired order.
[131] Fix | Delete
$order_map[ $id ] = $order;
[132] Fix | Delete
[133] Fix | Delete
return $order_map;
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Add an id to a specific order in an order map.
[138] Fix | Delete
*
[139] Fix | Delete
* @param array $order_map The order map.
[140] Fix | Delete
* @param string $id The id to move.
[141] Fix | Delete
* @param int $order The order to move the id to.
[142] Fix | Delete
*
[143] Fix | Delete
* @return array The updated order map. If the id is already in the order map, the order map is returned as is.
[144] Fix | Delete
*/
[145] Fix | Delete
public static function order_map_add_at_order( array $order_map, string $id, int $order ): array {
[146] Fix | Delete
// If the id is in the order map, return the order map as is.
[147] Fix | Delete
if ( isset( $order_map[ $id ] ) ) {
[148] Fix | Delete
return $order_map;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
return self::order_map_place_at_order( $order_map, $id, $order );
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
/**
[155] Fix | Delete
* Normalize an order map.
[156] Fix | Delete
*
[157] Fix | Delete
* Sort the order map by the order and ensure the order values start from 0 and are consecutive.
[158] Fix | Delete
*
[159] Fix | Delete
* @param array $order_map The order map.
[160] Fix | Delete
*
[161] Fix | Delete
* @return array The normalized order map.
[162] Fix | Delete
*/
[163] Fix | Delete
public static function order_map_normalize( array $order_map ): array {
[164] Fix | Delete
asort( $order_map );
[165] Fix | Delete
[166] Fix | Delete
return array_flip( array_keys( $order_map ) );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Change the minimum order of an order map.
[171] Fix | Delete
*
[172] Fix | Delete
* @param array $order_map The order map.
[173] Fix | Delete
* @param int $new_min_order The new minimum order.
[174] Fix | Delete
*
[175] Fix | Delete
* @return array The updated order map.
[176] Fix | Delete
*/
[177] Fix | Delete
public static function order_map_change_min_order( array $order_map, int $new_min_order ): array {
[178] Fix | Delete
// Sanity checks.
[179] Fix | Delete
if ( empty( $order_map ) ) {
[180] Fix | Delete
return array();
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
$updated_map = array();
[184] Fix | Delete
$bump = $new_min_order - min( $order_map );
[185] Fix | Delete
foreach ( $order_map as $id => $order ) {
[186] Fix | Delete
$updated_map[ $id ] = $order + $bump;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
asort( $updated_map );
[190] Fix | Delete
[191] Fix | Delete
return $updated_map;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Get the list of plugin slug suffixes used for handling non-standard testing slugs.
[196] Fix | Delete
*
[197] Fix | Delete
* @return string[] The list of plugin slug suffixes used for handling non-standard testing slugs.
[198] Fix | Delete
*/
[199] Fix | Delete
public static function get_testing_plugin_slug_suffixes(): array {
[200] Fix | Delete
return array( '-dev', '-rc', '-test', '-beta', '-alpha' );
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
/**
[204] Fix | Delete
* Generate a list of testing plugin slugs from a standard/official plugin slug.
[205] Fix | Delete
*
[206] Fix | Delete
* @param string $slug The standard/official plugin slug. Most likely the WPORG slug.
[207] Fix | Delete
* @param bool $include_original Optional. Whether to include the original slug in the list.
[208] Fix | Delete
* If true, the original slug will be the first item in the list.
[209] Fix | Delete
*
[210] Fix | Delete
* @return string[] The list of testing plugin slugs generated from the standard/official plugin slug.
[211] Fix | Delete
*/
[212] Fix | Delete
public static function generate_testing_plugin_slugs( string $slug, bool $include_original = false ): array {
[213] Fix | Delete
$slugs = array();
[214] Fix | Delete
if ( $include_original ) {
[215] Fix | Delete
$slugs[] = $slug;
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
foreach ( self::get_testing_plugin_slug_suffixes() as $suffix ) {
[219] Fix | Delete
$slugs[] = $slug . $suffix;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
return $slugs;
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* Normalize a plugin slug to a standard/official slug.
[227] Fix | Delete
*
[228] Fix | Delete
* This is a best-effort approach.
[229] Fix | Delete
* It will remove beta testing suffixes and lowercase the slug.
[230] Fix | Delete
* It will NOT convert plugin titles to slugs or sanitize the slug like sanitize_title() does.
[231] Fix | Delete
*
[232] Fix | Delete
* @param string $slug The plugin slug.
[233] Fix | Delete
*
[234] Fix | Delete
* @return string The normalized plugin slug.
[235] Fix | Delete
*/
[236] Fix | Delete
public static function normalize_plugin_slug( string $slug ): string {
[237] Fix | Delete
// If the slug is empty or contains anything other than alphanumeric and dash characters, it will be left as is.
[238] Fix | Delete
if ( empty( $slug ) || ! preg_match( '/^[\w-]+$/', $slug, $matches ) ) {
[239] Fix | Delete
return $slug;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
// Lowercase the slug.
[243] Fix | Delete
$slug = strtolower( $slug );
[244] Fix | Delete
// Remove testing suffixes.
[245] Fix | Delete
foreach ( self::get_testing_plugin_slug_suffixes() as $suffix ) {
[246] Fix | Delete
$slug = str_ends_with( $slug, $suffix ) ? substr( $slug, 0, -strlen( $suffix ) ) : $slug;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
return $slug;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
/**
[253] Fix | Delete
* Trim the .php file extension from a path.
[254] Fix | Delete
*
[255] Fix | Delete
* @param string $path The path to trim.
[256] Fix | Delete
*
[257] Fix | Delete
* @return string The trimmed path. If the path does not end with .php, it will be returned as is.
[258] Fix | Delete
*/
[259] Fix | Delete
public static function trim_php_file_extension( string $path ): string {
[260] Fix | Delete
if ( ! empty( $path ) && str_ends_with( $path, '.php' ) ) {
[261] Fix | Delete
$path = substr( $path, 0, - 4 );
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
return $path;
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Truncate a text to a target character length while preserving whole words.
[269] Fix | Delete
*
[270] Fix | Delete
* We take a greedy approach: if some characters of a word fit in the target length, the whole word is included.
[271] Fix | Delete
* This means we might exceed the target length by a few characters.
[272] Fix | Delete
* The append string length is not included in the character count.
[273] Fix | Delete
*
[274] Fix | Delete
* @param string $text The text to truncate.
[275] Fix | Delete
* It will not be sanitized, stripped of HTML tags, or modified in any way before truncation.
[276] Fix | Delete
* @param int $target_length The target character length of the truncated text.
[277] Fix | Delete
* @param string $append Optional. The string to append to the truncated text, if there is any truncation.
[278] Fix | Delete
*
[279] Fix | Delete
* @return string The truncated text.
[280] Fix | Delete
*/
[281] Fix | Delete
public static function truncate_with_words( string $text, int $target_length, string $append = '' ): string {
[282] Fix | Delete
// First, deal with locale that doesn't have words separated by spaces, but instead deals with characters.
[283] Fix | Delete
// Borrowed from wp_trim_words().
[284] Fix | Delete
if ( str_starts_with( wp_get_word_count_type(), 'characters' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
[285] Fix | Delete
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
[286] Fix | Delete
preg_match_all( '/./u', $text, $words_array );
[287] Fix | Delete
[288] Fix | Delete
// Nothing to do if the text is already short enough.
[289] Fix | Delete
if ( count( $words_array[0] ) <= $target_length ) {
[290] Fix | Delete
return $text;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
$words_array = array_slice( $words_array[0], 0, $target_length );
[294] Fix | Delete
$truncated = implode( '', $words_array );
[295] Fix | Delete
if ( $append ) {
[296] Fix | Delete
$truncated .= $append;
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
return $truncated;
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
// Deal with locale that has words separated by spaces.
[303] Fix | Delete
if ( strlen( $text ) <= $target_length ) {
[304] Fix | Delete
return $text;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
$words_array = preg_split( "/[\n\r\t ]+/", $text, - 1, PREG_SPLIT_NO_EMPTY );
[308] Fix | Delete
$sep = ' ';
[309] Fix | Delete
[310] Fix | Delete
// Include words until the target length is reached.
[311] Fix | Delete
$truncated = '';
[312] Fix | Delete
$remaining_length = $target_length;
[313] Fix | Delete
while ( $remaining_length > 0 && ! empty( $words_array ) ) {
[314] Fix | Delete
$word = array_shift( $words_array );
[315] Fix | Delete
$truncated .= $word . $sep;
[316] Fix | Delete
$remaining_length -= strlen( $word . $sep );
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
// Remove the last separator.
[320] Fix | Delete
$truncated = rtrim( $truncated, $sep );
[321] Fix | Delete
[322] Fix | Delete
if ( null !== $append ) {
[323] Fix | Delete
$truncated .= $append;
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
return $truncated;
[327] Fix | Delete
}
[328] Fix | Delete
[329] Fix | Delete
/**
[330] Fix | Delete
* Retrieves a URL to relative path inside WooCommerce admin Payments settings with
[331] Fix | Delete
* the provided query parameters.
[332] Fix | Delete
*
[333] Fix | Delete
* @param string|null $path Relative path of the desired page.
[334] Fix | Delete
* @param array $query Query parameters to append to the path.
[335] Fix | Delete
*
[336] Fix | Delete
* @return string Fully qualified URL pointing to the desired path.
[337] Fix | Delete
*/
[338] Fix | Delete
public static function wc_payments_settings_url( ?string $path = null, array $query = array() ): string {
[339] Fix | Delete
$path = $path ? '&path=' . $path : '';
[340] Fix | Delete
[341] Fix | Delete
$query_string = '';
[342] Fix | Delete
if ( ! empty( $query ) ) {
[343] Fix | Delete
$query_string = '&' . http_build_query( $query );
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
return admin_url( 'admin.php?page=wc-settings&tab=checkout' . $path . $query_string );
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
/**
[350] Fix | Delete
* Get data from a WooCommerce API endpoint.
[351] Fix | Delete
*
[352] Fix | Delete
* @param string $endpoint Endpoint.
[353] Fix | Delete
* @param array $params Params to pass with request query.
[354] Fix | Delete
*
[355] Fix | Delete
* @return array|\WP_Error The response data or a WP_Error object.
[356] Fix | Delete
*/
[357] Fix | Delete
public static function rest_endpoint_get_request( string $endpoint, array $params = array() ) {
[358] Fix | Delete
$request = new \WP_REST_Request( 'GET', $endpoint );
[359] Fix | Delete
if ( $params ) {
[360] Fix | Delete
$request->set_query_params( $params );
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
// Do the internal request.
[364] Fix | Delete
// This has minimal overhead compared to an external request.
[365] Fix | Delete
$response = rest_do_request( $request );
[366] Fix | Delete
[367] Fix | Delete
$server = rest_get_server();
[368] Fix | Delete
$response_data = json_decode( wp_json_encode( $server->response_to_data( $response, false ) ), true );
[369] Fix | Delete
[370] Fix | Delete
// Handle non-200 responses.
[371] Fix | Delete
if ( 200 !== $response->get_status() ) {
[372] Fix | Delete
return new \WP_Error(
[373] Fix | Delete
'woocommerce_settings_payments_rest_error',
[374] Fix | Delete
sprintf(
[375] Fix | Delete
/* translators: 1: the endpoint relative URL, 2: error code, 3: error message */
[376] Fix | Delete
esc_html__( 'REST request GET %1$s failed with: (%2$s) %3$s', 'woocommerce' ),
[377] Fix | Delete
$endpoint,
[378] Fix | Delete
$response_data['code'] ?? 'unknown_error',
[379] Fix | Delete
$response_data['message'] ?? esc_html__( 'Unknown error', 'woocommerce' )
[380] Fix | Delete
),
[381] Fix | Delete
$response_data
[382] Fix | Delete
);
[383] Fix | Delete
}
[384] Fix | Delete
[385] Fix | Delete
// If the response is 200, return the data.
[386] Fix | Delete
return $response_data;
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
/**
[390] Fix | Delete
* Post data to a WooCommerce API endpoint and return the response data.
[391] Fix | Delete
*
[392] Fix | Delete
* @param string $endpoint Endpoint.
[393] Fix | Delete
* @param array $params Params to pass with request body.
[394] Fix | Delete
*
[395] Fix | Delete
* @return array|\WP_Error The response data or a WP_Error object.
[396] Fix | Delete
*/
[397] Fix | Delete
public static function rest_endpoint_post_request( string $endpoint, array $params = array() ) {
[398] Fix | Delete
$request = new \WP_REST_Request( 'POST', $endpoint );
[399] Fix | Delete
if ( $params ) {
[400] Fix | Delete
$request->set_body_params( $params );
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
// Do the internal request.
[404] Fix | Delete
// This has minimal overhead compared to an external request.
[405] Fix | Delete
$response = rest_do_request( $request );
[406] Fix | Delete
[407] Fix | Delete
$server = rest_get_server();
[408] Fix | Delete
$response_data = json_decode( wp_json_encode( $server->response_to_data( $response, false ) ), true );
[409] Fix | Delete
[410] Fix | Delete
// Handle non-200 responses.
[411] Fix | Delete
if ( 200 !== $response->get_status() ) {
[412] Fix | Delete
return new \WP_Error(
[413] Fix | Delete
'woocommerce_settings_payments_rest_error',
[414] Fix | Delete
sprintf(
[415] Fix | Delete
/* translators: 1: the endpoint relative URL, 2: error code, 3: error message */
[416] Fix | Delete
esc_html__( 'REST request POST %1$s failed with: (%2$s) %3$s', 'woocommerce' ),
[417] Fix | Delete
$endpoint,
[418] Fix | Delete
$response_data['code'] ?? 'unknown_error',
[419] Fix | Delete
$response_data['message'] ?? esc_html__( 'Unknown error', 'woocommerce' )
[420] Fix | Delete
),
[421] Fix | Delete
$response_data
[422] Fix | Delete
);
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
// If the response is 200, return the data.
[426] Fix | Delete
return $response_data;
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
/**
[430] Fix | Delete
* Get the details to authorize a connection to WordPress.com.
[431] Fix | Delete
*
[432] Fix | Delete
* The most important part of the result is the URL to redirect to for authorization.
[433] Fix | Delete
*
[434] Fix | Delete
* @param string $return_url The URL to redirect to after the connection is authorized.
[435] Fix | Delete
*
[436] Fix | Delete
* @return array {
[437] Fix | Delete
* 'success' => bool Whether the request was successful.
[438] Fix | Delete
* 'errors' => array An array of error messages, if any.
[439] Fix | Delete
* 'color_scheme' => string The color scheme to use for the authorization page.
[440] Fix | Delete
* 'url' => string The URL to redirect to for authorization.
[441] Fix | Delete
* }
[442] Fix | Delete
*/
[443] Fix | Delete
public static function get_wpcom_connection_authorization( string $return_url ): array {
[444] Fix | Delete
$result = JetpackConnection::get_authorization_url( $return_url );
[445] Fix | Delete
[446] Fix | Delete
if ( ! empty( $result['url'] ) ) {
[447] Fix | Delete
$result['url'] = add_query_arg(
[448] Fix | Delete
array(
[449] Fix | Delete
// We use the new WooDNA value.
[450] Fix | Delete
'from' => 'woocommerce-onboarding',
[451] Fix | Delete
// We inform Calypso that this is a WooPayments onboarding flow.
[452] Fix | Delete
'plugin_name' => 'woocommerce-payments',
[453] Fix | Delete
// Use the current user's WP admin color scheme.
[454] Fix | Delete
'color_scheme' => $result['color_scheme'],
[455] Fix | Delete
),
[456] Fix | Delete
$result['url']
[457] Fix | Delete
);
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
return $result;
[461] Fix | Delete
}
[462] Fix | Delete
}
[463] Fix | Delete
[464] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function