Commit e4aa0e34 authored by MediaFormat's avatar MediaFormat
Browse files

Add emoji support

parent 1f8b307d
......@@ -285,6 +285,12 @@
cursor: pointer;
display: inline-block;
}
.status__content span.invisible{
display: none;
}
.status__content span.ellipsis:after{
content: '\2026';
}
.status__content .media-gallery__item{
margin: 1em 0;
}
......
......@@ -43,8 +43,6 @@ class FediEmbedi_Mastodon extends WP_Widget {
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
$height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%';
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>'. $instance_type .'</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
echo $args['before_widget'];
if ( $title ) {
echo $args['before_title'] . $title . $args['after_title'];
......@@ -52,7 +50,9 @@ class FediEmbedi_Mastodon extends WP_Widget {
//getStatus from remote instance
$status = $client->getStatus($only_media, $pinned, $exclude_replies, null, null, null, $number, $exclude_reblogs);
include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' );
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>Mastodon</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
$account = $status[0]->account;
include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' );
echo $args['after_widget'];
}
......
......@@ -25,6 +25,7 @@ class FediConfig
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
add_action('admin_menu', array($this, 'configuration_page'));
add_action('admin_notices', array($this, 'admin_notices'));
add_filter('fedi_emoji', array($this, 'convert_emoji'), 10, 2);
add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'fediembedi_add_plugin_page_settings_link'));
}
......@@ -144,6 +145,17 @@ class FediConfig
register_widget( 'FediEmbedi_PeerTube' );
}
public function convert_emoji($string, $emojis){
if(is_null($emojis) || !is_array($emojis)){
return $string;
}
foreach($emojis as $emoji){
$match = '/:' . $emoji->shortcode .':/';
$string = preg_replace($match, "<img draggable=\"false\" role=\"img\" class=\"emoji\" src=\"{$emoji->static_url}\">", $string);
}
return $string;
}
public function enqueue_styles($hook)
{
if( is_active_widget( false, false, 'mastodon') ) {
......
......@@ -6,28 +6,28 @@
<div class="account__header">
<div class="account__header__image">
<div class="account__header__info"></div>
<?php if ($status[0]->account->header): echo "<img src=" . $status[0]->account->header . " loading='lazy'>"; endif; ?>
<?php if ($account->header): echo "<img src=" . $account->header . " loading='lazy'>"; endif; ?>
</div>
<div class="account__header__bar">
<div class="account__header__tabs">
<a href="<?php echo $status[0]->account->url; ?>" class="avatar" rel="noreferrer noopener" target="_blank">
<div class="account__avatar" style="width:90px; height: 90px; background-image: url('<?php echo $status[0]->account->avatar; ?>'); background-size: cover;"></div>
<a href="<?php echo $account->url; ?>" class="avatar" rel="noreferrer noopener" target="_blank">
<div class="account__avatar" style="width:90px; height: 90px; background-image: url('<?php echo $account->avatar; ?>'); background-size: cover;"></div>
</a>
<div class="spacer"></div>
<div class="account__header__tabs__buttons">
<a href="<?php echo $status[0]->account->url; ?>" rel="noreferrer noopener" class="button logo-button"><?php _e('Follow', 'fediembedi'); ?></a>
<a href="<?php echo $account->url; ?>" rel="noreferrer noopener" class="button logo-button"><?php _e('Follow', 'fediembedi'); ?></a>
</div>
</div>
<div class="account__header__tabs__name">
<h1>
<span><?php echo $status[0]->account->display_name; ?></span>
<small><a href="" target="_blank" rel="noreferrer noopener"><?php echo $status[0]->account->url; ?></a></small>
<span><?php echo apply_filters('fedi_emoji', $account->display_name, $account->emojis); ?></span>
<small><a href="<?php echo $account->url; ?>" target="_blank" rel="noreferrer noopener"><?php echo $account->url; ?></a></small>
</h1>
</div>
<div class="account__header__extra">
<div class="account__header__bio">
<div class="account__header__content">
<?php echo $status[0]->account->note; ?>
<?php echo apply_filters('fedi_emoji', $account->note, $account->emojis); ?>
</div>
</div>
</div>
......@@ -62,7 +62,7 @@
<div class="status__avatar">
<div class="account__avatar" style="background-image: url(<?php if(is_null($statut->reblog)): echo $statut->account->avatar; else: echo $statut->reblog->account->avatar; endif; ?>); background-size: 40px; width: 40px; height: 40px;"></div>
</div>
<span class="display-name"><?php if(is_null($statut->reblog)): echo $statut->account->display_name; else: echo $statut->reblog->account->display_name; endif; ?></span>
<span class="display-name"><?php if(is_null($statut->reblog)): echo apply_filters('fedi_emoji', $statut->account->display_name, $statut->account->emojis); else: echo apply_filters('fedi_emoji', $statut->reblog->account->display_name, $statut->reblog->account->emojis); endif; ?></span>
</a>
</div>
<div class="status__content"><?php
......@@ -70,7 +70,7 @@
$statut = $statut->reblog;
endif;
if(empty($statut->spoiler_text)):
echo $statut->content;
echo apply_filters('fedi_emoji', $statut->content, $statut->emojis);
if(!is_null($statut->card)): ?>
<a href="<?php echo $statut->card->url; ?>" class="status-card compact" target="_blank" rel="noopener noreferrer">
<div class="status-card__image"><div class="status-card__image-image" style="background-image: url(<?php echo $statut->card->image; ?>);"></div></div>
......@@ -82,7 +82,7 @@
</a>
<?php
endif;
else: echo '<details><summary>' . $statut->spoiler_text . '</summary>'. $statut->content . '</details>';
else: echo '<details><summary>' . apply_filters('fedi_emoji', $statut->spoiler_text, $statut->emojis) . '</summary>'. apply_filters('fedi_emoji', $statut->content, $statut->emojis) . '</details>';
endif;
if(!empty($statut->media_attachments)):
foreach ($statut->media_attachments as $attachment) {
......
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