| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO. |
| 4 |
* |
| 5 |
* @package WCPOS\WooCommercePOS |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WCPOS\WooCommercePOS\Integrations; |
| 9 |
|
| 10 |
/** |
| 11 |
* Yoast SEO Integration |
| 12 |
*/ |
| 13 |
class WPSEO { |
| 14 |
/** |
| 15 |
* Constructor. |
| 16 |
*/ |
| 17 |
public function __construct() { |
| 18 |
add_filter( 'option_wpseo', array( $this, 'remove_wpseo_rest_api_links' ), 10, 1 ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Yoast SEO adds SEO to the WC REST API by default, this adds to the download weight and can cause problems. |
| 23 |
* It is programmatically turned off here for POS requests. |
| 24 |
* This gets loaded and cached before the rest_api init hook, so we can't use the filter. |
| 25 |
* |
| 26 |
* QUESTION: How long is the WPSEO_Options cache persisted? |
| 27 |
* |
| 28 |
* @param array $wpseo_options The WPSEO options array. |
| 29 |
*/ |
| 30 |
public function remove_wpseo_rest_api_links( $wpseo_options ) { |
| 31 |
$wpseo_options['remove_rest_api_links'] = false; // needed for WC API discovery. |
| 32 |
|
| 33 |
if ( woocommerce_pos_request() ) { |
| 34 |
$wpseo_options['remove_rest_api_links'] = true; |
| 35 |
$wpseo_options['enable_headless_rest_endpoints'] = false; |
| 36 |
return $wpseo_options; |
| 37 |
} |
| 38 |
|
| 39 |
return $wpseo_options; |
| 40 |
} |
| 41 |
} |
| 42 |
|