is_pos

Test for POS requests to the server.

Description

is_pos( (bool) $type = false ); 

Parameters (1)

0. $type — Optional. (bool) => false
The type.

Usage

  1. if ( !function_exists( 'is_pos' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-pos/includes/wc-pos-functions.php'; 
  3.  
  4. // The type. 
  5. $type = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_pos($type); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-pos-functions.php  
  1. function is_pos( $type = false ) { 
  2.  
  3. // test for template requests, ie: matched rewrite rule 
  4. // also matches $_GET & $_POST for pos=1 
  5. if( $type == 'template' || !$type ) { 
  6. global $wp; 
  7. if( isset( $wp->query_vars['pos'] ) && $wp->query_vars['pos'] == 1 ) { 
  8. return true; 
  9.  
  10. // test for WC REST API requests, ie: matched request header 
  11. if( $type == 'ajax' || !$type ) { 
  12. if ( function_exists( 'getallheaders' ) 
  13. && is_array( getallheaders() ) 
  14. && array_key_exists( 'X-WC-POS', getallheaders() ) 
  15. ) { 
  16. return true; 
  17. } elseif ( isset( $_SERVER['HTTP_X_WC_POS'] ) && $_SERVER['HTTP_X_WC_POS'] == 1 ) { 
  18. return true; 
  19.  
  20. return false;