PluginProbe
Tiered Pricing Table for WooCommerce / 7.1.7
Tiered Pricing Table for WooCommerce v7.1.7
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
tier-pricing-table / src / Integrations / Plugins / Yoast / Yoast.php

Yoast.php in Tiered Pricing Table for WooCommerce 7.1.7, at src/Integrations/Plugins/Yoast/Yoast.php

72 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TierPricingTable\Integrations\Plugins\Yoast;
4
5 use TierPricingTable\Integrations\Plugins\SeoIntegrationAbstract;
6 use WC_Product;
7 class Yoast extends SeoIntegrationAbstract {
8 public function getTitle() : string {
9 return 'Yoast SEO';
10 }
11
12 public function getDescription() : string {
13 return __( 'Add tiered pricing data to the Yoast product schema and introduce <b>%%lowest_price%%</b> and <b>%%price_range%%</b> variables for SEO.', 'tier-pricing-table' );
14 }
15
16 public function getSlug() : string {
17 return 'yoast-seo';
18 }
19
20 protected function getSettingsPrefix() : string {
21 return 'yoast';
22 }
23
24 protected function getSchemaFilterSlug() : string {
25 return 'yoast_seo';
26 }
27
28 public function run() {
29 add_action( 'plugins_loaded', function () {
30 if ( !class_exists( 'WPSEO_Options' ) ) {
31 return;
32 }
33 add_filter( 'tiered_pricing_table/settings/sections', function ( $sections ) {
34 $sections[] = new Settings();
35 return $sections;
36 } );
37 } );
38 return;
39 add_filter(
40 'wpseo_replacements',
41 function ( $replacements ) {
42 if ( !$this->isVariablesEnabled() ) {
43 return $replacements;
44 }
45 if ( !$this->get_product() ) {
46 return $replacements;
47 }
48 $replacements['%%lowest_price%%'] = $this->getFormattedProductPrice( 'lowest_price' );
49 $replacements['%%price_range%%'] = $this->getFormattedProductPrice( 'range' );
50 return $replacements;
51 },
52 10,
53 2
54 );
55 add_filter( 'wpseo_schema_product', function ( $data ) {
56 if ( !is_product() || !is_array( $data ) ) {
57 return $data;
58 }
59 global $product;
60 if ( !$this->isEnhancedSchemaEnabled() || !$product instanceof WC_Product ) {
61 return $data;
62 }
63 return $this->enhanceProductSchema( $data, $product );
64 } );
65 }
66
67 public function getIconURL() : ?string {
68 return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/yoast-icon.gif' );
69 }
70
71 }
72