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.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / packages / woocommerce-admin / includes / connect-existing-pages.php
woocommerce / packages / woocommerce-admin / includes Last commit date
emails 5 years ago connect-existing-pages.php 5 years ago core-functions.php 5 years ago feature-config.php 5 years ago page-controller-functions.php 5 years ago wc-admin-update-functions.php 5 years ago
connect-existing-pages.php
295 lines
1 <?php
2 /**
3 * Connect existing WooCommerce pages to WooCommerce Admin.
4 *
5 * @package WooCommerce\Admin
6 */
7
8 use Automattic\WooCommerce\Admin\Loader;
9 use Automattic\WooCommerce\Admin\PageController;
10
11 /**
12 * Returns core WC pages to connect to WC-Admin.
13 *
14 * @return array
15 */
16 function wc_admin_get_core_pages_to_connect() {
17 $all_reports = WC_Admin_Reports::get_reports();
18 $report_tabs = array();
19
20 foreach ( $all_reports as $report_id => $report_data ) {
21 $report_tabs[ $report_id ] = $report_data['title'];
22 }
23
24 return array(
25 'wc-addons' => array(
26 'title' => __( 'Extensions', 'woocommerce' ),
27 'tabs' => array(),
28 ),
29 'wc-reports' => array(
30 'title' => __( 'Reports', 'woocommerce' ),
31 'tabs' => $report_tabs,
32 ),
33 'wc-settings' => array(
34 'title' => __( 'Settings', 'woocommerce' ),
35 'tabs' => apply_filters( 'woocommerce_settings_tabs_array', array() ),
36 ),
37 'wc-status' => array(
38 'title' => __( 'Status', 'woocommerce' ),
39 'tabs' => apply_filters(
40 'woocommerce_admin_status_tabs',
41 array(
42 'status' => __( 'System status', 'woocommerce' ),
43 'tools' => __( 'Tools', 'woocommerce' ),
44 'logs' => __( 'Logs', 'woocommerce' ),
45 )
46 ),
47 ),
48 );
49 }
50
51 /**
52 * Filter breadcrumbs for core pages that aren't explicitly connected.
53 *
54 * @param array $breadcrumbs Breadcrumb pieces.
55 * @return array Filtered breadcrumb pieces.
56 */
57 function wc_admin_filter_core_page_breadcrumbs( $breadcrumbs ) {
58 $screen_id = PageController::get_instance()->get_current_screen_id();
59 $pages_to_connect = wc_admin_get_core_pages_to_connect();
60 $woocommerce_breadcrumb = array(
61 'admin.php?page=wc-admin',
62 __( 'WooCommerce', 'woocommerce' ),
63 );
64
65 foreach ( $pages_to_connect as $page_id => $page_data ) {
66 if ( preg_match( "/^woocommerce_page_{$page_id}\-/", $screen_id ) ) {
67 if ( empty( $page_data['tabs'] ) ) {
68 $new_breadcrumbs = array(
69 $woocommerce_breadcrumb,
70 $page_data['title'],
71 );
72 } else {
73 $new_breadcrumbs = array(
74 $woocommerce_breadcrumb,
75 array(
76 add_query_arg( 'page', $page_id, 'admin.php' ),
77 $page_data['title'],
78 ),
79 );
80
81 if ( isset( $_GET['tab'] ) ) {
82 $current_tab = wc_clean( wp_unslash( $_GET['tab'] ) );
83 } else {
84 $current_tab = key( $page_data['tabs'] );
85 }
86
87 $new_breadcrumbs[] = $page_data['tabs'][ $current_tab ];
88 }
89
90 return $new_breadcrumbs;
91 }
92 }
93
94 return $breadcrumbs;
95 }
96
97 /**
98 * Render the WC-Admin header bar on all WooCommerce core pages.
99 *
100 * @param bool $is_connected Whether the current page is connected.
101 * @param bool $current_page The current page, if connected.
102 * @return bool Whether to connect the page.
103 */
104 function wc_admin_connect_core_pages( $is_connected, $current_page ) {
105 if ( false === $is_connected && false === $current_page ) {
106 $screen_id = PageController::get_instance()->get_current_screen_id();
107 $pages_to_connect = wc_admin_get_core_pages_to_connect();
108
109 foreach ( $pages_to_connect as $page_id => $page_data ) {
110 if ( preg_match( "/^woocommerce_page_{$page_id}\-/", $screen_id ) ) {
111 add_filter( 'woocommerce_navigation_get_breadcrumbs', 'wc_admin_filter_core_page_breadcrumbs' );
112
113 return true;
114 }
115 }
116 }
117
118 return $is_connected;
119 }
120
121 add_filter( 'woocommerce_navigation_is_connected_page', 'wc_admin_connect_core_pages', 10, 2 );
122
123 $posttype_list_base = 'edit.php';
124
125 // WooCommerce > Orders.
126 wc_admin_connect_page(
127 array(
128 'id' => 'woocommerce-orders',
129 'screen_id' => 'edit-shop_order',
130 'title' => __( 'Orders', 'woocommerce' ),
131 'path' => add_query_arg( 'post_type', 'shop_order', $posttype_list_base ),
132 )
133 );
134
135 // WooCommerce > Orders > Add New.
136 wc_admin_connect_page(
137 array(
138 'id' => 'woocommerce-add-order',
139 'parent' => 'woocommerce-orders',
140 'screen_id' => 'shop_order-add',
141 'title' => __( 'Add New', 'woocommerce' ),
142 )
143 );
144
145 // WooCommerce > Orders > Edit Order.
146 wc_admin_connect_page(
147 array(
148 'id' => 'woocommerce-edit-order',
149 'parent' => 'woocommerce-orders',
150 'screen_id' => 'shop_order',
151 'title' => __( 'Edit Order', 'woocommerce' ),
152 )
153 );
154
155 // WooCommerce > Coupons.
156 wc_admin_connect_page(
157 array(
158 'id' => 'woocommerce-coupons',
159 'parent' => Loader::is_feature_enabled( 'coupons' ) ? 'woocommerce-marketing' : null,
160 'screen_id' => 'edit-shop_coupon',
161 'title' => __( 'Coupons', 'woocommerce' ),
162 'path' => add_query_arg( 'post_type', 'shop_coupon', $posttype_list_base ),
163 )
164 );
165
166 // WooCommerce > Coupons > Add New.
167 wc_admin_connect_page(
168 array(
169 'id' => 'woocommerce-add-coupon',
170 'parent' => 'woocommerce-coupons',
171 'screen_id' => 'shop_coupon-add',
172 'title' => __( 'Add New', 'woocommerce' ),
173 )
174 );
175
176 // WooCommerce > Coupons > Edit Coupon.
177 wc_admin_connect_page(
178 array(
179 'id' => 'woocommerce-edit-coupon',
180 'parent' => 'woocommerce-coupons',
181 'screen_id' => 'shop_coupon',
182 'title' => __( 'Edit Coupon', 'woocommerce' ),
183 )
184 );
185
186 // WooCommerce > Products.
187 wc_admin_connect_page(
188 array(
189 'id' => 'woocommerce-products',
190 'screen_id' => 'edit-product',
191 'title' => __( 'Products', 'woocommerce' ),
192 'path' => add_query_arg( 'post_type', 'product', $posttype_list_base ),
193 )
194 );
195
196 // WooCommerce > Products > Add New.
197 wc_admin_connect_page(
198 array(
199 'id' => 'woocommerce-add-product',
200 'parent' => 'woocommerce-products',
201 'screen_id' => 'product-add',
202 'title' => __( 'Add New', 'woocommerce' ),
203 )
204 );
205
206 // WooCommerce > Products > Edit Order.
207 wc_admin_connect_page(
208 array(
209 'id' => 'woocommerce-edit-product',
210 'parent' => 'woocommerce-products',
211 'screen_id' => 'product',
212 'title' => __( 'Edit Product', 'woocommerce' ),
213 )
214 );
215
216 // WooCommerce > Products > Import Products.
217 wc_admin_connect_page(
218 array(
219 'id' => 'woocommerce-import-products',
220 'parent' => 'woocommerce-products',
221 'screen_id' => 'product_page_product_importer',
222 'title' => __( 'Import Products', 'woocommerce' ),
223 )
224 );
225
226 // WooCommerce > Products > Export Products.
227 wc_admin_connect_page(
228 array(
229 'id' => 'woocommerce-export-products',
230 'parent' => 'woocommerce-products',
231 'screen_id' => 'product_page_product_exporter',
232 'title' => __( 'Export Products', 'woocommerce' ),
233 )
234 );
235
236 // WooCommerce > Products > Product categories.
237 wc_admin_connect_page(
238 array(
239 'id' => 'woocommerce-product-categories',
240 'parent' => 'woocommerce-products',
241 'screen_id' => 'edit-product_cat',
242 'title' => __( 'Product categories', 'woocommerce' ),
243 )
244 );
245
246 // WooCommerce > Products > Edit category.
247 wc_admin_connect_page(
248 array(
249 'id' => 'woocommerce-product-edit-category',
250 'parent' => 'woocommerce-products',
251 'screen_id' => 'product_cat',
252 'title' => __( 'Edit category', 'woocommerce' ),
253 )
254 );
255
256 // WooCommerce > Products > Product tags.
257 wc_admin_connect_page(
258 array(
259 'id' => 'woocommerce-product-tags',
260 'parent' => 'woocommerce-products',
261 'screen_id' => 'edit-product_tag',
262 'title' => __( 'Product tags', 'woocommerce' ),
263 )
264 );
265
266 // WooCommerce > Products > Edit tag.
267 wc_admin_connect_page(
268 array(
269 'id' => 'woocommerce-product-edit-tag',
270 'parent' => 'woocommerce-products',
271 'screen_id' => 'product_tag',
272 'title' => __( 'Edit tag', 'woocommerce' ),
273 )
274 );
275
276 // WooCommerce > Products > Attributes.
277 wc_admin_connect_page(
278 array(
279 'id' => 'woocommerce-product-attributes',
280 'parent' => 'woocommerce-products',
281 'screen_id' => 'product_page_product_attributes',
282 'title' => __( 'Attributes', 'woocommerce' ),
283 )
284 );
285
286 // WooCommerce > Products > Edit attribute.
287 wc_admin_connect_page(
288 array(
289 'id' => 'woocommerce-product-edit-attribute',
290 'parent' => 'woocommerce-products',
291 'screen_id' => 'product_page_product_attribute-edit',
292 'title' => __( 'Edit attribute', 'woocommerce' ),
293 )
294 );
295