Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
fix(Components): load layout component assets only when necessary (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doğa Gürdal committed Nov 2, 2018
1 parent 4cfe9d5 commit 246a8f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Components/LayoutMultiplePosts/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Timber\Timber;
use Flynt\Features\Components\Component;

add_action('wp_enqueue_scripts', function () {
Component::enqueueAssets('LayoutMultiplePosts');
});

add_filter('Flynt/addComponentData?name=LayoutMultiplePosts', function ($data) {
add_action('wp_enqueue_scripts', function () {
Component::enqueueAssets('LayoutMultiplePosts');
});

$query = !empty($data['query']) ? $data['query'] : false;
$posts = Timber::get_posts($query);
if (!empty($posts)) {
Expand Down
8 changes: 4 additions & 4 deletions Components/LayoutSinglePost/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Timber\Timber;
use Flynt\Features\Components\Component;

add_action('wp_enqueue_scripts', function () {
Component::enqueueAssets('LayoutSinglePost');
});

add_filter('Flynt/addComponentData?name=LayoutSinglePost', function ($data) {
add_action('wp_enqueue_scripts', function () {
Component::enqueueAssets('LayoutSinglePost');
});

$query = !empty($data['query']) ? $data['query'] : false;
$post = Timber::get_post($query);
if (!empty($post)) {
Expand Down

0 comments on commit 246a8f9

Please sign in to comment.