PluginProbe
Packeta / 1.4.1
Packeta v1.4.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / ContextResolver.php

ContextResolver.php in Packeta 1.4.1, at src/Packetery/Module/ContextResolver.php

82 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class ContextResolver.
4 *
5 * @package Packetery\Module
6 */
7
8 declare( strict_types=1 );
9
10
11 namespace Packetery\Module;
12
13 /**
14 * Class ContextResolver.
15 *
16 * @package Packetery\Module
17 */
18 class ContextResolver {
19
20 /**
21 * Tells if requesting user is at order grid page.
22 *
23 * @return bool
24 */
25 public function isOrderGridPage(): bool {
26 global $pagenow, $typenow;
27
28 return 'edit.php' === $pagenow && 'shop_order' === $typenow;
29 }
30
31 /**
32 * Tells if requesting user is at order detail page.
33 *
34 * @return bool
35 */
36 public function isOrderDetailPage(): bool {
37 global $pagenow, $typenow;
38
39 return 'post.php' === $pagenow && 'shop_order' === $typenow;
40 }
41
42 /**
43 * Tells if requesting user is at product detail page.
44 *
45 * @return bool
46 */
47 private function isProductDetailPage(): bool {
48 global $pagenow, $typenow;
49
50 return 'post.php' === $pagenow && 'product' === $typenow;
51 }
52
53 /**
54 * Tells if requesting user is at product create page.
55 *
56 * @return bool
57 */
58 private function isProductCreatePage(): bool {
59 global $pagenow, $typenow;
60
61 return 'post-new.php' === $pagenow && 'product' === $typenow;
62 }
63
64 /**
65 * Tells if requesting user is at product page.
66 *
67 * @return bool
68 */
69 public function isProductPage(): bool {
70 return $this->isProductCreatePage() || $this->isProductDetailPage();
71 }
72
73 /**
74 * Tells if requesting user is at page using packetery confirm.
75 *
76 * @return bool
77 */
78 public function isPacketeryConfirmPage(): bool {
79 return $this->isOrderDetailPage() || $this->isOrderGridPage();
80 }
81 }
82