mirror of
https://github.com/jgonyea/grav-plugin-podcast.git
synced 2025-12-05 16:00:02 +01:00
Fixed missing date field in frontmatter. Removed auto-date dependency
This commit is contained in:
@@ -27,7 +27,7 @@ You should now have all the plugin files under
|
||||
> NOTE: This plugin is a modular component for Grav which requires the following to operate:
|
||||
* [Grav Core](http://github.com/getgrav/grav)
|
||||
* [Admin](https://github.com/getgrav/grav-plugin-admin)
|
||||
* [Auto Date](https://github.com/getgrav/grav-plugin-auto-date)
|
||||
* [Breadcrumbs](https://github.com/getgrav/grav-plugin-breadcrumbs)
|
||||
* [Feed](https://github.com/getgrav/grav-plugin-feed)
|
||||
* [GetId3](https://github.com/jgonyea/grav-plugin-get-id3), along with its accompanying [getID3 php library](http://www.getid3.org/)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ license: MIT
|
||||
|
||||
dependencies:
|
||||
- admin
|
||||
- auto-date
|
||||
- breadcrumbs
|
||||
- feed
|
||||
- get-id3
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ en:
|
||||
MAX_UPLOAD_HELP: 'Set "upload_max_filesize" and "post_max_size" in php.ini to at least this value or higher.'
|
||||
PODCAST: Podcast Channel
|
||||
SERIES: Podcast Series
|
||||
|
||||
SERIES_CONTENT:
|
||||
HEADER: Series Description
|
||||
EPISODE_CONTENT:
|
||||
HEADER: Episode Content
|
||||
DOWNLOAD: Download Audio
|
||||
|
||||
17
podcast.php
17
podcast.php
@@ -82,13 +82,26 @@ class PodcastPlugin extends Plugin
|
||||
public function onAdminSave($event)
|
||||
{
|
||||
$obj = $event['object'];
|
||||
// Process only podcast episodes page types.
|
||||
// Process only podcast-* page types.
|
||||
$obj_class = get_class($obj);
|
||||
if (($obj_class != 'Grav\Common\Page\Page' && $obj_class != 'Grav\Common\Flex\Types\Pages\PageObject') || $obj->template() != 'podcast-episode') {
|
||||
if (($obj_class != 'Grav\Common\Page\Page' && $obj_class != 'Grav\Common\Flex\Types\Pages\PageObject')){
|
||||
return;
|
||||
}
|
||||
$header = $obj->header();
|
||||
|
||||
// Set auto dates on all podcast-* page types.
|
||||
if ( str_starts_with($obj->template(), 'podcast-') && !isset($header->date)) {
|
||||
$date = date($this->grav['config']->get('system.pages.dateformat.default', 'H:i d-m-Y'));
|
||||
$header['date'] = $date;
|
||||
}
|
||||
|
||||
// Return with just auto-date updated field if not podcast-episode.
|
||||
if ($obj->template() != 'podcast-episode') {
|
||||
$new_header = $header->toArray();
|
||||
$obj->header($new_header);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use local file for meta calculations, if present.
|
||||
// Else, use remote file for meta, if present.
|
||||
// Else, cleanup media entry in markdown header.
|
||||
|
||||
Reference in New Issue
Block a user