frostschutz / MyBB-Google-SEO

Search Engine Optimization plugin for MyBB.
https://community.mybb.com/thread-202483.html
GNU General Public License v3.0
30 stars 25 forks source link

[Request] Meta Tag Variable or Open Graph implantation #62

Open ErikThiart opened 6 years ago

ErikThiart commented 6 years ago

Hello, Ii added Open Graph tags to my forum in the headerinclude page, what I am looking for is a way to dynamically populate that open graph description tag like you do with the meta tag.

My question, do you have a variable that I can use/hook almost like:

<meta property="og:description" content="{{google-seo-desc}}" />

Alternatively, can you just build in Open Graph support?

frostschutz commented 6 years ago

There is no variable, unfortunately. You'd have to change code for that (meta.php).

I currently have no plans to support open graph, twitter cards, etc., they have a lot more options, it might be better to handle those in a separate addon.

ErikThiart commented 6 years ago

Thank you for the reply, I appreciate that.

Dammit, was hoping I can somehow hook into this:

function google_seo_meta_description($description)
{
    global $settings, $plugins, $google_seo_meta;
    if($settings['google_seo_meta_length'] > 0)
    {
        $description = strip_tags($description);
        $description = str_replace("&nbsp;", " ", $description);
        $description = preg_replace("/\\[[^\\]]+\\]/u", "", $description);
        $description = preg_replace("/\\s+/u", " ", $description);
        $description = trim($description);
        $description = my_substr($description, 0, $settings['google_seo_meta_length'], true);
        $description = trim($description);
        if($description)
        {
            $plugins->add_hook('pre_output_page', 'google_seo_meta_output');
            $google_seo_meta = "<meta name=\"description\" content=\"{$description}\" />\n{$google_seo_meta}";
        }
    }
}

What I currently did is add all the social meta tags on the site in the headerinclude I am able to dynamically populate the title for each meta tag, it's just the description that is missing a hook.

frostschutz commented 6 years ago

You can change that code:

$google_seo_meta = "<meta name=\"description\" content=\"{$description}\" />\n

to add another meta description tag using the same $description.

ErikThiart commented 6 years ago

Smart! Did not think of that... Might build all the Open Graph Tags into that variable...