premier commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Roots\Acorn\Sage\SageServiceProvider;
|
||||
|
||||
class ThemeServiceProvider extends SageServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
parent::register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Roots\Acorn\View\Component;
|
||||
|
||||
class Alert extends Component
|
||||
{
|
||||
/**
|
||||
* The alert type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* The alert message.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* The alert types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'default' => 'text-indigo-50 bg-indigo-400',
|
||||
'success' => 'text-green-50 bg-green-400',
|
||||
'caution' => 'text-yellow-50 bg-yellow-400',
|
||||
'warning' => 'text-red-50 bg-red-400',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create the component instance.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($type = 'default', $message = null)
|
||||
{
|
||||
$this->type = $this->types[$type] ?? $this->types['default'];
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->view('components.alert');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Theme filters.
|
||||
*/
|
||||
|
||||
namespace App;
|
||||
|
||||
/**
|
||||
* Add "… Continued" to the excerpt.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
add_filter('excerpt_more', function () {
|
||||
return sprintf(' … <a href="%s">%s</a>', get_permalink(), __('Continued', 'sage'));
|
||||
});
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Theme setup.
|
||||
*/
|
||||
|
||||
namespace App;
|
||||
|
||||
use function Roots\bundle;
|
||||
|
||||
/**
|
||||
* Register the theme assets.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
add_action('wp_enqueue_scripts', function () {
|
||||
bundle('app')->enqueue();
|
||||
}, 100);
|
||||
|
||||
/**
|
||||
* Register the theme assets with the block editor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
add_action('enqueue_block_editor_assets', function () {
|
||||
bundle('editor')->enqueue();
|
||||
}, 100);
|
||||
|
||||
/**
|
||||
* Register the initial theme setup.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
add_action('after_setup_theme', function () {
|
||||
/**
|
||||
* Enable features from the Soil plugin if activated.
|
||||
*
|
||||
* @link https://roots.io/plugins/soil/
|
||||
*/
|
||||
add_theme_support('soil', [
|
||||
'clean-up',
|
||||
'nav-walker',
|
||||
'nice-search',
|
||||
'relative-urls',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Disable full-site editing support.
|
||||
*
|
||||
* @link https://wptavern.com/gutenberg-10-5-embeds-pdfs-adds-verse-block-color-options-and-introduces-new-patterns
|
||||
*/
|
||||
remove_theme_support('block-templates');
|
||||
|
||||
/**
|
||||
* Register the navigation menus.
|
||||
*
|
||||
* @link https://developer.wordpress.org/reference/functions/register_nav_menus/
|
||||
*/
|
||||
register_nav_menus([
|
||||
'primary_navigation' => __('Primary Navigation', 'sage'),
|
||||
]);
|
||||
|
||||
/**
|
||||
* Disable the default block patterns.
|
||||
*
|
||||
* @link https://developer.wordpress.org/block-editor/developers/themes/theme-support/#disabling-the-default-block-patterns
|
||||
*/
|
||||
remove_theme_support('core-block-patterns');
|
||||
|
||||
/**
|
||||
* Enable plugins to manage the document title.
|
||||
*
|
||||
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag
|
||||
*/
|
||||
add_theme_support('title-tag');
|
||||
|
||||
/**
|
||||
* Enable post thumbnail support.
|
||||
*
|
||||
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
|
||||
*/
|
||||
add_theme_support('post-thumbnails');
|
||||
|
||||
/**
|
||||
* Enable responsive embed support.
|
||||
*
|
||||
* @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#responsive-embedded-content
|
||||
*/
|
||||
add_theme_support('responsive-embeds');
|
||||
|
||||
/**
|
||||
* Enable HTML5 markup support.
|
||||
*
|
||||
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#html5
|
||||
*/
|
||||
add_theme_support('html5', [
|
||||
'caption',
|
||||
'comment-form',
|
||||
'comment-list',
|
||||
'gallery',
|
||||
'search-form',
|
||||
'script',
|
||||
'style',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Enable selective refresh for widgets in customizer.
|
||||
*
|
||||
* @link https://developer.wordpress.org/reference/functions/add_theme_support/#customize-selective-refresh-widgets
|
||||
*/
|
||||
add_theme_support('customize-selective-refresh-widgets');
|
||||
}, 20);
|
||||
|
||||
/**
|
||||
* Register the theme sidebars.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
add_action('widgets_init', function () {
|
||||
$config = [
|
||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>',
|
||||
];
|
||||
|
||||
register_sidebar([
|
||||
'name' => __('Primary', 'sage'),
|
||||
'id' => 'sidebar-primary',
|
||||
] + $config);
|
||||
|
||||
register_sidebar([
|
||||
'name' => __('Footer', 'sage'),
|
||||
'id' => 'sidebar-footer',
|
||||
] + $config);
|
||||
});
|
||||
Reference in New Issue
Block a user