## plugins – Question: It is possible to pass $args that sent by add_settings_field() inside another function? Question I’m trying To do my plugin Setting with OOP PHP when I’m Creating Setting Filed it sends$args so I can use it in their function, but when I call this function in another place it is for $args and it’s undefined. here are my codes: • Please Look At the Last Chapter and see the $args

    add_settings_field(
'st-test-color',
__('Color', 'st-search'),
'st_color_ca',
'st-test',
'st-test-settings-section-2',
array(
'name'      => 'color_css',
'id'        => 'st-test-color',
'class'     => 'st-test-color',
'options'   => $st_test, ) ); class STTEST { public function st_color_ca($args) {
global $stsearch_style_get_opts; ?> <label for="<?php echo esc_attr($args['id']); ?>">
<input type="color" name="stsearch_style_opts[<?php echo esc_attr($args['name']); ?>]" > </label> <?php } }  Now Let’s Put the function inside the Form  function myform() { <form action="options.php" method="post"> <?php settings_errors(); settings_fields( 'st-search-style' ); // Call the Function the color$class = new STTEST();
echo $class->st_color_ca($args); <---- THIS \$args is not undefined!!

?>
</form>
}


How I can solve this problem with the correct way?

0
6 days 2022-05-13T15:39:35-05:00 0 Answers 0 views 0