問題描述
使用 WP 3.2,WordPress 可能有一個新的功能,以將 Link-Quicktags 添加到編輯器。但是我發現了一個功能來設置 link-button 的默認值:
看看 wplink.js Line 278 。
setDefaultValues : function() {
// Set URL and description to defaults.
// Leave the new tab setting as-is.
inputs.url.val( 'http://' );
inputs.title.val( '' );
// Update save prompt.
inputs.submit.val( wpLinkL10n.save );
},
如何設置自定義值的值?
這是可能的,可以幫助我嗎?
感謝 JavaScript 專家的回答。
最佳解決方案
另外還有一個小例子來改變 link-button 中的 url 來使用安裝的博客中的 url 。在頁腳中使用 print JS,而不是通過 wp_enqueue_script()從 js 文件中包含的 – 更快的 vor 開發,特別是對於這個小小的要求,但不是標準和罰款,從另一個答案的例子。
<?php
/**
* Plugin Name: Change URL in Link Popup
* Plugin URI: http://bueltge.de/
* Description: Adds a domain link button to the post editing screen.
* Version: 0.0.1
* Author: Frank Bültge
*/
if ( ! function_exists( 'fb_add_quicktag_button' ) ) {
function fb_add_quicktag_button() {
?>
<script type="text/javascript">
// change link on Link popup in TinyMCE and quicktag popup
( function( $ ) {
if ( typeof wpLink == 'undefined' )
return;
wpLink.setDefaultValues = function () {
$('#url-field').val('<?php echo home_url( '/' ); ?>');
};
} )( jQuery );
</script>
<?php
}
add_action( 'admin_footer-post-new.php', 'fb_add_quicktag_button', 9999 );
add_action( 'admin_footer-post.php', 'fb_add_quicktag_button', 9999 );
}
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。

