• Resolved pxmkosh

    (@pxmkosh)


    Hi
    After upgrading to 5.x my code seems not to work anymore. I already changed the code based on the deprecation notices but still not working. Can you maybe help me with that?

    if (class_exists('\The_SEO_Framework\Admin\SEOBar\Builder')) {
    $postType = get_post_type($postId);
    $tsf = tsf();
    if ($tsf->post_type($postType)->is_supported()) {
    $seobar = new \The_SEO_Framework\Admin\SEOBar\Builder;
    $bar = $seobar->generate_bar([
    'id' => $postId,
    'post_type' => $postType,
    ]);
    $title .= $bar;
    }
    }


    The problem seems to happen in the 2nd if statement: $tsf->post_type($postType)->is_supported() returns false all the time.

    Thank you if you can help me solve this issue ??

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Please do not use class_exists() without setting the second parameter to false. It will crash when the class structure changes because it invokes autoloaders. See https://www.php.net/manual/en/function.class-exists.php.

    I recommend using function_exists( 'tsf' ) instead.

    But, more specifically, I never made the class you mentioned public. If you look closely at that file, it’ll say “@access private” at the top — this is PHPDoc for “do not document this to the public; it’s for internal use only.” I’ve accidentally marked it as a replacement for The_SEO_Framework\Interpreters\SEOBar.

    But that class was marked “protected” already (same as “private,” but a public API elsewhere exists). The old method tsf()->get_generated_seo_bar(), which is a gateway to that protected class, was deprecated with no alternatives available.

    I deprecated it because I did not expect anyone to output the SEO Bar outside of TSF’s interface. Moreover, consistently loading all styles and scripts for it is complex, and its query API may run into issues.

    There’s currently no good way to output the SEO Bar programmatically. You could use \The_SEO_Framework\Admin\SEOBar\Builder::generate_bar( $args ), but that may cause autoloader issues in the future.

    Is there any reason you need to output the SEO Bar? Would it be something I could integrate natively, or where you could benefit from API changes? Let me know, and I’ll see what I can do to make the API future-proof.

    As for the is_supported() part, tsf()->post_type() is a pool method and doesn’t accept parameters. Instead, please use tsf()->post_type()->is_supported( $post_type );.

Viewing 1 replies (of 1 total)
  • The topic ‘$tsf->post_type not working after 5.x’ is closed to new replies.