-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add web app manifest display setting in Reading settings page #985
Open
thelovekesh
wants to merge
4
commits into
develop
Choose a base branch
from
add/manifest-display-field
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a090aa6
Add settings field in reading page for web app manifest diplay member
thelovekesh 1c74fa1
Update main plugin file to include web app manifest display setting
thelovekesh 34861aa
Update get_manifest() to read display setting from `web_app_manifest_…
thelovekesh 39805fe
Add tests for web app manifest display setting
thelovekesh 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 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 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 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,71 @@ | ||
<?php | ||
/** | ||
* Web App manifest display field for the reading settings administration panel. | ||
* | ||
* As part of a core merge, the code in this file would go inside wp-admin/options-reading.php | ||
* | ||
* @package PWA | ||
*/ | ||
|
||
namespace PWA_WP; | ||
|
||
/** | ||
* Register web app manifest display setting. | ||
*/ | ||
function register_web_app_manifest_display_setting() { | ||
register_setting( | ||
'reading', | ||
'web_app_manifest_display', | ||
array( | ||
'type' => 'string', | ||
'sanitize_callback' => 'sanitize_text_field', | ||
) | ||
); | ||
} | ||
add_action( 'init', __NAMESPACE__ . '\register_web_app_manifest_display_setting' ); | ||
|
||
/** | ||
* Register web app manifest display setting field. | ||
*/ | ||
function add_web_app_manifest_display_setting_field() { | ||
add_settings_field( | ||
'web_app_manifest_display', | ||
__( 'Display', 'pwa' ), | ||
__NAMESPACE__ . '\render_web_app_manifest_display_setting_field', | ||
'reading' | ||
); | ||
} | ||
add_action( 'admin_init', __NAMESPACE__ . '\add_web_app_manifest_display_setting_field' ); | ||
|
||
/** | ||
* Render web app manifest display setting field. | ||
*/ | ||
function render_web_app_manifest_display_setting_field() { | ||
// See: <https://developer.mozilla.org/en-US/docs/Web/Manifest/display#values>. | ||
$allowed_values = array( 'fullscreen', 'standalone', 'minimal-ui', 'browser' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While probably out of scope of this UI, there is also a |
||
|
||
?> | ||
<fieldset> | ||
<legend class="screen-reader-text"><span><?php esc_html_e( 'Web App manifest display', 'pwa' ); ?> </span></legend> | ||
|
||
<label for="web_app_manifest_display"> | ||
<?php esc_html_e( 'Web App manifest display', 'pwa' ); ?> | ||
</label> | ||
|
||
<select name="web_app_manifest_display" id="web_app_manifest_display"> | ||
<?php foreach ( $allowed_values as $value ) : ?> | ||
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, get_option( 'web_app_manifest_display', 'minimal-ui' ) ); ?>><?php echo esc_html( $value ); ?></option> | ||
<?php endforeach; ?> | ||
</select> | ||
|
||
<p class="description"> | ||
<?php | ||
echo wp_kses( | ||
__( 'This controls how the web app is displayed when launched from the home screen. See <a href="https://developer.mozilla.org/en-US/docs/Web/Manifest/display" rel="noreferrer noopener" target="_blank">MDN documentation</a> for more information.', 'pwa' ), | ||
array( 'a' => array_fill_keys( array( 'href', 'rel', 'target' ), true ) ) | ||
); | ||
?> | ||
</p> | ||
</fieldset> | ||
<?php | ||
} |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure this doesn't end up adding
web_app_manifest_display
as an autoloaded option, since it is only used in the web app manifest request.I think this may mean adding a call to
add_option
before this call.Although there may be a better place for it.
I realize this should also be done for the
short_name
field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And for the
offline_browsing
option.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For existing installs that have
offline_browsing
andshort_name
options that are autoloaded, they should switch to non-autoloaded.