[buddypress-trac] [BuddyPress] #4728: Visibility API refactoring/restructuring

buddypress-trac noreply at wordpress.org
Fri Dec 21 08:48:34 UTC 2012


#4728: Visibility API refactoring/restructuring
--------------------------+------------------------------
 Reporter:  chrisclayton  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Core          |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  2nd-opinion   |
--------------------------+------------------------------

Comment (by chrisclayton):

 As an example to clarify what I'm saying, the way it is currently - we'll
 end up with this (modified from Boones example plugin - link above) in
 plugins when we start building privacy in other components...

 {{{
      // Add the levels to all components
 add_filter( 'bp_xprofile_get_visibility_levels', array( &$this,
 'modify_levels' ) );
 add_filter( 'bp_activity_get_visibility_levels', array( &$this,
 'modify_levels' ) );
 add_filter( 'bp_groups_get_visibility_levels', array( &$this,
 'modify_levels' ) );
      // the example plugin had to build its thing from scratch and decided
 to create a fun name
      // it probably changed the array key too, meaning this won't work.
      // Or, forgot to add a filter.
 add_filter( 'bp_example_awesomesauce_privacy_sauce', array( &$this,
 'modify_levels' ) );

         function modify_levels( $levels ) {
                 // Remove the 'friends' level, if it exists
                 if ( isset( $levels['friends'] ) ) {
                         unset( $levels['friends'] );
                 }

                 // Add a new 'Admins Only' level
                 if ( !isset( $levels['admins-only'] ) ) {
                         $levels['admins-only'] = array(
                                 'id' => 'admins-only',
                                 'label' => __( 'Admins Only', 'textdomain'
 )
                         );
                 }

                 return $levels;
         }
 }}}

 When it should be something like
 {{{
 add_filter( 'bp_core_get_visibility_levels', array( &$this,
 'modify_levels' ) );

         function modify_levels( $levels ) {
                 // Remove the 'friends' level, if it exists
                 if ( isset( $levels['friends'] ) ) {
                         unset( $levels['friends'] );
                 }

                 // Add a new 'Admins Only' level
                 if ( !isset( $levels['admins-only'] ) ) {
                         $levels['admins-only'] = array(
                                 'id' => 'admins-only',
                                 'label' => __( 'Admins Only', 'textdomain'
 )
                         );
                 }

                 return $levels;
         }
 }}}

 And then the individual components that need that info will get that info
 from core.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4728#comment:4>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list