Ticket #7226: 7226-02.patch
File 7226-02.patch, 5.4 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 $button_type Optional. Set the button type i.e like input types 39 * Defaults to 'button' [type="button"] can be 'submit' [type="submit"] 40 * @type string $button_name Optional: Button 'name' value - if type == 'submit'. 41 * @type string $button_value Optional: Button 'value' value - if type == 'submit'. 36 42 * @type string $link_href Optional. Destination link of the button. 37 43 * Default: ''. 44 * @type string $data_attr Optional. Allow a data attributte to be set. e.g 'data-bp-buttons=""' 45 * Default: ''. 38 46 * @type string $link_class Optional. DOM class of the button. Default: ''. 39 47 * @type string $link_id Optional. DOM ID of the button. Default: ''. 40 48 * @type string $link_rel Optional. DOM 'rel' attribute of the button. … … 103 111 /** Button ****************************************************************/ 104 112 105 113 /** 114 * The node element type type i.e. a true '<button>' element or '<a>' anchor: 115 * 'button', 'anchor' 116 * 117 * @var string 118 */ 119 public $element = 'anchor'; 120 121 /** 122 * The button elements type i.e. 'submit', 'button'. 123 * 124 * 125 * @var string 126 */ 127 public $button_type = 'button'; 128 129 /** 130 * The button elements name attr i.e. 'name=""'. 131 * 132 * 133 * @var string 134 */ 135 public $button_name = ''; 136 137 /** 138 * The button elements value attr i.e. 'value=""'. 139 * 140 * 141 * @var string 142 */ 143 public $button_value = ''; 144 145 146 /** 106 147 * The destination link of the button. 107 148 * 108 149 * @var string … … 138 179 public $link_title = ''; 139 180 140 181 /** 182 * A data attribute. 183 * 184 * @var string 185 */ 186 public $data_attr = ''; 187 188 /** 141 189 * The contents of the button link. 142 190 * 143 191 * @var string … … 223 271 $before = $after = ''; 224 272 } 225 273 226 // Link properties. 274 275 // Link/Button properties. 276 //if ( !empty( $r['element'] ) ) $this->element = 277 if ( !empty( $r['element_type'] ) && 'button' == $r['element'] ) $this->element_type = ' type="' . $r['element_type'] . '"'; 278 if ( !empty( $r['button_name'] ) && 'button' == $r['element_type'] && 'submit' == $r['button_type'] ) $this->button_name = ' type="' . $r['button_name'] . '"'; 279 if ( !empty( $r['button_value'] ) && 'button' == $r['element_type'] && 'submit' == $r['button_type'] ) $this->button_value = ' type="' . $r['button_value'] . '"'; 227 280 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'] . '"'; 281 // No href if we're a button please! 282 if ( !empty( $r['link_href'] && 'button' !== $r['element'] ) ) $this->link_href = ' href="' . $r['link_href'] . '"'; 229 283 if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"'; 230 284 if ( !empty( $r['link_rel'] ) ) $this->link_rel = ' rel="' . $r['link_rel'] . '"'; 231 285 if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"'; 232 if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text']; 286 if ( !empty( $r['data_attr'] ) ) $this->data_attr = ' ' . $r['data_attr'] ; 287 if ( !empty( $r['link_text'] ) ) $this->link_text = $r['link_text']; 233 288 289 // The element tag: e.g '<a', '<button' 290 291 if ( 'button' == $r['element'] ) { 292 $before_element = '<button ' . $this->element_type ; 293 $after_element = '</button>'; 294 } else { 295 $before_element = '<a '; 296 $after_element = '</a>'; 297 } 298 234 299 // 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;300 $this->contents = $before . $before_element . $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->button_name . $this->button_value . $this->data_attr . $this->link_class . '>' . $this->link_text . $after_element . $after; 236 301 237 302 /** 238 303 * Filters the button based on class parameters. … … 246 311 * @param BP_Button $this Current BP_Button instance. 247 312 * @param string $before HTML appended before the actual button. 248 313 * @param string $after HTML appended after the actual button. 314 * @param string $before_element Actual items opening element. 315 * @param string $after_element Actual items closing element t& tag . 249 316 */ 250 $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after );317 $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after, $before_element, $after_element ); 251 318 } 252 319 253 320 /**