Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

wp_seo_get_bc_title is deprecated #101

Closed
flowdee opened this issue Mar 11, 2018 · 13 comments
Closed

wp_seo_get_bc_title is deprecated #101

flowdee opened this issue Mar 11, 2018 · 13 comments
Labels
4.0.0 Subtitles 4.0.0 Release Target bug

Comments

@flowdee
Copy link

flowdee commented Mar 11, 2018

add_filter( 'wp_seo_get_bc_title', array( &$this, 'plugin_compat_wordpress_seo' ) );

Deprecated: wp_seo_get_bc_title
New: wpseo_breadcrumb_single_link_info

Would be great if you fix your plugin because it's throwing annoying PHP notices. Thanks ;)

@philiparthurmoore
Copy link
Member

@flowdee So sorry for not getting on this. We unhooked Subtitles from Slack and I'm playing cleanup right now. Let me roll out a fix for this and push a new version of the plugin tomorrow!

@philiparthurmoore
Copy link
Member

@flowdee Sorry for the late follow-up. Do you happen to have the specific PHP notice you're receiving and does it happen only when breadcrumbs in Yoast are turned on?

@flowdee
Copy link
Author

flowdee commented Apr 1, 2018

Yes it only happens with enabled breadcrumbs.

[01-Apr-2018 08:56:51 UTC] PHP Notice: wp_seo_get_bc_title is <strong>deprecated</strong> since version WPSEO 5.8! Use wpseo_breadcrumb_single_link_info instead. in /wp-includes/functions.php on line 4090

@philiparthurmoore
Copy link
Member

@flowdee Perfect, thank you. Working on adjustments today and tomorrow. This is top of the list.

@flowdee
Copy link
Author

flowdee commented Apr 1, 2018

Happy to hear 👍

Right now I'm using a hook in all of my projects to prevent deprecated notices from showing up but of course this is only a temporary solution 😄

@philiparthurmoore
Copy link
Member

philiparthurmoore commented Apr 1, 2018

Would you mind sharing your hook? I don't want to ruin your adjustments by pushing a wrong update to the plugin.

@flowdee
Copy link
Author

flowdee commented Apr 2, 2018

add_filter( 'deprecated_hook_trigger_error', '__return_false' );

But it's hiding all deprecated notices, not only from your plugin. That's why I don't want to use it forever but right now it's better than a bloated log file 😄

@philiparthurmoore
Copy link
Member

Thanks so much. I'll let you know when the fix is live. Should be any day now, definitely this week.

@philiparthurmoore philiparthurmoore added bug 4.0.0 Subtitles 4.0.0 Release Target needs patch labels Apr 7, 2018
@philiparthurmoore
Copy link
Member

@philiparthurmoore
Copy link
Member

@philiparthurmoore
Copy link
Member

@philiparthurmoore
Copy link
Member

Working undocumented pseudocode. Will tidy this up tomorrow.

add_filter( 'wpseo_breadcrumb_single_link_info', array( &$this, 'plugin_compat_wordpress_seo_new' ) );

public function plugin_compat_wordpress_seo_new( $breadcrumb_text ) {
	// check if in loop
	$in_the_loop = (bool) in_the_loop();
	if ( ! $in_the_loop ) {
		return $breadcrumb_text;
	}
	// subtitle
	$post_subtitle = get_the_subtitle(); // get subtitle
	$post_subtitle_length = (int) strlen( $post_subtitle ); // get subtitle length
	$post_subtitle_length_neg = -1 * $post_subtitle_length;
	// title
	$post_title = $breadcrumb_text['text']; // get post title
	$post_title_length = (int) strlen( $post_title ); // get post title length
	// remove subtitle from breadcrumb title
	if ( ( $post_title == $post_subtitle ) || ( '' == $post_title ) ) {
		return $breadcrumb_text;
	}
	$post_title = substr( $post_title, 0, $post_subtitle_length_neg );
	$post_title = apply_filters( 'compat_wordpress_seo', $post_title );
	$reconstructed_title = $post_title . $post_subtitle;
	if ( $reconstructed_title == $breadcrumb_text['text'] ) {
		$breadcrumb_text['text'] = $post_title;
		return $breadcrumb_text;
	}
	return $breadcrumb_text;
}

@philiparthurmoore
Copy link
Member

Noting that this will require a plugin version bump to 4.0.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4.0.0 Subtitles 4.0.0 Release Target bug
Projects
None yet
Development

No branches or pull requests

2 participants