Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
_bp_core_inject_bp_widget_css_class( array $params )
Injects specific BuddyPress CSS classes into a widget sidebar.
Description Description
Helps to standardize styling of BuddyPress widgets within a theme that does not use dynamic CSS classes in their widget sidebar’s ‘before_widget’ call.
Parameters Parameters
- $params
-
(Required) Current sidebar params.
Return Return
(array)
Source Source
File: bp-core/bp-core-filters.php
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 | function _bp_core_inject_bp_widget_css_class( $params ) { global $wp_registered_widgets ; $widget_id = $params [0][ 'widget_id' ]; // If callback isn't an array, bail. if ( false === is_array ( $wp_registered_widgets [ $widget_id ][ 'callback' ] ) ) { return $params ; } // If the current widget isn't a BuddyPress one, stop! // We determine if a widget is a BuddyPress widget, if the widget class // begins with 'bp_'. if ( 0 !== strpos ( $wp_registered_widgets [ $widget_id ][ 'callback' ][0]->id_base, 'bp_' ) ) { return $params ; } // Dynamically add our widget CSS classes for BP widgets if not already there. $classes = array (); // Try to find 'widget' CSS class. if ( false === strpos ( $params [0][ 'before_widget' ], 'widget ' ) ) { $classes [] = 'widget' ; } // Try to find 'buddypress' CSS class. if ( false === strpos ( $params [0][ 'before_widget' ], ' buddypress' ) ) { $classes [] = 'buddypress' ; } // Stop if widget already has our CSS classes. if ( empty ( $classes ) ) { return $params ; } // CSS injection time! $params [0][ 'before_widget' ] = str_replace ( 'class="' , 'class="' . implode( ' ' , $classes ) . ' ' , $params [0][ 'before_widget' ] ); return $params ; } |
Changelog Changelog
Version | Description |
---|---|
2.4.0 | Introduced. |