Local lables in themes, comments functions improvements.

This commit is contained in:
Emidio Reggiani 2026-01-14 09:11:32 +01:00
commit 8f1d51764b
5 changed files with 35 additions and 12 deletions

View file

@ -428,5 +428,3 @@ sysmsg_subscribe_success = "Your will receive now new comment notifications on t
sysmsg_subscribe_fail = "Something went wrong during subscription verification process."
sysmsg_unsubscribe_success = "You have successfully unsubscribed from notification emails."
sysmsg_unsubscribe_fail = "Something wrong during unsubscription process"
codebtn_copy = "Copy"
codebtn_copied = "Copied!"

View file

@ -2025,6 +2025,13 @@ function delete_comments($mdfile) {
// regardless if file is content .md file or comments .json file
function get_url_from_file($file)
{
// Ensure config is loaded - if not loads it
$config_loaded = config('permalink.type');
if (!$config_loaded) {
if (file_exists('config/config.ini')) {
config('source', 'config/config.ini');
}
}
// Normalize path separators (Windows/Linux))
$file = str_replace('\\', '/', $file);
@ -2096,9 +2103,6 @@ function get_url_from_file($file)
// return site_url() . $slug;
}
// Check if it's a blog post: {username}/blog/{category}/{type}/[scheduled/]{date}_{tags}_{slug}.md
if (count($parts) >= 5 && $parts[1] == 'blog') {
$filename_parts = explode('_', pathinfo($basename, PATHINFO_FILENAME));

View file

@ -61,8 +61,8 @@
<?php endif; ?>
</td>
<td>
<a href="<?php echo site_url() . get_url_from_file($comment['file']); ?>" target="_blank">
<?php echo _h(get_url_from_file($comment['file'])); ?>
<a href="<?php echo site_url() . $comment['url']; ?>" target="_blank">
<?php echo _h($comment['url']); ?>
</a>
</td>
<td>

View file

@ -213,9 +213,6 @@ function get_comments_file_from_url($url) {
}
/**
* Get all comments for a post/page
*
@ -283,11 +280,12 @@ function getAllComments($page = null, $perpage = null)
$allComments = array();
foreach ($files as $file) {
$comments = getComments('', $file, true);
$url = get_url_from_file($file);
foreach ($comments as $comment) {
$comment['file'] = $file;
$comment['url'] = $url;
$allComments[] = $comment;
}
}
@ -308,6 +306,22 @@ function getAllComments($page = null, $perpage = null)
return $allComments;
}
function getPublishedComments($limit = 5)
{
$comments = array();
$counter = 0;
$allComments = getAllComments();
foreach ($allComments as $comment) {
if ($comment['published'] == 1) {
$comments[] = $comment;
}
if (count($comments) >= $limit) break;
}
return $comments;
}
/**
* Generate unique comment ID
*
@ -702,7 +716,7 @@ function commentPublish($file, $commentId)
if ($comment['id'] === $commentId) {
$comment['published'] = true;
$updated = true;
$url = get_url_from_file($file);
// Send notifications only to subscribers when publishing (admin already saw it in moderation)

View file

@ -90,6 +90,13 @@ function i18n($key, $value = null)
$_i18n = parse_ini_file($value, true);
else
$_i18n = parse_ini_file('lang/en_US.ini', true);
$theme_path = parse_url(theme_path(), PHP_URL_PATH);
$theme_lang_file = $_SERVER['DOCUMENT_ROOT'] . $theme_path . 'lang/en_US.ini';
$_i18n_local = array();
if (file_exists($theme_lang_file)) {
$_i18n_local = parse_ini_file($theme_lang_file, true);
}
$_i18n = array_replace($_i18n, $_i18n_local);
} elseif ($value == null)
return (isset($_i18n[$key]) ? $_i18n[$key] : $key);
else