diff --git a/fediembedi-client.php b/fediembedi-client.php index 7c3f26c..e6c5a35 100644 --- a/fediembedi-client.php +++ b/fediembedi-client.php @@ -138,14 +138,28 @@ class FediClient return $response; } - public function getVideos($account_id, $is_channel) { - + public function getVideos($account_id, $is_channel, $count, $nsfw = false) { + //https://docs.joinpeertube.org/api-rest-reference.html#tag/Video $headers = array(); + $query = http_build_query(array( + //'categoryOneOf' => $categoryID, + 'count' => $count, + //'filter' => $filter, + //'languageOneOf' => $lang, + //'licenceOneOf' => $licence, + 'nsfw' => $nsfw, + //'skipCount' => $skipCount, + //'sort' => $sort, + //'start' => $offset, + //'tagsAllOf' => $tagsAllOf,//videos where all tags are present + //'tagsOneOf' => $tags + )); + if(!is_null($is_channel)){ - $response = $this->_get("/api/v1/video-channels/{$account_id}/videos", null, $headers); + $response = $this->_get("/api/v1/video-channels/{$account_id}/videos?{$query}", null, $headers); } else { - $response = $this->_get("/api/v1/accounts/{$account_id}/videos", null, $headers); + $response = $this->_get("/api/v1/accounts/{$account_id}/videos?{$query}", null, $headers); } return $response; diff --git a/fediembedi-peertube-widget.php b/fediembedi-peertube-widget.php index 5801662..c8be9d1 100644 --- a/fediembedi-peertube-widget.php +++ b/fediembedi-peertube-widget.php @@ -37,7 +37,8 @@ class FediEmbedi_PeerTube extends WP_Widget { //widget options $show_header = (!empty($instance['show_header'])) ? $instance['show_header'] : null; - $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $count = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $nsfw = isset( $instance['nsfw'] ) ? $instance['nsfw'] : false; $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%'; echo $args['before_widget']; @@ -46,13 +47,13 @@ class FediEmbedi_PeerTube extends WP_Widget { }; //getVideos from remote instance - $status = $client->getVideos($actor, $is_channel); + $status = $client->getVideos($actor, $is_channel, $count, $nsfw); if(!is_null($is_channel)){ $account = $status->data[0]->channel; } else { $account = $status->data[0]->account; } - + include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' ); echo $args['after_widget']; @@ -79,6 +80,7 @@ class FediEmbedi_PeerTube extends WP_Widget { $exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : NULL; $exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : NULL; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $nsfw = isset( $instance['nsfw'] ) ? $instance['nsfw'] : false; $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : ''; ?> @@ -126,6 +128,17 @@ class FediEmbedi_PeerTube extends WP_Widget {

+ +

+

Mastodon
'; var_dump($client->getStatus($atts)); echo '
'; endif; $show_header = $atts['show_header']; - $account = $status[0]->account; - ob_start(); - include(plugin_dir_path(__FILE__) . 'templates/pixelfed.tpl.php' ); - return ob_get_clean(); + if($account = $status[0]->account){ + ob_start(); + include(plugin_dir_path(__FILE__) . 'templates/pixelfed.tpl.php' ); + return ob_get_clean(); + } else { + return; + } } public function peertube_shortcode($atts){ @@ -224,7 +227,7 @@ class FediConfig $client = new \FediClient($atts['instance']); //getVideos from remote instance - $status = $client->getVideos($atts['actor'], $atts['is_channel']); + $status = $client->getVideos($atts['actor'], $atts['is_channel'], $atts['limit'], $atts['nsfw'] ); if(!is_null($atts['is_channel'])){ $account = $status->data[0]->channel; } else { diff --git a/readme.md b/readme.md index 502a78e..abd37d9 100644 --- a/readme.md +++ b/readme.md @@ -53,6 +53,9 @@ and redirected to your site with a secure token. Similar to how you would connec ## Changelog +### 0.10.5 +* Bug fix: Template issues. + ### 0.10.4 * Bug fix: Embed included in post edit screen, causing post save issues. diff --git a/readme.txt b/readme.txt index 412ca6d..d61fdd7 100644 --- a/readme.txt +++ b/readme.txt @@ -64,7 +64,10 @@ and redirected to your site with a secure token. Similar to how you would connec == Changelog == -= 0.10.3 = += 0.10.5 = +* Bug fix: Template issues. + += 0.10.4 = * Bug fix: Embed included in post edit screen, causing post save issues = 0.10.3 = diff --git a/templates/mastodon.tpl.php b/templates/mastodon.tpl.php index 5fde702..8114d66 100644 --- a/templates/mastodon.tpl.php +++ b/templates/mastodon.tpl.php @@ -1,5 +1,5 @@ -
+
>
diff --git a/templates/peertube.tpl.php b/templates/peertube.tpl.php index 199e682..d1b7c0e 100644 --- a/templates/peertube.tpl.php +++ b/templates/peertube.tpl.php @@ -1,5 +1,5 @@ -
+
>
diff --git a/templates/pixelfed.tpl.php b/templates/pixelfed.tpl.php index 770b273..508c1db 100644 --- a/templates/pixelfed.tpl.php +++ b/templates/pixelfed.tpl.php @@ -1,5 +1,5 @@ -
+
>
@@ -37,15 +37,16 @@
media_attachments[0]->preview_url) && $statut->media_attachments[0]->type === 'image'): ?> + $attachment = $statut->media_attachments[0]; + if (!empty($attachment->preview_url) && $attachment->type === 'image'): ?>
-
+
media_attachments[0]->type === 'video'): - echo "
@@ -53,7 +54,7 @@