first commit

This commit is contained in:
User A0264400
2026-04-01 23:20:16 +03:00
commit a766acdc90
23071 changed files with 4933189 additions and 0 deletions

View File

@@ -0,0 +1,497 @@
<?php
/**
* AJAX обработчик выбора папки
*/
add_action(
'wp_ajax_wriop_browse_dir',
function () {
if ( ! check_ajax_referer( 'bulk_optimization', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
if ( is_main_site() ) {
$base = get_home_path();
$root = wp_normalize_path( $base );
} else {
$up = wp_upload_dir();
$root = wp_normalize_path( $up['basedir'] );
}
$dir = trim( WRIO_Plugin::app()->request->post( 'dir', null, 'rawurldecode' ) );
$multiselect = WRIO_Plugin::app()->request->post( 'multiSelect' );
$multiselect = $multiselect == 'true' ? true : false;
$only_folders = WRIO_Plugin::app()->request->post( 'onlyFolders' );
$only_folders = $only_folders == 'true' ? true : false;
$only_folders = $dir == '/' || $only_folders;
$only_files = WRIO_Plugin::app()->request->post( 'onlyFiles' );
$only_files = $only_files == 'true' ? true : false;
$selected_dir = trailingslashit( $root ) . ( $dir == '/' ? '' : $dir );
// set checkbox if multiSelect set to true
$checkbox = $multiselect ? "<input type='checkbox' />" : null;
$upload_dir = wp_upload_dir();
$upload_dir_path = trailingslashit( str_replace( ABSPATH, '', $upload_dir['basedir'] ) );
$wp_content_dir = trailingslashit( str_replace( ABSPATH, '', WP_CONTENT_DIR ) );
$ngg_path = str_replace( wp_normalize_path( ABSPATH ), '', wrio_get_ngg_galleries_path() );
$shortpixel_path = str_replace( wp_normalize_path( ABSPATH ), '', wrio_get_shortpixel_path() );
$ewww_path = str_replace( wp_normalize_path( ABSPATH ), '', wrio_get_ewww_tools_path() );
$wc_path = str_replace( wp_normalize_path( ABSPATH ), '', wrio_get_wc_logs_path() );
$exclude_dirs = [
$ngg_path,
$shortpixel_path,
$ewww_path,
$wc_path,
$wp_content_dir . 'backup',
$wp_content_dir . 'backups',
$wp_content_dir . 'cache',
$wp_content_dir . 'lang',
$wp_content_dir . 'langs',
$wp_content_dir . 'languages',
$upload_dir_path . 'wio_backup',
$upload_dir_path . 'wrio',
$upload_dir_path . 'wrio-webp-uploads',
// 'wp-admin',
// 'wp-includes'
];
// исключаем все директории /wp-content/uploads/2019 - они уже оптимизируются в медиабиблиотеке.
// с основания WP в 2003 году до текущего года + 1 на всякий случай.
$year = date( 'Y' ) + 1;
for ( $i = 2003; $i <= $year; $i++ ) {
$exclude_dirs[] = $upload_dir_path . $i;
}
if ( file_exists( $selected_dir ) && is_dir( $selected_dir ) ) {
$files = scandir( $selected_dir );
$return_dir = substr( $selected_dir, strlen( $root ) );
natcasesort( $files );
if ( count( $files ) > 2 ) { // The 2 accounts for . and ..
echo "<ul class='jqueryFileTree'>";
$counter = 0;
foreach ( $files as $file ) {
// если в папке очень много файлов, то показываем не все.
if ( $counter++ > 200 ) {
break;
}
// если это папка бекап или другое исключение - пропускаем
if ( in_array( $return_dir . $file, $exclude_dirs ) ) {
continue;
}
$htmlRel = str_replace( "'", '&apos;', $return_dir . $file );
$htmlName = htmlentities( $file );
$ext = preg_replace( '/^.*\./', '', $file );
if ( file_exists( $selected_dir . $file ) && $file != '.' && $file != '..' ) {
// KEEP the spaces in front of the rel values - it's a trick to make WP Hide not replace the wp-content path
if ( is_dir( $selected_dir . $file ) && ( ! $only_files || $only_folders ) ) {
echo "<li class='directory collapsed'>{$checkbox}<a rel=' " . $htmlRel . "/'>" . $htmlName . '</a></li>';
} elseif ( ! $only_folders || $only_files ) {
echo "<li class='file ext_{$ext}'>{$checkbox}<a rel=' " . $htmlRel . "'>" . $htmlName . '</a></li>';
}
}
}
echo '</ul>';
}
}
die();
}
);
/**
* AJAX обработчик добавления папки
*/
add_action(
'wp_ajax_wrio-add-custom-folder',
function () {
if ( ! check_ajax_referer( 'bulk_optimization', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$path = WRIO_Plugin::app()->request->request( 'path', null, true );
if ( empty( $path ) ) {
wp_die( - 1 );
}
$cf = WRIO_Custom_Folders::get_instance();
$folder = $cf->addFolder( $path );
if ( is_wp_error( $folder ) ) {
wp_send_json_error(
[
'error_message' => $folder->get_error_message(),
'error_code' => $folder->get_error_code(),
]
);
}
wp_send_json_success( $folder->toArray() );
}
);
/**
* AJAX индексация папки
*/
add_action(
'wp_ajax_wrio-scan-folder',
function () {
if ( ! check_ajax_referer( 'bulk_optimization', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$uid = WRIO_Plugin::app()->request->request( 'uid', null, true );
$offset = WRIO_Plugin::app()->request->request( 'offset', 0, true );
$total = WRIO_Plugin::app()->request->request( 'total', 0, true );
if ( empty( $uid ) ) {
wp_die( - 1 );
}
$max_process_elements = 100; // сколько элементов за итерацию индексирования
$cf = WRIO_Custom_Folders::get_instance();
$folder = $cf->getFolder( $uid );
if ( ! $total ) {
$total = $folder->reCountFiles();
$cf->saveFolders();
}
$processed_count = $folder->indexing( $offset, $max_process_elements );
$offset = $offset + $processed_count;
$results = [
'offset' => $offset,
'total' => $total,
'complete' => false,
'percent' => 0,
];
if ( $total ) {
$results['percent'] = 100 - ( ( $total - $offset ) * 100 / $total );
/**
* Операция индексирования состоит из двух этапов. Проверка существующих файлов и поиск новых файлов.
* Поэтому процент делим на 2 и добавляем 50% т.к. это вторая часть.
*/
$results['percent'] = $results['percent'] / 2 + 50;
}
if ( $offset >= $total ) {
$results['percent'] = 100;
$results['complete'] = true;
}
wp_send_json_success( $results );
}
);
/**
* AJAX обработчик удаления папки
*/
add_action(
'wp_ajax_wriop_remove_folder',
function () {
if ( ! check_ajax_referer( 'bulk_optimization', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$uid = isset( $_POST['uid'] ) ? $_POST['uid'] : false;
if ( ! $uid ) {
die();
}
$cf = WRIO_Custom_Folders::get_instance();
$cf->removeFolder( $uid );
$cf->saveFolders();
die();
}
);
/**
* AJAX проверка проиндексированных файлов
*/
add_action(
'wp_ajax_wriop_folder_sync_index',
function () {
if ( ! check_ajax_referer( 'bulk_optimization', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$uid = isset( $_POST['uid'] ) ? $_POST['uid'] : false;
$offset = isset( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0;
$total = isset( $_POST['total'] ) ? intval( $_POST['total'] ) : 0;
$max_process_elements = 20; // сколько элементов за итерацию индексирования
$cf = WRIO_Custom_Folders::get_instance();
$folder = $cf->getFolder( $uid );
$total = $folder->countIndexedFiles();
$processed_count = $folder->syncIndex( $offset, $max_process_elements );
$offset = $offset + $processed_count;
$results = [
'offset' => $offset,
'total' => $total,
'complete' => false,
'percent' => 0,
];
if ( $total ) {
$results['percent'] = 100 - ( ( $total - $offset ) * 100 / $total );
/**
* Операция индексирования состоит из двух этапов. Проверка существующих файлов и поиск новых файлов.
* Поэтому процент делим на 2. Это первая часть.
*/
$results['percent'] = $results['percent'] / 2;
}
if ( $offset >= $total ) {
$results['percent'] = 100;
$results['complete'] = true;
}
wp_send_json( $results );
}
);
/**
* AJAX массовая оптимизация
*/
/*
add_action( 'wp_ajax_wriop_process_cf_images', function () {
check_admin_referer( 'wio-iph' );
$reset_current_error = (bool) WRIO_Plugin::app()->request->request( 'reset_current_errors' );
// в ajax запросе мы не знаем, получен ли он из мультиадминки или из обычной. Поэтому проверяем параметр, полученный из frontend
if ( isset( $_POST['multisite'] ) and $_POST['multisite'] ) {
$multisite = new WIO_Multisite;
$multisite->initHooks();
}
$cf = WRIO_Custom_Folders::get_instance();
/*$folders = $cf->getFolders();
if ( ! empty( $folders ) ) {
foreach ( (array) $folders as $folder ) {
$folder = $cf->getFolder( $folder->get( 'uid' ) );
$count_files = $folder->countFiles();
$count_indexed_files = $folder->countIndexedFiles();
$test = 'fsdf';
}
}*/
/*
if ( $reset_current_error ) {
// сбрасываем текущие ошибки оптимизации
$cf->resetCurrentErrors();
}
$max_process_per_request = 1;
$optimized_data = $cf->processUnoptimizedImages( $max_process_per_request );
// если изображения закончились - посылаем команду завершения
if ( $optimized_data['remain'] <= 0 ) {
$optimized_data['end'] = true;
}
wp_send_json( $optimized_data );
} );*/
/**
* AJAX массовая оптимизация выбранной папки
*/
/*
add_action( 'wp_ajax_wriop_process_cf_folder_images', function () {
check_admin_referer( 'wio-iph' );
// в ajax запросе мы не знаем, получен ли он из мультиадминки или из обычной. Поэтому проверяем параметр, полученный из frontend
if ( isset( $_POST['multisite'] ) and $_POST['multisite'] ) {
$multisite = new WIO_Multisite;
$multisite->initHooks();
}
$cf = WRIO_Custom_Folders::get_instance();
$max_process_per_request = 1;
add_filter( 'wriop_cf_current_folder', function ( $folder_uid ) {
$folder_uid = isset( $_POST['uid'] ) ? $_POST['uid'] : false;
return $folder_uid;
} );
$optimized_data = $cf->processUnoptimizedImages( $max_process_per_request );
// если изображения закончились - посылаем команду завершения
if ( $optimized_data['remain'] <= 0 ) {
$optimized_data['end'] = true;
}
wp_send_json( $optimized_data );
} );*/
/**
* Переоптимизация cf_image. AJAX
*/
add_action(
'wp_ajax_wio_cf_reoptimize_image',
function () {
if ( ! check_ajax_referer( 'reoptimize', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$image_id = (int) $_POST['id'];
$backup = WRIOP_Backup::get_instance();
$backup_origin_images = WRIO_Plugin::app()->getPopulateOption( 'backup_origin_images', false );
$cf = WRIO_Custom_Folders::get_instance();
if ( $backup_origin_images and ! $backup->isBackupWritable() ) {
echo $cf->getMediaColumnContent( $image_id );
die();
}
wp_suspend_cache_addition( true );
$default_level = WRIO_Plugin::app()->getPopulateOption( 'image_optimization_level', 'normal' );
$level = isset( $_POST['level'] ) ? sanitize_text_field( $_POST['level'] ) : $default_level;
$optimized_data = $cf->optimizeImage( $image_id, $level );
if ( $optimized_data && isset( $optimized_data['processing'] ) ) {
echo 'processing'; // эту строку не локализировать!
die();
}
echo $cf->getMediaColumnContent( $image_id );
die();
}
);
/**
* Восстановление
*/
add_action(
'wp_ajax_wio_cf_restore_image',
function () {
if ( ! check_ajax_referer( 'restore', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
wp_suspend_cache_addition( true );
$image_id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
$cf = WRIO_Custom_Folders::get_instance();
$cf_image = $cf->getImage( $image_id );
$image_statistics = WRIO_Image_Statistic_Folders::get_instance();
if ( $cf_image->isOptimized() ) {
$restored = $cf_image->restore();
if ( ! is_wp_error( $restored ) ) {
$optimization_data = $cf_image->getOptimizationData();
$optimized_size = $optimization_data->get_final_size();
$original_size = $optimization_data->get_original_size();
$webp_optimized_size = $optimization_data->get_extra_data()->get_webp_main_size();
$image_statistics->deductFromField( 'webp_optimized_size', $webp_optimized_size );
$image_statistics->deductFromField( 'optimized_size', $optimized_size );
$image_statistics->deductFromField( 'original_size', $original_size );
$image_statistics->save();
$folder = $cf->getFolder( $cf_image->get( 'folder_uid' ) );
$folder->reCountOptimizedFiles();
$cf->saveFolders();
}
}
echo $cf->getMediaColumnContent( $image_id );
die();
}
);
/**
* AJAX обработчик восстановления из резервной копии
*/
/*
add_action( 'wp_ajax_wio_cf_restore_backup', function () {
check_admin_referer( 'wio-iph' );
$max_process_per_request = 10; // сколько картинок восстанавливаем за 1 запрос
$total = sanitize_text_field( $_POST['total'] );
if ( isset( $_POST['blog_id'] ) && $_POST['blog_id'] ) {
switch_to_blog( intval( $_POST['blog_id'] ) );
}
$folder_uid = isset( $_POST['uid'] ) ? sanitize_text_field( $_POST['uid'] ) : false;
$cf = WRIO_Custom_Folders::get_instance();
if ( $total == '?' ) {
$total = RIO_Process_Queue::count_by_type_status( 'cf_image', 'success' );
}
$restored_data = $cf->restoreFolderFromBackup( $folder_uid, $max_process_per_request );
if ( isset( $_POST['blog_id'] ) && $_POST['blog_id'] ) {
restore_current_blog();
}
$restored_data['total'] = $total;
if ( $total ) {
$restored_data['percent'] = 100 - ( $restored_data['remain'] * 100 / $total );
} else {
$restored_data['percent'] = 0;
}
// если изображения закончились - посылаем команду завершения
if ( $restored_data['remain'] <= 0 ) {
$restored_data['end'] = true;
}
wp_send_json( $restored_data );
} );*/
/**
* Загружает шаблон для всплывающий окон
*/
/*
add_action( 'wp_ajax_wio_cf_get_template_part', function () {
$template = sanitize_text_field( $_POST['template'] );
$templates = [
'select_folder' => 'select-folder.php',
'restore_folder' => 'restore-folder.php',
'sync_folder' => 'sync-folder.php',
'optimize_folder' => 'optimize-folder.php',
'sync_all_folders' => 'sync-all-folders.php',
'folders_table_body' => 'folders-table-body.php',
];
if ( isset( $templates[ $template ] ) ) {
$template_file = WRIOP_PLUGIN_DIR . '/admin/pages/parts/' . $templates[ $template ];
if ( file_exists( $template_file ) ) {
include( $template_file );
}
}
die();
} );*/
/**
* Загружает шаблон для всплывающий окон
*/
add_action(
'wp_ajax_wio_cf_reload_ui',
function () {
if ( ! check_ajax_referer( 'bulk_optimization', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$template_file = WRIOP_PLUGIN_DIR . '/admin/pages/parts/folders-table-body.php';
$folders_table = '';
if ( is_file( $template_file ) ) {
ob_start();
include $template_file;
$folders_table = ob_get_contents();
ob_end_clean();
}
$image_statistics = WRIO_Image_Statistic_Folders::get_instance();
$responce = [
'folders_table' => $folders_table,
'statistic' => $image_statistics->load(),
];
wp_send_json( $responce );
}
);

View File

@@ -0,0 +1,71 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Переоптимизация аттачмента
*/
function wbcr_riop_reoptimizeImage() {
if ( ! check_ajax_referer( 'reoptimize', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
$image_id = (int) $_POST['id'];
$backup = WRIOP_Backup::get_instance();
$backup_origin_images = WRIO_Plugin::app()->getPopulateOption( 'backup_origin_images', false );
$nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
if ( $backup_origin_images && ! $backup->isBackupWritable() ) {
echo $nextgen_gallery->getMediaColumnContent( $image_id );
die();
}
wp_suspend_cache_addition( true );
$default_level = WRIO_Plugin::app()->getPopulateOption( 'image_optimization_level', 'normal' );
$level = isset( $_POST['level'] ) ? sanitize_text_field( $_POST['level'] ) : $default_level;
$optimized_data = $nextgen_gallery->optimizeNextgenImage( $image_id, $level );
if ( $optimized_data && isset( $optimized_data['processing'] ) ) {
echo 'processing';
die();
}
echo $nextgen_gallery->getMediaColumnContent( $image_id );
die();
}
/**
* Восстановление
*/
function wbcr_riop_restoreImage() {
if ( ! check_ajax_referer( 'restore', false, false ) || ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
}
wp_suspend_cache_addition( true );
$image_id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
$nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
$nextgen_image = $nextgen_gallery->getNextgenImage( $image_id );
$image_statistics = WRIO_Image_Statistic_Nextgen::get_instance();
if ( $nextgen_image->isOptimized() ) {
$restored = $nextgen_image->restore();
if ( ! is_wp_error( $restored ) ) {
$optimization_data = $nextgen_image->getOptimizationData();
$optimized_size = $optimization_data->get_final_size();
$original_size = $optimization_data->get_original_size();
$webp_optimized_size = $optimization_data->get_extra_data()->get_webp_main_size();
$image_statistics->deductFromField( 'webp_optimized_size', $webp_optimized_size );
$image_statistics->deductFromField( 'optimized_size', $optimized_size );
$image_statistics->deductFromField( 'original_size', $original_size );
$image_statistics->save();
}
}
$nextgen_gallery = WRIO_Nextgen_Gallery::get_instance();
echo $nextgen_gallery->getMediaColumnContent( $image_id );
die();
}

View File

@@ -0,0 +1,4 @@
/**
* Bulk optimization
*/
/*# sourceMappingURL=custom-folders.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"custom-folders.css"}

View File

@@ -0,0 +1,9 @@
/**
* Bulk optimization
*/
#WBCR {
// less code
}

View File

@@ -0,0 +1,318 @@
#wrio-file-tree {
min-height: 100px;
max-height: 400px;
overflow: auto;
padding: 10px;
border: 1px solid #888;
background: #fff url("../img/quick-start-loader.gif") center center no-repeat;
}
div.sp-folder-picker {
margin: 20px 0; /* 15% from the top and centered */
border: 1px solid #888;
max-height: 400px;
overflow: auto;
}
/*UL.jqueryFileTree LI.directory.selected {
background-color: #209fd2;
}*/
UL.jqueryFileTree {
font-family: Verdana, sans-serif;
font-size: 11px;
line-height: 18px;
padding: 0;
margin: 0;
display: none;
background: #fff;
}
UL.jqueryFileTree LI {
list-style: none;
text-align: left;
padding: 0;
padding-left: 20px;
margin: 0;
white-space: nowrap;
}
UL.jqueryFileTree LI.directory {
background: url(../img/file-tree/directory.png) left top no-repeat;
}
UL.jqueryFileTree LI.directory-locked {
background: url(../img/file-tree/directory-lock.png) left top no-repeat;
}
UL.jqueryFileTree LI.expanded {
background: url(../img/file-tree/folder_open.png) left top no-repeat;
}
UL.jqueryFileTree LI.file {
background: url(../img/file-tree/file.png) left top no-repeat;
}
UL.jqueryFileTree LI.file-locked {
background: url(../img/file-tree/file-lock.png) left top no-repeat !important;
}
UL.jqueryFileTree LI.wait {
background: url(../img/file-tree/spinner.gif) left top no-repeat;
}
UL.jqueryFileTree LI.selected > a {
font-weight: bold;
}
UL.jqueryFileTree LI.ext_3gp {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_afp {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_afpa {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_asp {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_aspx {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_avi {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_bat {
background: url(../img/file-tree/application.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_bmp {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_c {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_cfm {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_cgi {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_com {
background: url(../img/file-tree/application.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_cpp {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_css {
background: url(../img/file-tree/css.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_doc {
background: url(../img/file-tree/doc.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_exe {
background: url(../img/file-tree/application.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_gif {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_fla {
background: url(../img/file-tree/flash.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_h {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_htm {
background: url(../img/file-tree/html.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_html {
background: url(../img/file-tree/html.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_jar {
background: url(../img/file-tree/java.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_jpg {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_jpeg {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_js {
background: url(../img/file-tree/script.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_lasso {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_log {
background: url(../img/file-tree/txt.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_m4p {
background: url(../img/file-tree/music.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_mov {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_mp3 {
background: url(../img/file-tree/music.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_mp4 {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_mpg {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_mpeg {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_ogg {
background: url(../img/file-tree/music.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_ogv {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_pcx {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_pdf {
background: url(../img/file-tree/pdf.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_php {
background: url(../img/file-tree/php.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_png {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_ppt {
background: url(../img/file-tree/ppt.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_psd {
background: url(../img/file-tree/psd.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_pl {
background: url(../img/file-tree/script.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_py {
background: url(../img/file-tree/script.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_rb {
background: url(../img/file-tree/ruby.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_rbx {
background: url(../img/file-tree/ruby.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_rhtml {
background: url(../img/file-tree/ruby.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_rpm {
background: url(../img/file-tree/linux.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_ruby {
background: url(../img/file-tree/ruby.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_sql {
background: url(../img/file-tree/db.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_swf {
background: url(../img/file-tree/flash.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_tif {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_tiff {
background: url(../img/file-tree/picture.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_txt {
background: url(../img/file-tree/txt.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_vb {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_wav {
background: url(../img/file-tree/music.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_webm {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_wmv {
background: url(../img/file-tree/film.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_xls {
background: url(../img/file-tree/xls.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_xml {
background: url(../img/file-tree/code.png) left top no-repeat;
}
UL.jqueryFileTree LI.ext_zip {
background: url(../img/file-tree/zip.png) left top no-repeat;
}
UL.jqueryFileTree A {
color: #333;
text-decoration: none;
display: inline-block;
padding: 0 2px;
cursor: pointer;
}
UL.jqueryFileTree A:hover {
background: #BDF;
}

View File

@@ -0,0 +1,210 @@
.wriop-files-list #preview {
width: 80px;
}
.wriop-files-list #file {
width: 250px;
}
.wriop-files-list #status {
width: 100px;
}
.wriop-files-list #optimization {
width: 200px;
}
/* Filter block */
.wriop-files-list .wp-filter {
padding: 15px 20px;
}
.wriop-files-list .filter-items select {
height: auto;
padding: 6px;
margin-right: 12px;
}
.wriop-files-list .filter-items .button {
height: auto;
padding: 2px 12px 3px;
}
/* Empty table */
.wriop-files-list .no-items td {
padding: 35px;
text-align: center;
font-size: 18px;
}
.wriop-files-list .no-items td a {
text-decoration: underline;
}
/* Th sortable */
.wriop-files-list .sortable a {
color: #000;
}
/* Global links */
.wriop-files-list a {
color: #3694AE;
}
/* Global TDs */
.wriop-files-list tbody td,
.wriop-files-list tbody th,
.wriop-files-list.wriop-files-list tbody .check-column {
vertical-align: top;
text-align: left;
/*padding-top: 20px;
padding-bottom: 20px;*/
color: #626E7B;
}
.wriop-files-list .column-file,
.wriop-files-list .column-folder,
.wriop-files-list .column-status {
padding-top: 28px;
}
/* Col Title */
.wriop-files-list .column-preview strong  {
font-weight: normal;
font-size: 14px;
}
.wriop-files-list .column-preview strong a {
display: inline-flex;
align-items: center;
word-break: break-all;
word-wrap: break-word;
font-weight: normal;
}
.wriop-files-list .filename {
font-size: 12px;
font-weight: bold;
}
.wriop-files-list .media-icon {
position: relative;
width: 60px;
overflow: hidden;
flex-shrink: 0;
}
.media-icon .centered {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
transform: translate(50%, 50%);
}
.media-icon .centered img {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
}
table.media .column-preview .media-icon.landscape img {
max-width: none;
width: auto;
height: 60px;
}
table.media .column-preview .media-icon.portrait img {
width: 60px;
}
/* Optimization datas Col */
.wriop-files-list ul.wriop-datas-list {
font-size: 11px;
}
.wriop-files-list ul.wriop-datas-list .big {
font-size: 13px;
}
.wriop-files-list ul.wriop-datas-list span.wriopy-chart-value {
font-size: 12px;
}
.wriop-files-list ul.wriop-datas-list .wriop-chart-container {
margin-right: 2px;
}
.wriop-files-list ul.wriop-datas-list canvas {
width: 18px !important;
height: 18px !important;
}
/* Optimization Level Col */
.wriop-files-list .optimization_level {
text-align: center;
font-weight: bold;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 0.02em;
}
.wriopy-files-list .column-optimization_level,
.wriop-files-list .column-optimization_level a {
text-align: center;
}
.wriop-files-list .column-optimization_level a span {
float: none;
display: inline-block;
vertical-align: middle;
}
.wriop-files-list .column-optimization_level .sorting-indicator {
vertical-align: -10px;
}
/* Actions col */
.wriop-files-list .column-actions .button,
.wriop-files-list .column-actions .button-primary {
padding: 5px 20px;
font-size: 14px;
height: auto;
}
.wriop-files-list .column-actions .button-primary {
background: #3694AE;
color: #FFF;
border: 0;
box-shadow: none;
text-shadow: none;
}
.wriop-files-list .column-actions a,
.status a.button-wriop-refresh-status {
display: inline-block;
margin: .3em 0;
font-size: 12px;
font-weight: bold;
}
.wriop-files-list .wriop-status-already_optimized {
font-weight: bold;
color: #8BC34A;
}
.wriop-files-list .column-actions a .dashicons,
.wriop-files-list .column-actions a .dashicons:before,
.status a.button-wriop-refresh-status .dashicons,
.status a.button-wriop-refresh-status .dashicons:before {
margin-right: 2px;
font-size: 17px;
height: 17px;
width: 17px;
}
.wriop-files-list .wio-reoptimize {
margin-top: 15px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,404 @@
/**
* General
* @version 1.0
*/
(function($) {
var customFolders = {
selectedFolder: null,
init: function() {
if( wrio_l18n_bulk_page === undefined || wrio_settings_bulk_page === undefined ) {
console.log('[Error]: Required global variables are not declared.');
return;
}
this.i18n = wrio_l18n_bulk_page;
this.settings = wrio_settings_bulk_page;
this.startOptButton = $('#wrio-start-optimization');
this.registerEvents();
},
registerEvents: function() {
var self = this;
$("#wrio-add-new-folder").on('click', function() {
swal({
title: self.i18n.modal_cf_title,
html: $('#wrio-tmpl-select-custom-folders').html(),
type: '',
customClass: 'wrio-modal wrio-modal-optimization-way',
showCancelButton: true,
showCloseButton: true,
padding: 0,
width: 654,
confirmButtonText: self.i18n.button_select,
cancelButtonText: self.i18n.button_cancel,
reverseButtons: false,
onOpen: function(modal) {
$(modal).find("#wrio-file-tree").fileTree({
script: ajaxurl + '?action=wriop_browse_dir&_wpnonce=' + self.settings.optimization_nonce,
multiFolder: false,
onlyFolders: true
});
$(document).on('click', '#wrio-file-tree .directory > a', function() {
var subPath = $(this).attr("rel").trim();
if( subPath ) {
var fullPath = subPath;
if( fullPath.slice(-1) === '/' ) {
fullPath = fullPath.slice(0, -1);
}
$("#wbcr-rio-selected-path").val(fullPath);
self.selectedFolder = fullPath;
}
});
}
}).then(function() {
self.addNewFolder();
}).catch(swal.noop);
return false;
});
},
addNewFolder: function() {
var self = this;
var data = {
action: 'wrio-add-custom-folder',
path: self.selectedFolder,
_wpnonce: self.settings.optimization_nonce,
};
$.post(ajaxurl, data, function(response) {
if( !response || !response.success ) {
console.log('[Error]: Failed ajax request (Add new folder).');
console.log(data);
console.log(response);
if( response.data && response.data.error_message ) {
// todo: так как фреймворк не используется в аддоне, нужно доработать этот кусок кода. Он не
// может быть скомпилирован.
var noticeId = $.wbcr_factory_clearfy_000.app.showNotice(response.data.error_message, 'danger');
setTimeout(function() {
$.wbcr_factory_clearfy_000.app.hideNotice(noticeId);
}, 5000);
}
return;
}
var tr = $('<tr>'),
td = $('<td>'),
path = $('<span>'),
button = $('<button>'),
compressed_msg;
path.addClass('wrio-table-highlighter').text(response.data.path);
button.addClass('wbcr-rio-remove-folder')
.addClass('btn')
.addClass('btn-default')
.attr('data-confirm', self.i18n.alert_remove_folder)
.html(' <span class="dashicons dashicons-no"></span>');
compressed_msg = self.i18n.compressed_in_folder.replace('%1$d', 0);
compressed_msg = compressed_msg.replace('%2$s', '<span id="wrio-cf-total-' + response.data.uid + '">0</span>');
tr.addClass('wrio-table-item')
.append(td.clone().addClass('wrio-table-spinner'))
.append(td.clone().html(compressed_msg))
.append(td.clone().append(path))
.append(td.clone().attr('data-uid', response.data.uid).append(button));
$('.wbcr-rio-folders-table tbody').append(tr);
self.scanFolder({
action: 'wrio-scan-folder',
uid: response.data.uid,
total: 0,
offset: 0,
_wpnonce: self.settings.optimization_nonce,
}, function(result) {
tr.find('td').eq(0).removeClass('wrio-table-spinner');
tr.find('td').eq(1).find('span').text(result.total);
reload_ui(); // обновляем интерфейс
});
});
},
scanFolder: function(data, callback) {
var self = this;
$.post(ajaxurl, data, function(response) {
console.log(response);
if( !response || !response.success ) {
console.log('[Error]: Failed ajax request (Scan folder).');
console.log(data);
console.log(response);
if( response.data && response.data.error_message ) {
// todo: так как фреймворк не используется в аддоне, нужно доработать этот кусок кода. Он не
// может быть скомпилирован.
var noticeId = $.wbcr_factory_clearfy_000.app.showNotice(response.data.error_message, 'danger');
setTimeout(function() {
$.wbcr_factory_clearfy_000.app.hideNotice(noticeId);
}, 5000);
}
return;
}
data.total = response.data.total;
data.offset = response.data.offset;
$('#wrio-cf-total-' + data.uid).text(data.offset);
if( response.data.complete ) {
callback && callback(response.data);
} else {
self.scanFolder(data, callback);
}
}).fail(function(xhr, status, error) {
// error handling
});
}
};
$(document).ready(function() {
customFolders.init();
});
$(document).on('click', '.wbcr-rio-scan-folder', function() {
$('#wbcr-rio-popup').empty();
tb_show('Sync Folder', '#TB_inline?&width=500&height=200&inlineId=wbcr-rio-popup');
$('#TB_ajaxContent').html('Loading...');
var data = {
action: 'wio_cf_get_template_part',
template: 'sync_folder'
};
var self = $(this);
$.post(ajaxurl, data, function(response) {
$('#TB_ajaxContent').html(response);
var ai_data = {
'action': 'wriop_folder_sync_index',
'uid': self.closest('td').data('uid'),
'total': 0,
'offset': 0,
'_wpnonce': wrio_settings_bulk_page.optimization_nonce,
};
send_indexing_data(ai_data);
});
});
$('.wbcr-rio-scan-all-folders').on('click', function() {
$('#wbcr-rio-popup').empty();
tb_show('Sync All Folders', '#TB_inline?&width=500&height=200&inlineId=wbcr-rio-popup');
$('#TB_ajaxContent').html('Loading...');
var data = {
action: 'wio_cf_get_template_part',
template: 'sync_all_folders'
};
var self = $(this);
$.post(ajaxurl, data, function(response) {
$('#TB_ajaxContent').html(response);
});
});
$(document).on('click', '.wbcr-rio-optimize-folder', function() {
$('#wbcr-rio-popup').empty();
tb_show('Optimize Folder', '#TB_inline?&width=500&height=200&inlineId=wbcr-rio-popup');
$('#TB_ajaxContent').html('Loading...');
var data = {
action: 'wio_cf_get_template_part',
template: 'optimize_folder'
};
var self = $(this);
$.post(ajaxurl, data, function(response) {
$('#TB_ajaxContent').html(response);
var ai_data = {
'uid': self.closest('td').data('uid'),
'action': 'wriop_process_cf_folder_images',
'_wpnonce': $('#wio-iph-nonce').val()
};
send_optimize_post_data(ai_data);
});
});
$(document).on('click', '.wbcr-rio-restore-folder', function() {
if( !confirm($(this).data('confirm')) ) {
return false;
}
$('#wbcr-rio-popup').empty();
tb_show('Restore Folder', '#TB_inline?&width=500&height=200&inlineId=wbcr-rio-popup');
$('#TB_ajaxContent').html('Loading...');
var data = {
action: 'wio_cf_get_template_part',
template: 'restore_folder'
};
var self = $(this);
$.post(ajaxurl, data, function(response) {
$('#TB_ajaxContent').html(response);
var ai_data = {
'total': '?',
'uid': self.closest('td').data('uid'),
'action': 'wio_cf_restore_backup',
'_wpnonce': $('#wio-iph-nonce').val()
};
send_backup_post_data(ai_data);
});
return false;
});
$(document).on('click', '.wbcr-rio-remove-folder', function() {
if( !confirm($(this).data('confirm')) ) {
return false;
}
var data = {
action: 'wriop_remove_folder',
uid: $(this).closest('td').data('uid'),
_wpnonce: wrio_settings_bulk_page.optimization_nonce,
};
$(this).closest('tr').remove();
$.post(ajaxurl, data, function(response) {
reload_ui(); // обновляем интерфейс
});
});
function reload_ui() {
var data = {
action: 'wio_cf_reload_ui',
_wpnonce: wrio_settings_bulk_page.optimization_nonce,
};
$.post(ajaxurl, data, function(response) {
if( response.folders_table ) {
$('.wbcr-rio-folders-table tbody').html(response.folders_table);
}
if( response.statistic ) {
redraw_statistics(response.statistic);
}
});
}
function redraw_statistics(statistic) {
$('#wio-main-chart').attr('data-unoptimized', statistic.unoptimized)
.attr('data-optimized', statistic.optimized)
.attr('data-errors', statistic.error);
$('#wio-total-optimized-attachments').text(statistic.optimized); // optimized
$('#wio-original-size').text(bytesToSize(statistic.original_size));
$('#wio-optimized-size').text(bytesToSize(statistic.optimized_size));
$('#wio-total-optimized-attachments-pct').text(statistic.save_size_percent + '%');
$('#wio-overview-chart-percent').html(statistic.optimized_percent + '<span>%</span>');
$('.wio-total-percent').text(statistic.optimized_percent + '%');
$('#wio-optimized-bar').css('width', statistic.percent_line + '%');
$('#wio-unoptimized-num').text(statistic.unoptimized);
$('#wio-optimized-num').text(statistic.optimized);
$('#wio-error-num').text(statistic.error);
window.wio_chart.data.datasets[0].data[0] = statistic.unoptimized; // unoptimized
window.wio_chart.data.datasets[0].data[1] = statistic.optimized; // optimized
window.wio_chart.data.datasets[0].data[2] = statistic.error; // errors
window.wio_chart.update();
}
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if( bytes == 0 ) {
return '0 Byte';
}
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if( i == 0 ) {
return bytes + ' ' + sizes[i];
}
return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i];
}
function send_backup_post_data(data) {
$.post(ajaxurl, data, function(response) {
if( !response.end ) {
data.total = response.total;
send_backup_post_data(data);
$('#wio-restore-backup-progress').find('.progress-bar').css('width', response.percent + '%');
} else {
$('#wio-restore-backup-progress').find('.progress-bar').css('width', '100%');
$('#wio-restore-backup-success-msg').show();
$('#wio-restore-backup-progress-msg').hide();
reload_ui(); // обновляем интерфейс
}
});
}
function send_optimize_post_data(data) {
$.post(ajaxurl, data, function(response) {
if( !response.end ) {
send_optimize_post_data(data);
$('#wio-optimize-progress').find('.progress-bar').css('width', response.statistic.optimized_percent + '%');
} else {
$('#wio-optimize-progress').find('.progress-bar').css('width', '100%');
$('#wio-optimize-success-msg').show();
$('#wio-optimize-progress-msg').hide();
reload_ui(); // обновляем интерфейс
}
});
}
function send_indexing_data(data) {
$.post(ajaxurl, data, function(response) {
data.total = response.total;
data.offset = response.offset;
if( response.complete ) {
$('#wio-sync-progress').find('.progress-bar').css('width', '50%');
data.action = 'wriop_folder_indexing';
data.offset = 0;
data.total = 0;
send_check_index_data(data);
} else {
send_indexing_data(data);
$('#wio-sync-progress').find('.progress-bar').css('width', response.percent + '%');
}
});
}
function send_check_index_data(data) {
$.post(ajaxurl, data, function(response) {
data.total = response.total;
data.offset = response.offset;
if( response.complete ) {
$('#wio-sync-progress').find('.progress-bar').css('width', '100%');
$('#wio-sync-success-msg').show();
$('#wio-sync-progress-msg').hide();
reload_ui(); // обновляем интерфейс
} else {
send_check_index_data(data);
$('#wio-sync-progress').find('.progress-bar').css('width', response.percent + '%');
}
});
}
function first_indexing(data) {
$.post(ajaxurl, data, function(response) {
data.total = response.total;
data.offset = response.offset;
$('.wbcr-rio-indexing-counter').text(data.offset);
if( response.complete ) {
$("#wbcr-rio-add-folder").show();
$('#wbcr-rio-indexing-text').hide();
$('#wbcr-rio-indexing-finish-text').show();
reload_ui(); // обновляем интерфейс
} else {
first_indexing(data);
}
});
}
})(jQuery);

View File

@@ -0,0 +1,12 @@
/**
* General
* @version 1.0
*/
(function($) {
'use strict';
// less code
})(jQuery);

View File

@@ -0,0 +1,213 @@
/*
* jQueryFileTree Plugin
*
* @author - Cory S.N. LaViska - A Beautiful Site (http://abeautifulsite.net/) - 24 March 2008
* @author - Dave Rogers - (https://github.com/daverogers/)
*
* Usage: $('.fileTreeDemo').fileTree({ options }, callback )
*
* TERMS OF USE
*
* This plugin is dual-licensed under the GNU General Public License and the MIT License and
* is copyright 2008 A Beautiful Site, LLC.
*/
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
(function($, window) {
var FileTree;
FileTree = (function() {
function FileTree(el, args, callback) {
this.onEvent = bind(this.onEvent, this);
var $el, _this, defaults;
$el = $(el);
_this = this;
defaults = {
root: '/',
script: '/files/filetree',
folderEvent: 'click',
expandSpeed: 500,
collapseSpeed: 500,
expandEasing: 'swing',
collapseEasing: 'swing',
multiFolder: true,
loadMessage: 'Loading...',
errorMessage: 'Unable to get file tree information',
multiSelect: false,
onlyFolders: false,
onlyFiles: false,
preventLinkAction: false
};
this.jqft = {
container: $el
};
this.options = $.extend(defaults, args);
this.callback = callback;
this.data = {};
$el.html('<ul class="jqueryFileTree start"><li class="wait">' + this.options.loadMessage + '<li></ul>');
_this.showTree($el, escape(this.options.root), function() {
return _this._trigger('filetreeinitiated', {});
});
$el.delegate("li a", this.options.folderEvent, _this.onEvent);
}
FileTree.prototype.onEvent = function(event) {
var $ev, _this, callback, jqft, options, ref;
$ev = $(event.target);
options = this.options;
jqft = this.jqft;
_this = this;
callback = this.callback;
_this.data = {};
_this.data.li = $ev.closest('li');
_this.data.type = (ref = _this.data.li.hasClass('directory')) != null ? ref : {
'directory': 'file'
};
_this.data.value = $ev.text();
_this.data.rel = $ev.prop('rel');
_this.data.container = jqft.container;
if (options.preventLinkAction) {
event.preventDefault();
}
if ($ev.parent().hasClass('directory')) {
_this.jqft.container.find('LI.directory').removeClass('selected');
$ev.parent().addClass('selected');
if ($ev.parent().hasClass('collapsed')) {
if (!options.multiFolder) {
$ev.parent().parent().find('UL').slideUp({
duration: options.collapseSpeed,
easing: options.collapseEasing
});
$ev.parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');
}
$ev.parent().removeClass('collapsed').addClass('expanded');
$ev.parent().find('UL').remove();
return _this.showTree($ev.parent(), $ev.attr('rel'), function() {
_this._trigger('filetreeexpanded', _this.data);
return callback != null;
});
} else {
return $ev.parent().find('UL').slideUp({
duration: options.collapseSpeed,
easing: options.collapseEasing,
start: function() {
return _this._trigger('filetreecollapse', _this.data);
},
complete: function() {
$ev.parent().removeClass('expanded').addClass('collapsed');
_this._trigger('filetreecollapsed', _this.data);
return callback != null;
}
});
}
} else {
if (!options.multiSelect) {
jqft.container.find('li').removeClass('selected');
$ev.parent().addClass('selected');
} else {
if ($ev.parent().find('input').is(':checked')) {
$ev.parent().find('input').prop('checked', false);
$ev.parent().removeClass('selected');
} else {
$ev.parent().find('input').prop('checked', true);
$ev.parent().addClass('selected');
}
}
_this._trigger('filetreeclicked', _this.data);
return typeof callback === "function" ? callback($ev.attr('rel')) : void 0;
}
};
FileTree.prototype.showTree = function(el, dir, finishCallback) {
var $el, _this, data, handleFail, handleResult, options, result;
$el = $(el);
options = this.options;
_this = this;
$el.addClass('wait');
$(".jqueryFileTree.start").remove();
data = {
dir: dir,
onlyFolders: options.onlyFolders,
onlyFiles: options.onlyFiles,
multiSelect: options.multiSelect
};
handleResult = function(result) {
var li;
$el.find('.start').html('');
$el.removeClass('wait').append(result);
if (options.root === dir) {
$el.find('UL:hidden').show(typeof callback !== "undefined" && callback !== null);
} else {
if (jQuery.easing[options.expandEasing] === void 0) {
console.log('Easing library not loaded. Include jQueryUI or 3rd party lib.');
options.expandEasing = 'swing';
}
$el.find('UL:hidden').slideDown({
duration: options.expandSpeed,
easing: options.expandEasing,
start: function() {
return _this._trigger('filetreeexpand', _this.data);
},
complete: finishCallback
});
}
li = $('[rel="' + decodeURIComponent(dir) + '"]').parent();
if (options.multiSelect && li.children('input').is(':checked')) {
li.find('ul li input').each(function() {
$(this).prop('checked', true);
return $(this).parent().addClass('selected');
});
}
return false;
};
handleFail = function() {
$el.find('.start').html('');
$el.removeClass('wait').append("<p>" + options.errorMessage + "</p>");
return false;
};
if (typeof options.script === 'function') {
result = options.script(data);
if (typeof result === 'string' || result instanceof jQuery) {
return handleResult(result);
} else {
return handleFail();
}
} else {
return $.ajax({
url: options.script,
type: 'POST',
dataType: 'HTML',
data: data
}).done(function(result) {
return handleResult(result);
}).fail(function() {
return handleFail();
});
}
};
FileTree.prototype._trigger = function(eventType, data) {
var $el;
$el = this.jqft.container;
return $el.triggerHandler(eventType, data);
};
return FileTree;
})();
return $.fn.extend({
fileTree: function(args, callback) {
return this.each(function() {
var $this, data;
$this = $(this);
data = $this.data('fileTree');
if (!data) {
$this.data('fileTree', (data = new FileTree(this, args, callback)));
}
if (typeof args === 'string') {
return data[option].apply(data);
}
});
}
});
})(window.jQuery, window);

View File

@@ -0,0 +1,49 @@
<?php
/**
* Обычно в этом файле размещает код, который отвечает за уведомление, совместимость с другими плагинами,
* незначительные функции, которые должны быть выполнены на всех страницах админ панели.
*
* В этом файле должен быть размещен код, которые относится только к области администрирования.
*
* @version 1.0
*/
// Exit if accessed directly
use WRIO\WEBP\HTML\Delivery;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Flush configuration after saving the settings
*
* @param WHM_Plugin $plugin
* @param Wbcr_FactoryPages480_ImpressiveThemplate $page
*
* @return bool
*/
add_action(
'wbcr/factory/pages/impressive/after_form_save',
function ( $plugin, $page ) {
$is_rio_plugin = WRIO_Plugin::app()->getPluginName() == $plugin->getPluginName();
$is_settings_page = 'rio_settings' == $page->id;
$is_apache = WRIO\WEBP\Server::is_apache();
$is_use_htaccess = WRIO\WEBP\Server::server_use_htaccess();
if ( $is_rio_plugin && $is_settings_page ) {
if ( WRIO\WEBP\HTML\Delivery::should_use_converted_images() && WRIO\WEBP\HTML\Delivery::is_redirect_delivery_mode() ) {
if ( $is_apache && $is_use_htaccess ) {
WRIO\WEBP\Server::htaccess_update_webp_rules();
}
return;
}
if ( $is_apache && $is_use_htaccess ) {
WRIO\WEBP\Server::htaccess_clear_webp_rules();
}
}
},
10,
2
);

View File

@@ -0,0 +1,70 @@
<?php
/**
* Used to process different filters.
*
* @version 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Processing restore back-up of custom folder and Nextgen.
*
* @return array {
* Processing result.
* @type int $remane Count of remained images to be processed.
* @type int $total Count of total processed items.
* }
* @since 1.0.4
*/
add_filter(
'wbcr/rio/backup/restore_filter',
function ( $limit ) {
$remane_count = 0;
$total = 0;
$premium_backup = WRIOP_Backup::get_instance();
if ( wrio_is_active_nextgen_gallery() ) {
/* NextGen*/
$nextgen_restored = $premium_backup->restoreAllNextGen( $limit );
if ( isset( $nextgen_restored['remane'] ) ) {
$remane_count += $nextgen_restored['remane'];
}
$nextgen_count = RIO_Process_Queue::count_by_type_status( 'nextgen', 'success' );
if ( is_numeric( $nextgen_count ) && (int) $nextgen_count > 0 ) {
$total += $nextgen_count;
}
unset( $nextgen_count );
}
/* Custom folders */
$cf_restored = $premium_backup->restoreAllCustomFolders( $limit );
if ( isset( $cf_restored['remane'] ) ) {
$remane_count += $cf_restored['remane'];
}
$cf_count = RIO_Process_Queue::count_by_type_status( 'cf_image', 'success' );
if ( is_numeric( $cf_count ) && (int) $cf_count > 0 ) {
$total += $cf_count;
}
unset( $cf_count );
return [
'remane' => $remane_count,
'total' => $total,
];
}
);

View File

@@ -0,0 +1,87 @@
<?php
/**
* Adds hooks to the main plugin settings page.
*
* @version 1.0
*/
use WRIO\WEBP\HTML\Delivery as WEBP_Delivery;
use WRIO\WEBP\Server;
/**
* Used to save webp/avif conversion options.
*
* @since 1.0.4
*/
add_action(
'wrio/settings_page/berfore_form_save',
function () {
// Get AVIF option - if user tries to enable without premium, force disable
$avif_enabled = WRIO_Plugin::app()->request->post(
WRIO_Plugin::app()->getPrefix() . 'convert_avif_format',
false
);
if ( $avif_enabled && ! wrio_is_license_activate() ) {
WRIO_Plugin::app()->updatePopulateOption( 'convert_avif_format', false );
}
// Check if any conversion is enabled (WebP or AVIF)
$webp_enabled = WRIO_Plugin::app()->request->post(
WRIO_Plugin::app()->getPrefix() . 'convert_webp_format',
false
);
// Only process delivery mode if any conversion is enabled
if ( ! $webp_enabled && ! $avif_enabled ) {
return;
}
$allow_redirection_mode = Server::is_apache() && Server::server_use_htaccess();
$delivery_mode = WRIO_Plugin::app()->request->post( 'wrio_webp_delivery_mode', WEBP_Delivery::PICTURE_DELIVERY_MODE );
if ( WEBP_Delivery::REDIRECT_DELIVERY_MODE === $delivery_mode && ! $allow_redirection_mode ) {
$delivery_mode = WEBP_Delivery::PICTURE_DELIVERY_MODE;
}
WRIO_Plugin::app()->updatePopulateOption( 'webp_delivery_mode', $delivery_mode );
}
);
/**
* This hook prints options for delivering webp images.
*
* @since 1.0.4
*/
add_action(
'wrio/settings_page/conver_webp_options',
function () {
$allow_redirection_mode = Server::is_apache() && Server::server_use_htaccess();
$delivery_mode = WRIO_Plugin::app()->getPopulateOption( 'webp_delivery_mode', WEBP_Delivery::PICTURE_DELIVERY_MODE );
$server = 'unknown';
if ( Server::is_apache() ) {
$server = 'apache';
} elseif ( Server::is_nginx() ) {
$server = 'nginx';
} elseif ( Server::is_iss() ) {
$server = 'iss';
}
// Help
$docs_url = WRIO_Plugin::app()->get_support()->get_tracking_page_url( 'what-is-webp-format-and-how-webp-images-can-speed-up-your-wordpress-website', 'settings-page' );
$view = \WRIO_Views::get_instance( WRIOP_PLUGIN_DIR );
$view->print_template(
'part-settings-page-webp-options',
[
'server' => $server,
'delivery_mode' => $delivery_mode,
'allow_redirection_mode' => $allow_redirection_mode,
'docs_url' => $docs_url,
]
);
}
);

View File

@@ -0,0 +1 @@
<?php

View File

@@ -0,0 +1,204 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс отвечает за работу страницы статистики
*
* @version 1.0
*/
class WRIO_StatisticFolders extends WRIO_StatisticPage {
/**
* {@inheritdoc}
*/
public $id = 'io_folders_statistic';
/**
* {@inheritdoc}
*/
public $internal = true;
/**
* {@inheritdoc}
*/
public $page_parent_page = 'none';
/**
* @var string
*/
public $menu_target = null;
/**
* Use admin.php as base URL instead of menu_target.
*
* @var bool
*/
public $custom_target = true;
/**
* @var string
*/
public $page_menu_dashicon = 'dashicons-images-alt';
/**
* {@inheritdoc}
*/
public $add_link_to_plugin_actions = false;
/**
* {@inheritdoc}
*/
protected $scope = 'custom-folders';
/**
* @since 1.0
* @var WRIO_Views
*/
private $parent_view;
/**
* @param WRIO_Plugin $plugin
*/
public function __construct( WRIO_Plugin $plugin ) {
parent::__construct( $plugin );
$this->parent_view = $this->view;
$this->view = new WRIO_Views( WRIOP_PLUGIN_DIR );
}
/**
* {@inheritdoc}
*/
public function getMenuTitle() {
return __( 'Custom Folders', 'robin-image-optimizer' );
}
/**
* {@inheritdoc}
*/
public function getPageTitle() {
return __( 'Custom Folders', 'robin-image-optimizer' );
}
/**
* Подменяем простраинство имен для меню плагина, если активирован плагин
* Меню текущего плагина будет добавлено в общее меню
*
* @return string
*/
public function getMenuScope() {
if ( $this->clearfy_collaboration ) {
$this->page_parent_page = 'rio_general';
return 'wbcr_clearfy';
}
return 'robin-image-optimizer';
}
/**
* {@inheritdoc}
*/
public function assets( $scripts, $styles ) {
parent::assets( $scripts, $styles );
$this->styles->add( WRIOP_PLUGIN_URL . '/admin/assets/css/jquery-file-tree.css' );
$this->scripts->add( WRIOP_PLUGIN_URL . '/admin/assets/js/jquery-file-tree.js' );
$this->scripts->add( WRIOP_PLUGIN_URL . '/admin/assets/css/custom-folders.css' );
$this->scripts->add( WRIOP_PLUGIN_URL . '/admin/assets/js/custom-folders.js' );
}
/**
* {@inheritdoc}
*/
public function showPageContent() {
$is_premium = wrio_is_license_activate();
$statistics = WRIO_Image_Statistic_Folders::get_instance();
$template_data = [
'is_premium' => $is_premium,
'scope' => $this->scope,
];
// do_action( 'wbcr/rio/multisite_current_blog' );
// Page header
$this->parent_view->print_template(
'part-page-header',
[
'title' => __( 'Image optimization dashboard', 'robin-image-optimizer' ),
'description' => __( 'Monitor image optimization statistics and run on demand or scheduled optimization.', 'robin-image-optimizer' ),
],
$this
);
// Page tabs
$this->parent_view->print_template( 'part-bulk-optimization-tabs', $template_data, $this );
?>
<div class="wbcr-factory-page-group-body" style="padding:0; border-top: 1px solid #d4d4d4;">
<?php
// Servers
$this->parent_view->print_template( 'part-bulk-optimization-servers', $template_data, $this );
// Statistic
$this->parent_view->print_template(
'part-bulk-optimization-statistic',
array_merge(
$template_data,
[
'stats' => $statistics->get(),
]
),
$this
);
// Folders table
$this->view->print_template( 'part-bulk-optimization-table-folders', $template_data, $this );
// Optimization log
$this->parent_view->print_template(
'part-bulk-optimization-log',
array_merge(
$template_data,
[
'process_log' => $statistics->get_last_optimized_images(),
]
),
$this
);
?>
</div>
<script type="text/html" id="wrio-tmpl-bulk-optimization">
<?php $this->parent_view->print_template( 'modal-bulk-optimization' ); ?>
</script>
<script type="text/html" id="wrio-tmpl-select-custom-folders">
<?php $this->view->print_template( 'modal-select-custom-folders' ); ?>
</script>
<?php
// do_action( 'wbcr/rio/multisite_restore_blog' );
}
protected function get_i18n() {
$i18n = parent::get_i18n();
$i18n['modal_cf_title'] = __( 'Select custom folder', 'robin-image-optimizer' );
// $i18n['modal_cf_description'] = __( 'Select a directory for optimization. All nested images and folders will be optimized recursively.', 'robin-image-optimizer' );
$i18n['button_select'] = __( 'Select', 'robin-image-optimizer' );
$i18n['button_cancel'] = __( 'Cancel', 'robin-image-optimizer' );
$i18n['button_remove'] = __( 'Remove', 'robin-image-optimizer' );
$i18n['alert_remove_folder'] = __( 'Exclude directory from optimization?', 'robin-image-optimizer' );
// translators: %d is the number of images found
$i18n['found_images'] = __( 'Selected directory is being indexed. Found %d images.', 'robin-image-optimizer' );
$i18n['scan_complete'] = __( 'Indexing complete. Directory successfully added and ready for optimization.', 'robin-image-optimizer' );
// translators: %1$d is the number of compressed images, %2$s is the total number of images
$i18n['compressed_in_folder'] = __( 'Compressed %1$d of %2$s<br>images', 'robin-image-optimizer' );
$i18n['optimization_complete'] = __( 'All images from custom folders are optimized.', 'robin-image-optimizer' );
return $i18n;
}
}

View File

@@ -0,0 +1,111 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Класс отвечает за работу страницы статистики
*
* @version 1.0
*/
class WRIO_StatisticNextgenPage extends WRIO_StatisticPage {
/**
* {@inheritdoc}
*/
public $id = 'io_nextgen_gallery_statistic';
/**
* {@inheritdoc}
*/
public $page_menu_dashicon = 'dashicons-images-alt';
/**
* {@inheritdoc}
*/
public $internal = true;
/**
* @var string
*/
public $menu_target = null;
/**
* Use admin.php as base URL instead of menu_target.
*
* @var bool
*/
public $custom_target = true;
/**
* none - to hide page from plugin menu
* {@inheritdoc}
*/
public $page_parent_page = 'none';
/**
* {@inheritdoc}
*/
public $add_link_to_plugin_actions = false;
/**
* {@inheritdoc}
*/
protected $scope = 'nextgen-gallery';
/**
* @param WRIO_Plugin $plugin
*/
public function __construct( WRIO_Plugin $plugin ) {
$this->plugin = $plugin;
parent::__construct( $plugin );
}
/**
* {@inheritdoc}
*/
public function getMenuTitle() {
return __( 'NextGen Gallery', 'robin-image-optimizer' );
}
/**
* {@inheritdoc}
*/
public function getPageTitle() {
return __( 'NextGen Gallery', 'robin-image-optimizer' );
}
/**
* Подменяем простраинство имен для меню плагина, если активирован плагин
* Меню текущего плагина будет добавлено в общее меню
*
* @return string
*/
public function getMenuScope() {
if ( $this->clearfy_collaboration ) {
$this->page_parent_page = 'rio_general';
return 'wbcr_clearfy';
}
return 'robin-image-optimizer';
}
/**
* {@inheritdoc}
*/
public function assets( $scripts, $styles ) {
parent::assets( $scripts, $styles );
}
/**
* @since 1.3.0
* @return object|\WRIO_Image_Statistic
*/
protected function get_statisctic_data() {
return WRIO_Image_Statistic_Nextgen::get_instance();
}
}