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