Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#6273 closed defect (bug) (worksforme)

global $wp_embed not working on custom post type activity...

Reported by: revolutionfrance's profile revolutionfrance Owned by:
Milestone: Priority: high
Severity: normal Version:
Component: Core Keywords: reporter-feedback
Cc:

Description

Hello, I am not in any way an expert at bp, but I am trying to get youtube embeds to work on my video custom post type in buddypress activity. I use the following code in my entry.php file:

<?php
		 //oEmbed video
		 $videotest = get_post_meta( $blogpost_id, '_kleo_embed', true );
		 		

		// oEmbed
		
			global $wp_embed;
			$post_embed = $wp_embed->run_shortcode('[embed]'.$videotest.'[/embed]');

			echo $post_embed; ?>

This works with the activity of a normal post, but not of my video custom post type. Is this a buddypress bug?

Change History (7)

#1 follow-up: @imath
9 years ago

  • Keywords reporter-feedback added

Hello,

I'm not sure it's a BuddyPress bug. I'm using $wp_embed for one of my plugin (BuddyDrive) and it's working fine. In this plugin, i'm using wp_embed_register_handler see https://github.com/imath/buddydrive/blob/master/includes/buddydrive-component.php#L316

What would be an example of the content of $videotest ? is it an url ?
Why do you need to use the WP_Embed->run_shortcode method ?

How the activity of your custom post type is generated ? using the post type activities introduced in 2.2 ? see https://codex.buddypress.org/plugindev/post-types-activities/

BuddyPress is using a specific class BP_Embed which extends WP_Embed and which is used in the different BuddyPress parts (activity entry, message entry...)

#2 @imath
9 years ago

  • Milestone changed from 2.2.2 to Awaiting Review

#3 @imath
9 years ago

This is an example with one plugin generating an activity in which i'm adding an url that will generate an embed code (BuddyDrive plugin)
https://farm9.staticflickr.com/8636/16075692483_639de3e28e_z.jpg

As you can see, it's working fine.

#4 in reply to: ↑ 1 @revolutionfrance
9 years ago

Hello, yes $videotest is a youtube url. The strange thing for me is that it works for normal posts, but not video custom post types. It seems like the iframe is being removed.

Do I still need to use wp_embed_register_handler if I am using embeds already handled by wordpress?

Yes, the custom post type activity is registered using the post types activities from 2.2. The code that I shared is from my entry.php file.

Sorry for using the trac for this, but I'm just not sure where the bug is, since the exact same code works for posts, but not video CPT, can't seem to get to the root of it. Which way would you recommend to try to embed in entry.php?

Funny we communicate in English although we're both French ;-)

#5 @imath
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Yes it's funny. But it's important we do so in order to let everybody understand this discussion :)

1/ I don't think you need the code you shared, and i'm not sure editing the entry.php is a good solution.
2/ you simply need to make sure the url is inside the post content

You should get this :
https://farm9.staticflickr.com/8678/16511073769_0e8570d346_z.jpg

4/ I'd say it's not a BuddyPress bug and i will close this ticket as 'worksforme'.

If you wish to carry on this discussion, i advise you to open a support topic on https://buddypress.org/support . You can add an @imath mention if you want me to bring you my support.

#6 @revolutionfrance
9 years ago

Ok, no worries, I'll fix it some other way. Just wanted to make sure this wasn't a buddypress bug. The entry.php is in a child theme :-)

Thanks for your help :-)

#7 @DJPaul
8 years ago

  • Component changed from API to Core
Note: See TracTickets for help on using tickets.