Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
WooCommerce
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 isWooCommerce
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAllPageIds
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace NewfoldLabs\WP\Module\InstallChecker;
4
5class WooCommerce {
6
7    /**
8     * Check if WooCommerce is installed and active.
9     *
10     * @return bool
11     */
12    public static function isWooCommerce() {
13        return class_exists( 'WooCommerce' );
14    }
15
16    /**
17     * Get all WooCommerce page IDs.
18     *
19     * @return int[]
20     */
21    public static function getAllPageIds() {
22        
23        $pages = array(
24            'shop',
25            'cart',
26            'checkout',
27            'myaccount',
28            'refund_returns'
29        );
30        
31        array_walk( $pages, function ( &$page ) {
32            $page =  wc_get_page_id( $page );
33        });
34        
35        return array_filter( $pages, function ( $page ) {
36            return $page >= 1;
37        } );
38    }
39}