Notifications
Clear all

[Closed] Want to share forum posts in regular WordPress blog, but links default to forum page

6 Posts
2 Users
0 Likes
2,177 Views
Posts: 24
Topic starter
(@davidborrink)
Eminent Member
Joined: 6 years ago

We're using an older plug-in to allow oEmbeds in regular WordPress comments. It works fine for almost any kind of link, but when used with Forum posts, the embed only goes to the Main Forum link and shows a default graphic. The URL of the forum post remains in the backend code of the comment, but the plug-in changes it to the home page of the forum. I found a newer plug-in to try and improve the functions so that a Forum post could show up, and this newer (and still updated) plug-in allows embeds anywhere on a site. It did the same thing, showing the forum post as a home-page link. 

Is there something about the way WPForo is set up that conflicts with the capabilities of these plug-ins? All other content can be embedded easily. Just WPForo content gives us this issue. If we turn off the plug-ins, the original URLs show up, and the actual URL of a WP Foro post shows up as a hyperlink.

Topic Tags
5 Replies
Posts: 24
Topic starter
(@davidborrink)
Eminent Member
Joined: 6 years ago

Here is the code of the older plug-in for reference. By seeing how it works with the code, perhaps someone might see why this plug-in doesn't handle WPForo post links.

<?php

/*
Plugin Name: oEmbed in Comments
Description: Allow oEmbeds in comment text
Version: 1.1.2
Author: Evan Solomon
Author URI:  http://evansolomon.me 
*/

class ES_oEmbed_Comments {

	function __construct() {
		add_action( 'init', array( $this, 'init' ) );
	}

	function init() {
		if ( is_admin() )
			return;

		$this->add_filter();
	}

	/**
	 * Setup filter with correct priority to do oEmbed in comments
	 */
	function add_filter() {
		// make_clickable breaks oEmbed regex, make sure we go earlier
		$clickable = has_filter( 'get_comment_text', 'make_clickable' );
		$priority = ( $clickable ) ? $clickable - 1 : 10;

		add_filter( 'get_comment_text', array( $this, 'oembed_filter' ), $priority );
	}

	/**
	 * Safely add oEmbed media to a comment
	 */
	function oembed_filter( $comment_text ) {
		global $wp_embed;

		// Automatic discovery would be a security risk, safety first
		add_filter( 'embed_oembed_discover', '__return_false', 999 );
		$comment_text = $wp_embed->autoembed( $comment_text );

		// ...but don't break your posts if you use it
		remove_filter( 'embed_oembed_discover', '__return_false', 999 );

		return $comment_text;
	}
}

new ES_oEmbed_Comments;
4 Replies
Robert
Admin
(@robert)
Joined: 8 years ago

Support Team
Posts: 10499

@davidborrink,

wpForo topics and posts are not WordPress custom post types. I think the plugin tries to embed certain page, but all wpForo topics and posts are loaded in a one page, in the forum page. So it always tries to embed the same page.

(@davidborrink)
Joined: 6 years ago

Eminent Member
Posts: 24

@robert

Thanks for replying. So though a wpForo topic and post are not officially a WordPress custom post type, their true URL shows up in the browser address bar when a wpForo topic or post is shown on a page. I'm wondering why the post portion of the forum URL gets stripped out when the embedding plug-in takes over. I mentioned that when the embed-in-comments plug-in is turned off, the full URL does appear as a hyperlink within comments. I have no problem with a default image being shown, but it would be nice if the full link could be active, not just a default forum front page link. The problem is that in order to share those links in a regular WordPress post, we have to turn off the embeds plug-in and only show links as hyperlinks, no matter where they're from.

Robert
Admin
(@robert)
Joined: 8 years ago

Support Team
Posts: 10499

@davidborrink,

I think the problem in your embed plugin. wpForo URLs are solid and work everywhere.

(@davidborrink)
Joined: 6 years ago

Eminent Member
Posts: 24

@robert Well, I actually went and pasted a forum link in two different sites I run and found that the embed was being reduced to the forum home page. These are not comment-based embeds but are in normal WordPress posts.

The forum post embed is this: https://sallieborrink.com/community/simple-living/switching-to-a-flip-phone-or-dumb-phone/

Here are the links to the two tests, and in both of these cases this is the WordPress default embedding:

https://davidandsallie.com/testing/

https://davidborrink.com/test/  - in this one I placed a regular WordPress post first, then the forum item. You can see the regular embed works but the forum post does not.

Again, this is without the embed plugins installed on these sites. Also, you'll see that the image of the post/default page actually looks like a mobile site with a header/menu burger/featured image and it goes out of the content area but into the comments space.