Skip to content

Commit

Permalink
Merged and fixed code conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Feb 17, 2025
2 parents e78c0e0 + f814215 commit bf19eae
Show file tree
Hide file tree
Showing 90 changed files with 5,631 additions and 3,607 deletions.
2 changes: 1 addition & 1 deletion assets/js/lazyload-scripts.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dynamic-lists-delayjs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dynamic-lists.json

Large diffs are not rendered by default.

34 changes: 19 additions & 15 deletions inc/Addon/Cloudflare/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ServiceProvider extends AbstractServiceProvider {
* @var array
*/
protected $provides = [
'cloudflare_api_key_factory',
'cloudflare_client',
'cloudflare_endpoints',
'cloudflare',
Expand All @@ -42,26 +43,29 @@ public function provides( string $id ): bool {
* Registers items with the container
*/
public function register(): void {
$options = $this->getContainer()->get( 'options' );

$this->getContainer()->add( 'cloudflare_auth_factory', APIKeyFactory::class )->addArgument( $options );
$this->getContainer()->add( 'cloudflare_api_key_factory', APIKeyFactory::class )->addArgument( 'options' );

$this->getContainer()->add( 'cloudflare_client', Client::class )
->addArgument( $this->getContainer()->get( 'cloudflare_auth_factory' )->create() );
->addArgument( $this->getContainer()->get( 'cloudflare_api_key_factory' )->create() );
$this->getContainer()->add( 'cloudflare_endpoints', Endpoints::class )
->addArgument( $this->getContainer()->get( 'cloudflare_client' ) );
->addArgument( 'cloudflare_client' );

$this->getContainer()->add( 'cloudflare', Cloudflare::class )
->addArgument( $options )
->addArgument( $this->getContainer()->get( 'cloudflare_endpoints' ) );
->addArguments(
[
'options',
'cloudflare_endpoints',
]
);
$this->getContainer()->addShared( 'cloudflare_subscriber', CloudflareSubscriber::class )
->addArgument( $this->getContainer()->get( 'cloudflare' ) )
->addArgument( $options )
->addArgument( $this->getContainer()->get( 'options_api' ) )
->addArgument( $this->getContainer()->get( 'cloudflare_auth_factory' ) );
$this->getContainer()->addShared(
'cloudflare_admin_subscriber',
CloudflareAdminSubscriber::class
);
->addArguments(
[
'cloudflare',
'options',
'options_api',
'cloudflare_api_key_factory',
]
);
$this->getContainer()->addShared( 'cloudflare_admin_subscriber', CloudflareAdminSubscriber::class );
}
}
27 changes: 17 additions & 10 deletions inc/Addon/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Addon;

use WP_Rocket\Addon\Sucuri\Subscriber as SucuriSubscriber;
Expand Down Expand Up @@ -36,20 +38,25 @@ public function provides( string $id ): bool {
* Registers items with the container
*/
public function register(): void {
$options = $this->getContainer()->get( 'options' );

// Sucuri Addon.
$this->getContainer()->addShared( 'sucuri_subscriber', SucuriSubscriber::class )
->addArgument( $options );
->addArgument( 'options' );

$this->getContainer()->addShared( 'webp_admin_subscriber', WebPAdminSubscriber::class )
->addArgument( $options )
->addArgument( $this->getContainer()->get( 'cdn_subscriber' ) )
->addArgument( $this->getContainer()->get( 'beacon' ) );
->addArguments(
[
'options',
'cdn_subscriber',
'beacon',
]
);

$this->getContainer()->addShared( 'webp_subscriber', WebPSubscriber::class )
->addArgument( $options )
->addArgument( $this->getContainer()->get( 'options_api' ) )
->addArgument( $this->getContainer()->get( 'cdn_subscriber' ) );
->addArguments(
[
'options',
'options_api',
'cdn_subscriber',
]
);
}
}
10 changes: 8 additions & 2 deletions inc/Addon/Varnish/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Addon\Varnish;

use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
Expand Down Expand Up @@ -36,7 +38,11 @@ public function provides( string $id ): bool {
public function register(): void {
$this->getContainer()->add( 'varnish', Varnish::class );
$this->getContainer()->addShared( 'varnish_subscriber', Subscriber::class )
->addArgument( $this->getContainer()->get( 'varnish' ) )
->addArgument( $this->getContainer()->get( 'options' ) );
->addArguments(
[
'varnish',
'options',
]
);
}
}
3 changes: 2 additions & 1 deletion inc/Engine/Activation/Activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WP_Rocket\Engine\Activation;

use WP_Rocket\Admin\Options;
use WP_Rocket\Dependencies\League\Container\Argument\Literal\StringArgument;
use WP_Rocket\Dependencies\League\Container\Container;
use WP_Rocket\Engine\Common\PerformanceHints\Activation\ServiceProvider as PerformanceHintsActivationServiceProvider;
use WP_Rocket\Engine\License\ServiceProvider as LicenseServiceProvider;
Expand Down Expand Up @@ -44,7 +45,7 @@ public static function activate_plugin() {
$container = new Container();
$event_manager = new Event_Manager();

$container->add( 'template_path', WP_ROCKET_PATH . 'views' );
$container->add( 'template_path', new StringArgument( rocket_get_constant( 'WP_ROCKET_PATH', '' ) . 'views' ) );
$options_api = new Options( 'wp_rocket_' );
$container->add( 'options_api', $options_api );
$container->addServiceProvider( new OptionsServiceProvider() );
Expand Down
11 changes: 9 additions & 2 deletions inc/Engine/Activation/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Activation;

use WP_Rocket\Dependencies\League\Container\Argument\Literal\StringArgument;
use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
use WP_Rocket\Dependencies\League\Container\ServiceProvider\BootableServiceProviderInterface;
use WP_Rocket\Engine\Cache\AdvancedCache;
Expand Down Expand Up @@ -53,8 +56,12 @@ public function register(): void {
$filesystem = rocket_direct_filesystem();

$this->getContainer()->add( 'advanced_cache', AdvancedCache::class )
->addArgument( $this->getContainer()->get( 'template_path' ) . '/cache/' )
->addArgument( $filesystem );
->addArguments(
[
new StringArgument( $this->getContainer()->get( 'template_path' ) . '/cache/' ),
$filesystem,
]
);
$this->getContainer()->add( 'capabilities_manager', Manager::class );
$this->getContainer()->add( 'wp_cache', WPCache::class )
->addArgument( $filesystem );
Expand Down
1 change: 1 addition & 0 deletions inc/Engine/Admin/API/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Admin\API;

Expand Down
13 changes: 10 additions & 3 deletions inc/Engine/Admin/Beacon/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Admin\Beacon;

use WP_Rocket\Dependencies\League\Container\Argument\Literal\StringArgument;
use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;

/**
Expand Down Expand Up @@ -34,8 +37,12 @@ public function provides( string $id ): bool {
*/
public function register(): void {
$this->getContainer()->addShared( 'beacon', Beacon::class )
->addArgument( $this->getContainer()->get( 'options' ) )
->addArgument( $this->getContainer()->get( 'template_path' ) . '/settings' )
->addArgument( $this->getContainer()->get( 'support_data' ) );
->addArguments(
[
'options',
new StringArgument( $this->getContainer()->get( 'template_path' ) . '/settings' ),
'support_data',
]
);
}
}
13 changes: 10 additions & 3 deletions inc/Engine/Admin/Database/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Admin\Database;

use WP_Rocket\Admin\Options_Data;
use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;

/**
Expand Down Expand Up @@ -37,9 +40,13 @@ public function provides( string $id ): bool {
public function register(): void {
$this->getContainer()->add( 'db_optimization_process', OptimizationProcess::class );
$this->getContainer()->add( 'db_optimization', Optimization::class )
->addArgument( $this->getContainer()->get( 'db_optimization_process' ) );
->addArgument( 'db_optimization_process' );
$this->getContainer()->addShared( 'db_optimization_subscriber', Subscriber::class )
->addArgument( $this->getContainer()->get( 'db_optimization' ) )
->addArgument( $this->getContainer()->get( 'options' ) );
->addArguments(
[
'db_optimization',
'options',
]
);
}
}
12 changes: 9 additions & 3 deletions inc/Engine/Admin/DomainChange/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Admin\DomainChange;

use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;

use WP_Rocket\Engine\Common\Ajax\AjaxHandler;

class ServiceProvider extends AbstractServiceProvider {
Expand Down Expand Up @@ -34,8 +36,12 @@ public function provides( string $id ): bool {
*/
public function register(): void {
$this->getContainer()->add( 'ajax_handler', AjaxHandler::class );
$this->getContainer()->add( 'domain_change_subscriber', Subscriber::class )
->addArgument( $this->getContainer()->get( 'ajax_handler' ) )
->addArgument( $this->getContainer()->get( 'beacon' ) );
$this->getContainer()->addShared( 'domain_change_subscriber', Subscriber::class )
->addArguments(
[
'ajax_handler',
'beacon',
]
);
}
}
25 changes: 17 additions & 8 deletions inc/Engine/Admin/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Admin;

use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
use WP_Rocket\Dependencies\League\Container\Argument\Literal\StringArgument;
use WP_Rocket\Engine\Admin\Deactivation\{DeactivationIntent, Subscriber};
use WP_Rocket\Engine\Admin\Metaboxes\PostEditOptionsSubscriber;
use WP_Rocket\ThirdParty\Plugins\Optimization\Hummingbird;
Expand Down Expand Up @@ -40,19 +43,25 @@ public function provides( string $id ): bool {
* @return void
*/
public function register(): void {
$options = $this->getContainer()->get( 'options' );

$this->getContainer()->add( 'deactivation_intent', DeactivationIntent::class )
->addArgument( $this->getContainer()->get( 'template_path' ) . '/deactivation-intent' )
->addArgument( $this->getContainer()->get( 'options_api' ) )
->addArgument( $options );
->addArguments(
[
new StringArgument( $this->getContainer()->get( 'template_path' ) . '/deactivation-intent' ),
'options_api',
'options',
]
);
$this->getContainer()->addShared( 'deactivation_intent_subscriber', Subscriber::class )
->addArgument( $this->getContainer()->get( 'deactivation_intent' ) );
$this->getContainer()->addShared( 'hummingbird_subscriber', Hummingbird::class )
->addArgument( $options );
->addArgument( 'options' );
$this->getContainer()->addShared( 'actionscheduler_admin_subscriber', ActionSchedulerSubscriber::class );
$this->getContainer()->addShared( 'post_edit_options_subscriber', PostEditOptionsSubscriber::class )
->addArgument( $options )
->addArgument( $this->getContainer()->get( 'template_path' ) . '/metaboxes' );
->addArguments(
[
'options',
new StringArgument( $this->getContainer()->get( 'template_path' ) . '/metaboxes' ),
]
);
}
}
39 changes: 33 additions & 6 deletions inc/Engine/Admin/Settings/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ private function media_section() {
$exclude_lazyload = $this->beacon->get_suggest( 'exclude_lazyload' );
$dimensions = $this->beacon->get_suggest( 'image_dimensions' );
$fonts = $this->beacon->get_suggest( 'host_fonts_locally' );
$fonts_preload = $this->beacon->get_suggest( 'fonts_preload' );

$this->settings->add_page_section(
'media',
Expand Down Expand Up @@ -936,12 +937,10 @@ private function media_section() {
'page' => 'media',
],
'font_optimization_section' => [
'title' => __( 'Fonts', 'rocket' ),
'type' => 'fields_container',
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
'description' => sprintf( __( 'Download and serve fonts directly from your server. Reduces connections to external servers and minimizes font shifts. %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $fonts['url'] ) . '" data-beacon-article="' . esc_attr( $fonts['id'] ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ),
'help' => $fonts,
'page' => 'media',
'title' => __( 'Fonts', 'rocket' ),
'type' => 'fields_container',
'help' => $fonts,
'page' => 'media',
],
]
);
Expand Down Expand Up @@ -1041,9 +1040,21 @@ private function media_section() {
'default' => 0,
'sanitize_callback' => 'sanitize_checkbox',
],
'auto_preload_fonts' => [
'type' => 'checkbox',
'label' => __( 'Preload fonts', 'rocket' ),
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
'description' => sprintf( __( 'Preload above-the-fold fonts to enhance layout stability and optimize text-based LCP elements. %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $fonts_preload['url'] ) . '" data-beacon-article="' . esc_attr( $fonts_preload['id'] ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ),
'section' => 'font_optimization_section',
'page' => 'media',
'default' => 0,
'sanitize_callback' => 'sanitize_checkbox',
],
'host_fonts_locally' => [
'type' => 'checkbox',
'label' => __( 'Self-host Google Fonts', 'rocket' ),
// translators: %1$s = opening <a> tag, %2$s = closing </a> tag.
'description' => sprintf( __( 'Download and serve fonts directly from your server. Reduces connections to external servers and minimizes font shifts. %1$sMore info%2$s', 'rocket' ), '<a href="' . esc_url( $fonts['url'] ) . '" data-beacon-article="' . esc_attr( $fonts['id'] ) . '" target="_blank" rel="noopener noreferrer">', '</a>' ),
'section' => 'font_optimization_section',
'page' => 'media',
'default' => 0,
Expand Down Expand Up @@ -2294,4 +2305,20 @@ public function display_update_notice() {
]
);
}

/**
* Enables the auto preload fonts option if the old preload fonts option is not empty.
*
* This function checks the value of the `rocket_preload_fonts` option.
* If it contains a non-empty value, it updates the `auto_preload_fonts` option to `true`.
* This is useful for ensuring that automatic font preloading is enabled based on legacy settings.
*
* @return void
*/
public function maybe_enable_auto_preload_fonts(): void {
$old_preload_fonts = $this->options->get( 'rocket_preload_fonts', [] );
if ( ! empty( $old_preload_fonts ) ) {
$this->options->set( 'auto_preload_fonts', true );
}
}
}
Loading

0 comments on commit bf19eae

Please sign in to comment.