PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
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 / SEOPress / SEOPress.php

SEOPress.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Integrations/Plugins/SEOPress/SEOPress.php

101 lines 3.7 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\SEOPress;
4
5 use TierPricingTable\Integrations\Plugins\SeoIntegrationAbstract;
6 use WC_Product;
7 class SEOPress extends SeoIntegrationAbstract {
8 public function getTitle() : string {
9 return 'SEOPress';
10 }
11
12 public function getDescription() : string {
13 return __( 'Add tiered pricing data to SEOPress 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 'seopress';
18 }
19
20 protected function getSettingsPrefix() : string {
21 return 'seopress';
22 }
23
24 protected function getSchemaFilterSlug() : string {
25 return 'seopress';
26 }
27
28 public function run() {
29 add_action( 'plugins_loaded', function () {
30 if ( !function_exists( 'seopress_init' ) ) {
31 return;
32 }
33 add_filter( 'tiered_pricing_table/settings/sections', function ( $sections ) {
34 // Ensure you create a corresponding Settings class for SEOPress in this namespace
35 $sections[] = new Settings();
36 return $sections;
37 } );
38 } );
39 return;
40 add_filter( 'seopress_titles_template_replace_array', function ( $replace ) {
41 if ( !$this->isVariablesEnabled() ) {
42 return $replace;
43 }
44 $replace['%%lowest_price%%'] = $this->getPrice( 'lowest_price' );
45 $replace['%%price_range%%'] = $this->getPrice( 'range' );
46 return $replace;
47 } );
48 add_filter( 'seopress_titles_template_variables_array', function ( $variables ) {
49 if ( !$this->isVariablesEnabled() ) {
50 return $variables;
51 }
52 $variables[] = "%%lowest_price%%";
53 $variables[] = "%%price_range%%";
54 return $variables;
55 } );
56 add_filter( 'seopress_get_dynamic_variables', function ( $variables ) {
57 $variables['%%lowest_price%%'] = 'Lowest Price';
58 $variables['%%price_range%%'] = 'Price Range';
59 return $variables;
60 } );
61 add_filter( 'seopress_tags_available', function ( $tags ) {
62 // Register Lowest Price
63 $tags['lowest_price'] = [
64 'class' => SEOPressLowestPriceTag::class,
65 'name' => __( 'Lowest Price', 'tier-pricig-table' ),
66 'description' => SEOPressLowestPriceTag::getDescription(),
67 'input' => '%%lowest_price%%',
68 ];
69 // Register Price Range
70 $tags['price_range'] = [
71 'class' => SEOPressPriceRangeTag::class,
72 'name' => __( 'Price Range', 'seopress' ),
73 'description' => SEOPressPriceRangeTag::getDescription(),
74 'input' => '%%price_range%%',
75 ];
76 return $tags;
77 } );
78 // SEOPress Schema Integration
79 add_filter( 'seopress_structured_data_product', function ( $data ) {
80 if ( !is_product() || !is_array( $data ) ) {
81 return $data;
82 }
83 global $product;
84 if ( !$this->isEnhancedSchemaEnabled() || !$product instanceof WC_Product ) {
85 return $data;
86 }
87 return $this->enhanceProductSchema( $data, $product );
88 } );
89 }
90
91 public function getPrice( $type ) : ?string {
92 return $this->getFormattedProductPrice( $type, false );
93 }
94
95 public function getIconURL() : ?string {
96 // Make sure to add a seopress-icon.png/gif to your assets
97 return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/seopress-icon.gif' );
98 }
99
100 }
101