Support for site verification codes
This commit is contained in:
74
modules/KompassSettings/Controllers/SettingsPage.php
Normal file
74
modules/KompassSettings/Controllers/SettingsPage.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\KompassSettings\Controllers;
|
||||
|
||||
|
||||
class SettingsPage
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_options_page(BDP_LV_PLUGIN_SLUG . '-kompass',
|
||||
__('kompass', BDP_LV_PLUGIN_SLUG) . ' - ' . __('Settings', BDP_LV_PLUGIN_SLUG),
|
||||
'manage_options',
|
||||
BDP_LV_PLUGIN_SLUG . '-Kompass-settings',
|
||||
[$this, 'option_page'],2048);
|
||||
}
|
||||
|
||||
|
||||
public function option_page() {
|
||||
bdp_kompass_load_plugin_textdomain();
|
||||
$showMessage = null;
|
||||
$tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'tab1';
|
||||
if (isset($_REQUEST['update_options']) && $_REQUEST['update_options'] == true) {
|
||||
switch ($tab) {
|
||||
case 'tab1':
|
||||
break;
|
||||
|
||||
case 'tab2':
|
||||
update_option('kompass_seo_google_verification', $_POST['kompass_seo_google_verification']);
|
||||
update_option('kompass_seo_bing_verification', $_POST['kompass_seo_bing_verification']);
|
||||
$showMessage = __('The settings were saved.', BDP_LV_PLUGIN_SLUG);
|
||||
break;
|
||||
}
|
||||
|
||||
if (null !== $showMessage) {
|
||||
echo '<div class="notice notice-success" style="padding: 5px 10px;">';
|
||||
echo $showMessage;
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
bdp_kompass_load_plugin_textdomain();
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h1 class="wp-heading-inline">
|
||||
<?= __('kompass', BDP_LV_PLUGIN_SLUG); ?> - <?= __('Settings', BDP_LV_PLUGIN_SLUG); ?></h1>
|
||||
<hr class="wp-header-end">
|
||||
<?= kompass_settings_print_tab_header($tab); ?>
|
||||
|
||||
<div class="tab-content">
|
||||
<?php
|
||||
switch ($tab) {
|
||||
case 'tab1':
|
||||
echo '<form action="admin.php?page=bdp-kompass-Kompass-settings&tab=tab1" method="post">';
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-seo-settings');
|
||||
submit_button();
|
||||
echo '<input type="hidden" name="tab" value="tab4" />';
|
||||
echo '</form>';
|
||||
break;
|
||||
case 'tab2':
|
||||
echo '<form action="admin.php?page=bdp-kompass-Kompass-settings" method="post">';
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-seo-settings');
|
||||
submit_button();
|
||||
echo '<input type="hidden" name="tab" value="tab2" />';
|
||||
echo '</form>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
13
modules/KompassSettings/Views/tab-control.php
Normal file
13
modules/KompassSettings/Views/tab-control.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
function kompass_settings_print_tab_header(string $activeTab = 'tab1')
|
||||
{
|
||||
$baseUrl = 'admin.php?page=bdp-kompass-Kompass-settings&tab=';
|
||||
return '<h2 class="nav-tab-wrapper">'.
|
||||
'<a href="' . $baseUrl . 'tab1" class="nav-tab ' . ($activeTab == 'tab1' ? 'nav-tab-active' : '') . '">' .
|
||||
__('Calendar Settings', BDP_LV_PLUGIN_SLUG) .
|
||||
'</a>'.
|
||||
'<a href="' . $baseUrl . 'tab2" class="nav-tab ' . ($activeTab == 'tab2' ? 'nav-tab-active' : '') .'">' .
|
||||
__('SEO', BDP_LV_PLUGIN_SLUG) .
|
||||
'</a>'.
|
||||
'</h2>';
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
function kompass_print_checkbox(string $settingName) {
|
||||
$currentSetting = get_option($settingName, []);
|
||||
if (!is_array($currentSetting)) {
|
||||
$currentSetting = [$currentSetting];
|
||||
}
|
||||
$options = ['kompass_limit_login_lockout_notify' => [
|
||||
'email' => __('E-Mail to site admin', BDP_LV_PLUGIN_SLUG)
|
||||
],
|
||||
];
|
||||
|
||||
if(!isset($options[$settingName])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$setting = $options[$settingName];
|
||||
foreach ($setting as $radioOption => $optionText) {
|
||||
$isChecked = in_array($radioOption, $currentSetting) ? 'checked ' : '' ;
|
||||
|
||||
echo '<input ' .
|
||||
$isChecked .
|
||||
'type="checkbox"
|
||||
name="' . $settingName . '[]"
|
||||
value="' . $radioOption . '"
|
||||
id="setting_' . $settingName . '_' . $radioOption . '" />' .
|
||||
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
function kompass_print_radio(string $settingName) {
|
||||
$currentSetting = get_option($settingName, '');
|
||||
$options = [
|
||||
'kompass_limit_login_client_type' => [
|
||||
'REMOTE_ADDR' => __('Direct connection', BDP_LV_PLUGIN_SLUG),
|
||||
'HTTP_X_FORWARDED_FOR' => __('Behind a proxy', BDP_LV_PLUGIN_SLUG)
|
||||
],
|
||||
'kompass_limit_login_cookies' => [
|
||||
true => __('Yes', BDP_LV_PLUGIN_SLUG),
|
||||
false => __('No', BDP_LV_PLUGIN_SLUG)
|
||||
],
|
||||
'kompass_password_minimal_strength' => [
|
||||
'1' => __('Allow all password strengths', BDP_LV_PLUGIN_SLUG),
|
||||
'2' => __('At least passwords with medium strength', BDP_LV_PLUGIN_SLUG),
|
||||
'3' => __('Only allow strong passwords', BDP_LV_PLUGIN_SLUG)
|
||||
]
|
||||
];
|
||||
|
||||
if(!isset($options[$settingName])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$setting = $options[$settingName];
|
||||
foreach ($setting as $radioOption => $optionText) {
|
||||
$isChecked = $currentSetting == $radioOption ? 'checked ' : '' ;
|
||||
echo '<input
|
||||
' . $isChecked .
|
||||
' type="radio"
|
||||
name="' . $settingName . '"
|
||||
value="' . $radioOption . '"
|
||||
id="setting_' . $settingName . '_' . $radioOption . '" />' .
|
||||
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
function kompass_print_textbox($settingName, $settingValue) {
|
||||
echo '<input type="text" name="' . $settingName . '" value="' . $settingValue. '" />';
|
||||
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||
echo '<br />' . $settingName;
|
||||
}
|
||||
}
|
@ -4,19 +4,7 @@ function custom_settings_section_callback() {
|
||||
echo '<input type="hidden" name="update_options" value="true" />';
|
||||
}
|
||||
|
||||
function _kompass_limit_logins_settings_callback(array $args) {
|
||||
$setting = get_option($args['setting'], null);
|
||||
if (null === $setting) {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = esc_attr($setting);
|
||||
if (isset($args['unit_division'])) {
|
||||
$value = (int)$value / (int)$args['unit_division'];
|
||||
}
|
||||
|
||||
kompass_print_textbox($args['setting'], $value);
|
||||
}
|
||||
|
||||
function _kompass_limit_logins_settings_radio_callback(array $args)
|
||||
{
|
||||
@ -35,6 +23,10 @@ add_settings_section(
|
||||
BDP_LV_PLUGIN_SLUG . '-limit-login-attempts'
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$settings_page = BDP_LV_PLUGIN_SLUG . '-limit-login-attempts';
|
||||
|
||||
|
||||
@ -45,7 +37,7 @@ add_settings_field(
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_allowed_retries']);
|
||||
['setting' => 'kompass_seo_google_verification']);
|
||||
|
||||
add_settings_field(
|
||||
'kompass_lla_2',
|
||||
@ -110,3 +102,4 @@ add_settings_field(
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_notify_email_after']);
|
||||
|
||||
|
28
modules/seo/Views/seo-form.php
Normal file
28
modules/seo/Views/seo-form.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('SEO-Options', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
BDP_LV_PLUGIN_SLUG . '-seo-settings'
|
||||
);
|
||||
|
||||
$seo_settings_page = BDP_LV_PLUGIN_SLUG . '-seo-settings';
|
||||
|
||||
add_settings_field(
|
||||
'kompass_seo_1',
|
||||
__('Google Site verification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_seo_google_verification', 'style' => 'width: 500px']);
|
||||
|
||||
|
||||
add_settings_field(
|
||||
'kompass_seo_2',
|
||||
__('Bing Site verification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_seo_bing_verification', 'style' => 'width: 500px']);
|
@ -3,8 +3,34 @@
|
||||
namespace Bdp\Modules\Seo;
|
||||
class Seo
|
||||
{
|
||||
public static function importVerificationKeys() {
|
||||
$aioseoSetting = get_option('aioseo_options', null);
|
||||
if (null === $aioseoSetting) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ('' !== $aioseoSetting && !is_object($aioseoSetting) && !is_array($aioseoSetting)){
|
||||
$aioseoSetting = json_decode( $aioseoSetting );
|
||||
}
|
||||
|
||||
if (!is_object($aioseoSetting) ||!isset($aioseoSetting->webmasterTools) ||!is_object($aioseoSetting->webmasterTools)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$webmasterTools = $aioseoSetting->webmasterTools;
|
||||
if ('' !== get_option('kompass_seo_google_verification', '')) {
|
||||
update_option('kompass_seo_google_verification', $webmasterTools->google);
|
||||
}
|
||||
|
||||
if ('' !== get_option('kompass_seo_bing_verification', '')) {
|
||||
update_option('kompass_seo_bing_verification', $webmasterTools->bing);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setup()
|
||||
{
|
||||
|
||||
if (get_option('permalink_structure') === '') {
|
||||
update_option('permalink_structure', '/%postname%/');
|
||||
flush_rewrite_rules();
|
||||
|
12
modules/seo/includes/meta.php
Normal file
12
modules/seo/includes/meta.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
function kompass_seo_add_verfications() {
|
||||
$googleVerification = get_option('kompass_seo_google_verification', '');
|
||||
if ('' !== $googleVerification) {
|
||||
echo '<meta name="google-site-verification" content="' . $googleVerification . '" />' . "\n";
|
||||
}
|
||||
|
||||
$bingVerification = get_option('kompass_seo_bing_verification', '');
|
||||
if ('' !== $bingVerification) {
|
||||
echo '<meta name="msvalidate.01="' . $bingVerification . '" />' . "\n";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user