This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,669 @@
<?php
namespace ShortPixel;
use \ShortPixel\Helper\UiHelper as UiHelper;
use ShortPixel\Helper\UtilHelper as UtilHelper;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<section id="tab-adv-settings" class="clearfix <?php echo esc_attr(($this->display_part == 'adv-settings') ? ' sel-tab ' :''); ?> ">
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-adv-settings"><?php esc_html_e('Advanced','shortpixel-image-optimiser');?></a></h2>
<?php
$deliverWebpAlteredDisabled = '';
$deliverWebpUnalteredDisabled = '';
$deliverWebpAlteredDisabledNotice = false;
$deliverWebpUnalteredLabel ='';
$deliverAVIFLabel ='';
if( $this->is_nginx ){
$deliverWebpUnaltered = ''; // Uncheck
$deliverWebpUnalteredDisabled = 'disabled'; // Disable
$deliverWebpUnalteredLabel = __('It looks like you\'re running your site on an NGINX server. This means that you can only achieve this functionality by directly configuring the server config files. Please follow this link for instructions:','shortpixel-image-optimiser')." <a class=\"shortpixel-help-link\" href=\"https://shortpixel.com/knowledge-base/article/111-configure-nginx-to-transparently-serve-webp-files-when-supported\" target=\"_blank\" data-beacon-article=\"5bfeb9de2c7d3a31944e78ee\"><span class=\"dashicons dashicons-editor-help\"></span></a>";
$deliverAVIFLabel = __('<strong>It looks like you\'re running your site on an NGINX server. You may need additional configuration for the AVIF delivery to work as expected</strong>','shortpixel-image-optimiser')." <a class=\"shortpixel-help-link\" href=\"https://shortpixel.com/knowledge-base/article/499-how-do-i-configure-my-web-server-to-deliver-avif-images\" target=\"_blank\"><span class=\"dashicons dashicons-editor-help\"></span></a>";
} else {
if( !$this->is_htaccess_writable ){
$deliverWebpUnalteredDisabled = 'disabled'; // Disable
if( $view->data->deliverWebp == 3 ){
$deliverWebpAlteredDisabled = 'disabled'; // Disable
$deliverWebpUnalteredLabel = __('It looks like you recently moved from an Apache server to an NGINX server, while the option to use .htacces was in use. Please follow this tutorial to see how you could implement by yourself this functionality, outside of the WP plugin: ','shortpixel-image-optimiser') . '<a href="https://shortpixel.com/knowledge-base/article/111-configure-nginx-to-transparently-serve-webp-files-when-supported" target="_blank" data-beacon-article="5bfeb9de2c7d3a31944e78ee"></a>';
} else {
$deliverWebpUnalteredLabel = __('It looks like your .htaccess file cannot be written. Please fix this and then return to refresh this page to enable this option.','shortpixel-image-optimiser');
}
} elseif (isset($_SERVER['HTTP_USER_AGENT']) && strpos( wp_unslash($_SERVER['HTTP_USER_AGENT']), 'Chrome') !== false) {
// Show a message about the risks and caveats of serving WEBP images via .htaccess
$deliverWebpUnalteredLabel = '<span style="color: initial;">'. esc_html__('Based on testing your particular hosting configuration, we determined that your server','shortpixel-image-optimiser').
'&nbsp;<img alt="can or can not" src="'. esc_url(plugins_url( 'res/img/test.jpg' , SHORTPIXEL_PLUGIN_FILE)) .'">&nbsp;'.
esc_html__('serve the WebP or AVIF versions of the JPEG files seamlessly, via .htaccess.','shortpixel-image-optimiser').' <a href="https://shortpixel.com/knowledge-base/article/127-delivering-webp-images-via-htaccess" target="_blank" data-beacon-article="5c1d050e04286304a71d9ce4">Open article to read more about this.</a></span>';
}
}
?>
<div class="wp-shortpixel-options wp-shortpixel-tab-content" style='visibility: hidden'>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php esc_html_e('Next Generation Images','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/286-how-to-serve-webp-files-using-spio"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="createWebp" value="1" <?php checked( $view->data->createWebp, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php printf(esc_html__('Create %s WebP versions %s of the images. Each image/thumbnail will use an additional credit unless you use the %s Unlimited plan. %s','shortpixel-image-optimiser'), '<a href="https://shortpixel.com/blog/how-webp-images-can-speed-up-your-site/" target="_blank">', '</a>', '<a href="https://shortpixel.com/knowledge-base/article/555-how-does-the-unlimited-plan-work" target="_blank">', '</a>' );?>
</label>
</div>
<p>&nbsp;</p>
<?php
$avifEnabled = $this->access()->isFeatureAvailable('avif');
$createAvifChecked = ($view->data->createAvif == 1 && $avifEnabled === true) ? true : false;
$disabled = ($avifEnabled === false) ? 'disabled' : '';
$avifEnabledNotice = false;
if ($avifEnabled == false)
{
$avifEnabledNotice = '<div class="sp-notice sp-notice-warning avifNoticeDisabled">';
$avifEnabledNotice .= __('The creation of AVIF files is not possible with this license type.', 'shortpixel-image-optimiser') ;
$avifEnabledNotice .= '<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/555-how-does-the-unlimited-plan-work"></span></div>';
$avifEnabledNotice .= '</div>';
}
?>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/467-how-to-create-and-serve-avif-files-using-shortpixel-image-optimizer"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="createAvif" value="1" <?php echo $disabled ?> <?php checked( $createAvifChecked );?>>
<div class="the_switch">&nbsp; </div>
<?php printf(esc_html__('Create %s AVIF versions %s of the images. Each image/thumbnail will use an additional credit. ','shortpixel-image-optimiser'), '<a href="https://shortpixel.com/blog/what-is-avif-and-why-is-it-good/" target="_blank">', '</a>');?>
</label>
</div>
<?php if(strlen($deliverAVIFLabel)){ ?>
<p class="sp-notice sp-notice-warning">
<?php echo ( $deliverAVIFLabel );?>
</p>
<?php } ?>
<?php if ($avifEnabledNotice !== false) { echo $avifEnabledNotice; } ?>
<p>&nbsp;</p>
<div class="deliverWebpSettings">
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/126-which-webp-files-delivery-method-is-the-best-for-me"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="deliverWebp" data-toggle="deliverTypes" value="1" <?php checked( ($view->data->deliverWebp > 0), true);?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Deliver the next generation versions of the images in the front-end:','shortpixel-image-optimiser');?>
</label>
</div>
<ul class="deliverWebpTypes toggleTarget" id="deliverTypes">
<li>
<input type="radio" name="deliverWebpType" id="deliverWebpAltered" <?php checked( ($view->data->deliverWebp >= 1 && $view->data->deliverWebp <= 2), true); ?> <?php echo esc_attr( $deliverWebpAlteredDisabled );?> value="deliverWebpAltered" data-toggle="deliverAlteringTypes">
<label for="deliverWebpAltered">
<?php esc_html_e('Using the &lt;PICTURE&gt; tag syntax','shortpixel-image-optimiser');?>
</label>
<?php if($deliverWebpAlteredDisabledNotice){ ?>
<p class="sp-notice">
<?php esc_html_e('After the option to work on .htaccess was selected, the .htaccess file has become unaccessible / read-only. Please make the .htaccess file writeable again to be able to further set this option up.','shortpixel-image-optimiser')?>
</p>
<?php } ?>
<p class="settings-info">
<?php esc_html_e('Each &lt;img&gt; will be replaced with a &lt;picture&gt; tag that will also provide AVIF and WebP images for browsers that support it. Also, it loads the picturefill.js for browsers that don\'t support the &lt;picture&gt; tag. You don\'t need to activate this if you\'re using the Cache Enabler plugin because your AVIF\WebP images are already handled by this plugin. <strong>Please run some tests before using this option!</strong> If the styles that your theme is using rely on the position of your &lt;img&gt; tags, you may experience display problems.','shortpixel-image-optimiser'); ?>
<strong><?php esc_html_e('You can revert anytime to the previous state just by deactivating the option.','shortpixel-image-optimiser'); ?></strong>
</p>
<ul class="deliverWebpAlteringTypes toggleTarget" id="deliverAlteringTypes">
<li>
<input type="radio" name="deliverWebpAlteringType" id="deliverWebpAlteredWP" <?php checked(($view->data->deliverWebp == 2), true);?> value="deliverWebpAlteredWP">
<label for="deliverWebpAlteredWP">
<?php esc_html_e('Only via Wordpress hooks (like the_content, the_excerpt, etc)');?>
</label>
</li>
<li>
<input type="radio" name="deliverWebpAlteringType" id="deliverWebpAlteredGlobal" <?php checked(($view->data->deliverWebp == 1),true)?> value="deliverWebpAlteredGlobal">
<label for="deliverWebpAlteredGlobal">
<?php esc_html_e('Global (processes the whole output buffer before sending the HTML to the browser)','shortpixel-image-optimiser');?>
</label>
</li>
</ul>
</li>
<li>
<input type="radio" name="deliverWebpType" id="deliverWebpUnaltered" <?php checked(($view->data->deliverWebp == 3), true);?> <?php echo esc_attr( $deliverWebpUnalteredDisabled );?> value="deliverWebpUnaltered" data-toggle="deliverAlteringTypes" data-toggle-reverse>
<label for="deliverWebpUnaltered">
<?php esc_html_e('Without altering the page code (via .htaccess)','shortpixel-image-optimiser')?>
</label>
<?php if(strlen($deliverWebpUnalteredLabel)){ ?>
<p class="sp-notice sp-notice-warning"><strong>
<?php echo( $deliverWebpUnalteredLabel );?>
</strong>
</p>
<?php } ?>
</li>
</ul>
</div>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Optimize media on upload','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/521-settings-optimize-media-on-upload"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="autoMediaLibrary" id='autoMediaLibrary' value="1" <?php checked( $view->data->autoMediaLibrary, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Automatically optimize images after they are uploaded (recommended).','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<?php if ( $view->data->frontBootstrap == 1): ?>
<tr id="frontBootstrapRow">
<th scope="row"><?php esc_html_e('Process in the front-end','shortpixel-image-optimiser');?></th>
<td>
<input name="frontBootstrap" type="checkbox" id="frontBootstrap" value="1" <?php checked( $view->data->frontBootstrap, '1' );?>>
<label for="frontBootstrap"><?php esc_html_e('Automatically optimize images added by users in front-end of the site.','shortpixel-image-optimiser');?></label>
</td>
</tr>
<tr>
<th scope='row'>&nbsp;</th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/536-why-is-the-option-process-in-the-front-end-gone"></span></div>
<div class='view-notice warning'><p><?php esc_html_e('Important. From version 5 the front processing option is no longer available. There will be no processing on the frontend. To enable optimizing images without visiting the backend, please see the options available for command line optimization.', 'shortpixel-image-optimiser') ?></p>
<p><?php esc_html_e('To turn off this message, click the checkbox and save settings', 'shortpixel-image-optimiser'); ?></p>
</div>
</td>
</tr>
<?php endif; ?>
<?php if($this->has_nextgen) { ?>
<tr>
<th scope="row"><?php esc_html_e('NextGen','shortpixel-image-optimiser');?></th>
<td>
<div class='switch_button'>
<label>
<input name="includeNextGen" type="checkbox" id="nextGen" value='1' <?php echo checked($view->data->includeNextGen,'1' );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Optimize NextGen galleries.','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<?php } ?>
<tr>
<th scope="row"><?php esc_html_e('Optimize PDFs','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/520-settings-optimize-pdfs"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="optimizePdfs" value="1" <?php checked( $view->data->optimizePdfs, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Also optimize PDF documents.','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Optimize Retina images','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/518-settings-optimize-retina-images"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="optimizeRetina" value="1" <?php checked( $view->data->optimizeRetina, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Also optimize the Retina images (@2x) if they exist.','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<?php if (true === $this->disable_heavy_features): ?>
<tr class="heavy-feature-virtual retina view-notice-row">
<th scope="row">&nbsp;</th>
<td>
<div class='heavy-feature-virtual warning view-notice'>
<p><?php printf(esc_html__('This feature has been disabled in offload mode for performance reasons. You can enable it again with a %s filter hook %s ', 'shortpixel-image-optimiser' ),'<a target="_blank" href="https://shortpixel.com/knowledge-base/article/577-performance-improvement-shortpixel-image-optimization-media-offload-plugin">', '</a>'); ?></p>
</div>
</td>
</tr>
<?php endif; ?>
<tr>
<th scope="row"><?php esc_html_e('Optimize other thumbnails','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/519-settings---optimize-other-thumbs"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="optimizeUnlisted" value="1" <?php checked( $view->data->optimizeUnlisted, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Also optimize unlisted thumbnails, if found.','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<?php if (true === $this->disable_heavy_features): ?>
<tr class="heavy-feature-virtual unlisted view-notice-row ">
<th scope="row">&nbsp;</th>
<td>
<div class='heavy-feature-virtual warning view-notice'>
<p><?php printf(esc_html__('This feature has been disabled in offload mode for performance reasons. You can enable it again with a %s filter hook %s ', 'shortpixel-image-optimiser' ),'<a target="_blank" href="https://shortpixel.com/knowledge-base/article/577-performance-improvement-shortpixel-image-optimization-media-offload-plugin">', '</a>'); ?></p>
</div>
</td>
</tr>
<?php endif; ?>
<tr>
<th scope="row"><?php esc_html_e('Convert PNG images to JPEG','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/516-settings-convert-png-images-to-jpeg"></span></div>
<div class='switch_button option-png2jpg'>
<label>
<input type="checkbox" class="switch" name="png2jpg" value="1" <?php checked( ($view->data->png2jpg > 0), true);?> <?php echo($this->is_gd_installed ? '' : 'disabled') ?> data-toggle="png2jpgforce">
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Automatically convert the PNG images to JPEG, if possible.','shortpixel-image-optimiser'); ?>
</label>
</div>
<?php if(!$this->is_gd_installed):
?>
<div style="color:red;"><?php esc_html_e('You need PHP GD with support for JPEG and PNG files for this feature. Please ask your hosting provider to install it.','shortpixel-image-optimiser'); ?>
</div>
<?php endif; ?>
<div class='switch_button option-png2jpgforce toggleTarget suboption' id="png2jpgforce">
<p>&nbsp;</p>
<label>
<input type="checkbox" class="switch" name="png2jpgForce" value="1" <?php checked(($view->data->png2jpg > 1), true);?> <?php echo($this->is_gd_installed ? '' : 'disabled') ?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Also force the conversion of images with transparency.','shortpixel-image-optimiser'); ?>
</label>
</div>
</td>
</tr>
<tr class='exif_warning view-notice-row'>
<th scope="row">&nbsp;</th>
<td>
<div class='view-notice warning'><p><?php printf(esc_html__('Warning - Converting from PNG to JPG will %s not %s keep the EXIF information!', 'shortpixel-image-optimiser'), "<strong>","</strong>"); ?></p></div>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('CMYK to RGB conversion','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/517-settings---cmyk-to-rgb-conversion"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="cmyk2rgb" value="1" <?php checked( $view->data->CMYKtoRGBconversion, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Adjust your images\' colors for computer and mobile displays.','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<tr>
<th scope="row"><label for="excludeSizes"><?php esc_html_e('Exclude thumbnail sizes','shortpixel-image-optimiser');?></label></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/113-how-can-i-optimize-only-certain-thumbnail-sizes"></span></div>
<div class="option-content">
<?php
foreach($view->allThumbSizes as $sizeKey => $sizeVal) {
?>
<span class="excludeSizeOption">
<label>
<?php
$excludeSizes = property_exists($view->data, 'excludeSizes') ? $view->data->excludeSizes : array();
$checked = in_array($sizeKey, $excludeSizes) ? 'checked' : '';
$width = isset($sizeVal['width']) ? $sizeVal['width'] : '*';
$height = isset($sizeVal['height']) ? $sizeVal['height'] : '*';
$name = isset($sizeVal['nice-name']) ? $sizeVal['nice-name'] : ucfirst($sizeKey);
$label = $name . " ( $width &times $height )";
printf(' <input name="excludeSizes[]" type="checkbox" id="excludeSizes_%s" value="%s" %s>%s ', esc_attr($sizeKey), esc_attr($sizeKey), $checked, $label);
?>
</label>
</span>
<?php } // exclude sizes ?>
</div>
</td>
</tr>
<tr>
<th scope="row"><label for="excludePatterns"><?php esc_html_e('Exclude patterns','shortpixel-image-optimiser');?></label></th>
<td>
<div class="option-content">
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/88-how-to-exclude-images-from-being-optimized"></span></div>
<p class="settings-info" data-toggle="exclude-settings-expanded">
<button class='button button-primary new-exclusion-button' type='button' name="addNewExclusion">
<?php _e('Add new Exclusion', 'shortpixel-image-optimiser'); ?>
</button>
<?php
printf(esc_html__('Use this section to exclude images based on patterns. There are three types of exclusions: based on the file name, on the file path or on the file size. Each exclusion type can be applied to: all images and thumbnails of that image (including the scaled or original image), only thumbnails (in this case the original and scaled images are not excluded), only Custom Media images (in this case the items from the Media Library are not excluded) or only for a selection of thumbnails of your choice. Examples can be found in the fold-out area below.','shortpixel-image-optimiser'),
'<b>','</b>',
'<b>','</b>'
);
?>
</p>
<p class="settings-info">
<label><input type='checkbox' class='shortpixel-hide' data-toggle='exclude-settings-expanded'> >> <?php printf(esc_html__('See examples')); ?></label>
</p>
<div class='exclude-settings-expanded toggleTarget ' id="exclude-settings-expanded">
<p class="settings-info">
<?php
printf(esc_html__('For the %s"Name"%s type, only the file name is matched, i.e. if you enter %s"flower.jpg"%s in the "Value" field, ShortPixel excludes all JPEG images ending in "flower" (lower case). If, on the other hand, you enter %s"logo"%s in the "Value" field, all images PNG/JPEG/GIF that contain the word "logo" in their name will be excluded: "nicelogo.jpg", "alllogos.png", "logo.gif"..', 'shortpixel-image-optimiser'),
'<b>','</b>',
'<b>','</b>',
'<b>','</b>'
);
?>
</p>
<br />
<p class="settings-info">
<?php
printf(esc_html__('With the %s"Path"%s type, the entire path is matched (useful for excluding certain (sub)directories altogether). For example, if you enter %s"2022"%s in the "Value" field, all images uploaded in 2022 will be excluded, but also images that contain 2022 in the file name (as this is also part of the path). If you only want to exclude images uploaded in 2022, enter %s"/2022/"%s instead.','shortpixel-image-optimiser'),
'<b>','</b>',
'<b>','</b>',
'<b>','</b>'
);
?>
</p>
<br />
<p class="settings-info">
<?php
printf(esc_html__('For both types mentioned above ("Name" and "Path") you can activate the option %s"Check as regular expression"%s. It works in the same way, but requires a valid regular expression between slashes in the "Value" field. Special characters should be preceded by a \ as an escape character. For example, %s/[0-9]+[^\/]*\.(PNG|png)/%s in the "Value" field for the "Name" type excludes all PNG images that have a numeric prefix.','shortpixel-image-optimiser'),
'<b>','</b>',
'<b>','</b>'
);
?>
</p>
<br />
<p class="settings-info">
<?php
printf(esc_html__('The %s"Size"%s type is applied to all images and thumbnails whose size is within the specified range. You can either use intervals or specify an exact size if you enable the %s"Exact sizes"%s option.','shortpixel-image-optimiser'),
'<b>','</b>',
'<b>','</b>'
);
?>
</p>
</div>
<?php
$exclusions = UtilHelper::getExclusions();
$excludeArray = $exclusions; //(strlen($excludePatterns) > 0) ? explode(',', $excludePatterns) : array();
if (is_array($excludeArray) && count($excludeArray) > 0)
{
echo "<ul class='exclude-list'>";
echo '<input type="hidden" id="new-exclusion-index" name="new-index" value="' . (count($excludeArray) -1) . '">';
$i = 0;
foreach($excludeArray as $index => $option)
{
$exclude_id = 'id="exclude-' . $i . '"';
$type = $option['type'];
$value = $option['value'];
$apply = $option['apply'];
$thumblist = isset($option['thumblist']) ? $option['thumblist'] : array();
$hasError = (isset($option['has-error']) && true == $option['has-error']) ? true : false;
$option_code = json_encode($option);
$typeStrings = UiHelper::getSettingsStrings('exclusion_types');
$applyStrings = UiHelper::getSettingsStrings('exclusion_apply');
$apply_name = isset($applyStrings[$apply]) ? $applyStrings[$apply] : '';
switch($type)
{
case 'name':
case 'regex-name':
$field_name = $typeStrings['name'];
break;
case 'path':
case 'regex-path':
$field_name = $typeStrings['path']; // __('Path', 'shortpixel-image-optimiser');
break;
case 'size':
$field_name = $typeStrings['size']; // __('Size', 'shortpixel-image-optimiser');
break;
default:
$field_name = __('Unknown', 'shortpixel-image-optimiser');
break;
}
$classes = array();
if (true === $hasError)
{
$classes[] = 'has-error';
}
if (strpos($type, 'regex') !== false)
{
$classes[] = 'is-regex';
}
$class = '';
if (count($classes) > 0)
{
$class = 'class="' . implode(' ', $classes) . '"';
}
$title = '';
if ('selected-thumbs' == $apply)
{
$thumbTitles = array();
foreach($thumblist as $thumbName)
{
$thumb = $view->allThumbSizes[$thumbName];
$thumbTitles[] = (isset($thumb['nice-name'])) ? $thumb['nice-name'] : $thumbName;
}
$title = 'title="' . implode(', ', $thumbTitles) . '"';
}
echo "<li $class $title $exclude_id>";
echo "<input type='hidden' name='exclusions[]' value='$option_code' />";
echo "<span>$field_name :</span>
<span>$value</span>";
echo "<span>$apply_name</span>";
echo "</li>";
$i++;
}
echo "</ul>";
}
else {
echo '<input type="hidden" id="new-exclusion-index" name="new-index" value="0">';
echo '<ul class="exclude-list"><li class="no-exclusion-item">' . __('No exclusions', 'shortpixel-image-optimiser') . '</li></ul>';
}
?>
</div> <!-- option-content -->
<div class='new-exclusion not-visible'>
<input type="hidden" name="edit-exclusion" value="">
<h3 class='new-title not-visible'><?php _e('New Exclusion' ,'shortpixel-image-optimiser'); ?></h3>
<h3 class='edit-title not-visible'><?php _e('Edit Exclusion' ,'shortpixel-image-optimiser'); ?></h3>
<div>
<label><?php _e('Type:', 'shortpixel-image-optimiser'); ?></label>
<select name="exclusion-type" class='new-exclusion-type'>
<option value='name'><?php _e('Name', 'shortpixel-image-optimiser'); ?></option>
<option value='path' data-example="/path/"><?php _e('Path', 'shortpixel-image-optimiser'); ?></option>
<option value='size' data-example="widthXheight-widthXheight"><?php _e('Size', 'shortpixel-image-optimiser'); ?></option>
</select>
</div>
<div class='regex-option'>
<label>&nbsp;</label>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="exclusion-regex">
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Check as regular expression','shortpixel-image-optimiser');?>
</label>
</div>
</div>
<div class='value-option '>
<label><?php _e('Value:', 'shortpixel-image-optimiser'); ?></label>
<input type="text" name="exclusion-value" value="">
</div>
<div class='size-option not-visible'>
<div class='exact-option'>
<label>&nbsp;</label>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="exclusion-exactsize">
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Exact sizes','shortpixel-image-optimiser');?>
</label>
</div>
</div>
<div class='size-option-range'>
<div class='width'>
<label><?php _e('Width between:', 'shortpixel-image-optimiser'); ?></label>
<input type="number" class='small' name="exclusion-minwidth" value="">px -
<input type="number" class='small' name="exclusion-maxwidth" value="">px
</div>
<div class='height'>
<label><?php _e('Height between:', 'shortpixel-image-optimiser'); ?></label>
<input type="number" class='small' name="exclusion-minheight" value="">px -
<input type="number" class='small' name="exclusion-maxheight" value="">px
</div>
</div>
<div class='size-option-exact not-visible'>
<div class='exact'>
<label>
<?php _e('Exact size:', 'shortpixel-image-optimiser'); ?></label>
<input type="number" class='small' name="exclusion-width" value="">px x
<input type="number" class='small' name="exclusion-height" value="">px
</div>
</div>
</div>
<div>
<label><?php _e('Apply To:', 'shortpixel-image-optimiser'); ?></label>
<select name='apply-select' class='thumbnail-type-option'>
<option value='all'><?php _e('All Images', 'shortpixel-image-optimiser'); ?></option>
<option value='only-thumbs'><?php _e('Only Thumbnails','shortpixel-image-optimiser'); ?>
</option>
<option value='only-custom'><?php _e('Only Custom Media images', 'shortpixel-image-optimiser'); ?>
</option>
<option value='selected-thumbs'><?php _e('Selected thumbnails', 'shortpixel-image-optimiser'); ?></option>
</select>
<select multiple="multiple" name='thumbnail-select' class='not-visible thumbnail-option'>
<?php foreach($view->allThumbSizes as $name => $data)
{
$nice_name = isset($data['nice-name']) ? $data['nice-name'] : $name;
echo "<option value='$name'>$nice_name</option>";
} ?>
</select>
</div>
<div class='button-actions'>
<button type="button" class="button" name='cancelEditExclusion'><?php _e('Close', 'shortpixel-image-optimiser'); ?></button>
<button type="button" class="button button-primary not-visible" name="addExclusion">
<?php _e('Add Exclusion', 'shortpixel-image-optimiser'); ?></button>
<button type="button" class="button button-primary not-visible" name="updateExclusion">
<?php _e("Update", 'shortpixel-image-optimiser'); ?>
</button>
<button type="button" class="button button-primary not-visible" name="removeExclusion">
<?php _e("Remove", 'shortpixel-image-optimiser'); ?>
</button>
</div>
</div> <!-- new exclusion -->
<p class='exclusion-save-reminder hidden'><?php _e('Reminder: Save the settings for the exclusion changes to take effect!', 'shortpixel-image-optimiser'); ?></p>
</td>
</tr> <!--- exclusions -->
<tr>
<th scope="row"><label for="additional-media"><?php esc_html_e('Custom Media folders','shortpixel-image-optimiser');?></label></th>
<td>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="showCustomMedia" value="1" <?php checked( $view->data->showCustomMedia, "1" );?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Show Custom Media menu item','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<tr>
<th scope="row"><label for="authentication"><?php esc_html_e('HTTP AUTH credentials','shortpixel-image-optimiser');?></label></th>
<td>
<?php if (! defined('SHORTPIXEL_HTTP_AUTH_USER')): ?>
<input name="siteAuthUser" type="text" id="siteAuthUser" value="<?php echo( esc_html(wp_unslash($view->data->siteAuthUser )));?>" class="regular-text" placeholder="<?php esc_html_e('User','shortpixel-image-optimiser');?>" style="margin-bottom: 8px"><br>
<input name="siteAuthPass" type="text" id="siteAuthPass" value="<?php echo( esc_html(wp_unslash($view->data->siteAuthPass )));?>" class="regular-text" placeholder="<?php esc_html_e('Password','shortpixel-image-optimiser');?>" style="margin-bottom: 8px">
<p class="settings-info">
<?php printf(esc_html__('Only fill in these fields if your site (front-end) is not publicly accessible and visitors need a user/pass to connect to it.
If you don\'t know what is this then just %sleave the fields empty%s.','shortpixel-image-optimiser'), '<strong>', '</strong>'); ?>
</p>
<?php else: ?>
<p><?php esc_html_e('The HTTP AUTH credentials have been defined in the wp-config file.', 'shortpixel-image-optimiser'); ?></p>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" name="save" id="saveAdv" class="button button-primary" title="<?php esc_attr_e('Save Changes','shortpixel-image-optimiser');?>" value="<?php esc_attr_e('Save Changes','shortpixel-image-optimiser');?>"> &nbsp;
<input type="submit" name="save_bulk" id="bulkAdvGo" class="button button-primary" title="<?php esc_attr_e('Save and go to the Bulk Processing page','shortpixel-image-optimiser');?>" value="<?php esc_attr_e('Save and Go to Bulk Process','shortpixel-image-optimiser');?>"> &nbsp;
</p>
</div>
<script>
<!-- @todo // Inline JS -->
jQuery(document).ready(function () { ShortPixel.setupAdvancedTab();});
</script>
</section>

View File

@ -0,0 +1,118 @@
<?php
namespace ShortPixel;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<section id="tab-cloudflare" class="<?php echo esc_attr(($this->display_part == 'cloudflare') ? 'sel-tab ' :''); ?>">
<h2><a class='tab-link' href='javascript:void(0);'
data-id="tab-cloudflare"><?php esc_html_e('Cloudflare API', 'shortpixel-image-optimiser'); ?></a>
</h2>
<div class="wp-shortpixel-tab-content" style="visibility: hidden">
<?php
if(! $this->is_curl_installed) {
echo('<p style="font-weight:bold;color:red">' . esc_html__("Please enable PHP cURL extension for the Cloudflare integration to work.", 'shortpixel-image-optimiser') . '</p>' );
}
?>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/160-cloudlfare"></span></div>
<p><?php esc_html_e("If you are using Cloudflare on your site, we recommend that you to fill in the details below. This will allow ShortPixel to work seamlessly with Cloudflare, so that any image optimized/restored by ShortPixel is automatically updated on Cloudflare as well.",'shortpixel-image-optimiser');?></p>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label
for="cloudflare-zone-id"><?php esc_html_e('Zone ID', 'shortpixel-image-optimiser'); ?></label>
</th>
<td>
<input name="cloudflareZoneID" type="text" id="cloudflare-zone-id" <?php echo(! $this->is_curl_installed ? 'disabled' : '');?>
value="<?php echo( esc_attr(wp_unslash($view->data->cloudflareZoneID))); ?>" class="regular-text">
<p class="settings-info">
<?php esc_html_e('You can find this in your Cloudflare account in the "Overview" section for your domain.','shortpixel-image-optimiser');?>
</p>
</td>
</tr>
<tr>
<th scope="row" class='cf_switch <?php if ($view->hide_cf_global === true) { echo 'global-hidden'; } ?>'>
<?php
$token_checked = (strlen($view->data->cloudflareToken) > 0) ? 'checked' : '';
$global_checked = (strlen($view->data->cloudflareAuthKey) > 0) ? 'checked' : '';
if ($token_checked == '' && $global_checked == '')
$token_checked = 'checked'; // default.
?>
<label><input type='radio' name='cf_auth_switch' value='token' <?php echo esc_attr($token_checked) ?> ><span><?php esc_html_e('Cloudflare Token', 'shortpixel-image-optimiser'); ?></span></label>
<?php if ($view->hide_cf_global === false): ?>
<label><input type='radio' name='cf_auth_switch' value='global' <?php echo esc_attr($global_checked) ?> ><span><?php esc_html_e('Global API Key', 'shortpixel-image-optimiser') ?></span></label>
<?php endif; ?>
</th>
<td class='token-cell'>
<input name="cloudflareToken" type="text" id="cloudflare-token" <?php echo(! $this->is_curl_installed ? 'disabled' : '');?> value="<?php echo esc_attr($view->data->cloudflareToken) ?>" class='regular-text' autocomplete="off">
<?php if ($view->hide_cf_global === false): ?>
<p class='settings-info'><?php printf(esc_html__('%s Preferred Method %s. Enter your %s site token %s for authentication. This token needs %sCache Purge permission!%s', 'shortpixel-image-optimiser'), '<b>', '</b>', '<a href="https://dash.cloudflare.com/profile/api-tokens" target="_blank">', '</a>', '<a href="https://shortpixel.com/knowledge-base/article/325-using-shortpixel-image-optimizer-with-cloudflare-api-token" target="_blank">', '</a>'); ?></p>
<p class='settings-info'><?php esc_html_e('When using a token, leave the email and global API key fields empty.', 'shortpixel-image-optimiser'); ?></p>
<?php else: ?>
<p class='settings-info'><?php printf(esc_html__('Enter your %s site token %s for authentication. This token needs %s Cache Purge permission %s! ', 'shortpixel-image-optimiser'), '<a href="https://dash.cloudflare.com/profile/api-tokens" target="_blank">', '</a>', '<a href="https://shortpixel.com/knowledge-base/article/325-using-shortpixel-image-optimizer-with-cloudflare-api-token" target="_blank">', '</a>'); ?></p>
<?php endif; ?>
<a href="https://shortpixel.com/knowledge-base/article/325-using-shortpixel-image-optimizer-with-cloudflare-api-token" target="_blank" class="shortpixel-help-link">
<span class="dashicons dashicons-editor-help"></span><?php esc_html_e('How to set it up','shortpixel-image-optimiser');?>
</a>
</td>
<?php if ($view->hide_cf_global === false): ?>
<td class='authkey-cell'>
<input name="cloudflareAuthKey" type="text" id="cloudflare-auth-key" <?php echo(! $this->is_curl_installed ? 'disabled' : '');?> value="<?php echo(esc_html(wp_unslash($view->data->cloudflareAuthKey))); ?>" class="regular-text" autocomplete="off">
<p class="settings-info">
<?php esc_html_e("This can be found when you're logged into your account, on the My Profile page:",'shortpixel-image-optimiser');?> <a href='https://www.cloudflare.com/a/profile' target='_blank'>https://www.cloudflare.com/a/profile</a>
</p>
</td>
<?php endif; ?>
</tr>
<tr class='email-cell'>
<th scope="row">
<label for="cloudflare-email"><?php esc_html_e('Cloudflare E-mail:', 'shortpixel-image-optimiser'); ?></label>
</th>
<td>
<input name="cloudflareEmail" type="text" id="cloudflare-email" <?php echo(! $this->is_curl_installed ? 'disabled' : '');?>
value="<?php echo( esc_html(wp_unslash($view->data->cloudflareEmail))); ?>" class="regular-text">
<p class="settings-info">
<?php esc_html_e('The e-mail address you use to login to CloudFlare.','shortpixel-image-optimiser');?>
</p>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" name="saveCloudflare" id="saveCloudflare" class="button button-primary"
title="<?php esc_attr_e('Save Changes', 'shortpixel-image-optimiser'); ?>"
value="<?php esc_attr_e('Save Changes', 'shortpixel-image-optimiser'); ?>"> &nbsp;
</p>
</div>
<script language="javascript">
<!-- @todo Inline JS - remove version 5.1 -->
function switchCF()
{
if ( jQuery('input[name="cf_auth_switch"]:checked').val() == 'token')
{
jQuery('.authkey-cell, .email-cell').hide();
jQuery('.token-cell').show();
}
else
{
jQuery('.token-cell').hide();
jQuery('.authkey-cell, .email-cell').show();
}
}
switchCF();
jQuery('input[name="cf_auth_switch"]').on('change', switchCF);
</script>
</section>

View File

@ -0,0 +1,271 @@
<?php
namespace ShortPixel;
use ShortPixel\Notices\NoticeController as NoticeController;
use ShortPixel\Controller\StatsController as StatsController;
use ShortPixel\Controller\OptimizeController as OptimizeController;
use ShortPixel\Controller\AdminNoticesController as AdminNoticesController;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$opt = new OptimizeController();
$q = $opt->getQueue('media');
$env = \wpSPIO()->env();
$fs = \wpSPIO()->filesystem();
$debugUrl = add_query_arg(array('part' => 'debug', 'noheader' => true), $this->url);
?>
<section id="tab-debug" class="<?php echo esc_attr(($this->display_part == 'debug') ? ' sel-tab ' :''); ?>">
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-debug">
<?php esc_html_e('Debug','shortpixel-image-optimiser');?></a>
</h2>
<div class="wp-shortpixel-options wp-shortpixel-tab-content" style="visibility: hidden">
<div class='env'>
<h3><?php esc_html_e('Environment', 'shortpixel'); ?></h3>
<div class='flex'>
<span>NGINX</span><span><?php var_export($this->is_nginx); ?></span>
<span>KeyVerified</span><span><?php var_export($this->is_verifiedkey); ?></span>
<span>HtAccess writable</span><span><?php var_export($this->is_htaccess_writable); ?></span>
<span>Multisite</span><span><?php var_export($this->is_multisite); ?></span>
<span>Main site</span><span><?php var_export($this->is_mainsite); ?></span>
<span>Constant key</span><span><?php var_export($this->is_constant_key); ?></span>
<span>Hide Key</span><span><?php var_export($this->hide_api_key); ?></span>
<span>Has Nextgen</span><span><?php var_export($this->has_nextgen); ?></span>
<span>Has Offload</span><span><?php
$offload = \wpSPIO()->env()->hasOffload();
var_export($offload);
if (true === $offload)
{
echo ' (' . \wpSPIO()->env()->getOffloadName() . ') ';
}
?></span>
</div>
<div class='flex'>
<span>GD Installed</span><span><?php var_export($env->is_gd_installed); ?></span>
<span>Curl Installed</span><span><?php var_export($env->is_curl_installed); ?></span>
</div>
<div class='flex'>
<span>Uploads Base</span><span><?php echo esc_html((defined('SHORTPIXEL_UPLOADS_BASE')) ? SHORTPIXEL_UPLOADS_BASE : 'not defined'); ?></span>
<span>Uploads Name</span><span><?php echo esc_html((defined('SHORTPIXEL_UPLOADS_NAME')) ? SHORTPIXEL_UPLOADS_NAME : 'not defined'); ?></span>
<span>Backup Folder</span><span><?php echo esc_html((defined('SHORTPIXEL_BACKUP_FOLDER')) ? SHORTPIXEL_BACKUP_FOLDER : 'not defined'); ?></span>
<span>Backup URL</span><span><?php echo esc_html((defined('SHORTPIXEL_BACKUP_URL')) ? SHORTPIXEL_BACKUP_URL : 'not defined'); ?></span>
<span>
</div>
</div> <!-- /env -->
<div class='fs'>
<h3><?php esc_html_e('FileSystem', 'shortpixel'); ?></h3>
<div class='flex'>
<span>WpFileBase</span><span><?php var_export($fs->getWPFileBase()); ?></span>
<span>Upload Base</span><span><?php var_export($fs->getWPUploadBase()); ?></span>
<span>WPAbspath</span><span><?php var_export($fs->getWPAbsPath()); ?></span>
</div>
</div>
<div class='settings'>
<h3><?php esc_html_e('Settings', 'shortpixel'); ?></h3>
<?php $local = $this->view->data;
$local->apiKey = strlen($local->apiKey) . ' chars'; ?>
<pre><?php var_export($local); ?></pre>
</div>
<div class='quotadata'>
<h3><?php esc_html_e('Quota Data', 'shortpixel'); ?></h3>
<pre><?php var_export($this->quotaData); ?></pre>
</div>
<div class='debug-quota'>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_resetquota'), $debugUrl)) ?>">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<button class='button' type='submit'>Clear Quota Data</button>
</form>
</div>
<div class="stats env">
<h3><?php esc_html_e('Stats', 'shortpixel-image-optimiser'); ?></h3>
<h4>Media</h4>
<div class='flex'>
<?php $statsControl = StatsController::getInstance();
?>
<span>Items</span><span><?php echo esc_html($statsControl->find('media', 'items')); ?></span>
<span>Thumbs</span><span><?php echo esc_html($statsControl->find('media', 'thumbs')); ?></span>
<span>Images</span><span><?php echo esc_html($statsControl->find('media', 'images')); ?></span>
<span>ItemsTotal</span><span><?php echo esc_html($statsControl->find('media', 'itemsTotal')); ?></span>
<span>ThumbsTotal</span><span><?php echo esc_html($statsControl->find('media', 'thumbsTotal')); ?></span>
</div>
<h4>Custom</h4>
<div class='flex'>
<span>Custom Optimized</span><span><?php echo esc_html($statsControl->find('custom', 'items')); ?></span>
<span>Custom itemsTotal</span><span><?php echo esc_html($statsControl->find('custom', 'itemsTotal')); ?>
</span>
</div>
<h4>Total</h4>
<div class='flex'>
<span>Items</span><span><?php echo esc_html($statsControl->find('total', 'items')); ?></span>
<span>Images</span><span><?php echo esc_html($statsControl->find('total', 'images')); ?></span>
<span>Thumbs</span><span><?php echo esc_html($statsControl->find('total', 'thumbs')); ?></span>
</div>
<h4>Period</h4>
<div class='flex'>
<span>Month #1 </span><span><?php echo esc_html($statsControl->find('period', 'months', '1')); ?></span>
<span>Month #2 </span><span><?php echo esc_html($statsControl->find('period', 'months', '2')); ?></span>
<span>Month #3 </span><span><?php echo esc_html($statsControl->find('period', 'months', '3')); ?></span>
<span>Month #4 </span><span><?php echo esc_html($statsControl->find('period', 'months', '4')); ?></span>
</div>
</div> <!-- stats -->
<div class='debug-stats'>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_resetStats'), $debugUrl)) ?>"
id="shortpixel-form-debug-stats">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<button class='button' type='submit'>Clear statistics cache</button>
</form>
</div>
<?php $noticeController = NoticeController::getInstance();
$notices = $noticeController->getNotices();
?>
<h3>Notices (<?php echo esc_html(count($notices)); ?>)</h3>
<div class='table notices'>
<div class='head'>
<span>ID</span><span>Done</span><span>Dismissed</span><span>Persistent</span><span>Exclude</span><span>Include</span>
</div>
<?php foreach ($notices as $noticeObj):
$exclude = $noticeObj->_debug_getvar('exclude_screens');
$include = $noticeObj->_debug_getvar('include_screens');
$exclude = is_array($exclude) ? implode(',', $exclude) : $exclude;
$include = is_array($include) ? implode(',', $include) : $include;
?>
<div>
<span><?php echo esc_html($noticeObj->getID()); ?></span>
<span><?php echo ($noticeObj->isDone()) ? 'Y' : 'N'; ?> </span>
<span><?php echo ($noticeObj->isDismissed()) ? 'Y' : 'N'; ?> </span>
<span><?php echo ($noticeObj->isPersistent()) ? 'Y' : 'N'; ?> </span>
<span><?php echo $exclude ?></span>
<span><?php echo $include ?></span>
</div>
<?php endforeach ?>
</div>
<div class='debug-notices'>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_resetNotices'), $debugUrl)) ?>"
id="shortpixel-form-debug-stats">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<button class='button' type='submit'>Reset Notices</button>
</form>
</div>
<div class='trigger-notices'>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_triggerNotice'), $debugUrl)) ?>"
id="shortpixel-form-debug-stats">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<?php
$controller = AdminNoticesController::getInstance();
$notices = $controller->getAllNotices();
?>
<select name="notice_constant">
<option value="trigger-all">Trigger All</option>
<?php foreach($notices as $key => $noticeObj)
echo "<option value='$key'>$key </option>";
?>
</select>
<button class="button" type="submit">Trigger this Notice</button>
</form>
</div>
<p>&nbsp;</p>
<div class='table queue-stats'>
<?php
$opt = new OptimizeController();
$statsMedia = $opt->getQueue('media');
$statsCustom = $opt->getQueue('custom');
$opt->setBulk(true);
$bulkMedia = $opt->getQueue('media');
$bulkCustom = $opt->getQueue('custom');
$queues = array('media' => $statsMedia, 'custom' => $statsCustom, 'mediaBulk' => $bulkMedia, 'customBulk' => $bulkCustom);
?>
<div class='head'>
<span>Name</span>
<span>In Queue</span>
<span>In process</span>
<span>Errors</span>
<span>Fatal</span>
<span>Done</span>
<span>Total</span>
</div>
<?php
foreach($queues as $name => $queue):
$stats = $queue->getStats();
echo "<div>";
echo "<span>" . esc_html($name) . '</span>';
echo "<span>" . esc_html($stats->in_queue) . '</span>';
echo "<span>" . esc_html($stats->in_process) . '</span>';
echo "<span>" . esc_html($stats->errors) . '</span>';
echo "<span>" . esc_html($stats->fatal_errors) . '</span>';
echo "<span>" . esc_html($stats->done) . '</span>';
echo "<span>" . esc_html($stats->total) . '</span>';
echo "</div>";
?>
<?php endforeach; ?>
<div class='debug-queue'>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_resetQueue'),$debugUrl)) ?>"
id="shortpixel-form-reset-queue">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<button class='button' type='submit'>Reset ShortQ</button>
<select name="queue">
<option>All</option>
<?php foreach($queues as $name => $q)
{
echo "<option>" . esc_attr($name) . "</option>";
}
?>
</select>
</form>
</div>
</div> <!--- stats -->
<p></p>
<div class='debug-key'>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_removeProcessorKey'),$debugUrl)) ?>"
id="shortpixel-form-debug-stats">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<button class='button' type='submit'>Reset Processor Key</button>
</form>
</div>
</div> <!-- tab-content -->
</section>

View File

@ -0,0 +1,395 @@
<?php
namespace ShortPixel;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<section id="tab-settings" class="<?php echo ($this->display_part == 'settings') ? 'sel-tab' :''; ?>" >
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-settings">
<?php esc_html_e('General','shortpixel-image-optimiser');?></a>
</h2>
<div class="wp-shortpixel-options wp-shortpixel-tab-content" style="visibility: hidden">
<table class="form-table">
<tbody>
<?php
if (true === \wpSPIO()->env()->useTrustedMode())
{
?>
<tr class="trusted-mode-warning">
<td colspan='2'>
<div class='compression-notice warning'>
<p><?php
_e('Trusted file mode is active. This means that ShortPixel will depend on the metadata and not check the fileystem while loading the UI. Information may be incorrect and error may occur during optimization ', 'shortpixel-image-optimiser');
?></p>
<?php if (true === \ShortPixel\Pantheon::IsActive())
{
echo '<p>'; _e('(You are on Pantheon. This setting was automatically activated)'); echo '</p>';
}
?>
</div>
</td>
</tr>
<?php
}
?>
<tr>
<th scope="row"><label for="key"><?php esc_html_e('API Key:','shortpixel-image-optimiser');?></label></th>
<td>
<?php
$canValidate = false;
// Several conditions for showing API key.
if ($this->hide_api_key)
$showApiKey = false;
elseif($this->is_multisite && $this->is_constant_key)
$showApiKey = false;
else {
$showApiKey = true; // is_mainsite, multisite, no constant.
}
$editApiKey = (! $this->is_constant_key && $showApiKey) ? true : false; ;
if($showApiKey) {
$canValidate = true;?>
<input name="key" type="text" id="key" value="<?php echo esc_attr( $view->data->apiKey );?>"
class="regular-text" <?php echo($editApiKey ? "" : 'disabled') ?> <?php echo $this->is_verifiedkey ? 'onkeyup="ShortPixel.apiKeyChanged()"' : '' ?>>
<?php
}
elseif(defined("SHORTPIXEL_API_KEY")) {
$canValidate = true;?>
<input name="key" type="text" id="key" disabled="true" placeholder="<?php
if( $this->hide_api_key ) {
echo("********************");
} else {
esc_html_e('Multisite API Key','shortpixel-image-optimiser');
}
?>" class="regular-text">
<?php } ?>
<input type="hidden" name="validate" id="valid" value=""/>
<span class="spinner" id="pluginemail_spinner" style="float:none;"></span>
<button type="button" id="validate" class="button button-primary" title="<?php esc_html_e('Validate the provided API key','shortpixel-image-optimiser');?>"
onclick="ShortPixel.validateKey(this)" <?php echo $canValidate ? "" : "disabled"?> <?php echo $this->is_verifiedkey ? 'style="display:none;"' : '' ?>>
<?php esc_html_e('Save settings & validate','shortpixel-image-optimiser');?>
</button>
<span class="shortpixel-key-valid" <?php echo $this->is_verifiedkey ? '' : 'style="display:none;"' ?>>
<span class="dashicons dashicons-yes"></span><?php esc_html_e('Your API key is valid.','shortpixel-image-optimiser');?>
</span>
<?php if($this->is_constant_key) { ?>
<p class="settings-info"><?php esc_html_e('Key defined in wp-config.php.','shortpixel-image-optimiser');?></p>
<?php } ?>
</td>
</tr>
<?php if (! $this->is_verifiedkey) { //if invalid key we display the link to the API Key ?>
</tbody>
</table>
<?php } else { //if valid key we display the rest of the options ?>
<tr>
<th scope="row">
<label for="compressionType"><?php esc_html_e('Compression type:','shortpixel-image-optimiser');?></label>
</th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/11-lossy-glossy-or-lossless-which-one-is-the-best-for-me"></span></div>
<input type="hidden" id="compressionType-database" value="<?php echo esc_attr($view->data->compressionType) ?>">
<div class="shortpixel-compression">
<div class="shortpixel-compression-options">
<label class="lossy" title="<?php esc_html_e('This is the recommended option in most cases, producing results that look the same as the original to the human eye.','shortpixel-image-optimiser');?>">
<input type="radio" class="shortpixel-radio-lossy" name="compressionType" value="1" <?php echo( $view->data->compressionType == 1 ? "checked" : "" );?>><span><?php esc_html_e('Lossy','shortpixel-image-optimiser');?></span>
</label>
<label class="glossy" title="<?php esc_html_e('Best option for photographers and other professionals that use very high quality images on their sites and want best compression while keeping the quality untouched.','shortpixel-image-optimiser');?>">
<input type="radio" class="shortpixel-radio-glossy" name="compressionType" value="2" <?php echo( $view->data->compressionType == 2 ? "checked" : "" );?>><span><?php esc_html_e('Glossy','shortpixel-image-optimiser');?></span>
</label>
<label class="lossless" title="<?php esc_html_e('Make sure not a single pixel looks different in the optimized image compared with the original. In some rare cases you will need to use this type of compression. Some technical drawings or images from vector graphics are possible situations.','shortpixel-image-optimiser');?>">
<input type="radio" class="shortpixel-radio-lossless" name="compressionType" value="0" <?php echo( $view->data->compressionType == 0 ? "checked" : "" );?>><span><?php esc_html_e('Lossless','shortpixel-image-optimiser');?></span>
</label>
<?php printf(esc_html__('%s Run a few tests%s to help you decide.', 'shortpixel-image-optimiser'), '<a href="https://shortpixel.com/online-image-compression" style="margin-left:20px;" target="_blank">', '</a>'); ?>
<p class="settings-info shortpixel-radio-info shortpixel-radio-lossy" <?php echo( $view->data->compressionType == 1 ? "" : 'style="display:none"' );?>>
<?php printf(esc_html__('%sLossy SmartCompression (recommended): %s offers the best compression rate. %s What is SmartCompress? %s This is the recommended option for most users, producing results that look the same as the original to the human eye.','shortpixel-image-optimiser'),'<b>','</b>', '<a href="https://shortpixel.com/blog/introducing-smartcompress/" target="_blank" class="shortpixel-help-link"><span class="dashicons dashicons-editor-help"></span>', '</a><br />');?>
</p>
<p class="settings-info shortpixel-radio-info shortpixel-radio-glossy" <?php echo( $view->data->compressionType == 2 ? "" : 'style="display:none"' );?>>
<?php printf(esc_html__('%sGlossy SmartCompression: %s creates images that are almost pixel-perfect identical with the originals. %s What is SmartCompress? %s Best option for photographers and other professionals that use very high quality images on their sites and want the best compression while keeping the quality untouched.','shortpixel-image-optimiser'), '<b>','</b>', '<a href="https://shortpixel.com/blog/introducing-smartcompress/" target="_blank" class="shortpixel-help-link"><span class="dashicons dashicons-editor-help"></span>', '</a><br>');?>
</p>
<p class="settings-info shortpixel-radio-info shortpixel-radio-lossless" <?php echo( $view->data->compressionType == 0 ? "" : 'style="display:none"' );?>>
<?php printf(esc_html__('%s Lossless compression: %s the resulting image is pixel-identical with the original image. %sMake sure not a single pixel looks different in the optimized image compared with the original.
In some rare cases you will need to use this type of compression. Some technical drawings or images from vector graphics are possible situations.','shortpixel-image-optimiser'),'<b>','</b>', '<br>');?>
</p>
</div>
</div>
<script>
<!-- @todo Inline JS -->
function shortpixelCompressionLevelInfo() {
jQuery(".shortpixel-compression p").css("display", "none");
jQuery(".shortpixel-compression p." + jQuery(".shortpixel-compression-options input:radio:checked").attr('class')).css("display", "block");
}
jQuery(".shortpixel-compression-options input:radio").on('change', shortpixelCompressionLevelInfo);
</script>
</td>
</tr>
<tr class="compression-notice-row shortpixel-hide">
<th scope="row">&nbsp;</th>
<td>
<div class='compression-notice warning'>
<p><?php printf(esc_html__('This compression type will apply only to new or unprocessed images. Images that were already processed will not be re-optimized. If you want to change the compression type of already optimized images, %s restore them from the backup %s first.', 'shortpixel-image-optimiser' ),'<a href="options-general.php?page=wp-shortpixel-settings&part=tools">', '</a>'); ?></p>
<p><?php esc_html_e('The current optimization processes in the queue will be stopped.', 'shortpixel-image-optimiser'); ?></p>
</div>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Thumbnail compression:','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/511-settings-also-include-thumbnails"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="processThumbnails" value="1" <?php checked($view->data->processThumbnails, '1');?>>
<div class="the_switch">&nbsp; </div>
<?php printf(esc_html__('Apply compression also to %s image thumbnails.%s ','shortpixel-image-optimiser'), '<strong>', '</strong>'); ?>
</label>
</div>
<p class="settings-info">
<?php printf(esc_html__('It is highly recommended that you optimize the thumbnails as they are usually the images most viewed by end users and can generate most traffic. %s Please note that thumbnails count up to your total quota.','shortpixel-image-optimiser'), '<br>'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Enable SmartCrop:','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/182-what-is-smart-cropping"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="useSmartcrop" value="1" <?php checked($view->data->useSmartcrop, '1');?>>
<div class="the_switch">&nbsp; </div>
<?php printf(esc_html__('Enable %s Smart cropping %s of the images where applicable.','shortpixel-image-optimiser'), '<strong>', '</strong>'); ?>
</label>
</div>
<p class="settings-info">
<?php printf(esc_html__('Generate subject-centered thumbnails using ShortPixel\'s AI engine (%sexample%s). The new thumbnails look sharper (and can be slightly bigger) than the ones created by WordPress. Ideal for e-commerce websites and blogs where the images sell the products/content.','shortpixel-image-optimiser'), '<a href="https://shortpixel.com/knowledge-base/article/182-what-is-smart-cropping" target="_blank">', '</a>'); ?>
</p>
</td>
</tr>
<?php
$smartcrop = (true === \wpSPIO()->env()->plugin_active('s3-offload')) ? 1 : 0; ?>
<tr class='smartcrop_warning view-notice-row' data-smartcrop="<?php echo esc_attr($smartcrop) ?>" >
<th scope="row">&nbsp;</th>
<td>
<div class='view-notice warning'><p>
<?php esc_html_e('It looks like you have the Offload Media plugin enabled. Please note that SmartCropping will not work if you have set the Offload Media plugin to remove files from the server, and strange effects may occur! We recommend you to disable this option in this case.', 'shortpixel-image-optimiser'); ?>
</p>
</div>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Backup','shortpixel-image-optimiser');?></th>
<td>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="backupImages" value="1" <?php checked($view->data->backupImages, '1');?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Create a backup of the original images, saved on your server in /wp-content/uploads/ShortpixelBackups/.','shortpixel-image-optimiser');?>
</label>
</div>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/515-settings-image-backup"></span></div>
<p class="settings-info"><?php esc_html_e('You can remove the backup folder at any moment but it is best to keep a local/cloud copy, in case you want to restore the optimized files to originals or re-optimize the images using a different compression type.','shortpixel-image-optimiser');?></p>
</td>
</tr>
<tr class='view-notice-row backup_warning'>
<th scope='row'>&nbsp;</th>
<td><div class='view-notice warning'><p><?php esc_html_e('Make sure you have a backup in place. When optimizing, ShortPixel will overwrite your images without recovery, which may result in lost images.', 'shortpixel-image-optimiser') ?></p></div></td>
</tr>
<tr>
<th scope="row"><?php esc_html_e('Remove EXIF','shortpixel-image-optimiser');?></th>
<td>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/483-spai-remove-exif"></span></div>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="removeExif" value="1" <?php checked($view->data->keepExif, 0);?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('Remove the EXIF tag of the image (recommended).','shortpixel-image-optimiser');?>
</label>
</div>
</td>
</tr>
<tr class='exif_warning view-notice-row'>
<th scope="row">&nbsp;</th>
<td>
<div class='view-notice warning'><p><?php printf(esc_html__('Warning - Converting from PNG to JPG will %s not %s keep the EXIF information!'), "<strong>","</strong>"); ?></p></div>
</td>
</tr>
<?php $imagick = (\wpSPIO()->env()->hasImagick()) ? 1 : 0; ?>
<tr class='exif_imagick_warning view-notice-row' data-imagick="<?php echo esc_attr($imagick) ?>">
<th scope="row">&nbsp;</th>
<td>
<div class='view-notice warning'><p><?php printf(esc_html__('Warning - Imagick library not detected on server. WordPress will use another library to resize images, which may result in loss of EXIF information'), "<strong>","</strong>"); ?></p></div>
</td>
</tr>
<tr>
<?php $resizeDisabled = (! $this->view->data->resizeImages) ? 'disabled' : '';
// @todo Inline styling here can be decluttered.
?>
<th scope="row"><?php esc_html_e('Resize large images','shortpixel-image-optimiser');?></th>
<td>
<div class='switch_button'>
<label>
<input type="checkbox" class="switch" name="resizeImages" id='resize' value="1" <?php checked($view->data->resizeImages, true);?>>
<div class="the_switch">&nbsp; </div>
<?php esc_html_e('to maximum','shortpixel-image-optimiser') ?>
</label>
</div>
<input type="number" min="1" max="20000" name="resizeWidth" id="width" style="width:80px" class="resize-sizes"
value="<?php echo esc_attr( $view->data->resizeWidth > 0 ? $view->data->resizeWidth : min(1200, $view->minSizes['width']) );?>" <?php echo esc_attr( $resizeDisabled );?>/> <?php
esc_html_e('pixels wide &times;','shortpixel-image-optimiser');?>
<input type="number" min="1" max="20000" name="resizeHeight" id="height" class="resize-sizes" style="width:80px"
value="<?php echo esc_attr( $view->data->resizeHeight > 0 ? $view->data->resizeHeight : min(1200, $view->minSizes['height']) );?>" <?php echo esc_attr( $resizeDisabled );?>/> <?php
esc_html_e('pixels high (preserves the original aspect ratio and doesn\'t crop the image)','shortpixel-image-optimiser');?>
<input type="hidden" id="min-resizeWidth" value="<?php echo esc_attr($view->minSizes['width']);?>" data-nicename="<?php esc_html_e('Width', 'shortpixel-image-optimiser'); ?>" />
<input type="hidden" id="min-resizeHeight" value="<?php echo esc_attr($view->minSizes['height']);?>" data-nicename="<?php esc_html_e('Height', 'shortpixel-image-optimiser'); ?>"/>
<p class="settings-info">
<?php esc_html_e('Recommended for large photos, like the ones taken with your phone. Saved space can go up to 80% or more after resizing. Please note that this option does not prevent thumbnails from being created that should be larger than the selected dimensions, but these thumbnails will also be resized to the dimensions selected here.','shortpixel-image-optimiser');?>
</p>
<?php if(false) { ?>
<div style="margin-top: 10px;">
<input type="radio" name="resizeType" id="resize_type_outer" value="outer" <?php echo($view->data->resizeType == 'inner' ? '' : 'checked') ?> style="margin: -50px 10px 60px 0;">
<img alt="<?php esc_html_e('Resize outer','shortpixel-image-optimiser'); ?>" src="<?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-outer.png' ));?>"
srcset='<?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-outer.png' ));?> 1x, <?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-outer@2x.png' ));?> 2x'
title="<?php esc_html_e('Sizes will be greater or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 1000x1500px while an image of 3000x2000px will be resized to 1800x1200px','shortpixel-image-optimiser');?>">
<input type="radio" name="resizeType" id="resize_type_inner" value="inner" <?php echo esc_attr($view->data->resizeType == 'inner' ? 'checked' : '') ?> style="margin: -50px 10px 60px 35px;">
<img alt="<?php esc_html_e('Resize inner','shortpixel-image-optimiser'); ?>" src="<?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-inner.png' ));?>"
srcset='<?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-inner.png' ));?> 1x, <?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-inner@2x.png' ));?> 2x'
title="<?php esc_html_e('Sizes will be smaller or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 800x1200px while an image of 3000x2000px will be resized to 1000x667px','shortpixel-image-optimiser');?>">
</div>
<?php } ?>
<style>
.presentation-wrap {
padding: 10px;
text-align: center;
display: flex;
justify-content: center;
width: 600px;
}
@media(max-width: 1280px) {
.presentation-wrap {
width: 460px;
}
}
@media(max-width: 1140px) {
.presentation-wrap {
width: 320px;
}
}
.presentation-wrap img {
margin-auto;
}
.spai-resize-frame {
position: absolute;
border: 2px dashed #fd1d1d;
}
.spai-resize-frame:after {
font-size: 10px;
font-weight: bold;
position: absolute;
bottom: -15px;
right: 0;
color: red;
}
.resize-options-wrap {
margin: 10px 20px 0 20px;
float: left;
}
.resize-type-wrap label {
display: inline-block;
padding: 15px 0 0 0;
}
</style>
<div class="resize-type-wrap" <?php echo( $view->data->resizeImages ? '' : 'style="display:none;"' );?>>
<div class="resize-options-wrap">
<label title="<?php esc_html_e('Sizes will be greater or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 1000x1500px while an image of 3000x2000px will be resized to 1800x1200px','shortpixel-image-optimiser');?>">
<input type="radio" name="resizeType" id="resize_type_outer" value="outer" <?= $view->data->resizeType == 'inner' ? '' : 'checked'; ?>>
<?= esc_html__( 'Cover', 'shortpixel-image-optimiser' ); ?>
</label><br>
<label title="<?php esc_html_e('Sizes will be smaller or equal to the corresponding value. For example, if you set the resize dimensions at 1000x1200, an image of 2000x3000px will be resized to 800x1200px while an image of 3000x2000px will be resized to 1000x667px','shortpixel-image-optimiser');?>">
<input type="radio" name="resizeType" id="resize_type_inner" value="inner" <?= $view->data->resizeType == 'inner' ? 'checked' : ''; ?>>
<?= esc_html__( 'Contain', 'shortpixel-image-optimiser' ); ?>
</label><br>
<div style="display:inline-block;margin-top: 15px;"><a href="https://shortpixel.com/knowledge-base/article/208-can-shortpixel-automatically-resize-new-image-uploads" class="shortpixel-help-link" target="_blank">
<span class="dashicons dashicons-editor-help"></span><?php esc_html_e('What is this?','shortpixel-image-optimiser');?></a>
</div>
</div>
<?php
$resize_width = (int) ( $view->data->resizeWidth > 0 ? $view->data->resizeWidth : min( 1200, $view->minSizes[ 'width' ] ) );
$resize_height = (int) ( $view->data->resizeHeight > 0 ? $view->data->resizeHeight : min( 1200, $view->minSizes[ 'height' ] ) );
$ratio = $resize_height / $resize_width;
$frame_style = 'padding-top:' . round( ( $ratio < 1.5 ? ( $ratio < 0.5 ? 0.5 : $ratio ) : 1.5 ) * 100, 0 ) . '%;';
$image_size = getimagesize( wpSPIO()->plugin_path( 'res/img/resize-type.png' ) );
?>
<div class="presentation-wrap">
<div class="spai-resize-frame"></div>
<img class="spai-resize-img" src="<?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-type.png'));?>" data-width="300" data-height="160"
srcset="<?php echo esc_url(wpSPIO()->plugin_url('res/img/resize-type@2x.png'));?> 2x" alt="">
</div>
</div>
</td>
</tr>
</tbody>
</table>
<?php } ?>
<p class="submit">
<input type="submit" name="save" id="save" class="button button-primary" title="<?php esc_attr_e('Save Changes','shortpixel-image-optimiser');?>" value="<?php esc_attr_e('Save Changes','shortpixel-image-optimiser');?>"> &nbsp;
<input type="submit" name="save_bulk" id="bulk" class="button button-primary" title="<?php esc_attr_e('Save and go to the Bulk Processing page','shortpixel-image-optimiser');?>" value="<?php esc_attr_e('Save and Go to Bulk Process','shortpixel-image-optimiser');?>"> &nbsp;
</p>
</div>
</section>

View File

@ -0,0 +1,144 @@
<?php
namespace ShortPixel;
use ShortPixel\Notices\NoticeController as Notice;
use ShortPixel\ShortPixelLogger\ShortPixelLogger as Log;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$canValidate = false;
// Several conditions for showing API key.
if ($this->hide_api_key)
$showApiKey = false;
elseif($this->is_multisite && $this->is_constant_key)
$showApiKey = false;
else {
$showApiKey = true; // is_mainsite, multisite, no constant.
}
$editApiKey = (! $this->is_constant_key && $showApiKey) ? true : false;
// Notices for fringe cases
if (! $this->is_verifiedkey && $this->hide_api_key && ! $this->is_constant_key)
{
Notice::addError(__('wp-config.php is hiding the API key, but no API key was found. Remove the constant, or define the SHORTPIXEL_API_KEY constant as well', 'shortpixel-image-optimiser'));
}
elseif ($this->is_constant_key && ! $this->is_verifiedkey)
{
$dkey = ($this->hide_api_key) ? '' : '(' . SHORTPIXEL_API_KEY. ')';
Notice::addError(sprintf(__('Constant API Key is not verified. Please check if this is a valid API key %s'),$dkey));
}
$adminEmail = get_bloginfo('admin_email');
?>
<section id="tab-settings" class="sel-tab" >
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-settings">
<?php esc_html_e('Join ShortPixel','shortpixel-image-optimiser');?></a>
</h2>
<div class="wp-shortpixel-options wp-shortpixel-tab-content">
<?php if($showApiKey): ?>
<!-- // @todo Inline CSS on whole page-->
<h3><?php esc_html_e('Request an API Key:','shortpixel-image-optimiser');?></h3>
<p style='font-size: 14px'><?php esc_html_e('If you don\'t have an API Key, you can request one for free. Just press the "Request Key" button after checking that the e-mail is correct.','shortpixel-image-optimiser');?></p>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="key"><?php esc_html_e('E-mail address:','shortpixel-image-optimiser');?></label></th>
<td>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('noheader' => 'true', 'sp-action' => 'action_request_new_key'))) ?>"
id="shortpixel-form-request-key">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<input name="pluginemail" type="text" id="pluginemail" value="<?php echo esc_attr( sanitize_email($adminEmail) );?>"
class="regular-text">
<span class="spinner" id="pluginemail_spinner" style="float:none;"></span>
<button type="submit" id="request_key" class="button button-primary" title="<?php esc_html_e('Request a new API key','shortpixel-image-optimiser');?>"
href="https://shortpixel.com/free-sign-up?pluginemail=<?php echo esc_attr( esc_url($adminEmail) );?>">
<?php esc_html_e('Request Key','shortpixel-image-optimiser');?>
</button>
<p class="settings-info shortpixel-settings-error" style='display:none;' id='pluginemail-error'>
<b><?php esc_html_e('Please provide a valid e-mail address.', 'shortpixel-image-optimiser');?></b>
</p>
<p class="settings-info" id='pluginemail-info'>
<?php if($adminEmail) {
printf(esc_html__('%s %s %s is the e-mail address in your WordPress Settings. You can use it, or change it to any valid e-mail address that you own.','shortpixel-image-optimiser'), '<b>', esc_html(sanitize_email($adminEmail)), '</b>');
} else {
esc_html_e('Please input your e-mail address and press the Request Key button.','shortpixel-image-optimiser');
}
?><p><span style="position:relative;">
<input name="tos" type="checkbox" id="tos">
<img id="tos-robo" alt="<?php esc_html_e('ShortPixel logo', 'shortpixel-image-optimiser'); ?>"
src="<?php echo esc_url(wpSPIO()->plugin_url('res/img/slider.png' ));?>" style="position: absolute;left: -95px;bottom: -26px;display:none;">
<img id="tos-hand" alt="<?php esc_html_e('Hand pointing', 'shortpixel-image-optimiser'); ?>"
src="<?php echo esc_url(wpSPIO()->plugin_url('res/img/point.png' ));?>" style="position: absolute;left: -39px;bottom: -9px;display:none;">
</span>
<label for="tos"><?php printf(esc_html__('I have read and I agree to the %s Terms of Service %s and the %s Privacy Policy %s (%s GDPR compliant %s).','shortpixel-image-optimiser'), '<a href="https://shortpixel.com/tos" target="_blank">', '</a>', '<a href="https://shortpixel.com/privacy" target="_blank">', '</a>', '<a href="https://shortpixel.com/privacy#gdpr" target="_blank">', '</a>');
?> </label></p>
</p>
</form>
</td>
</tr>
</tbody>
</table>
<?php endif; ?>
<h3>
<?php esc_html_e('Already have an API Key:','shortpixel-image-optimiser');?>
</h3>
<p style='font-size: 14px'>
<?php esc_html_e('If you already have an API Key please input it below and press Validate.','shortpixel-image-optimiser');?>
</p>
<form method="POST" action="<?php echo esc_url(add_query_arg(array('noheader' => 'true', 'sp-action' => 'action_addkey'))) ?>"
id="shortpixel-form-nokey">
<?php wp_nonce_field($this->form_action, 'sp-nonce'); ?>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="key"><?php esc_html_e('API Key:','shortpixel-image-optimiser');?></label></th>
<td>
<?php
if($showApiKey) {
if (! $this->is_constant_key)
$canValidate = true;
?>
<input name="key" type="text" id="key" value="<?php echo esc_attr( $view->data->apiKey );?>"
class="regular-text" <?php echo($editApiKey ? "" : 'disabled') ?> >
<?php
}
elseif(defined("SHORTPIXEL_API_KEY")) {
$canValidate = true;?>
<input name="key" type="text" id="key" disabled="true" placeholder="<?php
if( $this->hide_api_key ) {
echo esc_html("********************");
} else {
esc_html_e('Multisite API Key','shortpixel-image-optimiser');
}
?>" class="regular-text">
<?php } ?>
<input type="hidden" name="validate" id="valid" value="validate"/>
<span class="spinner" id="pluginemail_spinner" style="float:none;"></span>
<button type="submit" id="validate" class="button button-primary" title="<?php esc_html_e('Validate the provided API key','shortpixel-image-optimiser');?>"
>
<?php esc_html_e('Validate','shortpixel-image-optimiser');?>
</button>
<?php if($this->is_constant_key) { ?>
<p class="settings-info"><?php esc_html_e('Key defined in wp-config.php.','shortpixel-image-optimiser');?></p>
<?php } ?>
</td>
</tr>
</tbody>
</table>
</form>
</div> <!-- tab content -->
</section>

View File

@ -0,0 +1,39 @@
<?php
namespace ShortPixel;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$total_circle = 289.027;
$total =round($view->averageCompression);
if( $total >0 ) {
$total_circle = round($total_circle-($total_circle * $total /100));
}
?>
<div class="sp-bulk-summary">
<span><?php esc_html_e('Average optimization', 'shortpixel-image-optimiser'); ?></span><br>
<a title="<?php esc_html_e('Average optimization', 'shortpixel-image-optimiser'); ?>">
<svg class="opt-circle-average" viewBox="-10 0 120 100">
<path class="trail" d="
M 50,50
m 0,-46
a 46,46 0 1 1 0,92
a 46,46 0 1 1 0,-92
" stroke-width="16" fill-opacity="0">
</path>
<path class="path" d="
M 50,50
m 0,-46
a 46,46 0 1 1 0,92
a 46,46 0 1 1 0,-92
" stroke-width="16" fill-opacity="0" style="stroke-dasharray: 289.027px, 289.027px; stroke-dashoffset: <?php echo esc_html($total_circle) ?>">
</path>
<text class="text" x="52" y="55"><?php echo esc_html($total) ?>%</text>
</svg>
</a>
</div>

View File

@ -0,0 +1,171 @@
<?php
namespace ShortPixel;
use \ShortPixel\Controller\BulkController as BulkController;
use \ShortPixel\Helper\UiHelper as UiHelper;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$url = esc_url_raw(remove_query_arg('part'));
$bulk = BulkController::getInstance();
$queueRunning = $bulk->isAnyBulkRunning();
?>
<section id="tab-tools" class="clearfix <?php echo ($this->display_part == 'tools') ? ' sel-tab ' :''; ?> ">
<h2><a class='tab-link' href='javascript:void(0);' data-id="tab-tools"><?php esc_html_e('Tools','shortpixel-image-optimiser');?></a></h2>
<p><?php printf(esc_html__('The tools provided below are designed to make bulk changes to your image and optimization data. Therefore, it is %s very important %s that you back up your entire website before running them. ', 'shortpixel-image-optimiser'), '<b>', '</b>'); ?></p>
<div class='wp-shortpixel-options wp-shortpixel-tab-content'>
<?php if ($queueRunning === true): ?>
<div class='option'>
<div class='name'>&nbsp;</div>
<div class='field action queue-warning'>
<?php esc_html_e('It looks like a bulk process is still active. Please note that bulk actions will reset running bulk processes. ', 'shortpixel-image-optimiser'); ?>
</div>
</div>
<?php endif; ?>
<div class='option'>
<div class='name'><?php esc_html_e('Migrate data', 'shortpixel-image-optimiser'); ?></div>
<div class='field'>
<div class='option-content'>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/539-spio-5-tells-me-to-convert-legacy-data-what-is-this">
</span></div>
<a href="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_redirectBulk', 'bulk' => 'migrate', 'noheader' => true), $url)); ?>" class="button">
<?php esc_html_e('Search and Migrate All', 'shortpixel-image-optimiser'); ?>
</a>
</div>
<p class='settings-info'><?php printf(esc_html__('ShortPixel Image Optimizer version 5.0 brings a new format for saving the image optimization information. If you have upgraded from a version prior to version 5.0, you may want to convert all your image data to the new format. This conversion will speed up the plugin and ensure that all data is preserved. %s Check your image data after doing the conversion! %s', 'shortpixel-image-optimiser'), '<br><b>', '</b>') ?> </p>
</div>
</div>
<div class='option'>
<div class='name'><?php esc_html_e('Clear Queue','shortpixel-image-optimiser'); ?></div>
<div class='field'>
<a href="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_resetQueue', 'queue' => 'all', 'part' => 'tools', 'noheader' => true), $url)); ?>" class="button"><?php esc_html_e('Clear the Queue','shortpixel-image-optimiser'); ?></a>
<p class='settings-info'><?php esc_html_e('Removes all items currently waiting or being processed from all queues. This stops all optimization processes in the entire installation.', 'shortpixel-image-optimiser'); ?> </p>
</div>
</div>
<div class='option'>
<div class='name'><?php esc_html_e('Clear Optimization Errors','shortpixel-image-optimiser'); ?></div>
<div class='field'>
<a href="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_removePrevented', 'queue' => 'all', 'part' => 'tools', 'noheader' => true), $url)); ?>" class="button"><?php esc_html_e('Clear Optimization Errors','shortpixel-image-optimiser'); ?></a>
<p class='settings-info'><?php printf(esc_html__('Removes the blocks from the items where the optimization failed for some reason. This usually happens when the plugin is not able to save the backups. %sImportant!%s The cause of the error should be fixed, otherwise data corruption may occur.','shortpixel-image-optimiser') , '<b>','</b>'); ?> </p>
</div>
</div>
<hr />
<div class='danger-zone'>
<h3><?php esc_html_e('Danger Zone - please read carefully!', 'shortpixel-image-optimiser'); ?></h3>
<p><?php printf(esc_html__('The following actions are related to cleaning up and uninstalling the plugin. %s They cannot be undone %s. It is important that you create a new backup copy before performing any of these actions, as this may result in data loss.', 'shortpixel-image-optimiser'), '<strong>', '</strong>'); ?></p>
<hr />
<div class='option'>
<div class='name'>Remove data</div>
<div class='field'>
<div class="option-content">
<a href="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_redirectBulk', 'bulk' => 'restore', 'noheader' => true), $url)) ?>" class="button danger">Bulk Restore</a>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/14-can-i-restore-my-images-what-happens-with-the-originals"></span></div>
</div>
<p class='settings-info'><?php printf(esc_html__('%sUndoes%s all optimizations and restores all your backed-up images to their original state. Credits used will not be refunded and you will have to optimize your images again.', 'shortpixel-image-optimiser'), '<b>','</b>'); ?></p>
</div>
</div>
<div class='option'>
<div class='name'>&nbsp;</div>
<div class='field'>
<a href="<?php echo esc_url(add_query_arg(array('sp-action' => 'action_debug_redirectBulk', 'bulk' => 'removeLegacy', 'noheader' => true), $url)); ?>" class="button danger">Remove Legacy Data</a>
<p class='settings-info'><?php printf(esc_html__('%sRemoves Legacy Data%s (the old format for storing image optimization information in the database, which was used before version 5). This may result in data loss. It is not recommended to do this manually.', 'shortpixel-image-optimiser'), '<b>','</b>'); ?></p>
</div>
</div>
<div class='option'>
<div class='name'>&nbsp;</div>
<div class='field'>
<div class="option-content">
<button type="button" class='button danger' data-action="open-modal" data-target="ToolsRemoveAll">
<?php esc_html_e('Remove all ShortPixel Data', 'shortpixel-image-optimiser'); ?></button>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/81-remove-all-the-shortpixel-related-data-on-a-wp-website"></span></div>
</div>
<div class='remove-all modalTarget' id="ToolsRemoveAll">
<input type="hidden" name="screen_action" value="toolsRemoveAll" />
<?php wp_nonce_field('remove-all', 'tools-nonce'); ?>
<p>&nbsp;</p>
<p><?php esc_html_e('This will remove all ShortPixel Data including data about optimization and image backups.', 'shortpixel-image-optimiser'); ?></p>
<?php esc_html_e('Type confirm to delete all ShortPixel data', 'shortpixel-image-optimiser'); ?>
<input type="text" name="confirm" value="" data-required='confirm' />
<p><b><?php esc_html_e('I understand that all ShortPixel data will be removed.','shortpixel-image-optimiser'); ?></b></p>
<button type="button" class='button modal-send' name="uninstall" data-action='ajaxrequest'><?php esc_html_e('Remove all data', 'shortpixel-image-optimiser'); ?></button>
</div> <!-- modal -->
<p class='settings-info'><?php printf(esc_html__('%sRemoves all ShortPixel data (including backups) %s and deactivates the plugin. Your images will not be changed (the optimized images will remain), but the next time ShortPixel is activated, it will no longer recognize previous optimizations.', 'shortpixel-image-optimiser'), '<b>','</b>'); ?></p>
</div>
</div>
<div class="option">
<div class='name'>&nbsp;</div>
<div class='field'>
<div class="backup-modal">
<?php wp_nonce_field('empty-backup', 'tools-nonce'); ?>
<div class="option-content">
<button type="button" class='button danger' data-action="open-modal" data-target="ToolsRemoveBackup">
<?php esc_html_e('Remove backups', 'shortpixel-image-optimiser'); ?></button>
<div class="spio-inline-help"><span class="dashicons dashicons-editor-help" title="Click for more info" data-link="https://shortpixel.com/knowledge-base/article/83-how-to-remove-the-backed-up-images-in-wordpress"></span></div>
</div>
<div class='remove-backup modalTarget' id="ToolsRemoveBackup">
<input type="hidden" name="screen_action" value="toolsRemoveBackup" />
<?php wp_nonce_field('empty-backup', 'tools-nonce'); ?>
<p>&nbsp;</p>
<p><?php esc_html_e('This will delete all the backup images. You won\'t be able to restore from backup or to reoptimize with different settings if you delete the backups.', 'shortpixel-image-optimiser'); ?></p>
<?php esc_html_e('Type confirm to delete all ShortPixel backups', 'shortpixel-image-optimiser'); ?>
<input type="text" name="confirm" value="" data-required='confirm' />
<p><b><?php esc_html_e('I understand that all Backups will be removed.','shortpixel-image-optimiser'); ?> </b></p>
<p class='center'>
<button type="button" class='button modal-send' name="removebackups" data-action='ajaxrequest'><?php esc_html_e('Remove backups', 'shortpixel-image-optimiser'); ?></button>
</p>
</div>
</div> <!-- backup modal -->
<p class='settings-info'><?php esc_html_e('When backups are enabled, original images are stored in a backup folder. If you remove the backup folder, you will not be able to restore or reoptimize the images. We strongly recommend that you keep a copy of the backup folder (/wp-content/uploads/ShortpixelBackups/) somewhere safe.','shortpixel-image-optimiser');?>
</div>
</div>
</div> <!-- danger zone -->
</div> <!-- options tab content -->
</section>

View File

@ -0,0 +1,34 @@
<?php
namespace ShortPixel;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$bool = apply_filters('shortpixel/settings/no_banner', true);
if (! $bool )
return;
if ( defined('SHORTPIXEL_NO_BANNER') && SHORTPIXEL_NO_BANNER == true)
return;
?>
<section class='wso banner'>
<span class="image">
<a href="https://fastpixel.io/?utm_source=SPIO" target="_blank">
<img src="<?php echo \wpSPIO()->plugin_url() ?>res/img/fastpixel-logo.svg" />
</a>
</span>
<span class="line"><h3>
<?php printf(__('FAST%sPIXEL%s - the new website accelerator plugin from ShortPixel', 'shortpixel-image-optimiser'), '<span class="red">','</span>'); ?>
</h3>
</span>
<!-- <span class="line"><h3>
<?php printf(__('ALLOW ShortPixel SPECIALISTS TO %s FIND THE SOLUTION FOR YOU.', 'shortpixel-image-optimiser'), '<br>'); ?>
</h3>
</span> -->
<span class="button-wrap">
<a href="https://fastpixel.io/?utm_source=SPIO" target="_blank" class='button' ><?php _e('TRY NOW!', 'shortpixel-image-optimiser'); ?></a>
</span>
</section>