WCAdminHelper
in package
Class WCAdminHelper
Table of Contents
- WC_ADMIN_STORE_AGE_RANGES = array('week-1' => array('start' => 0, 'end' => WEEK_IN_SECONDS), 'week-1-4' => array('start' => WEEK_IN_SECONDS, 'end' => WEEK_IN_SECONDS * 4), 'month-1-3' => array('start' => MONTH_IN_SECONDS, 'end' => MONTH_IN_SECONDS * 3), 'month-3-6' => array('start' => MONTH_IN_SECONDS * 3, 'end' => MONTH_IN_SECONDS * 6), 'month-6+' => array('start' => MONTH_IN_SECONDS * 6))
- WC_ADMIN_TIMESTAMP_OPTION = 'woocommerce_admin_install_timestamp'
- WC Admin timestamp option name.
- get_wcadmin_active_for_in_seconds() : number
- Get the number of seconds that the store has been active.
- is_site_fresh() : bool
- Test if the site is fresh. A fresh site must meet the following requirements.
- is_store_page() : bool
- Test if a URL is a store page. This function ignores the domain and protocol of the URL and only checks the path and query string.
- is_wc_admin_active_for() : bool
- Test how long WooCommerce Admin has been active.
- is_wc_admin_active_in_date_range() : bool
- Test if WooCommerce Admin has been active within a pre-defined range.
- get_normalized_url_path() : mixed
- Get normalized URL path.
Constants
WC_ADMIN_STORE_AGE_RANGES
public
mixed
WC_ADMIN_STORE_AGE_RANGES
= array('week-1' => array('start' => 0, 'end' => WEEK_IN_SECONDS), 'week-1-4' => array('start' => WEEK_IN_SECONDS, 'end' => WEEK_IN_SECONDS * 4), 'month-1-3' => array('start' => MONTH_IN_SECONDS, 'end' => MONTH_IN_SECONDS * 3), 'month-3-6' => array('start' => MONTH_IN_SECONDS * 3, 'end' => MONTH_IN_SECONDS * 6), 'month-6+' => array('start' => MONTH_IN_SECONDS * 6))
WC_ADMIN_TIMESTAMP_OPTION
WC Admin timestamp option name.
public
mixed
WC_ADMIN_TIMESTAMP_OPTION
= 'woocommerce_admin_install_timestamp'
Methods
get_wcadmin_active_for_in_seconds()
Get the number of seconds that the store has been active.
public
static get_wcadmin_active_for_in_seconds() : number
Return values
number — Number of seconds.is_site_fresh()
Test if the site is fresh. A fresh site must meet the following requirements.
public
static is_site_fresh() : bool
- The current user was registered less than 1 month ago.
- fresh_site option must be 1
Return values
bool —is_store_page()
Test if a URL is a store page. This function ignores the domain and protocol of the URL and only checks the path and query string.
public
static is_store_page([string $url = '' ]) : bool
Store pages are defined as:
- Shop
- Cart
- Checkout
- Privacy Policy
- Terms and Conditions
Additionally, the following autogenerated pages should be included:
- Product pages
- Product Category pages
- Product Tag pages
Parameters
- $url : string = ''
-
URL to check. If not provided, the current URL will be used.
Return values
bool — Whether or not the URL is a store page.is_wc_admin_active_for()
Test how long WooCommerce Admin has been active.
public
static is_wc_admin_active_for(int $seconds) : bool
Parameters
- $seconds : int
-
Time in seconds to check.
Return values
bool — Whether or not WooCommerce admin has been active for $seconds.is_wc_admin_active_in_date_range()
Test if WooCommerce Admin has been active within a pre-defined range.
public
static is_wc_admin_active_in_date_range(string $range[, int $custom_start = null ]) : bool
Parameters
- $range : string
-
range available in WC_ADMIN_STORE_AGE_RANGES.
- $custom_start : int = null
-
custom start in range.
Tags
Return values
bool — Whether or not WooCommerce admin has been active within the range.get_normalized_url_path()
Get normalized URL path.
private
static get_normalized_url_path(string $url) : mixed
- Only keep the path and query string (if any).
- Remove wp home path from the URL path if WP is installed in a subdirectory.
- Remove leading and trailing slashes.
For example:
- https://example.com/wordpress/shop/uncategorized/test/?add-to-cart=123 => shop/uncategorized/test/?add-to-cart=123
Parameters
- $url : string
-
URL to normalize.