| 1 |
<?php |
| 2 |
|
| 3 |
namespace TierPricingTable\Integrations\Plugins\Yoast; |
| 4 |
|
| 5 |
use TierPricingTable\Integrations\Plugins\PluginIntegrationAbstract; |
| 6 |
use TierPricingTable\Managers\FormatPriceManager; |
| 7 |
use TierPricingTable\PriceManager; |
| 8 |
use TierPricingTable\TierPricingTablePlugin; |
| 9 |
use WC_Product; |
| 10 |
class Yoast extends PluginIntegrationAbstract { |
| 11 |
protected $product = null; |
| 12 |
|
| 13 |
public function getTitle() : string { |
| 14 |
return 'Yoast SEO'; |
| 15 |
} |
| 16 |
|
| 17 |
public function getDescription() : string { |
| 18 |
return __( 'Adds <b>%%lowest_price%%</b> and <b>%%price_range%%</b> variables to display the lowest and price range of products with tiered pricing.', 'tier-pricing-table' ); |
| 19 |
} |
| 20 |
|
| 21 |
public function getSlug() : string { |
| 22 |
return 'yoast-seo'; |
| 23 |
} |
| 24 |
|
| 25 |
public function run() { |
| 26 |
add_action( 'plugins_loaded', function () { |
| 27 |
if ( !class_exists( 'WPSEO_Options' ) ) { |
| 28 |
return; |
| 29 |
} |
| 30 |
add_filter( 'tiered_pricing_table/settings/sections', function ( $sections ) { |
| 31 |
$sections[] = new Settings(); |
| 32 |
return $sections; |
| 33 |
} ); |
| 34 |
} ); |
| 35 |
} |
| 36 |
|
| 37 |
public function getIntegrationCategory() : string { |
| 38 |
return 'seo'; |
| 39 |
} |
| 40 |
|
| 41 |
public function getIconURL() : ?string { |
| 42 |
return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/yoast-icon.gif' ); |
| 43 |
} |
| 44 |
|
| 45 |
public function get_product() { |
| 46 |
if ( !is_null( $this->product ) ) { |
| 47 |
return $this->product; |
| 48 |
} |
| 49 |
$product_id = get_queried_object_id(); |
| 50 |
$this->product = ( !function_exists( 'wc_get_product' ) || !$product_id || !is_admin() && !is_singular( 'product' ) ? null : wc_get_product( $product_id ) ); |
| 51 |
return $this->product; |
| 52 |
} |
| 53 |
|
| 54 |
public function isVariablesEnabled() : bool { |
| 55 |
return $this->getContainer()->getSettings()->get( 'yoast_enable_variables', 'yes' ) === 'yes'; |
| 56 |
} |
| 57 |
|
| 58 |
public function isEnhancedSchemaEnabled() : bool { |
| 59 |
return $this->getContainer()->getSettings()->get( 'yoast_enhance_schema', 'no' ) === 'yes'; |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
|