| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Integrations\Front_End; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Front_End_Conditional; |
| 6 |
use Yoast\WP\SEO\Helpers\Options_Helper; |
| 7 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 8 |
|
| 9 |
/** |
| 10 |
* Adds actions that were previously called and are now deprecated. |
| 11 |
*/ |
| 12 |
class Backwards_Compatibility implements Integration_Interface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Represents the options helper. |
| 16 |
* |
| 17 |
* @var Options_Helper |
| 18 |
*/ |
| 19 |
protected $options; |
| 20 |
|
| 21 |
/** |
| 22 |
* Returns the conditionals based in which this loadable should be active. |
| 23 |
* |
| 24 |
* @return array |
| 25 |
*/ |
| 26 |
public static function get_conditionals() { |
| 27 |
return [ Front_End_Conditional::class ]; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Backwards_Compatibility constructor |
| 32 |
* |
| 33 |
* @param Options_Helper $options The options helper. |
| 34 |
*/ |
| 35 |
public function __construct( Options_Helper $options ) { |
| 36 |
$this->options = $options; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Initializes the integration. |
| 41 |
* |
| 42 |
* This is the place to register hooks and filters. |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
public function register_hooks() { |
| 47 |
if ( $this->options->get( 'opengraph' ) === true ) { |
| 48 |
\add_action( 'wpseo_head', [ $this, 'call_wpseo_opengraph' ], 30 ); |
| 49 |
} |
| 50 |
if ( $this->options->get( 'twitter' ) === true && \apply_filters( 'wpseo_output_twitter_card', true ) !== false ) { |
| 51 |
\add_action( 'wpseo_head', [ $this, 'call_wpseo_twitter' ], 40 ); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Calls the old wpseo_opengraph action. |
| 57 |
* |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
public function call_wpseo_opengraph() { |
| 61 |
\do_action_deprecated( 'wpseo_opengraph', [], '14.0', 'wpseo_frontend_presenters' ); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Calls the old wpseo_twitter action. |
| 66 |
* |
| 67 |
* @return void |
| 68 |
*/ |
| 69 |
public function call_wpseo_twitter() { |
| 70 |
\do_action_deprecated( 'wpseo_twitter', [], '14.0', 'wpseo_frontend_presenters' ); |
| 71 |
} |
| 72 |
} |
| 73 |
|