Skip to content

Commit 33602b0

Browse files
authored
Release version 2.4.0 (#7)
Merge pull request #7 from short-pixel-optimizer/release-2.4.0
2 parents 87414e0 + da93020 commit 33602b0

21 files changed

+467
-505
lines changed

build/shortpixel/PackageLoader.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33

44
class PackageLoader
55
{
6-
public $dir;
7-
public $composerFile = false;
6+
public $dir;
7+
public $composerFile = false;
88

9-
public function __construct()
10-
{
9+
public function __construct()
10+
{
1111

12-
}
12+
}
1313

14-
public function setComposerFile($filePath)
15-
{
16-
$this->composerFile = json_decode(file_get_contents($filePath),1);
17-
}
14+
public function setComposerFile($filePath)
15+
{
16+
$this->composerFile = json_decode(file_get_contents($filePath),1);
17+
}
1818

19-
public function getComposerFile($filePath = false )
20-
{
21-
if (! $this->composerFile)
22-
$this->composerFile = json_decode(file_get_contents($this->dir."/composer.json"), 1);
19+
public function getComposerFile($filePath = false )
20+
{
21+
if (! $this->composerFile)
22+
$this->composerFile = json_decode(file_get_contents($this->dir."/composer.json"), 1);
2323

24-
return $this->composerFile;
25-
}
24+
return $this->composerFile;
25+
}
2626

2727
public function load($dir)
2828
{
2929
$this->dir = $dir;
3030
$composer = $this->getComposerFile();
31+
32+
3133
if(isset($composer["autoload"]["psr-4"])){
3234
$this->loadPSR4($composer['autoload']['psr-4']);
3335
}
@@ -61,13 +63,11 @@ public function loadPSR0($namespaces)
6163
public function loadPSR($namespaces, $psr4)
6264
{
6365
$dir = $this->dir;
64-
6566
// Foreach namespace specified in the composer, load the given classes
6667
foreach ($namespaces as $namespace => $classpaths) {
6768
if (!is_array($classpaths)) {
6869
$classpaths = array($classpaths);
6970
}
70-
7171
spl_autoload_register(function ($classname) use ($namespace, $classpaths, $dir, $psr4) {
7272
// Check if the namespace matches the class we are looking for
7373
if (preg_match("#^".preg_quote($namespace)."#", $classname)) {
@@ -76,7 +76,6 @@ public function loadPSR($namespaces, $psr4)
7676
$classname = str_replace($namespace, "", $classname);
7777
}
7878

79-
8079
// $filename = preg_replace("#\\\\#", "", $classname).".php";
8180
// This is fix for nested classes which were losing a /
8281
$filename = ltrim($classname .'.php', '\\');

build/shortpixel/log/src/ShortPixelLogger.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ protected function addLog($message, $level, $data = array())
138138
return;
139139
}
140140

141+
// Force administrator on manuals.
142+
if ( $this->is_manual_request )
143+
{
144+
if (! function_exists('wp_get_current_user')) // not loaded yet
145+
return false;
146+
147+
$user_is_administrator = (current_user_can('manage_options')) ? true : false;
148+
if (! $user_is_administrator)
149+
return false;
150+
}
151+
141152
// Check where to log to.
142153
if ($this->logPath === false)
143154
{
@@ -237,6 +248,11 @@ public static function addWarn($message, $args = array())
237248
$log = self::getInstance();
238249
$log->addLog($message, $level, $args);
239250
}
251+
// Alias, since it goes wrong so often.
252+
public static function addWarning($message, $args = array())
253+
{
254+
self::addWarn($message, $args);
255+
}
240256
public static function addInfo($message, $args = array())
241257
{
242258
$level = DebugItem::LEVEL_INFO;
@@ -321,6 +337,7 @@ public function loadView()
321337
$controller = $this;
322338

323339
$template_path = __DIR__ . '/' . $this->template . '.php';
340+
// var_dump( $template_path);
324341
if (file_exists($template_path))
325342
{
326343

build/shortpixel/notices/src/NoticeController.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class NoticeController //extends ShortPixelController
1919
/** For backward compat. Never call constructor directly. */
2020
public function __construct()
2121
{
22-
// $this->loadModel('notice');
2322
$ns = __NAMESPACE__;
2423
$ns = substr($ns, 0, strpos($ns, '\\')); // try to get first part of namespace
2524
$this->notice_option = $ns . '-notices';
@@ -40,6 +39,14 @@ public static function getInstance()
4039
return self::$instance;
4140
}
4241

42+
/** Reset all notices, before loading them, to ensure on updates / activations one starts fresh */
43+
public static function resetNotices()
44+
{
45+
$ns = __NAMESPACE__;
46+
$ns = substr($ns, 0, strpos($ns, '\\')); // try to get first part of namespace
47+
$result = delete_option($ns . '-notices');
48+
}
49+
4350
/** Load Notices Config File, if any
4451
*
4552
* [ Future Use ]
@@ -68,7 +75,15 @@ protected function loadNotices()
6875

6976
if ($notices !== false && is_array($notices))
7077
{
71-
self::$notices = $notices;
78+
$checked = array();
79+
foreach($notices as $noticeObj)
80+
{
81+
if (is_object($noticeObj) && $noticeObj instanceOf NoticeModel)
82+
{
83+
$checked[] = $noticeObj;
84+
}
85+
}
86+
self::$notices = $checked;
7287
$this->has_stored = true;
7388
}
7489
else {
@@ -183,7 +198,7 @@ public static function removeNoticeByID($id)
183198
for($i = 0; $i < count(self::$notices); $i++)
184199
{
185200
$item = self::$notices[$i];
186-
if ($item->getID() == $id)
201+
if (is_object($item) && $item->getID() == $id)
187202
{
188203
Log::addDebug('Removing notice with ID ' . $id);
189204
unset(self::$notices[$i]);

build/shortpixel/notices/src/NoticeModel.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ public static function setIcon($notice_type, $icon)
134134
self::$icons[$type] = $icon;
135135
}
136136

137+
private function checkIncomplete($var)
138+
{
139+
return ($var instanceof \__PHP_Incomplete_Class);
140+
}
141+
137142
public function getForDisplay()
138143
{
139144
$this->viewed = true;
@@ -143,6 +148,21 @@ public function getForDisplay()
143148

144149
if ($this->callback)
145150
{
151+
if (is_array($this->callback))
152+
{
153+
foreach($this->callback as $part)
154+
{
155+
if ($this->checkIncomplete($part) === true)
156+
{
157+
return false;
158+
}
159+
}
160+
} elseif (is_object($this->callback))
161+
{
162+
if ($this->checkIncomplete($part) === true)
163+
return false;
164+
}
165+
146166
$return = call_user_func($this->callback, $this);
147167
if ($return === false) // don't display is callback returns false explicitly.
148168
return;

build/shortpixel/shortq/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "shortpixel/shortq",
33
"description": "Simple Queue",
4-
"version": 0.5,
4+
"version": 1.1,
55
"type": "library",
66
"license": "MIT",
77
"authors": [

build/shortpixel/shortq/src/DataProvider/DataProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
*/
1111
interface DataProvider
1212
{
13-
13+
1414
function __construct($pluginSlug, $queueName);
1515

1616
//function add($items);
1717
function enqueue($items);
1818
function dequeue($args); // @return Items removed from queue and set to status. Returns Item Object
19-
function alterqueue($args); // @return Item Count / Boolean . Mass alteration of queue.
19+
function alterQueue($changes, $conditions, $operators); // @return Item Count / Boolean . Mass alteration of queue. ( changes, what to change, conditions, basically where statement)
2020
function itemUpdate(Item $item, $new_status);
21+
function getItem($item_id);
22+
function getItems($args); // get items on basis of status / updated date /etc
23+
2124

2225
// Returns number of items left in Queue.
2326
function itemCount($mode = 'waiting');

0 commit comments

Comments
 (0)