diff --git a/lang/en_US.ini b/lang/en_US.ini
index fbe88a37..2fab0130 100644
--- a/lang/en_US.ini
+++ b/lang/en_US.ini
@@ -321,3 +321,6 @@ 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"
+comment_state = "Comments Status"
+comments_enabled = "Enabled"
+comments_disabled = "Disabled"
\ No newline at end of file
diff --git a/system/admin/admin.php b/system/admin/admin.php
index bf11de3b..a6e6057b 100644
--- a/system/admin/admin.php
+++ b/system/admin/admin.php
@@ -120,7 +120,7 @@ function remove_accent($str)
}
// Add content
-function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null, $autoSave = null)
+function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $comments, $description = null, $media = null, $dateTime = null, $autoSave = null)
{
if (!is_null($autoSave)) {
$draft = 'draft';
@@ -213,12 +213,17 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
} else {
$tagmd = "";
}
- if ($media!== null) {
- $post_media = "\n";
+ if ($media !== null) {
+ $post_media = "\n";
} else {
$post_media = "";
}
- $post_content = "" . $post_description . $tagmd . $post_media . "\n\n" . $content;
+ if ($comments == "false") {
+ $comment = "\n";
+ } else {
+ $comment = "";
+ }
+ $post_content = "" . $post_description . $tagmd . $comment . $post_media . "\n\n" . $content;
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
@@ -273,7 +278,7 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
}
// Edit content
-function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null, $autoSave = null)
+function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $comments, $destination = null, $description = null, $date = null, $media = null, $autoSave = null)
{
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
$tag = array_filter(array_unique($tag));
@@ -363,7 +368,12 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
} else {
$post_media = "";
}
- $post_content = "" . $post_description . $tagmd . $post_media . "\n\n" . $content;
+ if ($comments == "false") {
+ $comment = "\n";
+ } else {
+ $comment = "";
+ }
+ $post_content = "" . $post_description . $tagmd . $comment . $post_media . "\n\n" . $content;
$dirBlog = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/' . $type . '/';
$dirDraft = $dir[0] . '/' . $dir[1] . '/' . $dir[2] . '/' . $category . '/draft/';
diff --git a/system/admin/views/add-content.html.php b/system/admin/views/add-content.html.php
index f468d039..37caaec0 100644
--- a/system/admin/views/add-content.html.php
+++ b/system/admin/views/add-content.html.php
@@ -109,6 +109,12 @@ function extractLast( term ) {
+
+
+
diff --git a/system/admin/views/edit-content.html.php b/system/admin/views/edit-content.html.php
index 22a2bc50..12e230aa 100644
--- a/system/admin/views/edit-content.html.php
+++ b/system/admin/views/edit-content.html.php
@@ -14,6 +14,7 @@
$oldtitle = get_content_tag('t', $content, 'Untitled');
$olddescription = get_content_tag('d', $content);
$oldtag = get_content_tag('tag', $content);
+$oldcomment = check_comments_state($content);
$oldcontent = remove_html_comments($content);
$oldimage = get_content_tag('image', $content);
@@ -155,6 +156,12 @@ function extractLast( term ) {
+
+
+
diff --git a/system/htmly.php b/system/htmly.php
index 49146681..59ad3878 100644
--- a/system/htmly.php
+++ b/system/htmly.php
@@ -722,6 +722,7 @@
$category = from($_REQUEST, 'category');
$date = from($_REQUEST, 'date');
$time = from($_REQUEST, 'time');
+ $comments = from($_REQUEST, 'comments');
$dateTime = null;
if ($date !== null && $time !== null) {
$dateTime = $date . ' ' . $time;
@@ -736,17 +737,17 @@
}
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
- add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime);
+ add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime, $comments);
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
- add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime);
+ add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime, $comments);
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
- add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime);
+ add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime, $comments);
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
- add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime);
+ add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime, $comments);
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
- add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime);
+ add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime, $comments);
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
- add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime);
+ add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime, $comments);
} else {
$message['error'] = '';
if (empty($title)) {
@@ -799,6 +800,7 @@
'postAudio' => $audio,
'postTag' => $tag,
'postUrl' => $url,
+ 'postComments' => $comments,
'postContent' => $content,
'type' => $type,
'is_admin' => true,
@@ -914,6 +916,7 @@
$addEdit = $_REQUEST['addEdit'];
$user = $_SESSION[site_url()]['user'];
$role = user('role', $user);
+ $comments = $_REQUEST['comments'];
if (empty($url)) {
$url = $title;
@@ -971,11 +974,11 @@
if (!empty($title) && !empty($tag) && !empty($content)) {
if ($addEdit == 'add') {
- $response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave);
+ $response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave, $comments);
} else {
$arr = explode('/', $oldfile);
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
- $response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave);
+ $response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave, $comments);
}
}
}
@@ -3706,6 +3709,7 @@
$description = from($_REQUEST, 'description');
$date = from($_REQUEST, 'date');
$time = from($_REQUEST, 'time');
+ $comments = from($_REQUEST, 'comments');
$dateTime = null;
$revertPost = from($_REQUEST, 'revertpost');
$publishDraft = from($_REQUEST, 'publishdraft');
@@ -3738,27 +3742,27 @@
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $comments, $destination, $description, $dateTime, $image);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $comments, $destination, $description, $dateTime, $video);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $comments, $destination, $description, $dateTime, $link);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $comments, $destination, $description, $dateTime, $quote);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $comments, $destination, $description, $dateTime, $audio);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $comments, $destination, $description, $dateTime, null);
} else {
$message['error'] = '';
@@ -3816,6 +3820,7 @@
'postUrl' => $url,
'type' => $type,
'is_admin' => true,
+ 'postComments' => $comments,
'postContent' => $content,
'bodyclass' => 'edit-post',
'breadcrumb' => '
' . config('breadcrumb.home') . ' » ' . i18n('Edit_content')
@@ -4889,6 +4894,7 @@
$description = from($_REQUEST, 'description');
$date = from($_REQUEST, 'date');
$time = from($_REQUEST, 'time');
+ $comments = $_REQUEST['comments'];
$dateTime = null;
$revertPost = from($_REQUEST, 'revertpost');
$publishDraft = from($_REQUEST, 'publishdraft');
@@ -4922,27 +4928,27 @@
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $comments, $destination, $description, $dateTime, $image);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $comments, $destination, $description, $dateTime, $video);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $comments, $destination, $description, $dateTime, $link);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $comments, $destination, $description, $dateTime, $quote);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $comments, $destination, $description, $dateTime, $audio);
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
- edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
+ edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $comments, $destination, $description, $dateTime, null);
} else {
$message['error'] = '';
@@ -5000,6 +5006,7 @@
'postUrl' => $url,
'type' => $type,
'postContent' => $content,
+ 'postComments' => $comments,
'is_admin' => true,
'bodyclass' => 'edit-post',
'breadcrumb' => '
' . config('breadcrumb.home') . ' » ' . $title
diff --git a/system/includes/functions.php b/system/includes/functions.php
index 70262040..7e789270 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -3720,10 +3720,17 @@ function get_content_tag($tag, $string, $alt = null)
return $alt;
}
+// Check if comments are disabled inside the markdown files (true = disabled)
+function check_comments_state($content)
+{
+ $tag = '';
+ return strpos($content, $tag) !== false ? "false" : "true";
+}
+
// Strip html comment
function remove_html_comments($content)
{
- $patterns = array('/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/');
+ $patterns = array('/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/', '/(\s|)(\s|)/');
return preg_replace($patterns, '', $content);
}
diff --git a/themes/doks/post.html.php b/themes/doks/post.html.php
index 3e31f06f..5428a1fd 100644
--- a/themes/doks/post.html.php
+++ b/themes/doks/post.html.php
@@ -68,7 +68,6 @@
-
title, $post->url) ?>
diff --git a/themes/twentysixteen/post.html.php b/themes/twentysixteen/post.html.php
index 033dc19a..f055c045 100644
--- a/themes/twentysixteen/post.html.php
+++ b/themes/twentysixteen/post.html.php
@@ -70,7 +70,6 @@
-
title, $p->url) ?>
@@ -93,7 +92,7 @@
-
+