Completed
Pull Request — master (#81)
by Felix
03:53
created

_starter.php ➔ example_my_term_starter()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 17

Duplication

Lines 38
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 1
dl 38
loc 38
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * Register Fields API configuration
4
 *
5
 * @param WP_Fields_API $wp_fields
6
 */
7 View Code Duplication
function example_my_term_starter( $wp_fields ) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
9
	// Object type: Term
10
	$object_type = 'term';
11
12
	// Object name: Category
13
	$object_name = 'category'; // @todo Change to any taxonomy name
14
15
	// Form: Term Edit
16
	$form_id = 'term-edit'; // @todo Also available is term-add
17
18
	/////////////////////////
19
	// Section: My Section //
20
	/////////////////////////
21
22
	$section_id   = ''; // @todo Fill in section ID
23
	$section_args = array(
24
		'title' => __( '', 'my-text-domain' ), // @todo Fill in section heading, update text domain
25
		'form'  => $form_id,
26
	);
27
28
	$wp_fields->add_section( $object_type, $section_id, $object_name, $section_args );
29
30
	// My Field
31
	$field_id   = '';
32
	$field_args = array(
33
		// You can register a control for this field at the same time
34
		'control' => array(
35
			'type'        => 'text', // @todo Change control type if needed
36
			'section'     => $section_id,
37
			'label'       => __( '', 'my-text-domain' ), // @todo Fill in label, update text domain
38
			'description' => __( '', 'my-text-domain' ), // @todo Fill in description, update text domain
39
		),
40
	);
41
42
	$wp_fields->add_field( $object_type, $field_id, $object_name, $field_args );
43
44
}
45
46
add_action( 'fields_register', 'example_my_term_starter' );