Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/01/2024 06:07:04 AM (13 months ago)
Author:
imath
Message:

Improve BuddyPress compatibility with WP Playground previews

  • Avoid using SIGNED casting into the SQL query retrieving the signup field IDs as it's generating an error with WP Playground SQLite db.
  • Make sure BP URI globals are set during Ajax requests passing the current displayed page canonical URL into these requests.
  • Ignore the bp-message cookie when its value is set to deleted to prevent the wrong display of a template notice when BP Legacy is the active template pack.
  • Update JSON blueprints to latest WP Playground's blueprint schema.

Props espellcaste

Fixes #9207
Closes https://github.com/buddypress/buddypress/pull/389

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r13890 r14068  
    14781478 *
    14791479 * @since 8.0.0
     1480 * @since 15.0.0 The SQL request was adapted to support WP Playground's SQLite DB.
    14801481 *
    14811482 * @global wpdb $wpdb WordPress database object.
     
    14901491        $bp = buddypress();
    14911492
    1492         $signup_field_ids = $wpdb->get_col( "SELECT object_id FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND meta_key = 'signup_position' ORDER BY CONVERT(meta_value, SIGNED) ASC" );
     1493        // WP Playground's SQLite DB does not support CONVERT AS SIGNED.
     1494        $results          = $wpdb->get_results( "SELECT object_id, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND meta_key = 'signup_position'" );
     1495        $signup_field_ids = array();
     1496
     1497        foreach ( $results as $result ) {
     1498            $index                      = (int) $result->meta_value;
     1499            $signup_field_ids[ $index ] = (int) $result->object_id;
     1500        }
     1501
     1502        // Sort.
     1503        ksort( $signup_field_ids );
    14931504
    14941505        wp_cache_set( 'signup_fields', $signup_field_ids, 'bp_xprofile' );
    14951506    }
    14961507
    1497     return array_map( 'intval', $signup_field_ids );
     1508    return array_values( $signup_field_ids );
    14981509}
    14991510
Note: See TracChangeset for help on using the changeset viewer.