Skip to content
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

Update displaying of error details and error message on offline/500 templates #14

Merged
merged 1 commit into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions 500.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,12 @@
</header><!-- .page-header -->
<div class="page-content">
<p><?php esc_html_e( 'Something prevented the page from being rendered. Please try again.', 'twentyseventeen-westonson' ); ?></p>
<?php if ( ! ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) ) : ?>
<details id="error-details" hidden>
<summary><?php esc_html_e( 'More details', 'twentyseventeen-westonson' ); ?></summary>
<iframe srcdoc=""></iframe>
<script>
function renderErrorDetails( data ) {
if ( data.bodyText.trim().length ) {
const details = document.getElementById( 'error-details' );
details.querySelector( 'iframe' ).srcdoc = data.bodyText;
details.hidden = false;
}
}
</script>
<?php wp_print_service_worker_error_details_script( 'renderErrorDetails' ); ?>
</details>
<?php endif; ?>
</div><!-- .page-content -->

<?php
if ( function_exists( 'wp_service_worker_error_details_template' ) ) {
wp_service_worker_error_details_template();
}
?>
</section><!-- .error-500 -->
</main><!-- #main -->
</div><!-- #primary -->
Expand Down
6 changes: 6 additions & 0 deletions offline.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

<div class="page-content">
<p><?php esc_html_e( 'Please check your internet connection, and try again.', 'twentyseventeen-westonson' ); ?></p>

<?php
if ( function_exists( 'wp_service_worker_error_message_placeholder' ) ) {
wp_service_worker_error_message_placeholder();
}
?>
</div><!-- .page-content -->
</section><!-- .error-offline -->
</main><!-- #main -->
Expand Down