PluginProbe
Tiered Pricing Table for WooCommerce / 8.1.0
Tiered Pricing Table for WooCommerce v8.1.0
8.1.0 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 All 92 releases
← All changes | src/Integrations/Plugins/SEOPress/SEOPress.php +61 -40 6.5.0 → 8.1.0 View file →
@@ -1,16 +1,11 @@
1 1 <?php
2 2
3 3 namespace TierPricingTable\Integrations\Plugins\SEOPress;
4 4
5 -use TierPricingTable\Integrations\Plugins\PluginIntegrationAbstract;
6 -use TierPricingTable\Managers\FormatPriceManager;
7 -use TierPricingTable\PriceManager;
8 -use TierPricingTable\TierPricingTablePlugin;
5 +use TierPricingTable\Integrations\Plugins\SeoIntegrationAbstract;
9 6 use WC_Product;
10 -class SEOPress extends PluginIntegrationAbstract {
11 - protected $product = null;
12 -
7 +class SEOPress extends SeoIntegrationAbstract {
13 8 public function getTitle() : string {
14 9 return 'SEOPress';
15 10 }
16 11
@@ -21,8 +16,16 @@
21 16 public function getSlug() : string {
22 17 return 'seopress';
23 18 }
24 19
20 + protected function getSettingsPrefix() : string {
21 + return 'seopress';
22 + }
23 +
24 + protected function getSchemaFilterSlug() : string {
25 + return 'seopress';
26 + }
27 +
25 28 public function run() {
26 29 add_action( 'plugins_loaded', function () {
27 30 if ( !function_exists( 'seopress_init' ) ) {
28 31 return;
@@ -32,48 +35,66 @@
32 35 $sections[] = new Settings();
33 36 return $sections;
34 37 } );
35 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 + } );
36 89 }
37 90
38 - public function getIntegrationCategory() : string {
39 - return 'seo';
40 - }
41 -
42 91 public function getPrice( $type ) : ?string {
43 - $product = $this->get_product();
44 - if ( !$product ) {
45 - return '';
46 - }
47 - return FormatPriceManager::getFormattedPrice( $product, array(
48 - 'for_display' => true,
49 - 'with_suffix' => false,
50 - 'with_default_price' => true,
51 - 'with_lowest_prefix' => false,
52 - 'html' => false,
53 - 'display_type' => $type,
54 - ) );
92 + return $this->getFormattedProductPrice( $type, false );
55 93 }
56 94
57 95 public function getIconURL() : ?string {
58 96 // Make sure to add a seopress-icon.png/gif to your assets
59 97 return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/seopress-icon.gif' );
60 - }
61 -
62 - public function get_product() {
63 - if ( !is_null( $this->product ) ) {
64 - return $this->product;
65 - }
66 - $product_id = get_queried_object_id();
67 - $this->product = ( !function_exists( 'wc_get_product' ) || !$product_id || !is_admin() && !is_singular( 'product' ) ? null : wc_get_product( $product_id ) );
68 - return $this->product;
69 - }
70 -
71 - public function isVariablesEnabled() : bool {
72 - return $this->getContainer()->getSettings()->get( 'seopress_enable_variables', 'yes' ) === 'yes';
73 - }
74 -
75 - public function isEnhancedSchemaEnabled() : bool {
76 - return $this->getContainer()->getSettings()->get( 'seopress_enhance_schema', 'no' ) === 'yes';
77 98 }
78 99
79 100 }