Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 07:12:25 PM (19 months ago)
Author:
espellcaste
Message:

WPCS: Part VIII: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], [13887], [13888], [13891], [13892], [13893]

See #9164 and #7228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-embed.php

    r13372 r13900  
    7171     * for oEmbed parsing.
    7272     *
    73      *
    7473     * @param array  $attr Shortcode attributes.
    7574     * @param string $url  The URL attempting to be embeded.
     
    7776     */
    7877    public function shortcode( $attr, $url = '' ) {
    79         if ( empty( $url ) )
     78        if ( empty( $url ) ) {
    8079            return '';
     80        }
    8181
    8282        $rawattr = $attr;
     
    9595            foreach ( $handlers as $hid => $handler ) {
    9696                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 ) {
    9899
    99100                        /**
     
    102103                         * @since 1.5.0
    103104                         *
    104                          * @param string $return Handler callback for the oEmbed.
     105                         * @param mixed $return Handler callback for the oEmbed.
    105106                         * @param string $url    URL attempting to be embedded.
    106107                         * @param array  $attr   Shortcode attributes.
     
    117118         * @since 1.5.0
    118119         *
    119          * @param int $value Value of zero.
     120         * @param int $embed_post_id Embed object id. Default is 0.
    120121         */
    121122        $id = apply_filters( 'embed_post_id', 0 );
     
    138139        // Set up a new WP oEmbed object to check URL with registered oEmbed providers.
    139140        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';
    141142        } else {
    142143            // 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';
    144145        }
    145146
     
    148149        // If oEmbed discovery is true, skip oEmbed provider check.
    149150        $is_oembed_link = false;
    150         if ( !$attr['discover'] ) {
     151        if ( ! $attr['discover'] ) {
    151152            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 ) ) {
    155156                    $is_oembed_link = true;
     157                }
    156158            }
    157159
    158160            // If url doesn't match a WP oEmbed provider, stop parsing.
    159             if ( !$is_oembed_link )
     161            if ( ! $is_oembed_link ) {
    160162                return $this->maybe_make_link( $url );
     163            }
    161164        }
    162165
     
    183186
    184187        if ( $id ) {
    185             // Setup the cachekey.
     188            // Setup the cache key.
    186189            $cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
    187190
     
    204207
    205208            // Grab cache and return it if available.
    206             if ( !empty( $cache ) ) {
     209            if ( ! empty( $cache ) ) {
    207210
    208211                /**
     
    218221                return apply_filters( 'bp_embed_oembed_html', $cache, $url, $attr, $rawattr );
    219222
    220             // If no cache, ping the oEmbed provider and cache the result.
     223                // If no cache, ping the oEmbed provider and cache the result.
    221224            } else {
    222                 $html = wp_oembed_get( $url, $attr );
     225                $html  = wp_oembed_get( $url, $attr );
    223226                $cache = ( $html ) ? $html : $url;
    224227
Note: See TracChangeset for help on using the changeset viewer.