Skip to content

button_set echo different keys each time selected #3180

@bomsn

Description

@bomsn

Hi, I'm just getting familiar with the framework, and I have some problems getting button_set type to work correctly

this is what it looks like on config file

 array(
                'id'       => 'mg-home-share-btns',
                'type'     => 'button_set',
				'required' => array( 'mg-home-share', '=', '1' ),
                'multi'    => true,
                'title'    => __( 'Social Buttons', 'redux-framework-demo' ),
                'subtitle' => __( 'Please select social media buttons you would like to display on homepage', 'redux-framework-demo' ),
                //Must provide key => value pairs for radio options
                'options'  => array(
					'1' => 'Facebook',
                    '2' => 'Twitter',
                    '3' => 'Email',
                    '4' => 'Google',
                    '5' => 'Tumblr',
                    '6' => 'Linkedin',
                    '7' => 'Reddit',
                    '8' => 'Hackernews',
					'9' => 'Pinterest',
					'10' => 'Pocket',

                ),

Now, I'm using conditional statment for each button to display specific text only if the button is selected, I have tried many thing, and got this one working:

when I echo an option
echo $options['mg-home-share-btns']['1']
I get value of 0 (only if button is not selected)

So I decided to go and display text only if option value is greater than 0

if ($options['mg-home-share-btns']['1'] > '0')  :
   $facebook = "facebook" ;
endif;	

the problem is let's say I enabled facebook button, and twitter button, and kept the rest not selected
I will echo the other unselected options and I will get different values than 0, which is causing my code not to work as intended, it should be set to 0 if not active and 1 or different number if active

can any one tell me what I'm doing wrong?

http://support.redux.io/?id=isIzccQFQcwybbg249uvT1fuJwsoUOOc9OXTcAK7hpeVvKLhwDAn7gzdobkkFeOp6xI4XoQvGPkHa5UC4LZUTg%3D%3D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions