cehojac/cmb2-field-order

Custom field for CMB2 to store custom order of options.

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 7

Type:cmb2-addon

dev-master 2019-06-04 13:15 UTC

This package is not auto-updated.

Last update: 2024-04-18 11:19:35 UTC


README

Custom field for CMB2 to store custom order of options.

example

add_action( 'cmb2_admin_init', 'cmb2_order_metabox' );
function cmb2_order_metabox() {

	$prefix = 'your_prefix_demo_';

	$cmb_demo = new_cmb2_box( array(
		'id'            => $prefix . 'metabox',
		'title'         => __( 'Test Metabox', 'cmb2' ),
		'object_types'  => array( 'page', 'post' ), // Post type
		// 'show_on_cb' => 'your_prefix_show_if_front_page', // function should return a bool value
		// 'context'    => 'normal',
		// 'priority'   => 'high',
		// 'show_names' => true, // Show field names on the left
		// 'cmb_styles' => false, // false to disable the CMB stylesheet
		// 'closed'     => true, // true to keep the metabox closed by default
	) );

	$cmb_demo->add_field( array(
		'name'          => __( 'Test Order', 'cmb2' ),
		'desc'          => __( 'field description (optional)', 'cmb2' ),
		'id'            => $prefix . '_order',
		'type'          => 'order',
		// 'inline'        => true,
		'options'       => array(
			'option-1'  => __('Option 1', 'cmb2'),
			'option-2'  => __('Option 2', 'cmb2'),
			'option-3'  => __('Option 3', 'cmb2'),
		),
	) );

}

Changelog

1.0.1

  • Sortable now works on Appearance >> Widgets

1.0.0

  • Initial commit