remove sage 10
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ACF;
|
||||
|
||||
class CloneGroup
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
public function block_background()
|
||||
{
|
||||
return [
|
||||
'contrast',
|
||||
'bg_colour',
|
||||
'bg_tint',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_intro()
|
||||
{
|
||||
return [
|
||||
'overline',
|
||||
'heading',
|
||||
'blurb',
|
||||
'intro_alignment',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_footer()
|
||||
{
|
||||
return [
|
||||
'blurb_footer',
|
||||
'links',
|
||||
'footer_alignment',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_settings()
|
||||
{
|
||||
return [
|
||||
'section_anchor_id',
|
||||
'padding_top',
|
||||
'padding_bottom',
|
||||
'container_width',
|
||||
'angle_status',
|
||||
'angle_position',
|
||||
'angle_direction',
|
||||
'angle_colour',
|
||||
'angle_tint',
|
||||
];
|
||||
}
|
||||
|
||||
public function block_all()
|
||||
{
|
||||
return array_merge($this->block_intro(), $this->block_footer(), $this->block_settings(), $this->block_background());
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ACF;
|
||||
use ourcodeworld\NameThatColor\ColorInterpreter as NameThatColor;
|
||||
use App\Utilities;
|
||||
|
||||
class Dynamic
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('acf/load_field/name=colour', [ $this, 'load_colours' ]);
|
||||
add_filter('acf/load_field/name=bg_colour', [ $this, 'load_colours' ]);
|
||||
add_filter('acf/load_field/name=tint', [ $this, 'load_tints' ]);
|
||||
add_filter('acf/load_field/name=bg_tint', [ $this, 'load_tints' ]);
|
||||
add_filter('acf/load_field/name=fontawesome_regular', [ $this, 'load_fontawesome_regular_icons' ]);
|
||||
add_filter('acf/load_field/name=fontawesome_solid', [ $this, 'load_fontawesome_solid_icons' ]);
|
||||
add_filter('acf/load_field/name=fontawesome_brands', [ $this, 'load_fontawesome_brand_icons' ]);
|
||||
|
||||
add_action( 'acf/input/admin_footer', [$this, 'colour_ui'] );
|
||||
}
|
||||
|
||||
public function load_colours( $field )
|
||||
{
|
||||
$colour = new Utilities\Colour;
|
||||
$NameThatColour = new NameThatColor;
|
||||
|
||||
$defined = get_field('badegg_colours', 'option');
|
||||
$colours = $colour->values();
|
||||
|
||||
$field['choices'] = [];
|
||||
|
||||
foreach($colours as $slug => $hex):
|
||||
$field['choices'][$slug] = '<i class="fas fa-circle" style="color: '. $hex .'"></i> ' . @$NameThatColour->name($hex)['name'];
|
||||
endforeach;
|
||||
|
||||
return $field;
|
||||
|
||||
}
|
||||
|
||||
public function load_tints( $field )
|
||||
{
|
||||
$colour = new Utilities\Colour;
|
||||
$tints = $colour->tints();
|
||||
|
||||
$field['choices'] = [];
|
||||
|
||||
foreach($tints as $slug => $hex):
|
||||
if($slug):
|
||||
$field['choices'][$slug] = ucfirst($slug);
|
||||
|
||||
else:
|
||||
$field['choices'][0] = 'None';
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function load_fontawesome_regular_icons( $field )
|
||||
{
|
||||
$field['choices'] = [];
|
||||
$field['choices'] = $this->fontawesome_choices('regular');
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function load_fontawesome_solid_icons( $field )
|
||||
{
|
||||
$field['choices'] = [];
|
||||
$field['choices'] = $this->fontawesome_choices('solid');
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function load_fontawesome_brand_icons( $field )
|
||||
{
|
||||
$field['choices'] = [];
|
||||
$field['choices'] = $this->fontawesome_choices('brands');
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function fontawesome_choices($set = 'solid')
|
||||
{
|
||||
$path = get_stylesheet_directory() . '/resources/json/font-awesome-' . $set . '.json';
|
||||
|
||||
$json = @file_get_contents($path);
|
||||
|
||||
if(!$json) return false;
|
||||
$icons = json_decode($json, true);
|
||||
|
||||
$choices = [
|
||||
'0' => '<i class="fa-solid"></i> <span>Please select an icon</span>',
|
||||
];
|
||||
|
||||
foreach($icons as $slug => $props):
|
||||
if(in_array($slug, range(0,9))) continue;
|
||||
|
||||
$choices[$slug] = '<i class="fa-'.$set.' fa-'.$slug.'" style="color: #2271b1;"></i> <span>' . (ucwords(str_replace('-', ' ', $slug))) . '</span>';
|
||||
endforeach;
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
public function colour_ui()
|
||||
{ ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
console.log("Script loaded from sage/app/ACF/Dynamic.php");
|
||||
|
||||
(function($) {
|
||||
|
||||
function my_custom_escaping_method( original_value){
|
||||
return original_value;
|
||||
}
|
||||
|
||||
acf.add_filter('select2_escape_markup', function( escaped_value, original_value, $select, settings, field, instance ){
|
||||
console.log(field.data('name'));
|
||||
|
||||
const whitelist = [
|
||||
'colour',
|
||||
'bg_colour',
|
||||
'angle_colour',
|
||||
];
|
||||
|
||||
// do something to the original_value to override the default escaping, then return it.
|
||||
// this value should still have some kind of escaping for security, but you may wish to allow specific HTML.
|
||||
if (whitelist.includes(field.data( 'name' ))) {
|
||||
return my_custom_escaping_method( original_value );
|
||||
}
|
||||
|
||||
// return
|
||||
return escaped_value;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ACF;
|
||||
|
||||
class JSON
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('acf/settings/save_json', [$this, 'save']);
|
||||
add_filter('acf/settings/load_json', [$this, 'load']);
|
||||
}
|
||||
|
||||
public function save( $path )
|
||||
{
|
||||
$path = get_stylesheet_directory() . '/resources/acf';
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function load( $paths )
|
||||
{
|
||||
unset($paths[0]);
|
||||
$paths[] = get_stylesheet_directory() . '/resources/acf';
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ACF;
|
||||
|
||||
class Options
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('acf/init', [$this, 'company']);
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
acf_add_options_page([
|
||||
'page_title' => __('Global Settings'),
|
||||
'menu_title' => __('Global Settings'),
|
||||
'menu_slug' => 'theme-global-settings',
|
||||
'capability' => 'edit_others_posts',
|
||||
'redirect' => false,
|
||||
'icon_url' => 'dashicons-admin-site',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class Blocks
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'after_setup_theme', [$this, 'block_patterns']);
|
||||
add_filter( 'admin_body_class', [$this, 'editor_classes']);
|
||||
add_filter( 'block_categories_all' , [$this, 'categories']);
|
||||
add_action( 'allowed_block_types_all', [$this, 'manage'], 10, 2);
|
||||
}
|
||||
|
||||
public function block_patterns()
|
||||
{
|
||||
remove_theme_support( 'core-block-patterns' );
|
||||
remove_theme_support('block-templates');
|
||||
}
|
||||
|
||||
public function editor_classes($classes)
|
||||
{
|
||||
global $pagenow;
|
||||
|
||||
if($pagenow == 'post.php'):
|
||||
$ID = @$_GET['post'];
|
||||
$pageTemplate = get_post_meta($ID, '_wp_page_template', true);
|
||||
|
||||
$classes .= ' ' . str_replace('.blade.php', '', $pageTemplate);
|
||||
endif;
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
public function categories( $categories )
|
||||
{
|
||||
|
||||
// Adding a new category.
|
||||
$categories = array_merge([
|
||||
[
|
||||
'slug' => 'badegg',
|
||||
'title' => __('Provided by Bad Egg Digital'),
|
||||
],
|
||||
[
|
||||
'slug' => 'tempsite',
|
||||
'title' => __('Temporary Site'),
|
||||
],
|
||||
], $categories);
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
public function manage($allowed_block_types, $editor_context)
|
||||
{
|
||||
// Reference:
|
||||
// https://www.wpexplorer.com/how-to-remove-gutenberg-blocks/
|
||||
// https://www.wpexplorer.com/wordpress-core-blocks-list/
|
||||
|
||||
// Existing blocks with Blade templates
|
||||
// https://roots.io/acorn/docs/rendering-blade-views/#existing-blocks-with-blade-templates
|
||||
|
||||
$blocks = array_keys( \WP_Block_Type_Registry::get_instance()->get_all_registered() );
|
||||
|
||||
$ID = @$editor_context->post->ID;
|
||||
$pageTemplate = get_post_meta($ID, '_wp_page_template', true);
|
||||
|
||||
if($pageTemplate == 'template-plain-document.blade.php'):
|
||||
$blacklist = $this->blacklist([
|
||||
'core/separator',
|
||||
'core/spacer',
|
||||
'core/heading',
|
||||
'core/list',
|
||||
'core/list-item',
|
||||
'core/paragraph',
|
||||
'core/pullquote',
|
||||
]);
|
||||
|
||||
$blacklist = array_merge($blacklist, [
|
||||
'acf/badegg-wysiwyg',
|
||||
]);
|
||||
|
||||
else:
|
||||
$blacklist = $this->blacklist();
|
||||
endif;
|
||||
|
||||
return array_values( array_diff( $blocks, $blacklist ) );
|
||||
}
|
||||
|
||||
public function blacklist($whitelist = [])
|
||||
{
|
||||
$blacklist = [
|
||||
// Contact Form 7
|
||||
'contact-form-7/contact-form-selector',
|
||||
|
||||
// Design
|
||||
'core/button',
|
||||
'core/comment-template',
|
||||
'core/home-link',
|
||||
'core/navigation-link',
|
||||
'core/navigation-submenu',
|
||||
'core/buttons',
|
||||
'core/column',
|
||||
'core/columns',
|
||||
'core/group',
|
||||
'core/more',
|
||||
'core/nextpage',
|
||||
'core/separator',
|
||||
'core/spacer',
|
||||
'core/text-columns',
|
||||
|
||||
// Embed
|
||||
'core/embed',
|
||||
|
||||
// Media
|
||||
'core/cover',
|
||||
'core/file',
|
||||
'core/gallery',
|
||||
'core/image',
|
||||
'core/media-text',
|
||||
'core/audio',
|
||||
'core/video',
|
||||
|
||||
// Reusable
|
||||
'core/block',
|
||||
|
||||
// Text
|
||||
'core/footnotes',
|
||||
'core/heading',
|
||||
'core/list',
|
||||
'core/code',
|
||||
'core/details',
|
||||
'core/freeform',
|
||||
// 'core/list-item',
|
||||
'core/missing',
|
||||
'core/paragraph',
|
||||
'core/preformatted',
|
||||
'core/pullquote',
|
||||
'core/quote',
|
||||
'core/table',
|
||||
'core/verse',
|
||||
|
||||
// Theme
|
||||
'core/avatar',
|
||||
'core/comment-author-name',
|
||||
'core/comment-content',
|
||||
'core/comment-date',
|
||||
'core/comment-edit-link',
|
||||
'core/comment-reply-link',
|
||||
'core/comments',
|
||||
'core/comments-pagination',
|
||||
'core/comments-pagination-next',
|
||||
'core/comments-pagination-numbers',
|
||||
'core/comments-pagination-previous',
|
||||
'core/comments-title',
|
||||
'core/loginout',
|
||||
'core/navigation',
|
||||
'core/pattern',
|
||||
'core/post-author',
|
||||
'core/post-author-biography',
|
||||
'core/post-author-name',
|
||||
'core/post-comments-form',
|
||||
'core/post-content',
|
||||
'core/post-date',
|
||||
'core/post-excerpt',
|
||||
'core/post-featured-image',
|
||||
'core/post-navigation-link',
|
||||
'core/post-template',
|
||||
'core/post-terms',
|
||||
'core/post-title',
|
||||
'core/query',
|
||||
'core/query-no-results',
|
||||
'core/query-pagination',
|
||||
'core/query-pagination-next',
|
||||
'core/query-pagination-numbers',
|
||||
'core/query-pagination-previous',
|
||||
'core/query-title',
|
||||
'core/read-more',
|
||||
'core/site-logo',
|
||||
'core/site-tagline',
|
||||
'core/site-title',
|
||||
'core/template-part',
|
||||
'core/term-description',
|
||||
'core/post-comments',
|
||||
|
||||
// Widgets
|
||||
'core/legacy-widget',
|
||||
'core/widget-group',
|
||||
'core/archives',
|
||||
'core/calendar',
|
||||
'core/categories',
|
||||
'core/latest-comments',
|
||||
'core/latest-posts',
|
||||
'core/page-list',
|
||||
'core/page-list-item',
|
||||
'core/rss',
|
||||
'core/search',
|
||||
'core/shortcode',
|
||||
'core/social-link',
|
||||
'core/tag-cloud',
|
||||
'core/html',
|
||||
'core/social-links',
|
||||
];
|
||||
|
||||
return array_values( array_diff( $blacklist, $whitelist ) );
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class Comments
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('admin_init', [$this, 'commentstatusdiv']); // Disable comment status div meta box
|
||||
add_action('wp_dashboard_setup', [$this, 'dashboard_activity']); // Remove the Activity widget
|
||||
add_action('wp_before_admin_bar_render', [$this, 'remove_menu_item']); // Remove from admin bar
|
||||
add_action('admin_menu', [$this, 'admin_menu']); // Remove from backend menu
|
||||
add_action('wp_dashboard_setup', [$this, 'dashboard_recent_comments']); // Remove Dashboard Meta Box
|
||||
add_filter('comments_rewrite_rules', '__return_empty_array'); // Remove comment rewrite rule
|
||||
add_action('after_theme_setup', [$this, 'theme_support']); // Remove comment theme support
|
||||
add_filter('rewrite_rules_array', [$this, 'rewrite']); // Clean up rewrite rule
|
||||
}
|
||||
|
||||
public function commentstatusdiv()
|
||||
{
|
||||
remove_meta_box( 'commentstatusdiv', 'post', 'normal' );
|
||||
remove_post_type_support( 'post', 'comments' );
|
||||
|
||||
remove_meta_box( 'commentstatusdiv', 'page', 'normal' );
|
||||
remove_post_type_support( 'page', 'comments' );
|
||||
}
|
||||
|
||||
public function dashboard_activity()
|
||||
{
|
||||
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
|
||||
}
|
||||
|
||||
public function remove_menu_item()
|
||||
{
|
||||
global $wp_admin_bar;
|
||||
$wp_admin_bar->remove_menu('comments');
|
||||
}
|
||||
|
||||
public function admin_menu()
|
||||
{
|
||||
remove_menu_page( 'edit-comments.php' );
|
||||
remove_submenu_page( 'options-general.php', 'options-discussion.php' );
|
||||
}
|
||||
|
||||
public function dashboard_recent_comments()
|
||||
{
|
||||
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
|
||||
}
|
||||
|
||||
public function theme_support()
|
||||
{
|
||||
remove_theme_support('comments');
|
||||
}
|
||||
|
||||
public function rewrite($rules)
|
||||
{
|
||||
foreach ($rules as $rule => $rewrite) {
|
||||
if (preg_match('/.*(feed)/', $rule)) {
|
||||
unset($rules[$rule]);
|
||||
}
|
||||
if (preg_match('/.*(comment-page)/', $rule)) {
|
||||
unset($rules[$rule]);
|
||||
}
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class DisablePost
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('register_post_type_args', [$this, 'args'], 0, 2);
|
||||
add_filter('register_taxonomy_args', [$this, 'args'], 0, 2);
|
||||
}
|
||||
|
||||
public function args($args, $type)
|
||||
{
|
||||
$types = [
|
||||
'post',
|
||||
'post_tag',
|
||||
'category',
|
||||
];
|
||||
|
||||
if(in_array($type, $types)) {
|
||||
$args['public'] = false;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class Enqueue
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'admin_enqueue_scripts', [$this, 'fontawesome']);
|
||||
}
|
||||
|
||||
public function fontawesome()
|
||||
{
|
||||
wp_enqueue_style(
|
||||
'fontawesome',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css',
|
||||
false,
|
||||
'6.5.2',
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class Integrations
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action( 'wp_head', [$this, 'FathomAnalytics']);
|
||||
}
|
||||
|
||||
public function FathomAnalytics()
|
||||
{
|
||||
$fathomID = get_field('badegg_integrations_fathom_id', 'option');
|
||||
|
||||
if($fathomID && WP_ENV == 'production'): ?>
|
||||
|
||||
<!-- Fathom - beautiful, simple website analytics -->
|
||||
<script src="https://cdn.usefathom.com/script.js" data-site="<?= $fathomID ?>" defer></script>
|
||||
<!-- / Fathom -->
|
||||
|
||||
<?php endif;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class Menus
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('admin_menu', [$this, 'cleanup_appearance']);
|
||||
|
||||
}
|
||||
|
||||
public function cleanup_appearance()
|
||||
{
|
||||
$customize_url = add_query_arg(
|
||||
'return',
|
||||
urlencode(
|
||||
remove_query_arg(
|
||||
wp_removable_query_args(),
|
||||
wp_unslash( $_SERVER['REQUEST_URI'] )
|
||||
)
|
||||
),
|
||||
'customize.php'
|
||||
);
|
||||
|
||||
remove_submenu_page( 'themes.php', $customize_url );
|
||||
remove_submenu_page( 'themes.php', 'widgets.php' );
|
||||
remove_submenu_page( 'themes.php', 'site-editor.php' );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\PostTypes;
|
||||
|
||||
class FAQ
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('init', [$this, 'register']);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$td = 'sage';
|
||||
$postType = 'faq';
|
||||
|
||||
register_extended_post_type(
|
||||
$postType,
|
||||
[
|
||||
'menu_position' => 40,
|
||||
'supports' => [
|
||||
'title',
|
||||
'editor',
|
||||
],
|
||||
'menu_icon' => 'dashicons-admin-comments',
|
||||
'rewrite' => false,
|
||||
'has_archive' => false,
|
||||
'publicly_queryable' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'page',
|
||||
'show_in_nav_menus' => false,
|
||||
'admin_cols' => [
|
||||
'faq_category' => [
|
||||
'title' => __('Category', $td),
|
||||
'taxonomy' => 'faq_category',
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
register_extended_taxonomy(
|
||||
'faq_category',
|
||||
$postType,
|
||||
[
|
||||
// 'meta_box' => 'radio',
|
||||
'rewrite' => false,
|
||||
'publicly_queryable' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
],
|
||||
[
|
||||
'singular' => __('Category', $td),
|
||||
'plural' => __('Categories', $td),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\PostTypes;
|
||||
|
||||
class Organization
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('init', [$this, 'register']);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$td = 'sage';
|
||||
$postType = 'organization';
|
||||
|
||||
register_extended_post_type(
|
||||
$postType,
|
||||
[
|
||||
'menu_position' => 40,
|
||||
'labels' => [
|
||||
'featured_image' => __('Logo', $td),
|
||||
],
|
||||
'supports' => [
|
||||
'title',
|
||||
'page-attributes',
|
||||
'thumbnail',
|
||||
],
|
||||
'menu_icon' => 'dashicons-building',
|
||||
'rewrite' => false,
|
||||
'has_archive' => false,
|
||||
'publicly_queryable' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'page',
|
||||
'show_in_nav_menus' => false,
|
||||
'admin_cols' => [
|
||||
'organisation_relationship' => [
|
||||
'title' => __('Relationship', $td),
|
||||
'taxonomy' => 'organisation_relationship',
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
register_extended_taxonomy(
|
||||
'organisation_relationship',
|
||||
$postType,
|
||||
[
|
||||
'meta_box' => 'radio',
|
||||
'rewrite' => false,
|
||||
'publicly_queryable' => false,
|
||||
],
|
||||
[
|
||||
'singular' => __('Relationship', $td),
|
||||
'plural' => __('Relationships', $td),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\PostTypes;
|
||||
|
||||
class Social
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('init', [$this, 'register']);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$td = 'sage';
|
||||
$postType = 'social';
|
||||
|
||||
register_extended_post_type(
|
||||
$postType,
|
||||
[
|
||||
'menu_position' => 28,
|
||||
'supports' => [
|
||||
'title',
|
||||
'page-attributes',
|
||||
],
|
||||
'menu_icon' => 'dashicons-share',
|
||||
'rewrite' => false,
|
||||
'has_archive' => false,
|
||||
'publicly_queryable' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'page',
|
||||
'show_in_nav_menus' => false,
|
||||
'admin_cols' => [
|
||||
'social_link' => [
|
||||
'title' => __('Social Link', $td),
|
||||
'meta_key' => 'fontawesome_brands',
|
||||
'function' => function(){
|
||||
$icon = get_field('fontawesome_brands');
|
||||
$url = get_field('url');
|
||||
|
||||
if($icon): ?>
|
||||
|
||||
<a
|
||||
href="<?= $url ?: '#' ?>"
|
||||
class="fa-brands fa-<?= $icon ?>"
|
||||
rel="nofollow noindex"
|
||||
style="font-size: 2em;"
|
||||
></a>
|
||||
|
||||
<?php endif;
|
||||
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\PostTypes;
|
||||
|
||||
class Testimonial
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('init', [$this, 'register']);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$td = 'sage';
|
||||
$postType = 'testimonial';
|
||||
|
||||
register_extended_post_type(
|
||||
$postType,
|
||||
[
|
||||
'menu_position' => 40,
|
||||
'supports' => [
|
||||
'title',
|
||||
],
|
||||
'menu_icon' => 'dashicons-format-quote',
|
||||
'rewrite' => false,
|
||||
'has_archive' => false,
|
||||
'publicly_queryable' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'page',
|
||||
'show_in_nav_menus' => false,
|
||||
'admin_cols' => [
|
||||
'social_link' => [
|
||||
'title' => __('Name', $td),
|
||||
'meta_key' => 'badegg_testimonial_name',
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class Colour
|
||||
{
|
||||
public function name2hex($colour = null, $tint = null)
|
||||
{
|
||||
if(!$colour) return false;
|
||||
|
||||
if($colour == 'black'):
|
||||
$hex = '#000000';
|
||||
elseif($colour == 'white'):
|
||||
$hex = '#FFFFFF';
|
||||
else:
|
||||
// TODO: replace company_info settings page and lookup function
|
||||
$hex = @$this->values()[(string)$colour];
|
||||
endif;
|
||||
|
||||
if($tint):
|
||||
$tints = $this->tints();
|
||||
$hex = $this->adjustBrightness($hex, $tints[$tint]);
|
||||
endif;
|
||||
|
||||
return $hex;
|
||||
}
|
||||
|
||||
public function values()
|
||||
{
|
||||
$colours = get_field('badegg_colours', 'option');
|
||||
|
||||
$values = [];
|
||||
|
||||
if($colours):
|
||||
foreach($colours as $index => $props):
|
||||
$index = $index + 1;
|
||||
$hex = @$props['hex'];
|
||||
|
||||
if($hex) $values[$this->latinate($index)] = $hex;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
$values['0'] = '#FFFFFF';
|
||||
$values['black'] = '#000000';
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function tints()
|
||||
{
|
||||
return [
|
||||
'lightest' => 100,
|
||||
'lighter' => 66,
|
||||
'light' => 33,
|
||||
'0' => 0,
|
||||
'dark' => -33,
|
||||
'darker' => -66,
|
||||
'darkest' => -100,
|
||||
];
|
||||
}
|
||||
|
||||
public function is_dark($colour = '#FFFFF')
|
||||
{
|
||||
|
||||
// https://css-tricks.com/snippets/php/convert-hex-to-rgb/
|
||||
|
||||
if ( @$colour[0] == '#' ) $colour = substr( $colour, 1 );
|
||||
|
||||
if ( strlen( $colour ) == 6 ) {
|
||||
list( $r, $g, $b ) = [
|
||||
$colour[0] . $colour[1],
|
||||
$colour[2] . $colour[3],
|
||||
$colour[4] . $colour[5],
|
||||
];
|
||||
|
||||
} elseif ( strlen( $colour ) == 3 ) {
|
||||
list( $r, $g, $b ) = [
|
||||
$colour[0] . $colour[0],
|
||||
$colour[1] . $colour[1],
|
||||
$colour[2] . $colour[2],
|
||||
];
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$r = hexdec( $r );
|
||||
$g = hexdec( $g );
|
||||
$b = hexdec( $b );
|
||||
// return array( 'red' => $r, 'green' => $g, 'blue' => $b );
|
||||
|
||||
$hsp = sqrt(
|
||||
0.299 * ($r * $r) +
|
||||
0.587 * ($g * $g) +
|
||||
0.114 * ($b * $b)
|
||||
);
|
||||
|
||||
if($hsp > 200) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function is_light($colour = '#000000', $override = null)
|
||||
{
|
||||
if($this->is_dark($colour, $override)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function adjustBrightness($hex, $steps)
|
||||
{
|
||||
// Steps should be between -255 and 255. Negative = darker, positive = lighter
|
||||
$steps = max(-255, min(255, $steps));
|
||||
|
||||
// Normalize into a six character long hex string
|
||||
$hex = str_replace('#', '', $hex);
|
||||
if (strlen($hex) == 3) {
|
||||
$hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2);
|
||||
}
|
||||
|
||||
// Split into three parts: R, G and B
|
||||
$color_parts = str_split($hex, 2);
|
||||
$return = '#';
|
||||
|
||||
foreach ($color_parts as $color) {
|
||||
$color = hexdec($color); // Convert to decimal
|
||||
$color = max(0,min(255,$color + $steps)); // Adjust color
|
||||
$return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function latinate($x = 0)
|
||||
{
|
||||
$latinate = [
|
||||
1 => 'primary',
|
||||
2 => 'secondary',
|
||||
3 => 'tertiary',
|
||||
4 => 'quaternary',
|
||||
5 => 'quinary',
|
||||
6 => 'senary',
|
||||
7 => 'septenary',
|
||||
8 => 'octonary',
|
||||
9 => 'nonary',
|
||||
10 => 'denary',
|
||||
11 => 'undenary',
|
||||
12 => 'duodenary',
|
||||
];
|
||||
|
||||
if(array_key_exists($x, $latinate)):
|
||||
return $latinate[$x];
|
||||
else:
|
||||
return 0;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class CssClasses {
|
||||
public function section($props = [])
|
||||
{
|
||||
$Colour = new Colour;
|
||||
$hex = $Colour->name2hex(@$props['bg_colour'], @$props['bg_tint']);
|
||||
|
||||
$pattern = @$props['pattern'];
|
||||
$pattern_top = @$props['pattern_top'];
|
||||
$pattern_bottom = @$props['pattern_bottom'];
|
||||
|
||||
$classes = [
|
||||
'section',
|
||||
'section-' . str_replace('acf/', '', $props['name']),
|
||||
'bg-' . $this->colourTint([
|
||||
'colour' => @$props['bg_colour'],
|
||||
'tint' => @$props['bg_tint'],
|
||||
]),
|
||||
];
|
||||
|
||||
if(@$props['angle_status'])
|
||||
$classes[] = 'section-has-angle';
|
||||
|
||||
if(@$props['angle_position'])
|
||||
$classes[] = 'section-has-angle-' . $props['angle_position'];
|
||||
|
||||
if(@$props['padding_top'])
|
||||
$classes[] = 'section-zero-top';
|
||||
|
||||
if(@$props['padding_bottom'])
|
||||
$classes[] = 'section-zero-bottom';
|
||||
|
||||
if(@$props['bg_image'])
|
||||
$classes[] = "bg-watermarked";
|
||||
|
||||
if($Colour->is_dark($hex) && $this->is_knockout_block($props['name']))
|
||||
$classes[] = 'knockout';
|
||||
|
||||
if(@$props['className']) $args = array_merge($classes, explode(' ', $props['className']));
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
public function button($args = [])
|
||||
{
|
||||
$default_args = [
|
||||
'colour' => null,
|
||||
'style' => null,
|
||||
];
|
||||
|
||||
$args = wp_parse_args($args, $default_args);
|
||||
|
||||
$classes = [
|
||||
'button',
|
||||
];
|
||||
|
||||
if($args['colour']) $classes[] = $args['colour'];
|
||||
if($args['style']) $classes[] = $args['style'];
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
public function colourTint($props = [])
|
||||
{
|
||||
if(@$props['colour']):
|
||||
$colour = $props['colour'];
|
||||
|
||||
if($props['colour'] != 'black' && @$props['tint']):
|
||||
$colour .= '-' . $props['tint'];
|
||||
endif;
|
||||
else:
|
||||
$colour = 'white';
|
||||
endif;
|
||||
|
||||
return $colour;
|
||||
}
|
||||
|
||||
public function is_knockout_block($name = null)
|
||||
{
|
||||
$blacklist = [
|
||||
'cards-alternating',
|
||||
];
|
||||
|
||||
if(in_array($name, $blacklist)):
|
||||
return false;
|
||||
else:
|
||||
return true;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class ImageSrcset
|
||||
{
|
||||
public function add($args = [])
|
||||
{
|
||||
$args = wp_parse_args($args, $this->default_args());
|
||||
$multipliers = $this->multipliers();
|
||||
|
||||
if(is_null($args['height'])) $args['height'] = $args['width'];
|
||||
|
||||
|
||||
if($args['sizes'] < 5) $multipliers = array_slice($multipliers, 0, $args['sizes']);
|
||||
|
||||
foreach ( $multipliers as $slug => $scale ):
|
||||
add_image_size (
|
||||
$args['name'] . '-' . $slug,
|
||||
round((int)$args['width'] * $scale),
|
||||
round((int)$args['height'] * $scale),
|
||||
$args['crop']
|
||||
);
|
||||
endforeach;
|
||||
}
|
||||
|
||||
public function default_args()
|
||||
{
|
||||
return [
|
||||
'name' => 'hero',
|
||||
'width' => 1920,
|
||||
'height' => null,
|
||||
'crop' => true,
|
||||
'sizes' => 5,
|
||||
];
|
||||
}
|
||||
|
||||
public function multipliers()
|
||||
{
|
||||
return [
|
||||
'xl' => 1,
|
||||
'lg' => 0.75,
|
||||
'md' => 0.52083333,
|
||||
'sm' => 0.33333333,
|
||||
'xs' => 0.20833333,
|
||||
];
|
||||
}
|
||||
|
||||
public function render($args = [])
|
||||
{
|
||||
global $_wp_additional_image_sizes;
|
||||
|
||||
$default_args = [
|
||||
'name' => 'hero',
|
||||
'image' => null,
|
||||
'lazy' => true,
|
||||
'sizes' => 5,
|
||||
'class' => null,
|
||||
];
|
||||
|
||||
$args = wp_parse_args($args, $default_args);
|
||||
$name = $args['name'];
|
||||
$image = ($args['image']) ? $args['image'] : get_post_thumbnail_id();
|
||||
|
||||
if(!$image) return false;
|
||||
|
||||
$properties = @$_wp_additional_image_sizes[$name . '-xl'];
|
||||
$width = @$properties['width'];
|
||||
$height = @$properties['height'];
|
||||
|
||||
$sizes = [
|
||||
'xl' => 1,
|
||||
'lg' => 0.75,
|
||||
'md' => 0.52083333,
|
||||
'sm' => 0.33333333,
|
||||
'xs' => 0.20833333,
|
||||
];
|
||||
|
||||
if($args['sizes'] < 5) $sizes = array_slice($sizes, 0, $args['sizes']);
|
||||
|
||||
$class = $name . '-image';
|
||||
if($args['class']) $class .= ' ' . $args['class'];
|
||||
|
||||
ob_start();
|
||||
|
||||
$full = wp_get_attachment_image_src($image, $name . '-xl');
|
||||
$lazy = wp_get_attachment_image_src($image, 'lazy');
|
||||
$alt = get_post_meta( $image, '_wp_attachment_image_alt', true );
|
||||
|
||||
$srcsets = [];
|
||||
foreach($sizes as $size => $multiplier) {
|
||||
$file = wp_get_attachment_image_src($image, $name . '-' . $size);
|
||||
$srcsets[] = $file[0] . ' ' . $file[1] . 'w';
|
||||
}
|
||||
|
||||
$atts = [
|
||||
'class' => $class,
|
||||
'src' => $full[0],
|
||||
'srcset' => implode(', ', $srcsets),
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'alt' => $alt,
|
||||
];
|
||||
|
||||
if($args['lazy'] && !is_admin()):
|
||||
$atts['class'] .= ' lazy';
|
||||
$atts['src'] = $lazy[0];
|
||||
$atts['srcset'] = null;
|
||||
$atts['data-src'] = $full[0];
|
||||
$atts['data-srcset'] = implode(', ', $srcsets);
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
||||
<img
|
||||
<?php foreach($atts as $att => $value):
|
||||
if($value) echo $att . '="' . $value . '" ';
|
||||
endforeach; ?>
|
||||
/>
|
||||
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class VideoSrcset
|
||||
{
|
||||
public function sizes($video_srcset = [])
|
||||
{
|
||||
if(empty($video_srcset)) return false;
|
||||
|
||||
$sizes = [];
|
||||
|
||||
foreach($video_srcset as $size => $video):
|
||||
if($video):
|
||||
$sizes[$size] = $video['width'];
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if(!empty($sizes)):
|
||||
return json_encode($sizes);
|
||||
else:
|
||||
return false;
|
||||
endif;
|
||||
}
|
||||
|
||||
public function smallest($video_srcset = [])
|
||||
{
|
||||
if(empty($video_srcset)) return false;
|
||||
|
||||
$smallest = null;
|
||||
|
||||
foreach($video_srcset as $size => $video):
|
||||
if($smallest) continue;
|
||||
if($video) $smallest = $size;
|
||||
endforeach;
|
||||
|
||||
return $smallest;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?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>',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?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'));
|
||||
});
|
||||
@@ -1,124 +0,0 @@
|
||||
<?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 () {
|
||||
/**
|
||||
* 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