Pass php callback with one argument
Get the solution ↓↓↓I made a function, which accepts one argument. I need to pass a callback to this function with a string argument. like this:
class AdminHelper {
static function print_checkbox($option_name){
$value_cpt_manager=esc_attr(get_option($option_name ));
echo '<input type="checkbox" name="'.$option_name.'" class="regular-text" value="'.$value_cpt_manager.'" placeholder="Your First name" >';
}
}
add_settings_field( "cpt_manager", "First Name",
[AdminHelper::class,'print_checkbox'], "main_menu", "MainSettings_section1", ['label_for'=>"MainSettings"."1",'class'=>'cpt_manager'] );
[AdminHelper::class,'print_checkbox'] would be the callback, but i cant find how i can give it a string argument. So something like [AdminHelper::class,'print_checkbox',"param"]
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: filter_sanitize_string
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.