Skip to content

Commit

Permalink
Merge pull request #1168 from INN/WE-103-better-404-page
Browse files Browse the repository at this point in the history
404 page improvements
  • Loading branch information
aschweigert committed Mar 17, 2016
2 parents 11e5537 + f7b811f commit 30957f8
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
29 changes: 29 additions & 0 deletions 404.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@

<div id="content" class="span8" role="main">
<?php get_template_part( 'partials/content', 'not-found' ); ?>
<p><?php
echo wp_kses(of_get_option('404_message'), array(
'a' => array(),
'b' => array(),
'br' => array(),
'i' => array(),
'em' => array(),
'strong' => array(),
));
?></p>

<?php
/*
* Display the Recent Posts widget
*
* @since 0.5.5
* @link http://jira.inn.org/browse/WE-103
* @link https://codex.wordpress.org/Function_Reference/the_widget
*/
if ( class_exists( 'largo_recent_posts_widget' ) ) {
the_widget(
'largo_recent_posts_widget',
array (
),
array(
)
);
}
?>
</div><!--#content -->

<?php get_sidebar(); ?>
Expand Down
6 changes: 6 additions & 0 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ function optionsframework_options() {
'std' => '0',
'type' => 'checkbox');

$options[] = array(
'desc' => __('<strong>404 page text.</strong> This will be displayed on the 404 page, which is shown when people try to navigate to a page on your site that does not exist. Allowed HTML tags are <code>a</code>, <code>b</code>, <code>br</code>, <code>em</code>, <code>i</code> and <code>strong</code>.', 'largo'),
'id' => '404_message',
'std' => '',
'type' => 'textarea');

$options[] = array(
'name' => __('Byline Options', 'largo'),
'type' => 'info');
Expand Down
17 changes: 15 additions & 2 deletions partials/content-not-found.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<?php
$apologies = __('Apologies, but no results were found. Perhaps searching will help.', 'largo');

if ( is_404() ) {
$apologies = sprintf(
__("Apologies, but <code>%s</code> was not found. Perhaps searching will help.", 'largo'),
wp_kses($_SERVER['REQUEST_URI'], array()) // The url, sanitized
);
} else if ( is_search() ) {
$apologies = __("Apologies, but no results were found. Perhaps searching for something else will help.", 'largo');
}

?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e('Nothing Found', 'largo'); ?></h1>
</header><!-- .entry-header -->

<div class="entry-content">
<p><?php _e('Apologies, but no results were found. Perhaps searching will help.', 'largo'); ?></p>
<p><?php echo $apologies; ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
</article><!-- #post-0 -->
2 changes: 1 addition & 1 deletion searchform.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
?>
<form class="form-search" role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div>
<input type="text" placeholder="<?php _e('Search', 'largo'); ?>" class="searchbox search-query" value="" name="s" />
<input type="text" placeholder="<?php _e('Search', 'largo'); ?>" class="searchbox search-query" value="<?php the_search_query(); ?>" name="s" />
<input type="submit" value="<?php _e('Go', 'largo'); ?>" name="search submit" class="search-submit btn">
</div>
</form>

0 comments on commit 30957f8

Please sign in to comment.