Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/21/2020 01:21:21 AM (5 years ago)
Author:
imath
Message:

BP Types: merge BP Types saved in DB with the ones registered by code

  • Introduces the bp_get_taxonomy_types() to merge types saved into the database with the types registered by code. It's now possible to edit all properties of the registered by code types except for the type's slug which needs to be unique.
  • Caches these merged types.
  • Introduces the bp_get_member_types_registered_by_code() to only get member types registered by code.
  • Updates the test_bp_get_member_type_should_not_return_unregistered_types() unit test to test_bp_get_registered_by_code_member_type_should_not_return_unregistered_types() to check the previous point new function.
  • Introduces the bp_update_type_metadata() function to update a type's metadata.

Props mercime, DJPaul, dcavins, boonebgorges, tw2113, sbrajesh

See #7179
See #7181

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-cache.php

    r12541 r12729  
    391391add_action( 'bp_invitation_after_save', 'bp_invitations_reset_cache_incrementor' );
    392392add_action( 'bp_invitation_after_delete', 'bp_invitations_reset_cache_incrementor' );
     393
     394/**
     395 * Add a cache group for Database object types.
     396 *
     397 * @since 7.0.0
     398 */
     399function bp_set_object_type_terms_cache_group() {
     400    wp_cache_add_global_groups( 'bp_object_terms' );
     401}
     402add_action( 'bp_setup_cache_groups', 'bp_set_object_type_terms_cache_group' );
     403
     404/**
     405 * Clear the Database object types cache.
     406 *
     407 * @since 7.0.0
     408 *
     409 * @param int $type_id The Type's term ID.
     410 * @param string $taxonomy The Type's taxonomy name.
     411 */
     412function bp_clear_object_type_terms_cache( $type_id = 0, $taxonomy = '' ) {
     413    wp_cache_delete( $taxonomy, 'bp_object_terms' );
     414}
     415add_action( 'bp_type_inserted', 'bp_clear_object_type_terms_cache' );
     416add_action( 'bp_type_updated', 'bp_clear_object_type_terms_cache' );
     417add_action( 'bp_type_deleted', 'bp_clear_object_type_terms_cache' );
Note: See TracChangeset for help on using the changeset viewer.