Home › Forums › Feature Requests › Button to Reset to Default Values › Reply To: Button to Reset to Default Values
I’m going to look at this one piece at a time. The first part is where the function for enqueuing the script. My function was just meant as an example and needed you do supply your own values
///////////////////
add_action('admin_enqueue_scripts', 'my_admin_enqueue_scripts');
function my_admin_enqueue_scripts() {
$screen = get_current_screen();
if ($screen->id == 'settings_page_my-options_page') {
$handle = 'my-script-handle';
// the $src value needs to be set to point to
// your script. Since you are doing this in the
// theme function.php file is should look something
// like the following. Note that you still need to
// update the path and file name to match your own
$src = get stylesheet directory uri().'/path/to/script/script-name.js';
$deps = array('acf-input', 'acf-pro-input');
wp_register_script($handle, $src, $deps);
// your should change the object name to
// match what your doing
$object_name = 'my_options_object';
$data = array(
'_ajax_url' => admin_url('admin-ajax.php'),
// your should use a unique nonce to create the nonce
'_nonce' => wp_create_nonce('my_options_reset_nonce')
);
wp_localize_script($handle, $object_name, $data);
wp_enqueue_script($handle);
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.