WP Manifestindependent plugin directory
manifest / content / cmb2-field-order

CMB2 Field Type: Order

Custom field for CMB2 to store custom order of options

by Tsunoa · github.com/rubengc/cmb2-field-order · website

12stars
8forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/rubengc/cmb2-field-order/archive/refs/heads/master.zip

Declares an update source (https://github.com/rubengc/cmb2-field-order), so updates arrive through the plugin's own updater.

Readme

CMB2 custom field "order"

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

Read the full README on GitHub →