| @@ -1,21 +1,32 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -include_once dirname( __FILE__ ) . '/url.php'; | |
| 3 | +class Random_Action extends Red_Action { | |
| 4 | + function can_change_code() { | |
| 5 | + return true; | |
| 6 | + } | |
| 4 | 7 | |
| 5 | -class Random_Action extends Url_Action { | |
| 6 | - public function process_before( $code, $target ) { | |
| 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 ) { | |
| 7 | 22 | // Pick a random WordPress page |
| 8 | 23 | global $wpdb; |
| 9 | 24 | |
| 10 | 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" ); |
| 11 | - return str_replace( get_bloginfo( 'url' ), '', get_permalink( $id ) ); | |
| 12 | - } | |
| 13 | 26 | |
| 14 | - public function process_after( $code, $target ) { | |
| 15 | - $this->redirect_to( $code, $target ); | |
| 16 | - } | |
| 27 | + $target = str_replace( get_bloginfo( 'url' ), '', get_permalink( $id ) ); | |
| 17 | 28 | |
| 18 | - public function needs_target() { | |
| 19 | - return true; | |
| 29 | + wp_redirect( $target, $code ); | |
| 30 | + exit(); | |
| 20 | 31 | } |
| 21 | 32 | } |