forked from drockney/append-qs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.php
More file actions
35 lines (29 loc) · 899 Bytes
/
plugin.php
File metadata and controls
35 lines (29 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/*
Plugin Name: Append Query String
Plugin URI: https://github.com/drockney/append-qs
Description: Appends a query string to the URL
Version: 1.0
Author: Doug Rockney
Author URI: https://github.com/drockney
*/
// Hook our custom function into the 'pre_redirect' event
yourls_add_filter('redirect_location', 'append_qs_redirect' );
// Our custom function that will be triggered when the event occurs
function append_qs_redirect($url) {
parse_str($_SERVER['QUERY_STRING'], $query);
if (isset($query)) {
$appendme .= '?';
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($query));
foreach ($it as $key=>$val) {
if (isset($key)) {
$appendme .= $key;
}
if (isset($val)) {
$appendme .= '='.$val;
}
}
return $url.$appendme;
}
}
?>