Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Added option for profile picture
Browse files Browse the repository at this point in the history
  • Loading branch information
aldolat committed Mar 28, 2021
1 parent 458ba07 commit 349a14f
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 89 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.6.0] - 2021-03-28
### Added
* Added option to display the user profile picture.

## [0.5.0] - 2021-02-27
### Fixed
* Fixed caching issue.
Expand Down Expand Up @@ -49,6 +53,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* First release of the plugin.

[Unreleased]: https://github.com/aldolat/aldolat-twitter/commits/develop
[0.6.0]: https://github.com/aldolat/aldolat-twitter/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/aldolat/aldolat-twitter/compare/0.4.0...0.5.0
[0.4.0]: https://github.com/aldolat/aldolat-twitter/compare/0.3.0...0.4.0
[0.3.0]: https://github.com/aldolat/aldolat-twitter/compare/0.2.0...0.3.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Tags** twitter, sidebar, widget
**Requires at least** 5.4
**Tested up to** 5.7
**Stable tag** 0.5.0
**Stable tag** 0.6.0
**License** GPLv3 or later
**License URI** <https://www.gnu.org/licenses/gpl-3.0.html>

Expand Down
2 changes: 1 addition & 1 deletion aldolat-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Plugin URI: https://dev.aldolat.it/projects/aldolat-twitter/
* Author: Aldo Latino
* Author URI: https://www.aldolat.it/
* Version: 0.5.0
* Version: 0.6.0
* License: GPLv3 or later
* Text Domain: aldolat-twitter
* Domain Path: /languages/
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
== Changelog ==

= 0.6.0 =

* Added option to display the user profile picture.

= 0.5.0 =

