| Server IP : 81.2.241.106 / Your IP : 216.73.216.165 Web Server : Apache/2.4.67 (Debian) System : Linux tranq-f.bakta.org 5.10.0-45-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : lisky ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/lisky/wp-content/plugins/weglot/src/ |
Upload File : |
<?php
namespace WeglotWP;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use Exception;
use WeglotWP\Models\Hooks_Interface_Weglot;
/**
* Init plugin
*
* @since 2.0
*/
class Bootstrap_Weglot {
/**
* List actions WordPress
* @since 2.0
* @var array<int|string,mixed>
*/
protected $actions = array();
/**
* List class services
* @since 2.0
* @var array<int|string,mixed>
*/
protected $services = array();
/**
* Set actions
*
* @since 2.0
* @param array<int|string,mixed> $actions
* @return Bootstrap_Weglot
*/
public function set_actions( $actions ) {
$this->actions = $actions;
return $this;
}
/**
* Set services
* @since 2.0
* @param array<int|string,mixed> $services
* @return Bootstrap_Weglot
*/
public function set_services( $services ) {
foreach ( $services as $service ) {
$this->set_service( $service );
}
return $this;
}
/**
* Set a service
* @since 2.0
* @param string $service
* @return Bootstrap_Weglot
*/
public function set_service( $service ) {
$name = explode( '\\', $service );
end( $name );
$key = key( $name );
$this->services[ $name[ $key ] ] = $service;
return $this;
}
/**
* Get one service by classname
* @param string $name
* @return object
* @throws Exception
* @since 2.0
*/
public function get_service( $name ) {
$parts = explode( '\\', $name );
$key = end( $parts );
if ( ! array_key_exists( $key, $this->services ) ) {
throw new Exception( 'Service : ' . $name . ' not exist' );
}
if ( is_string( $this->services[ $key ] ) ) {
$this->services[ $key ] = new $this->services[ $key ]();
}
return $this->services[ $key ];
}
/**
* Init plugin
* @since 2.0
* @return void
*/
public function init_plugin() {
foreach ( $this->actions as $action ) {
$action = new $action();
if ( $action instanceof Hooks_Interface_Weglot ) {
$action->hooks();
}
}
}
/**
* Activate plugin
* @since 2.0
* @return void
*/
public function activate_plugin() {
foreach ( $this->actions as $action ) {
$action = new $action();
if ( ! method_exists( $action, 'activate' ) ) {
continue;
}
$action->activate();
}
}
/**
* Deactivate plugin
* @since 2.0
* @return void
*/
public function deactivate_plugin() {
foreach ( $this->actions as $action ) {
$action = new $action();
if ( ! method_exists( $action, 'deactivate' ) ) {
continue;
}
$action->deactivate();
}
}
}