Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#4563 closed defect (bug) (worksforme)

actions `admin_print_scripts-*' and `admin_head-*' useless

Reported by: reedom Owned by: westi
Milestone: Priority: normal
Severity: normal Version: 2.2.1
Component: Administration Keywords: hooks
Focuses: Cc:


There are some problems.

  1. The code doesn't consider of localized menu string. add_menu_page() in admin-functions.php uses hook name from menu title.
    so a hook of an option page's custom plugin menu in Japanese turns like:


Not only gettext-ed string but also url encoded. Nonsense.

  1. Non unique hooks "admin_print_scripts-" and "admin_head-". When plugins calls add_options_page() without the last argument(hook function name), those hooks called just as literaly the above: without any plugins name.
    I think the patch of ticket:3835 should be applied.
    For plugins like need to insert <script> tag only to their setting page, "admin_print_scripts-<my-plugin>" hook is better than
    "admin_print_scripts", I think.

Attachments (1)

wp-ticket-4563-demo.tar.gz (1.2 KB) - added by reedom 14 years ago.

Download all attachments as: .zip

Change History (7)

#1 @foolswisdom
14 years ago

  • Milestone set to 2.4 (future)

#2 @westi
14 years ago

  • Keywords reporter-feedback added
  • Owner changed from anonymous to westi
  • Status changed from new to assigned

Please provide a simple example plugin which demonstrates these issues to help us understand the issue.

#3 @reedom
14 years ago

Well, made 3 files. Archived in ticket-4563-demo.tar.gz.

5 steps:

  1. please install the http://svn.automattic.com/wordpress-i18n/ja_JP/trunk/messages/ja.mo Japanese .mo file and set WPLANG to "ja".
  2. extract ticket-4563-demo.tar.gz into the plugins directory.
  3. apply patch file plugin.php.diff in the archive against wp-includes/plugin.php. This makes apply_filters() and do_action()' log their arguments to /tmp/wp_ticket_4563.log`.
  4. for the problem #1 of my first post, in the admin panel activate the plugin #4563-1, click [options] - [#4563-1], then grep as the option page displays.
  5. for the problem #2, deactivate the plugin #4563-1 and activate #4563-2, click [options] - [#4563-2], then grep as the option page displays.

#4 @m0n5t3r
14 years ago

this can be worked around by constructing the action name like this:

sanitize_title(__("Options")) . "_page_$myname";

maybe $admin_page_hooks should be built before calling load_default_textdomain?

#5 @m0n5t3r
14 years ago

  • Cc iacobs@… added

#6 @westi
14 years ago

  • Keywords reporter-feedback removed
  • Milestone 2.4 deleted
  • Resolution set to worksforme
  • Status changed from assigned to closed

admin_print_script and admin_page_hook are both generated based on the $file argument passed to add_menu_page and so will not contain a translated string but a plugin defined unique one.

Closing as works for me

Note: See TracTickets for help on using tickets.