Skip to main content
Commonmark migration
Source Link

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'section_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php on line 1332

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'field_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php

 

on line 1378

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'section_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php on line 1332

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'field_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php

 

on line 1378

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'section_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php on line 1332

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'field_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php

on line 1378

Source Link
ewizard
  • 101
  • 8

Wordpress Boilerplate Plugin doesn't see callback functions for add_settings_field and add_settings_section

I am developing my first plugin, and I have an options page setup. Now, I am trying to add some fields.

I have this in xxx-admin.php in admin folder

public function section_callback() {
        echo '<p>Select which areas of content you wish to display.</p>';
    }

    public function field_callback() {
        $html = '<input type="text" id="input_offer" name="questionaire[input_field]" />'; 
        echo $html; 
    }

    public function register_settings() {
        // First, we register a section. This is necessary since all future options must belong to a 
        add_settings_section(
            'my_settings_section',         // ID used to identify this section and with which to register options
            'iPhones',                  // Title to be displayed on the administration page
            'section_callback', // Callback used to render the description of the section
            $this->plugin_name                           // Page on which to add this section of options
        );
         
        // Next, we'll introduce the fields for toggling the visibility of content elements.
        add_settings_field( 
            'input_field',                      // ID used to identify the field throughout the theme
            'Offer',                           // The label to the left of the option interface element
            'field_callback',   // The name of the function responsible for rendering the option interface
            $this->plugin_name,                          // The page on which this option will be displayed
            'my_settings_section'         // The name of the section to which this field belongs
        );

        register_setting( $this->plugin_name, 'input_field' );
    }

In the main class-xxx.php file in the includes folder I have:

private function define_admin_hooks() {

        $plugin_admin = new Questionaire_Admin( $this->get_plugin_name(), $this->get_version() );

    ...

        $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );

    ...

    }

But I am getting:

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'section_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php on line 1332

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'field_callback' not found or invalid function name in /Users/eamonwhite/wordpress-plugin-playground/wp-admin/includes/template.php

on line 1378

How do I get it to see the callback functions?