@@ 175-212 (lines=38) @@ | ||
172 | * @param string $object_type Object type |
|
173 | * @return void |
|
174 | */ |
|
175 | public function render_form_open( $object_id = 0, $object_type = '' ) { |
|
176 | $object_type = $this->object_type( $object_type ); |
|
177 | $object_id = $this->object_id( $object_id ); |
|
178 | ||
179 | echo "\n<!-- Begin CMB2 Fields -->\n"; |
|
180 | ||
181 | $this->nonce_field(); |
|
182 | ||
183 | /** |
|
184 | * Hook before form table begins |
|
185 | * |
|
186 | * @param array $cmb_id The current box ID |
|
187 | * @param int $object_id The ID of the current object |
|
188 | * @param string $object_type The type of object you are working with. |
|
189 | * Usually `post` (this applies to all post-types). |
|
190 | * Could also be `comment`, `user` or `options-page`. |
|
191 | * @param array $cmb This CMB2 object |
|
192 | */ |
|
193 | do_action( 'cmb2_before_form', $this->cmb_id, $object_id, $object_type, $this ); |
|
194 | ||
195 | /** |
|
196 | * Hook before form table begins |
|
197 | * |
|
198 | * The first dynamic portion of the hook name, $object_type, is the type of object |
|
199 | * you are working with. Usually `post` (this applies to all post-types). |
|
200 | * Could also be `comment`, `user` or `options-page`. |
|
201 | * |
|
202 | * The second dynamic portion of the hook name, $this->cmb_id, is the meta_box id. |
|
203 | * |
|
204 | * @param array $cmb_id The current box ID |
|
205 | * @param int $object_id The ID of the current object |
|
206 | * @param array $cmb This CMB2 object |
|
207 | */ |
|
208 | do_action( "cmb2_before_{$object_type}_form_{$this->cmb_id}", $object_id, $this ); |
|
209 | ||
210 | echo '<div class="cmb2-wrap form-table"><div id="cmb2-metabox-', sanitize_html_class( $this->cmb_id ), '" class="cmb2-metabox cmb-field-list">'; |
|
211 | ||
212 | } |
|
213 | ||
214 | /** |
|
215 | * Outputs the closing form markup and runs corresponding hooks: |
|
@@ 222-258 (lines=37) @@ | ||
219 | * @param string $object_type Object type |
|
220 | * @return void |
|
221 | */ |
|
222 | public function render_form_close( $object_id = 0, $object_type = '' ) { |
|
223 | $object_type = $this->object_type( $object_type ); |
|
224 | $object_id = $this->object_id( $object_id ); |
|
225 | ||
226 | echo '</div></div>'; |
|
227 | ||
228 | $this->render_hidden_fields(); |
|
229 | ||
230 | /** |
|
231 | * Hook after form form has been rendered |
|
232 | * |
|
233 | * @param array $cmb_id The current box ID |
|
234 | * @param int $object_id The ID of the current object |
|
235 | * @param string $object_type The type of object you are working with. |
|
236 | * Usually `post` (this applies to all post-types). |
|
237 | * Could also be `comment`, `user` or `options-page`. |
|
238 | * @param array $cmb This CMB2 object |
|
239 | */ |
|
240 | do_action( 'cmb2_after_form', $this->cmb_id, $object_id, $object_type, $this ); |
|
241 | ||
242 | /** |
|
243 | * Hook after form form has been rendered |
|
244 | * |
|
245 | * The dynamic portion of the hook name, $this->cmb_id, is the meta_box id. |
|
246 | * |
|
247 | * The first dynamic portion of the hook name, $object_type, is the type of object |
|
248 | * you are working with. Usually `post` (this applies to all post-types). |
|
249 | * Could also be `comment`, `user` or `options-page`. |
|
250 | * |
|
251 | * @param int $object_id The ID of the current object |
|
252 | * @param array $cmb This CMB2 object |
|
253 | */ |
|
254 | do_action( "cmb2_after_{$object_type}_form_{$this->cmb_id}", $object_id, $this ); |
|
255 | ||
256 | echo "\n<!-- End CMB2 Fields -->\n"; |
|
257 | ||
258 | } |
|
259 | ||
260 | /** |
|
261 | * Renders a field based on the field type |