PluginProbe
Redirection / 2.7
Redirection v2.7
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
← All changes | actions/random.php +21 -10 4.22.7 View file →
@@ -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 }