Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Utils
File: MiniCartUtils.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\Blocks\Utils;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Utility methods used for the Mini Cart block.
[4] Fix | Delete
*/
[5] Fix | Delete
class MiniCartUtils {
[6] Fix | Delete
/**
[7] Fix | Delete
* Migrate attributes to color panel component format.
[8] Fix | Delete
*
[9] Fix | Delete
* @param array $attributes Any attributes that currently are available from the block.
[10] Fix | Delete
* @return array Reformatted attributes that are compatible with the color panel component.
[11] Fix | Delete
*/
[12] Fix | Delete
public static function migrate_attributes_to_color_panel( $attributes ) {
[13] Fix | Delete
if ( isset( $attributes['priceColorValue'] ) && ! isset( $attributes['priceColor'] ) ) {
[14] Fix | Delete
$attributes['priceColor'] = array(
[15] Fix | Delete
'color' => $attributes['priceColorValue'],
[16] Fix | Delete
);
[17] Fix | Delete
unset( $attributes['priceColorValue'] );
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
if ( isset( $attributes['iconColorValue'] ) && ! isset( $attributes['iconColor'] ) ) {
[21] Fix | Delete
$attributes['iconColor'] = array(
[22] Fix | Delete
'color' => $attributes['iconColorValue'],
[23] Fix | Delete
);
[24] Fix | Delete
unset( $attributes['iconColorValue'] );
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
if ( isset( $attributes['productCountColorValue'] ) && ! isset( $attributes['productCountColor'] ) ) {
[28] Fix | Delete
$attributes['productCountColor'] = array(
[29] Fix | Delete
'color' => $attributes['productCountColorValue'],
[30] Fix | Delete
);
[31] Fix | Delete
unset( $attributes['productCountColorValue'] );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
return $attributes;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Get the SVG icon for the mini cart.
[39] Fix | Delete
*
[40] Fix | Delete
* @param string $icon_name The name of the icon.
[41] Fix | Delete
* @param string $icon_color The color of the icon.
[42] Fix | Delete
* @return string The SVG icon.
[43] Fix | Delete
*/
[44] Fix | Delete
public static function get_svg_icon( $icon_name, $icon_color = 'currentColor' ) {
[45] Fix | Delete
// Default "Cart" icon.
[46] Fix | Delete
$icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="' . esc_attr( $icon_color ) . '" class="wc-block-mini-cart__icon" viewBox="0 0 32 32"><circle cx="12.667" cy="24.667" r="2"/><circle cx="23.333" cy="24.667" r="2"/><path fill-rule="evenodd" d="M9.285 10.036a1 1 0 0 1 .776-.37h15.272a1 1 0 0 1 .99 1.142l-1.333 9.333A1 1 0 0 1 24 21H12a1 1 0 0 1-.98-.797L9.083 10.87a1 1 0 0 1 .203-.834m2.005 1.63L12.814 19h10.319l1.047-7.333z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M5.667 6.667a1 1 0 0 1 1-1h2.666a1 1 0 0 1 .984.82l.727 4a1 1 0 1 1-1.967.359l-.578-3.18H6.667a1 1 0 0 1-1-1" clip-rule="evenodd"/></svg>';
[47] Fix | Delete
[48] Fix | Delete
if ( isset( $icon_name ) ) {
[49] Fix | Delete
if ( 'bag' === $icon_name ) {
[50] Fix | Delete
$icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" class="wc-block-mini-cart__icon" viewBox="0 0 32 32"><path fill="' . esc_attr( $icon_color ) . '" fill-rule="evenodd" d="M12.444 14.222a.89.89 0 0 1 .89.89 2.667 2.667 0 0 0 5.333 0 .889.889 0 1 1 1.777 0 4.444 4.444 0 1 1-8.888 0c0-.492.398-.89.888-.89M11.24 6.683a1 1 0 0 1 .76-.35h8a1 1 0 0 1 .76.35l4 4.666A1 1 0 0 1 24 13H8a1 1 0 0 1-.76-1.65zm1.22 1.65L10.174 11h11.652L19.54 8.333z" clip-rule="evenodd"/><path fill="' . esc_attr( $icon_color ) . '" fill-rule="evenodd" d="M7 12a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v13.333a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1zm2 1v11.333h14V13z" clip-rule="evenodd"/></svg>';
[51] Fix | Delete
} elseif ( 'bag-alt' === $icon_name ) {
[52] Fix | Delete
$icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" class="wc-block-mini-cart__icon" viewBox="0 0 32 32"><path fill="' . esc_attr( $icon_color ) . '" fill-rule="evenodd" d="M19.556 12.333a.89.89 0 0 1-.89-.889c0-.707-.28-3.385-.78-3.885a2.667 2.667 0 0 0-3.772 0c-.5.5-.78 3.178-.78 3.885a.889.889 0 1 1-1.778 0c0-1.178.468-4.309 1.301-5.142a4.445 4.445 0 0 1 6.286 0c.833.833 1.302 3.964 1.302 5.142a.89.89 0 0 1-.89.89" clip-rule="evenodd"/><path fill="' . esc_attr( $icon_color ) . '" fill-rule="evenodd" d="M7.5 12a1 1 0 0 1 1-1h15a1 1 0 0 1 1 1v13.333a1 1 0 0 1-1 1h-15a1 1 0 0 1-1-1zm2 1v11.333h13V13z" clip-rule="evenodd"/></svg>';
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
return $icon;
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function