| 1 |
<?php |
| 2 |
/** |
| 3 |
* Global helper functions for WCPOS. |
| 4 |
* |
| 5 |
* @author Paul Kilmurray <paul@kilbot.com> |
| 6 |
* |
| 7 |
* @see http://wcpos.com |
| 8 |
* @package WCPOS\WooCommercePOS |
| 9 |
*/ |
| 10 |
|
| 11 |
use WCPOS\WooCommercePOS\Admin\Permalink; |
| 12 |
use WCPOS\WooCommercePOS\Logger; |
| 13 |
use WCPOS\WooCommercePOS\Services\Settings; |
| 14 |
use WCPOS\WooCommercePOS\Template_Router; |
| 15 |
use const WCPOS\WooCommercePOS\PLUGIN_PATH; |
| 16 |
use const WCPOS\WooCommercePOS\SHORT_NAME; |
| 17 |
use const WCPOS\WooCommercePOS\VERSION; |
| 18 |
|
| 19 |
/* |
| 20 |
* ============================================================================ |
| 21 |
* WCPOS Functions |
| 22 |
* ============================================================================ |
| 23 |
* |
| 24 |
* Primary functions using the wcpos_ prefix. |
| 25 |
*/ |
| 26 |
|
| 27 |
/* |
| 28 |
* getallheaders() is an alias of apache_response_headers() |
| 29 |
* This function provides compatibility for nginx servers |
| 30 |
*/ |
| 31 |
if ( ! \function_exists( 'getallheaders' ) ) { |
| 32 |
/** |
| 33 |
* Polyfill for getallheaders() on nginx servers. |
| 34 |
* |
| 35 |
* @return array The request headers. |
| 36 |
*/ |
| 37 |
function getallheaders(): array { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- polyfill for missing PHP function. |
| 38 |
$headers = array(); |
| 39 |
foreach ( $_SERVER as $name => $value ) { |
| 40 |
// RFC2616 (HTTP/1.1) defines header fields as case-insensitive entities. |
| 41 |
if ( 'http_' == strtolower( substr( $name, 0, 5 ) ) ) { |
| 42 |
$headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
return $headers; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
/* |
| 51 |
* Resolve the URL scheme for POS permalinks. |
| 52 |
* |
| 53 |
* @return string|null 'https' when force_ssl is enabled, null for the home scheme. |
| 54 |
*/ |
| 55 |
if ( ! \function_exists( 'wcpos_url_scheme' ) ) { |
| 56 |
/** |
| 57 |
* Resolve the URL scheme for POS permalinks. |
| 58 |
* |
| 59 |
* See Settings::url_scheme() for the policy. |
| 60 |
* |
| 61 |
* @return string|null 'https' when force_ssl is enabled, null for the home scheme. |
| 62 |
*/ |
| 63 |
function wcpos_url_scheme(): ?string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 64 |
return Settings::instance()->url_scheme(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
/* |
| 69 |
* Construct the POS permalink. |
| 70 |
* |
| 71 |
* @param string $page Page slug. |
| 72 |
* @return string POS URL. |
| 73 |
*/ |
| 74 |
if ( ! \function_exists( 'wcpos_url' ) ) { |
| 75 |
/** |
| 76 |
* Construct the POS permalink. |
| 77 |
* |
| 78 |
* The trailing slash follows the site's permalink structure, via |
| 79 |
* user_trailingslashit(). |
| 80 |
* |
| 81 |
* @param string $page Page slug. |
| 82 |
* |
| 83 |
* @return string POS URL. |
| 84 |
*/ |
| 85 |
function wcpos_url( $page = '' ): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 86 |
$slug = Permalink::get_slug(); |
| 87 |
|
| 88 |
return home_url( user_trailingslashit( $slug . '/' . $page ), wcpos_url_scheme() ); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
/* |
| 93 |
* Construct a POS checkout permalink. |
| 94 |
* |
| 95 |
* @param string $path Path relative to the wcpos-checkout endpoint. |
| 96 |
* @return string POS checkout URL. |
| 97 |
*/ |
| 98 |
if ( ! \function_exists( 'wcpos_checkout_url' ) ) { |
| 99 |
/** |
| 100 |
* Construct a POS checkout permalink. |
| 101 |
* |
| 102 |
* Respects the force_ssl setting, like wcpos_url(), so checkout and receipt |
| 103 |
* links work when the site home URL is http but the POS is served over https, |
| 104 |
* eg: behind an SSL-terminating proxy. |
| 105 |
* |
| 106 |
* Like home_url(), this performs no encoding — pass trusted path segments |
| 107 |
* only and escape the result on output. |
| 108 |
* |
| 109 |
* The trailing slash follows the site's permalink structure, via |
| 110 |
* user_trailingslashit(). Slash-less URLs can trip origin rewrite rules |
| 111 |
* that force a trailing slash — some redirect to a hardcoded http:// |
| 112 |
* target, which the browser then blocks as mixed content. The slash is |
| 113 |
* appended to the end of the string, so $path must not contain a query |
| 114 |
* string or fragment; append query args to the returned URL instead. |
| 115 |
* |
| 116 |
* @param string $path Path relative to the wcpos-checkout endpoint, eg: 'order-pay/123'. |
| 117 |
* |
| 118 |
* @return string POS checkout URL. |
| 119 |
*/ |
| 120 |
function wcpos_checkout_url( $path = '' ): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 121 |
$full_path = Template_Router::CHECKOUT_PATH . '/' . ltrim( $path, '/' ); |
| 122 |
|
| 123 |
return home_url( user_trailingslashit( $full_path ), wcpos_url_scheme() ); |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
/* |
| 128 |
* Test for POS requests to the server. |
| 129 |
* |
| 130 |
* @param string $type Request type: 'query_var', 'header', or 'all'. |
| 131 |
* @return bool Whether this is a POS request. |
| 132 |
*/ |
| 133 |
if ( ! \function_exists( 'wcpos_request' ) ) { |
| 134 |
/** |
| 135 |
* Test for POS requests to the server. |
| 136 |
* |
| 137 |
* @param string $type Request type: 'query_var', 'header', or 'all'. |
| 138 |
* |
| 139 |
* @return bool Whether this is a POS request. |
| 140 |
*/ |
| 141 |
function wcpos_request( $type = 'all' ): bool { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 142 |
// check query_vars, eg: ?wcpos=1 or /pos rewrite rule. |
| 143 |
if ( 'all' == $type || 'query_var' == $type ) { |
| 144 |
global $wp; |
| 145 |
if ( 1 == isset( $wp->query_vars[ SHORT_NAME ] ) && $wp->query_vars[ SHORT_NAME ] ) { |
| 146 |
return true; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
// check headers, eg: from ajax request. |
| 151 |
if ( 'all' == $type || 'header' == $type ) { |
| 152 |
$headers = array_change_key_case( getallheaders() ); // convert headers to lowercase. |
| 153 |
if ( 1 == isset( $headers[ 'x-' . SHORT_NAME ] ) && $headers[ 'x-' . SHORT_NAME ] ) { |
| 154 |
return true; |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
return false; |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
/* |
| 163 |
* Check for POS admin requests. |
| 164 |
* |
| 165 |
* @return mixed Admin request header value or false. |
| 166 |
*/ |
| 167 |
if ( ! \function_exists( 'wcpos_admin_request' ) ) { |
| 168 |
/** |
| 169 |
* Check for POS admin requests. |
| 170 |
* |
| 171 |
* @return mixed Admin request header value or false. |
| 172 |
*/ |
| 173 |
function wcpos_admin_request() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 174 |
if ( \function_exists( 'getallheaders' ) ) { |
| 175 |
$headers = getallheaders(); |
| 176 |
if ( $headers && isset( $headers['X-WC-POS-ADMIN'] ) ) { |
| 177 |
return $headers['X-WC-POS-ADMIN']; |
| 178 |
} |
| 179 |
} |
| 180 |
if ( isset( $_SERVER['HTTP_X_woocommerce_pos_ADMIN'] ) ) { |
| 181 |
return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_woocommerce_pos_ADMIN'] ) ); |
| 182 |
} |
| 183 |
|
| 184 |
return false; |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
/* |
| 189 |
* Helper function to get WCPOS settings. |
| 190 |
* |
| 191 |
* @param string $id Settings ID. |
| 192 |
* @param string $key Optional settings key. |
| 193 |
* @return mixed Settings value. |
| 194 |
*/ |
| 195 |
if ( ! \function_exists( 'wcpos_get_settings' ) ) { |
| 196 |
/** |
| 197 |
* Helper function to get WCPOS settings. |
| 198 |
* |
| 199 |
* @param string $id Settings ID. |
| 200 |
* @param string $key Optional settings key. |
| 201 |
* |
| 202 |
* @return mixed Settings value. |
| 203 |
*/ |
| 204 |
function wcpos_get_settings( $id, $key = null ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 205 |
$settings_service = Settings::instance(); |
| 206 |
|
| 207 |
return $settings_service->get_settings( $id, $key ); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
/* |
| 212 |
* Simple wrapper for json_encode. |
| 213 |
* |
| 214 |
* Use JSON_FORCE_OBJECT for PHP 5.3 or higher with fallback for |
| 215 |
* PHP less than 5.3. |
| 216 |
* |
| 217 |
* @param mixed $data Data to encode. |
| 218 |
* @return string|false JSON string or false on failure. |
| 219 |
*/ |
| 220 |
if ( ! \function_exists( 'wcpos_json_encode' ) ) { |
| 221 |
/** |
| 222 |
* Simple wrapper for json_encode with JSON_FORCE_OBJECT. |
| 223 |
* |
| 224 |
* @param mixed $data Data to encode. |
| 225 |
* |
| 226 |
* @return string|false JSON string or false on failure. |
| 227 |
*/ |
| 228 |
function wcpos_json_encode( $data ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 229 |
$args = array( $data, JSON_FORCE_OBJECT ); |
| 230 |
|
| 231 |
return \call_user_func_array( 'json_encode', $args ); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
/* |
| 236 |
* Return template path for a given template. |
| 237 |
* |
| 238 |
* @param string $template Template name. |
| 239 |
* @return string|null Template path or null if not found. |
| 240 |
*/ |
| 241 |
if ( ! \function_exists( 'wcpos_locate_template' ) ) { |
| 242 |
/** |
| 243 |
* Return template path for a given template. |
| 244 |
* |
| 245 |
* @param string $template Template name. |
| 246 |
* |
| 247 |
* @return string|null Template path or null if not found. |
| 248 |
*/ |
| 249 |
function wcpos_locate_template( $template = '' ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 250 |
// check theme directory first. |
| 251 |
$path = locate_template( |
| 252 |
array( |
| 253 |
'woocommerce-pos/' . $template, |
| 254 |
) |
| 255 |
); |
| 256 |
|
| 257 |
// if not, use plugin template. |
| 258 |
if ( ! $path ) { |
| 259 |
$path = PLUGIN_PATH . 'templates/' . $template; |
| 260 |
} |
| 261 |
|
| 262 |
/** |
| 263 |
* Filters the template path. |
| 264 |
* |
| 265 |
* @hook woocommerce_pos_locate_template |
| 266 |
* |
| 267 |
* @since 1.0.0 |
| 268 |
* |
| 269 |
* @param string $path The full path to the template. |
| 270 |
* @param string $template The template name, eg: 'receipt.php'. |
| 271 |
* |
| 272 |
* @return string $path The full path to the template. |
| 273 |
*/ |
| 274 |
$filtered_path = apply_filters( 'woocommerce_pos_locate_template', $path, $template ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- legacy hook name. |
| 275 |
|
| 276 |
// Check if the filtered template file exists. |
| 277 |
if ( file_exists( $filtered_path ) ) { |
| 278 |
return $filtered_path; |
| 279 |
} |
| 280 |
|
| 281 |
// Echo a message or handle the error as needed if the file path does not exist. |
| 282 |
echo "The template file '" . esc_html( $filtered_path ) . "' does not exist."; |
| 283 |
|
| 284 |
return null; |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
/* |
| 289 |
* Remove newlines and code spacing. |
| 290 |
* |
| 291 |
* @param string $str HTML string to trim. |
| 292 |
* @return string Trimmed string. |
| 293 |
*/ |
| 294 |
if ( ! \function_exists( 'wcpos_trim_html_string' ) ) { |
| 295 |
/** |
| 296 |
* Remove newlines and code spacing from an HTML string. |
| 297 |
* |
| 298 |
* @param string $str HTML string to trim. |
| 299 |
* |
| 300 |
* @return string Trimmed string. |
| 301 |
*/ |
| 302 |
function wcpos_trim_html_string( $str ): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 303 |
return preg_replace( '/^\s+|\n|\r|\s+$/m', '', $str ); |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
/* |
| 308 |
* Get documentation URL. |
| 309 |
* |
| 310 |
* @param string $page Documentation page. |
| 311 |
* @return string Documentation URL. |
| 312 |
*/ |
| 313 |
if ( ! \function_exists( 'wcpos_doc_url' ) ) { |
| 314 |
/** |
| 315 |
* Get documentation URL. |
| 316 |
* |
| 317 |
* @param string $page Documentation page. |
| 318 |
* |
| 319 |
* @return string Documentation URL. |
| 320 |
*/ |
| 321 |
function wcpos_doc_url( $page ): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 322 |
return 'http://docs.wcpos.com/v/' . VERSION . '/en/' . $page; |
| 323 |
} |
| 324 |
} |
| 325 |
|
| 326 |
/* |
| 327 |
* Get FAQ URL. |
| 328 |
* |
| 329 |
* @param string $page FAQ page. |
| 330 |
* @return string FAQ URL. |
| 331 |
*/ |
| 332 |
if ( ! \function_exists( 'wcpos_faq_url' ) ) { |
| 333 |
/** |
| 334 |
* Get FAQ URL. |
| 335 |
* |
| 336 |
* @param string $page FAQ page. |
| 337 |
* |
| 338 |
* @return string FAQ URL. |
| 339 |
*/ |
| 340 |
function wcpos_faq_url( $page ): string { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 341 |
return 'http://faq.wcpos.com/v/' . VERSION . '/en/' . $page; |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
/* |
| 346 |
* Helper function to check whether an order is a POS order. |
| 347 |
* |
| 348 |
* @param \WC_Order|int $order Order object or ID. |
| 349 |
* @return bool Whether the order is a POS order. |
| 350 |
*/ |
| 351 |
if ( ! \function_exists( 'wcpos_is_pos_order' ) ) { |
| 352 |
/** |
| 353 |
* Helper function to check whether an order is a POS order. |
| 354 |
* |
| 355 |
* @param \WC_Order|int $order Order object or ID. |
| 356 |
* |
| 357 |
* @return bool Whether the order is a POS order. |
| 358 |
*/ |
| 359 |
function wcpos_is_pos_order( $order ): bool { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 360 |
// Handle various input types and edge cases. |
| 361 |
if ( ! $order instanceof WC_Order ) { |
| 362 |
// Sometimes the order is passed as an ID. |
| 363 |
if ( is_numeric( $order ) ) { |
| 364 |
$order = wc_get_order( $order ); |
| 365 |
} |
| 366 |
|
| 367 |
// If we still don't have a valid order, return false. |
| 368 |
if ( ! $order instanceof WC_Order ) { |
| 369 |
return false; |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
$legacy = $order->get_meta( '_pos', true ); |
| 374 |
$created_via = $order->get_created_via(); |
| 375 |
|
| 376 |
return 'woocommerce-pos' === $created_via || '1' === $legacy; |
| 377 |
} |
| 378 |
} |
| 379 |
|
| 380 |
/* |
| 381 |
* Get a default WooCommerce template. |
| 382 |
* |
| 383 |
* @param string $template_name Template name. |
| 384 |
* @param array $args Arguments. |
| 385 |
*/ |
| 386 |
if ( ! \function_exists( 'wcpos_get_woocommerce_template' ) ) { |
| 387 |
/** |
| 388 |
* Get a default WooCommerce template. |
| 389 |
* |
| 390 |
* @param string $template_name Template name. |
| 391 |
* @param array $args Arguments. |
| 392 |
*/ |
| 393 |
function wcpos_get_woocommerce_template( $template_name, $args = array() ): void { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- uses wcpos_ prefix. |
| 394 |
$plugin_path = WC()->plugin_path(); |
| 395 |
$template = trailingslashit( $plugin_path . '/templates' ) . $template_name; |
| 396 |
|
| 397 |
/** |
| 398 |
* Filter the default WooCommerce template path. |
| 399 |
* |
| 400 |
* @param string $template Template path. |
| 401 |
* @param string $template_name Template name. |
| 402 |
* @param array $args Arguments. |
| 403 |
*/ |
| 404 |
$template = apply_filters( 'wcpos_locate_woocommerce_template', $template, $template_name, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- uses wcpos_ prefix. |
| 405 |
|
| 406 |
if ( ! file_exists( $template ) ) { |
| 407 |
Logger::log( \sprintf( 'WooCommerce default template not found: %s', $template ) ); |
| 408 |
|
| 409 |
return; |
| 410 |
} |
| 411 |
|
| 412 |
if ( $args && \is_array( $args ) ) { |
| 413 |
extract( $args ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
| 414 |
} |
| 415 |
|
| 416 |
include $template; |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
/* |
| 421 |
* ============================================================================ |
| 422 |
* Legacy Aliases |
| 423 |
* ============================================================================ |
| 424 |
* |
| 425 |
* These functions use the old woocommerce_pos_ prefix. |
| 426 |
* They are kept for backwards compatibility but new code should use wcpos_ prefix. |
| 427 |
* |
| 428 |
* @deprecated Use wcpos_* functions instead. |
| 429 |
*/ |
| 430 |
|
| 431 |
if ( ! \function_exists( 'woocommerce_pos_url' ) ) { |
| 432 |
/** |
| 433 |
* Legacy alias for wcpos_url(). |
| 434 |
* |
| 435 |
* @deprecated Use wcpos_url() instead. |
| 436 |
* |
| 437 |
* @param mixed $page The page slug. |
| 438 |
*/ |
| 439 |
function woocommerce_pos_url( $page = '' ): string { |
| 440 |
return wcpos_url( $page ); |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
if ( ! \function_exists( 'woocommerce_pos_request' ) ) { |
| 445 |
/** |
| 446 |
* Legacy alias for wcpos_request(). |
| 447 |
* |
| 448 |
* @deprecated Use wcpos_request() instead. |
| 449 |
* |
| 450 |
* @param mixed $type The request type. |
| 451 |
*/ |
| 452 |
function woocommerce_pos_request( $type = 'all' ): bool { |
| 453 |
return wcpos_request( $type ); |
| 454 |
} |
| 455 |
} |
| 456 |
|
| 457 |
if ( ! \function_exists( 'woocommerce_pos_admin_request' ) ) { |
| 458 |
/** |
| 459 |
* Legacy alias for wcpos_admin_request(). |
| 460 |
* |
| 461 |
* @deprecated Use wcpos_admin_request() instead. |
| 462 |
*/ |
| 463 |
function woocommerce_pos_admin_request() { |
| 464 |
return wcpos_admin_request(); |
| 465 |
} |
| 466 |
} |
| 467 |
|
| 468 |
if ( ! \function_exists( 'woocommerce_pos_get_settings' ) ) { |
| 469 |
/** |
| 470 |
* Legacy alias for wcpos_get_settings(). |
| 471 |
* |
| 472 |
* @deprecated Use wcpos_get_settings() instead. |
| 473 |
* |
| 474 |
* @param mixed $id The settings ID. |
| 475 |
* @param null|mixed $key The settings key. |
| 476 |
*/ |
| 477 |
function woocommerce_pos_get_settings( $id, $key = null ) { |
| 478 |
return wcpos_get_settings( $id, $key ); |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
if ( ! \function_exists( 'woocommerce_pos_get_anon_id' ) ) { |
| 483 |
/** |
| 484 |
* Returns the anonymous analytics id (wcpos_anon_id), creating it on first use. |
| 485 |
* |
| 486 |
* Supported accessor for the Pro plugin's licence-activation request and the |
| 487 |
* wcpos.com purchase reconciler join (landing-experiments spec §5.3c). |
| 488 |
* |
| 489 |
* @return string v4 UUID. |
| 490 |
*/ |
| 491 |
function woocommerce_pos_get_anon_id(): string { |
| 492 |
return ( new \WCPOS\WooCommercePOS\Services\Anon_ID() )->get(); |
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
if ( ! \function_exists( 'woocommerce_pos_json_encode' ) ) { |
| 497 |
/** |
| 498 |
* Legacy alias for wcpos_json_encode(). |
| 499 |
* |
| 500 |
* @deprecated Use wcpos_json_encode() instead. |
| 501 |
* |
| 502 |
* @param mixed $data The data to encode. |
| 503 |
*/ |
| 504 |
function woocommerce_pos_json_encode( $data ) { |
| 505 |
return wcpos_json_encode( $data ); |
| 506 |
} |
| 507 |
} |
| 508 |
|
| 509 |
if ( ! \function_exists( 'woocommerce_pos_locate_template' ) ) { |
| 510 |
/** |
| 511 |
* Legacy alias for wcpos_locate_template(). |
| 512 |
* |
| 513 |
* @deprecated Use wcpos_locate_template() instead. |
| 514 |
* |
| 515 |
* @param mixed $template The template name. |
| 516 |
*/ |
| 517 |
function woocommerce_pos_locate_template( $template = '' ) { |
| 518 |
return wcpos_locate_template( $template ); |
| 519 |
} |
| 520 |
} |
| 521 |
|
| 522 |
if ( ! \function_exists( 'woocommerce_pos_trim_html_string' ) ) { |
| 523 |
/** |
| 524 |
* Legacy alias for wcpos_trim_html_string(). |
| 525 |
* |
| 526 |
* @deprecated Use wcpos_trim_html_string() instead. |
| 527 |
* |
| 528 |
* @param mixed $str The HTML string. |
| 529 |
*/ |
| 530 |
function woocommerce_pos_trim_html_string( $str ): string { |
| 531 |
return wcpos_trim_html_string( $str ); |
| 532 |
} |
| 533 |
} |
| 534 |
|
| 535 |
if ( ! \function_exists( 'woocommerce_pos_doc_url' ) ) { |
| 536 |
/** |
| 537 |
* Legacy alias for wcpos_doc_url(). |
| 538 |
* |
| 539 |
* @deprecated Use wcpos_doc_url() instead. |
| 540 |
* |
| 541 |
* @param mixed $page The documentation page. |
| 542 |
*/ |
| 543 |
function woocommerce_pos_doc_url( $page ): string { |
| 544 |
return wcpos_doc_url( $page ); |
| 545 |
} |
| 546 |
} |
| 547 |
|
| 548 |
if ( ! \function_exists( 'woocommerce_pos_faq_url' ) ) { |
| 549 |
/** |
| 550 |
* Legacy alias for wcpos_faq_url(). |
| 551 |
* |
| 552 |
* @deprecated Use wcpos_faq_url() instead. |
| 553 |
* |
| 554 |
* @param mixed $page The FAQ page. |
| 555 |
*/ |
| 556 |
function woocommerce_pos_faq_url( $page ): string { |
| 557 |
return wcpos_faq_url( $page ); |
| 558 |
} |
| 559 |
} |
| 560 |
|
| 561 |
if ( ! \function_exists( 'woocommerce_pos_is_pos_order' ) ) { |
| 562 |
/** |
| 563 |
* Legacy alias for wcpos_is_pos_order(). |
| 564 |
* |
| 565 |
* @deprecated Use wcpos_is_pos_order() instead. |
| 566 |
* |
| 567 |
* @param mixed $order The order object or ID. |
| 568 |
*/ |
| 569 |
function woocommerce_pos_is_pos_order( $order ): bool { |
| 570 |
return wcpos_is_pos_order( $order ); |
| 571 |
} |
| 572 |
} |
| 573 |
|