Ticket #6772: 6778.08.suggestions.patch
File 6778.08.suggestions.patch, 14.3 KB (added by , 8 years ago) |
---|
-
.jshintignore
diff --git .jshintignore .jshintignore index 7d7b4cc..2cf40f7 100644
src/bp-core/js/jquery.caret.js 7 7 src/bp-core/js/jquery-cookie.js 8 8 src/bp-core/js/jquery-scroll-to.js 9 9 src/bp-messages/js/autocomplete/* 10 src/bp-activity/js/fluidvids.js -
src/bp-activity/bp-activity-embeds.php
diff --git src/bp-activity/bp-activity-embeds.php src/bp-activity/bp-activity-embeds.php index cec54ca..2f5e334 100644
function bp_activity_setup_oembed() { 32 32 } 33 33 add_action( 'bp_loaded', 'bp_activity_setup_oembed' ); 34 34 35 /** 36 * Add inline styles for BP activity embeds. 37 * 38 * This is subject to change or be removed entirely for a different system. 39 * See PHPDoc for BP_Legacy::locate_asset_in_stack(). 40 * 41 * @since 2.6.0 42 * @access private 43 */ 44 function _bp_activity_embed_add_inline_styles() { 45 if ( false === bp_is_single_activity() ) { 46 return; 47 } 48 49 $inline_css = <<<EOD 50 51 #bp-embed-header:after { 52 clear: both; 53 content: ""; 54 display: table; 55 margin-bottom: 1em; 56 } 57 58 .bp-embed-avatar { 59 float: left; 60 margin: 0 .75em 0 0; 61 } 35 function bp_activity_embed_register_assets() { 36 $min = bp_core_get_minified_asset_suffix(); 37 $version = bp_get_version(); 62 38 63 p.bp-embed-activity-action { 64 font-size: 15px; 65 margin-bottom: 0; 66 } 67 68 p.bp-embed-activity-action a:first-child { 69 color: #32373c; 70 font-weight: bold; 71 } 39 // Css 40 $css_url = buddypress()->plugin_url . 'bp-activity/css/'; 72 41 73 p.bp-embed-activity-action img.avatar { 74 padding: 0 4px 0 3px; 75 vertical-align: text-bottom; 76 } 77 78 .bp-embed-excerpt { 79 margin-bottom: 1em; 80 } 42 /** 43 * Filters the BuddyPress Embed stylesheet files to register. 44 * 45 * @since 2.6.0 46 * 47 * @param array $value Array of stylesheet file information to register. 48 */ 49 $styles = apply_filters( 'bp_activity_embed_register_styles', array( 50 'bp-activity-embed' => array( 51 'file' => "{$css_url}embed{$min}.css", 52 'dependencies' => array(), 53 'has_rtl' => true, 54 'version' => $version, 55 ), 56 ) ); 57 58 foreach ( $styles as $id => $style ) { 59 wp_register_style( $id, $style['file'], $style['dependencies'], $style['version'] ); 60 61 if ( ! empty( $style['has_rtl'] ) ) { 62 wp_style_add_data( $id, 'rtl', true ); 63 } 81 64 82 .bp-embed-excerpt a { 83 color: #21759b; 84 display: inline-block; 85 overflow: hidden; 86 text-overflow: ellipsis; 87 vertical-align: top; 88 white-space: nowrap; 89 max-width: 250px; 90 } 65 if ( $min ) { 66 wp_style_add_data( $id, 'suffix', $min ); 67 } 68 } 91 69 92 .bp-activity-embed-display-media { 93 height: auto; 94 max-width: 550px; 95 } 70 // JS 71 $js_url = buddypress()->plugin_url . 'bp-activity/js/'; 96 72 97 .bp-activity-embed-display-media img { 98 height: auto; 99 max-width: 100%; 73 wp_register_script( 'bp-activity-fluidvids', "{$js_url}fluidvids{$min}.js", array(), $version, true ); 100 74 } 75 add_action( 'bp_enqueue_embed_scripts', 'bp_activity_embed_register_assets', 1 ); 101 76 102 .activity-read-more { 103 margin-left: .5em; 104 } 77 function bp_activity_embed_enqueue_head_assets() { 78 if ( false === bp_is_single_activity() ) { 79 return; 80 } 105 81 106 .activity-read-more a { 107 color: #b4b9be; 82 wp_enqueue_style( 'bp-activity-embed' ); 108 83 } 84 add_action( 'bp_enqueue_embed_scripts', 'bp_activity_embed_enqueue_head_assets', 10 ); 109 85 110 .wp-embed-footer { 111 margin-top: 20px; 112 } 86 function bp_activity_embed_has_activity( $activity_id = 0 ) { 87 global $activities_template; 113 88 114 span.bp-embed-timestamp{115 font-size: .9em;116 }89 if ( empty( $activity_id ) ) { 90 return false; 91 } 117 92 118 video { 119 width: 100%; 120 height: auto; 121 } 93 if ( ! empty( $activities_template->activities ) ) { 94 $activity = (array) $activities_template->activities; 95 $activity = reset( $activity ); 122 96 123 EOD; 97 // No need to requery if we already got the embed activity 98 if ( (int) $activity_id === (int) $activity->id ) { 99 return $activities_template->has_activities(); 100 } 101 } 124 102 125 echo "<style type='text/css'>{$inline_css}</style>"; 103 return bp_has_activities( array( 104 'display_comments' => 'threaded', 105 'show_hidden' => true, 106 'include' => (int) $activity_id, 107 ) ); 126 108 } 127 add_action( 'embed_head', '_bp_activity_embed_add_inline_styles', 20 );128 109 129 110 /** 130 111 * Outputs excerpt for an activity embed item. … … function bp_activity_embed_media() { 233 214 234 215 // Video takes precedence. HTML5-only. 235 216 if ( isset( $media['videos'] ) && 'shortcodes' === $media['videos'][0]['source'] ) { 236 echo "<video controls>237 <source src='{$media['videos'][0]['url']}'>238 <p>" . __( 'Your browser does not support HTML5 video', 'buddypress' ) . "</p>239 </video>";217 printf( '<video controls><source src="%1$s"><p>%2$s</p></video>', 218 esc_url( $media['videos'][0]['url'] ), 219 esc_html__( 'Your browser does not support HTML5 video', 'buddypress' ) 220 ); 240 221 241 222 // No video? Try audio. HTML5-only. 242 223 } elseif ( isset( $media['audio'] ) && 'shortcodes' === $media['audio'][0]['source'] ) { 243 echo "<audio controls>244 <source src='{$media['audio'][0]['url']}'>245 <p>" . __( 'Your browser does not support HTML5 audio', 'buddypress' ) . "</p>246 </audio>";224 printf( '<audio controls><source src="%1$s"><p>%2$s</p></audio>', 225 esc_url( $media['audio'][0]['url'] ), 226 esc_html__( 'Your browser does not support HTML5 audio', 'buddypress' ) 227 ); 247 228 248 229 // No video or audio? Try image. 249 230 } elseif ( isset( $media['images'] ) && 'html' === $media['images'][0]['source'] ) { 250 echo '<div class="bp-activity-embed-display-media"><img src="' . $media['images'][0]['url'] . '" /></div>';231 printf( '<div class="bp-activity-embed-display-media"><img src="%s"/></div>', $media['images'][0]['url'] ); 251 232 } 252 233 253 234 } 254 235 255 236 // Hook fluidvids script to embed footer. 256 237 if ( true === $do_fluidvids ) { 257 add_action( 'embed_footer', '_bp_activity_embed_print_fluidvids_js' ); 238 wp_enqueue_script ( 'bp-activity-fluidvids' ); 239 wp_add_inline_script( 'bp-activity-fluidvids', " 240 fluidvids.init( { 241 selector: ['iframe', 'object'], 242 players: ['.'] // remove default youtube / vimeo restriction. 243 } ); 244 " ); 258 245 } 259 246 260 247 /** This hook is documented in /bp-activity/bp-activity-embeds.php */ 261 248 do_action( 'bp_activity_embed_after_media' ); 262 249 } 263 264 /**265 * Print fluidvids.js inline.266 *267 * Subject to be removed at any time.268 *269 * @since 2.6.0270 * @access private271 */272 function _bp_activity_embed_print_fluidvids_js() {273 ?>274 275 <script>276 /*! fluidvids.js v2.4.1 | (c) 2014 @toddmotto | License: MIT | https://github.com/toddmotto/fluidvids */277 !function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t:e.fluidvids=t()}(this,function(){"use strict";function e(e){return new RegExp("^(https?:)?//(?:"+d.players.join("|")+").*$","i").test(e)}function t(e,t){return parseInt(e,10)/parseInt(t,10)*100+"%"}function i(i){if((e(i.src)||e(i.data))&&!i.getAttribute("data-fluidvids")){var n=document.createElement("div");i.parentNode.insertBefore(n,i),i.className+=(i.className?" ":"")+"fluidvids-item",i.setAttribute("data-fluidvids","loaded"),n.className+="fluidvids",n.style.paddingTop=t(i.height,i.width),n.appendChild(i)}}function n(){var e=document.createElement("div");e.innerHTML="<p>x</p><style>"+o+"</style>",r.appendChild(e.childNodes[1])}var d={selector:["iframe","object"],players:["www.youtube.com","player.vimeo.com"]},o=[".fluidvids {","width: 100%; max-width: 100%; position: relative;","}",".fluidvids-item {","position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;","}"].join(""),r=document.head||document.getElementsByTagName("head")[0];return d.render=function(){for(var e=document.querySelectorAll(d.selector.join()),t=e.length;t--;)i(e[t])},d.init=function(e){for(var t in e)d[t]=e[t];d.render(),n()},d});278 279 // init280 fluidvids.init({281 selector: ['iframe', 'object'],282 players: ['.'] // remove default youtube / vimeo restriction.283 });284 </script>285 286 <?php287 } -
src/bp-activity/css/embed.css
diff --git src/bp-activity/css/embed.css src/bp-activity/css/embed.css index e69de29..9334eda 100644
1 #bp-embed-header:after { 2 clear: both; 3 content: ""; 4 display: table; 5 margin-bottom: 1em; 6 } 7 8 .bp-embed-avatar { 9 float: left; 10 margin: 0 .75em 0 0; 11 } 12 13 p.bp-embed-activity-action { 14 font-size: 15px; 15 margin-bottom: 0; 16 } 17 18 p.bp-embed-activity-action a:first-child { 19 color: #32373c; 20 font-weight: bold; 21 } 22 23 p.bp-embed-activity-action img.avatar { 24 padding: 0 4px 0 3px; 25 vertical-align: text-bottom; 26 } 27 28 .bp-embed-excerpt { 29 margin-bottom: 1em; 30 } 31 32 .bp-embed-excerpt a { 33 color: #21759b; 34 display: inline-block; 35 overflow: hidden; 36 text-overflow: ellipsis; 37 vertical-align: top; 38 white-space: nowrap; 39 max-width: 250px; 40 } 41 42 .bp-activity-embed-display-media { 43 height: auto; 44 max-width: 550px; 45 } 46 47 .bp-activity-embed-display-media img { 48 height: auto; 49 max-width: 100%; 50 } 51 52 .activity-read-more { 53 margin-left: .5em; 54 } 55 56 .activity-read-more a { 57 color: #b4b9be; 58 } 59 60 .wp-embed-footer { 61 margin-top: 20px; 62 } 63 64 span.bp-embed-timestamp { 65 font-size: .9em; 66 } 67 68 video { 69 width: 100%; 70 height: auto; 71 } -
src/bp-activity/js/fluidvids.js
diff --git src/bp-activity/js/fluidvids.js src/bp-activity/js/fluidvids.js index e69de29..3af36bc 100755
1 (function (root, factory) { 2 if (typeof define === 'function' && define.amd) { 3 define(factory); 4 } else if (typeof exports === 'object') { 5 module.exports = factory; 6 } else { 7 root.fluidvids = factory(); 8 } 9 })(this, function () { 10 11 'use strict'; 12 13 var fluidvids = { 14 selector: ['iframe', 'object'], 15 players: ['www.youtube.com', 'player.vimeo.com'] 16 }; 17 18 var css = [ 19 '.fluidvids {', 20 'width: 100%; max-width: 100%; position: relative;', 21 '}', 22 '.fluidvids-item {', 23 'position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;', 24 '}' 25 ].join(''); 26 27 var head = document.head || document.getElementsByTagName('head')[0]; 28 29 function matches (src) { 30 return new RegExp('^(https?:)?\/\/(?:' + fluidvids.players.join('|') + ').*$', 'i').test(src); 31 } 32 33 function getRatio (height, width) { 34 return ((parseInt(height, 10) / parseInt(width, 10)) * 100) + '%'; 35 } 36 37 function fluid (elem) { 38 if (!matches(elem.src) && !matches(elem.data) || !!elem.getAttribute('data-fluidvids')) return; 39 var wrap = document.createElement('div'); 40 elem.parentNode.insertBefore(wrap, elem); 41 elem.className += (elem.className ? ' ' : '') + 'fluidvids-item'; 42 elem.setAttribute('data-fluidvids', 'loaded'); 43 wrap.className += 'fluidvids'; 44 wrap.style.paddingTop = getRatio(elem.height, elem.width); 45 wrap.appendChild(elem); 46 } 47 48 function addStyles () { 49 var div = document.createElement('div'); 50 div.innerHTML = '<p>x</p><style>' + css + '</style>'; 51 head.appendChild(div.childNodes[1]); 52 } 53 54 fluidvids.render = function () { 55 var nodes = document.querySelectorAll(fluidvids.selector.join()); 56 var i = nodes.length; 57 while (i--) { 58 fluid(nodes[i]); 59 } 60 }; 61 62 fluidvids.init = function (obj) { 63 for (var key in obj) { 64 fluidvids[key] = obj[key]; 65 } 66 fluidvids.render(); 67 addStyles(); 68 }; 69 70 return fluidvids; 71 72 }); -
src/bp-core/classes/class-bp-oembed-component.php
diff --git src/bp-core/classes/class-bp-oembed-component.php src/bp-core/classes/class-bp-oembed-component.php index fe1153e..f8e7493 100644
abstract class BP_oEmbed_Component { 589 589 590 590 $this->content(); 591 591 } 592 } 593 No newline at end of file 592 } -
src/bp-templates/bp-legacy/buddypress/assets/embeds/activity.php
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/activity.php src/bp-templates/bp-legacy/buddypress/assets/embeds/activity.php index 2b28cfc..c9672ae 100644
1 1 2 <?php if ( bp_ has_activities( 'display_comments=threaded&show_hidden=true&include=' .bp_current_action() ) ) : ?>2 <?php if ( bp_activity_embed_has_activity( bp_current_action() ) ) : ?> 3 3 4 4 <?php while ( bp_activities() ) : bp_the_activity(); ?> 5 5 <div class="bp-embed-excerpt"><?php bp_activity_embed_excerpt(); ?></div> -
src/bp-templates/bp-legacy/buddypress/assets/embeds/header-activity.php
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/header-activity.php src/bp-templates/bp-legacy/buddypress/assets/embeds/header-activity.php index 2887eeb..d668707 100644
6 6 </a> 7 7 </div> 8 8 9 <?php if ( bp_ has_activities( 'display_comments=threaded&show_hidden=true&include=' .bp_current_action() ) ) : ?>9 <?php if ( bp_activity_embed_has_activity( bp_current_action() ) ) : ?> 10 10 11 11 <?php while ( bp_activities() ) : bp_the_activity(); ?> 12 12 <p class="bp-embed-activity-action"> … … 16 16 17 17 <?php endif; ?> 18 18 19 <?php if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) : ?> 20 <p class="bp-embed-mentionname">@<?php bp_displayed_user_mentionname(); ?> · <span class="bp-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></span></p> 21 <?php endif; ?> 19 <p class="bp-embed-header-meta"> 20 <?php if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) : ?> 21 <span class="bp-embed-mentionname">@<?php bp_displayed_user_mentionname(); ?> · </span> 22 <?php endif; ?> 23 24 <span class="bp-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></span> 25 </p> 22 26 </div> -
src/bp-templates/bp-legacy/buddypress/assets/embeds/header.php
diff --git src/bp-templates/bp-legacy/buddypress/assets/embeds/header.php src/bp-templates/bp-legacy/buddypress/assets/embeds/header.php index e3d012e..69d2d5a 100644
11 11 <?php bp_displayed_user_fullname(); ?> 12 12 </a> 13 13 </p> 14 15 <?php if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) : ?>16 <p class="bp-embed-mentionname">@<?php bp_displayed_user_mentionname(); ?></p>17 <?php endif; ?>18 14 </div>