* Fixed caching issue.
Expand Down
3 changes: 3 additions & 0 deletions includes/aldolat-twitter-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
* string $title The title of the widget.
* string $intro_text The introductory text for the widget.
* string $screen_name The username on Twitter.
* string $type_of_tweets The type of tweets to display.
* string $count The number of tweets to retrieve.
* boolean $exclude_replies Whether to esclude replies.
* boolean $include_rts Whether to include retweets.
* boolean $display_avatar Whether to display user avatar.
* integer $cache_duration The duration of the cache.
* boolean $new_tab Whether the links should be opened in a new tab.
* string $consumer_key The Consumer Key of the Twitter app.
Expand All @@ -46,6 +48,7 @@ function aldolat_twitter_get_defaults() {
'count' => 5,
'exclude_replies' => false,
'include_rts' => true,
'display_avatar' => true,
'cache_duration' => 5, // In minutes.
'new_tab' => false,
'consumer_key' => '',
Expand Down
28 changes: 17 additions & 11 deletions includes/class-aldolat-twitter-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ class Aldolat_Twitter_Core {
* 'title' => string '',
* 'intro_text' => string '',
* 'screen_name' => string '',
* 'type_of_tweets' => string '',
* 'count' => int INT,
* 'exclude_replies' => boolean,
* 'include_rts' => boolean,
* 'display_avatar' => boolean,
* 'cache_duration' => int INT,
* 'new_tab' => boolean,
* 'consumer_key' => string '',
Expand Down Expand Up @@ -168,19 +170,23 @@ private function the_html_tweets( $tweets, $new_tab_text ) {
?>
<div class="tweet">
<?php
if ( isset( $tweet->retweeted_status ) ) {
$tweet_screen_name = $tweet->retweeted_status->user->screen_name;
$tweet_user_image = $tweet->retweeted_status->user->profile_image_url_https;
} else {
$tweet_screen_name = $tweet->user->screen_name;
$tweet_user_image = $tweet->user->profile_image_url_https;
if ( $this->plugin_settings['display_avatar'] ) {
if ( isset( $tweet->retweeted_status ) ) {
$tweet_screen_name = $tweet->retweeted_status->user->screen_name;
$tweet_user_image = $tweet->retweeted_status->user->profile_image_url_https;
} else {
$tweet_screen_name = $tweet->user->screen_name;
$tweet_user_image = $tweet->user->profile_image_url_https;
}
?>
<p class="tweet-user-image">
<a <?php echo $new_tab_text; ?>href="https://twitter.com/<?php echo esc_html( $tweet_screen_name ); ?>">
<img src="<?php echo esc_html( $tweet_user_image ); ?>" alt="profile picture" width="32" height="32" />
</a>
</p>
<?php
}
?>
<p class="tweet-user-image">
<a <?php echo $new_tab_text; ?>href="https://twitter.com/<?php echo esc_html( $tweet_screen_name ); ?>">
<img src="<?php echo esc_html( $tweet_user_image ); ?>" alt="profile picture" width="32" height="32" />
</a>
</p>
<p class="tweet-body">
<?php echo $this->format( $tweet ); ?>
</p>
Expand Down
9 changes: 9 additions & 0 deletions includes/class-aldolat-twitter-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function update( $new_instance, $old_instance ) {

$instance['exclude_replies'] = isset( $new_instance['exclude_replies'] ) ? true : false;
$instance['include_rts'] = isset( $new_instance['include_rts'] ) ? true : false;
$instance['display_avatar'] = isset( $new_instance['display_avatar'] ) ? true : false;

$instance['cache_duration'] = absint( sanitize_text_field( $new_instance['cache_duration'] ) );
if ( 0 === $instance['cache_duration'] || '' === $instance['cache_duration'] || ! is_numeric( $instance['cache_duration'] ) ) {
Expand Down Expand Up @@ -252,6 +253,14 @@ public function form( $instance ) {
$instance['include_rts']
);

// Display avatar.
aldolat_twitter_form_checkbox(
esc_html__( 'Display user profile picture', 'aldolat-twitter' ),
$this->get_field_id( 'display_avatar' ),
$this->get_field_name( 'display_avatar' ),
$instance['display_avatar']
);

// Cache.
aldolat_twitter_form_input_text(
esc_html__( 'Cache duration:', 'aldolat-twitter' ),
Expand Down
2 changes: 1 addition & 1 deletion includes/class-aldolat-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Aldolat_Twitter {
* @since 0.0.4
*/
public function __construct() {
$this->plugin_version = '0.5.0';
$this->plugin_version = '0.6.0';
$this->plugin_dir_path = trailingslashit( dirname( plugin_dir_path( __FILE__ ) ) );
$this->plugin_dirname = trailingslashit( dirname( plugin_basename( __FILE__ ), 2 ) );
}
Expand Down
83 changes: 45 additions & 38 deletions languages/aldolat-twitter-it_IT.po
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Copyright (C) 2020 Aldo Latino
# This file is distributed under the same license as the Aldolat Twitter plugin.
# Aldo Latino <[email protected]>, 2020.
# Aldo Latino <[email protected]>, 2020, 2021.
msgid ""
msgstr ""
"Project-Id-Version: Aldolat Twitter 0.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/aldolat-twitter\n"
"POT-Creation-Date: 2021-02-27T18:51:26+01:00\n"
"PO-Revision-Date: 2020-08-09 17:20+0200\n"
"POT-Creation-Date: 2021-03-28T08:17:37+02:00\n"
"PO-Revision-Date: 2021-03-28 08:18+0200\n"
"Last-Translator: Aldo Latino <[email protected]>\n"
"Language-Team: Italian <[email protected]>\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Lokalize 20.04.3\n"
"X-Generator: Lokalize 20.12.3\n"
"X-Domain: aldolat-twitter\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

Expand All @@ -38,141 +38,148 @@ msgstr "Aldo Latino"
msgid "https://www.aldolat.it/"
msgstr "https://www.aldolat.it/"

#: includes/aldolat-twitter-functions.php:42
#: includes/class-aldolat-twitter-widget.php:179
#: includes/aldolat-twitter-functions.php:44
#: includes/class-aldolat-twitter-widget.php:180
msgid "My latest tweets"
msgstr "I miei ultimi tweet"

#: includes/class-aldolat-twitter-core.php:77
#: includes/class-aldolat-twitter-core.php:79
msgid "No response from Twitter"
msgstr "Nessuna risposta da Twitter"

#. translators: The original tweet author name and link.
#: includes/class-aldolat-twitter-core.php:194
#: includes/class-aldolat-twitter-core.php:200
msgid "In reply to %s"
msgstr "In risposta a %s"

#: includes/class-aldolat-twitter-core.php:220
#: includes/class-aldolat-twitter-core.php:226
msgid "by"
msgstr "da"

#. translators: date and tweet author name
#: includes/class-aldolat-twitter-core.php:227
#: includes/class-aldolat-twitter-core.php:233
msgid "(RT on %1$s by %2$s)"
msgstr "(RT il %1$s da %2$s)"

#: includes/class-aldolat-twitter-core.php:329
#: includes/class-aldolat-twitter-core.php:335
msgid "ago"
msgstr "fa"

#: includes/class-aldolat-twitter-widget.php:30
msgid "Publish your tweets in your blog"
msgstr "Pubblica i tuoi tweet nel tuo blog"

#: includes/class-aldolat-twitter-widget.php:170
#: includes/class-aldolat-twitter-widget.php:171
msgid "Title of the widget"
msgstr "Titolo del widget"

#: includes/class-aldolat-twitter-widget.php:175
#: includes/class-aldolat-twitter-widget.php:176
msgid "Title:"
msgstr "Titolo:"

#: includes/class-aldolat-twitter-widget.php:183
#: includes/class-aldolat-twitter-widget.php:184
msgid "Introductory text"
msgstr "Testo introduttivo"

#: includes/class-aldolat-twitter-widget.php:188
#: includes/class-aldolat-twitter-widget.php:189
msgid "Place this text after the title:"
msgstr "Metti questo testo dopo il titolo:"

#: includes/class-aldolat-twitter-widget.php:192
#: includes/class-aldolat-twitter-widget.php:193
msgid "These are my latest tweets. Follow me on Twitter!"
msgstr "Questi sono i miei ultimi tweet. Seguimi su Twitter!"

#: includes/class-aldolat-twitter-widget.php:193
#: includes/class-aldolat-twitter-widget.php:194
msgid "You can use some HTML, as you would do when writing a post."
msgstr "Puoi usare anche dell'HTML, come quando scrivi un articolo."

#: includes/class-aldolat-twitter-widget.php:198
#: includes/class-aldolat-twitter-widget.php:199
msgid "Setup"
msgstr "Impostazioni"

#: includes/class-aldolat-twitter-widget.php:203
#: includes/class-aldolat-twitter-widget.php:204
msgid "Username on Twitter:"
msgstr "Nome utente su Twitter:"

#: includes/class-aldolat-twitter-widget.php:207
#: includes/class-aldolat-twitter-widget.php:208
msgid "username"
msgstr "nome_utente"

#: includes/class-aldolat-twitter-widget.php:208
#: includes/class-aldolat-twitter-widget.php:209
msgid "This is the only mandatory option."
msgstr "Questa è l'unica opzione obbligatoria."

#: includes/class-aldolat-twitter-widget.php:215
#: includes/class-aldolat-twitter-widget.php:216
msgid "Timeline"
msgstr "Timeline"

#: includes/class-aldolat-twitter-widget.php:219
#: includes/class-aldolat-twitter-widget.php:220
msgid "Favorites"
msgstr "Mi piace"

#: includes/class-aldolat-twitter-widget.php:232
#: includes/class-aldolat-twitter-widget.php:233
msgid "Number of items:"
msgstr "Numero di voci:"

#: includes/class-aldolat-twitter-widget.php:241
#: includes/class-aldolat-twitter-widget.php:242
msgid "Exclude replies"
msgstr "Escludi le risposte"

#: includes/class-aldolat-twitter-widget.php:249
#: includes/class-aldolat-twitter-widget.php:250
msgid "Include retweets"
msgstr "Includi i retweet"

#: includes/class-aldolat-twitter-widget.php:257
#: includes/class-aldolat-twitter-widget.php:258
msgid "Display user profile picture"
msgstr "Mostra l'immagine del profilo utente"

#: includes/class-aldolat-twitter-widget.php:266
msgid "Cache duration:"
msgstr "Durata della cache:"

#: includes/class-aldolat-twitter-widget.php:262
#: includes/class-aldolat-twitter-widget.php:271
msgid "In minutes. The minimum accepted value is 5."
msgstr "In minuti. Il valore minimo accettato è 5."

#: includes/class-aldolat-twitter-widget.php:267
#: includes/class-aldolat-twitter-widget.php:276
msgid "Open links in a new browser tab"
msgstr "Apri i link in una nuova scheda del browser"

#: includes/class-aldolat-twitter-widget.php:274
#: includes/class-aldolat-twitter-widget.php:283
msgid "Twitter authentication"
msgstr "Autenticazione su Twitter"

#: includes/class-aldolat-twitter-widget.php:279
#: includes/class-aldolat-twitter-widget.php:288
msgid "Consumer Key:"
msgstr "Consumer Key:"

#: includes/class-aldolat-twitter-widget.php:284
#: includes/class-aldolat-twitter-widget.php:293
msgid "Insert Consumer Key"
msgstr "Inserisci la Consumer Key:"

#: includes/class-aldolat-twitter-widget.php:291
#: includes/class-aldolat-twitter-widget.php:300
msgid "Consumer secret:"
msgstr "Consumer secret:"

#: includes/class-aldolat-twitter-widget.php:296
#: includes/class-aldolat-twitter-widget.php:305
msgid "Insert Consumer Secret"
msgstr "Inserisci il Consumer secret:"

#: includes/class-aldolat-twitter-widget.php:303
#: includes/class-aldolat-twitter-widget.php:312
msgid "Oauth token:"
msgstr "Oauth token:"

#: includes/class-aldolat-twitter-widget.php:308
#: includes/class-aldolat-twitter-widget.php:317
msgid "Insert Oauth Token"
msgstr "Inserisci l'Oauth token:"

#: includes/class-aldolat-twitter-widget.php:315
#: includes/class-aldolat-twitter-widget.php:324
msgid "Oauth token secret:"
msgstr "Oauth token secret:"

#: includes/class-aldolat-twitter-widget.php:320
#: includes/class-aldolat-twitter-widget.php:329
msgid "Insert Oauth Token Secret"
msgstr "Inserisci l'Oauth token secret:"

#~ msgid "Display avatar"
#~ msgstr "Mostra l'avatar"
Loading

0 comments on commit 349a14f

Please sign in to comment.