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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aldolat committed Jun 1, 2020
2 parents c705a6c + 029fc9d commit af7c7f6
Show file tree
Hide file tree
Showing 18 changed files with 1,194 additions and 56 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## 0.0.2 - 2020-06-01
### Added
* First completion of the plugin.

## 0.0.1 - 2020-06-01
### Added
* First release of the plugin.

[Unreleased]: https://github.com/aldolat/aldolat-twitter/commits/develop
[0.0.2]: https://github.com/aldolat/aldolat-twitter/compare/0.0.1...0.0.2
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Aldolat Twitter

**Contributors** aldolat
**Donate link** https://dev.aldolat.it/projects/aldolat-twitter/
**Tags** twitter, sidebar, widget
**Requires at least** 5.4
**Tested up to** 5.4
**Stable tag** 0.0.2
**License** GPLv3 or later
**License URI** https://www.gnu.org/licenses/gpl-3.0.html

Display your Tweets in a widget.

* [Aldolat Twitter](#aldolat-twitter)
* [Description](#description)
* [Filing Bugs](#filing-bugs)
* [Privacy Policy](#privacy-policy)
* [Installation](#installation)
* [Installing the plugin](#installing-the-plugin)
* [Uninstalling the plugin](#uninstalling-the-plugin)

## Description

This plugin provides a widget where to display your tweets.

## Filing Bugs

If you have found a bug, please report it on [GitHub](https://github.com/aldolat/aldolat-twitter/issues).

This plugin is developed using [GitHub](https://github.com/aldolat/aldolat-twitter). If you wrote an enhancement and would share it with the world, please send me a [Pull request](https://github.com/aldolat/aldolat-twitter/pulls).

## Privacy Policy

This plugin does not collect any user data.

## Installation

### Installing the plugin

This section describes how to install the plugin and get it working.

1. Upload the `aldolat-twitter` directory to the `/wp-content/plugins/` directory
1. Activate the plugin through the Plugins menu in WordPress
1. Go to the widgets manager and add the newly available widget into the sidebar
1. Adjust the options to fit your needs
1. Save and test your results.

### Uninstalling the plugin

Aldolat Twitter cleans up after itself. All plugin settings will be removed from your database when the plugin is uninstalled via the Plugins screen.
10 changes: 10 additions & 0 deletions TwitterOAuth/Exception/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Aldolat Twitter plugin index.php file.
*
* This file is intended to be empty.
*
* @package AldolatTwitter
*/

/* Silence is golden */
10 changes: 10 additions & 0 deletions TwitterOAuth/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Aldolat Twitter plugin index.php file.
*
* This file is intended to be empty.
*
* @package AldolatTwitter
*/

/* Silence is golden */
10 changes: 7 additions & 3 deletions aldolat-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
* Plugin URI: https://dev.aldolat.it/projects/aldolat-twitter/
* Author: Aldo Latino
* Author URI: https://www.aldolat.it/
* Version: 0.0.1
* Version: 0.0.2
* License: GPLv3 or later
* Text Domain: aldolat-twitter
* Domain Path: /languages/
*/

/*
* Copyright (C) 2019, 2020 Aldo Latino (email : [email protected])
* Copyright (C) 2020 Aldo Latino (email : [email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -41,6 +41,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* TODO: Change the caching so that the user can use more than one widget.
*/

/**
* Prevent direct access to this file.
*
Expand All @@ -66,7 +70,7 @@ function aldolat_twitter_setup() {
/*
* Define the version of the plugin.
*/
define( 'ALDOLAT_TWITTER_PLUGIN_VERSION', '0.0.1' );
define( 'ALDOLAT_TWITTER_PLUGIN_VERSION', '0.0.2' );

/*
* Load the translation.
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
== Changelog ==

= 0.0.2 =

* First completion of the plugin.

= 0.0.1 =

* First release of the plugin.
10 changes: 6 additions & 4 deletions includes/aldolat-twitter-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* $defaults contains the default parameters:
* string $title The title of the widget.
* string $intro_text The introductory text for the widget.
* string $username The username on Pinboard.
* string $username The username on Twitter.
* string $widget_id The ID of the widget.
* }
*
Expand All @@ -30,11 +30,13 @@
*/
function aldolat_twitter_get_defaults() {
$defaults = array(
'title' => esc_html__( 'My tweets', 'pinboard-bookmarks' ),
'title' => esc_html__( 'My latest tweets', 'aldolat-twitter' ),
'intro_text' => '',
'screen_name' => '',
'count' => 3,
'exclude_replies' => true,
'exclude_replies' => false,
'include_rts' => true,
'cache_duration' => 5, // In minutes.
'consumer_key' => '',
'consumer_secret' => '',
'oauth_token' => '',
Expand Down Expand Up @@ -62,7 +64,7 @@ function aldolat_twitter_get_tweets( $args ) {
if ( false === $feed ) {
$twitter_getter = new Aldolat_Twitter( $args );
$html = $twitter_getter->fetch();
set_transient( 'aldolat-twitter-tweets', $html, 5 * MINUTE_IN_SECONDS );
set_transient( 'aldolat-twitter-tweets', $html, $args['cache_duration'] * MINUTE_IN_SECONDS );
} else {
$html = $feed;
}
Expand Down
6 changes: 3 additions & 3 deletions includes/aldolat-twitter-widget-form-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function aldolat_twitter_form_label( $label, $id ) {
* @uses aldolat_twitter_form_label
*/
function aldolat_twitter_form_input_text( $label, $id, $name, $value, $placeholder = '', $comment = '', $style = '', $class = '' ) {
$class = rtrim( 'widefat pinboard-bookmarks-input ' . $class );
$class = rtrim( 'widefat aldolat-twitter-input ' . $class );

if ( $style ) {
echo '<p style="' . esc_attr( $style ) . '">';
Expand Down Expand Up @@ -111,7 +111,7 @@ class="widefat"
* @since 1.12
*/
function aldolat_twitter_form_checkbox( $label, $id, $name, $checked, $comment = '', $class = '' ) {
$class = rtrim( 'checkbox pinboard-bookmarks-checkbox ' . $class );
$class = rtrim( 'checkbox aldolat-twitter-checkbox ' . $class );
?>
<p>
<input class="<?php echo esc_attr( $class ); ?>" type="checkbox" <?php checked( $checked ); ?> id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $name ); ?>" />
Expand Down Expand Up @@ -139,7 +139,7 @@ function aldolat_twitter_form_checkbox( $label, $id, $name, $checked, $comment =
* @since 1.12
*/
function aldolat_twitter_form_select( $label, $id, $name, $options, $value, $comment = '', $class = '' ) {
$class = rtrim( 'pinboard-bookmarks-select ' . $class );
$class = rtrim( 'aldolat-twitter-select ' . $class );
?>
<p>
<?php aldolat_twitter_form_label( $label, $id ); ?>
Expand Down
85 changes: 56 additions & 29 deletions includes/class-aldolat-twitter-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,21 @@ public function widget( $args, $instance ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title'];
}

// The introductory text.
if ( $instance['intro_text'] ) {
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'],
'consumer_key' => $instance['consumer_key'],
'consumer_secret' => $instance['consumer_secret'],
'oauth_token' => $instance['oauth_token'],
'oauth_token_secret' => $instance['oauth_token_secret'],
'screen_name' => $instance['screen_name'],
'count' => $instance['count'],
'exclude_replies' => $instance['exclude_replies'],
);
aldolat_twitter_tweets( $params );

Expand Down Expand Up @@ -109,8 +116,21 @@ public function update( $new_instance, $old_instance ) {
if ( 0 === $instance['count'] || '' === $instance['count'] || ! is_numeric( $instance['count'] ) ) {
$instance['count'] = 3;
}
if ( 200 < $instance['count'] ) {
$instance['count'] = 200;
}

$instance['exclude_replies'] = isset( $new_instance['exclude_replies'] ) ? true : false;
$instance['include_rts'] = isset( $new_instance['include_rts'] ) ? 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'] ) ) {
$instance['cache_duration'] = 5;
}
if ( 5 > $instance['cache_duration'] ) {
$instance['cache_duration'] = 5;
}

$instance['consumer_key'] = sanitize_text_field( $new_instance['consumer_key'] );
$instance['consumer_secret'] = sanitize_text_field( $new_instance['consumer_secret'] );
$instance['oauth_token'] = sanitize_text_field( $new_instance['oauth_token'] );
Expand All @@ -135,50 +155,39 @@ public function form( $instance ) {

<div class="aldolat-twitter-widget-content">

<h4><?php esc_html_e( 'Introduction', 'aldolat-twitter' ); ?></h4>

<p>
<?php
esc_html_e(
'This widget allows you to publish your tweets in your sidebar.',
'aldolat-twitter'
);
?>
</p>

<h4><?php esc_html_e( 'Title of the widget', 'aldolat-twitter' ); ?></h4>

<?php
// Title.
pinboard_bookmarks_form_input_text(
esc_html__( 'Title:', 'aldolat-twitter' ),
aldolat_twitter_form_input_text(
esc_html__( 'Title', 'aldolat-twitter' ),
$this->get_field_id( 'title' ),
$this->get_field_name( 'title' ),
esc_attr( $instance['title'] ),
esc_html__( 'My bookmarks on Pinboard', 'aldolat-twitter' )
esc_html__( 'My latest tweets', 'aldolat-twitter' )
);
?>

<h4><?php esc_html_e( 'Introductory text', 'aldolat-twitter' ); ?></h4>

<?php
// Introductory text.
pinboard_bookmarks_form_textarea(
aldolat_twitter_form_textarea(
esc_html__( 'Place this text after the title', 'aldolat-twitter' ),
$this->get_field_id( 'intro_text' ),
$this->get_field_name( 'intro_text' ),
$instance['intro_text'],
esc_html__( 'These are my bookmarks on Pinboard about Italian recipes.', 'aldolat-twitter' ),
esc_html__( 'These are my latest tweets. Follow me on Twitter!', 'aldolat-twitter' ),
esc_html__( 'You can use some HTML, as you would do when writing a post.', 'aldolat-twitter' ),
$style = 'resize: vertical; height: 80px;'
);
?>

<h4><?php esc_html_e( 'Basic Setup', 'aldolat-twitter' ); ?></h4>
<h4><?php esc_html_e( 'Setup', 'aldolat-twitter' ); ?></h4>

<?php
// Username.
pinboard_bookmarks_form_input_text(
aldolat_twitter_form_input_text(
esc_html__( 'Username on Twitter:', 'aldolat-twitter' ),
$this->get_field_id( 'screen_name' ),
$this->get_field_name( 'screen_name' ),
Expand All @@ -188,49 +197,67 @@ public function form( $instance ) {
);

// Number of items.
pinboard_bookmarks_form_input_text(
aldolat_twitter_form_input_text(
esc_html__( 'Number of items:', 'aldolat-twitter' ),
$this->get_field_id( 'count' ),
$this->get_field_name( 'count' ),
esc_attr( $instance['count'] ),
'3'
);

// Random order.
pinboard_bookmarks_form_checkbox(
esc_html__( 'Esclude replies', 'aldolat-twitter' ),
// Exclude replies.
aldolat_twitter_form_checkbox(
esc_html__( 'Exclude replies', 'aldolat-twitter' ),
$this->get_field_id( 'exclude_replies' ),
$this->get_field_name( 'exclude_replies' ),
$instance['exclude_replies']
);

// Include retweets.
aldolat_twitter_form_checkbox(
esc_html__( 'Include retweets', 'aldolat-twitter' ),
$this->get_field_id( 'include_rts' ),
$this->get_field_name( 'include_rts' ),
$instance['include_rts']
);

// Cache.
aldolat_twitter_form_input_text(
esc_html__( 'Cache duration:', 'aldolat-twitter' ),
$this->get_field_id( 'cache_duration' ),
$this->get_field_name( 'cache_duration' ),
esc_attr( $instance['cache_duration'] ),
'5',
esc_html__( 'In minutes. The minimum accepted value is 5.', 'aldolat-twitter' )
);
?>

<h4><?php esc_html_e( 'Twitter authentication', 'aldolat-twitter' ); ?></h4>

<?php
// Consumer key.
pinboard_bookmarks_form_input_text(
aldolat_twitter_form_input_text(
esc_html__( 'Consumer Key:', 'aldolat-twitter' ),
$this->get_field_id( 'consumer_key' ),
$this->get_field_name( 'consumer_key' ),
esc_attr( $instance['consumer_key'] )
);
// Consumer secret.
pinboard_bookmarks_form_input_text(
aldolat_twitter_form_input_text(
esc_html__( 'Consumer secret:', 'aldolat-twitter' ),
$this->get_field_id( 'consumer_secret' ),
$this->get_field_name( 'consumer_secret' ),
esc_attr( $instance['consumer_secret'] )
);
// Oauth token.
pinboard_bookmarks_form_input_text(
aldolat_twitter_form_input_text(
esc_html__( 'Oauth token:', 'aldolat-twitter' ),
$this->get_field_id( 'oauth_token' ),
$this->get_field_name( 'oauth_token' ),
esc_attr( $instance['oauth_token'] )
);
// Oauth token secret.
pinboard_bookmarks_form_input_text(
aldolat_twitter_form_input_text(
esc_html__( 'Oauth token secret:', 'aldolat-twitter' ),
$this->get_field_id( 'oauth_token_secret' ),
$this->get_field_name( 'oauth_token_secret' ),
Expand Down
Loading

0 comments on commit af7c7f6

Please sign in to comment.