Comments (3)
When I retweet this: https://twitter.com/nrjeon/status/385997195335303168
The URL at the end of the tweet is truncated.
from wp-twitter-tools.
The following patch fixes the problem:
diff -urN a/classes/aktt_tweet.php b/classes/aktt_tweet.php
--- a/classes/aktt_tweet.php 2013-10-05 01:18:26.000000000 +0900
+++ b/classes/aktt_tweet.php 2013-10-05 01:19:38.000000000 +0900
@@ -90,6 +90,9 @@
* @return string
*/
public function content() {
+ if ($this->is_native_retweet()) {
+ return $this->data->retweeted_status->text;
+ }
if (isset($this->data) && isset($this->data->text)) {
return $this->data->text;
}
@@ -141,7 +144,11 @@
* @return string
*/
public function hashtags() {
- return (isset($this->data) && isset($this->data->entities) ? $this->data->entities->hashtags : array());
+ if ($this->is_native_retweet()) {
+ return (isset($this->data->retweeted_status->entities) ? $this->data->retweeted_status->entities->hashtags : array());
+ } else {
+ return (isset($this->data) && isset($this->data->entities) ? $this->data->entities->hashtags : array());
+ }
}
/**
@@ -150,7 +157,11 @@
* @return string
*/
public function mentions() {
- return (isset($this->data) && isset($this->data->entities) ? $this->data->entities->user_mentions : array());
+ if ($this->is_native_retweet()) {
+ return (isset($this->data->retweeted_status->entities) ? $this->data->retweeted_status->entities->user_mentions : array());
+ } else {
+ return (isset($this->data) && isset($this->data->entities) ? $this->data->entities->user_mentions : array());
+ }
}
/**
@@ -159,7 +170,11 @@
* @return string
*/
public function urls() {
- return (isset($this->data) && isset($this->data->entities) ? $this->data->entities->urls : array());
+ if ($this->is_native_retweet()) {
+ return (isset($this->data->retweeted_status->entities) ? $this->data->retweeted_status->entities->urls : array());
+ } else {
+ return (isset($this->data) && isset($this->data->entities) ? $this->data->entities->urls : array());
+ }
}
/**
@@ -287,12 +302,22 @@
/**
- * Is this a retweet?
+ * Is this a native retweet?
+ *
+ * @return bool
+ */
+ function is_native_retweet() {
+ return (bool) (isset($this->data) && !empty($this->data->retweeted_status));
+ }
+
+
+ /**
+ * Is this a retweet? (This includes both native and non-native retweets.)
*
* @return bool
*/
function is_retweet() {
- return (bool) (AKTT::substr($this->content(), 0, 2) == 'RT' || !empty($this->data->retweeted_status));
+ return (bool) (AKTT::substr($this->content(), 0, 2) == 'RT' || $this->is_native_retweet());
}
@@ -366,6 +391,12 @@
$str = AKTT::substr_replace($str, $entity['replace'], $start, ($end - $start));
$diff += AKTT::strlen($entity['replace']) - ($end - $start);
}
+
+ if ($this->is_native_retweet()) {
+ $orig_screen_name = $this->data->retweeted_status->user->screen_name;
+ $str = 'RT '.AKTT::profile_link($orig_screen_name).': '.$str;
+ }
+
return $str;
}
The patch basically does:
- Add
is_native_retweet()
method - Make
urls()
,mentions()
,hashtags()
, andcontent()
get the entities and text fromdata->retweeted_status
in case of a native retweet - Make
link_entities()
prepend"RT @username: "
in case of a native retweet to mimic a non-native retweet at rendering time.
from wp-twitter-tools.
Thanks, fixed in 959973d
from wp-twitter-tools.
Related Issues (20)
- Settings Page Saving HOT 2
- Post Formats HOT 1
- "Create blog posts" comes in as wrong time HOT 1
- "Create blog posts" setting to not include 'real' RTs HOT 1
- "Title prefix" is ignored HOT 3
- Remove @anywhere check (always link @usernames)
- Integrate with other service like twitter HOT 2
- Add option to not download images but just expand the links instead HOT 7
- Nothing happening after install
- Tweet URL shows "1" instead of username HOT 1
- Use dashicons for the meu icon HOT 2
- only pull twitter feeds from 2012 HOT 1
- aktt_tweets: add support for replacing links HOT 3
- aktt_tweets: add support for pagination HOT 1
- Add links to @username in tweet HOT 1
- Links issue
- _aktt_tweet_post_id meta fields empty on posts.
- Empty Tweets
- Stopped working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-twitter-tools.