better template class names, fix shortcode

This commit is contained in:
Django Doucet 2021-01-14 23:04:30 -05:00
parent 6be91f1c1c
commit b6fef90e91
10 changed files with 42 additions and 28 deletions

View File

@ -17,13 +17,13 @@ class FediEmbedi_Mastodon extends WP_Widget {
} }
/** /**
* Outputs the content for the current Search widget instance. * Outputs the content for the current Mastodon widget instance.
* *
* @since 2.8.0 * @since 2.8.0
* *
* @param array $args Display arguments including 'before_title', 'after_title', * @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'. * 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current Search widget instance. * @param array $instance Settings for the current Mastodon widget instance.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
@ -40,7 +40,7 @@ class FediEmbedi_Mastodon extends WP_Widget {
$pinned = (!empty($instance['pinned'])) ? $instance['pinned'] : ''; $pinned = (!empty($instance['pinned'])) ? $instance['pinned'] : '';
$exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : ''; $exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : '';
$exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : ''; $exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : '';
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; $limit = 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%';
echo $args['before_widget']; echo $args['before_widget'];
@ -49,7 +49,7 @@ 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, $limit, $exclude_reblogs);
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>Mastodon</summary><pre>'; var_dump($status); echo '</pre></details>'; endif; //if(WP_DEBUG_DISPLAY === true): echo '<details><summary>Mastodon</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
$account = $status[0]->account; $account = $status[0]->account;
include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' ); include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' );
@ -58,7 +58,7 @@ class FediEmbedi_Mastodon extends WP_Widget {
} }
/** /**
* Outputs the settings form for the Search widget. * Outputs the settings form for the Mastodon widget.
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -72,7 +72,7 @@ class FediEmbedi_Mastodon extends WP_Widget {
$pinned = (!empty($instance['pinned'])) ? $instance['pinned'] : NULL; $pinned = (!empty($instance['pinned'])) ? $instance['pinned'] : NULL;
$exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : NULL; $exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : NULL;
$exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : NULL; $exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : NULL;
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; $limit = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
$height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : ''; $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '';
?> ?>
@ -138,7 +138,7 @@ class FediEmbedi_Mastodon extends WP_Widget {
</p> </p>
<p> <p>
<label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to display:' ); ?><br> <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of posts to display:' ); ?><br>
<input class="tiny-text" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="<?php echo $number; ?>" size="3" /> <input class="tiny-text" id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="number" step="1" min="1" value="<?php echo $limit; ?>" size="3" />
<small>Max: 20</small> <small>Max: 20</small>
</label> </label>
</p> </p>
@ -152,7 +152,7 @@ class FediEmbedi_Mastodon extends WP_Widget {
} }
/** /**
* Handles updating settings for the current Search widget instance. * Handles updating settings for the current Mastodon widget instance.
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -174,5 +174,4 @@ class FediEmbedi_Mastodon extends WP_Widget {
$instance['height'] = sanitize_text_field( $new_instance['height'] ); $instance['height'] = sanitize_text_field( $new_instance['height'] );
return $instance; return $instance;
} }
} }

View File

@ -17,13 +17,13 @@ class FediEmbedi_PeerTube extends WP_Widget {
} }
/** /**
* Outputs the content for the current Search widget instance. * Outputs the content for the current PeerTube widget instance.
* *
* @since 2.8.0 * @since 2.8.0
* *
* @param array $args Display arguments including 'before_title', 'after_title', * @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'. * 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current Search widget instance. * @param array $instance Settings for the current PeerTube widget instance.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
@ -48,7 +48,7 @@ class FediEmbedi_PeerTube extends WP_Widget {
//getVideos from remote instance //getVideos from remote instance
$status = $client->getVideos($actor, $is_channel, $count, $nsfw); $status = $client->getVideos($actor, $is_channel, $count, $nsfw);
if(WP_DEBUG_DISPLAY === true): echo '<details><summary>PeerTube</summary><pre>'; var_dump($status); echo '</pre></details>'; endif; //if(WP_DEBUG_DISPLAY === true): echo '<details><summary>PeerTube</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
if(!is_null($is_channel)){ if(!is_null($is_channel)){
$account = $status->data[0]->channel; $account = $status->data[0]->channel;
} else { } else {
@ -61,7 +61,7 @@ class FediEmbedi_PeerTube extends WP_Widget {
} }
/** /**
* Outputs the settings form for the Search widget. * Outputs the settings form for the PeerTube widget.
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -149,7 +149,7 @@ class FediEmbedi_PeerTube extends WP_Widget {
} }
/** /**
* Handles updating settings for the current Search widget instance. * Handles updating settings for the current PeerTube widget instance.
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -175,5 +175,4 @@ class FediEmbedi_PeerTube extends WP_Widget {
$instance['height'] = sanitize_text_field( $new_instance['height'] ); $instance['height'] = sanitize_text_field( $new_instance['height'] );
return $instance; return $instance;
} }
} }

View File

@ -17,13 +17,13 @@ class FediEmbedi_Pixelfed extends WP_Widget {
} }
/** /**
* Outputs the content for the current Search widget instance. * Outputs the content for the current Pixelfed widget instance.
* *
* @since 2.8.0 * @since 2.8.0
* *
* @param array $args Display arguments including 'before_title', 'after_title', * @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'. * 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current Search widget instance. * @param array $instance Settings for the current Pixelfed widget instance.
*/ */
public function widget( $args, $instance ) { public function widget( $args, $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
@ -61,7 +61,7 @@ class FediEmbedi_Pixelfed extends WP_Widget {
} }
/** /**
* Outputs the settings form for the Search widget. * Outputs the settings form for the Pixelfed widget.
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -155,7 +155,7 @@ class FediEmbedi_Pixelfed extends WP_Widget {
} }
/** /**
* Handles updating settings for the current Search widget instance. * Handles updating settings for the current Pixelfed widget instance.
* *
* @since 2.8.0 * @since 2.8.0
* *
@ -177,5 +177,4 @@ class FediEmbedi_Pixelfed extends WP_Widget {
$instance['height'] = sanitize_text_field( $new_instance['height'] ); $instance['height'] = sanitize_text_field( $new_instance['height'] );
return $instance; return $instance;
} }
} }

View File

@ -68,7 +68,7 @@ class WP_Widget_fediembedi extends WP_Widget {
case 'PeerTube': case 'PeerTube':
//getVideos from remote instance //getVideos from remote instance
$status = $client->getVideos(); $status = $client->getVideos();
if(WP_DEBUG_DISPLAY === true): echo '<details><summary>'. $instance_type .'</summary><pre>'; var_dump($status); echo '</pre></details>'; endif; //if(WP_DEBUG_DISPLAY === true): echo '<details><summary>'. $instance_type .'</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' ); include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' );
break; break;
default: default:

View File

@ -4,7 +4,7 @@
* Plugin URI: https://git.feneas.org/mediaformat/fediembedi * Plugin URI: https://git.feneas.org/mediaformat/fediembedi
* GitLab Plugin URI: https://git.feneas.org/mediaformat/fediembedi * GitLab Plugin URI: https://git.feneas.org/mediaformat/fediembedi
* Description: Widgets and shortcodes to show your Fediverse profile timeline * Description: Widgets and shortcodes to show your Fediverse profile timeline
* Version: 0.11.0 * Version: 0.11.1
* Author: mediaformat * Author: mediaformat
* Author URI: https://mediaformat.org * Author URI: https://mediaformat.org
* License: GPLv3 * License: GPLv3
@ -170,6 +170,7 @@ class FediConfig
'limit' => 5, 'limit' => 5,
'exclude_reblogs' => false, 'exclude_reblogs' => false,
'show_header' => true, 'show_header' => true,
'height' => '100%',
), $atts, 'mastodon' ); ), $atts, 'mastodon' );
//getStatus from remote instance //getStatus from remote instance
@ -199,11 +200,12 @@ class FediConfig
'limit' => 9, 'limit' => 9,
'exclude_reblogs' => false, 'exclude_reblogs' => false,
'show_header' => true, 'show_header' => true,
'height' => '100%',
), $atts, 'pixelfed' ); ), $atts, 'pixelfed' );
//getStatus from remote instance //getStatus from remote instance
$status = $client->getStatus($atts['only_media'], $atts['pinned'], $atts['exclude_replies'], null, null, null, $atts['limit'], $atts['exclude_reblogs']); $status = $client->getStatus($atts['only_media'], $atts['pinned'], $atts['exclude_replies'], null, null, null, $atts['limit'], $atts['exclude_reblogs']);
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>Mastodon</summary><pre>'; var_dump($client->getStatus($atts)); echo '</pre></details>'; endif; //if(WP_DEBUG_DISPLAY === true): echo '<details><summary>Pixelfed</summary><pre>'; var_dump($client->getStatus($atts)); echo '</pre></details>'; endif;
$show_header = $atts['show_header']; $show_header = $atts['show_header'];
if($account = $status[0]->account){ if($account = $status[0]->account){
ob_start(); ob_start();
@ -221,9 +223,14 @@ class FediConfig
'actor' => null, 'actor' => null,
'is_channel' => null, 'is_channel' => null,
'limit' => 9, 'limit' => 9,
'nsfw' => null,
'show_header' => true, 'show_header' => true,
'height' => '100%',
), $atts, 'peertube' ); ), $atts, 'peertube' );
$atts['instance'] = \esc_attr( $atts['instance'], 'https' );
$client = new \FediClient($atts['instance']); $client = new \FediClient($atts['instance']);
//getVideos from remote instance //getVideos from remote instance
@ -234,11 +241,13 @@ class FediConfig
$account = $status->data[0]->account; $account = $status->data[0]->account;
} }
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>PeerTube</summary><pre>'; var_dump($status); echo '</pre></details>'; endif; if(WP_DEBUG_DISPLAY === true): echo '<details><summary>PeerTube</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
$show_header = $atts['show_header']; $show_header = $atts['show_header'];
$height = $atts['height'];
ob_start(); ob_start();
include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' ); include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' );
return ob_get_clean(); return ob_get_clean();
echo 'yoohoo';
} }
/* /*

View File

@ -53,6 +53,10 @@ and redirected to your site with a secure token. Similar to how you would connec
## Changelog ## Changelog
### 0.11.1
* Bug fix: Shortcode limit attribute.
* Document: Shortcodes on options page.
### 0.11.0 ### 0.11.0
* Feature: PeerTube widget NSFW option. * Feature: PeerTube widget NSFW option.
* Fix: PeerTube number of posts to display. * Fix: PeerTube number of posts to display.

View File

@ -64,6 +64,10 @@ and redirected to your site with a secure token. Similar to how you would connec
== Changelog == == Changelog ==
= 0.11.1 =
* Bug fix: Shortcode limit attribute.
* Document: Shortcodes on options page.
= 0.11.0 = = 0.11.0 =
* Feature: PeerTube widget NSFW option. * Feature: PeerTube widget NSFW option.
* Fix: PeerTube number of posts to display. * Fix: PeerTube number of posts to display.

View File

@ -1,5 +1,5 @@
<!-- mastodon --> <!-- mastodon -->
<div class="scrollable fediembedi-mastodon" <?php if (!empty($height)) : echo 'style="height: $height;"'; endif; ?>> <div class="fediembedi fediembedi-mastodon scrollable" <?php if (!empty($height)) : echo "style='height: $height;'"; endif; ?>>
<div role="feed"> <div role="feed">
<?php if($show_header): ?> <?php if($show_header): ?>
<div class="account-timeline__header"> <div class="account-timeline__header">
@ -112,4 +112,4 @@
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
<?php <?php

View File

@ -1,5 +1,5 @@
<!-- peertube --> <!-- peertube -->
<div class="scrollable fediembedi-peertube" <?php if (!empty($height)) : echo 'style="height: $height;"'; endif; ?>> <div class="fediembedi fediembedi-peertube scrollable" <?php if (!empty($height)) : echo "style='height: $height;'"; endif; ?>>
<div role="feed"> <div role="feed">
<?php if($show_header): ?> <?php if($show_header): ?>
<div class="peertube-timeline__header"> <div class="peertube-timeline__header">

View File

@ -1,5 +1,5 @@
<!-- pixelfed --> <!-- pixelfed -->
<div class="scrollable fediembedi-pixelfed" <?php if (!empty($height)) : echo 'style="height: $height;"'; endif; ?>> <div class="fediembedi fediembedi-pixelfed scrollable" <?php if (!empty($height)) : echo "style='height: $height;'"; endif; ?>>
<div role="feed" class="embed-card pixelfed"> <div role="feed" class="embed-card pixelfed">
<div class="pixelfed-inner card status-card-embed card-md-rounded-0 border"> <div class="pixelfed-inner card status-card-embed card-md-rounded-0 border">
<?php if($show_header): ?> <?php if($show_header): ?>