Created
April 28, 2014 00:17
-
-
Save thefuxia/11358809 to your computer and use it in GitHub Desktop.
Class Mlp_Redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Class Mlp_Redirect | |
* | |
* @version 2014.04.28 | |
* @author Inpsyde GmbH, toscho | |
* @license GPL | |
*/ | |
class Mlp_Redirect { | |
/** | |
* @var Mlp_Module_Manager_Interface | |
*/ | |
private $modules; | |
/** | |
* @var string | |
*/ | |
private $image_url; | |
/** | |
* @var string | |
*/ | |
private $option = 'inpsyde_multilingual_redirect'; | |
/** | |
* Constructor | |
* | |
* @param Mlp_Module_Manager_Interface $modules | |
* @param string $image_url | |
*/ | |
public function __construct( Mlp_Module_Manager_Interface $modules, $image_url ) { | |
$this->modules = $modules; | |
$this->image_url = $image_url; | |
} | |
/** | |
* Determine current state and actions, call subsequent methods. | |
* | |
* @return void | |
*/ | |
public function setup() { | |
if ( ! $this->register_setting() ) | |
return; | |
if ( ! is_admin() ) { | |
$this->frontend_redirect(); | |
return; | |
} | |
$this->site_settings(); | |
if ( is_network_admin() ) | |
$this->activation_column(); | |
} | |
/** | |
* Redirect visitors to the best matching language alternative | |
* | |
* @return void | |
*/ | |
private function frontend_redirect() { | |
$controller = new Mlp_Redirect_Frontend( $this->option ); | |
$controller->setup(); | |
} | |
/** | |
* Show the redirect status in the sites list | |
* | |
* @return void | |
*/ | |
private function activation_column() { | |
$controller = new Mlp_Redirect_Column( $this->option, $this->image_url ); | |
$controller->setup(); | |
} | |
/** | |
* Site specific settings | |
* | |
* @return void | |
*/ | |
private function site_settings() { | |
$controller = new Mlp_Redirect_Site_Settings( $this->option ); | |
$controller->setup(); | |
} | |
/** | |
* Register the settings. | |
* | |
* @return bool | |
*/ | |
private function register_setting() { | |
$controller = new Mlp_Redirect_Registration( $this->modules ); | |
return $controller->setup(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment