Skip to content

Commit

Permalink
Global option to disable processing in the page head section
Browse files Browse the repository at this point in the history
  • Loading branch information
av3nger committed Oct 16, 2024
1 parent d4653c6 commit d27e327
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Added:
* Bulk offload actions to the media library list view
* Global option to disable processing in the page head section

Changed:
* Improved UI/UX
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ If something is still not working for you, please let me know by creating a supp

Added:
* Bulk offload actions to the media library list view
* Global option to disable processing in the page head section

Changed:
* Improved UI/UX
Expand Down
1 change: 1 addition & 0 deletions app/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Settings {
'logging' => false,
'rss-feeds' => false,
'no-offload-user' => false, // Do not offload images for logged-in users.
'process-head' => false,
);

/**
Expand Down
2 changes: 1 addition & 1 deletion app/integrations/class-aio-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function integration_options( array $options, string $slug ): array {
array(
'name' => 'image_object',
'label' => esc_html__( 'Replace ImageObject', 'cf-images' ),
'description' => esc_html__( 'Use Cloudflare image for the ImageObject in the application/ld+json schema.', 'cf-images' ),
'description' => esc_html__( 'Use Cloudflare image for the ImageObject in the application/ld+json schema. Requires the `Process images in head` option to be enabled in Settings - Misc Options.', 'cf-images' ),
'value' => apply_filters( 'cf_images_integration_option_value', false, 'image_object' ),
),
);
Expand Down
4 changes: 2 additions & 2 deletions app/integrations/class-rank-math.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ public function integration_options( array $options, string $slug ): array {
array(
'name' => 'image_object',
'label' => esc_html__( 'Replace ImageObject', 'cf-images' ),
'description' => esc_html__( 'Use Cloudflare image for the ImageObject in the application/ld+json schema.', 'cf-images' ),
'description' => esc_html__( 'Use Cloudflare image for the ImageObject in the application/ld+json schema. Requires the `Process images in head` option to be enabled in Settings - Misc Options.', 'cf-images' ),
'value' => apply_filters( 'cf_images_integration_option_value', false, 'image_object' ),
),
array(
'name' => 'head',
'label' => esc_html__( 'Replace images in head', 'cf-images' ),
'description' => esc_html__( 'Use Cloudflare images in the head page element.', 'cf-images' ),
'description' => esc_html__( 'Use Cloudflare images in the head page element. Requires the `Process images in head` option to be enabled in Settings - Misc Options.', 'cf-images' ),
'value' => apply_filters( 'cf_images_integration_option_value', false, 'head' ),
),
);
Expand Down
4 changes: 4 additions & 0 deletions app/modules/class-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ protected function can_run( int $attachment_id = 0 ): bool {
return false;
}

if ( doing_action( 'wp_head' ) && ! $this->is_module_enabled( false, 'process-head' ) ) {
return false;
}

if ( did_action( 'wp' ) && ! $this->is_module_enabled( false, 'rss-feeds' ) && is_feed() ) {
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions assets/_src/modules/cloudflare/misc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ const MiscOptions = () => {
'cf-images'
),
},
'process-head': {
label: __('Process images in head', 'cf-images'),
description: __(
'Replace images inside the head element.',
'cf-images'
),
},
};

if (isNetworkAdmin) {
Expand Down

0 comments on commit d27e327

Please sign in to comment.