Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/09/2024 02:43:17 PM (2 years ago)
Author:
espellcaste
Message:

Fire the customizer_set_uri method for regular themes when BP Classic is activated.

Restore the deprecated (in BP 12.0) customizer_set_uri method since we still need to support it for regular themes using BP Classic.

We are also fixing a PHP 8.1 deprecated notice.

Props thomaslhotta, imath.

Fixes #8920 (branch 14.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/14.0/src/bp-templates/bp-nouveau/buddypress-functions.php

    r13898 r14004  
    121121                                0
    122122                        );
     123
     124                        // When BP Classic is activated, regular themes need this filter.
     125                        if ( function_exists( 'bp_classic' ) ) {
     126                                // Set the BP Uri for the Ajax customizer preview.
     127                                add_filter( 'bp_uri', array( $this, 'customizer_set_uri' ), 10, 1 );
     128                        }
    123129                } elseif ( wp_using_themes() && ! isset( $_GET['bp_customizer'] ) ) {
    124130                        remove_action( 'customize_register', 'bp_customize_register', 20 );
     
    694700         *
    695701         * @since 3.0.0
    696          * @deprecated 12.0.0
     702         * @since 12.0.0 Only fired for regular themes when BP Classic is activated.
    697703         *
    698704         * @param  string $path The BP Uri.
    699          * @return string       The BP Uri.
     705         * @return string
    700706         */
    701707        public function customizer_set_uri( $path ) {
    702                 _deprecated_function( __METHOD__, '12.0.0' );
    703708
    704709                if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
     
    708713                $uri = wp_parse_url( $path );
    709714
    710                 if ( false === strpos( $uri['path'], 'customize.php' ) ) {
     715                if ( ! str_contains( $uri['path'], 'customize.php' ) || empty( $uri['query'] ) ) {
    711716                        return $path;
    712                 } else {
    713                         $vars = bp_parse_args(
    714                                 $uri['query'],
    715                                 array(),
    716                                 'customizer_set_uri'
    717                         );
    718 
    719                         if ( ! empty( $vars['url'] ) ) {
    720                                 $path = str_replace( get_site_url(), '', urldecode( $vars['url'] ) );
    721                         }
     717                }
     718
     719                $vars = bp_parse_args(
     720                        $uri['query'],
     721                        array(),
     722                        'customizer_set_uri'
     723                );
     724
     725                if ( ! empty( $vars['url'] ) ) {
     726                        $path = str_replace( get_site_url(), '', urldecode( $vars['url'] ) );
    722727                }
    723728
Note: See TracChangeset for help on using the changeset viewer.