namespace PhysioAssist\Elementor;
use Elementor\Plugin;
+use Elementor\Controls_Manager;
class Setup {
public function register_customisations() {
+ $this->_customise_sections();
+
//--- Heading Widget
// Extend Elementor's heading widget to add a CSS class based on the alignment setting so we can also control the position of the underline
add_action( 'elementor/element/heading/section_title/before_section_end', function( $element, $args ) {
$elementor->widgets_manager->register_widget_type( new Widgets\TextBlock() );
$elementor->widgets_manager->register_widget_type( new Widgets\HeroBlock() );
$elementor->widgets_manager->register_widget_type( new Widgets\ProfileGrid() );
+ $elementor->widgets_manager->register_widget_type( new Widgets\ResourceGrid() );
$elementor->widgets_manager->register_widget_type( new Widgets\BackgroundImage() );
}
// Widgets\Carousel::register_scripts();
}
- // Ref: https://developers.elementor.com/widget-categories/
- // Now using standard 'theme-elements' category in favour of this one
-// public function register_category() {
-//
-// Plugin::$instance->elements_manager->add_category(
-// 'physioassist-elements',
-// [
-// 'title' => __( 'PhysioAssist Custom Elements', 'physioassist' ),
-// 'icon' => 'fa fa-plug', // default icon
-// ],
-// 1 // position
-// );
-// }
+
+ // Override the main Elementor section element to allow custom controls to be added to the editor
+ // This allows us to set specific CSS classes on the section wrapper, thereby centralising control
+ // of necessary settings for each section layout (column width, padding etc)
+ //
+ // References:
+ // https://www.ibenic.com/extending-elementor-custom-button-field-skin/
+ // https://blogs.devforum.ro/customizing-elementor-default-widgets/
+ // https://github.com/pojome/elementor/issues/3495
+ protected function _customise_sections() {
+
+ // Add controls to section element in editor
+ add_action( 'elementor/element/section/section_layout/after_section_start', function( $element, $args ) {
+ /** @var \Elementor\Element_Base $element */
+ $element->add_control(
+ 'block_layout',
+ [
+ 'label' => __('Custom Layout', 'cube'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ 'default' => __( 'Default', 'cube' ),
+ 'squares' => __( 'Text + Image Squares', 'cube' ),
+ 'indented' => __( 'Indented Content', 'cube' ),
+ ],
+ 'default' => 'default',
+ 'prefix_class' => 'layout-',
+ ]
+ );
+
+ $element->add_control(
+ 'layout_reversed',
+ [
+ 'label' => __('Reverse column layout?', 'cube'),
+ 'type' => Controls_Manager::SWITCHER,
+ 'default' => '',
+ 'return_value' => 'reversed',
+ 'prefix_class' => 'layout-', // Will apply return value as a class (eg. 'layout-reversed') when toggled. Prefix could also be an empty string.
+ ]
+ );
+
+ $element->add_control(
+ 'layout_disable_vertical_spacing',
+ [
+ 'label' => __('Disable vertical spacing?', 'cube'),
+ 'type' => Controls_Manager::SWITCHER,
+ 'default' => '',
+ 'return_value' => 'disable-vertical-spacing',
+ 'prefix_class' => '', // Will apply return value as a class
+ ]
+ );
+
+ }, 10, 2 );
+
+ }
}
$this->add_render_attribute('subtitle', 'class', ['hero-block-subtitle']);
$this->add_render_attribute('title', 'class', ['hero-block-title']);
$this->add_render_attribute('body', 'class', ['hero-block-body']);
- $this->add_render_attribute('cta_text', 'class', ['hero-block-cta']);
+ $this->add_render_attribute('cta_text', 'class', ['hero-block-cta arrow-link']);
$this->add_render_attribute('image', 'class', ['hero-block-image']);
// Add image src attribute
</div>
<# if ('' !== item.cta_text && '' !== item.cta_link.url) { #>
- <a href="{{ item.cta_link.url }}" class="profile-grid-cta">
+ <a href="{{ item.cta_link.url }}" class="profile-grid-cta arrow-link">
<?= \BladeSvgSage\svg_image('arrow')->toHtml() ?>
{{ item.cta_text }}
</a>
--- /dev/null
+<?php
+
+namespace PhysioAssist\Elementor\Widgets;
+
+use Elementor\Widget_Base;
+use Elementor\Controls_Manager;
+use Elementor\Utils;
+
+
+class ResourceGrid extends Widget_Base {
+
+// protected $_has_template_content = true;
+
+ // Widget name / ID
+ public function get_name() {
+ return 'cube-resource-grid';
+ }
+
+ // Elementor widget title
+ public function get_title() {
+ return __( 'Resource Grid', 'cube' );
+ }
+
+ // Elementor interface icon
+ public function get_icon() {
+ return 'eicon-posts-grid';
+ }
+
+ // Where to display the widget in the Elementor interface
+ public function get_categories() {
+ return [ 'theme-elements' ];
+ }
+
+ /**
+ * List of scripts the widget depends on.
+ * Used to set scripts dependencies required to run the widget.
+ *
+ * @since 1.0.0
+ * @access public
+ * @return array Widget scripts dependencies.
+ */
+ public function get_script_depends() {
+ return [];
+ }
+ /**
+ * Register the widget controls.
+ * Adds different input fields to allow the user to change and customize the widget settings.
+ *
+ * @since 1.0.0
+ * @access protected
+ */
+ protected function _register_controls() {
+
+ $this->start_controls_section(
+ 'section_content',
+ [
+ 'label' => __( 'Resource Grid', 'cube' ),
+ ]
+ );
+
+ $this->add_control(
+ 'items',
+ [
+ 'label' => __( 'Items', 'cube' ),
+ 'type' => Controls_Manager::REPEATER,
+ 'fields' => [
+ [
+ 'name' => 'image',
+ 'label' => __('Preview Image', 'cube'),
+ 'label_block' => true,
+ 'type' => Controls_Manager::MEDIA,
+ 'default' => [
+ 'url' => Utils::get_placeholder_image_src(),
+ ],
+ ],
+ [
+ 'name' => 'title',
+ 'label' => __( 'Title', 'cube' ),
+ 'type' => Controls_Manager::TEXT,
+ 'label_block' => true,
+ ],
+
+ // Todo: revisit this to see if we can have a more user-friendly file control
+ // See: https://github.com/pojome/elementor/issues/4468
+ [
+ 'name' => 'interactive_version',
+ 'label' => __( 'Interactive version link', 'cube' ),
+ 'type' => Controls_Manager::TEXT,
+ 'label_block' => true,
+ ],
+ [
+ 'name' => 'pdf',
+ 'label' => __( 'PDF link', 'cube' ),
+ 'type' => Controls_Manager::TEXT,
+ 'label_block' => true,
+ ],
+ ],
+ 'title_field' => '{{{ title }}}',
+ ]
+ );
+ $this->end_controls_section();
+ }
+ /**
+ * Render the widget output on the frontend.
+ * Written in PHP and used to generate the final HTML.
+ *
+ * @since 1.0.0
+ * @access protected
+ */
+ protected function render() {
+
+ $items = $this->get_settings('items');
+
+ $html = \App\template('widgets/resource-grid', compact('items'));
+
+ echo '<div class="resource-grid">'. $html .'</div>';
+ }
+
+ /**
+ * Render widget output in the editor.
+ *
+ * Written as a Backbone JavaScript template and used to generate the live preview.
+ *
+ * @since 1.0.0
+ * @access protected
+ */
+ protected function _content_template() {
+ ?>
+ <div class="resource-grid">
+ <#
+ if ( settings.items ) {
+
+ _.each( settings.items, function( item, index ) {
+ #>
+ <div class="resource-grid-item">
+
+ <img src="{{ item.image.url }}" class="resource-grid-image">
+
+ <div class="resource-grid-text">
+
+ <h3 class="resource-grid-title">{{{ item.title }}}</h3>
+
+ <# if ('' !== item.interactive_version) { #>
+ <a href="{{ item.interactive_version }}" class="resource-grid-link arrow-link">
+ <?= \BladeSvgSage\svg_image('arrow')->toHtml() ?>
+ <?php _ex('Read interactive version', 'Resource grid widget interactive version link text', 'cube') ?>
+ </a>
+ <# } #>
+
+ <# if ('' !== item.pdf) { #>
+ <a href="{{ item.pdf }}" class="resource-grid-link arrow-link">
+ <?= \BladeSvgSage\svg_image('arrow')->toHtml() ?>
+ <?php _ex('Download PDF', 'Resource grid widget PDF link text', 'cube') ?>
+ </a>
+ <# } #>
+
+ </div>
+
+ </div>
+ <#
+ });
+ } #>
+ </div>
+ <?php
+ }
+
+}
$this->add_render_attribute('subtitle', 'class', ['text-block-subtitle']);
$this->add_render_attribute('title', 'class', ['text-block-title']);
$this->add_render_attribute('body', 'class', ['text-block-body']);
- $this->add_render_attribute('cta_text', 'class', ['text-block-cta']);
+ $this->add_render_attribute('cta_text', 'class', ['text-block-cta arrow-link']);
// Rendered content
echo '<div class="text-block">';
view.addRenderAttribute( 'subtitle', 'class', ['text-block-subtitle']);
view.addRenderAttribute( 'title', 'class', ['text-block-title']);
view.addRenderAttribute( 'body', 'class', ['text-block-body']);
- view.addRenderAttribute( 'cta_text', 'class', ['text-block-cta']);
+ view.addRenderAttribute( 'cta_text', 'class', ['text-block-cta arrow-link']);
view.addInlineEditingAttributes( 'subtitle', 'none' );
view.addInlineEditingAttributes( 'title', 'none' );
});
/**
- * Add "… Continued" to the excerpt
+ * Add "> Read More" to the excerpt
*/
add_filter('excerpt_more', function () {
- return ' … <a href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
+ return '… <p><a class="arrow-link read-more-link" href="' . get_permalink() . '">' . \BladeSvgSage\svg_image('arrow')->toHtml() . __('Read More', 'sage') . '</a></p>';
});
+remove_filter('the_excerpt', 'wpautop'); // Don't apply wpautop to excerpt because it destroys the inline SVG in excerpt_more
/**
* Template Hierarchy should search for .blade.php files
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support('post-thumbnails');
+ set_post_thumbnail_size(237, 237, true);
/**
* Enable HTML5 markup support
padding: 0
min-width: 320px
+a
+ color: $colors.light-blue
+
// Paragraph spacing
p:not(:last-of-type)
margin-bottom: 1.5em
-.wrap
+//.wrap
// max-width: $content-max-width
// margin: 0 auto
// Get rid of default 10px padding around elements
.elementor-column-gap-default > .elementor-row > .elementor-column > .elementor-element-populated
padding: 0
+
+// Common action link with SVG arrow in front
+.arrow-link
+ display: inline-block
+ text-transform: uppercase
+ font-size: 14px
+ font-weight: 600
+ color: $colors.headings
+
+ &:hover
+ color: $colors.light-blue
+
+ svg
+ width: 6px
+ height: 10px
+ display: inline-block
+ margin-right: 8px
+
+ path
+ fill: currentColor
padding-top: 0 !important
padding-bottom: 0 !important
-.indent-content
+.indent-content, .layout-indented
constrain(padding-left, 7.5vw)
+
+.vertical-spacing
+ vertical-spacing()
-.elementor-heading-title
+.elementor-heading-title, .main-heading
color: $colors.headings
font-family: $font
font-size: $font-size-large
padding-bottom: 1em // To give space between menu and dropdown but keep them touching
padding-top: @padding-bottom // Matches bottom padding so menu stays vertically aligned in the centre
- &:hover
+ &:hover, &.current_page_parent, &.current_page_item
a
border-color: currentColor
+ // Home page is the exception - don't underline "home" when on home page...
+ &.menu-item-home a
+ border-color: transparent
+
+below(1500px)
margin-right: 3em
border: none
padding: 0
+ &:hover
+ color: $colors.light-blue
+
.locale-active
border-radius: 50%
border: 2px solid currentColor
+.blog-list
+ vertical-spacing(1.5vw)
+
+// Individual post on index/archive pages + single view
+.blog-post
+ display: flex
+ align-items: flex-start
+ &:not(:last-of-type)
+ constrain(margin-bottom, 4vw)
+
+.blog-post-featured-image
+ flex: 0 1 30%
+ max-width: 237px
+
+ &-inner
+ background-size: cover
+ background-color: #eee
+ padding-bottom: 100% // 1x1 ratio div
+
+.blog-post-text
+ flex: 1 1 70%
+ constrain(padding-left, 2.5vw)
+
+
+.entry-title
+ color: $colors.headings
+ font-size: 44px
+ line-height: 1.1
+ margin-bottom: 0.5em
+
+ a
+ color: currentColor
+
+.updated
+ display: inline-block
+ font-size: 18px
+ font-weight: 600
+ color: $colors.sub-headings
+ margin-bottom: 0.5em
+
+.entry-summary
+ .read-more-link
+ margin-top: 1.5em
+
+// Back home link
+.blog-back-link
+ margin-top: 1.5em
--- /dev/null
+.layout-reversed
+ .elementor-row
+ flex-direction: row-reverse
+
+.layout-squares
+ // ToDo...
+
@import 'layouts/header'
@import 'layouts/sidebar'
@import 'layouts/footer'
-// @import 'layouts/columns'
+ @import 'layouts/sections'
@import 'layouts/pages'
@import 'layouts/posts'
@import 'layouts/tinymce'
&-cta
display: block
- text-transform: uppercase
- font-size: 14px
- font-weight: 600
color: #fff
margin-top: 30px
-
- &:hover
- color: $colors.light-blue
-
- svg
- width: 6px
- height: 10px
- display: inline-block
- margin-right: 8px
-
- path
- fill: currentColor
&-cta
display: block
- color: $colors.headings
- font-size: 14px
- font-weight: 600
- text-transform: uppercase
margin-top: 1.4em
-
- &:hover
- color: $colors.light-blue
-
- svg
- width: 6px
- height: 10px
- display: inline-block
- margin-right: 4px
-
- path
- fill: currentColor
--- /dev/null
+.resource-grid
+ display: flex
+ flex-wrap: wrap
+ constrain(margin-bottom, -5vw) // Counteract space between rows for the last row
+
+ &-item
+ display: flex
+ constrain(margin-bottom, 5vw)
+ align-items: stretch // Make sure items are the same height
+ lost-column: 1/3 3 15px
+
+ +below(1100px)
+ lost-column: 1/2
+ +below(680px)
+ lost-column: 1/1
+
+ &-image
+ display: block
+ align-self: flex-end
+ max-width: 35% !important
+ box-shadow: -4px 6px 10px -2px rgba(0,0,0,0.4) !important
+ margin-left: 30px
+
+ +below(680px)
+ margin-left: 0
+
+ &-text
+ constrain(padding-left, 2.5vw) // Gutter between image and text
+ align-self: center
+
+ &-title
+ color: $colors.sub-headings
+ font-size: 18px
+ font-weight: 600
+ text-transform: uppercase
+ margin-bottom: 0.8em
+ line-height: 1.2
+
+ &-link
+ display: block
+ position: relative
+ margin-top: 1.4em
+ padding-left: 1em
+
+ svg
+ position: absolute
+ top: 0.425em
+ left: 0
margin-top: 40px
&-cta
- //font-smoothing()
display: block
- text-transform: uppercase
- font-size: 14px
- font-weight: 600
- color: $colors.headings
margin-top: 30px
-
- &:hover
- color: $colors.light-blue
-
- svg
- width: 6px
- height: 10px
- display: inline-block
- margin-right: 8px
-
- path
- fill: currentColor
@extends('layouts.app')
@section('content')
- @include('partials.page-header')
- @if (!have_posts())
- <div class="alert alert-warning">
- {{ __('Sorry, no results were found.', 'sage') }}
+ <div class="content-inner vertical-spacing">
+
+ <h2 class="main-heading"><?php _ex('News', 'Blog index title text', 'sage') ?></h2>
+
+ @include('partials.page-header')
+
+ @if (!have_posts())
+ <div class="alert alert-warning">
+ {{ __('Sorry, no results were found.', 'sage') }}
+ </div>
+ {!! get_search_form(false) !!}
+ @endif
+
+ <div class="indent-content blog-list">
+ @while (have_posts()) @php(the_post())
+ @include('partials.content-'.get_post_type())
+ @endwhile
+
+ {!! get_the_posts_navigation() !!}
</div>
- {!! get_search_form(false) !!}
- @endif
- @while (have_posts()) @php(the_post())
- @include('partials.content-'.get_post_type())
- @endwhile
- {!! get_the_posts_navigation() !!}
+ </div>
+
@endsection
-<article @php(post_class())>
- <header>
- <h1 class="entry-title">{{ get_the_title() }}</h1>
- @include('partials/entry-meta')
- </header>
- <div class="entry-content">
- @php(the_content())
+<article @php(post_class('blog-post blog-post-full'))>
+
+ <div class="blog-post-featured-image">
+ <div class="blog-post-featured-image-inner" style="background-image: url({{ the_post_thumbnail_url() }})"></div>
+ </div>
+
+ <div class="blog-post-text">
+ <header>
+ @include('partials/entry-meta')
+ <h1 class="entry-title">{{ get_the_title() }}</h1>
+ </header>
+ <div class="entry-content">
+ @php(the_content())
+ </div>
+ <footer>
+ {!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!}
+ </footer>
+
+ <p>
+ <a class="blog-back-link arrow-link" href="../../">@svg('arrow') <?php _ex('Back to news', 'Blog back link text', 'sage') ?></a>
+ </p>
+
+ @php(comments_template('/partials/comments.blade.php'))
</div>
- <footer>
- {!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!}
- </footer>
- @php(comments_template('/partials/comments.blade.php'))
</article>
-<article @php(post_class())>
- <header>
- <h2 class="entry-title"><a href="{{ get_permalink() }}">{{ get_the_title() }}</a></h2>
- @include('partials/entry-meta')
- </header>
- <div class="entry-summary">
- @php(the_excerpt())
+<article @php(post_class('blog-post'))>
+
+ <a class="blog-post-featured-image" href="{{ get_permalink() }}">
+ <div class="blog-post-featured-image-inner" style="background-image: url({{ the_post_thumbnail_url() }})"></div>
+ </a>
+
+ <div class="blog-post-text">
+ <header>
+ @include('partials/entry-meta')
+ <h3 class="entry-title"><a href="{{ get_permalink() }}">{{ get_the_title() }}</a></h3>
+ </header>
+ <div class="entry-summary">
+ @php(the_excerpt())
+ </div>
</div>
+
+
</article>
-<time class="updated" datetime="{{ get_post_time('c', true) }}">{{ get_the_date() }}</time>
-<p class="byline author vcard">
- {{ __('By', 'sage') }} <a href="{{ get_author_posts_url(get_the_author_meta('ID')) }}" rel="author" class="fn">
- {{ get_the_author() }}
- </a>
-</p>
+<time class="updated" datetime="{{ get_post_time('c', true) }}">{{ get_the_date('d/m/Y') }}</time>
+{{--<p class="byline author vcard">--}}
+ {{--{{ __('By', 'sage') }} <a href="{{ get_author_posts_url(get_the_author_meta('ID')) }}" rel="author" class="fn">--}}
+ {{--{{ get_the_author() }}--}}
+ {{--</a>--}}
+{{--</p>--}}
@extends('layouts.app')
@section('content')
- @while(have_posts()) @php(the_post())
- @include('partials.content-single-'.get_post_type())
- @endwhile
+ <div class="content-inner vertical-spacing">
+ @while(have_posts()) @php(the_post())
+ @include('partials.content-single-'.get_post_type())
+ @endwhile
+ </div>
+
@endsection
@if (!empty($item['cta_text']) && !empty($item['cta_link']['url']))
<a href="{{ $item['cta_link']['url'] }}"
- class="profile-grid-cta"
+ class="profile-grid-cta arrow-link"
@if ($item['cta_link']['is_external'])
target="_blank" rel="noopener"
@endif
--- /dev/null
+@foreach ($items as $item)
+
+ <div class="resource-grid-item">
+ @image($item['image']['id'], 'full', ['class' => 'resource-grid-image'])
+
+ <div class="resource-grid-text">
+
+ <h3 class="resource-grid-title">{{ $item['title'] }}</h3>
+
+ @if ($item['interactive_version'])
+ <a href="{{ $item['interactive_version'] }}" class="resource-grid-link arrow-link">
+ @svg('arrow')
+ <?php _ex('Read interactive version', 'Resource grid widget interactive version link text', 'cube') ?>
+ </a>
+ @endif
+
+ @if ($item['pdf'])
+ <a href="{{ $item['pdf'] }}" class="resource-grid-link arrow-link">
+ @svg('arrow')
+ <?php _ex('Download PDF', 'Resource grid widget PDF link text', 'cube') ?>
+ </a>
+ @endif
+
+ </div>
+ </div>
+
+@endforeach