Ticket #5899 (assigned enhancement)

Opened 6 months ago

Last modified 5 months ago

New action -hook for edit.php for plugin authors to create a title

Reported by: nerrad Assigned to: westi (accepted)
Priority: normal Milestone: 2.9
Component: Administration Version: 2.5
Severity: normal Keywords: manageposts action-hook filter-hook has-patch needs-testing
Cc:

Description

For plugin authors hooking into the Manage->posts page it would be nice to be able to create a $h2_[new_title]. (see attached suggestion)

Attachments

edit-h2-action-hook.txt (386 bytes) - added by nerrad on 02/18/08 17:25:21.
Suggested code for implementation
edit.php.diff (1.2 kB) - added by nerrad on 02/18/08 23:40:05.
Patch for edit.php (plugin hooks for title)
edit.php.2.diff (1.2 kB) - added by nerrad on 02/19/08 04:18:24.
Correction so literal string is not a variable. Translation is executed prior to filtering.

Change History

02/18/08 17:25:21 changed by nerrad

  • attachment edit-h2-action-hook.txt added.

Suggested code for implementation

02/18/08 17:28:03 changed by lloydbudd

  • milestone set to 2.6.

Please create a patch.

02/18/08 18:10:55 changed by nerrad

Patch added - any chance of this getting into 2.5? It's just a small change.... (crosses fingers)

02/18/08 18:15:29 changed by nerrad

  • keywords changed from manageposts, edit, plugin, action hook, filter hook to manageposts, edit, plugin, action hook, filter hook, has-patch.

02/18/08 20:20:00 changed by ryan

Filtering the string before translation could break translations. Literal strings, not variables, must be passed to _c().

02/18/08 22:11:46 changed by nerrad

I've tested it and providing the plugin author hooks in correctly it won't break existing translations.

02/18/08 22:22:09 changed by ryan

The patch does not mark the literal string for translation thus that string will not be in the POT file.

02/18/08 23:22:54 changed by nerrad

I'm still confused then, why the existing patch tests successfully with different language files loaded in WP (even after testing with a plugin using the new filter hooks).

Are you saying that automatically generated .pot files will miss this string with the patch (although existing .mo's will work as expected)? Please forgive my lack of knowledge here. Hopefully at least this is a good idea that just needs more work :)

02/18/08 23:39:26 changed by nerrad

Dang it...just noticed the error I made in the code - it's not the patch I tested lol. Uploading new patch now for eval.

02/18/08 23:40:05 changed by nerrad

  • attachment edit.php.diff added.

Patch for edit.php (plugin hooks for title)

02/19/08 00:59:37 changed by ryan

_c( $h2_result_reorder )

This will result in the literal string '$h2_result_order' being placed in the message catalog rather than the actual string we want to be translated. You can only filter a string after it has been translated.

02/19/08 04:18:24 changed by nerrad

  • attachment edit.php.2.diff added.

Correction so literal string is not a variable. Translation is executed prior to filtering.

02/19/08 04:19:14 changed by nerrad

Thanks for the explanation - confirmed what I thought your were meaning but what I still didn't fully understand. Now I do. So, I've translated the string right in the apply_filters call (see new patch/diff). This should work, BUT it will require docs to indicate to plugin authors using this hook that they need to run the translation on the string before returning it. Make sense?

02/19/08 04:27:54 changed by nerrad

  • keywords changed from manageposts, edit, plugin, action hook, filter hook, has-patch to manageposts, edit.php, plugin, action hook, filter hook, has-patch.

03/06/08 03:14:48 changed by nerrad

  • keywords changed from manageposts, edit.php, plugin, action hook, filter hook, has-patch to manageposts action-hook filter-hook has-patch needs-testing.

03/13/08 19:13:27 changed by westi

  • owner changed from anonymous to westi.
  • status changed from new to assigned.
  • severity changed from major to normal.