Created
September 16, 2012 09:25
-
-
Save thefuxia/3731739 to your computer and use it in GitHub Desktop.
T5 Temporary Internal Links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # -*- coding: utf-8 -*- | |
/** | |
* Plugin Name: T5 Temporary Internal Links | |
* Description: Changes the URLs from the Internal Link dialog to /?p=123. | |
* Plugin URI: | |
* Version: 2012.09.16 | |
* Author: Thomas Scholz | |
* Author URI: http://toscho.de | |
* License: MIT | |
* License URI: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
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" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment