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 @@
+
+
+
+
+
+
+ @php wp_head(); @endphp
+
+
+
+ @php wp_body_open(); @endphp
+ @php do_action('get_header'); @endphp
+
+
+ @include('layouts.app')
+
+
+ @php do_action('get_footer'); @endphp
+ @php wp_footer(); @endphp
+
+
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 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 @@
- $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);
?>
link) && ! empty($settings->text)) : ?>
text); ?>
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 @@
+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 @@
-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 @@
- [
- '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 @@
-layout) {
- return;
- }
-
- $postType = get_post_type() ?: $settings->post_type;
-
- if ('product' === $postType) {
- echo '';
- }
- }
-
- 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 '