Code Duplication    Length = 37-38 lines in 2 locations

includes/CMB2.php 2 locations

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