'peertube_widget',
'description' => __( 'Display a profile timeline', 'fediembedi' ),
'customize_selective_refresh' => true,
);
parent::__construct( 'peertube', _x( 'PeerTube', 'fediembedi' ), $widget_ops );
}
/**
* Outputs the content for the current PeerTube widget instance.
*
* @since 2.8.0
*
* @param array $args Display arguments including 'before_title', 'after_title',
* 'before_widget', and 'after_widget'.
* @param array $instance Settings for the current PeerTube widget instance.
*/
public function widget( $args, $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
//fedi instance
$fedi_instance = (!empty($instance['peertube'])) ? $instance['peertube'] : '';
$actor = (!empty($instance['actor'])) ? $instance['actor'] : '';
$is_channel = (!empty($instance['channel'])) ? $instance['channel'] : null;//radio channel or account
$client = new \FediClient($fedi_instance);
//widget options
$show_header = (!empty($instance['show_header'])) ? $instance['show_header'] : null;
$count = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
$nsfw = isset( $instance['nsfw'] ) ? $instance['nsfw'] : null;
$height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%';
echo $args['before_widget'];
if ( $title ) {
echo $args['before_title'] . $title . $args['after_title'];
};
//getVideos from remote instance
$status = $client->getVideos($actor, $is_channel, $count, $nsfw);
//if(WP_DEBUG_DISPLAY === true): echo 'PeerTube
'; var_dump($status); echo '
'' ) ); $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['peertube'] = esc_url($new_instance['peertube']); $instance['actor'] = sanitize_key($new_instance['actor']); $instance['channel'] = $new_instance['channel']; $instance['show_header'] = $new_instance['show_header']; $instance['only_media'] = $new_instance['only_media']; $instance['pinned'] = $new_instance['pinned']; $instance['exclude_replies'] = $new_instance['exclude_replies']; $instance['exclude_reblogs'] = $new_instance['exclude_reblogs']; $instance['number'] = (int) $new_instance['number']; $instance['nsfw'] = $new_instance['nsfw']; $instance['height'] = sanitize_text_field( $new_instance['height'] ); return $instance; } }