Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Dropdown option in function

$
0
0

I am in the process of converting a widget plugin where the user inputs the settings via the widget page to where the user inputs the settings via an admin page. Everything is working fine, apart from the dropdown option.

This is the settings field callback with the dropdown:

<?php
public function socialiconsselect_callback()
{
printf(
'<select id="socialiconsselect" name="social_contact_display_options[socialiconsselect]" />',
$options = array('Light', 'Dark', 'Modern Flat', 'Cute', 'Shaded', 'Simple Flat', 'Circle', 'Vintage', 'Retro', 'Retro 2', 'Wooden', 'CSS and HTML5 set 1', 'CSS and HTML5 set 2')
foreach ($options as $option) {
'<option value="' . $option . '" id="' . $option . '"', $socialiconsselect == $option ? ' selected="socialiconsselect"' : '', '>', $option, '</option>',
}
'</select>',
isset( $this->options['socialiconsselect'] ) ? esc_attr( $this->options['socialiconsselect']) : ''
);
}

Can anyone see what I have done wrong?

 

Put this through PHPStorm and corrected the syntax errors it stated, which gave me this:

public function socialiconsselect_callback()
{
    printf(
        '<select id="socialiconsselect" name="social_contact_display_options[socialiconsselect]" />',
        ($options = array('Light', 'Dark', 'Modern Flat', 'Cute', 'Shaded', 'Simple Flat', 'Circle', 'Vintage', 'Retro', 'Retro 2', 'Wooden', 'CSS and HTML5 set 1', 'CSS and HTML5 set 2')));
foreach ($options as $option) {
   '<option value="' . $option . '" id="' . $option . '"'; $socialiconsselect == $option ? ' selected="socialiconsselect"' : ''; '>'; $option;
    '</option>';
}
        '</select>';
        isset( $this->options['socialiconsselect'] ) ? esc_attr( $this->options['socialiconsselect']) : ''
    ;
}

The page now loads, but still does not show any options in the dropdown..


Viewing all articles
Browse latest Browse all 13200

Trending Articles