The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Guest Cookie and Co...
 
Share:
Notifications
Clear all

Question Guest Cookie and Comment Editing Duration

3 Posts
2 Users
1 Reactions
80 Views
Posts: 2
Topic starter
(@baboli)
New Member
Joined: 2 months ago

Hi. Thanks again for this awesome plugin. In the plugin settings, we can set the cookie for guests to a minimum of 1 day. For comment editing, we can also set a minimum of 15 minutes. I want to change both of them. I want to reduce the comment editing time to 5 minutes and the cookie duration for guests to 6 minutes. How can I do this?

2 Replies
Asti
Posts: 7802
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi,

You can use the wpdiscuz_is_comment_editable filter to control the comment editing time.

The cookie duration can be controlled using the wpdiscuz_js_options filter. Look for the storeCommenterData key within the options.

Reply
Posts: 2
Topic starter
(@baboli)
New Member
Joined: 2 months ago

Even though it appears to be working properly, I wanted to add the snippets I applied here and show them to you as well. This way, I want to make sure I'm not breaking anything.

It sets the cookies to 6 minutes. storeCommenterData doesn't accept minutes or hours so:

add_action('wp_print_footer_scripts', 'my_override_cookies_set', 9999);
function my_override_cookies_set() {
?>
<script>
(function() {
if (typeof Cookies === 'undefined') {
return;
}

var originalCookiesSet = Cookies.set;

Cookies.set = function(name, value, options) {
if (name && name.indexOf('comment_author_') > -1) {
if (!options) {
options = {};
}
options.expires = 6 / (60 * 24);
}
return originalCookiesSet.call(this, name, value, options);
};
})();
</script>
<?php
}

It reduces the comment editing time to 5 minutes:

add_filter('wpdiscuz_is_comment_editable', 'my_wpdiscuz_custom_edit_time', 10, 3);

function my_wpdiscuz_custom_edit_time($isCommentEditable, $comment, $editing_time = null) {
if (is_null($editing_time)) {
$editing_time = 5;
}

$editing_time = 5;

$comment_time_gmt = strtotime($comment->comment_date_gmt);
$now_gmt = current_time('timestamp', true);
$diff_in_minutes = ($now_gmt - $comment_time_gmt) / 60;

if ($diff_in_minutes < $editing_time) {
return true;
} else {
return false;
}
}

Just fyi: Apart from these, every time a comment is edited, the debug.log displays the following warning:

PHP Warning: Undefined array key "comment_agent" in /*****/******/public_html/wp/wp-includes/comment.php on line ...
Reply
Share: