Skip to content

Commit 2411cda

Browse files
bschuilingpdobrescu
authored andcommitted
Fix - Quota messages unstyled in dashboard
Fix - NoQuota message on Bulk now working
1 parent 72ae3ac commit 2411cda

File tree

10 files changed

+51
-26
lines changed

10 files changed

+51
-26
lines changed

class/Controller/AdminNoticesController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ public function displayNotices()
128128
if (! \wpSPIO()->env()->is_screen_to_use)
129129
{
130130
if(get_current_screen()->base !== 'dashboard') // ugly exception for dashboard.
131+
{
131132
return; // suppress all when not our screen.
133+
}
134+
else {
135+
\wpSPIO()->load_style('shortpixel-notices');
136+
\wpSPIO()->load_style('notices-module');
137+
}
132138
}
133139

134140
$access = AccessModel::getInstance();
@@ -161,10 +167,10 @@ public function displayNotices()
161167
continue;
162168
}
163169

164-
// @Todo change this to new keys
165-
if ($notice->getID() == 'MSG_QUOTA_REACHED' || $notice->getID() == 'MSG_UPGRADE_MONTH') //|| $notice->getID() == AdminNoticesController::MSG_UPGRADE_BULK
170+
171+
if ($notice->getID() == 'MSG_QUOTA_REACHED' || $notice->getID() == 'MSG_UPGRADE_MONTH')
166172
{
167-
// @todo check if this is still needed.
173+
// This is still needed
168174
wp_enqueue_script('jquery.knob.min.js');
169175
wp_enqueue_script('shortpixel');
170176
}

class/Controller/AjaxController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ public function ajax_proposeQuotaUpgrade()
10451045

10461046
public function ajax_checkquota()
10471047
{
1048+
10481049
$this->checkNonce('ajax_request');
10491050
$action = 'check_quota';
10501051
$this->checkActionAccess($action, 'is_author');

class/Controller/Front/CDNController.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ class CDNController extends \ShortPixel\Controller\Front\PageConverter
2626
public function __construct()
2727
{
2828
parent::__construct();
29-
//Log::addTemp("DOING: ", $_SERVER['REQUEST_URI']);
3029

3130
if (false === $this->shouldConvert())
3231
{
33-
Log::addTemp("not Converting", $_SERVER['REQUEST_URI']);
3432
return false;
3533
}
3634

@@ -190,12 +188,9 @@ protected function processFront($content)
190188
// If the items didn't survive the filters.
191189
if (count($replaceBlocks) == 0)
192190
{
193-
Log::addTemp('No Replace Blocks', $_SERVER['REQUEST_URI']);
194191
return $original_content;
195192
}
196193

197-
//Log::addTemp('ReplaceBlcoks', $replaceBlocks);
198-
199194
$replaceBlocks = $this->createReplacements($replaceBlocks);
200195

201196
// $replace_function = ($this->replace_method == 'preg') ? 'pregReplaceContent' : 'stringReplaceContent';
@@ -204,7 +199,7 @@ protected function processFront($content)
204199
$urls = array_column($replaceBlocks, 'raw_url');
205200
$replace_urls = array_column($replaceBlocks, 'replace_url');
206201

207-
Log::addTemp('Array result', [$urls, $replace_urls]);
202+
// Log::addDebug('Array result', [$urls, $replace_urls]);
208203

209204
$content = $this->$replace_function($original_content, $urls, $replace_urls);
210205

@@ -325,7 +320,6 @@ protected function checkDomain($replaceBlock)
325320
$url = $site_url . $original_url;
326321
$replaceBlock->parsed = parse_url($url); // parse the new URL
327322
$replaceBlock->url = $url;
328-
Log::addTemp("URL from $original_url changed to $url");
329323

330324
return true;
331325
}

class/Controller/Front/PageConverter.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ protected function filterRegexExclusions($replaceBlocks)
135135

136136
}
137137

