Changeset 2784230
- Timestamp:
- 09/13/2022 09:47:27 PM (2 years ago)
- Location:
- resmushit-image-optimizer/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
resmushit-image-optimizer/trunk/classes/resmushit.class.php
r2768724 r2784230 60 60 return false; 61 61 } 62 62 if(! in_array('curl', get_loaded_extensions())){ 63 return false; 64 } 65 63 66 $ch = curl_init(); 64 67 curl_setopt($ch, CURLOPT_URL, RESMUSHIT_ENDPOINT); -
resmushit-image-optimizer/trunk/classes/resmushitUI.class.php
r2784196 r2784230 22 22 public static function fullWidthPanel($title = null, $html = null, $border = null) { 23 23 self::fullWidthPanelWrapper($title, $html, $border); 24 echo $html;24 echo wp_kses_post($html); 25 25 self::fullWidthPanelEndWrapper(); 26 26 } … … 44 44 $borderClass = 'brdr-'.$border; 45 45 } 46 echo "<div class='rsmt-panel w100 $borderClass'><h2>$title</h2>";46 echo wp_kses_post("<div class='rsmt-panel w100 $borderClass'><h2>$title</h2>"); 47 47 } 48 48 … … 58 58 */ 59 59 public static function fullWidthPanelEndWrapper() { 60 echo "</div>";60 echo wp_kses_post("</div>"); 61 61 } 62 62 … … 88 88 */ 89 89 public static function settingsPanel() { 90 $allowed_html = array( 91 'input' => array( 92 'type' => array(), 93 'name' => array(), 94 'value' => array(), 95 'checked' => array(), 96 'class' => array(), 97 'id' => array() 98 ), 99 'form' => array( 100 'method' => array(), 101 'action' => array(), 102 'id' => array() 103 ), 104 'div' => array( 105 'class' => array(), 106 ), 107 'span' => array( 108 'class' => array(), 109 ), 110 'table' => array( 111 'class' => array(), 112 ), 113 'label' => array( 114 'class' => array(), 115 ), 116 'p' => array() 117 ); 118 90 119 self::fullWidthPanelWrapper(__('Settings', 'resmushit-image-optimizer'), null, 'orange'); 91 120 $new_label = "<span class='new'>" . __("New!", 'resmushit-image-optimizer') . "</span>"; 92 echo '<div class="rsmt-settings">93 <form method="post" action="options.php" id="rsmt-options-form">' ;121 echo wp_kses('<div class="rsmt-settings"> 122 <form method="post" action="options.php" id="rsmt-options-form">', $allowed_html); 94 123 settings_fields( 'resmushit-settings' ); 95 124 do_settings_sections( 'resmushit-settings' ); 96 125 97 echo '<table class="form-table">' 126 127 128 echo wp_kses('<table class="form-table">' 98 129 . self::addSetting("text", __("Image quality", 'resmushit-image-optimizer'), __("Default value is 92. The quality factor must be between 0 (very weak) and 100 (best quality)", 'resmushit-image-optimizer'), "resmushit_qlty") 99 130 . self::addSetting("checkbox", __("Optimize on upload", 'resmushit-image-optimizer'), __("All future images uploaded will be automatically optimized", 'resmushit-image-optimizer'), "resmushit_on_upload") … … 103 134 . self::addSetting("checkbox", $new_label . __("Preserve EXIF", 'resmushit-image-optimizer'), __("Will preserve EXIF data during optimization", 'resmushit-image-optimizer'), "resmushit_preserve_exif") 104 135 . self::addSetting("checkbox", $new_label . __("Do not preserve backups", 'resmushit-image-optimizer'), sprintf(__("Will not preserve a backup of the original file (save space). <a href='%s' title='Should I remove backups?' target='_blank'>Read instructions</a> carefully before enabling.", 'resmushit-image-optimizer'), 'https://resmush.it/wordpress/why-keeping-backup-files'), "resmushit_remove_unsmushed") 105 . '</table>' ;136 . '</table>', $allowed_html); 106 137 submit_button(); 107 echo '</form></div>';138 echo wp_kses('</form></div>', $allowed_html); 108 139 self::fullWidthPanelEndWrapper(); 109 140 } … … 132 163 } 133 164 134 echo "<div class='rsmt-bulk'><div class='non-optimized-wrapper $additionnalClassNeedOptimization'><h3 class='icon_message warning'>";165 echo wp_kses_post("<div class='rsmt-bulk'><div class='non-optimized-wrapper $additionnalClassNeedOptimization'><h3 class='icon_message warning'>"); 135 166 136 167 if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) { 137 echo "<em>$countNonOptimizedPictures "168 echo wp_kses_post("<em>$countNonOptimizedPictures " 138 169 . __('non optimized pictures will be automatically optimized', 'resmushit-image-optimizer') 139 170 . "</em>.</h3><p>" 140 171 . __('These pictures will be automatically optimized using schedule tasks (cronjobs).', 'resmushit-image-optimizer') 141 172 . " " 142 . __('Image optimization process can be launched <b>manually</b> by clicking on the button below :', 'resmushit-image-optimizer') ;173 . __('Image optimization process can be launched <b>manually</b> by clicking on the button below :', 'resmushit-image-optimizer')); 143 174 } else { 144 echo __('There is currently', 'resmushit-image-optimizer')175 echo wp_kses_post(__('There is currently', 'resmushit-image-optimizer') 145 176 . " <em>$countNonOptimizedPictures " 146 177 . __('non optimized pictures', 'resmushit-image-optimizer') 147 178 . "</em>.</h3><p>" 148 . __('This action will resmush all pictures which have not been optimized to the good Image Quality Rate.', 'resmushit-image-optimizer'); 149 } 150 151 echo "</p><p class='submit' id='bulk-resize-examine-button'><button class='button-primary' onclick='resmushit_bulk_resize(\"bulk_resize_image_list\");'>"; 179 . __('This action will resmush all pictures which have not been optimized to the good Image Quality Rate.', 'resmushit-image-optimizer')); 180 } 181 182 $allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array( 183 'button' => array( 184 'class' => array(), 185 'onclick' => array() 186 ))); 187 188 echo wp_kses("</p><p class='submit' id='bulk-resize-examine-button'><button class='button-primary' onclick='resmushit_bulk_resize(\"bulk_resize_image_list\");'>", $allowed_html); 152 189 153 190 if(get_option('resmushit_cron') && get_option('resmushit_cron') == 1) { 154 echo __('Optimize all pictures manually', 'resmushit-image-optimizer');191 echo wp_kses_post(__('Optimize all pictures manually', 'resmushit-image-optimizer')); 155 192 } else { 156 echo __('Optimize all pictures', 'resmushit-image-optimizer');157 } 158 159 echo "</button></p><div id='bulk_resize_image_list'></div></div>"193 echo wp_kses_post(__('Optimize all pictures', 'resmushit-image-optimizer')); 194 } 195 196 echo wp_kses_post("</button></p><div id='bulk_resize_image_list'></div></div>" 160 197 . "<div class='optimized-wrapper $additionnalClassNoNeedOptimization'><h3 class='icon_message ok'>" 161 198 . __('Congrats ! All your pictures are correctly optimized', 'resmushit-image-optimizer') 162 . "</h3></div></div>" ;199 . "</h3></div></div>"); 163 200 self::fullWidthPanelEndWrapper(); 164 201 } … … 186 223 } 187 224 188 echo "<div class='rsmt-bigfiles'><div class='optimized-wrapper $additionnalClass'>189 <h3 class='icon_message info'>" ;225 echo wp_kses_post("<div class='rsmt-bigfiles'><div class='optimized-wrapper $additionnalClass'> 226 <h3 class='icon_message info'>"); 190 227 191 228 if($countfilesTooBigPictures > 1) { 192 echo htmlspecialchars($countfilesTooBigPictures, ENT_QUOTES, 'UTF-8') . ' ' . __('pictures are too big (> 5MB) for the optimizer', 'resmushit-image-optimizer');229 echo esc_html($countfilesTooBigPictures . ' ' . __('pictures are too big (> 5MB) for the optimizer', 'resmushit-image-optimizer')); 193 230 } else { 194 echo htmlspecialchars($countfilesTooBigPictures, ENT_QUOTES, 'UTF-8') . ' ' . __('picture is too big (> 5MB) for the optimizer', 'resmushit-image-optimizer');195 } 196 echo "</h3><div class='list-accordion'><h4>"231 echo esc_html($countfilesTooBigPictures . ' ' . __('picture is too big (> 5MB) for the optimizer', 'resmushit-image-optimizer')); 232 } 233 echo wp_kses_post("</h3><div class='list-accordion'><h4>" 197 234 . __('List of files above 5MB', 'resmushit-image-optimizer') 198 . "</h4><ul>" ;235 . "</h4><ul>"); 199 236 200 237 foreach($getNonOptimizedPictures->filestoobig as $file){ … … 202 239 $filesize = reSmushitUI::sizeFormat(filesize(get_attached_file( $file->ID ))); 203 240 204 echo "<li><a href='"205 . htmlspecialchars(wp_get_attachment_url( $file->ID ), ENT_QUOTES, 'UTF-8')241 echo wp_kses_post("<li><a href='" 242 . esc_url(wp_get_attachment_url( $file->ID )) 206 243 . "' target='_blank'>" 207 244 . wp_get_attachment_image($file->ID, 'thumbnail') 208 245 . "<span>" 209 . htmlspecialchars($fileInfo['basename'], ENT_QUOTES, 'UTF-8') . ' (' . $filesize . ').</span></a></li>';210 } 211 echo '</ul></div></div></div>';246 . $fileInfo['basename'] . ' (' . $filesize . ').</span></a></li>'); 247 } 248 echo wp_kses_post('</ul></div></div></div>'); 212 249 213 250 self::fullWidthPanelEndWrapper(); … … 230 267 $resmushit_stat = reSmushit::getStatistics(); 231 268 232 echo "<div class='rsmt-statistics'>";269 echo wp_kses_post("<div class='rsmt-statistics'>"); 233 270 234 271 if($resmushit_stat['files_optimized'] != 0) { 235 echo "<p><strong>"272 echo wp_kses_post("<p><strong>" 236 273 . __('Space saved :', 'resmushit-image-optimizer') 237 274 . "</strong> <span id='rsmt-statistics-space-saved'>" … … 257 294 . "</strong> <span id='rsmt-statistics-total-optimizations'>" 258 295 . $resmushit_stat['total_optimizations'] 259 . "</span></p>" ;296 . "</span></p>"); 260 297 } else { 261 echo "<p>" . __('No picture has been optimized yet ! Add pictures to your Wordpress Media Library.', 'resmushit-image-optimizer') . "</p>";298 echo wp_kses_post("<p>" . __('No picture has been optimized yet ! Add pictures to your Wordpress Media Library.', 'resmushit-image-optimizer') . "</p>"); 262 299 } 263 echo "</div>";300 echo wp_kses_post("</div>"); 264 301 self::fullWidthPanelEndWrapper(); 265 302 } … … 278 315 } 279 316 self::fullWidthPanelWrapper(__('Restore Media Library', 'resmushit-image-optimizer'), null, 'black'); 280 281 echo "<div class='rsmt-restore'>"; 282 283 echo 284 '<p><strong>' 317 $allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array( 318 'input' => array( 319 'type' => array(), 320 'value' => array(), 321 'class' => array(), 322 'name' => array() 323 ))); 324 325 echo wp_kses("<div class='rsmt-restore'>" 326 . '<p><strong>' 285 327 . __('Warning! By clicking the button below, you will restore all the original pictures, as before reSmush.it Image Optimizer installation. You will not have your pictures optimized! We strongly advice to be sure to have a complete backup of your website before performing this action', 'resmushit-image-optimizer') 286 328 . '</strong></p><p>' 287 . '<input type="button" value="'. __('Restore ALL my original pictures', 'resmushit-image-optimizer') .'" class="rsmt-trigger--restore-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />' ;288 echo "</div>";329 . '<input type="button" value="'. __('Restore ALL my original pictures', 'resmushit-image-optimizer') .'" class="rsmt-trigger--restore-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />' 330 . '</div>', $allowed_html); 289 331 self::fullWidthPanelEndWrapper(); 290 332 } … … 300 342 global $wp_version; 301 343 302 echo "<div class='rsmt-news'>";344 echo wp_kses_post("<div class='rsmt-news'>"); 303 345 304 346 self::fullWidthPanelWrapper(__('News', 'resmushit-image-optimizer'), null, 'red'); 305 $ch = curl_init(); 306 curl_setopt($ch, CURLOPT_URL, RESMUSHIT_NEWSFEED); 307 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 308 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); 309 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 310 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 311 $data_raw = curl_exec($ch); 312 curl_close($ch); 313 $data = json_decode($data_raw); 314 347 if(in_array('curl', get_loaded_extensions())){ 348 $ch = curl_init(); 349 curl_setopt($ch, CURLOPT_URL, RESMUSHIT_NEWSFEED); 350 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 351 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); 352 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 353 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 354 $data_raw = curl_exec($ch); 355 curl_close($ch); 356 $data = json_decode($data_raw); 357 } else { 358 $data = []; 359 } 315 360 if($data) { 316 361 foreach($data as $i=>$news) { … … 319 364 } 320 365 321 echo "<div class='news-item'><span class='news-date'>"366 echo wp_kses_post("<div class='news-item'><span class='news-date'>" 322 367 . date('d/m/Y', $news->date) 323 . "</span>" ;368 . "</span>"); 324 369 if($news->picture) { 325 echo "<div class='news-img'><a href='"326 . htmlspecialchars($news->link, ENT_QUOTES, 'UTF-8')370 echo wp_kses_post("<div class='news-img'><a href='" 371 . esc_url($news->link) 327 372 . "' target='_blank'><img src='" 328 . htmlspecialchars($news->picture, ENT_QUOTES, 'UTF-8')329 . "' /></a></div>" ;373 . esc_url($news->picture) 374 . "' /></a></div>"); 330 375 } 331 echo "<h3><a href='"332 . htmlspecialchars($news->link, ENT_QUOTES, 'UTF-8')376 echo wp_kses_post("<h3><a href='" 377 . esc_url($news->link) 333 378 . "' target='_blank'>" 334 . htmlspecialchars($news->title, ENT_QUOTES, 'UTF-8')379 . $news->title 335 380 . "</a></h3><div class='news-content'>" 336 . htmlspecialchars($news->content, ENT_QUOTES, 'UTF-8')337 . "</div>" ;381 . $news->content 382 . "</div>"); 338 383 } 339 384 } 340 385 341 echo "<div class='social'>"386 echo wp_kses_post("<div class='social'>" 342 387 . "<p class='datainformation'>" 343 388 . __('No user data nor any information is collected while requesting this news feed.', 'resmushit-image-optimizer') … … 352 397 . "' href='https://www.twitter.com/resmushit' target='_blank'>" 353 398 . "<img src='" 354 . RESMUSHIT_BASE_URL . "images/twitter.png' /></a></div></div>" ;399 . RESMUSHIT_BASE_URL . "images/twitter.png' /></a></div></div>"); 355 400 356 401 self::fullWidthPanelEndWrapper(); … … 377 422 if(resmushit_get_cron_status() != 'DISABLED' && resmushit_get_cron_status() != 'OK') { 378 423 379 echo "<div class='rsmt-alert'>";380 echo"<h3 class='icon_message warning'>"424 echo wp_kses_post("<div class='rsmt-alert'>" 425 . "<h3 class='icon_message warning'>" 381 426 . __('Cronjobs seems incorrectly configured', 'resmushit-image-optimizer') 382 . "</h3>" ;427 . "</h3>"); 383 428 384 429 if (resmushit_get_cron_status() == 'MISCONFIGURED') { 385 echo "<p>"430 echo wp_kses_post("<p>" 386 431 . __('Cronjobs are not correctly configured. The variable <em>DISABLE_WP_CRON</em> must be set to <em>TRUE</em> in <em>wp-config.php</em>. Please install them by reading the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a>.', 'resmushit-image-optimizer') 387 432 . "</p><p>" 388 433 . __('We advice to disable Remush.it option "Process optimize on CRON" as long as Cron jobs are incorrectly set up.', 'resmushit-image-optimizer') 389 . "</p>" ;434 . "</p>"); 390 435 } else if (resmushit_get_cron_status() == 'NEVER_RUN') { 391 echo "<p>"436 echo wp_kses_post("<p>" 392 437 . __('Cronjobs seems to have never been launched. Please install them by reading the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a>.', 'resmushit-image-optimizer') 393 . "</p>" ;438 . "</p>"); 394 439 } else if (resmushit_get_cron_status() == 'NO_LATELY_RUN') { 395 echo "<p>"440 echo wp_kses_post("<p>" 396 441 . __('Cronjobs seems not to have run lately. Please read the following <a href="https://resmush.it/wordpress/howto-configure-cronjobs" target="_blank">instruction page</a> to install them correctly.', 'resmushit-image-optimizer') 397 442 . "<ul><li><em>" . __('Expected Frequency :', 'resmushit-image-optimizer') . "</em> " . __('Every', 'resmushit-image-optimizer') . " " . time_elapsed_string(RESMUSHIT_CRON_FREQUENCY) . "</li>" 398 443 . "<li><em>" . __('Last run :', 'resmushit-image-optimizer') . "</em> " . time_elapsed_string(time() - get_option('resmushit_cron_lastrun')) . " " . __('ago', 'resmushit-image-optimizer') . "</li></ul>" 399 . "</p>" ;444 . "</p>"); 400 445 } 401 echo "</div>";446 echo wp_kses_post("</div>"); 402 447 } 403 448 if(get_option('resmushit_remove_unsmushed') == 1 && get_option('resmushit_has_no_backup_files') == 0) { … … 405 450 406 451 if($files_to_delete) { 407 echo "<div class='rsmt-alert'>"; 408 echo "<h3 class='icon_message warning'>" 452 $allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array( 453 'input' => array( 454 'type' => array(), 455 'value' => array(), 456 'class' => array(), 457 'name' => array(), 458 ))); 459 echo wp_kses("<div class='rsmt-alert'>" 460 . "<h3 class='icon_message warning'>" 409 461 . __('Backup files can be removed.', 'resmushit-image-optimizer') 410 . "</h3>"; 411 412 echo 413 '<p>' 414 . sprintf(__('Keep these files and turn off "Do not preserve backups" option if you want to restore your unoptimized files in the future. Please <a href="%s" title="Should I remove backups? target="_blank">read instructions</a> before clicking.', 'resmushit-image-optimizer'), 'https://resmush.it/wordpress/why-keeping-backup-files') 415 . '</p><p>' 416 417 . sprintf( __( 'We have found %s files ready to be removed', 'resmushit-image-optimizer' ), count(detect_unsmushed_files()) ) 418 . '</p><p>' 419 . '<input type="button" value="'. __('Remove backup files', 'resmushit-image-optimizer') .'" class="rsmt-trigger--remove-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />'; 420 421 echo "</div>"; 462 . "</h3>" 463 . '<p>' 464 . sprintf(__('Keep these files and turn off "Do not preserve backups" option if you want to restore your unoptimized files in the future. Please <a href="%s" title="Should I remove backups? target="_blank">read instructions</a> before clicking.', 'resmushit-image-optimizer'), 'https://resmush.it/wordpress/why-keeping-backup-files') 465 . '</p><p>' 466 . sprintf( __( 'We have found %s files ready to be removed', 'resmushit-image-optimizer' ), count(detect_unsmushed_files()) ) 467 . '</p><p>' 468 . '<input type="button" value="'. __('Remove backup files', 'resmushit-image-optimizer') .'" class="rsmt-trigger--remove-backup-files button media-button select-mode-toggle-button" name="resmushit" class="button wp-smush-send" />' 469 . "</div>", $allowed_html); 422 470 } 423 471 } … … 483 531 $attachment_resmushit_disabled = 'checked'; 484 532 485 $output = '<input type="checkbox" data-attachment-id="'. htmlspecialchars($id, ENT_QUOTES, 'UTF-8').'"" class="rsmt-trigger--disabled-checkbox" '. $attachment_resmushit_disabled .' />';533 $output = '<input type="checkbox" data-attachment-id="'. $id .'"" class="rsmt-trigger--disabled-checkbox" '. $attachment_resmushit_disabled .' />'; 486 534 487 535 if($return) 488 536 return $output; 489 echo $output; 537 538 $allowed_html = array( 539 'input' => array( 540 'type' => array(), 541 'data-attachment-id' => array(), 542 'checked' => array(), 543 )); 544 echo wp_kses($output, $allowed_html); 490 545 } 491 546 … … 506 561 } 507 562 else if(reSmushit::getAttachmentQuality($attachment_id) != reSmushit::getPictureQualitySetting()) 508 $output = '<input type="button" value="'. __('Optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'. htmlspecialchars($attachment_id, ENT_QUOTES, 'UTF-8').'" class="button wp-smush-send" />';563 $output = '<input type="button" value="'. __('Optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'. $attachment_id .'" class="button wp-smush-send" />'; 509 564 else{ 510 565 $statistics = reSmushit::getStatistics($attachment_id); 511 $output = __('Reduced by', 'resmushit-image-optimizer') . " ". htmlspecialchars($statistics['total_saved_size_nice'], ENT_QUOTES, 'UTF-8') ." (". htmlspecialchars($statistics['percent_reduction'], ENT_QUOTES, 'UTF-8'). ' ' . __('saved', 'resmushit-image-optimizer') . ")";512 $output .= '<input type="button" value="'. __('Force re-optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'. htmlspecialchars($attachment_id, ENT_QUOTES, 'UTF-8').'" class="button wp-smush-send" />';566 $output = __('Reduced by', 'resmushit-image-optimizer') . " ". $statistics['total_saved_size_nice'] ." (". $statistics['percent_reduction'] . ' ' . __('saved', 'resmushit-image-optimizer') . ")"; 567 $output .= '<input type="button" value="'. __('Force re-optimize', 'resmushit-image-optimizer') .'" class="rsmt-trigger--optimize-attachment button media-button select-mode-toggle-button" name="resmushit" data-attachment-id="'. $attachment_id .'" class="button wp-smush-send" />'; 513 568 } 514 569 515 570 if($return) 516 571 return $output; 517 echo $output; 572 $allowed_html = array_merge(wp_kses_allowed_html( 'post' ), array( 573 'input' => array( 574 'type' => array(), 575 'value' => array(), 576 'class' => array(), 577 'name' => array(), 578 'data-attachment-id' => array(), 579 'checked' => array(), 580 ))); 581 echo wp_kses($output, $allowed_html); 518 582 } 519 583 -
resmushit-image-optimizer/trunk/readme.txt
r2784196 r2784230 4 4 Requires at least: 4.0.0 5 5 Tested up to: 6.0.2 6 Stable tag: 0.4. 56 Stable tag: 0.4.6 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 75 75 == Changelog == 76 76 77 78 = 0.4.6 = 79 * Security fixes : protection in a WP's way 77 80 78 81 = 0.4.5 = -
resmushit-image-optimizer/trunk/resmushit.inc.php
r2528798 r2784230 31 31 $prefix = "[\033[32m+\033[0m]"; break; 32 32 } 33 echo "$prefix $str\n";33 echo esc_html("$prefix $str\n"); 34 34 } 35 35 -
resmushit-image-optimizer/trunk/resmushit.php
r2784196 r2784230 11 11 * Plugin URI: https://wordpress.org/plugins/resmushit-image-optimizer/ 12 12 * Description: Image Optimization API. Provides image size optimization 13 * Version: 0.4. 513 * Version: 0.4.6 14 14 * Timestamp: 2022.09.13 15 15 * Author: reSmush.it … … 195 195 function resmushit_bulk_get_images() { 196 196 if(!is_super_admin() && !current_user_can('administrator')) { 197 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));198 die(); 199 } 200 echo reSmushit::getNonOptimizedPictures();197 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 198 die(); 199 } 200 wp_send_json(reSmushit::getNonOptimizedPictures()); 201 201 die(); 202 202 } … … 215 215 function resmushit_update_disabled_state() { 216 216 if(!is_super_admin() && !current_user_can('administrator')) { 217 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));217 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 218 218 die(); 219 219 } 220 220 if(isset($_POST['data']['id']) && $_POST['data']['id'] != null && isset($_POST['data']['disabled'])){ 221 echo htmlspecialchars(reSmushit::updateDisabledState(sanitize_text_field((int)$_POST['data']['id']), sanitize_text_field($_POST['data']['disabled'])), ENT_NOQUOTES, 'UTF-8');221 echo wp_kses_post(reSmushit::updateDisabledState(sanitize_text_field((int)$_POST['data']['id']), sanitize_text_field($_POST['data']['disabled']))); 222 222 } 223 223 die(); … … 238 238 function resmushit_optimize_single_attachment() { 239 239 if(!is_super_admin() && !current_user_can('administrator')) { 240 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));240 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 241 241 die(); 242 242 } 243 243 if(isset($_POST['data']['id']) && $_POST['data']['id'] != null){ 244 244 reSmushit::revert(sanitize_text_field((int)$_POST['data']['id'])); 245 echo json_encode(reSmushit::getStatistics(sanitize_text_field((int)$_POST['data']['id'])));245 wp_send_json(json_encode(reSmushit::getStatistics(sanitize_text_field((int)$_POST['data']['id'])))); 246 246 } 247 247 die(); … … 262 262 function resmushit_bulk_process_image() { 263 263 if(!is_super_admin() && !current_user_can('administrator')) { 264 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));264 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 265 265 die(); 266 266 } 267 267 rlog('Bulk optimization launched for file : ' . get_attached_file( sanitize_text_field((int)$_POST['data']['ID']) )); 268 echo htmlspecialchars(reSmushit::revert(sanitize_text_field((int)$_POST['data']['ID'])), ENT_QUOTES, 'UTF-8');268 echo esc_html(reSmushit::revert(sanitize_text_field((int)$_POST['data']['ID']))); 269 269 die(); 270 270 } … … 284 284 function resmushit_update_statistics() { 285 285 if(!is_super_admin() && !current_user_can('administrator')) { 286 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));286 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 287 287 die(); 288 288 } 289 289 $output = reSmushit::getStatistics(); 290 290 $output['total_saved_size_formatted'] = reSmushitUI::sizeFormat($output['total_saved_size']); 291 echo json_encode($output);291 wp_send_json(json_encode($output)); 292 292 die(); 293 293 } … … 454 454 $return = array('success' => 0); 455 455 if(!is_super_admin() && !current_user_can('administrator')) { 456 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));456 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 457 457 die(); 458 458 } … … 465 465 } 466 466 } 467 echo json_encode($return);468 467 update_option( 'resmushit_has_no_backup_files', 1); 468 wp_send_json(json_encode($return)); 469 469 470 470 die(); … … 496 496 function resmushit_restore_backup_files() { 497 497 if(!is_super_admin() && !current_user_can('administrator')) { 498 return(json_encode(array('error' => 'User must be at least administrator to retrieve these data')));498 wp_send_json(json_encode(array('error' => 'User must be at least administrator to retrieve these data'))); 499 499 die(); 500 500 } … … 514 514 } 515 515 } 516 echo json_encode($return);516 wp_send_json(json_encode($return)); 517 517 die(); 518 518 } -
resmushit-image-optimizer/trunk/resmushit.settings.php
r2784196 r2784230 2 2 3 3 define('RESMUSHIT_ENDPOINT', 'http://api.resmush.it/'); 4 define('RESMUSHIT_VERSION', '0.4. 5');4 define('RESMUSHIT_VERSION', '0.4.6'); 5 5 define('RESMUSHIT_DEFAULT_QLTY', '92'); 6 6 define('RESMUSHIT_TIMEOUT', '10');
Note: See TracChangeset
for help on using the changeset viewer.