Last active
August 29, 2015 14:23
-
-
Save supercleanse/84c2ac418f0034a9d523 to your computer and use it in GitHub Desktop.
Creates a pretty link from a target url. Returns a pretty link url on success and false on failure.
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 | |
/** Creates a pretty link from a target url. Returns a pretty link url on success and false on failure. | |
* Assumes that Pretty Link is installed on your WordPress website. | |
*/ | |
function create_my_pretty_link($target_url) { | |
if( false != ( $link_id = prli_create_pretty_link($target_url) ) ) { | |
return prli_get_pretty_link_url($link_id); | |
} | |
return false; | |
} | |
/** Gets (if it already exists) or creates a pretty link from a target url. | |
* Returns a pretty link url on success and false on failure. | |
* Assumes that Pretty Link is installed on your WordPress website. | |
*/ | |
function get_or_create_my_pretty_link($target_url) { | |
global $prli_link; | |
if( ( false != ( $link_id = $prli_link->find_first_target_url($target_url) ) ) || | |
( false != ( $link_id = prli_create_pretty_link($target_url) ) ) ) { | |
return prli_get_pretty_link_url($link_id); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment