Skip to content

Commit 574ad39

Browse files
Create a PageHelper class with method to check if we're on the analytics page
1 parent 9c71958 commit 574ad39

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

woocommerce/Helpers/PageHelper.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* WooCommerce Plugin Framework
4+
*
5+
* This source file is subject to the GNU General Public License v3.0
6+
* that is bundled with this package in the file license.txt.
7+
* It is also available through the world-wide-web at this URL:
8+
* http://www.gnu.org/licenses/gpl-3.0.html
9+
* If you did not receive a copy of the license and are unable to
10+
* obtain it through the world-wide-web, please send an email
11+
* to [email protected] so we can send you a copy immediately.
12+
*
13+
* DISCLAIMER
14+
*
15+
* Do not edit or add to this file if you wish to upgrade the plugin to newer
16+
* versions in the future. If you wish to customize the plugin for your
17+
* needs please refer to http://www.skyverge.com
18+
*
19+
* @package SkyVerge/WooCommerce/Plugin/Classes
20+
* @author SkyVerge
21+
* @copyright Copyright (c) 2013-2025, SkyVerge, Inc.
22+
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
23+
*/
24+
25+
namespace SkyVerge\WooCommerce\PluginFramework\v5_15_4\Helpers;
26+
27+
class PageHelper
28+
{
29+
/**
30+
* Determines whether the current page is the WooCommerce "Analytics" page.
31+
*
32+
* @since 5.15.4
33+
*/
34+
public static function isWooCommerceAnalyticsPage() : bool
35+
{
36+
if (! class_exists(\Automattic\WooCommerce\Admin\PageController::class)) {
37+
return false;
38+
}
39+
40+
$pageData = \Automattic\WooCommerce\Admin\PageController::get_instance()->get_current_page();
41+
42+
return ($pageData['id'] ?? '') === 'woocommerce-analytics' ||
43+
($pageData['parent'] ?? '') === 'woocommerce-analytics';
44+
}
45+
}

woocommerce/changelog.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*** SkyVerge WooCommerce Plugin Framework Changelog ***
22

3-
2024.nn.nn - version 5.15.4
3+
2025.nn.nn - version 5.15.4
4+
* New: Added PageHelper class to assist in determining page contexts.
5+
* New: Add a helper method to get WooCommerce object meta values.
46

57
2025.01.24 - version 5.15.3
68
* Fix - Add Merchant ID to Google Pay, distinguishing it from Gateway merchant ID

0 commit comments

Comments
 (0)