Rename app to src
This commit is contained in:
77
src/helpers.php
Normal file
77
src/helpers.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Roots\Sage\Asset;
|
||||
use Roots\Sage\Assets\JsonManifest;
|
||||
use Roots\Sage\Template;
|
||||
|
||||
/**
|
||||
* @param string $slug
|
||||
* @param array $context
|
||||
*/
|
||||
function template_unwrap($slug = '', $context = []) {
|
||||
if ($file = Template::unwrap($slug, $context)->locate()) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include $file;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $context
|
||||
*/
|
||||
function template_sidebar($context = []) {
|
||||
template_part('sidebar', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $template
|
||||
* @param array $context
|
||||
*/
|
||||
function template_part($template, $context = []) {
|
||||
if ($file = (new Template($template, $context))->locate()) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include $file;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* @return string
|
||||
*/
|
||||
function asset_path($filename) {
|
||||
static $manifest;
|
||||
isset($manifest) || $manifest = new JsonManifest(get_template_directory() . '/' . Asset::$dist . '/assets.json');
|
||||
return (string) new Asset($filename, $manifest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether to show the sidebar
|
||||
* @return bool
|
||||
*/
|
||||
function display_sidebar() {
|
||||
static $display;
|
||||
isset($display) || $display = apply_filters('sage/display_sidebar', true);
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page titles
|
||||
* @return string
|
||||
*/
|
||||
function 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(__('Search Results for %s', 'sage'), get_search_query());
|
||||
}
|
||||
if (is_404()) {
|
||||
return __('Not Found', 'sage');
|
||||
}
|
||||
return get_the_title();
|
||||
}
|
||||
Reference in New Issue
Block a user