fix
This commit is contained in:
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Subscribe Widget Class
|
||||
*
|
||||
* Self-contained newsletter subscription widget that can be used on any admin page.
|
||||
* No dependencies on Factory libs.
|
||||
*
|
||||
* @package Robin_Image_Optimizer
|
||||
* @subpackage Admin\Includes
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WRIO_Subscribe_Widget
|
||||
*/
|
||||
class WRIO_Subscribe_Widget {
|
||||
|
||||
/**
|
||||
* ThemeIsle subscription API endpoint
|
||||
*/
|
||||
const API_URL = 'https://api.themeisle.com/tracking/subscribe';
|
||||
|
||||
/**
|
||||
* Option name to track subscription status
|
||||
*/
|
||||
const OPTION_SUBSCRIBED = 'wrio_user_subscribed';
|
||||
|
||||
/**
|
||||
* Plugin slug for API
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $plugin_name = 'wbcr_image_optimizer';
|
||||
|
||||
/**
|
||||
* Privacy policy URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $privacy_url = 'https://themeisle.com/privacy-policy/';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_wrio_subscribe', [ $this, 'ajax_handler' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has already subscribed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_subscribed() {
|
||||
return (bool) get_option( self::OPTION_SUBSCRIBED, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the subscribe widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
if ( $this->is_subscribed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$nonce = wp_create_nonce( 'wrio_subscribe' );
|
||||
?>
|
||||
<div class="wrio-subscribe-widget">
|
||||
<div class="wrio-subscribe-widget__header">
|
||||
<h3><?php esc_html_e( 'Subscribe to plugin\'s newsletter', 'robin-image-optimizer' ); ?></h3>
|
||||
</div>
|
||||
<div class="wrio-subscribe-widget__body">
|
||||
<p><?php esc_html_e( 'Get the latest news and updates about the plugin:', 'robin-image-optimizer' ); ?></p>
|
||||
<div class="wrio-subscribe-widget__messages">
|
||||
<div class="wrio-subscribe-widget__success" style="display:none;">
|
||||
<?php esc_html_e( 'Thank you for subscribing.', 'robin-image-optimizer' ); ?>
|
||||
</div>
|
||||
<div class="wrio-subscribe-widget__error" style="display:none;"></div>
|
||||
</div>
|
||||
<form class="wrio-subscribe-widget__form">
|
||||
<div class="wrio-subscribe-widget__field-wrap">
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="wrio-subscribe-widget__email"
|
||||
placeholder="<?php esc_attr_e( 'Enter your email address', 'robin-image-optimizer' ); ?>"
|
||||
required
|
||||
>
|
||||
<button type="submit" class="button button-primary wrio-subscribe-widget__button">
|
||||
<?php esc_html_e( 'Subscribe', 'robin-image-optimizer' ); ?>
|
||||
</button>
|
||||
</div>
|
||||
<label class="wrio-subscribe-widget__checkbox-label">
|
||||
<input type="checkbox" name="agree_terms" checked required>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %1$s: opening link tag, %2$s: closing link tag */
|
||||
esc_html__( 'I agree to receive the Themeisle newsletter. See our %1$sPrivacy Policy%2$s for details.', 'robin-image-optimizer' ),
|
||||
'<a href="' . esc_url( $this->privacy_url ) . '" target="_blank" rel="noopener">',
|
||||
'</a>'
|
||||
);
|
||||
?>
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function() {
|
||||
const form = document.querySelector('.wrio-subscribe-widget__form');
|
||||
if (!form) return;
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const button = form.querySelector('.wrio-subscribe-widget__button');
|
||||
const successEl = document.querySelector('.wrio-subscribe-widget__success');
|
||||
const errorEl = document.querySelector('.wrio-subscribe-widget__error');
|
||||
const email = form.querySelector('[name="email"]').value;
|
||||
const agreed = form.querySelector('[name="agree_terms"]').checked;
|
||||
|
||||
if (!agreed) {
|
||||
return;
|
||||
}
|
||||
|
||||
button.disabled = true;
|
||||
button.textContent = '<?php echo esc_js( __( 'Subscribing...', 'robin-image-optimizer' ) ); ?>';
|
||||
errorEl.style.display = 'none';
|
||||
|
||||
const data = new FormData();
|
||||
data.append('action', 'wrio_subscribe');
|
||||
data.append('email', email);
|
||||
data.append('_wpnonce', '<?php echo esc_js( $nonce ); ?>');
|
||||
|
||||
fetch(ajaxurl, {
|
||||
method: 'POST',
|
||||
body: data
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
form.style.display = 'none';
|
||||
successEl.style.display = 'block';
|
||||
} else {
|
||||
errorEl.textContent = res.data.message || '<?php echo esc_js( __( 'An error occurred. Please try again.', 'robin-image-optimizer' ) ); ?>';
|
||||
errorEl.style.display = 'block';
|
||||
button.disabled = false;
|
||||
button.textContent = '<?php echo esc_js( __( 'Subscribe', 'robin-image-optimizer' ) ); ?>';
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
errorEl.textContent = '<?php echo esc_js( __( 'An error occurred. Please try again.', 'robin-image-optimizer' ) ); ?>';
|
||||
errorEl.style.display = 'block';
|
||||
button.disabled = false;
|
||||
button.textContent = '<?php echo esc_js( __( 'Subscribe', 'robin-image-optimizer' ) ); ?>';
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle AJAX subscription request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ajax_handler() {
|
||||
check_ajax_referer( 'wrio_subscribe', '_wpnonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( [ 'message' => __( 'Permission denied.', 'robin-image-optimizer' ) ] );
|
||||
}
|
||||
|
||||
$email = isset( $_POST['email'] ) ? sanitize_email( wp_unslash( $_POST['email'] ) ) : '';
|
||||
|
||||
if ( ! is_email( $email ) ) {
|
||||
wp_send_json_error( [ 'message' => __( 'Please enter a valid email address.', 'robin-image-optimizer' ) ] );
|
||||
}
|
||||
|
||||
$body = wp_json_encode(
|
||||
[
|
||||
'slug' => $this->plugin_name,
|
||||
'site' => home_url(),
|
||||
'email' => $email,
|
||||
]
|
||||
);
|
||||
|
||||
// Ensure body is a string, not false.
|
||||
if ( false === $body ) {
|
||||
wp_send_json_error( [ 'message' => __( 'Failed to encode request body.', 'robin-image-optimizer' ) ] );
|
||||
}
|
||||
|
||||
$response = wp_remote_post(
|
||||
self::API_URL,
|
||||
[
|
||||
'timeout' => 10,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'Cache-Control' => 'no-cache',
|
||||
'Accept' => 'application/json, */*;q=0.1',
|
||||
],
|
||||
'body' => $body,
|
||||
]
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
wp_send_json_error( [ 'message' => $response->get_error_message() ] );
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body( $response );
|
||||
$data = json_decode( $body, true );
|
||||
|
||||
if ( isset( $data['code'] ) ) {
|
||||
update_option( self::OPTION_SUBSCRIBED, 1 );
|
||||
wp_send_json_success( [ 'message' => __( 'Subscribed successfully!', 'robin-image-optimizer' ) ] );
|
||||
}
|
||||
|
||||
wp_send_json_error( [ 'message' => __( 'Subscription failed. Please try again.', 'robin-image-optimizer' ) ] );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Класс используется для вывода страницы лендинга
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
class WIO_NextgenLanding {
|
||||
|
||||
/**
|
||||
* Инициализация лендинга
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_menu', [ $this, 'removeSubMenu' ], 99999 );
|
||||
add_action( 'admin_menu', [ $this, 'addSubMenu' ], 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаляет лендинг nextgen
|
||||
*/
|
||||
public function removeSubMenu() {
|
||||
remove_submenu_page( 'nextgen-gallery', 'ngg_imagify' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляем свою страницу в меню Тextgen
|
||||
*/
|
||||
public function addSubMenu() {
|
||||
add_submenu_page(
|
||||
'nextgen-gallery',
|
||||
__( 'Image optimizer', 'robin-image-optimizer' ),
|
||||
__( 'Image optimizer', 'robin-image-optimizer' ),
|
||||
'manage_options',
|
||||
'ngg_robin', // если взять старый слаг ngg_imagify, то на странице выведет оба лендинга
|
||||
[ $this, 'nngLandingPage' ]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Контент лендинга
|
||||
*/
|
||||
public function nngLandingPage() {
|
||||
// если активна премиум версия - делаем редирект на страницу статистики nextgen
|
||||
if ( defined( 'WRIOP_PLUGIN_ACTIVE' ) && WRIOP_PLUGIN_ACTIVE ) {
|
||||
wp_redirect( admin_url( 'admin.php?page=io_nextgen_gallery_statistic-wbcr_image_optimizer' ) );
|
||||
die();
|
||||
}
|
||||
?>
|
||||
рекламма установки премиум аддона
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
new WIO_NextgenLanding();
|
||||
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Класс реализует шаблон блока статистики
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
class WIO_OptimizePageTemplate {
|
||||
|
||||
/**
|
||||
* Тип страницы
|
||||
*/
|
||||
protected $page_type = 'media-library';
|
||||
|
||||
|
||||
public function __construct( $type = 'media-library' ) {
|
||||
$this->page_type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Выводит контент страницы с учётом мультисайта
|
||||
*
|
||||
* @param WRIO_Page $page
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
/*
|
||||
public function showPageContent( WRIO_Page $page ) {
|
||||
do_action( 'wbcr/rio/multisite_current_blog' );
|
||||
$this->pageContent( $page );
|
||||
do_action( 'wbcr/rio/multisite_restore_blog' );
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Выбор сайта для мультисайт режима
|
||||
*/
|
||||
/*
|
||||
public function selectSite() {
|
||||
if ( ! WRIO_Plugin::app()->isNetworkAdmin() ) {
|
||||
return;
|
||||
}
|
||||
$blogs = WIO_Multisite::getBlogs( $this->page_type );
|
||||
$current_blog = WRIO_Plugin::app()->getPopulateOption( 'current_blog', 1 );
|
||||
?>
|
||||
<select style="width:200px;display:inline-block; height: 45px; margin-left:40px;" id="wbcr-rio-current-blog"
|
||||
class="factory-dropdown factory-from-control-dropdown form-control"
|
||||
data-context="<?php echo esc_attr( $this->page_type ); ?>"
|
||||
data-nonce="<?php echo wp_create_nonce( 'update_blog_id' ); ?>">
|
||||
<?php foreach ( $blogs as $blog ) : ?>
|
||||
<?php
|
||||
$blog_name = $blog->domain . $blog->path;
|
||||
if ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) {
|
||||
$blog_name = $blog->domain;
|
||||
}
|
||||
?>
|
||||
<option <?php selected( $current_blog, $blog->blog_id ); ?>
|
||||
value="<?php echo esc_attr( $blog->blog_id ); ?>"><?php echo esc_attr( $blog_name ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Возвращает html код блока ручной оптимизации
|
||||
*
|
||||
* @param array $params {
|
||||
* Параметры
|
||||
*
|
||||
* @type int $attachment_id Attachment post ID
|
||||
* @type bool $is_optimized Оптимизировано ли изображение
|
||||
* @type string $attach_dimensions Размеры изображения. Например 200x150
|
||||
* @type int $attachment_file_size Размер оригинального основного файла в байтах
|
||||
* @type bool $is_skipped Пропущено ли изображение. Изображения с таким флагом больше не участвуют в
|
||||
* оптимизации
|
||||
* @type int $optimized_size Оптимизированный размер основного файла + превьюшек в байтах
|
||||
* @type int $original_size Оригинальный размер основного файла + превьюшек в байтах
|
||||
* @type int $original_main_size Оригинальный размер основного файла в байтах
|
||||
* @type int $thumbnails_optimized Кол-во оптимизированных превьюшек
|
||||
* @type string $optimization_level Уровень оптимизации
|
||||
* @type string $error_msg Текст ошибки
|
||||
* @type bool $backuped Сделана ли резервная копия
|
||||
* @type float $diff_percent Разница между оригиналом и оптимизацией в процентах
|
||||
* @type float $diff_percent_all Общая оптимизация в процентах
|
||||
* }
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediaColumnTemplate( $params ) {
|
||||
ob_start();
|
||||
|
||||
$ajaxActionOptimize = apply_filters( 'wbcr/rio/optimize_template/reoptimize_ajax_action', 'wio_reoptimize_image', $this->page_type );
|
||||
$ajaxActionConvert = apply_filters( 'wbcr/rio/optimize_template/convert_ajax_action', 'wio_convert_image', $this->page_type );
|
||||
$ajaxActionRestore = apply_filters( 'wbcr/rio/optimize_template/restore_ajax_action', 'wio_restore_image', $this->page_type );
|
||||
|
||||
$attachment_id = $params['attachment_id'];
|
||||
$is_optimized = $params['is_optimized'];
|
||||
$attach_dimensions = $params['attach_dimensions'];
|
||||
$attachment_file_size = $params['attachment_file_size'];
|
||||
$is_skipped = $params['is_skipped'];
|
||||
$is_supported_format = isset( $params['is_supported_format'] ) ? $params['is_supported_format'] : true;
|
||||
$webp_size = $params['webp_size'];
|
||||
$avif_size = isset( $params['avif_size'] ) ? $params['avif_size'] : 0;
|
||||
$webp_percent = isset( $params['webp_percent'] ) ? $params['webp_percent'] : 0;
|
||||
$avif_percent = isset( $params['avif_percent'] ) ? $params['avif_percent'] : 0;
|
||||
$backuped = isset( $params['backuped'] ) ? $params['backuped'] : false;
|
||||
|
||||
if ( $is_skipped ) {
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
|
||||
// Don't show buttons for unsupported formats
|
||||
if ( ! $is_supported_format ) {
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
|
||||
if ( $is_optimized ) {
|
||||
$original_main_size = $params['original_main_size'];
|
||||
$thumbnails_optimized = $params['thumbnails_optimized'];
|
||||
$optimization_level = $params['optimization_level'];
|
||||
$error_msg = $params['error_msg'];
|
||||
$diff_percent = $params['diff_percent'];
|
||||
$diff_percent_all = $params['diff_percent_all'];
|
||||
|
||||
?>
|
||||
<ul class="wio-datas-list" data-size="<?php echo esc_attr( size_format( $attachment_file_size ) ); ?>"
|
||||
data-dimensions="<?php echo esc_attr( $attach_dimensions ); ?>">
|
||||
<li class="wio-data-item"><span
|
||||
class="data"><?php _e( 'New Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="big"><?php echo esc_attr( size_format( $attachment_file_size, 1 ) ); ?></strong>
|
||||
<span class="wio-chart-value">(<?php echo esc_attr( $diff_percent ); ?>%)</span></li>
|
||||
<?php if ( $webp_size ) : ?>
|
||||
<li class="wio-data-item"><span
|
||||
class="data"><?php _e( 'WebP Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="big"><?php echo esc_attr( size_format( $webp_size, 1 ) ); ?></strong>
|
||||
<span class="wio-chart-value">(<?php echo esc_attr( $webp_percent ); ?>%)</span></li>
|
||||
<?php endif; ?>
|
||||
<?php if ( $avif_size ) : ?>
|
||||
<li class="wio-data-item"><span
|
||||
class="data"><?php _e( 'AVIF Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="big"><?php echo esc_attr( size_format( $avif_size, 1 ) ); ?></strong>
|
||||
<span class="wio-chart-value">(<?php echo esc_attr( $avif_percent ); ?>%)</span></li>
|
||||
<?php endif; ?>
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php _e( 'Original Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="original"><?php echo esc_attr( size_format( $original_main_size, 1 ) ); ?></strong>
|
||||
</li>
|
||||
<li class="wio-data-item"><span class="data"><?php _e( 'Level:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong>
|
||||
<?php
|
||||
if ( ! $error_msg ) {
|
||||
// если уровень кастомный от 1 до 100
|
||||
if ( is_numeric( $optimization_level ) ) {
|
||||
echo __( 'Custom', 'robin-image-optimizer' ) . ' ' . intval( $optimization_level ) . '%';
|
||||
} else {
|
||||
// если уровень один из настроек
|
||||
if ( $optimization_level == 'normal' ) {
|
||||
echo __( 'Lossless', 'robin-image-optimizer' );
|
||||
} elseif ( $optimization_level == 'aggresive' ) {
|
||||
echo __( 'Lossy', 'robin-image-optimizer' );
|
||||
} else {
|
||||
echo __( 'High', 'robin-image-optimizer' );
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</strong>
|
||||
</li>
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php _e( 'Thumbnails Optimized:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="original"><?php echo intval( $thumbnails_optimized ); ?></strong>
|
||||
</li>
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php _e( 'Overall Saving:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="original"><?php echo esc_attr( $diff_percent_all ); ?>%</strong>
|
||||
</li>
|
||||
<?php if ( $error_msg ) : ?>
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php _e( 'Error Message:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong><?php echo esc_attr( $error_msg ); ?></strong></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<div class="wio-datas-actions-links" style="display:inline;">
|
||||
<?php if ( $optimization_level != 'normal' ) : ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionOptimize ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-level="normal"
|
||||
data-nonce="<?php echo wp_create_nonce( 'reoptimize' ); ?>"
|
||||
href="#"
|
||||
class="wio-reoptimize button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php _e( 'Optimization in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-admin-generic"></span>
|
||||
<span
|
||||
class="wio-hide-if-small"
|
||||
>
|
||||
<?php _e( 'Re-Optimize to:', 'robin-image-optimizer' ); ?>
|
||||
</span><?php _e( 'Lossless', 'robin-image-optimizer' ); ?>
|
||||
<span class="wio-hide-if-small"></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ( $optimization_level != 'aggresive' ) : ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionOptimize ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-level="aggresive"
|
||||
data-nonce="<?php echo wp_create_nonce( 'reoptimize' ); ?>"
|
||||
href="#"
|
||||
class="wio-reoptimize button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php _e( 'Optimization in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-admin-generic"></span>
|
||||
<span
|
||||
class="wio-hide-if-small"
|
||||
>
|
||||
<?php _e( 'Re-Optimize to:', 'robin-image-optimizer' ); ?>
|
||||
</span>
|
||||
<?php _e( 'Lossy', 'robin-image-optimizer' ); ?>
|
||||
<span class="wio-hide-if-small"></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ( $optimization_level != 'ultra' ) : ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionOptimize ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-level="ultra"
|
||||
data-nonce="<?php echo wp_create_nonce( 'reoptimize' ); ?>"
|
||||
href="#"
|
||||
class="wio-reoptimize button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php _e( 'Optimization in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-admin-generic"></span>
|
||||
<span
|
||||
class="wio-hide-if-small"
|
||||
>
|
||||
<?php _e( 'Re-Optimize to:', 'robin-image-optimizer' ); ?>
|
||||
</span>
|
||||
<?php _e( 'High', 'robin-image-optimizer' ); ?>
|
||||
<span class="wio-hide-if-small"></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php // WebP conversion is available to all users ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionConvert ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-format="webp"
|
||||
data-nonce="<?php echo wp_create_nonce( 'convert' ); ?>"
|
||||
href="#"
|
||||
class="wio-convert button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php esc_html_e( 'Convert in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-images-alt2"></span>
|
||||
<?php echo esc_html( $webp_size ? __( 'Re-convert to WebP', 'robin-image-optimizer' ) : __( 'Convert to WebP', 'robin-image-optimizer' ) ); ?>
|
||||
</a>
|
||||
<?php // AVIF conversion is a premium-only feature ?>
|
||||
<?php if ( wrio_is_license_activate() ) : ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionConvert ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-format="avif"
|
||||
data-nonce="<?php echo wp_create_nonce( 'convert' ); ?>"
|
||||
href="#"
|
||||
class="wio-convert button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php esc_html_e( 'Convert in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-images-alt2"></span>
|
||||
<?php echo esc_html( $avif_size ? __( 'Re-convert to AVIF', 'robin-image-optimizer' ) : __( 'Convert to AVIF', 'robin-image-optimizer' ) ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ( $backuped ) : ?>
|
||||
<a
|
||||
href="#" data-action="<?php echo esc_attr( $ajaxActionRestore ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-nonce="<?php echo wp_create_nonce( 'restore' ); ?>"
|
||||
class="button-wio-restore attachment-has-backup"
|
||||
data-waiting-label="<?php esc_html_e( 'Recovery in progress', 'robin-image-optimizer' ); ?>"
|
||||
>
|
||||
<span class="dashicons dashicons-image-rotate"></span>
|
||||
<?php esc_html_e( 'Restore original', 'robin-image-optimizer' ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<!-- .wio-datas-actions-links -->
|
||||
<?php
|
||||
} elseif ( $attach_dimensions !== '0 x 0' ) {
|
||||
// Show full stats view if any conversion exists
|
||||
if ( $webp_size || $avif_size ) {
|
||||
?>
|
||||
<ul class="wio-datas-list" data-size="<?php echo esc_attr( size_format( $attachment_file_size ) ); ?>"
|
||||
data-dimensions="<?php echo esc_attr( $attach_dimensions ); ?>">
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php esc_html_e( 'Original Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="big"><?php echo esc_attr( size_format( $attachment_file_size, 1 ) ); ?></strong>
|
||||
</li>
|
||||
<?php if ( $webp_size ) : ?>
|
||||
<?php $webp_saving = $attachment_file_size ? round( ( $attachment_file_size - $webp_size ) * 100 / $attachment_file_size ) : 0; ?>
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php esc_html_e( 'WebP Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="big"><?php echo esc_attr( size_format( $webp_size, 1 ) ); ?></strong>
|
||||
<span class="wio-chart-value">(<?php echo esc_attr( $webp_saving ); ?>%)</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php if ( $avif_size ) : ?>
|
||||
<?php $avif_saving = $attachment_file_size ? round( ( $attachment_file_size - $avif_size ) * 100 / $attachment_file_size ) : 0; ?>
|
||||
<li class="wio-data-item">
|
||||
<span class="data"><?php esc_html_e( 'AVIF Filesize:', 'robin-image-optimizer' ); ?></span>
|
||||
<strong class="big"><?php echo esc_attr( size_format( $avif_size, 1 ) ); ?></strong>
|
||||
<span class="wio-chart-value">(<?php echo esc_attr( $avif_saving ); ?>%)</span>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<div class="wio-datas-actions-links" style="display:inline;">
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionOptimize ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-level=""
|
||||
data-nonce="<?php echo wp_create_nonce( 'reoptimize' ); ?>"
|
||||
href="#"
|
||||
class="wio-reoptimize button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php esc_attr_e( 'Optimization in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-admin-generic"></span>
|
||||
<?php esc_html_e( 'Optimize', 'robin-image-optimizer' ); ?>
|
||||
</a>
|
||||
<?php // WebP conversion is available to all users ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionConvert ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-format="webp"
|
||||
data-nonce="<?php echo esc_attr( wp_create_nonce( 'convert' ) ); ?>"
|
||||
href="#"
|
||||
class="wio-convert button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php esc_attr_e( 'Convert in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-images-alt2"></span>
|
||||
<?php echo esc_html( $webp_size ? __( 'Re-convert to WebP', 'robin-image-optimizer' ) : __( 'Convert to WebP', 'robin-image-optimizer' ) ); ?>
|
||||
</a>
|
||||
<?php // AVIF conversion is a premium-only feature ?>
|
||||
<?php if ( wrio_is_license_activate() ) : ?>
|
||||
<a data-action="<?php echo esc_attr( $ajaxActionConvert ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-format="avif"
|
||||
data-nonce="<?php echo esc_attr( wp_create_nonce( 'convert' ) ); ?>"
|
||||
href="#"
|
||||
class="wio-convert button-wio-manual-override-upload"
|
||||
data-waiting-label="<?php esc_attr_e( 'Convert in progress', 'robin-image-optimizer' ); ?>">
|
||||
<span class="dashicons dashicons-images-alt2"></span>
|
||||
<?php echo esc_html( $avif_size ? __( 'Re-convert to AVIF', 'robin-image-optimizer' ) : __( 'Convert to AVIF', 'robin-image-optimizer' ) ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ( $backuped ) : ?>
|
||||
<a
|
||||
href="#" data-action="<?php echo esc_attr( $ajaxActionRestore ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-nonce="<?php echo esc_attr( wp_create_nonce( 'restore' ) ); ?>"
|
||||
class="button-wio-restore attachment-has-backup"
|
||||
data-waiting-label="<?php esc_attr_e( 'Recovery in progress', 'robin-image-optimizer' ); ?>"
|
||||
>
|
||||
<span class="dashicons dashicons-image-rotate"></span>
|
||||
<?php esc_html_e( 'Restore original', 'robin-image-optimizer' ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<!-- .wio-datas-actions-links -->
|
||||
<?php
|
||||
} else {
|
||||
// No conversions yet - show buttons
|
||||
?>
|
||||
<button
|
||||
type="button" data-action="<?php echo esc_attr( $ajaxActionOptimize ); ?>"
|
||||
data-nonce="<?php echo wp_create_nonce( 'reoptimize' ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>" data-level=""
|
||||
class="wio-reoptimize button button-primary button-large"
|
||||
data-waiting-label="<?php esc_attr_e( 'Optimization in progress', 'robin-image-optimizer' ); ?>"
|
||||
data-size="<?php echo esc_attr( size_format( $attachment_file_size ) ); ?>"
|
||||
data-dimensions="<?php echo esc_attr( $attach_dimensions ); ?>"
|
||||
>
|
||||
<?php esc_html_e( 'Optimize', 'robin-image-optimizer' ); ?>
|
||||
</button>
|
||||
<?php // WebP conversion is available to all users ?>
|
||||
<button
|
||||
type="button" data-action="<?php echo esc_attr( $ajaxActionConvert ); ?>"
|
||||
data-nonce="<?php echo wp_create_nonce( 'convert' ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-format="webp"
|
||||
class="wio-convert button button-primary button-large"
|
||||
data-waiting-label="<?php esc_attr_e( 'Convert in progress', 'robin-image-optimizer' ); ?>"
|
||||
data-size="<?php echo esc_attr( size_format( $attachment_file_size ) ); ?>"
|
||||
data-dimensions="<?php echo esc_attr( $attach_dimensions ); ?>"
|
||||
>
|
||||
<?php esc_html_e( 'Convert to WebP', 'robin-image-optimizer' ); ?>
|
||||
</button>
|
||||
<?php // AVIF conversion is a premium-only feature ?>
|
||||
<?php if ( wrio_is_license_activate() ) : ?>
|
||||
<button
|
||||
type="button" data-action="<?php echo esc_attr( $ajaxActionConvert ); ?>"
|
||||
data-nonce="<?php echo wp_create_nonce( 'convert' ); ?>"
|
||||
data-id="<?php echo esc_attr( $attachment_id ); ?>"
|
||||
data-format="avif"
|
||||
class="wio-convert button button-primary button-large"
|
||||
data-waiting-label="<?php esc_attr_e( 'Convert in progress', 'robin-image-optimizer' ); ?>"
|
||||
data-size="<?php echo esc_attr( size_format( $attachment_file_size ) ); ?>"
|
||||
data-dimensions="<?php echo esc_attr( $attach_dimensions ); ?>"
|
||||
>
|
||||
<?php esc_html_e( 'Convert to AVIF', 'robin-image-optimizer' ); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// silence is golden
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// silence is golden
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Sidebar widgets
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return support widget markup
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function wrio_get_sidebar_support_widget() {
|
||||
$free_support_url = 'https://wordpress.org/support/plugin/robin-image-optimizer/';
|
||||
$support_url = tsdk_utmify( tsdk_translate_link( 'https://themeisle.com/contact/' ), 'bug-security-ticket' );
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="wbcr-clr-support-widget" class="wbcr-factory-sidebar-widget">
|
||||
<p><strong><?php _e( 'Having Issues?', 'robin-image-optimizer' ); ?></strong></p>
|
||||
<div class="wbcr-clr-support-widget-body">
|
||||
<p>
|
||||
<?php _e( 'Need help? Create a support ticket and we\'ll assist you.', 'robin-image-optimizer' ); ?>
|
||||
</p>
|
||||
<ul>
|
||||
<li><span class="dashicons dashicons-sos"></span>
|
||||
<a href="<?php echo esc_url( $free_support_url ); ?>" target="_blank" rel="noopener">
|
||||
<?php esc_html_e( 'Get free support', 'robin-image-optimizer' ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li style="margin-top: 15px;background: #fff4f1;padding: 10px;color: #a58074;">
|
||||
<span class="dashicons dashicons-warning"></span>
|
||||
<?php
|
||||
echo wp_kses_post(
|
||||
sprintf(
|
||||
// translators: %1$s is opening <a> tag, %2$s is closing </a> tag
|
||||
__( 'Found a bug or security issue? %1$sCreate a ticket%2$s for a faster response.', 'robin-image-optimizer' ),
|
||||
'<a href="' . esc_url( $support_url ) . '" target="_blank" rel="noopener">',
|
||||
'</a>'
|
||||
)
|
||||
);
|
||||
?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
$output = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return $output;
|
||||
}
|
||||
Reference in New Issue
Block a user