diff --git src/bp-activity/bp-activity-embeds.php src/bp-activity/bp-activity-embeds.php
index 31a4e02..f55ab4c 100644
|
|
defined( 'ABSPATH' ) || exit; |
19 | 19 | * @since 2.5.0 |
20 | 20 | */ |
21 | 21 | function bp_activity_setup_oembed() { |
22 | | if ( bp_get_major_wp_version() >= 4.4 && bp_is_active( 'activity', 'embeds' ) ) { |
| 22 | if ( function_exists( 'wp_oembed_register_route' ) && bp_is_active( 'activity', 'embeds' ) ) { |
23 | 23 | buddypress()->activity->oembed = new BP_Activity_oEmbed_Component; |
24 | 24 | } |
25 | 25 | } |
… |
… |
function bp_activity_embed_excerpt( $content = '' ) { |
50 | 50 | * bp_activity_truncate_entry() includes the 'Read More' link, which is why |
51 | 51 | * we're using this instead of bp_create_excerpt(). |
52 | 52 | */ |
53 | | $content = html_entity_decode( $content ); |
54 | | $content = bp_activity_truncate_entry( $content, array( |
55 | | 'html' => false, |
| 53 | $excerpt = bp_activity_truncate_entry( html_entity_decode( $content ), array( |
| 54 | 'html' => false, |
56 | 55 | 'filter_shortcodes' => true, |
57 | 56 | 'strip_tags' => true, |
58 | | 'force_truncate' => true |
| 57 | 'force_truncate' => true, |
| 58 | 'remove_links' => true, |
59 | 59 | ) ); |
60 | 60 | |
61 | | // Remove links from content. |
62 | | $content = preg_replace( '#^\s*(https?://[^\s"]+)\s*$#im', '', $content ); |
| 61 | // Temporarly remove this filter as we already truncated the entry. |
| 62 | remove_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry' ); |
63 | 63 | |
64 | | return $content; |
65 | | } |
66 | | |
67 | | /** |
68 | | * Outputs the first embedded item in the activity oEmbed template. |
69 | | * |
70 | | * @since 2.5.0 |
71 | | */ |
72 | | function bp_activity_embed_response_display_media() { |
73 | | // Bail if oEmbed request explicitly hides media. |
74 | | if ( isset( $_REQUEST['hide_media'] ) && true == wp_validate_boolean( $_REQUEST['hide_media'] ) ) { |
75 | | return; |
76 | | } |
77 | | |
78 | | // Find all embeds for the activity item. |
79 | | $embeds = bp_core_extract_media_from_content( $GLOBALS['activities_template']->activity->content, 'embeds' ); |
80 | | |
81 | | /** |
82 | | * Should we display media in the oEmbed template? |
83 | | * |
84 | | * @since 2.5.0 |
85 | | * |
86 | | * @param bool $retval Defaults to true. |
87 | | */ |
88 | | $allow_embeds = apply_filters( 'bp_activity_embed_display_media', true ); |
89 | | |
90 | | // Only embed the first embedded item. |
91 | | if ( $embeds && $allow_embeds ) { |
92 | | $content = apply_filters( 'bp_get_activity_content_body', $embeds['embeds'][0]['url'] ); |
93 | | echo $content; |
| 64 | // Apply all the other filters to the content. |
| 65 | $excerpt = apply_filters( 'bp_get_activity_content_body', $excerpt ); |
94 | 66 | |
95 | | if ( false !== strpos( $content, '<iframe' ) ) { |
96 | | ?> |
| 67 | // Restore the filter. |
| 68 | add_filter( 'bp_get_activity_content_body', 'bp_activity_truncate_entry' ); |
97 | 69 | |
98 | | <script> |
99 | | /*! fluidvids.js v1.2.0 | (c) 2013 @toddmotto | https://github.com/toddmotto/fluidvids */ |
100 | | window.fluidvids=function(a,b){"use strict";var c=function(a){this.elem=a};c.prototype={init:function(){var a=100*(this.elem.height/this.elem.width);this.elem.style.position="absolute",this.elem.style.top="0",this.elem.style.left="0",this.elem.width="100%",this.elem.height="100%";var c=b.createElement("div");c.className="fluidvids",c.style.width="100%",c.style.position="relative",c.style.paddingTop=a+"%";var d=this.elem.parentNode;d.insertBefore(c,this.elem),c.appendChild(this.elem)}};for(var d=b.getElementsByTagName("iframe"),e=0;e<d.length;e++){d[e].src&&new c(d[e]).init()}}(window,document); |
101 | | </script> |
102 | | |
103 | | <?php |
104 | | } |
| 70 | /** |
| 71 | * Filter here to edit the embed excerpt. |
| 72 | * |
| 73 | * @since 2.5.0 |
| 74 | * |
| 75 | * @param string $excerpt The embed excerpt |
| 76 | * @param string $content The full content of the activity |
| 77 | */ |
| 78 | return apply_filters( 'bp_activity_get_embed_excerpt', $excerpt, $content ); |
105 | 79 | } |
106 | | } |
107 | | add_action( 'bp_activity_embed_after_content', 'bp_activity_embed_response_display_media' ); |
diff --git src/bp-activity/bp-activity-loader.php src/bp-activity/bp-activity-loader.php
index f41630e..f8180e3 100644
|
|
class BP_Activity_Component extends BP_Component { |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Embeds - only applicable for WP 4.4+ |
72 | | if ( bp_get_major_wp_version() >= 4.4 && bp_is_active( $this->id, 'embeds' ) ) { |
| 72 | if ( function_exists( 'wp_oembed_register_route' ) && bp_is_active( $this->id, 'embeds' ) ) { |
73 | 73 | $includes[] = 'classes/class-bp-activity-oembed-component'; |
74 | 74 | $includes[] = 'embeds'; |
75 | 75 | } |
diff --git src/bp-activity/classes/class-bp-activity-oembed-component.php src/bp-activity/classes/class-bp-activity-oembed-component.php
index 8deaa8b..f61823d 100644
|
|
|
9 | 9 | // Exit if accessed directly. |
10 | 10 | defined( 'ABSPATH' ) || exit; |
11 | 11 | |
12 | | require_once( buddypress()->plugin_dir . '/bp-core/classes/class-bp-oembed-component.php' ); |
| 12 | if ( class_exists( 'BP_oEmbed_Component' ) ) : |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * oEmbed handler to respond and render single activity items. |
… |
… |
class BP_Activity_oEmbed_Component extends BP_oEmbed_Component { |
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | | * Add custom endpoint arguments. |
40 | | * |
41 | | * Currently, includes 'hide_media'. |
42 | | * |
43 | | * @since 2.5.0 |
44 | | * |
45 | | * @return array |
46 | | */ |
47 | | protected function set_route_args() { |
48 | | return array( |
49 | | 'hide_media' => array( |
50 | | 'default' => false, |
51 | | 'sanitize_callback' => 'wp_validate_boolean' |
52 | | ) |
53 | | ); |
54 | | } |
55 | | |
56 | | /** |
57 | 39 | * Output our custom embed template part. |
58 | 40 | * |
59 | 41 | * @since 2.5.0 |
… |
… |
class BP_Activity_oEmbed_Component extends BP_oEmbed_Component { |
158 | 140 | |
159 | 141 | // 'wp-embedded-content' CSS class is necessary due to how the embed JS works. |
160 | 142 | $blockquote = sprintf( '<blockquote class="wp-embedded-content bp-activity-item">%1$s%2$s %3$s</blockquote>', |
161 | | '<p>' . bp_activity_get_embed_excerpt( $activity->content ) . '</p>', |
| 143 | bp_activity_get_embed_excerpt( $activity->content ), |
162 | 144 | '- ' . bp_core_get_user_displayname( $activity->user_id ) . $mentionname, |
163 | 145 | '<a href="' . esc_url( bp_activity_get_permalink( $item_id ) ) . '">' . $date . '</a>' |
164 | 146 | ); |
… |
… |
class BP_Activity_oEmbed_Component extends BP_oEmbed_Component { |
217 | 199 | _n( |
218 | 200 | '%s <span class="screen-reader-text">Comment</span>', |
219 | 201 | '%s <span class="screen-reader-text">Comments</span>', |
220 | | $count |
| 202 | $count, |
| 203 | 'buddypress' |
221 | 204 | ), |
222 | 205 | number_format_i18n( $count ) |
223 | 206 | ); |
… |
… |
class BP_Activity_oEmbed_Component extends BP_oEmbed_Component { |
228 | 211 | <?php |
229 | 212 | } |
230 | 213 | } |
| 214 | |
| 215 | endif; |
diff --git src/bp-core/bp-core-actions.php src/bp-core/bp-core-actions.php
index aea4467..09f7b6a 100644
|
|
add_action( 'set_current_user', 'bp_setup_current_user', 10 ); |
37 | 37 | add_action( 'setup_theme', 'bp_setup_theme', 10 ); |
38 | 38 | add_action( 'after_setup_theme', 'bp_after_setup_theme', 100 ); // After WP themes. |
39 | 39 | add_action( 'wp_enqueue_scripts', 'bp_enqueue_scripts', 10 ); |
| 40 | add_action( 'enqueue_embed_scripts', 'bp_enqueue_embed_scripts', 10 ); |
40 | 41 | add_action( 'admin_bar_menu', 'bp_setup_admin_bar', 20 ); // After WP core. |
41 | 42 | add_action( 'template_redirect', 'bp_template_redirect', 10 ); |
42 | 43 | add_action( 'widgets_init', 'bp_widgets_init', 10 ); |
diff --git src/bp-core/bp-core-classes.php src/bp-core/bp-core-classes.php
index 0da6fbb..608eac6 100644
|
|
require dirname( __FILE__ ) . '/classes/class-bp-media-extractor.php'; |
24 | 24 | require dirname( __FILE__ ) . '/classes/class-bp-attachment.php'; |
25 | 25 | require dirname( __FILE__ ) . '/classes/class-bp-attachment-avatar.php'; |
26 | 26 | require dirname( __FILE__ ) . '/classes/class-bp-attachment-cover-image.php'; |
| 27 | |
| 28 | if ( function_exists( 'wp_oembed_register_route' ) ) { |
| 29 | require dirname( __FILE__ ) . '/classes/class-bp-oembed-component.php'; |
| 30 | } |
diff --git src/bp-core/bp-core-dependency.php src/bp-core/bp-core-dependency.php
index 6982924..9ab8314 100644
|
|
function bp_enqueue_scripts() { |
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
| 403 | * Fire the 'bp_enqueue_embed_scripts' action, where BP enqueues its CSS and JS |
| 404 | * for BuddyPress embeds. |
| 405 | * |
| 406 | * @since 2.5.0 |
| 407 | * |
| 408 | * @uses do_action() Calls 'bp_enqueue_embed_scripts'. |
| 409 | */ |
| 410 | function bp_enqueue_embed_scripts() { |
| 411 | if ( ! is_buddypress() ) { |
| 412 | return; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Fires inside the 'bp_enqueue_embed_scripts' function, where BP enqueues its CSS and JS |
| 417 | * for BuddyPress embeds. |
| 418 | * |
| 419 | * @since 2.5.0 |
| 420 | */ |
| 421 | do_action ( 'bp_enqueue_embed_scripts' ); |
| 422 | } |
| 423 | |
| 424 | /** |
403 | 425 | * Fire the 'bp_add_rewrite_tag' action, where BP adds its custom rewrite tags. |
404 | 426 | * |
405 | 427 | * @since 1.8.0 |
diff --git src/bp-core/bp-core-template-loader.php src/bp-core/bp-core-template-loader.php
index 8f4b03c..c76133f 100644
|
|
function bp_locate_template( $template_names, $load = false, $require_once = tru |
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
| 150 | * Locate the URL for a requested asset |
| 151 | * |
| 152 | * @since 2.5.0 |
| 153 | * |
| 154 | * @param string $filename The requested asset (eg: css/buddypress.css) |
| 155 | * @return string The located uri for the asset. |
| 156 | */ |
| 157 | function bp_locate_template_asset_uri( $filename ) { |
| 158 | $asset = bp_locate_template( $filename ); |
| 159 | |
| 160 | if ( ! $asset ) { |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | // Should be the majority of cases. |
| 165 | if ( preg_match( '/' . addcslashes( WP_CONTENT_DIR, '/' ) . '/' , $asset ) ) { |
| 166 | $uri = str_replace( WP_CONTENT_DIR, content_url(), $asset ); |
| 167 | |
| 168 | // Otherwise there's a good chance it's a symlinked plugin. |
| 169 | } else { |
| 170 | $uri = plugins_url( wp_basename( $filename ), $asset ); |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Filter here to edit the located url for the asset. |
| 175 | * |
| 176 | * @since 2.5.0 |
| 177 | * |
| 178 | * @param string $uri The located uri for the asset. |
| 179 | * @param string $filename The requested asset |
| 180 | */ |
| 181 | return apply_filters( 'bp_locate_template_asset_uri', $uri, $filename ); |
| 182 | } |
| 183 | |
| 184 | /** |
150 | 185 | * Register a new template stack location. |
151 | 186 | * |
152 | 187 | * This allows for templates to live in places beyond just the parent/child |
diff --git src/bp-core/classes/class-bp-oembed-component.php src/bp-core/classes/class-bp-oembed-component.php
index 4e0b9f9..99f571a 100644
|
|
abstract class BP_oEmbed_Component { |
176 | 176 | * @since 2.5.0 |
177 | 177 | */ |
178 | 178 | protected function setup_hooks() { |
179 | | add_action( 'rest_api_init', array( $this, 'register_route' ) ); |
180 | | add_action( 'embed_content', array( $this, 'inject_content' ) ); |
| 179 | add_action( 'rest_api_init', array( $this, 'register_route' ) ); |
| 180 | add_action( 'bp_embed_content', array( $this, 'inject_content' ) ); |
181 | 181 | |
182 | 182 | add_filter( 'embed_template', array( $this, 'filter_template' ) ); |
183 | 183 | add_filter( 'post_embed_url', array( $this, 'filter_embed_url' ) ); |
… |
… |
abstract class BP_oEmbed_Component { |
439 | 439 | |
440 | 440 | $this->content(); |
441 | 441 | } |
442 | | } |
443 | | No newline at end of file |
| 442 | } |
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php
index c5974e2..803b6da 100644
|
|
class BP_Legacy extends BP_Theme_Compat { |
83 | 83 | |
84 | 84 | /** Scripts ***********************************************************/ |
85 | 85 | |
86 | | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS |
87 | | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS |
88 | | add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization |
89 | | add_action( 'bp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head>. |
| 86 | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS |
| 87 | add_action( 'bp_enqueue_embed_scripts', array( $this, 'embed_enqueue_styles' ) ); // Enqueue theme Embed CSS |
| 88 | add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS |
| 89 | add_filter( 'bp_enqueue_scripts', array( $this, 'localize_scripts' ) ); // Enqueue theme script localization |
| 90 | add_action( 'bp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head>. |
90 | 91 | |
91 | 92 | /** Body no-js Class **************************************************/ |
92 | 93 | |
… |
… |
class BP_Legacy extends BP_Theme_Compat { |
270 | 271 | } |
271 | 272 | |
272 | 273 | /** |
| 274 | * Load the theme Embed CSS |
| 275 | * |
| 276 | * @since 2.5.0 |
| 277 | */ |
| 278 | public function embed_enqueue_styles() { |
| 279 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 280 | |
| 281 | wp_enqueue_style( 'bp-embeds-css', bp_locate_template_asset_uri( "assets/embeds/css/style{$min}.css" ), array(), $this->version, 'screen' ); |
| 282 | |
| 283 | if ( $min ) { |
| 284 | wp_style_add_data( 'bp-embeds-css', 'suffix', $min ); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /** |
273 | 289 | * Enqueue the required JavaScript files |
274 | 290 | * |
275 | 291 | * @since 1.7.0 |
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/activity.php src/bp-templates/bp-legacy/buddypress/assets/embeds/activity.php
index 1fdae1a..8fa909f 100644
|
|
|
2 | 2 | <?php if ( bp_has_activities( 'display_comments=threaded&show_hidden=true&include=' . bp_current_action() ) ) : ?> |
3 | 3 | |
4 | 4 | <?php while ( bp_activities() ) : bp_the_activity(); ?> |
5 | | <div class="wp-embed-excerpt"><p><?php bp_activity_embed_excerpt(); ?></p></div> |
| 5 | |
| 6 | <?php do_action( 'bp_activity_embed_before_content' ); ?> |
| 7 | |
| 8 | <div class="wp-embed-excerpt"><?php bp_activity_embed_excerpt(); ?></div> |
6 | 9 | |
7 | 10 | <p class="wp-embed-timestamp"><a href="<?php bp_activity_thread_permalink(); ?>"><?php echo date_i18n( get_option( 'time_format' ) . ' - ' . get_option( 'date_format' ), strtotime( bp_get_activity_date_recorded() ) ); ?></a></p> |
8 | 11 | |
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/css.php src/bp-templates/bp-legacy/buddypress/assets/embeds/css.php
deleted file mode 100644
index beaa782..0000000
+
|
-
|
|
1 | | <style type="text/css"> |
2 | | #wp-embed-header:after { |
3 | | clear: both; |
4 | | content: ""; |
5 | | display: table; |
6 | | margin-bottom: 1em; |
7 | | } |
8 | | |
9 | | .wp-embed-avatar { |
10 | | float: left; |
11 | | margin: 0 .75em 0 0; |
12 | | } |
13 | | |
14 | | p.wp-embed-heading { |
15 | | font-size: 16px; |
16 | | margin-bottom: 0; |
17 | | } |
18 | | |
19 | | .wp-embed-excerpt, p.wp-embed-timestamp { |
20 | | margin-bottom: .5em; |
21 | | } |
22 | | |
23 | | .activity-read-more { |
24 | | margin-left: .5em; |
25 | | } |
26 | | |
27 | | .activity-read-more a { |
28 | | color: #b4b9be; |
29 | | } |
30 | | |
31 | | .wp-embed-footer { |
32 | | margin-top: 20px; |
33 | | } |
34 | | </style> |
35 | | No newline at end of file |
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/css/style.css src/bp-templates/bp-legacy/buddypress/assets/embeds/css/style.css
index e69de29..7737744 100644
|
|
|
| 1 | #wp-embed-header:after { |
| 2 | clear: both; |
| 3 | content: ""; |
| 4 | display: table; |
| 5 | margin-bottom: 1em; |
| 6 | } |
| 7 | |
| 8 | .wp-embed-avatar { |
| 9 | float: left; |
| 10 | margin: 0 .75em 0 0; |
| 11 | } |
| 12 | |
| 13 | p.wp-embed-heading { |
| 14 | font-size: 16px; |
| 15 | margin-bottom: 0; |
| 16 | } |
| 17 | |
| 18 | .wp-embed-excerpt, p.wp-embed-timestamp { |
| 19 | margin-bottom: .5em; |
| 20 | } |
| 21 | |
| 22 | .activity-read-more { |
| 23 | margin-left: .5em; |
| 24 | } |
| 25 | |
| 26 | .activity-read-more a { |
| 27 | color: #b4b9be; |
| 28 | } |
| 29 | |
| 30 | .wp-embed-footer { |
| 31 | margin-top: 20px; |
| 32 | } |
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/template.php src/bp-templates/bp-legacy/buddypress/assets/embeds/template.php
index 599c283..eb488e7 100644
|
|
if ( ! headers_sent() ) { |
25 | 25 | <title><?php echo wp_get_document_title(); ?></title> |
26 | 26 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
27 | 27 | <base target="_top" /> |
| 28 | |
28 | 29 | <?php |
29 | 30 | /** This action is documented in wp-includes/embed-template.php */ |
30 | | do_action( 'embed_head' ); |
| 31 | do_action( 'embed_head' ); ?> |
31 | 32 | |
32 | | // This is used by r-a-y for testing purposes at the moment. |
33 | | bp_get_asset_template_part( 'embeds/css' ); |
34 | | ?> |
35 | 33 | </head> |
36 | 34 | <body <?php body_class(); ?>> |
37 | 35 | <div <?php post_class( 'wp-embed' ); ?>> |
| 36 | |
38 | 37 | <?php |
39 | 38 | bp_get_asset_template_part( 'embeds/header', bp_current_component() ); |
40 | 39 | |
41 | | /** This action is documented in wp-includes/embed-template.php */ |
42 | | do_action( 'embed_content' ); |
| 40 | /** |
| 41 | * Print the content for the BuddyPress Embed object. |
| 42 | * |
| 43 | * @since 2.5.0 |
| 44 | */ |
| 45 | do_action( 'bp_embed_content' ); |
43 | 46 | |
44 | 47 | bp_get_asset_template_part( 'embeds/footer', bp_current_component() ); |
45 | 48 | ?> |
… |
… |
bp_get_asset_template_part( 'embeds/footer', bp_current_component() ); |
51 | 54 | do_action( 'embed_footer' ); |
52 | 55 | ?> |
53 | 56 | </body> |
54 | | </html> |
55 | | No newline at end of file |
| 57 | </html> |