• I’m trying to make a simple drop down menu in WP_Theme Customer by getting a list of files in true glob(..) (return a list of files) function but it’s not working, they simply don’t display.

    $headers = array('default' => 'Default');
    $flist   = glob($directory . "*.php");
    foreach($flist as $header) {
        $title = current(explode(".", $title)); // Remove .php ext.
        $headers[$header] = ucfirst(str_replace("-"," ", $title)); // Add to array
    }
    
    $wp_customize->add_control('example_select_box', array(
        'settings' => 'themename_theme_options[header_select2]',
        'label'   => 'Select Something:',
        'section' => 'themename_color_scheme',
        'type'    => 'select',
        'choices' =>  $headers,
    ));
    
    var_dump($headers); // See [image 1] of it printing to screen correctly.

    If I remove the glob() function and replace it with just an array of hard coded key=>value pair , it works. Is this a blog problem? or a possibly a bug?

    [image 1]

  • The topic ‘WP Customizer and glob() func.’ is closed to new replies.