Commit 6bf9c7d3 authored by Thomas's avatar Thomas
Browse files

Prepares release 1.0.3

parent 17ad1b7e
......@@ -27,6 +27,9 @@ e.g.
== Changelog ==
= 1.0.3 =
* Background, text and link colors can be customized in settings
* Fix an issue with peertube profile picture
= 1.0.2 =
* Fix an issue with peertube videos
......
......@@ -97,7 +97,6 @@ class Mastodon_comments_Admin {
*/
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mastodon_comments-admin.js', array( 'jquery' ), $this->version, false );
}
......@@ -125,4 +124,10 @@ class Mastodon_comments_Admin {
register_setting($this->plugin_name.'preferences', $this->plugin_name.'preferences', array($this, 'set_preferences'));
}
function mw_enqueue_color_picker( $hook_suffix ) {
// first check that $hook_suffix is appropriate for your admin page
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'my-script-handle', plugins_url('my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
}
}
......@@ -28,5 +28,7 @@
* Although scripts in the WordPress core, Plugins and Themes may be
* practising this, we should strive to set a better example in our own work.
*/
jQuery(document).ready(function($){
$('.my-color-field').wpColorPicker();
});
})( jQuery );
......@@ -42,6 +42,26 @@ if( isset($optionsPreferences['selector']) ){
if( isset($optionsPreferences['peertubecomments']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[peertubecomments]", $optionsPreferences['peertubecomments'] );
}
if( isset($optionsPreferences['mastodon_bg']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[mastodon_bg]", $optionsPreferences['mastodon_bg'] );
}
if( isset($optionsPreferences['mastodon_text']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[mastodon_text]", $optionsPreferences['mastodon_text'] );
}
if( isset($optionsPreferences['mastodon_link']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[mastodon_link]", $optionsPreferences['mastodon_link'] );
}
if( isset($optionsPreferences['peertube_bg']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[peertube_bg]", $optionsPreferences['peertube_bg'] );
}
if( isset($optionsPreferences['peertube_text']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[peertube_text]", $optionsPreferences['peertube_text'] );
}
if( isset($optionsPreferences['peertube_link']) ){
register_setting( $this->plugin_name.'preferences', $this->plugin_name."preferences[peertube_link]", $optionsPreferences['peertube_link'] );
}
if( ! isset($_SESSION['mc_step']))
$_SESSION['mc_step'] = 1;
......@@ -218,6 +238,66 @@ if ( isset($options['oauth']) ){
isset($optionsPreferences['peertubecomments']) )
{echo "checked";}?>
/>
</fieldset>
<h2 class="nav-tab-wrapper"><?php _e('Custom colors', $this->plugin_name);?></h2>
<fieldset style="margin-top: 10px;">
<table>
<tr>
<th>Mastodon</th>
<th>Peertube</th>
</tr>
<tr>
<td valign="top" style="padding:0 15px 0 15px;">
<label for="<?php echo $this->plugin_name;?>-mastodon_bg"><?php _e('Background color for Mastodon comments', $this->plugin_name);?></label>
<input type="text" id="<?php echo $this->plugin_name;?>-mastodon_bg"
name="<?php echo $this->plugin_name;?>preferences[mastodon_bg]"
value="<?php echo isset($optionsPreferences['mastodon_bg'])?$optionsPreferences['mastodon_bg']: "#eee";?>"
class="my-color-field" /></td>
<td valign="top" style="padding:0 15px 0 15px;">
<label for="<?php echo $this->plugin_name;?>-peertube_bg"><?php _e('Background color for Peertube comments', $this->plugin_name);?></label>
<input type="text" id="<?php echo $this->plugin_name;?>-peertube_bg"
name="<?php echo $this->plugin_name;?>preferences[peertube_bg]"
value="<?php echo isset($optionsPreferences['peertube_bg'])?$optionsPreferences['peertube_bg']: "#eee";?>"
class="my-color-field" />
</td>
</tr>
<tr>
<td valign="top" style="padding:0 15px 0 15px;">
<label for="<?php echo $this->plugin_name;?>-mastodon_text"><?php _e('Text color for Mastodon Comments', $this->plugin_name);?></label>
<input type="text" id="<?php echo $this->plugin_name;?>-mastodon_text"
name="<?php echo $this->plugin_name;?>preferences[mastodon_text]"
value="<?php echo isset($optionsPreferences['mastodon_text'])?$optionsPreferences['mastodon_text']: "#000";?>"
class="my-color-field" /></td>
<td valign="top" style="padding:0 15px 0 15px;">
<label for="<?php echo $this->plugin_name;?>-peertube_text"><?php _e('Text color for Peertube Comments', $this->plugin_name);?></label>
<input type="text" id="<?php echo $this->plugin_name;?>-peertube_text"
name="<?php echo $this->plugin_name;?>preferences[peertube_text]"
value="<?php echo isset($optionsPreferences['peertube_text'])?$optionsPreferences['peertube_text']: "#000";?>"
class="my-color-field" />
</td>
</tr>
<tr>
<td valign="top" style="padding:0 15px 0 15px;">
<label for="<?php echo $this->plugin_name;?>-mastodon_link"><?php _e('Link color for Mastodon Comments', $this->plugin_name);?></label>
<input type="text" id="<?php echo $this->plugin_name;?>-mastodon_link"
name="<?php echo $this->plugin_name;?>preferences[mastodon_link]"
value="<?php echo isset($optionsPreferences['mastodon_link'])?$optionsPreferences['mastodon_link']: "#000";?>"
class="my-color-field" /></td>
<td valign="top" style="padding:0 15px 0 15px;">
<label for="<?php echo $this->plugin_name;?>-peertube_link"><?php _e('Link color for Peertube Comments', $this->plugin_name);?></label>
<input type="text" id="<?php echo $this->plugin_name;?>-peertube_link"
name="<?php echo $this->plugin_name;?>preferences[peertube_link]"
value="<?php echo isset($optionsPreferences['peertube_link'])?$optionsPreferences['peertube_link']: "#000";?>"
class="my-color-field" />
</td>
</tr>
</table>
</fieldset>
<fieldset style="margin-top: 10px;">
</fieldset>
<?php submit_button(__('Save', $this->plugin_name), 'primary','submit', TRUE); ?>
</form>
......@@ -158,6 +158,7 @@ class Mastodon_comments {
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$this->loader->add_action('admin_init', $plugin_admin, 'options_update_site');
$this->loader->add_action('admin_init', $plugin_admin,'register_session', 1);
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin,'mw_enqueue_color_picker' );
}
/**
......
......@@ -16,7 +16,7 @@
* Plugin Name: mastodon comments
* Plugin URI: https://mastalab.app
* Description: Display comments on Mastodon related to an URL
* Version: 1.0.2
* Version: 1.0.3
* Author: Thomas Schneider
* Author URI: https://gitlab.com/tom79/mastodon-comments-for-wordpress
* License: GPL-2.0+
......@@ -35,7 +35,7 @@ if ( ! defined( 'WPINC' ) ) {
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'PLUGIN_NAME_VERSION', '1.0.2' );
define( 'PLUGIN_NAME_VERSION', '1.0.3' );
/**
* The code that runs during plugin activation.
......
......@@ -103,7 +103,13 @@ class Mastodon_comments_Public {
'ajaxurl' => admin_url('admin-ajax.php'),
'post_id' => get_the_id(),
'search' => "",
'peertube_comment' => isset($optionsPreferences['peertubecomments']),
'peertube_comment' => $optionsPreferences['peertubecomments'],
'mastodon_bg' => $optionsPreferences['mastodon_bg'],
'mastodon_text' => $optionsPreferences['mastodon_text'],
'mastodon_link' => $optionsPreferences['mastodon_link'],
'peertube_bg' => $optionsPreferences['peertube_bg'],
'peertube_text' => $optionsPreferences['peertube_text'],
'peertube_link' => $optionsPreferences['peertube_link'],
'mastodon_comments_nonce' => wp_create_nonce('mastodon_comments_nonce')
);
wp_localize_script( $this->plugin_name, 'params', $params );
......@@ -121,10 +127,11 @@ class Mastodon_comments_Public {
$searchResult = $MastodonAPI->get_content_curl($search);
$resultArray = $searchResult['html']['data'];
$result['stats']['replies'] = $searchResult['html']['total'];
$domain = explode("/",str_replace("https://","",$source))[0];
if (isset($resultArray)) {
foreach ($resultArray as $status) {
if( isset($status['account']['avatar']['path']))
$avatar = "https://".$status['account']['host'].$status['account']['avatar']['path'];
$avatar = "https://".$domain.$status['account']['avatar']['path'];
else
$avatar = strtolower(plugins_url($this->plugin_name))."/public/img/missing.png";
$result['comments'][$status['id']] = [
......@@ -199,4 +206,7 @@ class Mastodon_comments_Public {
wp_send_json($result);
}
}
......@@ -4,11 +4,14 @@
*/
#mastodon_comments_counters{
.mastodon_comments_counters{
display: inline-block;
width: 100%;
height: 30px;
}
.comments-container{
padding:5px;
}
.comments-container .comment .avatar {
float: left;
width: 50px;
......@@ -39,9 +42,9 @@
padding-bottom: 10px;
}
.comments-container #mastodon-like-count,
.comments-container #mastodon-reblog-count,
.comments-container #mastodon-reply-count
.comments-container .mastodon-like-count,
.comments-container .mastodon-reblog-count,
.comments-container .mastodon-reply-count
{
float: right;
font-size: 16px;
......@@ -51,21 +54,12 @@
border-radius: 5px;
}
.comments-container #mastodon-like-count a,
.comments-container #mastodon-reblog-count a,
.comments-container #mastodon-reply-count a
.mastodon-reply-count a:hover, .mastodon-reply-count a:visited, .mastodon-reply-count a:link, .mastodon-reply-count a:active, .mastodon-reply-count a:-webkit-any-link
{
color: #333333;
}
.comments-container #mastodon-like-count a:hover,
.comments-container #mastodon-reblog-count a:hover,
.comments-container #mastodon-reply-count a:hover
{
color: black;
text-decoration: none;
}
.comments-container .fa {
padding-right: 10px;
}
......
......@@ -36,7 +36,7 @@
{
'action': 'mastodon_comments_getcomment',
'post_id': params.post_id,
'search': window.location.href,
'search': "https://mastalab.app/2018/09/02/how-to-login/",
'mastodon_comments_nonce': params.mastodon_comments_nonce
},
function(data){
......@@ -50,17 +50,28 @@
var root = data.stats.root;
var element = jQuery('<div/>', {
id: 'mastodon_comments',
class: 'comments-container',
class: 'mastodon comments-container',
title: 'Mastodon Comments'
});
if( typeof params.mastodon_bg)
element.css("background-color", params.mastodon_bg);
if( typeof params.mastodon_text)
element.css("color", params.mastodon_text);
var elementCounter = jQuery('<div/>', {
id: 'mastodon_comments_counters',
class: 'mastodon_container_counters',
title: 'Mastodon Comments Counters'
});
elementCounter.append('<div id="mastodon-like-count"><a href="' + stats.url + '"><span title="Likes"><i class="fa fa-star"></i>' + stats.favs + '</span></a></div></div>');
elementCounter.append('<div id="mastodon-reblog-count"><a href="' + stats.url + '"><span title="Reblogs"><i class="fa fa-retweet"></i>' + stats.reblogs + '</span></a></div></div>');
elementCounter.append('<div id="mastodon-reply-count"><a href="' + stats.url + '"><span title="Comments"><i class="fa fa-comments"></i>' + stats.replies + '</span></a></div></div>');
$("<style type='text/css'> " +
".mastodon.comments-container{ background-color:"+params.mastodon_bg +";color:" + params.mastodon_text + "}" +
".mastodon.comments-container a{box-shadow: none; color:" + params.mastodon_link + "; text-decoration: none;}" +
".mastodon.comments-container a:hover{ box-shadow: none;color:" + params.mastodon_link + "}" +
".mastodon_container_counters a{ box-shadow: none; color: black !important}" +
".mastodon_container_counters a:hover{ box-shadow: none;color: black !important}" +
"</style>").appendTo("head");
elementCounter.append('<div class="mastodon-like-count"><a href="' + stats.url + '"><span title="Likes"><i class="fa fa-star"></i>' + stats.favs + '</span></a></div></div>');
elementCounter.append('<div class="mastodon-reblog-count"><a href="' + stats.url + '"><span title="Reblogs"><i class="fa fa-retweet"></i>' + stats.reblogs + '</span></a></div></div>');
elementCounter.append('<div class="mastodon-reply-count"><a href="' + stats.url + '"><span title="Comments"><i class="fa fa-comments"></i>' + stats.replies + '</span></a></div></div>');
element.prepend(elementCounter);
var comments = data.comments;
......@@ -124,14 +135,21 @@
return;
var stats = data.stats;
var element = jQuery('<div/>', {
class: 'comments-container',
class: 'peertube comments-container',
title: 'Mastodon Comments'
});
$("<style type='text/css'> " +
".peertube.comments-container{ background-color:"+params.peertube_bg +";color:" + params.peertube_text + "}" +
".peertube.comments-container a{box-shadow: none; color:" + params.peertube_link + "; text-decoration: none;}" +
".peertube.comments-container a:hover{ box-shadow: none;color:" + params.peertube_link + "}" +
".mastodon_container_counters a{ box-shadow: none; color: black !important}" +
".mastodon_container_counters a:hover{ box-shadow: none;color: black !important}" +
"</style>").appendTo("head");
var elementCounter = jQuery('<div/>', {
class: 'mastodon_container_counters',
title: 'Mastodon Comments Counters'
});
elementCounter.append('<div id="mastodon-reply-count"><a href="' + stats.url + '"><span title="Comments"><i class="fa fa-comments"></i>' + stats.replies + '</span></a></div></div>');
elementCounter.append('<div class="mastodon-reply-count"><a href="' + stats.url + '"><span title="Comments"><i class="fa fa-comments"></i>' + stats.replies + '</span></a></div></div>');
element.prepend(elementCounter);
var comments = data.comments;
$.each(comments, function(key, value) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment