Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions inc/spbc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,16 @@ function spbc_admin_init()
new CleantalkSettingsTemplates($spbc->api_key);
}

// Getting key for daughter blogs once
if (!$spbc->is_mainsite && $spbc->ms__work_mode == 1 && $spbc->ms__hoster_api_key && $spbc->data['ms__key_tries'] < 3) {
// Getting key for daughter blogs once.
// The network key could be stored on the subsite after saving the settings in the mode 2 - not an individual key.
$subsite_key = $spbc->settings['spbc_key'];
if (
!$spbc->is_mainsite &&
$spbc->ms__work_mode == 1 &&
$spbc->ms__hoster_api_key &&
(empty($subsite_key) || $subsite_key === $spbc->network_settings['spbc_key']) &&
$spbc->data['ms__key_tries'] < 3
) {
$spbc->data['ms__key_tries']++;
$spbc->save('data');
spbc_set_api_key();
Expand Down
31 changes: 30 additions & 1 deletion inc/spbc-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,18 @@ function spbc_settings__error__output()

$errors = $spbc->errors;
$errors_out = array();
$network_scope_types = spbc_settings__error__network_scope_types();

foreach ($errors as $type => $error) {
if (empty($error) || !isset($types[$type])) {
if (empty($error) || !isset($types[$type]) || in_array($type, $network_scope_types, true)) {
continue;
}

if (is_array(current($error))) {
foreach ($error as $sub_type => $sub_error) {
if ($type === 'cron' && in_array($sub_type, $network_scope_types, true)) {
continue;
}
$text_time = isset($sub_error['error_time']) ? date('Y-m-d H:i:s', $sub_error['error_time']) . ': ' : '';
$text_type = $types[ $type ];
$text_sub_type = isset($sub_types[ $sub_type ]) ? $sub_types[ $sub_type ] : $sub_type . ': ';
Expand All @@ -599,6 +603,31 @@ function spbc_settings__error__output()
return $errors_out;
}

/**
* Error types the network super-admin is responsible for, so they are not shown on a WPMS subsite.
* Mode 1 (Mutual Account, Individual Access Keys): the key is obtained with the network Hoster Access Key.
* Mode 2 (Mutual Account, Mutual Access Key): the subsite works with the main site key.
*
* @return string[]
*/
function spbc_settings__error__network_scope_types()
{
global $spbc;

if ( ! $spbc->is_network || $spbc->is_mainsite ) {
return array();
}

switch ( (int)$spbc->ms__work_mode ) {
case 1:
return array('get_key');
case 2:
return array('apikey', 'get_key', 'notice_paid_till', 'access_key_notices');
default:
return array();
}
}

function spbc_tab__summary()
{
global $spbc;
Expand Down
Loading