Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
  1 <?php
  2 /**
  3  *
  4  *
  5  * @class    WC_POS_Status
  6  * @package  WooCommerce POS
  7  * @author   Paul Kilmurray <paul@kilbot.com.au>
  8  * @link     http://www.woopos.com.au
  9  */
 10 
 11 namespace WC_POS;
 12 
 13 class Status {
 14 
 15   public function output() {
 16     $results = array(
 17       $this->test_wc_version(),
 18       $this->test_php_version(),
 19       $this->test_wc_rest_api()
 20     );
 21     return $results;
 22   }
 23 
 24   /**
 25    * Test WC >= $wc_min_version
 26    * @return boolean
 27    */
 28   private function test_wc_version() {
 29     $result = array(
 30       'title'   => __( 'WC Version', 'woocommerce-pos' ),
 31       'pass'    => version_compare( WC()->version, Activator::WC_MIN_VERSION, '>=' ),
 32       'message' => esc_html( WC()->version )
 33     );
 34 
 35     if( ! $result['pass'] ){
 36       $result = array_merge( $result, array(
 37         'message' => sprintf( __( 'WooCommerce >= %s required', 'woocommerce-pos' ), Activator::WC_MIN_VERSION),
 38         'buttons' => array(
 39           array(
 40             'href'  => admin_url( 'update-core.php' ),
 41             /* translators: wordpress */
 42             'prompt'  => __( 'Update' )
 43           )
 44         )
 45       ));
 46     }
 47 
 48     return $result;
 49   }
 50 
 51   /**
 52    * Test PHP >= $php_min_version
 53    * @return boolean
 54    */
 55   private function test_php_version() {
 56     if( ! function_exists('phpversion') )
 57       return;
 58 
 59     $php_version = phpversion();
 60 
 61     $result = array(
 62       'title'   => /* translators: woocommerce */ __( 'PHP Version', 'woocommerce' ),
 63       'pass'    => version_compare( $php_version, Activator::PHP_MIN_VERSION, '>' ),
 64       'message' => esc_html( $php_version )
 65     );
 66 
 67     if( ! $result['pass'] ){
 68       $result = array_merge( $result, array(
 69         'message' => sprintf( __( 'PHP >= %s required', 'woocommerce-pos' ), Activator::PHP_MIN_VERSION ),
 70         'buttons' => array(
 71           array(
 72             'href'  => 'http://docs.woothemes.com/document/how-to-update-your-php-version/',
 73             /* translators: wordpress */
 74             'prompt'  => __( 'Update' )
 75           )
 76         )
 77       ));
 78     }
 79 
 80     return $result;
 81   }
 82 
 83   /**
 84    * Test WC REST API is accessible using RESTful HTTP methods
 85    * @return array
 86    */
 87   private function test_wc_rest_api() {
 88     $result = array(
 89       'pass'    => true,
 90       'title'   => __( 'WC REST API', 'woocommerce-pos' ),
 91       'message' => __( 'API is active', 'woocommerce-pos' )
 92     );
 93 
 94     if( $fail = self::permalinks_disabled() )
 95       return array_merge( $result, $fail );
 96 
 97     if( $fail = self::wc_rest_api_disabled() )
 98       return array_merge( $result, $fail );
 99 
100     return $result;
101   }
102 
103   /**
104    * Option for to emulate RESTful HTTP requests
105    */
106   static public function toggle_legacy_server(){
107     if( isset($_GET['enable']) && $_GET['enable'] === 'true' ) {
108       update_option( 'woocommerce_pos_emulateHTTP', true );
109     } else {
110       delete_option( 'woocommerce_pos_emulateHTTP' );
111     }
112   }
113 
114   /**
115    * @return array
116    */
117   static public function wc_rest_api_disabled(){
118     if( get_option('woocommerce_api_enabled') !== 'yes' ) {
119 
120       // api settings changes in WC 2.4
121       $href = admin_url('admin.php?page=wc-settings');
122       if( version_compare( WC()->version, '2.4', '>=' ) ){
123         $href .= '&tab=api';
124       }
125 
126       return array(
127         'pass' => false,
128         'message' => __('Access to the REST API is required', 'woocommerce-pos'),
129         'buttons' => array(
130           array(
131             'href' => $href,
132             /* translators: woocommerce */
133             'prompt' => __('Enable the REST API', 'woocommerce')
134           )
135         )
136       );
137     }
138   }
139 
140   /**
141    * @return array
142    */
143   static public function permalinks_disabled(){
144     $permalinks = get_option('permalink_structure');
145     if( empty( $permalinks ) ) {
146       return array(
147         'pass'    => false,
148         'message' => __( '<strong>WooCommerce REST API</strong> requires <em>pretty</em> permalinks to work correctly', 'woocommerce-pos' ),
149         'buttons' => array(
150           array(
151             'href'  => admin_url('options-permalink.php'),
152             'prompt'  => __( 'Enable permalinks', 'woocommerce-pos' )
153           )
154         )
155       );
156     }
157   }
158 
159 }
API documentation generated by ApiGen