File tree Expand file tree Collapse file tree 7 files changed +45
-26
lines changed
Expand file tree Collapse file tree 7 files changed +45
-26
lines changed Original file line number Diff line number Diff line change 4141 'change_frequency ' => 'Sitemap: Updatefrequentie ' ,
4242 'change_frequency_instruct ' => 'Een instructie voor zoekmachines over hoe vaak de pagina waarschijnlijk geüpdatet zal worden. ' ,
4343
44- ];
44+ ];
Original file line number Diff line number Diff line change 6666 'three_segment_urls_site_warning ' => ':count pagina met meer dan 3 segmenten in de URL.|:count pagina \'s met meer dan 3 segmenten in hun URL \'s. ' ,
6767 ],
6868
69- ];
69+ ];
Original file line number Diff line number Diff line change 33namespace Statamic \SeoPro ;
44
55use Statamic \Assets \Asset ;
6+ use Statamic \Facades \Blink ;
7+ use Statamic \Statamic ;
68
79class Fields
810{
@@ -241,15 +243,23 @@ public function getConfig()
241243 */
242244 protected function getPlaceholder ($ handle )
243245 {
244- $ cascade = (new Cascade )->with (SiteDefaults::load ()->all ());
245-
246- if ($ this ->data ) {
247- $ cascade = $ cascade
248- ->with ($ this ->getSectionDefaults ($ this ->data ))
249- ->with ($ this ->data ->value ('seo ' , []))
250- ->withCurrent ($ this ->data );
246+ if (! Statamic::isCpRoute ()) {
247+ return null ;
251248 }
252249
250+ $ cascade = Blink::once ('seo-pro::placeholder.cascade ' , function () {
251+ $ cascade = (new Cascade )->with (SiteDefaults::load ()->all ());
252+
253+ if ($ this ->data ) {
254+ $ cascade = $ cascade
255+ ->with ($ this ->getSectionDefaults ($ this ->data ))
256+ ->with ($ this ->data ->value ('seo ' , []))
257+ ->withCurrent ($ this ->data );
258+ }
259+
260+ return $ cascade ;
261+ });
262+
253263 $ placeholder = $ cascade ->value ($ handle );
254264
255265 if (is_array ($ placeholder )) {
Original file line number Diff line number Diff line change @@ -53,16 +53,18 @@ protected function fields()
5353
5454 protected function fieldConfig ()
5555 {
56- if ($ this ->field ()->parent () instanceof Entry || $ this ->field ()->parent () instanceof Term) {
57- $ parent = $ this ->field ()->parent ();
56+ $ parent = $ this ->field ()->parent ();
57+
58+ if (! ($ parent instanceof Entry || $ parent instanceof Term)) {
59+ $ parent = null ;
5860 }
5961
6062 return SeoProFields::new ($ parent ?? null )->getConfig ();
6163 }
6264
6365 public function augment ($ data )
6466 {
65- if (! is_iterable ($ data )) {
67+ if (empty ( $ data ) || ! is_iterable ($ data )) {
6668 return $ data ;
6769 }
6870
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ public function augment($data)
9393 return $ data ;
9494 }
9595
96- $ fieldtype = $ this ->sourceField ()-> fieldtype ();
96+ $ fieldtype = $ this ->fieldtype ();
9797
9898 if ($ data === false ) {
9999 $ data = $ fieldtype ->defaultValue ();
@@ -105,7 +105,7 @@ public function augment($data)
105105 protected function sourceField ()
106106 {
107107 if (! $ config = $ this ->config ('field ' )) {
108- return null ;
108+ return ;
109109 }
110110
111111 return new Field (null , $ config );
Original file line number Diff line number Diff line change @@ -27,15 +27,17 @@ public function getAugmentedSectionDefaults($current)
2727 return [];
2828 }
2929
30- return Blueprint::make ()
31- ->setContents ([
32- 'fields ' => Fields::new ()->getConfig (),
33- ])
34- ->fields ()
35- ->addValues ($ seo = $ parent ->cascade ('seo ' ) ?: [])
36- ->augment ()
37- ->values ()
38- ->only (array_keys ($ seo ));
30+ return Blink::once ($ this ->getCacheKey ($ parent ).'.augmented ' , function () use ($ parent ) {
31+ return Blueprint::make ()
32+ ->setContents ([
33+ 'fields ' => Fields::new ()->getConfig (),
34+ ])
35+ ->fields ()
36+ ->addValues ($ seo = $ parent ->cascade ('seo ' ) ?: [])
37+ ->augment ()
38+ ->values ()
39+ ->only (array_keys ($ seo ));
40+ });
3941 }
4042
4143 protected function getCacheKey ($ parent )
Original file line number Diff line number Diff line change 33namespace Statamic \SeoPro ;
44
55use Illuminate \Support \Collection ;
6+ use Statamic \Facades \Blink ;
67use Statamic \Facades \Blueprint ;
78use Statamic \Facades \File ;
89use Statamic \Facades \YAML ;
@@ -73,6 +74,8 @@ public function save()
7374 File::put ($ this ->path (), YAML ::dump ($ this ->items ));
7475
7576 SeoProSiteDefaultsSaved::dispatch ($ this );
77+
78+ Blink::forget ('seo-pro::defaults ' );
7679 }
7780
7881 /**
@@ -82,9 +85,11 @@ public function save()
8285 */
8386 protected function getDefaults ()
8487 {
85- return collect (YAML ::file (__DIR__ .'/../content/seo.yaml ' )->parse ())
86- ->merge (YAML ::file ($ this ->path ())->parse ())
87- ->all ();
88+ return Blink::once ('seo-pro::defaults ' , function () {
89+ return collect (YAML ::file (__DIR__ .'/../content/seo.yaml ' )->parse ())
90+ ->merge (YAML ::file ($ this ->path ())->parse ())
91+ ->all ();
92+ });
8893 }
8994
9095 /**
You can’t perform that action at this time.
0 commit comments