138-
if (count($allMatches) > 0)
139-
{
140-
Log::addTEmp('RegexExclusions: ', $allMatches);
141-
}
142-
143138
$replaceBlocks = array_filter($replaceBlocks, function ($replaceBlock) use ($allMatches) {
144139
if (in_array($replaceBlock->raw_url, $allMatches))
145140
{

class/Controller/QuotaController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function getQuotaData()
5757
if (! $cacheData->exists() )
5858
{
5959
$quotaData = $this->getRemoteQuota();
60-
if (! $this->hasQuota())
60+
if (false === $this->hasQuota())
6161
$timeout = MINUTE_IN_SECONDS;
6262
else {
6363
$timeout = HOUR_IN_SECONDS;
@@ -173,7 +173,6 @@ private function resetQuotaExceeded()
173173
{
174174
AdminNoticesController::resetQuotaNotices();
175175
}
176-
// Log::addDebug('Reset Quota Exceeded and reset Notices');
177176
$settings->quotaExceeded = 0;
178177
}
179178

class/Model/AdminNoticeModel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function load()
4040
$noticeController = Notices::getInstance();
4141
$notice = $noticeController->getNoticeByID($this->key);
4242

43+
4344
if (is_object($notice))
4445
{
4546
$this->notice = $notice;
@@ -57,7 +58,9 @@ public function load()
5758
elseif ( is_object($this->notice) && $this->checkReset() === true)
5859
{
5960
$this->reset();
61+
return false;
6062
}
63+
return true;
6164
}
6265

6366
public function getKey()
@@ -69,6 +72,7 @@ public function reset($key = null)
6972
{
7073
$key = (is_null($key)) ? $this->key : $key;
7174
Notices::removeNoticeByID($key);
75+
$this->notice = null;
7276
}
7377

7478
protected function checkReset()
@@ -131,6 +135,7 @@ protected function add()
131135
$notice->limitScreens('include', $this->include_screens);
132136
}
133137

138+
134139
if (! is_null($this->callback))
135140
Notices::makePersistent($notice, $this->key, $this->suppress_delay, $this->callback);
136141
else

class/Model/AdminNotices/QuotaNoticeMonth.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ class QuotaNoticeMonth extends \ShortPixel\Model\AdminNoticeModel
1515

1616
public function load()
1717
{
18-
$this->callback = array(AdminNoticesController::getInstance(), 'proposeUpgradePopup');
19-
parent::load();
18+
$bool = parent::load();
19+
20+
// $this->callback = array(AdminNoticesController::getInstance(), 'proposeUpgradePopup');
21+
if (true === $bool && is_object($this->notice))
22+
{
23+
AdminNoticesController::getInstance()->proposeUpgradePopup();
24+
}
25+
2026
}
2127

2228
protected function checkTrigger()

class/Model/AdminNotices/QuotaNoticeReached.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ class QuotaNoticeReached extends \ShortPixel\Model\AdminNoticeModel
1919

2020
public function load()
2121
{
22-
$this->callback = array(AdminNoticesController::getInstance(), 'proposeUpgradePopup');
23-
parent::load();
22+
// $this->callback = array(AdminNoticesController::getInstance(), 'proposeUpgradePopup');
23+
$bool = parent::load();
24+
if (true === $bool && is_object($this->notice))
25+
{
26+
AdminNoticesController::getInstance()->proposeUpgradePopup();
27+
}
2428
}
2529

2630
protected function checkTrigger()
@@ -30,8 +34,6 @@ protected function checkTrigger()
3034
if ($quotaController->hasQuota() === true)
3135
return false;
3236

33-
// $quotaData = $quotaController->getQuota();
34-
3537
$this->reset('MSG_UPGRADE_MONTH');
3638
$this->reset('MSG_UPGRADE_BULK');
3739
return true;

res/js/screens/screen-bulk.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,13 @@ class ShortPixelScreen extends ShortPixelScreenBase
596596
data.http_text = this.strings.fatalError500;
597597
super.HandleError(data);
598598
}
599+
else if(data.error) { // If this happens on the processor - checkResponse level instead of item.
600+
var error = this.processor.aStatusError[data.error];
601+
if (error == 'NOQUOTA')
602+
{
603+
this.ToggleOverQuotaNotice(true);
604+
}
605+
}
599606
}
600607

601608

@@ -627,12 +634,21 @@ class ShortPixelScreen extends ShortPixelScreenBase
627634
{
628635
var info = '<span class="kbinfo"><a href="' + result.kblink + '" target="_blank" ><span class="dashicons dashicons-editor-help">&nbsp;</span></a></span>';
629636
}
637+
638+
// Error can be passed here, get it.
639+
if (item.error)
640+
{
641+
var error = this.processor.aStatusError[item.error];
642+
}
630643
}
631644

632-
var error = this.processor.aStatusError[result.error];
645+
if (typeof error === 'undefined')
646+
{
647+
var error = this.processor.aStatusError[result.error];
648+
}
649+
633650
if (error == 'NOQUOTA')
634651
{
635-
636652
this.ToggleOverQuotaNotice(true);
637653
}
638654

@@ -1185,7 +1201,7 @@ class ShortPixelScreen extends ShortPixelScreenBase
11851201
var target = event.target;
11861202
var settingParent = target.closest('.optiongroup');
11871203
var warningEl = settingParent.querySelector('.warning');
1188-
//console.log(settingParent, warningEl);
1204+
11891205
if (true === target.checked)
11901206
{
11911207
warningEl.classList.remove('hidden');

res/js/shortpixel-processor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ window.ShortPixelProcessor =
614614

615615
HandleItemError : function(result, type)
616616
{
617+
617618
console.log('Handle Item Error', result, type);
618619
var error = this.aStatusError[result.error];
619620

0 commit comments

Comments
 (0)