Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using the code by Chip Bennett to create a settings options page for my plugin. The problem is that I am getting a Warning error as indicated below that I cannot figure it out. Any help is appreciated.

Warning: call_user_func(ch_settings_defaults_style_section_text) [function.call-user-func]: First argument is expected to be a valid callback in /home/loc123/public_html/domaindvb.com/wp-admin/includes/template.php on line 1083

    <?php
function ch_admin_options_page() {
    global $pagenow;
 ?>
    <div class="wrap">
<?php
        /* Calls function to add tabs */
        ch_admin_options_page_tabs ();

        /* adds the "updated" admin notice */
        if ( isset( $_GET['settings-updated'] ) ) {
            echo "<div class='updated'><p>Custom Header settings updated successfully.</p></div>";
        }
?>
        <form action="options.php" method="post">   
            <?php
            settings_fields('mycustom_options');
            do_settings_sections('mycustom');
            ?>
        <?php
        if ( 'themes.php' == $pagenow && isset( $_GET['page'] ) && 'ch-settings' == $_GET['page'] ) :
             if ( isset ( $_GET['tab'] ) ) :
                  $tab = $_GET['tab'];
             else:
                  $tab = 'general';
             endif;
             switch ( $tab ) :
                  case 'general' :
                require ('options-register-defaults.php') ; 
                break;
                  case 'Home Page' :
                require( 'options-register-homepage.php' );
                break;
             endswitch;
        endif; 
         ?>
        <p></br></p>

        <input name="mycustom_options[submit-<?php echo $tab; ?>]" type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'default'); ?>" />

        <?php /* Add a Reset Button */ ?>
        <input name="mycustom_options[reset-<?php echo $tab; ?>]" type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults', 'default'); ?>" />

        </form>

    </div>
<?php
}
?>

<?php
add_action('admin_init', 'chr_settings');
function chr_settings() {

    /*  register_setting( $option_group, $option_name, $sanitize_callback )- Associates an option group passed to settings_fields with database entry */
    register_setting( 'mycustom_options', 'mycustom_options', 'ch_options_validate' ); 
    add_settings_section('ch_settings_defaults_style', 'Style Options', 'ch_settings_defaults_style_section_text', 'mycustom');

}
?>

File: options-register-defaults.php

<?php
function ch_settings_defaults_style_section_text() { ?>

     <p><?php _e( 'Manage Header options for the Oenology Theme. Refer to the contextual help screen for descriptions and help regarding each theme option.', 'mycustom' ); ?></p>
<?php 
}
?>
share|improve this question
    
So where and when is the options-register-defaults.php included? –  t31os Apr 25 '13 at 17:24
add comment

1 Answer

You should include your options-register-defaults.php to make the callback available.

function chr_settings() {

require_once 'options-register-defaults.php'; // add path to file

    /*  register_setting( $option_group, $option_name, $sanitize_callback )- Associates an option group passed to settings_fields with database entry */
    register_setting( 'mycustom_options', 'mycustom_options', 'ch_options_validate' ); 
    add_settings_section('ch_settings_defaults_style', 'Style Options', 'ch_settings_defaults_style_section_text', 'mycustom');

}
share|improve this answer
    
Thanks, will try changing the location where it is included. –  Joe Apr 26 '13 at 19:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.