diff --git a/assets/mastodon.css b/assets/mastodon.css index a229e1e..39d87f9 100644 --- a/assets/mastodon.css +++ b/assets/mastodon.css @@ -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; } diff --git a/fediembedi-mastodon-widget.php b/fediembedi-mastodon-widget.php index b3bb95c..92ca0d0 100644 --- a/fediembedi-mastodon-widget.php +++ b/fediembedi-mastodon-widget.php @@ -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 '
'. $instance_type .'
'; var_dump($status); echo '
'; 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 '
Mastodon
'; var_dump($status); echo '
'; endif; + $account = $status[0]->account; + include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' ); echo $args['after_widget']; } diff --git a/fediembedi.php b/fediembedi.php index 4fb6ed6..24f5e5c 100644 --- a/fediembedi.php +++ b/fediembedi.php @@ -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, "static_url}\">", $string); + } + return $string; + } + public function enqueue_styles($hook) { if( is_active_widget( false, false, 'mastodon') ) { diff --git a/templates/mastodon.tpl.php b/templates/mastodon.tpl.php index c7b305c..b636d79 100644 --- a/templates/mastodon.tpl.php +++ b/templates/mastodon.tpl.php @@ -6,28 +6,28 @@
- account->header): echo ""; endif; ?> + header): echo ""; endif; ?>
@@ -62,7 +62,7 @@
- reblog)): echo $statut->account->display_name; else: echo $statut->reblog->account->display_name; endif; ?> + 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; ?>
reblog; endif; if(empty($statut->spoiler_text)): - echo $statut->content; + echo apply_filters('fedi_emoji', $statut->content, $statut->emojis); if(!is_null($statut->card)): ?>
@@ -82,7 +82,7 @@
' . $statut->spoiler_text . ''. $statut->content . ''; + else: echo '
' . apply_filters('fedi_emoji', $statut->spoiler_text, $statut->emojis) . ''. apply_filters('fedi_emoji', $statut->content, $statut->emojis) . '
'; endif; if(!empty($statut->media_attachments)): foreach ($statut->media_attachments as $attachment) {