mirror of
https://git.feneas.org/mediaformat/fediembedi
synced 2025-02-03 20:58:16 +01:00
Add emoji support
This commit is contained in:
parent
1f8b307d57
commit
e4aa0e344a
@ -285,6 +285,12 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
.status__content span.invisible{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.status__content span.ellipsis:after{
|
||||||
|
content: '\2026';
|
||||||
|
}
|
||||||
.status__content .media-gallery__item{
|
.status__content .media-gallery__item{
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,6 @@ class FediEmbedi_Mastodon extends WP_Widget {
|
|||||||
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
|
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
|
||||||
$height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%';
|
$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'];
|
echo $args['before_widget'];
|
||||||
if ( $title ) {
|
if ( $title ) {
|
||||||
echo $args['before_title'] . $title . $args['after_title'];
|
echo $args['before_title'] . $title . $args['after_title'];
|
||||||
@ -52,7 +50,9 @@ class FediEmbedi_Mastodon extends WP_Widget {
|
|||||||
|
|
||||||
//getStatus from remote instance
|
//getStatus from remote instance
|
||||||
$status = $client->getStatus($only_media, $pinned, $exclude_replies, null, null, null, $number, $exclude_reblogs);
|
$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'];
|
echo $args['after_widget'];
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ class FediConfig
|
|||||||
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
|
add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
|
||||||
add_action('admin_menu', array($this, 'configuration_page'));
|
add_action('admin_menu', array($this, 'configuration_page'));
|
||||||
add_action('admin_notices', array($this, 'admin_notices'));
|
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'));
|
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' );
|
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)
|
public function enqueue_styles($hook)
|
||||||
{
|
{
|
||||||
if( is_active_widget( false, false, 'mastodon') ) {
|
if( is_active_widget( false, false, 'mastodon') ) {
|
||||||
|
@ -6,28 +6,28 @@
|
|||||||
<div class="account__header">
|
<div class="account__header">
|
||||||
<div class="account__header__image">
|
<div class="account__header__image">
|
||||||
<div class="account__header__info"></div>
|
<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>
|
||||||
<div class="account__header__bar">
|
<div class="account__header__bar">
|
||||||
<div class="account__header__tabs">
|
<div class="account__header__tabs">
|
||||||
<a href="<?php echo $status[0]->account->url; ?>" class="avatar" rel="noreferrer noopener" target="_blank">
|
<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 $status[0]->account->avatar; ?>'); background-size: cover;"></div>
|
<div class="account__avatar" style="width:90px; height: 90px; background-image: url('<?php echo $account->avatar; ?>'); background-size: cover;"></div>
|
||||||
</a>
|
</a>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div class="account__header__tabs__buttons">
|
<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>
|
</div>
|
||||||
<div class="account__header__tabs__name">
|
<div class="account__header__tabs__name">
|
||||||
<h1>
|
<h1>
|
||||||
<span><?php echo $status[0]->account->display_name; ?></span>
|
<span><?php echo apply_filters('fedi_emoji', $account->display_name, $account->emojis); ?></span>
|
||||||
<small><a href="" target="_blank" rel="noreferrer noopener"><?php echo $status[0]->account->url; ?></a></small>
|
<small><a href="<?php echo $account->url; ?>" target="_blank" rel="noreferrer noopener"><?php echo $account->url; ?></a></small>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="account__header__extra">
|
<div class="account__header__extra">
|
||||||
<div class="account__header__bio">
|
<div class="account__header__bio">
|
||||||
<div class="account__header__content">
|
<div class="account__header__content">
|
||||||
<?php echo $status[0]->account->note; ?>
|
<?php echo apply_filters('fedi_emoji', $account->note, $account->emojis); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<div class="status__avatar">
|
<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 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>
|
</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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="status__content"><?php
|
<div class="status__content"><?php
|
||||||
@ -70,7 +70,7 @@
|
|||||||
$statut = $statut->reblog;
|
$statut = $statut->reblog;
|
||||||
endif;
|
endif;
|
||||||
if(empty($statut->spoiler_text)):
|
if(empty($statut->spoiler_text)):
|
||||||
echo $statut->content;
|
echo apply_filters('fedi_emoji', $statut->content, $statut->emojis);
|
||||||
if(!is_null($statut->card)): ?>
|
if(!is_null($statut->card)): ?>
|
||||||
<a href="<?php echo $statut->card->url; ?>" class="status-card compact" target="_blank" rel="noopener noreferrer">
|
<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>
|
<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>
|
</a>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
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;
|
endif;
|
||||||
if(!empty($statut->media_attachments)):
|
if(!empty($statut->media_attachments)):
|
||||||
foreach ($statut->media_attachments as $attachment) {
|
foreach ($statut->media_attachments as $attachment) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user