Skip to content

Commit bcdf47b

Browse files
committed
hotfix for media
1 parent cc6b2f6 commit bcdf47b

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
33

44
This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
55

6+
## [8.0.4]
7+
8+
### Fixed
9+
- broken media upload after adding svg filters.
10+
- wrong optimization service class namespace.
11+
612
## [8.0.3]
713

814
### Added
@@ -565,6 +571,7 @@ Init setup
565571

566572
[Unreleased]: https://github.com/infinum/eightshift-libs/compare/main...HEAD
567573

574+
[8.0.4]: https://github.com/infinum/eightshift-libs/compare/8.0.3...8.0.4
568575
[8.0.3]: https://github.com/infinum/eightshift-libs/compare/8.0.2...8.0.3
569576
[8.0.2]: https://github.com/infinum/eightshift-libs/compare/8.0.1...8.0.2
570577
[8.0.1]: https://github.com/infinum/eightshift-libs/compare/8.0.0...8.0.1

src/Cli/Cli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
use EightshiftLibs\Media\RegenerateWebPMediaCli;
6767
use EightshiftLibs\Media\UseWebPMediaCli;
6868
use EightshiftLibs\Misc\VersionCli;
69-
use EightshiftLibs\ModifyAdminAppearance\OptimizationCli;
69+
use EightshiftLibs\Optimization\OptimizationCli;
7070
use EightshiftLibs\Plugin\PluginCli;
7171
use EightshiftLibs\Readme\ReadmeCli;
7272
use EightshiftLibs\Rest\Routes\LoadMore\LoadMoreRouteCli;

src/Media/AbstractMedia.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,23 @@ public function enableSvgMediaLibraryPreview($response, $attachment)
148148
*/
149149
public function validateSvgOnUpload($response)
150150
{
151-
if ($response['type'] !== 'image/svg+xml' && !\class_exists('SimpleXMLElement')) {
152-
return $response;
153-
}
154-
155-
$path = $response['tmp_name'] ?? '';
151+
if ($response['type'] === 'image/svg+xml' && \class_exists('SimpleXMLElement')) {
152+
$path = $response['tmp_name'];
156153

157-
$svgContent = \file($path);
158-
$svgContent = \implode(' ', $svgContent);
154+
$svgContent = \file($path);
155+
$svgContent = \implode(' ', $svgContent);
159156

160-
if (!\file_exists($path) || Helpers::isValidXml($svgContent)) {
161-
return $response;
157+
if (\file_exists($path)) {
158+
if (!Helpers::isValidXml($svgContent)) {
159+
return [
160+
'size' => $response,
161+
'name' => $response['name'],
162+
];
163+
}
164+
}
162165
}
163166

164-
return [
165-
'size' => $response,
166-
'name' => $response['name'],
167-
];
167+
return $response;
168168
}
169169

170170
/**

src/Optimization/OptimizationCli.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

33
/**
4-
* Class that registers WPCLI command for ModifyAdminAppearance.
4+
* Class that registers WPCLI command for Optimization.
55
*
6-
* @package EightshiftLibs\ModifyAdminAppearance
6+
* @package EightshiftLibs\Optimization
77
*/
88

99
declare(strict_types=1);
1010

11-
namespace EightshiftLibs\ModifyAdminAppearance;
11+
namespace EightshiftLibs\Optimization;
1212

1313
use EightshiftLibs\Cli\AbstractCli;
1414
use EightshiftLibs\Cli\ParentGroups\CliCreate;

src/Optimization/OptimizationExample.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public function dequeueStyles(): void
5757
*/
5858
public function dequeueScripts(): void
5959
{
60+
if (!\function_exists('is_plugin_active')) {
61+
include_once(\ABSPATH . 'wp-admin/includes/plugin.php');
62+
}
63+
6064
// Query monitor expects jquery to work.
6165
if (\is_plugin_active('query-monitor/query-monitor.php') && \is_user_logged_in()) {
6266
return;

0 commit comments

Comments
 (0)