Ticket #7226: 7226-01.patch
File 7226-01.patch, 4.5 KB (added by , 8 years ago) |
---|
-
src/bp-core/classes/class-bp-button.php
33 33 * Default: ''. 34 34 * @type string $wrapper_class Optional. DOM class of the button wrapper 35 35 * element. Default: ''. 36 * @type string $element Optional. The type of element to use e.g 'anchor', 'button' 37 * Default: 'anchor'. 38 * @type string $element_type Optional. Set the button type i.e like input types 39 * Defaults to 'button' [type="button"] can be 'submit' [type="submit"] 36 40 * @type string $link_href Optional. Destination link of the button. 37 41 * Default: ''. 42 * @type string $data_attr Optional. Allow a data attributte to be set. e.g 'data-bp-buttons=""' 43 * Default: ''. 38 44 * @type string $link_class Optional. DOM class of the button. Default: ''. 39 45 * @type string $link_id Optional. DOM ID of the button. Default: ''. 40 46 * @type string $link_rel Optional. DOM 'rel' attribute of the button. … … 103 109 /** Button ****************************************************************/ 104 110 105 111 /** 112 * The node element type type i.e. a true '<button>' element or '<a>' anchor: 113 * 'button', 'anchor' 114 * 115 * @var string 116 */ 117 public $element = 'anchor'; 118 119 /** 120 * The button elements type i.e. 'submit', 'button'. 121 * 122 * 123 * @var string 124 */ 125 public $button_type = 'button'; 126 127 /** 106 128 * The destination link of the button. 107 129 * 108 130 * @var string … … 138 160 public $link_title = ''; 139 161 140 162 /** 163 * A data attribute. 164 * 165 * @var string 166 */ 167 public $data_attr = ''; 168 169 /** 141 170 * The contents of the button link. 142 171 * 143 172 * @var string … … 223 252 $before = $after = ''; 224 253 } 225 254 226 // Link properties. 255 256 // Link/Button properties. 257 //if ( !empty( $r['element'] ) ) $this->element = 258 if ( !empty( $r['element_type'] ) && 'button' == $r['element'] ) $this->element_type = ' type="' . $r['element_type'] . '"'; 227 259 if ( !empty( $r['link_id'] ) ) $this->link_id = ' id="' . $r['link_id'] . '"'; 228 if ( !empty( $r['link_href'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"';260 if ( !empty( $r['link_href'] && 'button' !== $r['element'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"'; 229 261 if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"'; 230 262 if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"'; 231 263 if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"'; 232 if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text']; 264 if ( !empty( $r['data_attr'] ) ) $this->data_attr = ' ' . $r['data_attr'] ; 265 if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text']; 233 266 267 // The element tag: e.g '<a', '<button' 268 269 if ( 'button' == $r['element'] ) { 270 $before_element = '<button ' . $this->element_type ; 271 $after_element = '</button>'; 272 } else { 273 $before_element = '<a '; 274 $after_element = '</a>'; 275 } 276 234 277 // Build the button. 235 $this->contents = $before . '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>'. $after;278 $this->contents = $before . $before_element . $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->data_attr . $this->link_class . '>' . $this->link_text . $after_element . $after; 236 279 237 280 /** 238 281 * Filters the button based on class parameters. … … 246 289 * @param BP_Button $this Current BP_Button instance. 247 290 * @param string $before HTML appended before the actual button. 248 291 * @param string $after HTML appended after the actual button. 292 * @param string $before_element Actual items opening element. 293 * @param string $after_element Actual items closing element t& tag . 249 294 */ 250 $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after );295 $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after, $before_element, $after_element ); 251 296 } 252 297 253 298 /**