Skip to content

Commit

Permalink
3.3.8
Browse files Browse the repository at this point in the history
* Fix for errors on Task Manager pages caused by a library conflict with other plugins.
* When using the post editor after migrating an existing site to cloud storage, images appeared broken if the original images were deleted from the server.  This is now fixed.
  • Loading branch information
jawngee committed Dec 9, 2019
1 parent eeae037 commit e5227d2
Show file tree
Hide file tree
Showing 171 changed files with 17,610 additions and 30 deletions.
3 changes: 2 additions & 1 deletion classes/Storage/StorageFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

namespace ILAB\MediaCloud\Storage;

use Carbon\Carbon;

use ILAB\MediaCloud\Utilities\Misc\Carbon\Carbon;

class StorageFile {
/** @var string The type of file (DIR or FILE) */
Expand Down
4 changes: 1 addition & 3 deletions classes/Tasks/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@

namespace ILAB\MediaCloud\Tasks;

use Carbon\Carbon;
use GPBMetadata\Google\Api\Log;
use ILAB\MediaCloud\Model\Model;
use ILAB\MediaCloud\Utilities\Misc\Carbon\Carbon;
use function ILAB\MediaCloud\Utilities\gen_uuid;
use ILAB\MediaCloud\Utilities\Logging\Logger;
use ILAB\MediaCloud\Utilities\Performance;
use function ILAB\MediaCloud\Utilities\phpMemoryLimit;
use ILAB\MediaCloud\Utilities\Tracker;

Expand Down
2 changes: 1 addition & 1 deletion classes/Tasks/TaskSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace ILAB\MediaCloud\Tasks;

use Carbon\Carbon;
use Cron\CronExpression;
use ILAB\MediaCloud\Model\Model;
use ILAB\MediaCloud\Utilities\Misc\Carbon\Carbon;
use function ILAB\MediaCloud\Utilities\gen_uuid;
use Lorisleiva\CronTranslator\CronParsingException;
use Lorisleiva\CronTranslator\CronTranslator;
Expand Down
2 changes: 1 addition & 1 deletion classes/Tools/Debugging/System/SystemCompatibilityTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ILAB\MediaCloud\Tools\Debugging\System;

use Carbon\CarbonInterval;
use ILAB\MediaCloud\Utilities\Misc\Carbon\CarbonInterval;
use FasterImage\FasterImage;
use ILAB\MediaCloud\Storage\StorageGlobals;
use ILAB\MediaCloud\Tasks\TaskRunner;
Expand Down
43 changes: 43 additions & 0 deletions classes/Tools/SettingsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,49 @@ public function renderNumberFieldSetting($args) {
]);
}

/**
* Registers an option with a number input
*
* @param $option_name
* @param $title
* @param $settings_slug
* @param null $description
* @param null $conditions
*/
protected function registerImageFieldSetting($option_name, $title, $settings_slug, $description=null, $conditions=null) {
add_settings_field($option_name,
$title,
[$this, 'renderImageFieldSetting'],
$this->options_page,
$settings_slug,
['option'=>$option_name,'description'=>$description, 'conditions' => $conditions]);

}

/**
* Renders a number input
* @param $args
*/
public function renderImageFieldSetting($args) {
$value = Environment::Option($args['option'], null, null);

$imageUrl = null;
if (!empty($value)) {
$src = wp_get_attachment_image_src($value, 'medium');
if (!empty($src)) {
$imageUrl = $src[0];
}
}

echo View::render_view('base/fields/image.php',[
'value' => $value,
'imageUrl' => $imageUrl,
'name' => $args['option'],
'conditions' => $args['conditions'],
'description' => (isset($args['description'])) ? $args['description'] : false
]);
}

/**
* Registers an option with a dropdown/select input
* @param $option_name
Expand Down
23 changes: 21 additions & 2 deletions classes/Tools/Storage/StorageTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ function ( $file, $type, $fullsize ) {
PHP_INT_MAX - 1,
1
);
add_filter(
'the_editor_content',
[ $this, 'filterContent' ],
PHP_INT_MAX - 1,
2
);
add_filter(
'render_block',
[ $this, 'filterBlocks' ],
Expand Down Expand Up @@ -2121,13 +2127,20 @@ public function filterGutenbergContent( $content )
* @return mixed
* @throws StorageException
*/
public function filterContent( $content )
public function filterContent( $content, $context = 'post' )
{
if ( !apply_filters( 'media-cloud/storage/can-filter-content', true ) ) {
return $content;
}
$originalContent = $content;

if ( $context !== 'post' ) {
$content = str_replace( '&lt;', '<', $content );
$content = str_replace( '&gt;', '>', $content );
}

if ( !preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
return $content;
return $originalContent;
}
$uploadDir = wp_get_upload_dir();
$replacements = [];
Expand Down Expand Up @@ -2261,6 +2274,12 @@ public function filterContent( $content )
foreach ( $resizedReplacements as $id => $data ) {
$content = $this->replaceImageInContent( $data['id'], $data, $content );
}

if ( $context !== 'post' ) {
$content = str_replace( '<', '&lt;', $content );
$content = str_replace( '>', '&gt;', $content );
}

return $content;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/Tools/Tasks/CLI/TasksCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

namespace ILAB\MediaCloud\Tools\Tasks\CLI;

use Carbon\Carbon;
use ILAB\MediaCloud\CLI\Command;
use ILAB\MediaCloud\Tasks\TaskSchedule;
use ILAB\MediaCloud\Tasks\TestTask;
use ILAB\MediaCloud\Utilities\Misc\Carbon\Carbon;
use function ILAB\MediaCloud\Utilities\arrayPath;
use function ILAB\MediaCloud\Utilities\gen_uuid;

Expand Down
3 changes: 3 additions & 0 deletions classes/Tools/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ public function registerSettings() {
case 'advanced-privacy':
$this->registerAdvancedPrivacy($option, $optionInfo['title'], $group, $conditions);
break;
case 'image':
$this->registerImageFieldSetting($option, $optionInfo['title'], $group, $description, $conditions);
break;
default:
do_action('media-cloud/tools/register-setting-type', $option, $optionInfo, $group, $groupInfo, $conditions);
}
Expand Down
15 changes: 0 additions & 15 deletions classes/Tools/ToolsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,6 @@ public function __construct()
'ilab-media-tools-extime-notice'
);
}
$runTime = Environment::Option( 'ilab_media_tools_run_time', null, 0 );

if ( $runTime == 0 ) {
Environment::UpdateOption( 'ilab_media_tools_run_time', microtime( true ) );
} else {
if ( microtime( true ) - floatval( $runTime ) > 1209600 ) {
NoticeManager::instance()->displayAdminNotice(
'info',
"Thanks for using Media Cloud! If you like it, please <a href='https://wordpress.org/support/plugin/ilab-media-tools/reviews/#new-post' target=_blank>leave a review</a>. Thank you!",
true,
'ilab-media-tools-nag-notice'
);
}
}

if ( !extension_loaded( 'mbstring' ) ) {
NoticeManager::instance()->displayAdminNotice(
'warning',
Expand Down
Loading

0 comments on commit e5227d2

Please sign in to comment.