@@ -72,6 +72,7 @@ private static function get_default_settings( $container = null ) {
72
72
* @param \NewfoldLabs\WP\Container\Container $container Dependency injection container.
73
73
*/
74
74
public function __construct ( $ container ) {
75
+ $ this ->container = $ container ;
75
76
$ this ->default_settings = self ::get_default_settings ( $ container );
76
77
$ this ->register_settings ( $ container );
77
78
$ this ->initialize_settings ();
@@ -407,11 +408,12 @@ public static function get_monthly_usage() {
407
408
/**
408
409
* Retrieves the image optimization settings.
409
410
*
410
- * @param bool $call_worker Whether to fetch the latest monthly usage from the worker. Default is true.
411
+ * @param \NewfoldLabs\WP\Container\Container|null $container Dependency injection container (optional).
412
+ * @param bool $call_worker Whether to fetch the latest monthly usage from the worker. Default is true.
411
413
*
412
414
* @return array The current image optimization settings, including monthly usage and banned status.
413
415
*/
414
- public static function get ( $ call_worker = true ) {
416
+ public static function get ( $ container , $ call_worker = true ) {
415
417
$ settings = get_option ( self ::SETTING_KEY , array () );
416
418
417
419
if ( ! is_array ( $ settings ) ) {
@@ -423,7 +425,7 @@ public static function get( $call_worker = true ) {
423
425
}
424
426
425
427
if ( $ call_worker && ( empty ( $ settings ['monthly_usage ' ] ) || ! is_array ( $ settings ['monthly_usage ' ] ) ) ) {
426
- $ usage_data = ( new ImageService () )->get_monthly_usage_limit ( true );
428
+ $ usage_data = ( new ImageService ( $ container ) )->get_monthly_usage_limit ( true );
427
429
if ( ! is_wp_error ( $ usage_data ) ) {
428
430
$ settings ['monthly_usage ' ] = $ usage_data ;
429
431
update_option ( self ::SETTING_KEY , $ settings );
0 commit comments