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

18 lines 530 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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