Changeset 6312 for trunk/bp-core/bp-core-classes.php
- Timestamp:
- 09/06/2012 04:45:50 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-classes.php
r6310 r6312 873 873 * API to create BuddyPress buttons 874 874 * 875 * component: Which component this button is for 876 * must_be_logged_in: Button only appears for logged in users 877 * block_self: Button will not appear when viewing your own profile. 878 * wrapper: div|span|p|li|false for no wrapper 879 * wrapper_id: The DOM ID of the button wrapper 880 * wrapper_class: The DOM class of the button wrapper 881 * link_href: The destination link of the button 882 * link_title: Title of the button 883 * link_id: The DOM ID of the button 884 * link_class: The DOM class of the button 885 * link_rel: The DOM rel of the button 886 * link_text: The text of the button 887 * contents: The contents of the button 888 * 875 889 * @package BuddyPress Core 876 890 * @since BuddyPress (1.2.6) … … 981 995 public $contents = ''; 982 996 983 /** 984 * Builds the button based on passed parameters: 985 * 986 * component: Which component this button is for 987 * must_be_logged_in: Button only appears for logged in users 988 * block_self: Button will not appear when viewing your own profile. 989 * wrapper: div|span|p|li|false for no wrapper 990 * wrapper_id: The DOM ID of the button wrapper 991 * wrapper_class: The DOM class of the button wrapper 992 * link_href: The destination link of the button 993 * link_title: Title of the button 994 * link_id: The DOM ID of the button 995 * link_class: The DOM class of the button 996 * link_rel: The DOM rel of the button 997 * link_text: The contents of the button 997 /** Methods ***************************************************************/ 998 999 /** 1000 * Builds the button based on class parameters: 1001 * 1002 * @since BuddyPress (1.2.6) 998 1003 * 999 1004 * @param array $args … … 1003 1008 1004 1009 $r = wp_parse_args( $args, get_class_vars( __CLASS__ ) ); 1005 extract( $r, EXTR_SKIP );1006 1010 1007 1011 // Required button properties 1008 $this->id = $ id;1009 $this->component = $ component;1010 $this->must_be_logged_in = (bool) $must_be_logged_in;1011 $this->block_self = (bool) $block_self;1012 $this->wrapper = $ wrapper;1012 $this->id = $r['id']; 1013 $this->component = $r['component']; 1014 $this->must_be_logged_in = (bool) $r['must_be_logged_in']; 1015 $this->block_self = (bool) $r['block_self']; 1016 $this->wrapper = $r['wrapper']; 1013 1017 1014 1018 // $id and $component are required 1015 if ( empty( $ id ) || empty( $component) )1019 if ( empty( $r['id'] ) || empty( $r['component'] ) ) 1016 1020 return false; 1017 1021 1018 1022 // No button if component is not active 1019 if ( ! bp_is_active( $this->component ) )1023 if ( ! bp_is_active( $this->component ) ) 1020 1024 return false; 1021 1025 1022 1026 // No button for guests if must be logged in 1023 if ( true == $this->must_be_logged_in && ! is_user_logged_in() )1027 if ( true == $this->must_be_logged_in && ! is_user_logged_in() ) 1024 1028 return false; 1025 1029 … … 1032 1036 1033 1037 // Wrapper ID 1034 if ( !empty( $ wrapper_id) ) {1035 $this->wrapper_id = ' id="' . $ wrapper_id. '"';1038 if ( !empty( $r['wrapper_id'] ) ) { 1039 $this->wrapper_id = ' id="' . $r['wrapper_id'] . '"'; 1036 1040 } 1037 1041 1038 1042 // Wrapper class 1039 if ( !empty( $ wrapper_class) ) {1040 $this->wrapper_class = ' class="generic-button ' . $ wrapper_class. '"';1043 if ( !empty( $r['wrapper_class'] ) ) { 1044 $this->wrapper_class = ' class="generic-button ' . $r['wrapper_class'] . '"'; 1041 1045 } else { 1042 1046 $this->wrapper_class = ' class="generic-button"'; … … 1044 1048 1045 1049 // Set before and after 1046 $before = '<' . $ wrapper. $this->wrapper_class . $this->wrapper_id . '>';1047 $after = '</' . $ wrapper. '>';1050 $before = '<' . $r['wrapper'] . $this->wrapper_class . $this->wrapper_id . '>'; 1051 $after = '</' . $r['wrapper'] . '>'; 1048 1052 1049 1053 // No wrapper … … 1053 1057 1054 1058 // Link properties 1055 if ( !empty( $link_id ) ) 1056 $this->link_id = ' id="' . $link_id . '"'; 1057 1058 if ( !empty( $link_href ) ) 1059 $this->link_href = ' href="' . $link_href . '"'; 1060 1061 if ( !empty( $link_title ) ) 1062 $this->link_title = ' title="' . $link_title . '"'; 1063 1064 if ( !empty( $link_rel ) ) 1065 $this->link_rel = ' rel="' . $link_rel . '"'; 1066 1067 if ( !empty( $link_class ) ) 1068 $this->link_class = ' class="' . $link_class . '"'; 1069 1070 if ( !empty( $link_text ) ) 1071 $this->link_text = $link_text; 1059 if ( !empty( $r['link_id'] ) ) $this->link_id = ' id="' . $r['link_id'] . '"'; 1060 if ( !empty( $r['link_href'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"'; 1061 if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"'; 1062 if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"'; 1063 if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"'; 1064 if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text']; 1072 1065 1073 1066 // Build the button … … 1075 1068 1076 1069 // Allow button to be manipulated externally 1077 $this->contents = apply_filters( 'bp_button_' . $ component . '_' . $id, $this->contents, $this, $before, $after );1070 $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after ); 1078 1071 } 1079 1072 1080 1073 /** 1081 1074 * Return contents of button 1075 * 1076 * @since BuddyPress (1.2.6) 1082 1077 * 1083 1078 * @return string … … 1089 1084 /** 1090 1085 * Output contents of button 1086 * 1087 * @since BuddyPress (1.2.6) 1091 1088 */ 1092 1089 public function display() {
Note: See TracChangeset
for help on using the changeset viewer.