Skip to content

Commit

Permalink
Update a few SEO Framework deprecations (#59)
Browse files Browse the repository at this point in the history
* Update a few SEO Framework deprecations
Fixes Strategy11/awpcp#3160
  • Loading branch information
stephywells authored Mar 20, 2024
1 parent d938846 commit dcefdc9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Yes it is. However, you cannot "network-activate" the plugin (as this will share
* Security: Add more nonce and user role protection for uninstalling and other ajax functions.
* Update SelectWoo script version.
* Fix: Fallback to native dropdowns if there is a conflict with Select2.
* Fix: SEO Framework updatesfor outdated code.

= 4.3.1 =
* Security update against CSRF attacks in some admin pages. add CSRF tokens "nonce".
Expand Down
28 changes: 17 additions & 11 deletions includes/compatibility/class-seo-framework-plugin-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ class AWPCP_SEOFrameworkIntegration {
*/
private $request;

public $title_builder;

public $metadata;

public $is_singular;

public $attachment;

public function __construct( $listing_post_type, $query, $attachments, $request, $attachment_properties ) {
$this->listing_post_type = $listing_post_type;
$this->query = $query;
Expand All @@ -69,11 +77,11 @@ public function setup() {
*/
private function are_required_classes_loaded() {
if ( ! defined( 'THE_SEO_FRAMEWORK_VERSION' ) ) {
// Yoast SEO doesn't seem to be loaded. Bail.
// SEO plugin doesn't seem to be loaded. Bail.
return false;
}

return class_exists( 'The_SEO_Framework\Post_Data' );
return function_exists( 'tsf' );
}

/**
Expand All @@ -84,7 +92,6 @@ public function before_configure_frontend_meta( $meta ) {
$this->title_builder = $meta->title_builder;
$this->is_singular = is_singular( $this->listing_post_type );
$this->metadata = [];
$this->seo = the_seo_framework();

if ( $this->current_listing ) {
$this->metadata = $meta->get_listing_metadata();
Expand Down Expand Up @@ -162,8 +169,7 @@ public function configure_opengraph_meta_tags() {
* @since 4.1.0
*/
public function filter_document_title( $title ) {
$override = $this->seo->get_custom_field( '_genesis_title', $this->current_listing->ID );

$override = get_post_meta( $this->current_listing->ID, '_genesis_title', true );
if ( empty( $override ) ) {
return $this->build_title( $title );
}
Expand All @@ -189,7 +195,7 @@ private function build_title( $title ) {
* @since 4.1.0
*/
public function filter_listing_description( $description ) {
$override = $this->seo->get_custom_field( '_genesis_description', $this->current_listing->ID );
$override = get_post_meta( $this->current_listing->ID, '_genesis_description', true );

return $this->get_social_description( $description, $override );
}
Expand Down Expand Up @@ -225,7 +231,7 @@ public function filter_opengraph_type( $type ) {
* @since 4.1.0
*/
public function add_opengraph_images() {
$override = $this->seo->get_custom_field( '_social_image_url', $this->current_listing->ID );
$override = get_post_meta( $this->current_listing->ID, '_social_image_url', true );

if ( empty( $override ) ) {
$featured_image = $this->attachments->get_featured_attachment_of_type(
Expand All @@ -248,7 +254,7 @@ public function add_opengraph_images() {
* @since 4.1.0
*/
public function filter_opengraph_title( $title ) {
$override = $this->seo->get_custom_field( '_open_graph_title', $this->current_listing->ID );
$override = get_post_meta( $this->current_listing->ID, '_open_graph_title' );

return $this->get_social_title( $title, $override );
}
Expand Down Expand Up @@ -279,7 +285,7 @@ public function filter_opengraph_url() {
* @since 4.1.0
*/
public function filter_opengraph_description( $description ) {
$override = $this->seo->get_custom_field( '_open_graph_description', $this->current_listing->ID );
$override = get_post_meta( $this->current_listing->ID, '_open_graph_description' );

return $this->get_social_description( $description, $override );
}
Expand All @@ -288,7 +294,7 @@ public function filter_opengraph_description( $description ) {
* @since 4.1.0
*/
public function filter_twitter_title( $title ) {
$override = $this->seo->get_custom_field( '_twitter_title', $this->current_listing->ID );
$override = get_post_meta( $this->current_listing->ID, '_twitter_title' );

return $this->get_social_title( $title, $override );
}
Expand All @@ -297,7 +303,7 @@ public function filter_twitter_title( $title ) {
* @since 4.1.0
*/
public function filter_twitter_description( $description ) {
$override = $this->seo->get_custom_field( '_twitter_description', $this->current_listing->ID );
$override = get_post_meta( $this->current_listing->ID, '_twitter_description' );

return $this->get_social_description( $description, $override );
}
Expand Down

0 comments on commit dcefdc9

Please sign in to comment.