Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
834e12c
Init onboarding
tijmenbruggeman Aug 25, 2026
858e248
onboarding scaffolding
tijmenbruggeman Aug 27, 2026
57eda31
format
tijmenbruggeman Aug 27, 2026
20e0221
use onboarding flag
tijmenbruggeman Aug 27, 2026
fccfe39
transport to step 2 on api key registration
tijmenbruggeman Aug 27, 2026
c0860e0
onboarding
tijmenbruggeman Sep 1, 2026
873a844
simplify menu registration
tijmenbruggeman Sep 8, 2026
e7cdf57
update dashboard widget
tijmenbruggeman Sep 23, 2026
07a033d
refactor ui for dashboard widget
tijmenbruggeman Sep 23, 2026
90b3175
fix tests
tijmenbruggeman Sep 23, 2026
a612785
Use plugin version
tijmenbruggeman Sep 23, 2026
5a64197
fix empty label
tijmenbruggeman Sep 23, 2026
db7470b
simplify pay state
tijmenbruggeman Sep 23, 2026
4bf80a7
resolve e2e tests
tijmenbruggeman Sep 23, 2026
eb3edbc
format
tijmenbruggeman Sep 23, 2026
41d6570
feat: update texts
tijmenbruggeman Sep 29, 2026
2210523
set guard to only allow dashboard widget for users that can upload
tijmenbruggeman Oct 6, 2026
33fdc86
convert to private funcs
tijmenbruggeman Oct 6, 2026
5d3035a
use settings get pay state
tijmenbruggeman Oct 6, 2026
3a4846a
remove unused action and method
tijmenbruggeman Oct 6, 2026
c63df81
remove default valeus
tijmenbruggeman Oct 6, 2026
da29255
format and tests
tijmenbruggeman Oct 6, 2026
1b50e80
read credits and api key from settings in widget data
tijmenbruggeman Oct 6, 2026
da613b8
formatting
tijmenbruggeman Oct 6, 2026
a58f8a4
add doc
tijmenbruggeman Oct 6, 2026
f14c406
Merge branch 'master' of github.com:wcreateweb/wordpress-plugin into …
tijmenbruggeman Oct 6, 2026
eef72c8
add media assets
tijmenbruggeman Oct 12, 2026
c2b2694
UI for onboarding
tijmenbruggeman Oct 12, 2026
4b470d1
phpcs
tijmenbruggeman Oct 12, 2026
6a53d2f
use css variables
tijmenbruggeman Oct 12, 2026
c32287c
do not redirect on admin_init
tijmenbruggeman Oct 13, 2026
aeafc66
reuse rendering for modern formats
tijmenbruggeman Oct 13, 2026
1b2ec35
Merge branch 'master' of github.com:wcreateweb/wordpress-plugin into …
tijmenbruggeman Oct 19, 2026
90595ef
feat: refresh pending api key status in settings
tijmenbruggeman Oct 19, 2026
f500f6f
feat: store when a bulk run started
tijmenbruggeman Oct 19, 2026
e52ab1a
feat: redesign dashboard widget
tijmenbruggeman Oct 19, 2026
d2efee3
style: lighten the widget badge
tijmenbruggeman Oct 19, 2026
2b7091d
refactor: remove dashboard widget polling
tijmenbruggeman Oct 19, 2026
99c77e7
test: allow 15s for the background run
tijmenbruggeman Oct 19, 2026
bcaa6a1
style: slide between the widget views
tijmenbruggeman Oct 19, 2026
38258fb
simplify timeleft calculation
tijmenbruggeman Oct 20, 2026
7a34a89
css tuning
tijmenbruggeman Oct 20, 2026
8cec312
show auto compress when option is enabled
tijmenbruggeman Oct 20, 2026
9b52a85
PR fixes
tijmenbruggeman Oct 20, 2026
5cf9781
translation
tijmenbruggeman Oct 20, 2026
745e330
time_left to seconds_left
tijmenbruggeman Oct 20, 2026
c847cc1
fix: require a nonce to start the bulk run from the widget
tijmenbruggeman Oct 20, 2026
0a02b15
load widget async
tijmenbruggeman Oct 20, 2026
72014b6
show buttons conditionally
tijmenbruggeman Oct 20, 2026
77d56b1
remove unused state
tijmenbruggeman Oct 20, 2026
c211b55
cleanup
tijmenbruggeman Oct 20, 2026
718c377
hide notice when autostart
tijmenbruggeman Oct 20, 2026
f0695b7
hide trigger when autostart
tijmenbruggeman Oct 20, 2026
bb309d7
speed up tests
tijmenbruggeman Oct 20, 2026
d7d0894
Settings Page UI
tijmenbruggeman Oct 23, 2026
337bc19
refactor step rendering
tijmenbruggeman Oct 23, 2026
071c11b
convert arrow func to plain func
tijmenbruggeman Oct 23, 2026
b776b56
redirect after activation
tijmenbruggeman Oct 23, 2026
4cc6f5f
show 2 steps when connecting with an api key
tijmenbruggeman Oct 23, 2026
9b5d071
is_api_key_pending will show when key is actually valid
tijmenbruggeman Oct 23, 2026
adb9fbd
keep the three compression timing options
tijmenbruggeman Oct 23, 2026
69386ad
Move tinify link to account card
tijmenbruggeman Oct 26, 2026
8120dc1
Merge branch 'tiny-onboarding' into feat/bulk-page-redesign
tijmenbruggeman Oct 26, 2026
ffbf374
Merge branch 'feat/dashboard-widget' into feat/bulk-page-redesign
tijmenbruggeman Oct 26, 2026
82871e8
bulk optimization UI
tijmenbruggeman Oct 27, 2026
fe44417
Merge branch 'master' of github.com:wcreateweb/wordpress-plugin into …
tijmenbruggeman Nov 6, 2026
5da248d
divide by zero fix
tijmenbruggeman Nov 6, 2026
6d93798
simplify rendering
tijmenbruggeman Nov 6, 2026
828a430
fix translations
tijmenbruggeman Nov 6, 2026
c02d2c5
refactor
tijmenbruggeman Nov 7, 2026
66439cb
stop polling on 5 consecutive failures
tijmenbruggeman Nov 7, 2026
64bb2f0
remove unused strong and stats
tijmenbruggeman Nov 7, 2026
0e8e855
cleanup unused stats
tijmenbruggeman Nov 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions src/class-tiny-bulk-optimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ class Tiny_Bulk_Optimization {
const PAGING_SIZE = 25000;

public static function get_optimization_statistics( $settings, $result = null ) {
$stats = array();
$stats['uploaded-images'] = 0;
$stats['optimized-image-sizes'] = 0;
$stats['available-unoptimized-sizes'] = 0;
$stats['optimized-library-size'] = 0;
$stats['unoptimized-library-size'] = 0;
$stats['estimated_credit_use'] = 0;
$stats['available-for-optimization'] = array();
$stats = array();
$stats['uploaded-images'] = 0;
$stats['optimized-library-size'] = 0;
$stats['unoptimized-library-size'] = 0;
$stats['estimated_credit_use'] = 0;
$stats['available-for-optimization'] = array();

if ( is_null( $result ) ) {
$last_image_id = null;
Expand Down Expand Up @@ -104,6 +102,8 @@ private static function populate_optimization_statistics( $settings, $result, $s
$active_sizes = $settings->get_sizes();
$active_tinify_sizes = $settings->get_active_tinify_sizes();
$conversion_enabled = $settings->get_conversion_enabled();
$uploads = wp_upload_dir();
$uploads_url = $uploads['baseurl'];

$result_count = count( $result );
for ( $i = 0; $i < $result_count; $i++ ) {
Expand All @@ -125,11 +125,9 @@ private static function populate_optimization_statistics( $settings, $result, $s
$image_stats = $tiny_image->get_statistics( $active_sizes, $active_tinify_sizes );

++$stats['uploaded-images'];
$stats['estimated_credit_use'] += $image_stats['available_uncompressed_sizes'];
$stats['available-unoptimized-sizes'] += $image_stats['available_unoptimized_sizes'];
$stats['optimized-image-sizes'] += $image_stats['image_sizes_optimized'];
$stats['optimized-library-size'] += $image_stats['compressed_total_size'];
$stats['unoptimized-library-size'] += $image_stats['initial_total_size'];
$stats['estimated_credit_use'] += $image_stats['available_uncompressed_sizes'];
$stats['optimized-library-size'] += $image_stats['compressed_total_size'];
$stats['unoptimized-library-size'] += $image_stats['initial_total_size'];

if ( $conversion_enabled ) {
$stats['estimated_credit_use'] += $image_stats['available_unconverted_sizes'];
Expand All @@ -144,10 +142,44 @@ private static function populate_optimization_statistics( $settings, $result, $s
$stats['available-for-optimization'][] = array(
'ID' => $result[ $i ]['ID'],
'post_title' => $result[ $i ]['post_title'],
'file' => self::get_file_name( $wp_metadata ),
'sizes' => $image_stats['available_unoptimized_sizes'],
'bytes' => $image_stats['compressed_total_size'],
'thumbnail' => self::get_thumbnail_url( $wp_metadata, $uploads_url ),
);
}
}// End for().

return $stats;
}

/**
* The name of the file that was uploaded, also when WordPress scaled it down.
*/
private static function get_file_name( $wp_metadata ) {
if ( isset( $wp_metadata['original_image'] ) ) {
return wp_basename( $wp_metadata['original_image'] );
}
if ( isset( $wp_metadata['file'] ) ) {
return wp_basename( $wp_metadata['file'] );
}
return '';
}

/**
* The URL of the image's thumbnail, built from its metadata so the page
* does not need a query for each image. Falls back to the image itself.
*/
private static function get_thumbnail_url( $wp_metadata, $uploads_url ) {
if ( ! isset( $wp_metadata['file'] ) ) {
return '';
}
$file = $wp_metadata['file'];
if ( isset( $wp_metadata['sizes']['thumbnail']['file'] ) ) {
$directory = dirname( $file );
$file = ( '.' === $directory ? '' : $directory . '/' ) .
$wp_metadata['sizes']['thumbnail']['file'];
}
return $uploads_url . '/' . $file;
}
}
27 changes: 0 additions & 27 deletions src/class-tiny-compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ public static function create( $api_key, $after_compress_callback = null ) {
return new $class( $api_key, $after_compress_callback );
}

/* Based on pricing April 2016. */
public static function estimate_cost( $compressions, $compressions_used ) {
return round(
self::compression_cost( $compressions + $compressions_used ) -
self::compression_cost( $compressions_used ),
2
);
}

protected function __construct( $after_compress_callback ) {
$this->after_compress_callback = $after_compress_callback;
}
Expand Down Expand Up @@ -202,22 +193,4 @@ private static function needs_resize( $file, $resize_options ) {

return $should_resize_width || $should_resize_height;
}

private static function compression_cost( $total ) {
$cost = 0;

if ( $total > 10000 ) {
$compressions = $total - 10000;
$cost += $compressions * 0.002;
$total -= $compressions;
}

if ( $total > Tiny_Config::MONTHLY_FREE_COMPRESSIONS ) {
$compressions = $total - Tiny_Config::MONTHLY_FREE_COMPRESSIONS;
$cost += $compressions * 0.009;
$total -= $compressions;
}

return $cost;
}
}
Loading
Loading