I'm assembling a WordPress theme options page. I'm trying to puzzle out if your url joined right into a text area passes a validation. Whether it does not, I wish to display a note towards the top of the admin page to fix what's joined.

Within this situation, I wish to display File type should have the file extension .digital, .jpeg, .presen or .png towards the top of the page whenever a user makes its way into personal files with every other extension. This message is at an if statement, but it's turning up no matter what's typed in to the area. I must understand what mistake I'm making here or maybe the input is even being validated.

This is actually the code inside the initialization from the options page

add_action('admin_init', 'theme_admin_init');

function theme_admin_init() {
    register_setting(
        'coolorange_theme_options',
        'coolorange_options',
        'coolorange_options_validate'
    );
    // what each parameter represents:
    // add_settings_field($id, $title, $callback, $page, $section, $args);
    add_settings_section(
        'coolorange_logo_main',
        'Logo Section Settings',
        'logo_section_text',
        'coolorange'
    );
    add_settings_field(
        'upload_image_button',
        '<strong>Upload logo to the Media Folder</strong>',
        'file_upload_button',
        'coolorange',
        'coolorange_logo_main'
    ); // Upload Logo button
    add_settings_field(
        'logo_textfields',
        '<strong>Logo location</strong>',
        'file_location',
        'coolorange',
        'coolorange_logo_main'
    ); // logo url, width and height text fields
    add_settings_field(
        'restore_selectbox',
        '<strong>Restore original heading</strong>',
        'restore_dropdown',
        'coolorange',
        'coolorange_logo_main'
    );
}

This is actually the code for that input box (this really is inside a file_location() function):

<strong>File URL:</strong> <input id="image_url" type="text" value="<?php $options['image_url']; ?>" size="60" name="coolorange_options[image_url]" />

Which is the validation code:

//Validation
function coolorange_options_validate($input) {
    $options = get_option('coolorange_theme_options');
    //check filetypes for image url
    $options['image_url'] = trim($input['image_url']);
    if ( !preg_match ( '/\.(gif|jpg|jpeg|png)$/', $options['image_url'] ) ) { //opens if statement
        $options['image_url'] = ''; 
        echo '<div id="message" style="color: red;"><p>File type must have the file extension .jpg, .jpeg, .gif or .png</p></div>';
    } // closes if statement
    else {

    }
    return $options;
}

add_action('admin_notices', 'coolorange_options_validate'); 
//shows validation errors at the top of the page

Appears like problem is incorporated in the html title in following line

<strong>File URL:</strong> <input id="image_url" type="text" value="<?php $options['image_url']; ?>" size="60" name="coolorange_options[image_url]" />

It ought to be like following

<strong>File URL:</strong> <input id="image_url" type="text" value="<?php $options['image_url']; ?>" size="60" name="coolorange_theme_options[image_url]" />

When you are expecting $options = get_option('coolorange_theme_options');.