diff --git a/.gitattributes b/.gitattributes index 425d5cd..3cfd4ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,5 +6,6 @@ # Export white-listed production code only. /src -export-ignore +/resources -export-ignore /composer.json -export-ignore /README.md -export-ignore diff --git a/composer.json b/composer.json index 69af6b2..f0165cc 100644 --- a/composer.json +++ b/composer.json @@ -3,16 +3,10 @@ "description": "x", "license": "proprietary", "require": { - "php": "^7.1", - "illuminate/support": "^5.4", - "roots/sage-lib": "^9.0" + "php": "^8.1" }, "require-dev": { - "automattic/vipwpcs": "dev-master", - "beaver-builder/bb-plugin": "*", - "beaver-builder/bb-theme-builder": "*", "roave/security-advisories": "dev-master", - "roots/sage": "*", "wp-coding-standards/wpcs": "^1.0" }, "config": { @@ -21,6 +15,9 @@ "extra": { "branch-alias": { "dev-master": "0.11.x-dev" + }, + "acorn": { + "providers": "Itineris\\SageFLBuilder\\SageFLBuilderServiceProvider" } }, "autoload": { @@ -28,32 +25,7 @@ "Itineris\\SageFLBuilder\\": "src/" } }, - "repositories": [ - { - "type": "package", - "package": { - "name": "beaver-builder/bb-plugin", - "type": "wordpress-plugin", - "version": "999.999.999", - "dist": { - "type": "zip", - "url": "https://updates.wpbeaverbuilder.com/?fl-api-method=composer_download&download=bb-plugin-pro.zip&license=78682e62702e6676657261766776407a7667" - } - } - }, - { - "type": "package", - "package": { - "name": "beaver-builder/bb-theme-builder", - "type": "wordpress-plugin", - "version": "999.999.999", - "dist": { - "type": "zip", - "url": "https://updates.wpbeaverbuilder.com/?fl-api-method=composer_download&download=bb-theme-builder.zip&license=78682e62702e6676657261766776407a7667" - } - } - } - ], + "minimum-stability": "dev", "prefer-stable": true, "scripts": { "check-style": "phpcs --standard=ruleset.xml --colors -p -s", diff --git a/resources/views/fl-builder-archive.blade.php b/resources/views/fl-builder-archive.blade.php new file mode 100644 index 0000000..9aa1614 --- /dev/null +++ b/resources/views/fl-builder-archive.blade.php @@ -0,0 +1,5 @@ +@extends('ItinerisSageFLBuilder::layouts.archive') + +@section('content') + @php FLBuilder::render_content_by_id($post_id, 'div', apply_filters('fl_theme_builder_content_attrs', [])); @endphp +@endsection diff --git a/resources/views/fl-builder-single.blade.php b/resources/views/fl-builder-single.blade.php new file mode 100644 index 0000000..9aa1614 --- /dev/null +++ b/resources/views/fl-builder-single.blade.php @@ -0,0 +1,5 @@ +@extends('ItinerisSageFLBuilder::layouts.archive') + +@section('content') + @php FLBuilder::render_content_by_id($post_id, 'div', apply_filters('fl_theme_builder_content_attrs', [])); @endphp +@endsection diff --git a/resources/views/layouts/archive.blade.php b/resources/views/layouts/archive.blade.php new file mode 100644 index 0000000..58bb8d6 --- /dev/null +++ b/resources/views/layouts/archive.blade.php @@ -0,0 +1,21 @@ +<!doctype html> +<html @php language_attributes(); @endphp> + <head> + <meta charset="utf-8"> + <meta http-equiv="x-ua-compatible" content="ie=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + @php wp_head(); @endphp + </head> + + <body @php body_class(); @endphp> + @php wp_body_open(); @endphp + @php do_action('get_header'); @endphp + + <div id="wrapper"> + @include('layouts.app') + </div> + + @php do_action('get_footer'); @endphp + @php wp_footer(); @endphp + </body> +</html> diff --git a/src/AbstractBladeModule.php b/src/AbstractBladeModule.php index 2c27dcc..c07818f 100644 --- a/src/AbstractBladeModule.php +++ b/src/AbstractBladeModule.php @@ -5,7 +5,7 @@ namespace Itineris\SageFLBuilder; use FLBuilderModule; -use function App\sage; +use function Roots\app; /** * Add Laravel Blade support. @@ -32,8 +32,8 @@ public static function renderFrontendTemplate(string $file, FLBuilderModule $mod } /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); - $path = $helper->templatePath($module->dir . 'includes/frontend.blade.php'); + $helper = app(AbstractHelper::class); + $path = $module->slug . '/includes/frontend'; echo $helper->template($path, [ 'module' => $module, diff --git a/src/AbstractHelper.php b/src/AbstractHelper.php index 8e6b853..bd35f3c 100644 --- a/src/AbstractHelper.php +++ b/src/AbstractHelper.php @@ -4,6 +4,9 @@ namespace Itineris\SageFLBuilder; +use function Roots\view; +use function Roots\asset; + abstract class AbstractHelper { /** @@ -12,22 +15,17 @@ abstract class AbstractHelper * * @return string */ - public function template($file, $data = []): string + public function template(string $file, array $data = []): string { - return \App\template($file, $data); - } + $file_path = "Theme::{$file}"; - /** - * Retrieve path to a compiled blade view - * - * @param $file - * @param array $data - * - * @return string - */ - public function templatePath($file, $data = []): string - { - return \App\template_path($file, $data); + if ($this->getModuleGroup() === $data['module']->group) { + $file_path = "ItinerisSageFLBuilderModules::{$file}"; + } + + return view()->exists($file_path) + ? view($file_path, $data)->render() + : ''; } /** @@ -37,7 +35,7 @@ public function templatePath($file, $data = []): string */ public function assetPath($asset): string { - return \App\asset_path($asset); + return asset($asset)->uri(); } public function getModuleGroup(): string @@ -57,13 +55,6 @@ public function getModuleCategory(): string return __('Custom Widgets', 'fabric'); } - /** - * @param string|string[] $templates Relative path to possible template files. - * - * @return string Location of the template - */ - abstract public function locateTemplate($templates): string; - /** * Button Styles usable in the cutup * @@ -76,59 +67,5 @@ abstract public function buttonStyles(): array; */ abstract public function breadcrumbs(); - /** - * Some times le wild <span class="blue hedgehog"> appears, which is when you need this function, to validate both - * blue and hedgehog because sanitize_html_class doesn't allow spaces. - * - * @param mixed $classes "blue hedgehog goes shopping" or array("blue", "hedgehog", "goes", "shopping"). - * @param mixed $fallback Anything you want returned in case of a failure. - * - * @return string - */ - abstract public function sanitizeHtmlClasses($classes, $fallback = null): string; - - /** - * @param string $videoUrl - * @param bool $isElement - * @param int $size - * @param string $altText - * - * @return string|null - */ - abstract public function videoThumb($videoUrl, $isElement = false, $size = '0', string $altText = ''); - - /** - * @param string $videoUrl - * @param string $urlType - * - * @return string - */ - abstract public function formatVideoUrl($videoUrl, $urlType = 'embed'): string; - - /** - * Creates a responsive iframe and embeds a video player - * or an embed URL for the video - * - * @param string $videoUrl URL of the video. - * @param boolean $isUrl If true, returns the iframe URL, not the iframe. - * @param int $width The width of the iframe. - * @param int $height The height of the iframe. - * - * @return string|false Video embed URL or HTML for iframe embed - */ - abstract public function videoEmbed($video_url, $width = null, $height = null); - - /** - * Builds a navigation menu based on parent post, children and siblings - */ - abstract public function getSecondaryNav(); - abstract public function getGravityForms(): array; - - /** - * Full path to PostGrid template directory. - * - * @return string - */ - abstract public function getPostGridTemplateDir(): string; } diff --git a/src/God.php b/src/God.php deleted file mode 100644 index b46b646..0000000 --- a/src/God.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Itineris\SageFLBuilder; - -use Itineris\SageFLBuilder\Settings\PostGrid; -use WP_Query; -use function App\sage; - -/** - * TODO: This class needs refactor! - * TODO: The final goal is to remove this class. - */ -class God implements InitializableInterface -{ - public static function init(): void - { - $god = new static(); - - add_action('fl_builder_posts_module_after_pagination', [$god, 'noPostsFilterBar'], 10, 2); - add_filter('fl_builder_module_frontend_custom_FilterBar', [$god, 'filterBarFrontend']); - } - - /** - * TODO: Do I deserve a class? - * - * Warning: This is a slow database query! - * - * @param $postType - * - * @return array - */ - public static function flGetLocations($postType): array - { - $locations = []; - $locQuery = new WP_Query([ - 'post_type' => $postType, - 'meta_key' => 'location', - 'meta_query' => [ - [ - 'key' => 'location', - 'value' => '', - 'compare' => '!=', - ], - ], - ]); // WPCS: slow query ok. - - if ($locQuery->have_posts()) { - while ($locQuery->have_posts()) { - $locQuery->the_post(); - $location = get_field('location', get_the_ID()); - if (! array_key_exists($location, $locations)) { - $locations[esc_attr($location)] = $location; - } - } - } - - wp_reset_postdata(); - - return $locations; - } - - /** - * TODO: Do I deserve a class? - */ - public static function flGetFilterCount($settings): int - { - $count = 0; - if (! $settings->show_filter) { - return $count; - } - if ($settings->show_search_filter) { - $count++; - } - if (isset($settings->tax_exists) && $settings->tax_exists) { - $count++; - } - if ($settings->show_meta_filters) { - $count++; - } - if (isset($settings->show_role) && $settings->show_role) { - $count++; - } - - return $count; - } - - /** - * TODO: Am I belong to class `PostGrid` or `FilterBar`? - */ - public function filterBarFrontend($settings): string - { - $settings['show_filter'] = true; - $settings['layout'] = 'theme'; - - return sage(PostGrid::class)->filterBar((object) $settings); - } - - /** - * TODO: Am I belong to class `PostGrid` or `FilterBar`? - */ - public function noPostsFilterBar($settings, $query): void - { - if ($query->have_posts()) { - return; - } - - $settings->show_filter = true; - $settings->layout = 'theme'; - - echo sage(PostGrid::class)->filterBar($settings); - } -} diff --git a/src/Modules/Accordion/Accordion.php b/src/Modules/Accordion/Accordion.php index c93f6e4..ccbee21 100644 --- a/src/Modules/Accordion/Accordion.php +++ b/src/Modules/Accordion/Accordion.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * Generic Bootstrap accordion widget @@ -87,7 +87,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Accordion', 'fabric'), diff --git a/src/Modules/Alert/Alert.php b/src/Modules/Alert/Alert.php index 0ea2811..93f0d8e 100644 --- a/src/Modules/Alert/Alert.php +++ b/src/Modules/Alert/Alert.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractBladeModule; use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** * Class Alert @@ -55,7 +55,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Alert', 'fabric'), diff --git a/src/Modules/Breadcrumbs/Breadcrumbs.php b/src/Modules/Breadcrumbs/Breadcrumbs.php index b7f52d3..f4b20ac 100644 --- a/src/Modules/Breadcrumbs/Breadcrumbs.php +++ b/src/Modules/Breadcrumbs/Breadcrumbs.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * Class Breadcrumbs @@ -28,7 +28,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Breadcrumbs', 'fabric'), diff --git a/src/Modules/Breadcrumbs/includes/frontend.php b/src/Modules/Breadcrumbs/includes/frontend.php index 6ba362a..a6506b3 100644 --- a/src/Modules/Breadcrumbs/includes/frontend.php +++ b/src/Modules/Breadcrumbs/includes/frontend.php @@ -3,9 +3,9 @@ declare(strict_types=1); use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** @var AbstractHelper $helper */ -$helper = sage(AbstractHelper::class); +$helper = app(AbstractHelper::class); echo $helper->breadcrumbs(); diff --git a/src/Modules/Button/Button.php b/src/Modules/Button/Button.php index 72486d5..4c976c7 100644 --- a/src/Modules/Button/Button.php +++ b/src/Modules/Button/Button.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * Generic Bootstrap button widget @@ -19,7 +19,7 @@ class Button extends AbstractModule public static function register(): void { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); FLBuilder::register_module(__CLASS__, [ 'general' => [ @@ -66,7 +66,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Button', 'fabric'), diff --git a/src/Modules/Button/includes/frontend.php b/src/Modules/Button/includes/frontend.php index 9ec8bed..92ce84c 100644 --- a/src/Modules/Button/includes/frontend.php +++ b/src/Modules/Button/includes/frontend.php @@ -6,14 +6,14 @@ */ use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** @var AbstractHelper $helper */ -$helper = sage(AbstractHelper::class); +$helper = app(AbstractHelper::class); ?> <?php if (! empty($settings->link) && ! empty($settings->text)) : ?> <a href="<?php echo esc_url($settings->link); ?>" - class="btn <?php echo $helper->sanitizeHtmlClasses($settings->style); ?>" + class="btn <?php echo esc_html($settings->style); ?>" target="<?php echo esc_attr($settings->target); ?>"><?php echo esc_html($settings->text); ?></a> <?php endif; ?> diff --git a/src/Modules/ContentImage/ContentImage.php b/src/Modules/ContentImage/ContentImage.php index 9c3d70f..aa25dec 100644 --- a/src/Modules/ContentImage/ContentImage.php +++ b/src/Modules/ContentImage/ContentImage.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractBladeModule; use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** * Generic Bootstrap button widget @@ -39,7 +39,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Content image', 'fabric'), diff --git a/src/Modules/FilterBar/FilterBar.php b/src/Modules/FilterBar/FilterBar.php index 8866d50..d3cd543 100644 --- a/src/Modules/FilterBar/FilterBar.php +++ b/src/Modules/FilterBar/FilterBar.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * @class FilterBar @@ -103,7 +103,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Filter bar', 'fabric'), diff --git a/src/Modules/Gallery/Gallery.php b/src/Modules/Gallery/Gallery.php index 4542f2f..1b09a6d 100644 --- a/src/Modules/Gallery/Gallery.php +++ b/src/Modules/Gallery/Gallery.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractBladeModule; use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** * Class Gallery @@ -61,7 +61,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Gallery', 'fabric'), diff --git a/src/Modules/GravityForm/GravityForm.php b/src/Modules/GravityForm/GravityForm.php index 6bbf037..ceafbf9 100644 --- a/src/Modules/GravityForm/GravityForm.php +++ b/src/Modules/GravityForm/GravityForm.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractBladeModule; use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; class GravityForm extends AbstractBladeModule { @@ -18,7 +18,7 @@ class GravityForm extends AbstractBladeModule public static function register(): void { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); FLBuilder::register_module(__CLASS__, [ 'items' => [ @@ -104,7 +104,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Gravity Form', 'fabric'), diff --git a/src/Modules/PageHeading/PageHeading.php b/src/Modules/PageHeading/PageHeading.php index eb731ca..7836e87 100644 --- a/src/Modules/PageHeading/PageHeading.php +++ b/src/Modules/PageHeading/PageHeading.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractBladeModule; use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** * @class PageHeading @@ -61,7 +61,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Page heading', 'fabric'), diff --git a/src/Modules/PageSlider/PageSlider.php b/src/Modules/PageSlider/PageSlider.php index 69c2a02..debd35b 100644 --- a/src/Modules/PageSlider/PageSlider.php +++ b/src/Modules/PageSlider/PageSlider.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * @class PageSlider @@ -19,7 +19,7 @@ class PageSlider extends AbstractModule public static function register(): void { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); FLBuilder::register_module(__CLASS__, [ 'general' => [ @@ -207,7 +207,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Page Slider', 'fabric'), diff --git a/src/Modules/SecondaryNav/SecondaryNav.php b/src/Modules/SecondaryNav/SecondaryNav.php index ffe77f8..68c629e 100644 --- a/src/Modules/SecondaryNav/SecondaryNav.php +++ b/src/Modules/SecondaryNav/SecondaryNav.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * Class SecondaryNav @@ -28,7 +28,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Secondary nav', 'fabric'), diff --git a/src/Modules/SecondaryNav/includes/frontend.php b/src/Modules/SecondaryNav/includes/frontend.php index 9b6fb14..f23235a 100644 --- a/src/Modules/SecondaryNav/includes/frontend.php +++ b/src/Modules/SecondaryNav/includes/frontend.php @@ -3,10 +3,10 @@ declare(strict_types=1); use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** @var AbstractHelper $helper */ -$helper = sage(AbstractHelper::class); +$helper = app(AbstractHelper::class); ?> diff --git a/src/Modules/Table/Table.php b/src/Modules/Table/Table.php index 74f46f6..cebb003 100644 --- a/src/Modules/Table/Table.php +++ b/src/Modules/Table/Table.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractHelper; use Itineris\SageFLBuilder\AbstractModule; -use function App\sage; +use function Roots\app; /** * Generic Bootstrap table widget @@ -89,7 +89,7 @@ public static function register(): void public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Table', 'fabric'), diff --git a/src/Modules/Testimonial/Testimonial.php b/src/Modules/Testimonial/Testimonial.php index 9d8b320..7d53bf9 100644 --- a/src/Modules/Testimonial/Testimonial.php +++ b/src/Modules/Testimonial/Testimonial.php @@ -7,7 +7,7 @@ use FLBuilder; use Itineris\SageFLBuilder\AbstractBladeModule; use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; +use function Roots\app; /** * Generic Testimonial widget @@ -66,7 +66,7 @@ public function getCite(): string public function __construct() { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); parent::__construct([ 'name' => __('Testimonial', 'fabric'), diff --git a/src/SageFLBuilder.php b/src/SageFLBuilder.php index 44510ea..409fe71 100644 --- a/src/SageFLBuilder.php +++ b/src/SageFLBuilder.php @@ -17,14 +17,12 @@ use Itineris\SageFLBuilder\Modules\SecondaryNav\SecondaryNav; use Itineris\SageFLBuilder\Modules\Table\Table; use Itineris\SageFLBuilder\Modules\Testimonial\Testimonial; -use Itineris\SageFLBuilder\Settings\Archives\EventsArchive; -use Itineris\SageFLBuilder\Settings\PostGrid; -use Itineris\SageFLBuilder\Settings\RichText; use Itineris\SageFLBuilder\Settings\ThemeLayouts\ArchiveThemeLayout; use Itineris\SageFLBuilder\Settings\ThemeLayouts\DefaultThemeLayout; use Itineris\SageFLBuilder\Settings\ThemeLayouts\HomeThemeLayout; use Itineris\SageFLBuilder\Settings\ThemeLayouts\SingleThemeLayout; -use function App\sage; + +use function Roots\app; /** * Beaver Builder extensions @@ -38,16 +36,12 @@ final class SageFLBuilder Breadcrumbs::class, Button::class, ContentImage::class, - EventsArchive::class, FilterBar::class, Gallery::class, - God::class, GravityForm::class, HomeThemeLayout::class, PageHeading::class, PageSlider::class, - PostGrid::class, - RichText::class, SecondaryNav::class, SingleThemeLayout::class, Table::class, @@ -102,7 +96,7 @@ public function setInitializables($initializables): self public static function setDefaultModuleGroup(array $data): array { /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); + $helper = app(AbstractHelper::class); // Get the name of the projects module group. $group_name = $helper->getSiteModuleGroup(); @@ -147,8 +141,7 @@ public function addFilters(): void public function init(): void { - sage()->instance(AbstractHelper::class, $this->helper); - sage()->bind(PostGrid::class); + app()->instance(AbstractHelper::class, $this->helper); foreach ($this->initializables as $initializable) { $initializable::init(); diff --git a/src/SageFLBuilderServiceProvider.php b/src/SageFLBuilderServiceProvider.php new file mode 100644 index 0000000..1bdcca8 --- /dev/null +++ b/src/SageFLBuilderServiceProvider.php @@ -0,0 +1,39 @@ +<?php + +declare(strict_types=1); + +namespace Itineris\SageFLBuilder; + +use Illuminate\Support\Facades\View; +use Itineris\SageFLBuilder\View\Composers\FLBuilder; +use Roots\Acorn\ServiceProvider; + +use function Roots\base_path; + +class SageFLBuilderServiceProvider extends ServiceProvider +{ + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot(): void + { + $this->loadViewsFrom( + base_path('app/Plugins/FLBuilder/Modules/'), + 'Theme' + ); + + $this->loadViewsFrom( + __DIR__ . '/../resources/views/', + 'ItinerisSageFLBuilder' + ); + + $this->loadViewsFrom( + __DIR__ . '/Modules/', + 'ItinerisSageFLBuilderModules' + ); + + View::composer(FLBuilder::views(), FLBuilder::class); + } +} diff --git a/src/Settings/Archives/Archive.php b/src/Settings/Archives/Archive.php deleted file mode 100644 index c266f70..0000000 --- a/src/Settings/Archives/Archive.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Itineris\SageFLBuilder\Settings\Archives; - -use WP_Query; - -final class Archive -{ - /** - * @var string - */ - private $postType; - - public function __construct(string $postType) - { - $this->postType = $postType; - } - - public function modifyQuery(WP_Query $query): WP_Query - { - if ($this->shouldModify($query)) { - $query->set('post_parent', 0); - } - - return $query; - } - - private function shouldModify(WP_Query $query): bool - { - return ! is_admin() && - $query->is_post_type_archive($this->postType) && - ($query->is_main_query() || $query->get('fl_builder_loop', false)) && - (! isset($query->query['settings']->type) || 'post-grid' === $query->query['settings']->type); // WPCS: precision alignment ok. - } -} diff --git a/src/Settings/Archives/EventsArchive.php b/src/Settings/Archives/EventsArchive.php deleted file mode 100644 index 644f2dd..0000000 --- a/src/Settings/Archives/EventsArchive.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Itineris\SageFLBuilder\Settings\Archives; - -use Itineris\SageFLBuilder\InitializableInterface; - -final class EventsArchive implements InitializableInterface -{ - public static function init(): void - { - $archive = new Archive('event'); - - add_action('pre_get_posts', [$archive, 'modifyQuery']); - } -} diff --git a/src/Settings/PostGrid.php b/src/Settings/PostGrid.php deleted file mode 100644 index 161b2b6..0000000 --- a/src/Settings/PostGrid.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Itineris\SageFLBuilder\Settings; - -use Itineris\SageFLBuilder\AbstractHelper; -use Itineris\SageFLBuilder\InitializableInterface; -use RuntimeException; -use function App\sage; - -/** - * Custom Post Grid for the theme builder. - */ -class PostGrid implements InitializableInterface -{ - private const NOT_FOUND = 'not found'; - - public static function init(): void - { - // Filters. - add_filter('fl_builder_register_settings_form', static::class . '::postGridSettings', 10, 2); - add_filter('fl_builder_posts_module_layout_path', static::class . '::loadLayoutPath', 10, 3); - } - - /** - * Adds custom settings to the Posts module. - * - * @param array $form - * @param string $slug - * - * @return array - */ - public static function postGridSettings($form, $slug): array - { - if ('post-grid' !== $slug) { - return $form; - } - - $form['layout']['sections']['general']['fields']['layout']['options']['theme'] = __('Theme', 'fl-builder'); - $form['layout']['sections']['general']['fields']['layout']['toggle']['theme'] = [ - 'sections' => [ - 'posts', - ], - 'fields' => [ - 'match_height', - 'show_filter', - 'show_cat_desc', - ], - ]; - $form['layout']['sections']['general']['fields']['show_filter'] = [ - 'type' => 'select', - 'label' => __('Show filter bar?', 'fabric'), - 'default' => '1', - 'options' => [ - '1' => __('Yes', 'fl-builder'), - '0' => __('No', 'fl-builder'), - ], - 'toggle' => [ - '0' => [], - '1' => [ - 'sections' => ['filter_bar'], - ], - ], - ]; - $form['layout']['sections']['info']['fields']['date_format']['options']['l jS F'] = date('l jS F'); - $form['layout']['sections']['filter_bar'] = [ - 'title' => __('Filter bar', 'fabric'), - 'fields' => [ - 'auto_filter' => [ - 'type' => 'select', - 'label' => __('Auto filter?', 'fabric'), - 'default' => '1', - 'options' => [ - '1' => __('Yes', 'fl-builder'), - '0' => __('No', 'fl-builder'), - ], - ], - 'show_button' => [ - 'type' => 'select', - 'label' => __('Show submit button?', 'fabric'), - 'default' => '1', - 'options' => [ - '0' => __('No', 'fabric'), - '1' => __('Yes', 'fabric'), - ], - ], - 'show_search_filter' => [ - 'type' => 'select', - 'label' => __('Show search box?', 'fabric'), - 'default' => '1', - 'options' => [ - '1' => __('Yes', 'fl-builder'), - '0' => __('No', 'fl-builder'), - ], - ], - 'show_meta_filters' => [ - 'type' => 'select', - 'label' => __('Show field filters?', 'fabric'), - 'default' => '1', - 'options' => [ - '1' => __('Yes', 'fl-builder'), - '0' => __('No', 'fl-builder'), - ], - ], - 'show_cat_desc' => [ - 'type' => 'select', - 'label' => __('Show category description?', 'fabric'), - 'default' => '1', - 'options' => [ - '1' => __('Yes', 'fl-builder'), - '0' => __('No', 'fl-builder'), - ], - ], - 'show_cat_filter' => [ - 'type' => 'select', - 'label' => __('Show category dropdown?', 'fabric'), - 'default' => '1', - 'options' => [ - '1' => __('Yes', 'fl-builder'), - '0' => __('No', 'fl-builder'), - ], - ], - ], - ]; - - return $form; - } - - public static function loadLayoutPath($path, $layout, $settings) - { - if ('theme' !== $layout) { - return $path; - } - - /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); - - return self::templatePath( - $helper->getPostGridTemplateDir(), - 'post-theme', - get_post_type() ?: $settings->post_type - ); - } - - private static function templatePath(string $dir, string $prefix, string $postType): string - { - $dir = untrailingslashit($dir); - $prefix = untrailingslashit($prefix); - - $paths = [ - "$dir/$prefix-$postType.blade.php", - "$dir/$prefix-$postType.php", - "$dir/$prefix.blade.php", - "$dir/$prefix.php", - __DIR__ . "/../post-grid/$prefix-$postType.blade.php", - __DIR__ . "/../post-grid/$prefix-$postType.php", - __DIR__ . "/../post-grid/$prefix.blade.php", - __DIR__ . "/../post-grid/$prefix.php", - ]; - - $path = array_first($paths, function (string $path): bool { - return file_exists($path); - }, self::NOT_FOUND); - - if (self::NOT_FOUND === $path) { - throw new RuntimeException('Template not found in ' . implode(', ', $paths)); - } - - if (ends_with($path, '.blade.php')) { - /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); - $path = $helper->templatePath($path); - } - - return $path; - } - - public static function filterBar($settings): string - { - /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); - - ob_start(); - - // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable - $show_filter = false; - $tax_exists = false; - - $postType = $settings->post_type ?? null; - if ('main_query' === $settings->data_source) { - $postType = get_post_type(); - } - if (empty($postType)) { - $postType = 'post'; - } - - if ($settings->show_filter) { - // Get the taxonomy name. - if ('post' === $postType) { - $category = 'category'; - } elseif ('product' === $postType) { - $category = 'product_cat'; - } else { - $category = $postType . '_category'; - } - // Check if the taxonomy exists. - $tax_exists = taxonomy_exists($category); - // Whether or not to show the filter. - $show_filter = $tax_exists ? true : false; - // Get the Term ID to filter by from $_GET['pc']. - $term_id = $helper->getCat(true, $category, true); - // Change the category if it is valid. - if (! empty($term_id)) { - $settings->{'tax_' . $postType . '_' . $category} = $term_id; - } - } - - $path = self::templatePath( - $helper->getPostGridTemplateDir(), - 'filter-bar', - $postType - ); - - // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.IncludingFile - include $path; - - return ob_get_clean(); - } -} diff --git a/src/Settings/ProductsArchive.php b/src/Settings/ProductsArchive.php deleted file mode 100644 index 6357450..0000000 --- a/src/Settings/ProductsArchive.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Itineris\SageFLBuilder\Settings; - -use Itineris\SageFLBuilder\InitializableInterface; -use function App\sage; - -/** - * Custom Post Grid for the theme builder. - */ -class ProductsArchive implements InitializableInterface -{ - public static function init(): void - { - remove_action( - 'fl_builder_posts_module_before_posts', - 'FLThemeBuilderWooCommerceArchive::posts_module_before_posts' - ); - add_action('fl_builder_posts_module_after_posts', static::class . '::loadProductMarkupAfterPosts'); - add_action('fl_builder_posts_module_before_posts', static::class . '::loadFilterBar', 11, 2); - } - - public static function loadProductMarkupAfterPosts($settings): void - { - if ('theme' !== $settings->layout) { - return; - } - - $postType = get_post_type() ?: $settings->post_type; - - if ('product' === $postType) { - echo '</ul></div></div>'; - } - } - - public static function loadFilterBar($settings, $query) - { - if ('theme' !== $settings->layout) { - return; - } - - $tax_query = $query->get('tax_query'); - $term = isset($tax_query[0]['terms'][0]) && is_numeric($tax_query[0]['terms'][0]) ? - get_term($tax_query[0]['terms'][0], 'product_cat') : ''; - $cat_title = ! empty($term) && ! is_wp_error($term) ? $term->name : ''; - $post_type = $query->query_vars['post_type']; - if ('product' === $post_type) { - echo '<div class="container">'; - echo '<header class="woocommerce-products-header"><div class="row">'; - echo '<div class="col-sm-8">'; - echo '<h2 class="woocommerce-products-header__title page-title">'; - if (function_exists('is_product_category') && is_product_category()) { - single_term_title(); - } else { - echo $cat_title; - } - echo '</h2>'; - echo '</div>'; - echo '<div class="col-sm-4">'; - \FLThemeBuilderWooCommerceArchive::posts_module_before_posts($settings); - echo '</div></div></header>'; - echo '<div class="product-row row"><ul class="products">'; - } elseif ($settings->show_filter) { - echo sage(PostGrid::class)->filterBar($settings); - } - } -} diff --git a/src/Settings/RichText.php b/src/Settings/RichText.php deleted file mode 100644 index 68e4889..0000000 --- a/src/Settings/RichText.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Itineris\SageFLBuilder\Settings; - -use Itineris\SageFLBuilder\InitializableInterface; - -final class RichText implements InitializableInterface -{ - public static function init(): void - { - add_filter('fl_builder_render_module_content', static::class . '::wrap', 10, 2); - } - - public static function wrap(string $out, $module): string - { - if ('rich-text' !== $module->slug) { - return $out; - } - - return '<div class="content">' . $out . '</div>'; - } -} diff --git a/src/Settings/ThemeLayouts/ThemeLayout.php b/src/Settings/ThemeLayouts/ThemeLayout.php index a084ab6..ca8a838 100644 --- a/src/Settings/ThemeLayouts/ThemeLayout.php +++ b/src/Settings/ThemeLayouts/ThemeLayout.php @@ -5,25 +5,25 @@ namespace Itineris\SageFLBuilder\Settings\ThemeLayouts; use Closure; -use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; + +use function Roots\view; final class ThemeLayout { /** * @var Closure */ - private $shouldInclude; + private Closure $shouldInclude; /** * @var string */ - private $template; + private string $template; public function __construct(Closure $shouldInclude, string $template) { $this->shouldInclude = $shouldInclude; - $this->template = $template; + $this->template = $template; } public function locateTemplatePath(string $template): string @@ -32,15 +32,14 @@ public function locateTemplatePath(string $template): string return $template; } - /** @var AbstractHelper $helper */ - $helper = sage(AbstractHelper::class); - - $newTemplate = $helper->locateTemplate($this->template); + if (view()->exists($this->template)) { + return view($this->template)->makeLoader(); + } - if (empty($newTemplate)) { - return $template; + if (view()->exists("ItinerisSageFLBuilder::{$this->template}")) { + return view("ItinerisSageFLBuilder::{$this->template}")->makeLoader(); } - return $helper->templatePath($newTemplate); + return $template; } } diff --git a/src/View/Composers/FLBuilder.php b/src/View/Composers/FLBuilder.php new file mode 100644 index 0000000..b917a59 --- /dev/null +++ b/src/View/Composers/FLBuilder.php @@ -0,0 +1,47 @@ +<?php + +declare(strict_types=1); + +namespace Itineris\SageFLBuilder\View\Composers; + +use FLBuilderModel; +use FLThemeBuilderLayoutData; +use Roots\Acorn\View\Composer; + +class FLBuilder extends Composer +{ + /** + * List of views served by this composer. + */ + protected static $views = [ + 'fl-builder-archive', + 'fl-builder-single', + 'ItinerisSageFLBuilder::fl-builder-archive', + 'ItinerisSageFLBuilder::fl-builder-single', + ]; + + protected function getPostId(): int + { + $ids = array_map('absint', FLThemeBuilderLayoutData::get_current_page_content_ids()); + + if ('fl-theme-layout' === get_post_type() && count($ids) > 1) { + $id = FLBuilderModel::get_post_id(); + } else { + $id = $ids[0] ?? get_the_ID(); + } + + return apply_filters('itineris/sage-flbuilder/themer-layout-id', absint($id)); + } + + /** + * Data to be passed to view before rendering. + * + * @return array + */ + public function with(): array + { + return [ + 'post_id' => $this->getPostId(), + ]; + } +} diff --git a/src/empty.php b/src/empty.php index 32ff58b..956650b 100644 --- a/src/empty.php +++ b/src/empty.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); // This file is empty for `AbstractBladeModule::renderFrontendTemplate`. diff --git a/src/post-grid/filter-bar-event.php b/src/post-grid/filter-bar-event.php deleted file mode 100644 index 337e2b0..0000000 --- a/src/post-grid/filter-bar-event.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Post Type Archive widget. - * Used for displaying various types of content in a consistent manner - * - * @package Fabric - */ - -use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; - -/** @var AbstractHelper $helper */ -$helper = sage(AbstractHelper::class); - -// Show the posts filter. -$post_type = 'event'; -$show_filter = true; -?> -<?php if ('theme' === $settings->layout && $show_filter) : ?> - <section id="fab-search-block" class="filter-form events-filter" data-filter-auto="true"> - <form action="<?php echo esc_url(get_pagenum_link()); ?>" method="get"> - <div class="row"> - <div class="col-xs-12 col-sm-4"> - <?php $helper->taxonomyDropdown('event_category', 'event', 'ec', 'Category'); ?> - </div> - <div class="col-xs-12 col-sm-4"> - <?php $helper->taxonomyDropdown('event_type', 'event', 'et', 'Type'); ?> - </div> - <div class="col-xs-12 col-sm-4"> - <select name="sort" class="form-control"> - <option value="">- Select order -</option> - <option value="future">Future</option> - <option value="past">Past</option> - </select> - </div> - </div> - <div class="events-calendar hidden-xs"> - <div class="input-date"> - <input readonly placeholder="view our events calendar" type="text" class="form-control" - id="lbl-calendar"> - <label class="ico" for="lbl-calendar"><i class="fa fa-calendar"></i></label> - </div><!-- end input-date --> - </div> - </form> - </section> -<?php endif; ?> diff --git a/src/post-grid/filter-bar.php b/src/post-grid/filter-bar.php deleted file mode 100644 index 2473c0e..0000000 --- a/src/post-grid/filter-bar.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * Post Type Archive widget. - * Used for displaying various types of content in a consistent manner - * - * @package Fabric - */ - -use Itineris\SageFLBuilder\AbstractHelper; -use function App\sage; - -/** @var AbstractHelper $helper */ -$helper = sage(AbstractHelper::class); - -// Show the posts filter. -$show_filter = false; -$tax_exists = false; -$post_type = 'main_query' === $settings->data_source ? (get_post_type() ?: 'post') : $settings->post_type; -if ($settings->show_filter) { - // Get the taxonomy name. - $category = ('post' === $post_type) ? 'category' : ('product' === $post_type ? 'product_cat' : $post_type . '_category'); - // Check if the taxonomy exists. - $tax_exists = taxonomy_exists($category); - - // Whether or not to show the filter. - $show_filter = $tax_exists ? true : false; - - // Get the Term ID to filter by from $_GET['cat']. - $term_id = $helper->getCat(true, $category, true); - // Change the category if it is valid. - if (! empty($term_id)) { - $settings->{'tax_' . $post_type . '_' . $category} = $term_id; - } -} -$list_class = 'news'; -if (('job_vacancy' === $post_type || 'volunteer_vacancy' === $post_type) && 'theme' === $settings->layout) { - $list_class = 'jobs'; -} elseif ('team' === $post_type && 'theme' === $settings->layout) { - $list_class = 'team'; -} elseif ('product' === $post_type && 'theme' === $settings->layout) { - $list_class = 'product'; -} -$filter_count = Itineris\SageFLBuilder\God::flGetFilterCount($settings); -if ('post' === $post_type) { - // TODO: `\App\get_posts` only accepts 2 parameters. - $authors = $helper->getPosts('team', '', true); - $filter_count++; -} -if (1 === $filter_count) { - $filter_col = 12; -} elseif (2 === $filter_count) { - $filter_col = 6; -} elseif (3 === $filter_count) { - $filter_col = 6; -} elseif (4 === $filter_count) { - $filter_col = 3; -} -$kw = get_query_var('kw'); -?> -<?php if ('theme' === $settings->layout && $show_filter) : ?> - <section id="fab-search-block" - class="filter-form main-form<?php (! $settings->auto_filter) || ($settings->show_button) && print ' no-labels'; ?>"<?php $settings->auto_filter && print ' data-filter-auto="true"'; ?>> - <form action="<?php echo esc_url(get_pagenum_link()); ?>" method="get" id="searchform"> - <div class="row"> - <?php if ($settings->show_search_filter) : ?> - <div class="col-xs-12 col-sm-<?php echo sanitize_html_class($filter_col); ?>"> - <div class="sfFormBox"> - <div class="sfFieldWrap"> - <input type="text" name="kw" class="sfTxt" - value="<?php echo ! empty($kw) ? esc_attr($kw) : ''; ?>" - placeholder="Enter keywords here..."> - </div> - </div> - </div> - <?php endif; ?> - <?php if (isset($tax_exists) && $tax_exists) : ?> - <div class="col-xs-12 col-sm-<?php echo sanitize_html_class($filter_col); ?>"> - <?php $helper->taxonomyDropdown($category, 'Category', $post_type); ?> - </div> - <?php endif; ?> - <?php if ($settings->show_meta_filters) : ?> - <?php $locations = Itineris\SageFLBuilder\God::flGetLocations($post_type); ?> - <?php if (! empty($locations)) : ?> - <?php $current = get_query_var('location'); ?> - <div class="col-xs-12 col-sm-<?php echo sanitize_html_class($filter_col); ?>"> - <div class="form-group"> - <div class="input-box dropdown-box"> - <select name="vacancy-location" id="location-filter" class="selectpicker"> - <option value="" selected>-- Select location --</option> - <?php foreach ($locations as $key => $location) : ?> - <option value="<?php echo esc_attr($key); ?>"<?php $current === $key && print ' selected'; ?>><?php echo esc_html($location); ?></option> - <?php endforeach; ?> - </select> - </div> - </div> - </div> - <?php endif; ?> - <?php endif; ?> - </div> - <?php if ($settings->show_button) : ?> - <input type="submit" class="btn btn-primary" value="Search"/> - <?php endif; ?> - </form> - </section> - <?php if ($settings->show_cat_desc) : ?> - <div class="filter-description"><?php echo term_description($term_id, $category); ?></div> - <?php endif; ?> -<?php endif; ?> diff --git a/src/post-grid/post-theme-event.php b/src/post-grid/post-theme-event.php deleted file mode 100644 index c00ef05..0000000 --- a/src/post-grid/post-theme-event.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** - * Generic frontend theme template file for Post Grid widget - * - * @package Fabric - */ - -$the_id = get_the_id(); -$the_excerpt = (! empty($summary)) ? $summary : get_the_excerpt(); -$the_date_format = 'default' === $settings->date_format ? get_option('date_format') : $settings->date_format; -$img = has_post_thumbnail() ? get_the_post_thumbnail(null, - 'post-thumb') : wp_get_attachment_image(get_theme_mod('fabric_placeholder_image'), 'post-thumb'); -?> -<div id="post-<?php echo esc_attr($the_id); ?>" <?php post_class('col-xs-6 col-md-3 fl-post-theme-post'); ?> itemscope - itemtype="<?php FLPostGridModule::schema_itemtype(); ?>" role="contentinfo" aria-label="article"> - <a href="<?php the_permalink(); ?>" class="widget-link"> - <?php FLPostGridModule::schema_meta(); ?> - <figure class="event-box"> - <?php if (! empty($img)) : ?> - <div class="img"> - <?php echo $img; ?> - </div> - <?php endif; ?> - <figcaption> - <?php the_title('<h3>', '</h3>'); ?> - <?php if ($settings->show_date) : ?> - <p><?php Itineris\SageFLBuilder\EventDate::echo($settings->date_format); ?></p> - <?php if (get_field('location')['location']) : ?> - <?php echo wpautop(get_field('location')['location']); ?> - <?php endif; ?> - <?php endif; ?> - </figcaption> - </figure> - </a> -</div> diff --git a/src/post-grid/post-theme-product.php b/src/post-grid/post-theme-product.php deleted file mode 100644 index 2844af7..0000000 --- a/src/post-grid/post-theme-product.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -$product = wc_get_product(); -if (! $product) { - return; -} -$title = get_the_title(); -?> - -<li class="products"> - <a href="<?php the_permalink(); ?>"> - <?php echo woocommerce_get_product_thumbnail(); ?> - <h4 class="woocommerce-loop-product__title"><?php echo $title; ?></h4> - <span class="price"> - <ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>3.95</span></ins> - </span> - </a> - <?php echo apply_filters('woocommerce_loop_add_to_cart_link', - sprintf('<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>', - esc_url($product->add_to_cart_url()), - esc_attr(isset($quantity) ? $quantity : 1), - esc_attr($product->get_id()), - esc_attr($product->get_sku()), - esc_attr(isset($class) ? $class : 'button product_type_simple add_to_cart_button ajax_add_to_cart'), - esc_html($product->add_to_cart_text()) - ), - $product); ?> -</li> diff --git a/src/post-grid/post-theme.php b/src/post-grid/post-theme.php deleted file mode 100644 index 8bc0d2a..0000000 --- a/src/post-grid/post-theme.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Generic frontend theme template file for Post Grid widget - * - * @package Fabric - */ - -$post_type = get_post_type_object($settings->post_type); -$the_id = get_the_id(); -$the_excerpt = (! empty($summary)) ? $summary : get_the_excerpt(); -$the_date_format = 'default' === $settings->date_format ? get_option('date_format') : $settings->date_format; -?> -<div id="post-<?php echo esc_attr($the_id); ?>" <?php post_class('col-md-3 col-sm-6'); ?> itemscope - itemtype="<?php FLPostGridModule::schema_itemtype(); ?>" role="contentinfo" aria-label="article"> - - <a href="<?php the_permalink(); ?>" class="news-box"> - - <?php FLPostGridModule::schema_meta(); ?> - - <figure> - - <div class="img"> - <?php - if (has_post_thumbnail()) { - the_post_thumbnail(); - } else { - echo wp_get_attachment_image(get_theme_mod('fabric_placeholder_image'), 'post-thumbnail'); - } - ?> - </div> - - <figcaption> - - <?php if ($settings->show_date) : ?> - <span class="date"><?php echo FLBuilderLoop::post_date($settings->date_format); ?></span> - <?php endif; ?> - - <?php the_title('<h3 class="entry-title" itemprop="headline">', '</h3>'); ?> - - </figcaption> - - </figure> - - </a> - -</div>