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

Commit

Permalink
Releasing 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aldolat committed Aug 9, 2020
2 parents 9c58189 + 86b5800 commit de6f6e5
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 112 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.4.0] - 2020-08-09
### Changed
* Short changes in code.


## [0.3.0] - 2020-07-26
### Changed
* Removed use of gmdate() in favour of wp_date().
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.4
**Stable tag** 0.3.0
**Stable tag** 0.4.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.3.0
* Version: 0.4.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.4.0 =

* Short changes in code.

= 0.3.0 =

* Removed use of gmdate() in favour of wp_date().
Expand Down
64 changes: 39 additions & 25 deletions includes/class-aldolat-twitter-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ public function __construct( $args ) {
);
}

/**
* Get the tweets.
*
* @since 0.1.0
* @access public
*/
public function the_tweets() {
$tweets = $this->fetch();
$new_tab_text = $this->new_tab( $this->plugin_settings['new_tab'] );

if ( false === $tweets ) {
esc_html_e( 'No response from Twitter', 'aldolat-twitter' );
} else {
$this->the_html_tweets( $tweets, $new_tab_text );
}
}

/**
* Fetch the tweets from Twitter.
*
Expand All @@ -81,16 +98,20 @@ public function __construct( $args ) {
* @access private
*/
private function fetch() {
$widget_id = preg_replace( '/\D/', '', $this->plugin_settings['widget_id'] );
$the_widget_id = preg_replace( '/\D/', '', $this->plugin_settings['widget_id'] );

$transient = get_transient( 'aldolat-twitter-tweets-' . $widget_id );
$transient = get_transient( 'aldolat-twitter-tweets-' . $the_widget_id );

if ( false === $transient ) {
$response = $this->get_response();
$tweets = json_decode( $response );
set_transient( 'aldolat-twitter-tweets-' . $widget_id, $tweets, $this->plugin_settings['cache_duration'] * MINUTE_IN_SECONDS );
} else {
if ( $transient ) {
$tweets = $transient;
} else {
$response = $this->get_response();
if ( $response ) {
$tweets = json_decode( $response );
set_transient( 'aldolat-twitter-tweets-' . $the_widget_id, $tweets, $this->plugin_settings['cache_duration'] * MINUTE_IN_SECONDS );
} else {
$tweets = false;
}
}

return $tweets;
Expand Down Expand Up @@ -129,16 +150,15 @@ private function get_response() {
return $response;
}


/**
* Get the tweets.
* Print the HTML with tweets.
*
* @return string $output The final HTML with tweets.
* @since 0.1.0
* @access public
* @param $tweets The array containing the tweets.
* @param $new_tab_text The string with the text for HTML new tab.
* @since 0.4.0
*/
public function the_tweets() {
$tweets = $this->fetch();
$new_tab_text = $this->new_tab( $this->plugin_settings['new_tab'] );
private function the_html_tweets( $tweets, $new_tab_text ) {
?>

<div id="twitter-feed">
Expand All @@ -156,7 +176,7 @@ public function the_tweets() {
}
?>
<p class="tweet-user-image">
<a <?php echo esc_html( $new_tab_text ); ?>href="https://twitter.com/<?php echo esc_html( $tweet_screen_name ); ?>">
<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>
Expand Down Expand Up @@ -193,25 +213,19 @@ public function the_tweets() {
}
?>
<span class="tweet-date">
<a <?php echo esc_html( $new_tab_text ); ?>href="https://twitter.com/<?php echo esc_html( $tweet_user ); ?>/status/<?php echo esc_html( $tweet_id ); ?>">
<time>
<?php echo esc_html( $this->get_tweet_time( $tweet_time ) ); ?>
</time>
</a>
<a <?php echo $new_tab_text; ?>href="https://twitter.com/<?php echo esc_html( $tweet_user ); ?>/status/<?php echo esc_html( $tweet_id ); ?>"><time><?php echo esc_html( $this->get_tweet_time( $tweet_time ) ); ?></time></a>
</span>
<span class="tweet-author">
<?php esc_html_e( 'by', 'aldolat-twitter' ); ?>
<a <?php echo esc_html( $new_tab_text ); ?>href="https://twitter.com/<?php echo esc_html( $tweet_user ); ?>">
<?php echo esc_html( $tweet_name ); ?>
</a>
<a <?php echo $new_tab_text; ?>href="https://twitter.com/<?php echo esc_html( $tweet_user ); ?>"><?php echo esc_html( $tweet_name ); ?></a>
</span>
<?php
if ( isset( $tweet->retweeted_status ) ) {
printf(
// translators: date and tweet author name
' ' . esc_html__( '(RT on %1$s by %2$s)', 'aldolat-twitter' ),
'<a ' . esc_html( $new_tab_text ) . 'href="https://twitter.com/' . esc_html( $tweet->user->screen_name ) . '/status/' . esc_html( $tweet->id_str ) . '">' . esc_html( $this->get_tweet_time( $tweet->created_at ) ) . '</a>',
'<a ' . esc_html( $new_tab_text ) . 'href="https://twitter.com/' . esc_html( $tweet->user->screen_name ) . '">' . esc_html( $tweet->user->name ) . '</a>'
'<a ' . $new_tab_text . 'href="https://twitter.com/' . esc_html( $tweet->user->screen_name ) . '/status/' . esc_html( $tweet->id_str ) . '">' . esc_html( $this->get_tweet_time( $tweet->created_at ) ) . '</a>',
'<a ' . $new_tab_text . 'href="https://twitter.com/' . esc_html( $tweet->user->screen_name ) . '">' . esc_html( $tweet->user->name ) . '</a>'
);
}
?>
Expand Down
36 changes: 21 additions & 15 deletions includes/class-aldolat-twitter-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function __construct() {
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
$instance = wp_parse_args( $instance, aldolat_twitter_get_defaults() );
$defaults = aldolat_twitter_get_defaults();
$instance = wp_parse_args( $instance, $defaults );

echo "\n" . '<!-- Start Aldolat Twitter - ' . $args['widget_id'] . ' -->' . "\n";

Expand All @@ -77,19 +78,23 @@ public function widget( $args, $instance ) {
echo '<p class="aldolat-twitter-intro-text">' . wp_kses_post( $instance['intro_text'] ) . '</p>';
}

/* $params = array(
'screen_name' => $instance['screen_name'],
'count' => $instance['count'],
'exclude_replies' => $instance['exclude_replies'],
'include_rts' => $instance['include_rts'],
'cache_duration' => $instance['cache_duration'],
'new_tab' => $instance['new_tab'],
'consumer_key' => $instance['consumer_key'],
'consumer_secret' => $instance['consumer_secret'],
'oauth_token' => $instance['oauth_token'],
'oauth_token_secret' => $instance['oauth_token_secret'],
'widget_id' => $args['widget_id'],
); */
/*
* The $instance variable contains:
* title
* intro_text
* screen_name
* type_of_tweets
* count
* exclude_replies
* include_rts
* cache_duration
* new_tab
* consumer_key
* consumer_secret
* oauth_token
* oauth_token_secret
* widget_id
*/
$aldolat_tweets = new Aldolat_Twitter_Core( $instance );
$aldolat_tweets->the_tweets();

Expand Down Expand Up @@ -156,7 +161,8 @@ public function update( $new_instance, $old_instance ) {
* @param array $instance Previously saved values from database.
*/
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, aldolat_twitter_get_defaults() );
$defaults = aldolat_twitter_get_defaults();
$instance = wp_parse_args( (array) $instance, $defaults );
?>

<div class="aldolat-twitter-widget-content">
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.1.0';
$this->plugin_version = '0.4.0';
$this->plugin_dir_path = trailingslashit( dirname( plugin_dir_path( __FILE__ ) ) );
$this->plugin_dirname = trailingslashit( dirname( plugin_basename( __FILE__ ), 2 ) );
}
Expand Down
Binary file modified languages/aldolat-twitter-it_IT.mo
Binary file not shown.
Loading

0 comments on commit de6f6e5

Please sign in to comment.