Skip to content

Commit

Permalink
Merge pull request #14 from westonruter/add/error-template-messages
Browse files Browse the repository at this point in the history
Update displaying of error details and error message on offline/500 templates
  • Loading branch information
westonruter authored Nov 6, 2018
2 parents 9fc6d9e + bcc1c5c commit a60d935
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
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

0 comments on commit a60d935

Please sign in to comment.