0

I am working with customize register on sage wordpress

//adding setting for copyright text
add_action('customize_register', 'theme_copyright_customizer');

function theme_copyright_customizer($wp_customize) {
    //adding section in wordpress customizer   
    $wp_customize->add_section('copyright_extras_section', array(
        'title'          => 'Copyright Text Section'
    ));

    //adding setting for copyright text
    $wp_customize->add_setting('text_setting', array(
        'default'        => 'Default Text For copyright Section',
    ));

    $wp_customize->add_control('text_setting', array(
        'label'   => 'Copyright text',
        'section' => 'copyright_extras_section',
        'type'    => 'text',
    ));
}

This shows me

call_user_func_array() expects parameter 1 to be a valid callback, class xxx not found

Do anyone has an idea?

2
  • 1
    is your code in a namespace? What was class xxx? I see you removed it to hide the value, but the value is important and critical to answering the question
    – Tom J Nowell
    Jun 30, 2022 at 9:43
  • Also remember that 3rd party plugin/theme dev support is offtopic here so if any knowledge of Sage is necessary to answer this question then it must be closed as offtopic
    – Tom J Nowell
    Jun 30, 2022 at 9:44

1 Answer 1

0

This is the solution for my question

    add_action('customize_register', function ($wp_customize) {
        $wp_customize->add_section('copyright_extras_section', array(
            'title'          => 'Copyright Text Section'
        ));
    
        //adding setting for copyright text
        $wp_customize->add_setting('text_setting', array(
            'default'        => 'Default Text For copyright Section',
        ));
    
        $wp_customize->add_control('text_setting', array(
            'label'   => 'Copyright text',
            'section' => 'copyright_extras_section',
            'type'    => 'text',
        ));
    });
1
  • This seems like your code was it a class and you second argument for the add_action was incorrect. Your solution will work but consider not using anonymous functions as callbacks because you can remove_action those. See this developer.wordpress.org/reference/functions/add_action/… to know how to use callbacks with actions/filters inside classes or namespaces, there are many resources for working with classes and events in wordpress Jun 30, 2022 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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