summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/theme-tools/random-redirect.php')
-rw-r--r--plugins/jetpack/modules/theme-tools/random-redirect.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/jetpack/modules/theme-tools/random-redirect.php b/plugins/jetpack/modules/theme-tools/random-redirect.php
index a4f29d80..2e58bee6 100644
--- a/plugins/jetpack/modules/theme-tools/random-redirect.php
+++ b/plugins/jetpack/modules/theme-tools/random-redirect.php
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Random Redirect
-Plugin URI: http://wordpress.org/extend/plugins/random-redirect/
+Plugin URI: https://wordpress.org/extend/plugins/random-redirect/
Description: Allows you to create a link to yourblog.example.com/?random which will redirect someone to a random post on your blog, in a StumbleUpon-like fashion.
Version: 1.2-wpcom
Author: Matt Mullenweg
@@ -31,6 +31,8 @@ function jetpack_matt_random_redirect() {
if ( is_author() ) {
$random_author_name = get_the_author_meta( 'user_login' );
$random_author_query = 'AND user_login = "' . $random_author_name . '"';
+ } else {
+ $random_author_query = '';
}
// Acceptable URL formats: /[...]/?random=[post type], /?random, /&random, /&random=1
@@ -65,7 +67,7 @@ function jetpack_matt_random_redirect() {
} else {
$random_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_password = '' AND post_status = 'publish' %s ORDER BY RAND() LIMIT 1", $post_type, $random_author_query ) );
}
-
+
$permalink = get_permalink( $random_id );
wp_safe_redirect( $permalink );
exit;