PluginProbe
Redirection / 2.6.5
Redirection v2.6.5
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.6.5, at actions/random.php

33 lines 758 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Random_Action extends Red_Action {
4 function can_change_code() {
5 return true;
6 }
7
8 function can_perform_action() {
9 return false;
10 }
11
12 function action_codes() {
13 return array(
14 301 => get_status_header_desc( 301 ),
15 302 => get_status_header_desc( 302 ),
16 307 => get_status_header_desc( 307 ),
17 308 => get_status_header_desc( 308 ),
18 );
19 }
20
21 function process_before( $code, $target ) {
22 // Pick a random WordPress page
23 global $wpdb;
24
25 $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" );
26
27 $target = str_replace( get_bloginfo( 'url' ), '', get_permalink( $id ) );
28
29 wp_redirect( $target, $code );
30 exit();
31 }
32 }
33