PluginProbe
Redirection / 2.2.10
Redirection v2.2.10
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / actions / random.php

random.php in Redirection 2.2.10, at actions/random.php

51 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Redirection
4 *
5 * @package Redirection
6 * @author John Godley
7 * @copyright Copyright (C) John Godley
8 **/
9
10 /*
11 ============================================================================================================
12 This software is provided "as is" and any express or implied warranties, including, but not limited to, the
13 implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall
14 the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or
15 consequential damages (including, but not limited to, procurement of substitute goods or services; loss of
16 use, data, or profits; or business interruption) however caused and on any theory of liability, whether in
17 contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of
18 this software, even if advised of the possibility of such damage.
19
20 For full license details see license.txt
21 ============================================================================================================ */
22
23 class Random_Action extends Red_Action
24 {
25 function can_change_code () { return true; }
26 function can_perform_action () { return false; }
27
28 function action_codes ()
29 {
30 return array
31 (
32 301 => get_status_header_desc (301),
33 302 => get_status_header_desc (302),
34 307 => get_status_header_desc (307)
35 );
36 }
37
38 function process_before ($code, $target)
39 {
40 // Pick a random WordPress page
41 global $wpdb;
42 $id = $wpdb->get_var ("SELECT ID FROM {$wpdb->prefix}posts WHERE post_status='publish' AND post_password='' AND post_type='post' ORDER BY RAND() LIMIT 0,1");
43
44 $target = str_replace (get_bloginfo ('url'), '', get_permalink ($id));
45
46 wp_redirect ($target, $code);
47 exit ();
48 }
49 }
50
51 ?>