Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Internal/ProductI...
File: MatchImageBySKU.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* MatchImageBySKU class file.
[2] Fix | Delete
*/
[3] Fix | Delete
[4] Fix | Delete
namespace Automattic\WooCommerce\Internal\ProductImage;
[5] Fix | Delete
[6] Fix | Delete
defined( 'ABSPATH' ) || exit;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Class for the product image matching by SKU.
[10] Fix | Delete
*/
[11] Fix | Delete
class MatchImageBySKU {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* The name of the setting for this feature.
[15] Fix | Delete
*
[16] Fix | Delete
* @var string
[17] Fix | Delete
*/
[18] Fix | Delete
private $setting_name = 'woocommerce_product_match_featured_image_by_sku';
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* MatchImageBySKU constructor.
[22] Fix | Delete
*/
[23] Fix | Delete
public function __construct() {
[24] Fix | Delete
$this->init_hooks();
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Initialize the hooks used by the class.
[29] Fix | Delete
*/
[30] Fix | Delete
private function init_hooks() {
[31] Fix | Delete
add_filter( 'woocommerce_get_settings_products', array( $this, 'add_product_image_sku_setting' ), 110, 2 );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Is this feature enabled.
[36] Fix | Delete
*
[37] Fix | Delete
* @since 8.3.0
[38] Fix | Delete
* @return bool
[39] Fix | Delete
*/
[40] Fix | Delete
public function is_enabled() {
[41] Fix | Delete
return wc_string_to_bool( get_option( $this->setting_name ) );
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Handler for 'woocommerce_get_settings_products', adds the settings related to the product image SKU matching table.
[46] Fix | Delete
*
[47] Fix | Delete
* @param array $settings Original settings configuration array.
[48] Fix | Delete
* @param string $section_id Settings section identifier.
[49] Fix | Delete
* @return array New settings configuration array.
[50] Fix | Delete
*
[51] Fix | Delete
* @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed.
[52] Fix | Delete
*/
[53] Fix | Delete
public function add_product_image_sku_setting( array $settings, string $section_id ): array {
[54] Fix | Delete
if ( 'advanced' !== $section_id ) {
[55] Fix | Delete
return $settings;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
$settings[] = array(
[59] Fix | Delete
'title' => __( 'Product image matching by SKU', 'woocommerce' ),
[60] Fix | Delete
'type' => 'title',
[61] Fix | Delete
);
[62] Fix | Delete
[63] Fix | Delete
$settings[] = array(
[64] Fix | Delete
'title' => __( 'Match images', 'woocommerce' ),
[65] Fix | Delete
'desc' => __( 'Set product featured image when uploaded image file name matches product SKU.', 'woocommerce' ),
[66] Fix | Delete
'id' => $this->setting_name,
[67] Fix | Delete
'default' => 'no',
[68] Fix | Delete
'type' => 'checkbox',
[69] Fix | Delete
'checkboxgroup' => 'start',
[70] Fix | Delete
);
[71] Fix | Delete
[72] Fix | Delete
$settings[] = array( 'type' => 'sectionend' );
[73] Fix | Delete
[74] Fix | Delete
return $settings;
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function