| 1 |
<?php |
| 2 |
|
| 3 |
include_once dirname( __FILE__ ) . '/url.php'; |
| 4 |
|
| 5 |
class Random_Action extends Url_Action { |
| 6 |
public function process_before( $code, $target ) { |
| 7 |
// Pick a random WordPress page |
| 8 |
global $wpdb; |
| 9 |
|
| 10 |
$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 |
|
| 14 |
public function process_after( $code, $target ) { |
| 15 |
$this->redirect_to( $code, $target ); |
| 16 |
} |
| 17 |
} |
| 18 |
|