Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#9585 closed defect (bug) (duplicate)

wp-ajax-response not loaded !

Reported by: arena Owned by: anonymous
Priority: normal Milestone: 2.8
Component: Administration Version:
Severity: normal Keywords:
Cc:

Description

Well, i do not know if it is a wp bug but i am asking for an external eye !

One of the main changes in 2.8 admin is that javascript can be inserted in the footer.

In order to comply with the current wp admin screen, i intended to do so for my plugin (MailPress)

I have been comparing the 'new post' html source with the 'new mail' html source and for the javascript the result looks very similar,
except that in my plugin, i am loading a specific "handle"
for wp-ajax-response called mp-ajax-response :

$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
wp_register_script( 'mp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1);
wp_localize_script( 'mp-ajax-response', 'wpAjax', array( 'noPerm' => __('Email was not sent AND/OR Update database failed','MailPress'), 
                                                         'broken' => __('An unidentified error has occurred.'), 
                                                         'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};' ) );

I have the following in the html source :

<script type='text/javascript' src='http://127.0.0.1/wp28/wp-admin/load-scripts.php?c=0&amp;load=hoverIntent,common,jquery-color,schedule,mp-ajax-response,jquery-ui-core,jquery-ui-sortable,postbox,thickbox&amp;ver=3a76a22d74c994ad03412a0aa610805d'></script>

So mp-ajax-response is appearing in the list of handles loaded except that when i look at the js file generated,

i can see schedule js code, jquery-ui-core js code and no wp-ajax-response js code !

The result is things like :

wpAjax.parseAjaxResponse is not a function

Change History (2)

  • Resolution set to duplicate
  • Status changed from new to closed

What exactly do you want to achieve by changing the handle for a default script? The problem is that load-scripts.php doesn't load the rest of WordPress and cannot see your changes while loading and concatenating the scripts as it reads the handles/paths from script-loader.

If you want to use a modified version of wp-ajax-response, copy it to your plugin's directory and load it as external script. If not, just queue it.

You can change some of the i18n strings there at runtime:

<script type="text/javascript">
wpAyax['broken'] = (your string...);
...

Best hook for this is do_action("admin_footer-$hook_suffix");.

Note: See TracTickets for help on using tickets.