Skip to content

Commit d492a70

Browse files
author
vishalkakadiya
committed
Update readme and add screenshots
1 parent d8b8206 commit d492a70

7 files changed

+38
-7
lines changed

README.md

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1-
# WP Comment Preview - (In Progress)
2-
Plugin for WordPress Comment Preview
1+
# WP Comment Preview
32

43
[![Build Status](https://app.travis-ci.com/vishalkakadiya/comment-preview.svg?branch=main)](https://app.travis-ci.com/vishalkakadiya/comment-preview)
54
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/vishalkakadiya/comment-preview/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/vishalkakadiya/comment-preview/?branch=main)
65
[![Code Coverage](https://scrutinizer-ci.com/g/vishalkakadiya/comment-preview/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/vishalkakadiya/comment-preview/?branch=main)
6+
7+
This plugin will show real comment preview to the users, it's also supporting jetpack's markdown.
8+
9+
#### Steps to configure this plugin in your site:
10+
11+
- Activate jetpack's markdown module.
12+
- ![Activate Jetpack's markdown module](https://github.com/vishalkakadiya/comment-preview/tree/main/screenshots/enable-jetpack-markdown.png)
13+
14+
- Activate jetpack markdown for comments settings.
15+
- ![Activate jetpack markdown for comments settings](https://github.com/vishalkakadiya/comment-preview/tree/main/screenshots/enable-markdown-for-comments.png)
16+
17+
- Activate comment preview plugin now.
18+
- ![Activate comment preview plugin](https://github.com/vishalkakadiya/comment-preview/tree/main/screenshots/enable-comment-preview-plugin.png)
19+
20+
- Comment's form and preview of comment.
21+
- ![Comment's form and preview of comment](https://github.com/vishalkakadiya/comment-preview/tree/main/screenshots/working-comment-preview.png)
22+
23+
#### Support for Custom Post Type?
24+
25+
Yes, this plugin is giving support for custom post types, for that you can use below filter.
26+
- `wp_comment_preview_allowed_post_types`: Returning array of post types will support those post types.
27+
28+
**NOTE:** This plugin works with WordPress's default comment form only.
29+
30+
#### Available Endpoint
31+
32+
**Get single post ( POST request )**
33+
- http://example.com/wp-json/wp_comment_preview/v1/preview
34+
- Params:
35+
- `comment` - Comment text.
36+
- `format` - Whether to preview markdown or plain text - Two values it will take `plain` OR `markdown`.
37+
- `author` - For non-logged in user you can send author's name here, logged-in users will automatically get their name in that comment.

clover.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<coverage generated="1632933931">
3-
<project timestamp="1632933931">
2+
<coverage generated="1632940952">
3+
<project timestamp="1632940952">
44
<package name="CommentPreview\Inc">
55
<file name="/var/www/app/inc/classes/class-comment-preview.php">
66
<class name="CommentPreview\Inc\Comment_Preview" namespace="CommentPreview\Inc" fullPackage="CommentPreview" package="CommentPreview">
7-
<metrics complexity="17" methods="8" coveredmethods="8" conditionals="0" coveredconditionals="0" statements="58" coveredstatements="58" elements="66" coveredelements="66"/>
7+
<metrics complexity="18" methods="8" coveredmethods="8" conditionals="0" coveredconditionals="0" statements="58" coveredstatements="58" elements="66" coveredelements="66"/>
88
</class>
99
<line num="20" type="method" name="__construct" visibility="public" complexity="1" crap="1" count="10"/>
1010
<line num="22" type="stmt" count="10"/>
@@ -54,7 +54,7 @@
5454
<line num="150" type="stmt" count="10"/>
5555
<line num="151" type="stmt" count="10"/>
5656
<line num="152" type="stmt" count="10"/>
57-
<line num="164" type="method" name="generate_preview" visibility="public" complexity="8" crap="8" count="2"/>
57+
<line num="164" type="method" name="generate_preview" visibility="public" complexity="9" crap="9" count="2"/>
5858
<line num="166" type="stmt" count="2"/>
5959
<line num="168" type="stmt" count="2"/>
6060
<line num="169" type="stmt" count="2"/>

inc/classes/class-comment-preview.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function generate_preview( $request ) {
171171

172172
$user_id = ( ( is_user_logged_in() ) ? get_current_user_id() : 0 );
173173

174-
if ( ! empty( $user_id ) ) {
174+
if ( ! empty( $user_id ) && empty( $response['author'] ) ) {
175175

176176
$user = get_userdata( $user_id );
177177

117 KB
Loading
153 KB
Loading
202 KB
Loading
201 KB
Loading

0 commit comments

Comments
 (0)