How to 'clone' select metabox options with a callback function?

Here is my metabox

      array(
        'id'    = 'all_btns',
        'name'  = 'Button Select',
        'type'  = 'select',
        'options' = array(
            'button'         = 'Button',
            'button_red'     = 'Button Red',
            'button_yellow'  = 'Button Yellow',

        ),             
        'callback' = 'metabox_clone_options',
      ),

I want to clone this options to another metabox array

Topic callbacks metabox Wordpress

Category Web


Add a simple function in your functions.php file.

function get_button_styles(){
    return array(
        'button'         => 'Button',
        'button_red'     => 'Button Red',
        'button_yellow'  => 'Button Yellow',

    );
}

Use it to get button styles in different metabox fields

array(
    'id'    => 'all_btns',
    'name'  => 'Button Select',
    'type'  => 'select',
    'options' => get_button_styles(),             
    'callback' => 'metabox_clone_options',
),

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.