1 | <?php # -*- coding: utf-8 -*- |
||||||
2 | declare(strict_types=1); |
||||||
3 | |||||||
4 | namespace MultisiteGlobalMedia\WooCommerce; |
||||||
5 | |||||||
6 | use MultisiteGlobalMedia\Helper; |
||||||
7 | use MultisiteGlobalMedia\SingleSwitcher; |
||||||
8 | use MultisiteGlobalMedia\Site; |
||||||
9 | |||||||
10 | /** |
||||||
11 | * Class Gallery |
||||||
12 | * |
||||||
13 | * TODO May be we want to split admin from the frontend? |
||||||
14 | */ |
||||||
15 | class Gallery |
||||||
16 | { |
||||||
17 | use Helper; |
||||||
18 | |||||||
19 | const FILTER_ATTACHMENT_IMAGE_SRC = 'wp_get_attachment_image_src'; |
||||||
20 | |||||||
21 | const DEFAULT_PRODUCT_TYPE = 'simple'; |
||||||
22 | const POST_PRODUCT_TYPE = 'product-type'; |
||||||
23 | const POST_PRODUCT_IMAGE_GALLERY = 'product_image_gallery'; |
||||||
24 | |||||||
25 | const META_KEY_PRODUCT_GALLERY = '_product_image_gallery'; |
||||||
26 | |||||||
27 | /** |
||||||
28 | * @var Site |
||||||
29 | */ |
||||||
30 | private $site; |
||||||
31 | |||||||
32 | /** |
||||||
33 | * @var SingleSwitcher |
||||||
34 | */ |
||||||
35 | private $siteSwitcher; |
||||||
36 | |||||||
37 | /** |
||||||
38 | * Gallery constructor |
||||||
39 | * |
||||||
40 | * @param Site $site |
||||||
41 | * @param SingleSwitcher $siteSwitcher |
||||||
42 | */ |
||||||
43 | public function __construct(Site $site, SingleSwitcher $siteSwitcher) |
||||||
44 | { |
||||||
45 | $this->site = $site; |
||||||
46 | $this->siteSwitcher = $siteSwitcher; |
||||||
47 | } |
||||||
48 | |||||||
49 | /** |
||||||
50 | * Save Gallery Ids into product meta |
||||||
51 | * |
||||||
52 | * @param int $productId |
||||||
53 | */ |
||||||
54 | public function saveGalleryIds(int $productId) |
||||||
55 | { |
||||||
56 | $productType = \WC_Product_Factory::get_product_type($productId); |
||||||
0 ignored issues
–
show
|
|||||||
57 | $requestProductType = filter_input( |
||||||
58 | INPUT_POST, |
||||||
59 | self::POST_PRODUCT_TYPE, |
||||||
60 | FILTER_SANITIZE_STRING |
||||||
61 | ); |
||||||
62 | |||||||
63 | $requestProductType and $productType = sanitize_title(stripslashes($requestProductType)); |
||||||
0 ignored issues
–
show
The function
sanitize_title was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
64 | |||||||
65 | $productType = $productType ?: self::DEFAULT_PRODUCT_TYPE; |
||||||
66 | $classname = \WC_Product_Factory::get_product_classname($productId, $productType); |
||||||
67 | /** @var \WC_Product $product */ |
||||||
68 | $product = new $classname($productId); |
||||||
69 | $attachmentIds = filter_input( |
||||||
70 | INPUT_POST, |
||||||
71 | self::POST_PRODUCT_IMAGE_GALLERY, |
||||||
72 | FILTER_SANITIZE_STRING |
||||||
73 | ); |
||||||
74 | |||||||
75 | update_post_meta($product->get_id(), self::META_KEY_PRODUCT_GALLERY, $attachmentIds); |
||||||
0 ignored issues
–
show
The function
update_post_meta was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
76 | } |
||||||
77 | } |
||||||
78 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths