Add 'web/app/themes/badegg/' from commit 'b31aa7550b02a4516fdf161f53dc7666854c9a14'
git-subtree-dir: web/app/themes/badegg git-subtree-mainline:b862ff9755git-subtree-split:b31aa7550b
This commit is contained in:
28
web/app/themes/badegg/app/ACF/CloneGroup.php
Normal file
28
web/app/themes/badegg/app/ACF/CloneGroup.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\ACF;
|
||||
|
||||
class CloneGroup
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
public function background()
|
||||
{
|
||||
return [
|
||||
'contrast',
|
||||
'bg_type',
|
||||
'bg_colour',
|
||||
'bg_tint',
|
||||
'bg_opacity',
|
||||
'bg_image',
|
||||
'bg_video',
|
||||
'pattern',
|
||||
'pattern_top',
|
||||
'pattern_bottom',
|
||||
'padding_top',
|
||||
'padding_bottom',
|
||||
];
|
||||
}
|
||||
}
|
||||
102
web/app/themes/badegg/app/ACF/Dynamic.php
Normal file
102
web/app/themes/badegg/app/ACF/Dynamic.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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' ]);
|
||||
}
|
||||
|
||||
public function load_colours( $field )
|
||||
{
|
||||
$colour = new Utilities\Colour;
|
||||
$NameThatColour = new NameThatColor;
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
25
web/app/themes/badegg/app/ACF/JSON.php
Normal file
25
web/app/themes/badegg/app/ACF/JSON.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
23
web/app/themes/badegg/app/ACF/Options.php
Normal file
23
web/app/themes/badegg/app/ACF/Options.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
135
web/app/themes/badegg/app/Admin/Blocks.php
Normal file
135
web/app/themes/badegg/app/Admin/Blocks.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
|
||||
class Blocks
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('allowed_block_types_all', [$this, 'blacklist'], 100, 2);
|
||||
}
|
||||
|
||||
public function blacklist()
|
||||
{
|
||||
// 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() );
|
||||
|
||||
$blacklist = [
|
||||
// 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( $blocks, $blacklist ) );
|
||||
}
|
||||
}
|
||||
67
web/app/themes/badegg/app/Admin/Comments.php
Normal file
67
web/app/themes/badegg/app/Admin/Comments.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
27
web/app/themes/badegg/app/Admin/DisablePost.php
Normal file
27
web/app/themes/badegg/app/Admin/DisablePost.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
22
web/app/themes/badegg/app/Admin/Enqueue.php
Normal file
22
web/app/themes/badegg/app/Admin/Enqueue.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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'
|
||||
);
|
||||
}
|
||||
}
|
||||
24
web/app/themes/badegg/app/Admin/Integrations.php
Normal file
24
web/app/themes/badegg/app/Admin/Integrations.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
65
web/app/themes/badegg/app/Blocks/BadExample.php
Normal file
65
web/app/themes/badegg/app/Blocks/BadExample.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Blocks;
|
||||
use App\Utilities;
|
||||
use App\ACF;
|
||||
|
||||
class BadExample
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('acf/init', [$this, 'init']);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
acf_register_block_type([
|
||||
'name' => 'badegg/bad-example',
|
||||
'title' => __('Bad Example'),
|
||||
'description' => __('This is an example block'),
|
||||
'render_callback' => [ $this, 'render'],
|
||||
'category' => 'layout',
|
||||
'multiple' => false,
|
||||
'icon' => [
|
||||
'src' => 'dismiss',
|
||||
],
|
||||
'supports' => [
|
||||
'align' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function render($block)
|
||||
{
|
||||
$CssClasses = new Utilities\CssClasses;
|
||||
$Colour = new Utilities\Colour;
|
||||
$CloneGroup = new ACF\CloneGroup;
|
||||
|
||||
$data = [];
|
||||
|
||||
$fields = [
|
||||
'heading',
|
||||
'blurb',
|
||||
];
|
||||
|
||||
$fields = array_merge($fields, $CloneGroup->background());
|
||||
|
||||
foreach($fields as $field):
|
||||
$data[$field] = get_field($field);
|
||||
endforeach;
|
||||
|
||||
unset($block['data']);
|
||||
$block['name'] = str_replace('acf/', '', $block['name']);
|
||||
|
||||
$data = array_merge($data, $block);
|
||||
$data['section_classes'] = $CssClasses->section($data);
|
||||
$data['block'] = $block;
|
||||
|
||||
$data['knockout'] = ($Colour->is_dark($data['bg_colour'], $data['bg_tint'], $data['contrast'])) ? null : 'knockout';
|
||||
|
||||
echo \Roots\view('blocks.bad-example', [
|
||||
'data' => $data,
|
||||
'block' => $block,
|
||||
])->render();
|
||||
}
|
||||
}
|
||||
57
web/app/themes/badegg/app/PostTypes/Social.php
Normal file
57
web/app/themes/badegg/app/PostTypes/Social.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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;
|
||||
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
28
web/app/themes/badegg/app/Providers/ThemeServiceProvider.php
Normal file
28
web/app/themes/badegg/app/Providers/ThemeServiceProvider.php
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
168
web/app/themes/badegg/app/Utilities/Colour.php
Normal file
168
web/app/themes/badegg/app/Utilities/Colour.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?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', $tint = null, $override = null)
|
||||
{
|
||||
|
||||
if($override == 'light') return true;
|
||||
if($override == 'dark') return false;
|
||||
|
||||
// https://css-tricks.com/snippets/php/convert-hex-to-rgb/
|
||||
|
||||
if($tint) $colour = $this->adjustBrightness($colour, $this->tints()[$tint]);
|
||||
|
||||
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', $tint = null)
|
||||
{
|
||||
if($this->is_dark($colour, $tint)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
105
web/app/themes/badegg/app/Utilities/CssClasses.php
Normal file
105
web/app/themes/badegg/app/Utilities/CssClasses.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?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($Colour->is_dark($hex) && $this->is_knockout_block($props['name']))
|
||||
$classes[] = 'knockout';
|
||||
|
||||
if(@$props['padding_top'])
|
||||
$classes[] = 'section-zero-top';
|
||||
|
||||
if(@$props['padding_bottom'])
|
||||
$classes[] = 'section-zero-bottom';
|
||||
|
||||
if($pattern):
|
||||
if($pattern == 'both'):
|
||||
$classes[] = 'pattern-top';
|
||||
$classes[] = 'pattern-bottom';
|
||||
|
||||
else:
|
||||
$classes[] = 'pattern-' . $pattern;
|
||||
|
||||
endif;
|
||||
|
||||
if(in_array($pattern, ['top', 'both']))
|
||||
$classes[] = 'pattern-top-' . $this->colourTint($pattern_top);
|
||||
|
||||
if(in_array($pattern, ['bottom', 'both']))
|
||||
$classes[] = 'pattern-bottom-' . $this->colourTint($pattern_bottom);
|
||||
|
||||
endif;
|
||||
|
||||
if(@$props['bg_image'])
|
||||
$classes[] = "bg-watermarked";
|
||||
|
||||
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 = [
|
||||
'bad-example',
|
||||
];
|
||||
|
||||
if(in_array($name, $blacklist)):
|
||||
return false;
|
||||
else:
|
||||
return true;
|
||||
endif;
|
||||
}
|
||||
}
|
||||
124
web/app/themes/badegg/app/Utilities/ImageSrcset.php
Normal file
124
web/app/themes/badegg/app/Utilities/ImageSrcset.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?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']):
|
||||
$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();
|
||||
}
|
||||
}
|
||||
39
web/app/themes/badegg/app/Utilities/VideoSrcset.php
Normal file
39
web/app/themes/badegg/app/Utilities/VideoSrcset.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
use App\Utilities;
|
||||
|
||||
class App extends Composer
|
||||
{
|
||||
/**
|
||||
* List of views served by this composer.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $views = [
|
||||
'*',
|
||||
];
|
||||
|
||||
/**
|
||||
* Retrieve the site name.
|
||||
*/
|
||||
public function siteName(): string
|
||||
{
|
||||
return get_bloginfo('name', 'display');
|
||||
}
|
||||
|
||||
public function with()
|
||||
{
|
||||
return [
|
||||
'Colour' => new Utilities\Colour,
|
||||
'VideoSrcset' => new Utilities\VideoSrcset,
|
||||
'ImageSrcset' => new Utilities\ImageSrcset,
|
||||
'siteName' => $this->siteName(),
|
||||
'company_legal' => get_field('badegg_company_legal', 'option'),
|
||||
'company_tel' => get_field('badegg_company_tel', 'option'),
|
||||
'company_email' => get_field('badegg_company_email', 'option'),
|
||||
];
|
||||
}
|
||||
}
|
||||
90
web/app/themes/badegg/app/View/Composers/Comments.php
Normal file
90
web/app/themes/badegg/app/View/Composers/Comments.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?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',
|
||||
];
|
||||
|
||||
/**
|
||||
* The comment title.
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
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.
|
||||
*/
|
||||
public function responses(): ?string
|
||||
{
|
||||
if (! have_comments()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return wp_list_comments([
|
||||
'style' => 'ol',
|
||||
'short_ping' => true,
|
||||
'echo' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The previous comments link.
|
||||
*/
|
||||
public function previous(): ?string
|
||||
{
|
||||
if (! get_previous_comments_link()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return get_previous_comments_link(
|
||||
__('← Older comments', 'sage')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The next comments link.
|
||||
*/
|
||||
public function next(): ?string
|
||||
{
|
||||
if (! get_next_comments_link()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return get_next_comments_link(
|
||||
__('Newer comments →', 'sage')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the comments are paginated.
|
||||
*/
|
||||
public function paginated(): bool
|
||||
{
|
||||
return get_comment_pages_count() > 1 && get_option('page_comments');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the comments are closed.
|
||||
*/
|
||||
public function closed(): bool
|
||||
{
|
||||
return ! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments');
|
||||
}
|
||||
}
|
||||
67
web/app/themes/badegg/app/View/Composers/Post.php
Normal file
67
web/app/themes/badegg/app/View/Composers/Post.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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-*',
|
||||
];
|
||||
|
||||
/**
|
||||
* Retrieve the post title.
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
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.
|
||||
*/
|
||||
public function pagination(): string
|
||||
{
|
||||
return wp_link_pages([
|
||||
'echo' => 0,
|
||||
'before' => '<p>'.__('Pages:', 'sage'),
|
||||
'after' => '</p>',
|
||||
]);
|
||||
}
|
||||
}
|
||||
35
web/app/themes/badegg/app/View/Composers/Socials.php
Normal file
35
web/app/themes/badegg/app/View/Composers/Socials.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Composers;
|
||||
|
||||
use Roots\Acorn\View\Composer;
|
||||
|
||||
class Socials extends Composer
|
||||
{
|
||||
/**
|
||||
* List of views served by this composer.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $views = [
|
||||
'components.socials',
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be passed to view before rendering.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function with()
|
||||
{
|
||||
return [
|
||||
'socials' => get_posts([
|
||||
'post_type' => 'social',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order name',
|
||||
'posts_per_page' => -1,
|
||||
'fields' => 'ids',
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
16
web/app/themes/badegg/app/filters.php
Normal file
16
web/app/themes/badegg/app/filters.php
Normal file
@@ -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'));
|
||||
});
|
||||
172
web/app/themes/badegg/app/setup.php
Normal file
172
web/app/themes/badegg/app/setup.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Theme setup.
|
||||
*/
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
|
||||
/**
|
||||
* Inject styles into the block editor.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
add_filter('block_editor_settings_all', function ($settings) {
|
||||
$style = Vite::asset('resources/css/editor.scss');
|
||||
|
||||
$settings['styles'][] = [
|
||||
'css' => "@import url('{$style}')",
|
||||
];
|
||||
|
||||
return $settings;
|
||||
});
|
||||
|
||||
/**
|
||||
* Inject scripts into the block editor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
add_filter('admin_head', function () {
|
||||
if (! get_current_screen()?->is_block_editor()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dependencies = json_decode(Vite::content('editor.deps.json'));
|
||||
|
||||
foreach ($dependencies as $dependency) {
|
||||
if (! wp_script_is($dependency)) {
|
||||
wp_enqueue_script($dependency);
|
||||
}
|
||||
}
|
||||
|
||||
echo Vite::withEntryPoints([
|
||||
'resources/js/editor.js',
|
||||
])->toHtml();
|
||||
});
|
||||
|
||||
/**
|
||||
* Use the generated theme.json file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
add_filter('theme_file_path', function ($path, $file) {
|
||||
return $file === 'theme.json'
|
||||
? public_path('build/assets/theme.json')
|
||||
: $path;
|
||||
}, 10, 2);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
});
|
||||
|
||||
add_filter('admin_post_thumbnail_size', function(){
|
||||
return "medium";
|
||||
});
|
||||
|
||||
add_action( 'init', __NAMESPACE__ . '\\cors', 15 );
|
||||
function cors() {
|
||||
|
||||
if(WP_ENV == 'development'):
|
||||
header( 'Access-Control-Allow-Origin: *' );
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
$image_srcset = new Utilities\ImageSrcset;
|
||||
$image_srcset->add(['name' => 'hero', 'width' => 1920, 'height' => 1000]);
|
||||
add_image_size('lazy', 50, 50);
|
||||
Reference in New Issue
Block a user