Created
July 22, 2016 15:29
-
-
Save PhrozenByte/c4eeb451eed175110dc0f9d79f2c98bd to your computer and use it in GitHub Desktop.
This is a example of a "Drafts" plugin for Pico. Pico is a stupidly simple, blazing fast, flat file CMS. http://picocms.org/
This file contains hidden or 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
<?php | |
/** | |
* Pico Drafts Plugin (example) | |
* | |
* This is a example of a "Drafts" plugin for Pico's documentation. | |
* Pico is a stupidly simple, blazing fast, flat file CMS. | |
* | |
* This example plugin basically just removes all pages starting with a `_` | |
* from Pico's page list. The page will not show up anywhere, however, you | |
* can still access it by manually navigating to the corresponding URL. | |
* | |
* @author Daniel Rudolf | |
* @link http://picocms.org | |
* @license http://opensource.org/licenses/MIT The MIT License | |
*/ | |
class PicoDrafts extends AbstractPicoPlugin | |
{ | |
public function onPagesLoaded(array &$pages) | |
{ | |
foreach ($pages as $pageId => $pageData) { | |
$fileName = basename($pageData['id']); | |
if ($fileName[0] === '_') { | |
unset($pages[$pageId]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment