Changeset 13900 for trunk/src/bp-core/classes/class-bp-embed.php
- Timestamp:
- 06/02/2024 07:12:25 PM (19 months ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/classes/class-bp-embed.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-embed.php
r13372 r13900 71 71 * for oEmbed parsing. 72 72 * 73 *74 73 * @param array $attr Shortcode attributes. 75 74 * @param string $url The URL attempting to be embeded. … … 77 76 */ 78 77 public function shortcode( $attr, $url = '' ) { 79 if ( empty( $url ) ) 78 if ( empty( $url ) ) { 80 79 return ''; 80 } 81 81 82 82 $rawattr = $attr; … … 95 95 foreach ( $handlers as $hid => $handler ) { 96 96 if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { 97 if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) { 97 $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ); 98 if ( false !== $return ) { 98 99 99 100 /** … … 102 103 * @since 1.5.0 103 104 * 104 * @param string$return Handler callback for the oEmbed.105 * @param mixed $return Handler callback for the oEmbed. 105 106 * @param string $url URL attempting to be embedded. 106 107 * @param array $attr Shortcode attributes. … … 117 118 * @since 1.5.0 118 119 * 119 * @param int $ value Value of zero.120 * @param int $embed_post_id Embed object id. Default is 0. 120 121 */ 121 122 $id = apply_filters( 'embed_post_id', 0 ); … … 138 139 // Set up a new WP oEmbed object to check URL with registered oEmbed providers. 139 140 if ( file_exists( ABSPATH . WPINC . '/class-wp-oembed.php' ) ) { 140 require_once ( ABSPATH . WPINC . '/class-wp-oembed.php' );141 require_once ABSPATH . WPINC . '/class-wp-oembed.php'; 141 142 } else { 142 143 // class-oembed.php is deprecated in WordPress 5.3.0. 143 require_once ( ABSPATH . WPINC . '/class-oembed.php' );144 require_once ABSPATH . WPINC . '/class-oembed.php'; 144 145 } 145 146 … … 148 149 // If oEmbed discovery is true, skip oEmbed provider check. 149 150 $is_oembed_link = false; 150 if ( ! $attr['discover'] ) {151 if ( ! $attr['discover'] ) { 151 152 foreach ( (array) $oembed_obj->providers as $provider_matchmask => $provider ) { 152 $regex = ( $ is_regex = $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i';153 154 if ( preg_match( $regex, $url ) ) 153 $regex = ( $provider[1] ) ? $provider_matchmask : '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $provider_matchmask ), '#' ) ) . '#i'; 154 155 if ( preg_match( $regex, $url ) ) { 155 156 $is_oembed_link = true; 157 } 156 158 } 157 159 158 160 // If url doesn't match a WP oEmbed provider, stop parsing. 159 if ( ! $is_oembed_link )161 if ( ! $is_oembed_link ) { 160 162 return $this->maybe_make_link( $url ); 163 } 161 164 } 162 165 … … 183 186 184 187 if ( $id ) { 185 // Setup the cache key.188 // Setup the cache key. 186 189 $cachekey = '_oembed_' . md5( $url . serialize( $attr ) ); 187 190 … … 204 207 205 208 // Grab cache and return it if available. 206 if ( ! empty( $cache ) ) {209 if ( ! empty( $cache ) ) { 207 210 208 211 /** … … 218 221 return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr ); 219 222 220 // If no cache, ping the oEmbed provider and cache the result.223 // If no cache, ping the oEmbed provider and cache the result. 221 224 } else { 222 $html = wp_oembed_get( $url, $attr );225 $html = wp_oembed_get( $url, $attr ); 223 226 $cache = ( $html ) ? $html : $url; 224 227
Note: See TracChangeset
for help on using the changeset viewer.