Skip to content

Instantly share code, notes, and snippets.

@mtoensing
Last active October 30, 2017 17:57
Show Gist options
  • Save mtoensing/d1eda089485decc2f6ddef4174efd5bb to your computer and use it in GitHub Desktop.
Save mtoensing/d1eda089485decc2f6ddef4174efd5bb to your computer and use it in GitHub Desktop.
Better Internal Link Search Add-On for out links
<?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