RSS Description config option added

Gives the admin the config option to choose to replace the RSS description value with Meta Description instead of Body (default is the current setting of body, if nothing is selected defaults to body).
This commit is contained in:
KuJoe 2024-09-12 22:56:11 -04:00
commit 32388b2a37
4 changed files with 38 additions and 7 deletions

View file

@ -317,4 +317,7 @@ msg_error_field_req_video = "Video field is required."
msg_error_field_req_link = "Link field is required."
msg_error_field_req_quote = "Quote field is required."
msg_error_field_req_audio = "Audio field is required."
msg_error_field_req_feedurl = "You need to specify the feed url."
msg_error_field_req_feedurl = "You need to specify the feed url."
rss_feeds_description_select = "RSS Description"
rss_description_body = "Post Body"
rss_description_meta = "Post Meta Description"

View file

@ -27,7 +27,7 @@
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-static.frontpage" id="static.frontpage1" value="true" <?php if (config('static.frontpage') === 'true'):?>checked<?php endif;?>>
<input class="form-check-input" type="radio" name="-config-static.frontpage" id="static.frontpage2" value="true" <?php if (config('static.frontpage') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="static.frontpage2">
<?php echo i18n('Static_page');?>
</label>
@ -134,6 +134,25 @@
<br>
<h4><?php echo i18n('RSS_settings');?></h4>
<hr>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('RSS_feeds_description_select');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-rss.description" id="rss.description1" value="body" <?php if (config('rss.description') === 'body'):?>checked<?php endif;?>>
<label class="form-check-label" for="rss.description1">
<?php echo i18n('RSS_description_body');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-rss.description" id="rss.description2" value="meta" <?php if (config('rss.description') === 'meta'):?>checked<?php endif;?>>
<label class="form-check-label" for="rss.description2">
<?php echo i18n('RSS_description_meta');?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="rss.count" class="col-sm-2 col-form-label"><?php echo i18n('RSS_feeds_show_the_most_recent');?></label>
<div class="col-sm-10">

View file

@ -92,5 +92,6 @@
"autosave.enable",
"mfa.state",
"show.version",
"thumbnail.width"
"thumbnail.width",
"rss.description"
]

View file

@ -2992,6 +2992,7 @@ function generate_rss($posts, $data = null)
$channel = new Channel();
$rssLength = config('rss.char');
$data = $data;
$rssDesc = config('rss.description');
if (is_null($data)) {
$channel
@ -3009,12 +3010,19 @@ function generate_rss($posts, $data = null)
if ($posts) {
foreach ($posts as $p) {
$img = get_image($p->body);
if (!empty($rssLength)) {
$body = shorten($p->body, $rssLength);
if ($rssDesc == "meta") {
if (!empty($rssLength)) {
$body = shorten($p->description, $rssLength);
} else {
$body = $p->description;
}
} else {
$body = $p->body;
if (!empty($rssLength)) {
$body = shorten($p->body, $rssLength);
} else {
$body = $p->body;
}
}
$item = new Item();
$item
->category(strip_tags($p->category));