Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 1.04 — Clickable hashtags and label changes.

  • Loading branch information...
commit 75f76ffae2e7b51ccb716fd099c3f4a0ab175b2e 1 parent a9502ef
@matthiassiegel authored
Showing with 19 additions and 9 deletions.
  1. +4 −0 README.md
  2. +4 −1 readme.txt
  3. +11 −8 twitter.php
View
4 README.md
@@ -46,9 +46,13 @@ The code has been extensively tested and most issues can be resolved by trying t
Also keep in mind it will only work with public Twitter feeds, not private ones.
+
Changelog
---------
+### 1.04
+* Clickable hashtags (thanks Tyler Longren)
+
### 1.03
* Added new option to HTML-encode special characters like ampersands (requested)
View
5 readme.txt
@@ -4,7 +4,7 @@ Donate link: http://chipsandtv.com/
Tags: twitter, widget
Requires at least: 2.8
Tested up to: 3.2.1
-Stable tag: 1.03
+Stable tag: 1.04
A simple but powerful widget to display updates from a Twitter feed. Configurable and reliable.
@@ -54,6 +54,9 @@ Also keep in mind it will only work with public Twitter feeds, not private ones.
== Changelog ==
+= 1.04 =
+* Clickable hashtags (thanks Tyler Longren)
+
= 1.03 =
* Added new option to HTML-encode special characters like ampersands (requested)
View
19 twitter.php
@@ -3,7 +3,7 @@
Plugin Name: Simple Twitter Widget
Plugin URI: http://chipsandtv.com/
Description: A simple but powerful widget to display updates from a Twitter feed. Configurable and reliable.
-Version: 1.03
+Version: 1.04
Author: Matthias Siegel
Author URI: http://chipsandtv.com/
@@ -115,7 +115,10 @@ function widget($args, $instance) {
$text = preg_replace('`\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))`', '<a href="$0">$0</a>', $text);
// Match @name
- $text = preg_replace('/(@)([a-zA-Z0-9\_]+)/', '@<a href="http://twitter.com/$2">$2</a>', $text);
+ $text = preg_replace('/(@)([a-zA-Z0-9\_]+)/', '@<a href="https://twitter.com/$2">$2</a>', $text);
+
+ // Match #hashtag
+ $text = preg_replace('/(#)([a-zA-Z0-9\_]+)/', '#<a href="https://twitter.com/search/?q=$2">$2</a>', $text);
endif;
// Display date/time
@@ -226,7 +229,7 @@ function form($instance) {
</p>
<p>
- <label for="<?php echo $this->get_field_id('posts'); ?>">Display how many posts?</label>
+ <label for="<?php echo $this->get_field_id('posts'); ?>">Number of posts to display</label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('posts'); ?>" name="<?php echo $this->get_field_name('posts'); ?>" value="<?php echo $instance['posts']; ?>">
</p>
@@ -242,27 +245,27 @@ function form($instance) {
<p>
<input class="checkbox" type="checkbox" <?php if ($instance['datedisplay']) echo 'checked="checked" '; ?>id="<?php echo $this->get_field_id('datedisplay'); ?>" name="<?php echo $this->get_field_name('datedisplay'); ?>">
- <label for="<?php echo $this->get_field_id('datedisplay'); ?>">Display date?</label>
+ <label for="<?php echo $this->get_field_id('datedisplay'); ?>">Display date</label>
<br>
<input class="checkbox" type="checkbox" <?php if ($instance['datebreak']) echo 'checked="checked" '; ?>id="<?php echo $this->get_field_id('datebreak'); ?>" name="<?php echo $this->get_field_name('datebreak'); ?>">
- <label for="<?php echo $this->get_field_id('datebreak'); ?>">Add linebreak after date?</label>
+ <label for="<?php echo $this->get_field_id('datebreak'); ?>">Add linebreak after date</label>
<br>
<input class="checkbox" type="checkbox" <?php if ($instance['clickable']) echo 'checked="checked" '; ?>id="<?php echo $this->get_field_id('clickable'); ?>" name="<?php echo $this->get_field_name('clickable'); ?>">
- <label for="<?php echo $this->get_field_id('clickable'); ?>">Make URLs &amp; usernames clickable?</label>
+ <label for="<?php echo $this->get_field_id('clickable'); ?>">Clickable URLs, names &amp; hashtags</label>
<br>
<input class="checkbox" type="checkbox" <?php if ($instance['hideerrors']) echo 'checked="checked" '; ?>id="<?php echo $this->get_field_id('hideerrors'); ?>" name="<?php echo $this->get_field_name('hideerrors'); ?>">
- <label for="<?php echo $this->get_field_id('hideerrors'); ?>">Hide error message if update fails?</label>
+ <label for="<?php echo $this->get_field_id('hideerrors'); ?>">Hide error message if update fails</label>
<br>
<input class="checkbox" type="checkbox" <?php if ($instance['encodespecial']) echo 'checked="checked" '; ?>id="<?php echo $this->get_field_id('encodespecial'); ?>" name="<?php echo $this->get_field_name('encodespecial'); ?>">
- <label for="<?php echo $this->get_field_id('encodespecial'); ?>">HTML-encode special characters?</label>
+ <label for="<?php echo $this->get_field_id('encodespecial'); ?>">HTML-encode special characters</label>
</p>
<?php
Please sign in to comment.
Something went wrong with that request. Please try again.