-
Notifications
You must be signed in to change notification settings - Fork 143
Add checkbox to Settings > Media to control whether to generate JPEG in addition to WebP #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
felixarntz
merged 34 commits into
trunk
from
enhancement/525-checkbox-multi-mime-setting
Oct 7, 2022
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1780c65
new setting added for generating webp and jpeg in Settings > Media > …
mehulkaklotar 952a40a
new setting used when true for generating webp and jpeg
mehulkaklotar 7b3e221
Merge branch 'trunk' into enhancement/525-checkbox-multi-mime-setting
mehulkaklotar cd79323
Merge branch 'trunk' into enhancement/525-checkbox-multi-mime-setting
mehulkaklotar 6094407
Merge branch 'trunk' into enhancement/525-checkbox-multi-mime-setting
mukeshpanchal27 cd96030
Set default value for option
mukeshpanchal27 1f3d1cc
Update markup and remove the return in function
mukeshpanchal27 49cd8f6
Set default value and code from parent PR
mukeshpanchal27 a328153
Unset default value for option
mukeshpanchal27 b6a6531
Unset default value for option
mukeshpanchal27 4570b8d
Add webp_uploads_check_multi_mime_support()
mukeshpanchal27 9d8a992
Update image-edit.php
mukeshpanchal27 2c73233
Unit test for new setting
mukeshpanchal27 89cc855
Merge branch 'trunk' into enhancement/525-checkbox-multi-mime-setting
mukeshpanchal27 009ef92
settings.php file added for the new setting perflab_generate_webp_and…
mehulkaklotar 112e259
settings.php file added for the new setting perflab_generate_webp_and…
mehulkaklotar ce3a8b2
new setting perflab_generate_webp_and_jpeg used and filters reverted …
mehulkaklotar 35b303a
new setting perflab_generate_webp_and_jpeg tests added and moved from…
mehulkaklotar 9a71553
new setting perflab_generate_webp_and_jpeg deleted when uninstalled
mehulkaklotar 23b8102
Update document
mukeshpanchal27 1cd10bc
Update document
mukeshpanchal27 f892ddb
Update modules/images/webp-uploads/settings.php
mukeshpanchal27 f7c3a2a
Update document
mukeshpanchal27 02aaa7d
Update document
mukeshpanchal27 0c3a321
Add `$args` in register_setting
mukeshpanchal27 c7b7575
Fix PHPCS and remove doc
mukeshpanchal27 ab65615
Update structure and add css
mukeshpanchal27 691f5a1
Update style
mukeshpanchal27 8a00c25
Revert some changes
mukeshpanchal27 522dea3
Update tests/modules/images/webp-uploads/helper-tests.php
mehulkaklotar d2a3a13
Update tests/modules/images/webp-uploads/helper-tests.php
mehulkaklotar c80ca0f
Update tests/modules/images/webp-uploads/load-tests.php
mehulkaklotar 25858c9
Update add_action
mukeshpanchal27 90cac1f
Remove global and condition
mukeshpanchal27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
| /** | ||
| * Settings for the WebP Uploads module. | ||
| * | ||
| * @package performance-lab | ||
| * @since n.e.x.t | ||
| */ | ||
|
|
||
| /** | ||
| * Registers setting for generating both JPEG and WebP versions for image uploads. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| function webp_uploads_register_media_settings_field() { | ||
| register_setting( | ||
| 'media', | ||
| 'perflab_generate_webp_and_jpeg', | ||
| array( | ||
| 'type' => 'boolean', | ||
| 'default' => false, | ||
| 'show_in_rest' => false, | ||
| ) | ||
| ); | ||
| } | ||
| add_action( 'init', 'webp_uploads_register_media_settings_field' ); | ||
|
|
||
| /** | ||
| * Adds media settings field for the 'perflab_generate_webp_and_jpeg' setting. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| function webp_uploads_add_media_settings_field() { | ||
| // Add settings field. | ||
| add_settings_field( | ||
| 'perflab_generate_webp_and_jpeg', | ||
| __( 'Generate WebP and JPEG', 'performance-lab' ), | ||
| 'webp_uploads_generate_webp_jpeg_setting_callback', | ||
| 'media', | ||
| 'uploads', | ||
| array( 'class' => 'perflab-generate-webp-and-jpeg' ) | ||
| ); | ||
| } | ||
| add_action( 'admin_init', 'webp_uploads_add_media_settings_field' ); | ||
|
|
||
| /** | ||
| * Renders the settings field for the 'perflab_generate_webp_and_jpeg' setting. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| function webp_uploads_generate_webp_jpeg_setting_callback() { | ||
| ?> | ||
| </td> | ||
| <td class="td-full"> | ||
| <label for="perflab_generate_webp_and_jpeg"> | ||
| <input name="perflab_generate_webp_and_jpeg" type="checkbox" id="perflab_generate_webp_and_jpeg" aria-describedby="perflab_generate_webp_and_jpeg_description" value="1"<?php checked( '1', get_option( 'perflab_generate_webp_and_jpeg' ) ); ?> /> | ||
| <?php esc_html_e( 'Generate JPEG files in addition to WebP', 'performance-lab' ); ?> | ||
| </label> | ||
| <p class="description" id="perflab_generate_webp_and_jpeg_description"><?php esc_html_e( 'Enabling JPEG in addition to WebP can improve compatibility, but will effectively double the filesystem storage use of your images.', 'performance-lab' ); ?></p> | ||
| <?php | ||
| } | ||
|
|
||
| /** | ||
| * Adds custom style for media settings. | ||
| * | ||
| * @since n.e.x.t | ||
| */ | ||
| function webp_uploads_media_setting_style() { | ||
| ?> | ||
| <style> | ||
| .form-table .perflab-generate-webp-and-jpeg th, | ||
| .form-table .perflab-generate-webp-and-jpeg td:not(.td-full) { | ||
| display: none; | ||
| } | ||
| </style> | ||
| <?php | ||
| } | ||
| add_action( 'admin_head-options-media.php', 'webp_uploads_media_setting_style' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.