Opened 13 years ago
Closed 10 years ago
#21265 closed defect (bug) (wontfix)
settings_fields() conflict with admin-ajax.php in ajax requests
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4.1 |
Component: | Plugins | Keywords: | needs-patch |
Focuses: | administration | Cc: |
Description
I created a plugin, which uses the function 'settings_fields()' to generate required fields. When I save the plugin options, I decided to use Ajax Requests to save time.
Until 3.3.2 this was working well, but with 3.4.1 admin-ajax.php code update generates a errors. Because "settings_fields()" generate hidden field called "action" and before 3.4.1 admin-ajax.php used $_GETaction? to call ajax action dynamically.
How reproduce:
- Use WP 3.4.1
- Put this code snippet in a .php file in wp root folder:
<?php require 'wp-load.php'; add_action('wp_ajax_mysettings_save' , 'mysettings_save'); function mysettings_save() { //DO SOMETHING USEFULL HERE exit('It worked!'); } ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> <form> <p><input type="text" name="my_settings_field" value=""></p> <button>Save</button> <?php settings_fields('my_settings'); ?> </form> <script> $('form').submit(function(event){ event.preventDefault(); $.post('wp-admin/admin-ajax.php?action=mysettings_save', $(this).serialize(), function(data){ console.log(data); }); }); </script>
In wordpress 3.4.1 field 'action' changes to 'update', because $_REQUESTaction?. In wordpress 3.3.2, field 'action' is 'mysettings_save'.
I have to redo all my work with my plugin with this change in Wordpress 3.4.1.
Attachments (1)
Change History (4)
#3
@
10 years ago
- Keywords needs-patch added
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
Closing as wontfix. Complete lack of interest on the ticket over the last 3 years, and by now, most developers affected would have worked around this in their plugins. Feel free to reopen when more interest re-emerges (particularly if there's a patch)
Simple PHP file with code to generate bug