File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 11<?php
22
33use Kirby \Cms \Page ;
4+ use Kirby \Toolkit \A ;
45use Kirby \Toolkit \Str ;
56
67return [
78 'page.update:after ' => function (Page $ newPage , Page $ oldPage ) {
8- foreach ($ newPage ->kirby ()->option ('tobimori.seo.robots.types ' ) as $ robots ) {
9- $ upper = Str::ucfirst ($ robots );
10- if ($ newPage ->content ()->get ("robots {$ upper }" )->value () === "" ) {
11- $ newPage = $ newPage ->update ([
12- "robots {$ upper }" => 'default '
13- ]);
14- }
15- }
9+ $ updates = A::reduce (
10+ $ newPage ->kirby ()->option ('tobimori.seo.robots.types ' ),
11+ function ($ carry , $ robots ) use ($ newPage ) {
12+ $ upper = Str::ucfirst ($ robots );
13+
14+ if ($ newPage ->content ()->get ("robots {$ upper }" )->value () === '' ) {
15+ $ carry ["robots {$ upper }" ] = 'default ' ;
16+ }
17+
18+ return $ carry ;
19+ },
20+ []
21+ );
22+
23+ $ newPage = $ newPage ->update ($ updates );
24+
25+ return $ newPage ;
1626 },
1727 'page.render:before ' => function (string $ contentType , array $ data , Page $ page ) {
1828 if (!class_exists ('Spatie\SchemaOrg\Schema ' )) {
You can’t perform that action at this time.
0 commit comments