Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php use Automattic\WooCommerce\Utilities\ArrayUtil; goto gUjlA; KJwXM: if (!class_exist..

Decoded Output download

<?php
 use Automattic\WooCommerce\Utilities\ArrayUtil; goto gUjlA; KJwXM: if (!class_exists("WC_Product_CSV_Importer_Controller", false)) { include_once WC_ABSPATH . "includes/admin/importers/class-wc-product-csv-importer-controller.php"; } goto WeB3A; p0Ml6: if (!class_exists("WC_Product_Importer", false)) { include_once dirname(__FILE__) . "/abstract-wc-product-importer.php"; } goto KJwXM; gUjlA: if (!defined("ABSPATH")) { die; } goto p0Ml6; WeB3A: class WC_Product_CSV_Importer extends WC_Product_Importer { protected $parsing_raw_data_index = 0; public function __construct($file, $params = array()) { $default_args = array("start_pos" => 0, "end_pos" => -1, "lines" => -1, "mapping" => array(), "parse" => false, "update_existing" => false, "delimiter" => ",", "prevent_timeouts" => true, "enclosure" => """, "escape" => "\0"); $this->params = wp_parse_args($params, $default_args); $this->file = $file; if (isset($this->params["mapping"]["from"], $this->params["mapping"]["to"])) { $this->params["mapping"] = array_combine($this->params["mapping"]["from"], $this->params["mapping"]["to"]); } include_once dirname(dirname(__FILE__)) . "/admin/importers/mappings/mappings.php"; $this->read_file(); } private function adjust_character_encoding($value) { $encoding = $this->params["character_encoding"]; return "UTF-8" === $encoding ? $value : mb_convert_encoding($value, "UTF-8", $encoding); } protected function read_file() { if (!WC_Product_CSV_Importer_Controller::is_file_valid_csv($this->file)) { wp_die(esc_html__("Invalid file type. The importer supports CSV and TXT file formats.", "woocommerce")); } $handle = fopen($this->file, "r"); if (false !== $handle) { $this->raw_keys = array_map("trim", fgetcsv($handle, 0, $this->params["delimiter"], $this->params["enclosure"], $this->params["escape"])); if (ArrayUtil::is_truthy($this->params, "character_encoding")) { $this->raw_keys = array_map(array($this, "adjust_character_encoding"), $this->raw_keys); } $this->raw_keys = wc_clean(wp_unslash($this->raw_keys)); if (isset($this->raw_keys[0])) { $this->raw_keys[0] = $this->remove_utf8_bom($this->raw_keys[0]); } if (0 !== $this->params["start_pos"]) { fseek($handle, (int) $this->params["start_pos"]); } while (1) { $row = fgetcsv($handle, 0, $this->params["delimiter"], $this->params["enclosure"], $this->params["escape"]); if (false !== $row) { if (ArrayUtil::is_truthy($this->params, "character_encoding")) { $row = array_map(array($this, "adjust_character_encoding"), $row); } $this->raw_data[] = $row; $this->file_positions[count($this->raw_data)] = ftell($handle); if ($this->params["end_pos"] > 0 && ftell($handle) >= $this->params["end_pos"] || 0 === --$this->params["lines"]) { break; } } else { break; } } $this->file_position = ftell($handle); } if (!empty($this->params["mapping"])) { $this->set_mapped_keys(); } if ($this->params["parse"]) { $this->set_parsed_data(); } } protected function remove_utf8_bom($string) { if ("efbbbf" === substr(bin2hex($string), 0, 6)) { $string = substr($string, 3); } return $string; } protected function set_mapped_keys() { $mapping = $this->params["mapping"]; foreach ($this->raw_keys as $key) { $this->mapped_keys[] = isset($mapping[$key]) ? $mapping[$key] : $key; } } public function parse_relative_field($value) { global $wpdb; if (empty($value)) { return ''; } if (preg_match("/^id:(\d+)$/", $value, $matches)) { $id = intval($matches[1]); $original_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_original_id' AND meta_value = %s;", $id)); if ($original_id) { return absint($original_id); } $existing_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation' ) AND ID = %d;", $id)); if ($existing_id) { return absint($existing_id); } if (!$this->params["update_existing"]) { $product = wc_get_product_object("simple"); $product->set_name("Import placeholder for " . $id); $product->set_status("importing"); $product->add_meta_data("_original_id", $id, true); $id = $product->save(); } return $id; } $id = wc_get_product_id_by_sku($value); if ($id) { return $id; } try { $product = wc_get_product_object("simple"); $product->set_name("Import placeholder for " . $value); $product->set_status("importing"); $product->set_sku($value); $id = $product->save(); if ($id && !is_wp_error($id)) { return $id; } } catch (Exception $e) { return ''; } return ''; } public function parse_id_field($value) { global $wpdb; $id = absint($value); if (!$id) { return 0; } $original_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_original_id' AND meta_value = %s;", $id)); if ($original_id) { return absint($original_id); } if (!$this->params["update_existing"]) { $mapped_keys = $this->get_mapped_keys(); $sku_column_index = absint(array_search("sku", $mapped_keys, true)); $row_sku = isset($this->raw_data[$this->parsing_raw_data_index][$sku_column_index]) ? $this->raw_data[$this->parsing_raw_data_index][$sku_column_index] : ''; $id_from_sku = $row_sku ? wc_get_product_id_by_sku($row_sku) : ''; if ($id_from_sku) { return $id_from_sku; } $product = wc_get_product_object("simple"); $product->set_name("Import placeholder for " . $id); $product->set_status("importing"); $product->add_meta_data("_original_id", $id, true); if ($row_sku) { $product->set_sku($row_sku); } $id = $product->save(); } return $id && !is_wp_error($id) ? $id : 0; } public function parse_relative_comma_field($value) { if (empty($value)) { return array(); } return array_filter(array_map(array($this, "parse_relative_field"), $this->explode_values($value))); } public function parse_comma_field($value) { if (empty($value) && "0" !== $value) { return array(); } $value = $this->unescape_data($value); return array_map("wc_clean", $this->explode_values($value)); } public function parse_bool_field($value) { if ("0" === $value) { return false; } if ("1" === $value) { return true; } return wc_clean($value); } public function parse_float_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); return floatval($value); } public function parse_stock_quantity_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); return wc_stock_amount($value); } public function parse_tax_status_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); if ("true" === strtolower($value) || "false" === strtolower($value)) { $value = wc_string_to_bool($value) ? "taxable" : "none"; } return wc_clean($value); } public function parse_categories_field($value) { if (empty($value)) { return array(); } $row_terms = $this->explode_values($value); $categories = array(); foreach ($row_terms as $row_term) { $parent = null; $_terms = array_map("trim", explode(">", $row_term)); $total = count($_terms); foreach ($_terms as $index => $_term) { if (!current_user_can("manage_product_terms")) { break; } $term = wp_insert_term($_term, "product_cat", array("parent" => intval($parent))); if (is_wp_error($term)) { if ($term->get_error_code() === "term_exists") { $term_id = $term->get_error_data(); } else { break; } } else { $term_id = $term["term_id"]; } if (1 + $index === $total) { $categories[] = $term_id; } else { $parent = $term_id; } } } return $categories; } public function parse_tags_field($value) { if (empty($value)) { return array(); } $value = $this->unescape_data($value); $names = $this->explode_values($value); $tags = array(); foreach ($names as $name) { $term = get_term_by("name", $name, "product_tag"); if (!$term || is_wp_error($term)) { $term = (object) wp_insert_term($name, "product_tag"); } if (!is_wp_error($term)) { $tags[] = $term->term_id; } } return $tags; } public function parse_tags_spaces_field($value) { if (empty($value)) { return array(); } $value = $this->unescape_data($value); $names = $this->explode_values($value, " "); $tags = array(); foreach ($names as $name) { $term = get_term_by("name", $name, "product_tag"); if (!$term || is_wp_error($term)) { $term = (object) wp_insert_term($name, "product_tag"); } if (!is_wp_error($term)) { $tags[] = $term->term_id; } } return $tags; } public function parse_shipping_class_field($value) { if (empty($value)) { return 0; } $term = get_term_by("name", $value, "product_shipping_class"); if (!$term || is_wp_error($term)) { $term = (object) wp_insert_term($value, "product_shipping_class"); } if (is_wp_error($term)) { return 0; } return $term->term_id; } public function parse_images_field($value) { if (empty($value)) { return array(); } $images = array(); $separator = apply_filters("woocommerce_product_import_image_separator", ","); foreach ($this->explode_values($value, $separator) as $image) { if (stristr($image, "://")) { $images[] = esc_url_raw($image); } else { $images[] = sanitize_file_name($image); } } return $images; } public function parse_date_field($value) { if (empty($value)) { return null; } if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])([ 01-9:]*)$/", $value)) { return current(explode(" ", $value)); } return null; } public function parse_datetime_field($value) { try { if (is_numeric($value)) { $datetime = new DateTime("@{$value}"); return $datetime->format("Y-m-d\TH:i:s\Z"); } if (false !== strtotime($value)) { return $value; } } catch (Exception $e) { return null; } return null; } public function parse_backorders_field($value) { if (empty($value)) { return "no"; } $value = $this->parse_bool_field($value); if ("notify" === $value) { return "notify"; } elseif (is_bool($value)) { return $value ? "yes" : "no"; } return "no"; } public function parse_skip_field($value) { return $value; } public function parse_download_file_field($value) { if (0 === strpos($value, "http")) { return esc_url_raw($value); } return wc_clean($value); } public function parse_int_field($value) { $value = $this->unescape_data($value); return intval($value); } public function parse_description_field($description) { $parts = explode("\\n", $description); foreach ($parts as $key => $part) { $parts[$key] = str_replace("\n", "
", $part); } return implode("\\n", $parts); } public function parse_published_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); if ("true" === strtolower($value) || "false" === strtolower($value)) { return wc_string_to_bool($value) ? 1 : -1; } return floatval($value); } protected function get_formating_callback() { return $this->get_formatting_callback(); } protected function get_formatting_callback() { $data_formatting = array("id" => array($this, "parse_id_field"), "type" => array($this, "parse_comma_field"), "published" => array($this, "parse_published_field"), "featured" => array($this, "parse_bool_field"), "date_on_sale_from" => array($this, "parse_datetime_field"), "date_on_sale_to" => array($this, "parse_datetime_field"), "name" => array($this, "parse_skip_field"), "short_description" => array($this, "parse_description_field"), "description" => array($this, "parse_description_field"), "manage_stock" => array($this, "parse_bool_field"), "low_stock_amount" => array($this, "parse_stock_quantity_field"), "backorders" => array($this, "parse_backorders_field"), "stock_status" => array($this, "parse_bool_field"), "sold_individually" => array($this, "parse_bool_field"), "width" => array($this, "parse_float_field"), "length" => array($this, "parse_float_field"), "height" => array($this, "parse_float_field"), "weight" => array($this, "parse_float_field"), "reviews_allowed" => array($this, "parse_bool_field"), "purchase_note" => "wp_filter_post_kses", "price" => "wc_format_decimal", "regular_price" => "wc_format_decimal", "stock_quantity" => array($this, "parse_stock_quantity_field"), "category_ids" => array($this, "parse_categories_field"), "tag_ids" => array($this, "parse_tags_field"), "tag_ids_spaces" => array($this, "parse_tags_spaces_field"), "shipping_class_id" => array($this, "parse_shipping_class_field"), "images" => array($this, "parse_images_field"), "parent_id" => array($this, "parse_relative_field"), "grouped_products" => array($this, "parse_relative_comma_field"), "upsell_ids" => array($this, "parse_relative_comma_field"), "cross_sell_ids" => array($this, "parse_relative_comma_field"), "download_limit" => array($this, "parse_int_field"), "download_expiry" => array($this, "parse_int_field"), "product_url" => "esc_url_raw", "menu_order" => "intval", "tax_status" => array($this, "parse_tax_status_field")); $regex_match_data_formatting = array("/attributes:value*/" => array($this, "parse_comma_field"), "/attributes:visible*/" => array($this, "parse_bool_field"), "/attributes:taxonomy*/" => array($this, "parse_bool_field"), "/downloads:url*/" => array($this, "parse_download_file_field"), "/meta:*/" => "wp_kses_post"); $callbacks = array(); foreach ($this->get_mapped_keys() as $index => $heading) { $callback = "wc_clean"; if (isset($data_formatting[$heading])) { $callback = $data_formatting[$heading]; } else { foreach ($regex_match_data_formatting as $regex => $callback) { if (preg_match($regex, $heading)) { $callback = $callback; break; } } } $callbacks[] = $callback; } return apply_filters("woocommerce_product_importer_formatting_callbacks", $callbacks, $this); } protected function starts_with($haystack, $needle) { return substr($haystack, 0, strlen($needle)) === $needle; } protected function expand_data($data) { $data = apply_filters("woocommerce_product_importer_pre_expand_data", $data); if (isset($data["images"])) { $images = $data["images"]; $data["raw_image_id"] = array_shift($images); if (!empty($images)) { $data["raw_gallery_image_ids"] = $images; } unset($data["images"]); } if (isset($data["type"])) { $data["type"] = array_map("strtolower", $data["type"]); $data["virtual"] = in_array("virtual", $data["type"], true); $data["downloadable"] = in_array("downloadable", $data["type"], true); $data["type"] = current(array_diff($data["type"], array("virtual", "downloadable"))); if (!$data["type"]) { $data["type"] = "simple"; } } if (isset($data["published"])) { $published = $data["published"]; if (is_float($published)) { $published = (int) $published; } $statuses = array(-1 => "draft", 0 => "private", 1 => "publish"); $data["status"] = $statuses[$published] ?? "draft"; if ("variation" === ($data["type"] ?? null) && -1 === $published) { $data["status"] = "publish"; } unset($data["published"]); } if (isset($data["stock_quantity"])) { if ('' === $data["stock_quantity"]) { $data["manage_stock"] = false; $data["stock_status"] = isset($data["stock_status"]) ? $data["stock_status"] : true; } else { $data["manage_stock"] = true; } } if (isset($data["stock_status"])) { if ("backorder" === $data["stock_status"]) { $data["stock_status"] = "onbackorder"; } else { $data["stock_status"] = $data["stock_status"] ? "instock" : "outofstock"; } } if (isset($data["grouped_products"])) { $data["children"] = $data["grouped_products"]; unset($data["grouped_products"]); } if (isset($data["tag_ids_spaces"])) { $data["tag_ids"] = $data["tag_ids_spaces"]; unset($data["tag_ids_spaces"]); } $attributes = array(); $downloads = array(); $meta_data = array(); foreach ($data as $key => $value) { if ($this->starts_with($key, "attributes:name")) { if (!empty($value)) { $attributes[str_replace("attributes:name", '', $key)]["name"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "attributes:value")) { $attributes[str_replace("attributes:value", '', $key)]["value"] = $value; unset($data[$key]); } elseif ($this->starts_with($key, "attributes:taxonomy")) { $attributes[str_replace("attributes:taxonomy", '', $key)]["taxonomy"] = wc_string_to_bool($value); unset($data[$key]); } elseif ($this->starts_with($key, "attributes:visible")) { $attributes[str_replace("attributes:visible", '', $key)]["visible"] = wc_string_to_bool($value); unset($data[$key]); } elseif ($this->starts_with($key, "attributes:default")) { if (!empty($value)) { $attributes[str_replace("attributes:default", '', $key)]["default"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "downloads:id")) { if (!empty($value)) { $downloads[str_replace("downloads:id", '', $key)]["id"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "downloads:name")) { if (!empty($value)) { $downloads[str_replace("downloads:name", '', $key)]["name"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "downloads:url")) { if (!empty($value)) { $downloads[str_replace("downloads:url", '', $key)]["url"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "meta:")) { $meta_data[] = array("key" => str_replace("meta:", '', $key), "value" => $value); unset($data[$key]); } } if (!empty($attributes)) { foreach ($attributes as $attribute) { if (empty($attribute["name"])) { continue; } $data["raw_attributes"][] = $attribute; } } if (!empty($downloads)) { $data["downloads"] = array(); foreach ($downloads as $key => $file) { if (empty($file["url"])) { continue; } $data["downloads"][] = array("download_id" => isset($file["id"]) ? $file["id"] : null, "name" => $file["name"] ? $file["name"] : wc_get_filename_from_url($file["url"]), "file" => $file["url"]); } } if (!empty($meta_data)) { $data["meta_data"] = $meta_data; } return $data; } protected function set_parsed_data() { $parse_functions = $this->get_formatting_callback(); $mapped_keys = $this->get_mapped_keys(); $use_mb = function_exists("mb_convert_encoding"); foreach ($this->raw_data as $row_index => $row) { if (!count(array_filter($row))) { continue; } $this->parsing_raw_data_index = $row_index; $data = array(); do_action("woocommerce_product_importer_before_set_parsed_data", $row, $mapped_keys); foreach ($row as $id => $value) { if (empty($mapped_keys[$id])) { continue; } if ($use_mb) { $encoding = mb_detect_encoding($value, mb_detect_order(), true); if ($encoding) { $value = mb_convert_encoding($value, "UTF-8", $encoding); } else { $value = mb_convert_encoding($value, "UTF-8", "UTF-8"); } } else { $value = wp_check_invalid_utf8($value, true); } $data[$mapped_keys[$id]] = call_user_func($parse_functions[$id], $value); } $this->parsed_data[] = apply_filters("woocommerce_product_importer_parsed_data", $this->expand_data($data), $this); } } protected function get_row_id($parsed_data) { $id = isset($parsed_data["id"]) ? absint($parsed_data["id"]) : 0; $sku = isset($parsed_data["sku"]) ? esc_attr($parsed_data["sku"]) : ''; $name = isset($parsed_data["name"]) ? esc_attr($parsed_data["name"]) : ''; $row_data = array(); if ($name) { $row_data[] = $name; } if ($id) { $row_data[] = sprintf(__("ID %d", "woocommerce"), $id); } if ($sku) { $row_data[] = sprintf(__("SKU %s", "woocommerce"), $sku); } return implode(", ", $row_data); } public function import() { $this->start_time = time(); $index = 0; $update_existing = $this->params["update_existing"]; $data = array("imported" => array(), "imported_variations" => array(), "failed" => array(), "updated" => array(), "skipped" => array()); foreach ($this->parsed_data as $parsed_data_key => $parsed_data) { do_action("woocommerce_product_import_before_import", $parsed_data); $id = isset($parsed_data["id"]) ? absint($parsed_data["id"]) : 0; $sku = isset($parsed_data["sku"]) ? $parsed_data["sku"] : ''; $id_exists = false; $sku_exists = false; if ($id) { $product = wc_get_product($id); $id_exists = $product && "importing" !== $product->get_status(); } if ($sku) { $id_from_sku = wc_get_product_id_by_sku($sku); $product = $id_from_sku ? wc_get_product($id_from_sku) : false; $sku_exists = $product && "importing" !== $product->get_status(); } if ($id_exists && !$update_existing) { $data["skipped"][] = new WP_Error("woocommerce_product_importer_error", esc_html__("A product with this ID already exists.", "woocommerce"), array("id" => $id, "row" => $this->get_row_id($parsed_data))); continue; } if ($sku_exists && !$update_existing) { $data["skipped"][] = new WP_Error("woocommerce_product_importer_error", esc_html__("A product with this SKU already exists.", "woocommerce"), array("sku" => esc_attr($sku), "row" => $this->get_row_id($parsed_data))); continue; } if ($update_existing && (isset($parsed_data["id"]) || isset($parsed_data["sku"])) && !$id_exists && !$sku_exists) { $data["skipped"][] = new WP_Error("woocommerce_product_importer_error", esc_html__("No matching product exists to update.", "woocommerce"), array("id" => $id, "sku" => esc_attr($sku), "row" => $this->get_row_id($parsed_data))); continue; } $result = $this->process_item($parsed_data); if (is_wp_error($result)) { $result->add_data(array("row" => $this->get_row_id($parsed_data))); $data["failed"][] = $result; } elseif ($result["updated"]) { $data["updated"][] = $result["id"]; } else { if ($result["is_variation"]) { $data["imported_variations"][] = $result["id"]; } else { $data["imported"][] = $result["id"]; } } $index++; if ($this->params["prevent_timeouts"] && ($this->time_exceeded() || $this->memory_exceeded())) { $this->file_position = $this->file_positions[$index]; break; } } return $data; } } ?>

Did this file decode correctly?

Original Code

<?php
 use Automattic\WooCommerce\Utilities\ArrayUtil; goto gUjlA; KJwXM: if (!class_exists("\127\103\x5f\x50\x72\157\x64\x75\x63\164\x5f\x43\123\126\x5f\x49\155\160\157\162\164\145\x72\x5f\x43\157\x6e\164\x72\x6f\x6c\154\x65\162", false)) { include_once WC_ABSPATH . "\x69\x6e\143\154\165\144\145\163\x2f\x61\x64\155\x69\x6e\57\151\155\160\x6f\162\x74\x65\162\163\x2f\x63\154\x61\163\163\x2d\167\x63\x2d\x70\162\157\144\x75\x63\164\x2d\143\163\x76\55\151\x6d\160\x6f\x72\x74\x65\x72\x2d\143\x6f\x6e\164\x72\x6f\x6c\154\145\162\x2e\160\150\x70"; } goto WeB3A; p0Ml6: if (!class_exists("\127\x43\137\120\x72\x6f\144\x75\143\164\137\111\155\x70\x6f\x72\164\145\162", false)) { include_once dirname(__FILE__) . "\57\141\x62\163\164\x72\141\143\x74\x2d\167\x63\55\x70\162\x6f\x64\x75\143\164\x2d\151\155\x70\157\162\164\x65\x72\56\160\x68\160"; } goto KJwXM; gUjlA: if (!defined("\x41\102\123\x50\101\x54\x48")) { die; } goto p0Ml6; WeB3A: class WC_Product_CSV_Importer extends WC_Product_Importer { protected $parsing_raw_data_index = 0; public function __construct($file, $params = array()) { $default_args = array("\163\164\x61\162\164\137\160\x6f\x73" => 0, "\x65\x6e\144\x5f\160\x6f\x73" => -1, "\x6c\x69\156\x65\x73" => -1, "\155\x61\x70\160\x69\x6e\147" => array(), "\x70\141\x72\163\145" => false, "\165\160\144\141\164\x65\x5f\x65\170\151\163\164\151\x6e\147" => false, "\144\145\154\151\155\151\164\145\x72" => "\x2c", "\160\x72\145\x76\145\x6e\164\x5f\164\151\x6d\145\157\x75\164\163" => true, "\145\x6e\143\154\x6f\163\165\162\x65" => "\x22", "\x65\x73\143\141\x70\x65" => "\0"); $this->params = wp_parse_args($params, $default_args); $this->file = $file; if (isset($this->params["\x6d\141\160\160\151\156\x67"]["\146\162\x6f\x6d"], $this->params["\155\x61\x70\160\x69\156\x67"]["\164\157"])) { $this->params["\x6d\141\x70\160\151\156\x67"] = array_combine($this->params["\x6d\x61\x70\160\151\156\x67"]["\146\x72\x6f\x6d"], $this->params["\x6d\x61\160\160\151\x6e\x67"]["\164\157"]); } include_once dirname(dirname(__FILE__)) . "\x2f\x61\144\x6d\x69\156\x2f\151\155\x70\x6f\x72\x74\145\x72\x73\57\155\141\160\160\x69\156\x67\x73\x2f\155\141\160\160\x69\x6e\x67\x73\56\160\x68\x70"; $this->read_file(); } private function adjust_character_encoding($value) { $encoding = $this->params["\143\x68\x61\162\x61\x63\164\145\162\137\145\x6e\x63\157\144\x69\x6e\147"]; return "\125\x54\106\x2d\x38" === $encoding ? $value : mb_convert_encoding($value, "\125\124\106\55\70", $encoding); } protected function read_file() { if (!WC_Product_CSV_Importer_Controller::is_file_valid_csv($this->file)) { wp_die(esc_html__("\111\x6e\x76\141\x6c\151\x64\40\146\151\x6c\145\x20\x74\x79\x70\145\56\x20\124\x68\145\40\x69\x6d\x70\157\x72\x74\145\x72\40\x73\165\160\160\157\x72\164\163\x20\x43\x53\x56\40\141\156\144\x20\124\130\x54\x20\x66\151\x6c\x65\x20\146\x6f\162\x6d\141\164\163\x2e", "\167\x6f\157\143\157\155\x6d\145\x72\143\x65")); } $handle = fopen($this->file, "\x72"); if (false !== $handle) { $this->raw_keys = array_map("\164\162\151\x6d", fgetcsv($handle, 0, $this->params["\144\145\x6c\151\x6d\x69\x74\145\x72"], $this->params["\145\x6e\x63\154\x6f\x73\x75\162\x65"], $this->params["\145\163\x63\x61\160\x65"])); if (ArrayUtil::is_truthy($this->params, "\143\150\141\162\x61\x63\x74\x65\x72\137\x65\156\143\157\x64\x69\x6e\x67")) { $this->raw_keys = array_map(array($this, "\141\144\x6a\x75\163\x74\x5f\x63\150\x61\x72\141\x63\x74\145\162\137\145\156\143\x6f\144\x69\x6e\147"), $this->raw_keys); } $this->raw_keys = wc_clean(wp_unslash($this->raw_keys)); if (isset($this->raw_keys[0])) { $this->raw_keys[0] = $this->remove_utf8_bom($this->raw_keys[0]); } if (0 !== $this->params["\163\164\141\162\x74\x5f\x70\x6f\163"]) { fseek($handle, (int) $this->params["\163\x74\141\x72\x74\137\x70\157\x73"]); } while (1) { $row = fgetcsv($handle, 0, $this->params["\144\145\x6c\x69\155\x69\164\x65\x72"], $this->params["\x65\156\143\x6c\x6f\163\165\x72\145"], $this->params["\145\163\143\141\x70\145"]); if (false !== $row) { if (ArrayUtil::is_truthy($this->params, "\x63\x68\x61\162\141\143\164\145\x72\x5f\145\x6e\x63\x6f\144\151\x6e\147")) { $row = array_map(array($this, "\141\144\x6a\x75\x73\164\x5f\143\x68\x61\x72\141\143\164\x65\x72\137\145\156\143\x6f\x64\x69\x6e\x67"), $row); } $this->raw_data[] = $row; $this->file_positions[count($this->raw_data)] = ftell($handle); if ($this->params["\145\156\x64\x5f\160\x6f\163"] > 0 && ftell($handle) >= $this->params["\x65\x6e\144\x5f\x70\157\163"] || 0 === --$this->params["\x6c\151\x6e\x65\163"]) { break; } } else { break; } } $this->file_position = ftell($handle); } if (!empty($this->params["\155\141\160\160\151\156\147"])) { $this->set_mapped_keys(); } if ($this->params["\x70\x61\x72\x73\145"]) { $this->set_parsed_data(); } } protected function remove_utf8_bom($string) { if ("\145\146\142\x62\142\x66" === substr(bin2hex($string), 0, 6)) { $string = substr($string, 3); } return $string; } protected function set_mapped_keys() { $mapping = $this->params["\x6d\x61\x70\x70\x69\156\x67"]; foreach ($this->raw_keys as $key) { $this->mapped_keys[] = isset($mapping[$key]) ? $mapping[$key] : $key; } } public function parse_relative_field($value) { global $wpdb; if (empty($value)) { return ''; } if (preg_match("\x2f\136\x69\x64\72\50\134\x64\x2b\x29\44\x2f", $value, $matches)) { $id = intval($matches[1]); $original_id = $wpdb->get_var($wpdb->prepare("\x53\x45\x4c\105\x43\x54\40\x70\x6f\x73\x74\137\x69\x64\40\106\122\x4f\115\x20{$wpdb->postmeta}\x20\127\110\105\122\x45\x20\155\145\164\x61\x5f\153\x65\171\40\75\x20\47\x5f\157\162\x69\x67\x69\156\141\154\137\151\144\47\40\x41\x4e\104\40\155\145\164\x61\137\166\x61\x6c\x75\x65\x20\x3d\40\45\x73\x3b", $id)); if ($original_id) { return absint($original_id); } $existing_id = $wpdb->get_var($wpdb->prepare("\x53\x45\x4c\105\103\124\x20\x49\104\40\x46\122\x4f\115\x20{$wpdb->posts}\40\x57\110\x45\122\105\40\x70\x6f\x73\x74\x5f\x74\171\x70\x65\x20\x49\x4e\40\50\40\47\x70\162\157\x64\x75\x63\164\x27\x2c\40\x27\160\162\x6f\x64\165\143\x74\x5f\166\x61\162\151\x61\164\151\157\156\x27\x20\51\40\101\x4e\104\x20\111\104\40\75\40\45\x64\x3b", $id)); if ($existing_id) { return absint($existing_id); } if (!$this->params["\x75\160\x64\x61\x74\145\x5f\x65\170\x69\x73\x74\151\x6e\x67"]) { $product = wc_get_product_object("\x73\x69\x6d\160\x6c\x65"); $product->set_name("\x49\x6d\x70\x6f\162\x74\40\x70\154\141\x63\x65\x68\x6f\x6c\144\x65\x72\x20\x66\x6f\162\x20" . $id); $product->set_status("\x69\x6d\x70\157\162\164\151\156\x67"); $product->add_meta_data("\x5f\157\x72\x69\x67\x69\156\141\154\137\x69\144", $id, true); $id = $product->save(); } return $id; } $id = wc_get_product_id_by_sku($value); if ($id) { return $id; } try { $product = wc_get_product_object("\x73\151\155\160\154\145"); $product->set_name("\111\x6d\160\x6f\x72\x74\40\x70\154\141\143\145\x68\x6f\x6c\x64\145\162\40\x66\157\162\x20" . $value); $product->set_status("\151\155\160\157\x72\x74\x69\x6e\x67"); $product->set_sku($value); $id = $product->save(); if ($id && !is_wp_error($id)) { return $id; } } catch (Exception $e) { return ''; } return ''; } public function parse_id_field($value) { global $wpdb; $id = absint($value); if (!$id) { return 0; } $original_id = $wpdb->get_var($wpdb->prepare("\x53\x45\x4c\x45\x43\x54\40\160\157\x73\x74\137\x69\x64\x20\x46\x52\x4f\x4d\40{$wpdb->postmeta}\x20\127\110\x45\x52\x45\x20\155\145\x74\x61\137\x6b\145\x79\x20\x3d\40\x27\137\157\x72\151\x67\151\x6e\141\x6c\x5f\151\144\47\x20\x41\116\x44\x20\x6d\x65\164\141\137\166\x61\154\x75\145\x20\x3d\40\x25\163\73", $id)); if ($original_id) { return absint($original_id); } if (!$this->params["\165\x70\144\x61\x74\x65\137\145\170\x69\x73\164\151\x6e\x67"]) { $mapped_keys = $this->get_mapped_keys(); $sku_column_index = absint(array_search("\x73\153\165", $mapped_keys, true)); $row_sku = isset($this->raw_data[$this->parsing_raw_data_index][$sku_column_index]) ? $this->raw_data[$this->parsing_raw_data_index][$sku_column_index] : ''; $id_from_sku = $row_sku ? wc_get_product_id_by_sku($row_sku) : ''; if ($id_from_sku) { return $id_from_sku; } $product = wc_get_product_object("\x73\x69\x6d\x70\x6c\x65"); $product->set_name("\x49\x6d\x70\157\162\x74\40\160\x6c\141\x63\x65\150\x6f\154\x64\x65\162\x20\x66\157\x72\x20" . $id); $product->set_status("\151\x6d\160\157\x72\x74\151\156\147"); $product->add_meta_data("\x5f\157\x72\151\147\151\156\x61\154\137\151\x64", $id, true); if ($row_sku) { $product->set_sku($row_sku); } $id = $product->save(); } return $id && !is_wp_error($id) ? $id : 0; } public function parse_relative_comma_field($value) { if (empty($value)) { return array(); } return array_filter(array_map(array($this, "\160\141\x72\163\x65\x5f\162\x65\154\x61\164\x69\x76\145\x5f\x66\151\x65\154\144"), $this->explode_values($value))); } public function parse_comma_field($value) { if (empty($value) && "\60" !== $value) { return array(); } $value = $this->unescape_data($value); return array_map("\x77\143\137\143\x6c\x65\x61\156", $this->explode_values($value)); } public function parse_bool_field($value) { if ("\60" === $value) { return false; } if ("\x31" === $value) { return true; } return wc_clean($value); } public function parse_float_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); return floatval($value); } public function parse_stock_quantity_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); return wc_stock_amount($value); } public function parse_tax_status_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); if ("\x74\162\x75\145" === strtolower($value) || "\146\x61\x6c\163\x65" === strtolower($value)) { $value = wc_string_to_bool($value) ? "\164\x61\170\141\142\154\x65" : "\156\x6f\x6e\x65"; } return wc_clean($value); } public function parse_categories_field($value) { if (empty($value)) { return array(); } $row_terms = $this->explode_values($value); $categories = array(); foreach ($row_terms as $row_term) { $parent = null; $_terms = array_map("\x74\162\151\155", explode("\x3e", $row_term)); $total = count($_terms); foreach ($_terms as $index => $_term) { if (!current_user_can("\155\141\156\141\x67\145\x5f\x70\x72\157\144\x75\143\x74\x5f\x74\x65\x72\x6d\163")) { break; } $term = wp_insert_term($_term, "\160\x72\x6f\x64\165\x63\164\137\x63\141\164", array("\160\141\162\145\x6e\x74" => intval($parent))); if (is_wp_error($term)) { if ($term->get_error_code() === "\x74\x65\162\x6d\x5f\145\x78\151\163\164\x73") { $term_id = $term->get_error_data(); } else { break; } } else { $term_id = $term["\164\145\x72\x6d\x5f\151\144"]; } if (1 + $index === $total) { $categories[] = $term_id; } else { $parent = $term_id; } } } return $categories; } public function parse_tags_field($value) { if (empty($value)) { return array(); } $value = $this->unescape_data($value); $names = $this->explode_values($value); $tags = array(); foreach ($names as $name) { $term = get_term_by("\x6e\x61\155\145", $name, "\x70\x72\x6f\144\165\x63\164\137\x74\x61\147"); if (!$term || is_wp_error($term)) { $term = (object) wp_insert_term($name, "\x70\x72\x6f\144\165\143\164\137\x74\141\147"); } if (!is_wp_error($term)) { $tags[] = $term->term_id; } } return $tags; } public function parse_tags_spaces_field($value) { if (empty($value)) { return array(); } $value = $this->unescape_data($value); $names = $this->explode_values($value, "\40"); $tags = array(); foreach ($names as $name) { $term = get_term_by("\x6e\x61\155\145", $name, "\160\162\157\x64\165\143\x74\137\x74\x61\x67"); if (!$term || is_wp_error($term)) { $term = (object) wp_insert_term($name, "\160\162\157\x64\x75\143\164\x5f\x74\141\147"); } if (!is_wp_error($term)) { $tags[] = $term->term_id; } } return $tags; } public function parse_shipping_class_field($value) { if (empty($value)) { return 0; } $term = get_term_by("\156\x61\x6d\x65", $value, "\x70\162\x6f\x64\165\143\x74\x5f\163\x68\x69\160\160\151\x6e\x67\x5f\143\154\141\163\x73"); if (!$term || is_wp_error($term)) { $term = (object) wp_insert_term($value, "\x70\x72\x6f\144\x75\x63\x74\x5f\x73\150\x69\x70\160\151\x6e\x67\137\143\154\x61\x73\163"); } if (is_wp_error($term)) { return 0; } return $term->term_id; } public function parse_images_field($value) { if (empty($value)) { return array(); } $images = array(); $separator = apply_filters("\167\x6f\157\143\157\155\155\x65\162\x63\x65\x5f\160\162\157\x64\x75\143\164\x5f\x69\x6d\x70\157\162\x74\x5f\151\155\x61\147\145\137\163\x65\x70\x61\162\x61\x74\157\162", "\54"); foreach ($this->explode_values($value, $separator) as $image) { if (stristr($image, "\72\x2f\x2f")) { $images[] = esc_url_raw($image); } else { $images[] = sanitize_file_name($image); } } return $images; } public function parse_date_field($value) { if (empty($value)) { return null; } if (preg_match("\57\136\x5b\x30\x2d\71\x5d\x7b\x34\175\x2d\50\x30\x5b\61\x2d\71\x5d\174\x31\133\60\55\62\x5d\x29\55\50\x30\133\x31\x2d\x39\135\174\133\61\55\62\135\133\60\55\71\x5d\174\x33\x5b\60\x2d\61\x5d\51\x28\133\x20\x30\61\55\x39\x3a\x5d\52\51\x24\57", $value)) { return current(explode("\x20", $value)); } return null; } public function parse_datetime_field($value) { try { if (is_numeric($value)) { $datetime = new DateTime("\100{$value}"); return $datetime->format("\131\x2d\x6d\55\144\134\x54\x48\72\151\72\x73\x5c\x5a"); } if (false !== strtotime($value)) { return $value; } } catch (Exception $e) { return null; } return null; } public function parse_backorders_field($value) { if (empty($value)) { return "\x6e\157"; } $value = $this->parse_bool_field($value); if ("\156\157\164\151\146\x79" === $value) { return "\x6e\x6f\164\x69\146\171"; } elseif (is_bool($value)) { return $value ? "\x79\x65\163" : "\x6e\157"; } return "\156\x6f"; } public function parse_skip_field($value) { return $value; } public function parse_download_file_field($value) { if (0 === strpos($value, "\150\164\x74\160")) { return esc_url_raw($value); } return wc_clean($value); } public function parse_int_field($value) { $value = $this->unescape_data($value); return intval($value); } public function parse_description_field($description) { $parts = explode("\134\x5c\x6e", $description); foreach ($parts as $key => $part) { $parts[$key] = str_replace("\134\x6e", "\12", $part); } return implode("\x5c\134\x6e", $parts); } public function parse_published_field($value) { if ('' === $value) { return $value; } $value = $this->unescape_data($value); if ("\x74\162\x75\x65" === strtolower($value) || "\146\141\154\x73\x65" === strtolower($value)) { return wc_string_to_bool($value) ? 1 : -1; } return floatval($value); } protected function get_formating_callback() { return $this->get_formatting_callback(); } protected function get_formatting_callback() { $data_formatting = array("\x69\144" => array($this, "\160\141\x72\x73\x65\137\151\x64\137\146\151\145\154\144"), "\164\171\x70\x65" => array($this, "\160\141\162\x73\x65\137\x63\x6f\155\x6d\141\137\x66\x69\145\154\144"), "\160\x75\x62\154\x69\163\x68\x65\144" => array($this, "\160\141\162\163\x65\137\x70\165\142\154\151\x73\x68\x65\x64\x5f\146\151\145\154\144"), "\146\145\141\164\165\x72\x65\144" => array($this, "\160\141\162\163\145\x5f\142\x6f\157\x6c\137\x66\151\145\x6c\144"), "\x64\x61\164\x65\137\x6f\x6e\x5f\x73\x61\154\145\x5f\146\x72\157\x6d" => array($this, "\160\x61\x72\163\x65\137\144\x61\164\x65\164\x69\155\145\137\x66\x69\145\x6c\x64"), "\144\141\x74\x65\x5f\157\x6e\137\163\141\154\x65\x5f\164\157" => array($this, "\160\141\162\x73\145\137\x64\141\x74\x65\164\x69\x6d\x65\137\x66\151\145\x6c\144"), "\x6e\141\x6d\x65" => array($this, "\x70\141\162\x73\x65\137\x73\x6b\x69\x70\x5f\146\x69\x65\154\x64"), "\163\150\157\x72\x74\x5f\144\x65\x73\x63\x72\151\x70\164\x69\157\x6e" => array($this, "\160\x61\162\163\x65\x5f\144\x65\163\x63\162\151\x70\164\151\157\156\x5f\146\151\x65\154\144"), "\x64\145\163\143\x72\x69\160\164\151\157\156" => array($this, "\160\x61\x72\x73\145\x5f\x64\145\163\x63\162\x69\x70\164\x69\157\x6e\x5f\146\151\145\x6c\x64"), "\x6d\141\x6e\x61\x67\x65\137\163\164\157\x63\153" => array($this, "\160\x61\x72\x73\145\x5f\142\157\157\154\x5f\x66\x69\145\154\x64"), "\154\157\167\137\163\164\157\x63\153\137\141\155\157\165\156\164" => array($this, "\160\x61\162\x73\x65\x5f\163\164\x6f\143\153\137\161\x75\x61\156\164\x69\x74\171\x5f\x66\x69\x65\154\x64"), "\142\141\x63\x6b\x6f\x72\144\145\162\163" => array($this, "\x70\x61\162\x73\145\x5f\x62\x61\143\x6b\157\162\144\x65\x72\163\x5f\146\151\145\x6c\x64"), "\163\164\157\143\x6b\x5f\163\x74\x61\164\x75\x73" => array($this, "\x70\x61\162\x73\x65\x5f\x62\x6f\157\154\x5f\146\x69\x65\x6c\x64"), "\163\x6f\x6c\144\137\151\x6e\x64\151\x76\x69\x64\x75\141\154\154\x79" => array($this, "\160\x61\x72\x73\145\137\x62\x6f\x6f\154\137\x66\151\x65\154\x64"), "\167\151\x64\164\x68" => array($this, "\160\141\x72\x73\x65\x5f\x66\154\157\x61\164\x5f\x66\151\145\x6c\x64"), "\x6c\145\156\x67\164\x68" => array($this, "\x70\141\x72\x73\145\137\x66\154\157\x61\164\x5f\x66\151\x65\154\x64"), "\x68\145\x69\x67\x68\x74" => array($this, "\x70\x61\x72\163\x65\x5f\146\154\157\x61\x74\x5f\146\151\145\154\144"), "\167\145\x69\x67\x68\164" => array($this, "\160\x61\162\163\x65\137\x66\x6c\157\x61\164\137\x66\151\145\154\x64"), "\162\145\x76\151\x65\167\x73\x5f\141\x6c\x6c\x6f\x77\145\144" => array($this, "\x70\x61\162\x73\145\x5f\x62\157\157\154\137\146\x69\145\154\x64"), "\x70\165\162\x63\150\141\x73\x65\137\x6e\x6f\x74\x65" => "\x77\160\x5f\146\x69\154\x74\x65\x72\137\160\157\x73\x74\x5f\x6b\x73\x65\163", "\160\162\x69\143\x65" => "\167\x63\x5f\x66\x6f\162\155\x61\164\x5f\x64\x65\143\x69\x6d\x61\154", "\162\x65\x67\x75\154\x61\x72\137\160\162\x69\x63\145" => "\x77\143\x5f\146\x6f\x72\155\x61\x74\137\x64\x65\143\x69\155\141\x6c", "\x73\x74\x6f\x63\153\137\x71\x75\141\156\x74\x69\x74\x79" => array($this, "\160\141\x72\163\x65\x5f\163\164\x6f\x63\x6b\x5f\161\x75\x61\156\x74\x69\x74\171\x5f\x66\x69\145\x6c\x64"), "\x63\x61\164\x65\147\157\x72\171\x5f\x69\144\163" => array($this, "\x70\141\162\163\x65\x5f\x63\141\164\x65\x67\x6f\x72\x69\x65\x73\x5f\x66\x69\x65\x6c\x64"), "\164\141\x67\x5f\x69\144\163" => array($this, "\x70\x61\162\x73\x65\x5f\x74\141\x67\163\137\146\x69\x65\154\144"), "\164\141\147\137\151\144\x73\137\x73\160\x61\143\145\x73" => array($this, "\x70\x61\x72\163\145\x5f\164\x61\x67\163\137\x73\160\x61\143\x65\x73\x5f\x66\x69\145\x6c\144"), "\163\150\x69\160\160\151\156\147\x5f\143\154\141\163\x73\137\151\x64" => array($this, "\160\141\x72\x73\145\137\163\x68\151\160\160\151\x6e\x67\x5f\143\154\x61\x73\x73\x5f\146\x69\145\154\144"), "\x69\x6d\x61\147\145\163" => array($this, "\160\141\x72\163\145\x5f\x69\x6d\141\147\x65\x73\137\146\151\145\x6c\144"), "\x70\141\x72\145\x6e\164\137\x69\x64" => array($this, "\x70\141\162\163\145\x5f\162\145\x6c\x61\x74\151\166\145\x5f\x66\x69\x65\154\x64"), "\x67\x72\x6f\x75\x70\145\x64\137\x70\162\x6f\x64\165\143\164\x73" => array($this, "\x70\x61\x72\x73\145\x5f\162\145\x6c\x61\x74\x69\166\x65\x5f\143\x6f\155\155\141\x5f\146\x69\x65\154\x64"), "\165\160\163\x65\x6c\x6c\x5f\x69\x64\163" => array($this, "\x70\141\162\x73\145\x5f\162\145\x6c\x61\x74\151\166\x65\137\x63\157\155\155\141\137\146\151\x65\154\x64"), "\x63\162\157\x73\163\x5f\x73\x65\154\154\137\x69\x64\163" => array($this, "\160\x61\x72\163\x65\x5f\162\x65\154\141\x74\x69\166\145\x5f\143\157\x6d\155\141\137\x66\151\145\x6c\x64"), "\144\157\x77\x6e\154\157\x61\144\137\x6c\x69\x6d\x69\x74" => array($this, "\160\x61\x72\x73\x65\x5f\151\x6e\x74\x5f\x66\x69\x65\x6c\x64"), "\x64\157\x77\156\154\x6f\141\x64\137\x65\x78\160\151\x72\171" => array($this, "\x70\141\162\x73\145\137\x69\156\164\x5f\x66\151\145\154\144"), "\x70\x72\157\144\x75\x63\x74\137\x75\x72\x6c" => "\x65\163\x63\137\165\x72\154\x5f\162\x61\x77", "\x6d\145\x6e\165\137\157\x72\144\x65\162" => "\x69\x6e\164\x76\141\154", "\164\141\170\137\x73\164\x61\x74\165\163" => array($this, "\160\x61\x72\163\x65\x5f\164\x61\x78\x5f\x73\164\x61\164\x75\x73\x5f\146\x69\145\x6c\x64")); $regex_match_data_formatting = array("\x2f\x61\164\x74\x72\151\x62\165\x74\x65\x73\x3a\166\141\x6c\x75\x65\52\57" => array($this, "\160\x61\162\163\x65\137\x63\157\155\x6d\x61\x5f\146\x69\145\154\x64"), "\57\x61\x74\x74\x72\x69\142\165\x74\x65\x73\x3a\166\151\x73\151\142\x6c\x65\x2a\x2f" => array($this, "\160\x61\x72\x73\x65\137\142\x6f\157\154\x5f\x66\151\x65\x6c\x64"), "\57\x61\164\164\162\x69\142\x75\164\145\x73\x3a\164\141\170\157\156\157\155\x79\x2a\57" => array($this, "\160\x61\x72\163\x65\137\142\157\x6f\154\x5f\x66\x69\145\x6c\x64"), "\57\x64\x6f\167\x6e\154\x6f\141\144\x73\72\x75\162\x6c\x2a\x2f" => array($this, "\160\141\162\x73\145\137\x64\157\167\156\154\x6f\141\144\137\x66\x69\154\145\137\x66\x69\145\154\x64"), "\57\x6d\145\164\x61\x3a\x2a\57" => "\167\160\x5f\x6b\163\145\x73\137\160\x6f\163\x74"); $callbacks = array(); foreach ($this->get_mapped_keys() as $index => $heading) { $callback = "\x77\143\137\143\154\145\x61\156"; if (isset($data_formatting[$heading])) { $callback = $data_formatting[$heading]; } else { foreach ($regex_match_data_formatting as $regex => $callback) { if (preg_match($regex, $heading)) { $callback = $callback; break; } } } $callbacks[] = $callback; } return apply_filters("\167\x6f\x6f\x63\x6f\155\x6d\145\x72\x63\145\x5f\x70\162\157\x64\x75\143\x74\137\x69\x6d\160\157\x72\164\145\162\137\146\157\x72\x6d\141\164\164\151\x6e\147\137\143\x61\x6c\x6c\x62\x61\x63\153\x73", $callbacks, $this); } protected function starts_with($haystack, $needle) { return substr($haystack, 0, strlen($needle)) === $needle; } protected function expand_data($data) { $data = apply_filters("\167\157\x6f\x63\157\x6d\x6d\x65\162\x63\x65\x5f\x70\162\157\144\165\x63\164\x5f\x69\155\x70\157\x72\x74\x65\x72\x5f\x70\162\x65\137\x65\170\x70\x61\x6e\144\137\144\141\164\141", $data); if (isset($data["\151\155\x61\x67\145\163"])) { $images = $data["\x69\x6d\141\147\145\163"]; $data["\x72\x61\167\137\151\x6d\x61\x67\x65\x5f\x69\144"] = array_shift($images); if (!empty($images)) { $data["\x72\141\x77\137\147\141\154\x6c\x65\162\x79\x5f\x69\155\x61\147\145\x5f\151\144\x73"] = $images; } unset($data["\x69\155\141\147\x65\x73"]); } if (isset($data["\x74\171\x70\145"])) { $data["\x74\x79\x70\x65"] = array_map("\x73\x74\x72\164\157\x6c\x6f\167\x65\x72", $data["\164\171\160\x65"]); $data["\166\151\162\164\165\x61\x6c"] = in_array("\x76\x69\x72\164\165\x61\x6c", $data["\x74\x79\x70\145"], true); $data["\144\157\x77\156\154\157\x61\144\x61\142\154\x65"] = in_array("\x64\157\x77\156\154\x6f\x61\x64\141\142\154\x65", $data["\x74\171\160\145"], true); $data["\x74\x79\160\145"] = current(array_diff($data["\x74\x79\x70\x65"], array("\x76\151\162\164\x75\x61\x6c", "\x64\157\167\156\x6c\x6f\141\x64\141\x62\154\145"))); if (!$data["\164\x79\x70\145"]) { $data["\164\x79\x70\145"] = "\163\x69\155\x70\154\x65"; } } if (isset($data["\x70\x75\x62\154\x69\x73\x68\145\144"])) { $published = $data["\160\x75\x62\154\x69\x73\150\145\x64"]; if (is_float($published)) { $published = (int) $published; } $statuses = array(-1 => "\x64\x72\x61\146\164", 0 => "\x70\x72\151\166\x61\x74\x65", 1 => "\160\x75\142\x6c\151\163\150"); $data["\163\164\141\164\x75\163"] = $statuses[$published] ?? "\144\162\x61\146\164"; if ("\166\141\x72\x69\141\164\151\157\156" === ($data["\164\x79\160\x65"] ?? null) && -1 === $published) { $data["\x73\x74\141\x74\x75\163"] = "\x70\165\142\x6c\x69\x73\x68"; } unset($data["\160\165\x62\154\151\x73\150\145\144"]); } if (isset($data["\163\x74\x6f\143\x6b\x5f\161\x75\141\156\164\x69\164\171"])) { if ('' === $data["\163\164\x6f\x63\153\x5f\161\x75\141\x6e\164\151\164\171"]) { $data["\x6d\141\156\141\x67\145\137\x73\x74\x6f\143\x6b"] = false; $data["\x73\x74\x6f\x63\x6b\x5f\x73\164\x61\164\165\163"] = isset($data["\x73\164\x6f\x63\153\137\163\x74\x61\x74\x75\163"]) ? $data["\x73\x74\157\x63\x6b\x5f\x73\x74\x61\164\165\163"] : true; } else { $data["\155\x61\x6e\x61\147\x65\137\163\164\157\x63\153"] = true; } } if (isset($data["\x73\x74\157\143\153\x5f\x73\164\141\x74\x75\x73"])) { if ("\142\x61\143\153\x6f\x72\x64\145\x72" === $data["\163\x74\157\143\x6b\x5f\x73\x74\x61\164\x75\163"]) { $data["\x73\x74\157\x63\x6b\x5f\163\x74\x61\x74\x75\163"] = "\x6f\x6e\x62\x61\143\x6b\x6f\162\x64\145\x72"; } else { $data["\x73\x74\157\143\153\x5f\163\164\141\164\x75\x73"] = $data["\x73\x74\x6f\143\x6b\137\x73\x74\141\164\165\x73"] ? "\151\156\163\164\x6f\x63\x6b" : "\157\x75\164\157\x66\x73\x74\x6f\x63\153"; } } if (isset($data["\x67\162\157\x75\x70\145\x64\137\x70\162\157\144\x75\143\164\x73"])) { $data["\x63\x68\x69\154\144\162\145\x6e"] = $data["\147\162\157\165\160\x65\144\x5f\x70\162\x6f\144\x75\143\x74\163"]; unset($data["\147\x72\157\x75\160\x65\x64\137\160\162\x6f\144\165\143\164\x73"]); } if (isset($data["\x74\141\x67\x5f\x69\x64\163\x5f\x73\x70\x61\x63\x65\163"])) { $data["\164\141\147\137\x69\x64\163"] = $data["\x74\141\147\x5f\151\144\163\x5f\x73\x70\x61\x63\x65\163"]; unset($data["\x74\141\x67\x5f\151\144\163\x5f\x73\x70\x61\x63\x65\163"]); } $attributes = array(); $downloads = array(); $meta_data = array(); foreach ($data as $key => $value) { if ($this->starts_with($key, "\141\164\x74\162\x69\142\x75\164\x65\x73\x3a\x6e\x61\155\145")) { if (!empty($value)) { $attributes[str_replace("\x61\164\x74\x72\151\142\165\164\145\163\72\156\141\155\145", '', $key)]["\156\x61\155\145"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "\x61\164\164\162\x69\x62\165\x74\145\163\x3a\x76\x61\x6c\x75\145")) { $attributes[str_replace("\x61\x74\164\x72\x69\142\165\164\145\x73\x3a\x76\x61\x6c\165\145", '', $key)]["\166\141\154\x75\x65"] = $value; unset($data[$key]); } elseif ($this->starts_with($key, "\x61\164\x74\162\151\x62\x75\164\145\163\72\x74\141\170\157\x6e\x6f\x6d\171")) { $attributes[str_replace("\141\164\164\162\151\142\165\164\145\163\72\x74\141\x78\x6f\156\157\155\171", '', $key)]["\164\141\x78\x6f\x6e\x6f\x6d\171"] = wc_string_to_bool($value); unset($data[$key]); } elseif ($this->starts_with($key, "\141\164\164\162\x69\x62\x75\164\145\x73\72\x76\x69\x73\151\142\154\145")) { $attributes[str_replace("\141\x74\x74\162\151\x62\x75\x74\x65\163\x3a\166\x69\x73\151\142\154\145", '', $key)]["\166\151\x73\151\142\154\x65"] = wc_string_to_bool($value); unset($data[$key]); } elseif ($this->starts_with($key, "\141\164\x74\x72\x69\142\x75\x74\145\163\72\x64\145\146\141\165\154\x74")) { if (!empty($value)) { $attributes[str_replace("\x61\x74\x74\x72\x69\142\x75\164\145\163\72\144\x65\x66\141\165\154\x74", '', $key)]["\144\x65\146\x61\x75\x6c\164"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "\x64\x6f\167\x6e\x6c\157\141\x64\163\72\151\144")) { if (!empty($value)) { $downloads[str_replace("\144\x6f\167\156\x6c\x6f\141\x64\x73\72\x69\144", '', $key)]["\151\x64"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "\x64\157\x77\156\154\x6f\141\144\163\72\x6e\x61\155\145")) { if (!empty($value)) { $downloads[str_replace("\144\157\167\156\154\x6f\141\144\x73\x3a\156\x61\155\145", '', $key)]["\156\x61\155\x65"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "\144\x6f\167\x6e\x6c\157\x61\144\x73\x3a\x75\x72\x6c")) { if (!empty($value)) { $downloads[str_replace("\144\157\x77\156\x6c\157\x61\144\163\x3a\165\x72\x6c", '', $key)]["\x75\162\154"] = $value; } unset($data[$key]); } elseif ($this->starts_with($key, "\x6d\145\164\x61\72")) { $meta_data[] = array("\153\145\x79" => str_replace("\x6d\145\x74\141\72", '', $key), "\x76\141\x6c\x75\145" => $value); unset($data[$key]); } } if (!empty($attributes)) { foreach ($attributes as $attribute) { if (empty($attribute["\x6e\x61\155\x65"])) { continue; } $data["\162\141\167\x5f\141\x74\164\162\151\142\165\164\145\163"][] = $attribute; } } if (!empty($downloads)) { $data["\x64\x6f\167\156\x6c\157\x61\x64\x73"] = array(); foreach ($downloads as $key => $file) { if (empty($file["\x75\162\x6c"])) { continue; } $data["\144\x6f\167\156\x6c\157\x61\144\x73"][] = array("\x64\157\x77\156\154\157\x61\144\137\x69\x64" => isset($file["\151\x64"]) ? $file["\x69\144"] : null, "\156\141\155\145" => $file["\x6e\141\x6d\x65"] ? $file["\156\141\x6d\x65"] : wc_get_filename_from_url($file["\165\x72\154"]), "\x66\151\154\x65" => $file["\x75\162\x6c"]); } } if (!empty($meta_data)) { $data["\x6d\145\x74\x61\137\x64\x61\x74\x61"] = $meta_data; } return $data; } protected function set_parsed_data() { $parse_functions = $this->get_formatting_callback(); $mapped_keys = $this->get_mapped_keys(); $use_mb = function_exists("\x6d\x62\x5f\x63\x6f\156\x76\145\162\164\x5f\145\x6e\x63\157\144\x69\x6e\x67"); foreach ($this->raw_data as $row_index => $row) { if (!count(array_filter($row))) { continue; } $this->parsing_raw_data_index = $row_index; $data = array(); do_action("\x77\157\x6f\x63\157\155\155\145\162\143\145\137\160\x72\x6f\144\165\143\164\137\151\x6d\160\x6f\x72\x74\x65\x72\137\x62\x65\x66\157\x72\x65\137\x73\145\x74\137\x70\141\x72\163\145\144\x5f\x64\x61\x74\141", $row, $mapped_keys); foreach ($row as $id => $value) { if (empty($mapped_keys[$id])) { continue; } if ($use_mb) { $encoding = mb_detect_encoding($value, mb_detect_order(), true); if ($encoding) { $value = mb_convert_encoding($value, "\125\124\106\x2d\70", $encoding); } else { $value = mb_convert_encoding($value, "\x55\x54\x46\55\x38", "\125\x54\106\x2d\70"); } } else { $value = wp_check_invalid_utf8($value, true); } $data[$mapped_keys[$id]] = call_user_func($parse_functions[$id], $value); } $this->parsed_data[] = apply_filters("\x77\x6f\157\x63\x6f\155\155\145\x72\143\145\137\x70\x72\157\x64\x75\143\x74\x5f\x69\155\160\157\x72\164\x65\162\x5f\160\x61\162\x73\145\144\x5f\144\x61\x74\x61", $this->expand_data($data), $this); } } protected function get_row_id($parsed_data) { $id = isset($parsed_data["\151\x64"]) ? absint($parsed_data["\x69\144"]) : 0; $sku = isset($parsed_data["\x73\153\165"]) ? esc_attr($parsed_data["\x73\153\165"]) : ''; $name = isset($parsed_data["\x6e\x61\155\145"]) ? esc_attr($parsed_data["\x6e\x61\x6d\145"]) : ''; $row_data = array(); if ($name) { $row_data[] = $name; } if ($id) { $row_data[] = sprintf(__("\x49\x44\40\x25\144", "\x77\x6f\x6f\x63\x6f\x6d\x6d\x65\162\143\x65"), $id); } if ($sku) { $row_data[] = sprintf(__("\123\x4b\x55\x20\x25\163", "\x77\157\157\x63\157\x6d\x6d\145\x72\x63\145"), $sku); } return implode("\x2c\x20", $row_data); } public function import() { $this->start_time = time(); $index = 0; $update_existing = $this->params["\x75\x70\x64\x61\x74\145\x5f\145\170\151\x73\164\x69\156\147"]; $data = array("\x69\155\x70\x6f\162\x74\145\144" => array(), "\151\155\x70\x6f\162\164\x65\x64\x5f\x76\x61\162\x69\141\164\x69\x6f\156\x73" => array(), "\x66\x61\151\154\x65\x64" => array(), "\165\x70\144\141\x74\145\x64" => array(), "\163\x6b\x69\160\x70\145\144" => array()); foreach ($this->parsed_data as $parsed_data_key => $parsed_data) { do_action("\x77\157\157\x63\x6f\x6d\155\145\x72\143\x65\x5f\160\x72\x6f\x64\165\x63\x74\137\151\x6d\x70\x6f\x72\x74\137\142\x65\x66\x6f\162\145\x5f\151\155\160\157\x72\x74", $parsed_data); $id = isset($parsed_data["\x69\x64"]) ? absint($parsed_data["\151\x64"]) : 0; $sku = isset($parsed_data["\163\x6b\165"]) ? $parsed_data["\163\x6b\x75"] : ''; $id_exists = false; $sku_exists = false; if ($id) { $product = wc_get_product($id); $id_exists = $product && "\151\x6d\160\x6f\162\164\x69\156\x67" !== $product->get_status(); } if ($sku) { $id_from_sku = wc_get_product_id_by_sku($sku); $product = $id_from_sku ? wc_get_product($id_from_sku) : false; $sku_exists = $product && "\x69\155\x70\x6f\x72\x74\x69\x6e\x67" !== $product->get_status(); } if ($id_exists && !$update_existing) { $data["\163\153\151\160\x70\145\x64"][] = new WP_Error("\167\157\x6f\143\x6f\155\x6d\x65\162\143\x65\x5f\160\x72\157\144\165\143\164\x5f\151\x6d\x70\157\162\164\145\162\x5f\x65\162\162\x6f\x72", esc_html__("\101\40\160\162\157\144\165\x63\164\x20\x77\x69\x74\x68\x20\164\x68\x69\163\x20\x49\104\x20\141\154\x72\145\141\144\171\40\x65\x78\151\x73\164\x73\56", "\167\157\x6f\143\157\x6d\155\145\x72\x63\145"), array("\x69\144" => $id, "\162\x6f\167" => $this->get_row_id($parsed_data))); continue; } if ($sku_exists && !$update_existing) { $data["\x73\x6b\x69\160\160\x65\144"][] = new WP_Error("\167\x6f\157\143\x6f\155\155\x65\162\143\145\x5f\160\162\157\x64\165\143\x74\137\151\x6d\160\157\x72\x74\x65\x72\x5f\x65\162\x72\157\x72", esc_html__("\x41\40\x70\162\157\x64\x75\143\164\x20\167\151\164\x68\40\x74\x68\151\163\x20\x53\x4b\125\x20\141\x6c\162\x65\x61\144\x79\40\x65\x78\151\163\164\163\x2e", "\167\157\x6f\143\x6f\155\x6d\x65\162\143\145"), array("\x73\153\165" => esc_attr($sku), "\162\x6f\167" => $this->get_row_id($parsed_data))); continue; } if ($update_existing && (isset($parsed_data["\151\x64"]) || isset($parsed_data["\x73\153\165"])) && !$id_exists && !$sku_exists) { $data["\x73\153\x69\160\x70\x65\144"][] = new WP_Error("\x77\157\x6f\x63\157\x6d\155\145\162\143\x65\x5f\160\x72\x6f\144\165\x63\164\x5f\x69\155\x70\157\162\x74\145\162\137\145\162\x72\x6f\x72", esc_html__("\x4e\157\40\x6d\141\164\x63\x68\151\x6e\x67\x20\160\162\x6f\144\x75\x63\x74\40\x65\x78\151\163\164\x73\40\164\157\40\165\x70\144\x61\x74\x65\x2e", "\x77\x6f\x6f\143\157\155\155\145\x72\143\145"), array("\x69\144" => $id, "\x73\153\x75" => esc_attr($sku), "\x72\157\x77" => $this->get_row_id($parsed_data))); continue; } $result = $this->process_item($parsed_data); if (is_wp_error($result)) { $result->add_data(array("\x72\157\167" => $this->get_row_id($parsed_data))); $data["\146\141\x69\x6c\x65\x64"][] = $result; } elseif ($result["\165\160\x64\x61\164\145\x64"]) { $data["\x75\160\144\x61\164\145\x64"][] = $result["\151\x64"]; } else { if ($result["\x69\163\x5f\x76\141\x72\151\141\164\x69\x6f\x6e"]) { $data["\151\155\x70\157\162\x74\145\x64\137\x76\141\x72\151\x61\164\x69\x6f\x6e\163"][] = $result["\151\x64"]; } else { $data["\x69\155\160\x6f\x72\x74\145\x64"][] = $result["\x69\144"]; } } $index++; if ($this->params["\160\162\145\166\145\156\x74\137\x74\x69\x6d\145\157\x75\164\163"] && ($this->time_exceeded() || $this->memory_exceeded())) { $this->file_position = $this->file_positions[$index]; break; } } return $data; } }

Function Calls

None

Variables

None

Stats

MD5 ddb3f6ec75c81aba9be548366565cc51
Eval Count 0
Decode Time 111 ms