gppro_sections

When using the gppro_admin_block_add filter, you need to also add the corresponding sections to complete the process. The section can contain any number of options related to your new block. The slug variable in the admin block must match the array key set up in the section itself.

The section is a multi-dimensional array:

  • title:(string) The title above each option group
  • data:(array) An array of each option, using a key => value setup. the array key must be unique.
    • label:(string) the label for the option
    • sub:(string) optional small text to clarify a section (i.e. a hover state)
    • input:(string) available input type. a list of available types are here, or a custom input type can be declared with a corresponding callback
    • target:(string) which CSS class to target the changes in the live preview
    • selector:(string) what CSS selector to use in the live preview
    • tip:(string) optional tooltip
    • callback:(string) if declaring a custom input type, the function name used here will be called

Adding a new section.

function my_cool_section( $sections, $class ) {
	$sections['cool_thing']	= array(
		array(
			'title'		=> 'Section Title',
			'data'		=> array(
				'new-option'	=> array(
					'label'		=> __( 'New Option', 'my-text-domain' ),
					'sub'		=> __( 'Extra', 'my-text-domain' ),
					'input'		=> 'color',
					'target'	=> $class.' .class-to-target',
					'selector'	=> 'background-color'
					'tip'		=> __( 'Tooltip info', 'my-text-domain' ),
				),
				'custom-option'	=> array(
					'label'		=> __( 'Custom Option', 'my-text-domain' ),
					'input'		=> 'custom',
					'callback'	=> 'callback_function_name'
				),
			),
		),
	);
	return $sections;
}
add_filter ( 'gppro_sections', 'my_cool_section', 10, 2	);