PluginProbe
Redirection / 2.6.4
Redirection v2.6.4
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 / redirection-front.php

redirection-front.php in Redirection 2.6.4, at redirection-front.php

51 lines 1.3 KB
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__ ).'/modules/wordpress.php';
4
5 class Redirection {
6 private static $instance = null;
7 private $module;
8
9 static function init() {
10 if ( is_null( self::$instance ) ) {
11 self::$instance = new Redirection();
12 }
13
14 return self::$instance;
15 }
16
17 public function __construct() {
18 $this->module = Red_Module::get( WordPress_Module::MODULE_ID );
19 $this->module->start();
20
21 add_action( Red_Flusher::DELETE_HOOK, array( $this, 'clean_redirection_logs' ) );
22 add_action( 'redirection_url_target', array( $this, 'replace_special_tags' ) );
23 }
24
25 public function clean_redirection_logs() {
26 $flusher = new Red_Flusher();
27 $flusher->flush();
28 }
29
30 /**
31 * From the distant Redirection past. Undecided whether to keep
32 */
33 public function replace_special_tags( $url ) {
34 if ( is_numeric( $url ) ) {
35 $url = get_permalink( $url );
36 } else {
37 $user = wp_get_current_user();
38
39 if ( ! empty( $user ) ) {
40 $url = str_replace( '%userid%', $user->ID, $url );
41 $url = str_replace( '%userlogin%', isset( $user->user_login ) ? $user->user_login : '', $url );
42 $url = str_replace( '%userurl%', isset( $user->user_url ) ? $user->user_url : '', $url );
43 }
44 }
45
46 return $url;
47 }
48 }
49
50 add_action( 'plugins_loaded', array( 'Redirection', 'init' ) );
51