-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make plugin compatible with Kirby 2.2
This version of the plugin is only compatible with Kirby 2.2, to use it with Kirby 2.1 use the previous version (1.1)
- Loading branch information
1 parent
e2d1c42
commit fc29343
Showing
3 changed files
with
18 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
<?php | ||
|
||
kirby()->hook('panel.page.create', function($page) { | ||
$templates = c::get('autopublish.templates', false); | ||
kirby()->hook('panel.page.create', 'run'); | ||
|
||
function run( $page ) { | ||
$templates = c::get('autopublish.templates', array('project', 'item')); | ||
if (!$templates || in_array($page->template(), $templates)) { | ||
$parent = $page->parent(); | ||
$subpages = new Subpages($parent); | ||
try { | ||
$num = $subpages->sort($page, 'last'); | ||
return response::success('The page has been sorted', array( | ||
'num' => $num | ||
)); | ||
$page->toggle('last'); | ||
} catch(Exception $e) { | ||
return response::error($e->getMessage()); | ||
} | ||
} | ||
}); | ||
} |