Skip to content

Commit c171812

Browse files
committed
Make the Title type handle extra args. Merge pull request #656 from pixelgrade/trunk.
Squashed commit of the following: commit d3dad17ad8a97c50134dcb865b47cf4920458239 Author: Justin Sternberg <[email protected]> Date: Fri Jun 3 13:52:49 2016 -0400 Clean up commit 8b94b02 Author: Vlad Olaru <[email protected]> Date: Fri Jun 3 10:30:49 2016 +0300 Removed the $args for good commit 09e83ff Author: Vlad Olaru <[email protected]> Date: Thu Jun 2 21:29:31 2016 +0300 Removed the $args and bad slash for the title field commit c6c2b1f Author: Vlad Olaru <[email protected]> Date: Thu Jun 2 09:52:13 2016 +0300 Added PHPDoc for the title type render function commit 1e6369d Author: Vlad Olaru <[email protected]> Date: Thu Jun 2 09:38:14 2016 +0300 Make the Title type handle extra args Currently, the Title type didn't take into consideration extra arguments like 'attributes'. Now it does.
1 parent caffa95 commit c171812

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
77
* Implement CMB2_Ajax as a singleton. Props [jrfnl](https://github.com/jrfnl) ([#602](https://github.com/WebDevStudios/CMB2/pull/602)).
88
* CMB2 is now a lot more intelligent about where it is located in your installation. This update should solve almost all of the reasons to use the `'cmb2_meta_box_url'` filter (thought it will continue to work as expected). ([#27](https://github.com/WebDevStudios/CMB2/issues/27), [#118](https://github.com/WebDevStudios/CMB2/issues/118), [#432](https://github.com/WebDevStudios/CMB2/issues/432), [related wiki item](https://github.com/WebDevStudios/CMB2/wiki/Troubleshooting#cmb2-urls-issues))
99
* Add `classes` and `classes_cb` CMB2 box params which allows you to add additional classes to the cmb-wrap. The `classes` parameter can take a string or array, and the `classes_cb` takes a callback which returns a string or array. The callback will receive `$cmb` as an argument. These classes are also passed through a new filter, `'cmb2_wrap_classes'`, which receives the array of classes as the first argument, and the CMB2 object as the second. Reported/requested in [#364](https://github.com/WebDevStudios/CMB2/issues/364#issuecomment-213223692).
10+
* Make the `'title'` field type accept extra arguments. Props [@vladolaru](https://github.com/vladolaru), [@pixelgrade](https://github.com/pixelgrade) ([#656](https://github.com/WebDevStudios/CMB2/pull/656)).
1011

1112

1213
### Bug Fixes

includes/types/CMB2_Type_Title.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
*/
1313
class CMB2_Type_Title extends CMB2_Type_Base {
1414

15+
/**
16+
* Handles outputting an 'title' element
17+
* @return string Heading element
18+
*/
1519
public function render() {
1620
$a = $this->parse_args( 'title', array(
1721
'tag' => $this->field->object_type == 'post' ? 'h5' : 'h3',
@@ -21,7 +25,7 @@ public function render() {
2125
) );
2226

2327
return $this->rendered(
24-
sprintf( '<%1$s class="%2$s">%3$s</%1$s>%4$s', $a['tag'], $a['class'], $a['name'], $a['desc'] )
28+
sprintf( '<%1$s %2$s>%3$s</%1$s>%4$s', $a['tag'], $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), $a['name'], $a['desc'] )
2529
);
2630
}
2731

0 commit comments

Comments
 (0)