add sage theme
This commit is contained in:
39
web/app/themes/badegg/app/View/Composers/App.php
Normal file
39
web/app/themes/badegg/app/View/Composers/App.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Composers;
|
||||
|
||||
use Roots\Acorn\View\Composer;
|
||||
|
||||
class App extends Composer
|
||||
{
|
||||
/**
|
||||
* List of views served by this composer.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $views = [
|
||||
'*',
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be passed to view before rendering.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function with()
|
||||
{
|
||||
return [
|
||||
'siteName' => $this->siteName(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the site name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function siteName()
|
||||
{
|
||||
return get_bloginfo('name', 'display');
|
||||
}
|
||||
}
|
||||
119
web/app/themes/badegg/app/View/Composers/Comments.php
Normal file
119
web/app/themes/badegg/app/View/Composers/Comments.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Composers;
|
||||
|
||||
use Roots\Acorn\View\Composer;
|
||||
|
||||
class Comments extends Composer
|
||||
{
|
||||
/**
|
||||
* List of views served by this composer.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $views = [
|
||||
'partials.comments',
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be passed to view before rendering.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function with()
|
||||
{
|
||||
return [
|
||||
'title' => $this->title(),
|
||||
'responses' => $this->responses(),
|
||||
'previous' => $this->previous(),
|
||||
'next' => $this->next(),
|
||||
'paginated' => $this->paginated(),
|
||||
'closed' => $this->closed(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The comment title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return sprintf(
|
||||
/* translators: %1$s is replaced with the number of comments and %2$s with the post title */
|
||||
_nx('%1$s response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'),
|
||||
get_comments_number() === 1 ? _x('One', 'comments title', 'sage') : number_format_i18n(get_comments_number()),
|
||||
get_the_title()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the comments.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function responses()
|
||||
{
|
||||
if (! have_comments()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return wp_list_comments([
|
||||
'style' => 'ol',
|
||||
'short_ping' => true,
|
||||
'echo' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The previous comments link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function previous()
|
||||
{
|
||||
if (! get_previous_comments_link()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return get_previous_comments_link(
|
||||
__('← Older comments', 'sage')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The next comments link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
if (! get_next_comments_link()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return get_next_comments_link(
|
||||
__('Newer comments →', 'sage')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the comments are paginated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function paginated()
|
||||
{
|
||||
return get_comment_pages_count() > 1 && get_option('page_comments');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the comments are closed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function closed()
|
||||
{
|
||||
return ! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments');
|
||||
}
|
||||
}
|
||||
84
web/app/themes/badegg/app/View/Composers/Post.php
Normal file
84
web/app/themes/badegg/app/View/Composers/Post.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Composers;
|
||||
|
||||
use Roots\Acorn\View\Composer;
|
||||
|
||||
class Post extends Composer
|
||||
{
|
||||
/**
|
||||
* List of views served by this composer.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $views = [
|
||||
'partials.page-header',
|
||||
'partials.content',
|
||||
'partials.content-*',
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be passed to view before rendering, but after merging.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function override()
|
||||
{
|
||||
return [
|
||||
'title' => $this->title(),
|
||||
'pagination' => $this->pagination(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the post title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
if ($this->view->name() !== 'partials.page-header') {
|
||||
return get_the_title();
|
||||
}
|
||||
|
||||
if (is_home()) {
|
||||
if ($home = get_option('page_for_posts', true)) {
|
||||
return get_the_title($home);
|
||||
}
|
||||
|
||||
return __('Latest Posts', 'sage');
|
||||
}
|
||||
|
||||
if (is_archive()) {
|
||||
return get_the_archive_title();
|
||||
}
|
||||
|
||||
if (is_search()) {
|
||||
return sprintf(
|
||||
/* translators: %s is replaced with the search query */
|
||||
__('Search Results for %s', 'sage'),
|
||||
get_search_query()
|
||||
);
|
||||
}
|
||||
|
||||
if (is_404()) {
|
||||
return __('Not Found', 'sage');
|
||||
}
|
||||
|
||||
return get_the_title();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the pagination links.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function pagination()
|
||||
{
|
||||
return wp_link_pages([
|
||||
'echo' => 0,
|
||||
'before' => '<p>'.__('Pages:', 'sage'),
|
||||
'after' => '</p>',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user