Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/StoreApi/Utilitie...
File: ArrayUtils.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\StoreApi\Utilities;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* ArrayUtils class used for custom functions to operate on arrays
[4] Fix | Delete
*/
[5] Fix | Delete
class ArrayUtils {
[6] Fix | Delete
/**
[7] Fix | Delete
* Join a string with a natural language conjunction at the end.
[8] Fix | Delete
*
[9] Fix | Delete
* @param array $array The array to join together with the natural language conjunction.
[10] Fix | Delete
* @param bool $enclose_items_with_quotes Whether each item in the array should be enclosed within quotation marks.
[11] Fix | Delete
*
[12] Fix | Delete
* @return string a string containing a list of items and a natural language conjuction.
[13] Fix | Delete
*/
[14] Fix | Delete
public static function natural_language_join( $array, $enclose_items_with_quotes = false ) {
[15] Fix | Delete
if ( true === $enclose_items_with_quotes ) {
[16] Fix | Delete
$array = array_map(
[17] Fix | Delete
function ( $item ) {
[18] Fix | Delete
return '"' . $item . '"';
[19] Fix | Delete
},
[20] Fix | Delete
$array
[21] Fix | Delete
);
[22] Fix | Delete
}
[23] Fix | Delete
$last = array_pop( $array );
[24] Fix | Delete
if ( $array ) {
[25] Fix | Delete
return sprintf(
[26] Fix | Delete
/* translators: 1: The first n-1 items of a list 2: the last item in the list. */
[27] Fix | Delete
__( '%1$s and %2$s', 'woocommerce' ),
[28] Fix | Delete
implode( ', ', $array ),
[29] Fix | Delete
$last
[30] Fix | Delete
);
[31] Fix | Delete
}
[32] Fix | Delete
return $last;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Check if a string contains any of the items in an array.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $needle The string to check.
[39] Fix | Delete
* @param array $haystack The array of items to check for.
[40] Fix | Delete
*
[41] Fix | Delete
* @return bool true if the string contains any of the items in the array, false otherwise.
[42] Fix | Delete
*/
[43] Fix | Delete
public static function string_contains_array( $needle, $haystack ) {
[44] Fix | Delete
foreach ( $haystack as $item ) {
[45] Fix | Delete
if ( false !== strpos( $needle, $item ) ) {
[46] Fix | Delete
return true;
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
return false;
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function