@@ 97-115 (lines=19) @@ | ||
94 | * @param string|callable $template |
|
95 | * @return $this |
|
96 | */ |
|
97 | public function set_header_template( $template ) { |
|
98 | if ( count($this->groups) === 0 ) { |
|
99 | Incorrect_Syntax_Exception::raise( "Can't set group label template. There are no present groups for Complex Field " . $this->get_label() . "." ); |
|
100 | } |
|
101 | ||
102 | $template = is_callable( $template ) ? call_user_func( $template ) : $template; |
|
103 | ||
104 | // Assign the template to the group that was added last |
|
105 | $values = array_values( $this->groups ); |
|
106 | $group = end( $values ); |
|
107 | $group->set_label_template( $template ); |
|
108 | ||
109 | // Include the group label Underscore template |
|
110 | $this->add_template( $group->get_group_id(), array( $group, 'template_label' ) ); |
|
111 | ||
112 | $this->groups[ $group->get_name() ] = $group; |
|
113 | ||
114 | return $this; |
|
115 | } |
|
116 | ||
117 | /** |
|
118 | * Retrieve all groups of fields. |
@@ 97-115 (lines=19) @@ | ||
94 | * @param string|callable $template |
|
95 | * @return $this |
|
96 | */ |
|
97 | public function set_header_template( $template ) { |
|
98 | if ( count($this->groups) === 0 ) { |
|
99 | Incorrect_Syntax_Exception::raise( "Can't set group label template. There are no present groups for Complex Field " . $this->get_label() . "." ); |
|
100 | } |
|
101 | ||
102 | $template = is_callable( $template ) ? call_user_func( $template ) : $template; |
|
103 | ||
104 | // Assign the template to the group that was added last |
|
105 | $values = array_values( $this->groups ); |
|
106 | $group = end( $values ); |
|
107 | $group->set_label_template( $template ); |
|
108 | ||
109 | // Include the group label Underscore template |
|
110 | $this->add_template( $group->get_group_id(), array( $group, 'template_label' ) ); |
|
111 | ||
112 | $this->groups[ $group->get_name() ] = $group; |
|
113 | ||
114 | return $this; |
|
115 | } |
|
116 | ||
117 | /** |
|
118 | * Retrieve all groups of fields. |