Last active
October 30, 2017 17:57
-
-
Save mtoensing/d1eda089485decc2f6ddef4174efd5bb to your computer and use it in GitHub Desktop.
Better Internal Link Search Add-On for out links
This file contains hidden or 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 | |
/** | |
* Plugin Name: MarcTV Out Linker | |
* Description: Adds Links | |
* Plugin URI: https://marc.tv | |
* Version: 0.0.1 | |
*/ | |
function marctv_out_shortscuts( $shortcuts ) { | |
$lines = file(ABSPATH . '/out/redirects.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); | |
foreach ($lines as $line_num => $line) { | |
$outlink = explode(",", htmlspecialchars($line)); | |
$homeurl = home_url(); | |
$shortcuts[$outlink[0]] = array( | |
'title' => $outlink[0], | |
'permalink' => $homeurl . '/out/' . $outlink[0], | |
); | |
}; | |
return $shortcuts; | |
} | |
add_filter( 'better_internal_link_search_shortcuts', 'marctv_out_shortscuts' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment