Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Huereca committed May 8, 2017
2 parents 0c8dc6f + 0960681 commit 001f60b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 15 deletions.
4 changes: 1 addition & 3 deletions assets/css/elevated-comment.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

.postmatic-elevated {
width: 50%;
width: 45%;
float: right;
border: 1px solid #eee;
margin: 0 0 10px 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
padding: 10px;
background: url(../images/postmatic-elevated.png) center 50px no-repeat;
background-size: 90%;
}
.postmatic-elevated-comment {
quotes: "\201C""\201D""\2018""\2019";
Expand Down
Binary file removed assets/images/postmatic-elevated.png
Binary file not shown.
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: vernal, carlalexander, ronalfy
Tags: comments, engagement, long-tail
Donate link: http://gopostmatic.com
Requires at least: 4.4
Tested up to: 4.5.2
Stable tag: 1.1.5
Tested up to: 4.8
Stable tag: 1.1.6
License: GPLv2

Bring the best conversation to the top of the page with Elevated Comments.
Expand Down Expand Up @@ -62,6 +62,12 @@ Not yet. There is only one winner. The best comment.

== Changelog ==

= 1.1.6 =
* Released 2017-05-08
* Bug Fix: Fixed divided by zero bug.
* Tweak: Removed the default background image from the elevated comment.
* New: Added filter to include comments by the post author, disabled them by default (elevated_allow_post_author)

= 1.1.5 =
* Released 2016-06-12
* Bug Fix: Fixing HTML being stripped out of content.
Expand Down
18 changes: 9 additions & 9 deletions src/CommentIQ/API/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public function __construct(WP_Http $http_transport)
{
$this->http_transport = $http_transport;

/**
* Filter: elevated_api_endpoint
*
* Replace the endpoint with your own.
*
* @since 1.1.0
*
* @param string URL to the endpoint.
*/
/**
* Filter: elevated_api_endpoint
*
* Replace the endpoint with your own.
*
* @since 1.1.0
*
* @param string URL to the endpoint.
*/
$this->endpoint_base = apply_filters( 'elevated_api_endpoint', $this->endpoint_base );
}

Expand Down
13 changes: 12 additions & 1 deletion src/CommentIQ/Generator/ElevatedCommentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,19 @@ public function generate(WP_Post $post)
}

$elevated_comment = get_comment($elevated_comment_id);

/**
* Filter: elevated_allow_post_author
*
* Whether to allow post author comments to be elevated.
*
* @since 1.1.6
*
* @param bool false if not, true if yes
*/
$allow_post_author = apply_filters( 'elevated_allow_post_author', false );

if (!$elevated_comment instanceof WP_Comment || !$this->is_valid_comment($elevated_comment)) {
if ( ! $elevated_comment instanceof WP_Comment || ! $this->is_valid_comment($elevated_comment ) || ( ( $post->post_author === $elevated_comment->user_id ) && ! $allow_post_author ) ) {
return '';
}

Expand Down
14 changes: 14 additions & 0 deletions src/CommentIQ/Subscriber/CommentIQAPISubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,20 @@ private function update_elevated_comment(WP_Post $post)
}

$elevated_comment = array_reduce(get_comments(array('post_id' => $post->ID)), array($this, 'compare_comments'));

/**
* Filter: elevated_allow_post_author
*
* Whether to allow post author comments to be elevated.
*
* @since 1.1.6
*
* @param bool false if not, true if yes
*/
$allow_post_author = apply_filters( 'elevated_allow_post_author', false );
if ( $post->post_author === $elevated_comment->user_id && ! $allow_post_author ) {
return;
}

if ($elevated_comment instanceof WP_Comment) {
update_post_meta($post->ID, $this->elevated_comment_id_meta_key, $elevated_comment->comment_ID);
Expand Down

0 comments on commit 001f60b

Please sign in to comment.