| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; |
| 3 |
if (!class_exists('WPRWPLoginWhitelabel')) : |
| 4 |
|
| 5 |
class WPRWPLoginWhitelabel { |
| 6 |
private $bvinfo; |
| 7 |
private $label; |
| 8 |
private $logo; |
| 9 |
|
| 10 |
public function __construct() { |
| 11 |
$this->bvinfo = new WPRInfo(new WPRWPSettings()); |
| 12 |
|
| 13 |
$whitelabel_info = $this->bvinfo->getLPWhitelabelInfo(); |
| 14 |
if (isset($whitelabel_info['label']) && is_string($whitelabel_info['label'])) { |
| 15 |
$this->label = $whitelabel_info['label']; |
| 16 |
} |
| 17 |
|
| 18 |
if (isset($whitelabel_info['logo']) && is_string($whitelabel_info['logo'])) { |
| 19 |
$this->logo = $whitelabel_info['logo']; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
public function init() { |
| 24 |
add_action('login_head', array($this, 'custom_login_head')); |
| 25 |
add_filter('login_message', array($this, 'custom_login_message')); |
| 26 |
} |
| 27 |
|
| 28 |
function custom_login_head() { |
| 29 |
if (empty($this->logo) || |
| 30 |
!preg_match('/^data:image\/(jpeg|png);base64,[a-zA-Z0-9\/+]+={0,2}$/', $this->logo)) { |
| 31 |
|
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
$logo_style = 'background-image: none, url("' . esc_attr($this->logo) . '") !important;'; |
| 36 |
|
| 37 |
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 38 |
wp_register_style( 'bv-login-inline', false ); |
| 39 |
wp_enqueue_style( 'bv-login-inline' ); |
| 40 |
|
| 41 |
wp_add_inline_style( |
| 42 |
'bv-login-inline', |
| 43 |
'.login h1 a { ' . $logo_style . ' }' |
| 44 |
); |
| 45 |
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped |
| 46 |
} |
| 47 |
|
| 48 |
function custom_login_message($message) { |
| 49 |
if (empty($this->label)) { |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
return '<div style=" |
| 54 |
text-align: center; |
| 55 |
font-size: 22px; |
| 56 |
font-weight: bold; |
| 57 |
color: #333; |
| 58 |
margin-top: 10px; |
| 59 |
margin-bottom: 10px; |
| 60 |
">' . esc_html($this->label) . '</div>'; |
| 61 |
} |
| 62 |
} |
| 63 |
endif; |