该对话框中的链接由wp_ajax_wp_link_ajax()
(参见wp-admin/includes/ajax-actions.php
, 在Codex或queryposts上没有页面。com来实现该功能)。
更改链接过滤器\'page_link\'
, \'post_type_link\'
, \'post_link\'
也许吧\'attachment_link\'
after check_ajax_referer()
被要求采取行动\'internal-linking\'
.
好吧,听起来有点复杂,但其实很简单。:)
GitHub上的插件:https://gist.github.com/3731739
add_action( \'check_ajax_referer\', \'t5_temporary_internal_links\', 10, 1 );
/**
* Turn permalinks into dynamic links.
*
* @param string $action_or_link Action when called per \'check_ajax_referer\',
* later the permalink.
* @param object|integer $post
* @wp-hook check_ajax_referer
* @wp-hook page_link
* @wp-hook attachment_link
* @wp-hook post_type_link
* @wp-hook post_link
* @since 2012.09.16
* @return string
*/
function t5_temporary_internal_links( $action_or_link, $post = 0 )
{
if ( \'check_ajax_referer\' === current_filter()
and \'internal-linking\' === $action_or_link
)
{
add_filter( \'page_link\', __FUNCTION__, 10, 2 );
// You cannot search for attachments in this dialog,
// but a plugin might have changed that, so …
add_filter( \'attachment_link\', __FUNCTION__, 10, 2 );
add_filter( \'post_type_link\', __FUNCTION__, 10, 2 );
add_filter( \'post_link\', __FUNCTION__, 10, 2 );
return;
}
$id = is_object( $post ) ? $post->ID : $post;
return home_url( "?p=$id" );
}
但是…当您更改永久链接时,无论如何都必须在服务器配置文件中创建重定向以重定向现有URL。所以我不确定是否真的需要这个插件。