//////////////////////////////////////////////// //Make WP AJAX Edit Comments disable editing on posts with closed comments AND play nice with Comment Timeout //////////////////////////////////////////////// //////////////////// //Comment Timeout - comment-timeout.php //////////////////// //(...) //Right at the end //This creates a new function get_post_CT, to be called instead of get_post, that returns the correct value of $post->comment_status //NEW CODE STARTS function get_post_CT($postID) { return jmct_Core::get_instance()->process_posts( get_post($postID) ); } //NEW CODE ENDS //////////////////// //WP AJAX Edit Comments - wp-ajax-edit-comments.php //////////////////// //Right at the start, after plugin metadata //If get_post_CT doesn't exist, we fall back to get_post so that nothing breaks //NEW CODE STARTS if (!function_exists("get_post_CT")) { function get_post_CT($postID) { return get_post($postID); } } //NEW CODE ENDS //(...) function add_edit_links($content) { global $comment; //If comments are closed we don't add the AEC links and functions to the comments //NEW CODE STARTS if ('open' != get_post_CT($comment->comment_post_ID)->comment_status) { return $content; } //NEW CODE ENDS //(...) function can_edit($commentID = 0, $postID = 0) { global $wpdb; //If the page was already open before the comments closed and the AEC interface loaded before the comments were closed, this prevents the changes from being submitted //NEW CODE STARTS if ('open' != get_post_CT($postID)->comment_status) { return 'no_editing_on_closed_comments'; } //NEW CODE ENDS //(...) //////////////////// //WP AJAX Edit Comments - php/AjaxEditComments.php //////////////////// //(...) } elseif ($action == "editcomment") { //NEW CODE STARTS //If the page was already open before the comments closed this prevents the AEC interface from loading te previous content if ('open' != get_post_CT($postID)->comment_status) { die(''); } //NEW CODE ENDS //(...)