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.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / classes / Utilities / AdminUrl.php
woocommerce-multilingual / classes / Utilities Last commit date
Suspend 2 years ago ActionScheduler.php 2 years ago AdminPages.php 8 months ago AdminUrl.php 8 months ago DB.php 4 years ago Post.php 5 years ago Resources.php 5 years ago SyncHash.php 8 months ago WCTaxonomies.php 1 year ago WcAdminPages.php 8 months ago WpAdminPages.php 1 year ago
AdminUrl.php
231 lines
1 <?php
2
3 namespace WCML\Utilities;
4
5 use function WCML\functions\isStandAlone;
6
7 class AdminUrl {
8 const PAGE_WPML_WCML = \WCML_Admin_Menus::SLUG;
9
10 const PAGE_WOO_SETTINGS = 'wc-settings';
11
12 const TAB_PRODUCTS = 'products';
13 const TAB_MULTILINGUAL = AdminPages::TAB_MULTILINGUAL;
14 const TAB_MULTILINGUAL_STANDALONE = AdminPages::TAB_MULTILINGUAL_STANDALONE;
15 const TAB_MULTICURRENCY = AdminPages::TAB_MULTICURRENCY;
16 const TAB_TROUBLESHOOTING = 'troubleshooting';
17 const TAB_STORE_URL = 'slugs';
18 const TAB_STATUS = 'status';
19
20 const TAB_SETTINGS = 'settings';
21 const SRC_SETUP_LATER = 'setup_later';
22
23 const DASHBOARD_PARAM_SECTIONS = 'sections';
24 const DASHBOARD_SECTION_PRODUCT = 'post/product';
25 const DASHBOARD_SECTION_STRING = 'string';
26 const DASHBOARD_PARAM_STRING_DOMAIN = 'predefinedStringDomain';
27
28 private static function getAdminUrl( array $getParams ) : string {
29 return add_query_arg(
30 $getParams,
31 admin_url( 'admin.php' )
32 );
33 }
34
35 public static function getTab( $taxonomy ) : string {
36 return self::getAdminUrl( [
37 'page' => self::PAGE_WPML_WCML,
38 'tab' => $taxonomy,
39 ] );
40 }
41
42 public static function getMultilingualTab() : string {
43 return self::getAdminUrl( [
44 'page' => self::PAGE_WPML_WCML,
45 'tab' => isStandAlone() ? self::TAB_MULTILINGUAL_STANDALONE : self::TAB_MULTILINGUAL,
46 ] );
47 }
48
49 public static function getMultiCurrencyTab( string $anchor = '' ) : string {
50 $url = self::getAdminUrl( [
51 'page' => self::PAGE_WPML_WCML,
52 'tab' => self::TAB_MULTICURRENCY,
53 ] );
54
55 if ( ! empty( $anchor ) ) {
56 $url .= '#' . $anchor;
57 }
58
59 return $url;
60 }
61
62 public static function getStoreURLTab() : string {
63 return self::getAdminUrl( [
64 'page' => self::PAGE_WPML_WCML,
65 'tab' => self::TAB_STORE_URL,
66 ] );
67 }
68
69 public static function getStatusTab() : string {
70 return self::getAdminUrl( [
71 'page' => self::PAGE_WPML_WCML,
72 'tab' => self::TAB_STATUS,
73 ] );
74 }
75
76 public static function getSettingsTab() : string {
77 return self::getAdminUrl( [
78 'page' => self::PAGE_WPML_WCML,
79 'tab' => self::TAB_SETTINGS,
80 ] );
81 }
82
83 public static function getTroubleshootingTab() : string {
84 return self::getAdminUrl( [
85 'page' => self::PAGE_WPML_WCML,
86 'tab' => self::TAB_TROUBLESHOOTING,
87 ] );
88 }
89
90 public static function getSetupLater() : string {
91 return self::getAdminUrl( [
92 'page' => self::PAGE_WPML_WCML,
93 'src' => self::SRC_SETUP_LATER,
94 ] );
95 }
96
97 /**
98 * @param ?string $step
99 */
100 public static function getSetup( $step = null ) : string {
101 $args = [];
102 $args['page'] = \WCML_Setup_UI::SLUG;
103 if ( ! is_null( $step ) ) {
104 $args['step'] = $step;
105 }
106
107 return self::getAdminUrl( $args );
108 }
109
110 /**
111 * @param string[] $sections
112 * @param string $stringDomain
113 *
114 * @return string
115 *
116 * @throws \Error if WPML is not active, since \WPML\UIPage depends on it.
117 */
118 public static function getWPMLTMDashboard( array $sections = [], string $stringDomain = '' ) : string {
119 $dashboardUrl = admin_url( \WPML\UIPage::getTMDashboard() );
120 if ( empty( $sections ) ) {
121 return $dashboardUrl;
122 }
123
124 $dashboardUrl = add_query_arg(
125 [ self::DASHBOARD_PARAM_SECTIONS => implode( ',', $sections ) ],
126 $dashboardUrl
127 );
128
129 if ( in_array( self::DASHBOARD_SECTION_STRING, $sections, true ) && $stringDomain ) {
130 $dashboardUrl = add_query_arg(
131 [ self::DASHBOARD_PARAM_STRING_DOMAIN => $stringDomain ],
132 $dashboardUrl
133 );
134 }
135
136 return $dashboardUrl;
137 }
138
139 /**
140 * @param string $domain
141 *
142 * @return string
143 *
144 * @throws \Error if WPML is not active, since \WPML\UIPage depends on it.
145 */
146 public static function getWPMLTMDashboardStringDomain( string $domain ) : string {
147 return self::getWPMLTMDashboard(
148 [ self::DASHBOARD_SECTION_STRING ],
149 $domain
150 );
151 }
152
153 /**
154 * @return string
155 *
156 * @throws \Error if WPML is not active, since \WPML\UIPage depends on it.
157 */
158 public static function getWPMLTMDashboardProducts() : string {
159 return self::getWPMLTMDashboard( [ self::DASHBOARD_SECTION_PRODUCT ] );
160 }
161
162 /**
163 * @param ?string $taxonomy
164 *
165 * @return string
166 *
167 * @throws \Error if WPML is not active, since WPML_PLUGIN_FOLDER depends on it.
168 */
169 public static function getWPMLTaxonomyTranslation( $taxonomy = null ) : string {
170 $args = [
171 'page' => WPML_PLUGIN_FOLDER . '/menu/taxonomy-translation.php',
172 'taxonomy' => $taxonomy,
173 ];
174
175 return self::getAdminUrl( $args );
176 }
177
178 /**
179 * @param array $args
180 *
181 * @return string
182 *
183 * @throws \Error if WPML is not active, since WPML_ST_FOLDER depends on it.
184 */
185 public static function getWPMLStringTranslation( array $args = [] ) : string {
186 $args = array_merge(
187 [
188 'page' => WPML_ST_FOLDER . '/menu/string-translation.php',
189 ],
190 $args
191 );
192
193 return self::getAdminUrl( $args );
194 }
195
196 public static function getWooProductAll() : string {
197 $args = [
198 'post_type' => 'product',
199 ];
200
201 return add_query_arg(
202 $args,
203 admin_url( 'edit.php' )
204 );
205 }
206
207 /**
208 * @param ?string $tab
209 */
210 public static function getWooSettings( $tab = null ) : string {
211 $args = [
212 'page' => self::PAGE_WOO_SETTINGS,
213 'tab' => $tab,
214 ];
215
216 return self::getAdminUrl( $args );
217 }
218
219 /**
220 * @param ?string $tab
221 */
222 public static function getWooStatus( $tab = null ) : string {
223 $args = [
224 'page' => 'wc-status',
225 'tab' => $tab,
226 ];
227
228 return self::getAdminUrl( $args );
229 }
230 }
231