'pixelfed_widget',
'description' => __( 'Display a profile timeline', 'fediembedi' ),
'customize_selective_refresh' => true,
);
parent::__construct( 'pixelfed', _x( 'Pixelfed', 'fediembedi' ), $widget_ops );
}
/**
* Outputs the content for the current Pixelfed 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 Pixelfed widget instance.
*/
public function widget( $args, $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
//fedi instance
$instance_url = get_option('fediembedi-pixelfed-instance');
$access_token = get_option('fediembedi-pixelfed-token');
$client = new \FediClient($instance_url, $access_token);
$cred = $client->verify_credentials($access_token);
if (!$cred){
return;
}
//widget options
$show_header = (!empty($instance['show_header'])) ? $instance['show_header'] : '';
$only_media = (!empty($instance['only_media'])) ? $instance['only_media'] : '';
$pinned = (!empty($instance['pinned'])) ? $instance['pinned'] : '';
$exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : '';
$exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : '';
$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 '
'' ) ); $instance['title'] = sanitize_text_field( $new_instance['title'] ); $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['height'] = sanitize_text_field( $new_instance['height'] ); return $instance; } }