Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created April 28, 2014 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefuxia/11358809 to your computer and use it in GitHub Desktop.
Save thefuxia/11358809 to your computer and use it in GitHub Desktop.
Class Mlp_Redirect
<?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