Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Public Prefix-N-Shorten
- Plugin URI: http://yourls.org/
- Description: Redirect "Prefix n' Shorten" bookmarklets to public interface
- Version: 1.0
- Author: Ozh
- Author URI: http://ozh.org/
- */
- // URL of your public interface, with query parameter to which the long URL will be passed
- // This URL must contain a query string with "parameter equals %" (eg "url=%")
- define( 'OZH_PUBPNF_URL', 'http://shor.rt/public.php?url=%' );
- yourls_add_action( 'load_template_redirect_admin', 'ozh_pubpnf' );
- function ozh_pubpnf( $args ) {
- // Long URL requested?
- $url = $args[0];
- // If logged in and don't want to change behavior for logged in users, do nothing
- if( yourls_is_valid_user() )
- return;
- // Otherwise, interrupt
- $redirect = str_replace( '%', rawurlencode( $url ), OZH_PUBPNF_URL );
- yourls_redirect( $redirect, 302 );
- die();
- }
- /**
- Usage:
- you must have a public interface up and running (for instance rename the provided sample public interface to public.php)
- This public interface must accept a long URL as a query parameter (for instance 'url' as in
- the sample provided). Edit OZH_PUBPNF_URL to reflect the public interface location and the parameter name.
- **/
Add Comment
Please, Sign In to add comment