It is possible to pass $args that sent by add_settings_field() inside another function?
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 Setting:
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?
Topic settings-api theme-options plugin-development Wordpress
Category Web