使用WordPress 3.5+媒体上传器,还有另一种方法。所有字符串都在页面底部本地化为:
<script type=\'text/javascript\'>
/* <![CDATA[ */
var _wpMediaViewsL10n = {
"url":"URL",
"addMedia":"Add Media",
"search":"Search",
"select":"Select",
"cancel":"Cancel",
"selected":"%d selected",
"dragInfo":"Drag and drop to reorder images.",
"uploadFilesTitle":"Upload Files",
"uploadImagesTitle":"Upload Images",
"mediaLibraryTitle":"Media Library",
"insertMediaTitle":"Insert Media",
"createNewGallery":"Create a new gallery",
"returnToLibrary":"\\u2190 Return to library",
"allMediaItems":"All media items",
"noItemsFound":"No items found.",
"insertIntoPost":"Insert into post",
"uploadedToThisPost":"Uploaded to this post",
// ET CETERA
};
/* ]]> */
</script>
在上
document.ready
, 我们修改对象:
add_action(\'admin_footer\', function()
{
?>
<script type="text/javascript">
// or without jQuery: http://stackoverflow.com/q/799981
jQuery(document).ready( function($) {
_wpMediaViewsL10n.insertIntoPost = \'Gotchya!\';
});
</script>
<?php
});