- Timestamp:
- 06/02/2024 07:12:25 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-core-oembed-extension.php
r13878 r13900 6 6 * @subpackage Core 7 7 * @since 2.6.0 8 * 9 * @phpcs:disable PEAR.NamingConventions.ValidClassName.Invalid 8 10 */ 9 11 … … 54 56 * 55 57 * @since 2.6.0 56 *57 * @return null58 58 */ 59 59 abstract protected function content(); … … 128 128 * @param int $item_id The item ID to do checks for. 129 129 */ 130 protected function set_iframe_title( $item_id ) {} 130 protected function set_iframe_title( $item_id ) {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found 131 131 132 132 /** … … 145 145 * 146 146 * @since 2.6.0 147 * 148 * @return string 147 149 */ 148 150 protected function set_permalink() { … … 165 167 * 166 168 * @since 2.6.0 169 * 170 * @return int 167 171 */ 168 172 protected function get_item_id() { … … 189 193 */ 190 194 protected function setup_hooks() { 191 add_action( 'rest_api_init', array( $this, 'register_route' ) );195 add_action( 'rest_api_init', array( $this, 'register_route' ) ); 192 196 add_action( 'bp_embed_content', array( $this, 'inject_content' ) ); 193 197 194 198 add_filter( 'embed_template', array( $this, 'setup_template_parts' ) ); 195 199 add_filter( 'post_embed_url', array( $this, 'filter_embed_url' ) ); 196 add_filter( 'embed_html', array( $this, 'filter_embed_html' ) );200 add_filter( 'embed_html', array( $this, 'filter_embed_html' ) ); 197 201 add_filter( 'oembed_discovery_links', array( $this, 'add_oembed_discovery_links' ) ); 198 202 add_filter( 'rest_pre_serve_request', array( $this, 'oembed_xml_request' ), 20, 4 ); … … 223 227 'default' => $maxwidth, 224 228 'sanitize_callback' => 'absint', 229 ), 230 ); 231 232 // Merge custom arguments here. 233 $args = $args + (array) $this->set_route_args(); 234 235 register_rest_route( 236 'oembed/1.0', 237 "/embed/{$this->slug_endpoint}", 238 array( 239 array( 240 'methods' => WP_REST_Server::READABLE, 241 'callback' => array( $this, 'get_item' ), 242 'permission_callback' => '__return_true', 243 'args' => $args, 244 ), 225 245 ) 226 246 ); 227 228 // Merge custom arguments here.229 $args = $args + (array) $this->set_route_args();230 231 register_rest_route( 'oembed/1.0', "/embed/{$this->slug_endpoint}", array(232 array(233 'methods' => WP_REST_Server::READABLE,234 'callback' => array( $this, 'get_item' ),235 'permission_callback' => '__return_true',236 'args' => $args237 ),238 ) );239 247 } 240 248 … … 255 263 // Set up some BP-specific embed template overrides. 256 264 add_action( 'get_template_part_embed', array( $this, 'content_buffer_start' ), -999, 2 ); 257 add_action( 'get_footer', array( $this, 'content_buffer_end' ), -999 );265 add_action( 'get_footer', array( $this, 'content_buffer_end' ), -999 ); 258 266 259 267 // Return the original WP embed template. … … 341 349 } 342 350 343 add_filter( 'rest_url' , array( $this, 'filter_rest_url' ) );351 add_filter( 'rest_url', array( $this, 'filter_rest_url' ) ); 344 352 345 353 $retval = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( $permalink ) ) . '" />' . "\n"; … … 349 357 } 350 358 351 remove_filter( 'rest_url' , array( $this, 'filter_rest_url' ) );359 remove_filter( 'rest_url', array( $this, 'filter_rest_url' ) ); 352 360 353 361 return $retval; … … 357 365 * Fetch our oEmbed response data to return. 358 366 * 359 * A simplified version of {@ linkget_oembed_response_data()}.367 * A simplified version of {@see get_oembed_response_data()}. 360 368 * 361 369 * @since 2.6.0 … … 382 390 383 391 /** This filter is documented in /wp-includes/embed.php */ 384 $min_max_width = apply_filters( 'oembed_min_max_width', array( 385 'min' => 200, 386 'max' => 600 387 ) ); 392 $min_max_width = apply_filters( 393 'oembed_min_max_width', 394 array( 395 'min' => 200, 396 'max' => 600, 397 ) 398 ); 388 399 389 400 $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); … … 396 407 if ( 'video' === $data['type'] || 'rich' === $data['type'] ) { 397 408 // Fake a WP post so we can use get_post_embed_html(). 398 $post = new stdClass;409 $post = new stdClass(); 399 410 $post->post_content = $data['content']; 400 411 $post->post_title = $data['title']; … … 430 441 // This is needed for various oEmbed response data filtering. 431 442 if ( ! isset( buddypress()->{$this->slug_endpoint} ) || ! buddypress()->{$this->slug_endpoint} ) { 432 buddypress()->{$this->slug_endpoint} = new stdClass ;443 buddypress()->{$this->slug_endpoint} = new stdClass(); 433 444 } 434 445 buddypress()->{$this->slug_endpoint}->embedurl_in_progress = $url; … … 569 580 $custom_title = $this->set_iframe_title( $item_id ); 570 581 if ( ! empty( $custom_title ) ) { 571 $title_pos = strpos( $retval, 'title=' ) + 7;582 $title_pos = strpos( $retval, 'title=' ) + 7; 572 583 $title_end_pos = strpos( $retval, '"', $title_pos ); 573 584 … … 587 598 // @todo Maybe use KSES? 588 599 $fallback_html = $this->set_fallback_html( $item_id ); 600 601 $embed_html = $fallback_html . $retval; 589 602 590 603 /** … … 593 606 * @since 2.6.0 594 607 * 595 * @ var string $retval608 * @param string $embed_html Current embed HTML. 596 609 */ 597 return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $ fallback_html . $retval );610 return apply_filters( "bp_{$this->slug_endpoint}_embed_html", $embed_html ); 598 611 } 599 612
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)