Skip to content

Commit

Permalink
Merge pull request tomaszsita#12 from madebyreformat/master
Browse files Browse the repository at this point in the history
madebyreformat — Fix thick box bug in 4.7

* madebyreformat/master:
  Fix thick box bug in 4.7
  • Loading branch information
mcaskill committed Sep 18, 2018
2 parents 5f8f088 + 9e35ddc commit d86d979
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 46 deletions.
23 changes: 23 additions & 0 deletions assets/css/mic-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@
display: none;
}

/* Add clearfix */

.mic-editor-header:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}

.mic-editor-header {
display: inline-block;
}

* html .mic-editor-header {
height: 1%;
}

.mic-editor-header {
display: block;
}

.mic-editor-wrapper h2 .nav-tab {
font-size: 16px;
padding: 4px;
Expand Down
94 changes: 48 additions & 46 deletions lib/ManualImageCropEditorWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,60 @@ public function renderWindow() {
<h3><?php echo __('No available image size has "crop" enabled', 'microp'); ?></h3>
<p><?php echo __('Enable in a plugin/theme with either: add_image_size(x,y,<strong>true</strong>) or set_post_thumbnail_size(x,y,<strong>true</strong>)', 'microp'); ?></p>
<?php else : ?>
<h4>
<?php _e('Pick the image size:','microp'); ?>
</h4>
<h2 class="nav-tab-wrapper">
<?php

$imageSizes = get_intermediate_image_sizes();

$editedSize = (isset($_GET['size']) && in_array($_GET['size'], $imageSizes)) ? $_GET['size'] : null;

$postId = filter_var($_GET['postId'], FILTER_SANITIZE_NUMBER_INT);

$sizeLabels = apply_filters( 'image_size_names_choose', array(
'thumbnail' => __('Thumbnail'),
'medium' => __('Medium'),
'large' => __('Large'),
'full' => __('Full Size'),
) );
$sizeLabels = apply_filters( 'image_size_names_choose', array() );
<div class="mic-editor-header">
<h4>
<?php _e('Pick the image size:','microp'); ?>
</h4>
<h2 class="nav-tab-wrapper">
<?php

$imageSizes = get_intermediate_image_sizes();

$editedSize = (isset($_GET['size']) && in_array($_GET['size'], $imageSizes)) ? $_GET['size'] : null;

$postId = filter_var($_GET['postId'], FILTER_SANITIZE_NUMBER_INT);

$sizeLabels = apply_filters( 'image_size_names_choose', array(
'thumbnail' => __('Thumbnail'),
'medium' => __('Medium'),
'large' => __('Large'),
'full' => __('Full Size'),
) );
$sizeLabels = apply_filters( 'image_size_names_choose', array() );

foreach ($imageSizes as $s) {
if ( ! isset($sizesSettings[$s]) ) {
$sizesSettings[$s] = array('label' => '', 'quality' => 80, 'visibility' => 'visible');
}

foreach ($imageSizes as $s) {
if ( ! isset($sizesSettings[$s]) ) {
$sizesSettings[$s] = array('label' => '', 'quality' => 80, 'visibility' => 'visible');
}
if ( $sizesSettings[$s]['visibility'] == 'hidden') {
if ($editedSize == $s) {
$editedSize = null;
}
continue;
}

if ( $sizesSettings[$s]['visibility'] == 'hidden') {
if ($editedSize == $s) {
$editedSize = null;
if (isset($_wp_additional_image_sizes[$s])) {
$cropMethod = $_wp_additional_image_sizes[$s]['crop'];
} else {
$cropMethod = get_option($s.'_crop');
}
if ($cropMethod == 0) {
continue;
}
continue;
}

if (isset($_wp_additional_image_sizes[$s])) {
$cropMethod = $_wp_additional_image_sizes[$s]['crop'];
} else {
$cropMethod = get_option($s.'_crop');
}
if ($cropMethod == 0) {
continue;
}
if ( is_null($editedSize) ) {
$editedSize = $s;
}

if ( is_null($editedSize) ) {
$editedSize = $s;
// Get user defined label for the size or just cleanup a bit
$label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
$label = $sizesSettings[$s]['label'] ? $sizesSettings[$s]['label'] : $label;
echo '<a href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&size=' . $s . '&postId=' . $postId . '&width=940" class="mic-icon-' . $s . ' rm-crop-size-tab nav-tab ' . ( ($s == $editedSize) ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
}

// Get user defined label for the size or just cleanup a bit
$label = isset($sizeLabels[$s]) ? $sizeLabels[$s] : ucfirst( str_replace( '-', ' ', $s ) );
$label = $sizesSettings[$s]['label'] ? $sizesSettings[$s]['label'] : $label;
echo '<a href="' . admin_url( 'admin-ajax.php' ) . '?action=mic_editor_window&size=' . $s . '&postId=' . $postId . '&width=940" class="mic-icon-' . $s . ' rm-crop-size-tab nav-tab ' . ( ($s == $editedSize) ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
}
?>
</h2>
?>
</h2>
</div>
<div class="mic-left-col">
<?php
//reads the specific registered image size dimension
Expand Down

0 comments on commit d86d979

Please sign in to comment.