Version Description
- Fix: Custom date format not working in settings area
- Fix: Avatars would disappear from the feed in Firefox for certain accounts
- Fix: Changed http: links to https:
- Fix: Fixed retweets always being included in persistent caches during the initial tweet retrieval.
Download this release
Release Info
Developer | smashballoon |
Plugin | Custom Twitter Feeds |
Version | 1.2.4 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.4
- README.txt +288 -282
- css/ctf-styles.css +9 -0
- custom-twitter-feed.php +373 -373
- inc/CtfAdmin.php +1 -1
- inc/CtfFeed.php +1 -2
README.txt
CHANGED
@@ -1,283 +1,289 @@
|
|
1 |
-
=== Custom Twitter Feeds ===
|
2 |
-
Author: Smash Balloon
|
3 |
-
Contributors: smashballoon, craig-at-smash-balloon
|
4 |
-
Support Website: http://smashballoon/custom-twitter-feeds/
|
5 |
-
Tags: Twitter, Twitter feed,
|
6 |
-
Requires at least: 3.0
|
7 |
-
Tested up to: 4.
|
8 |
-
Stable tag: 1.2.
|
9 |
-
License: GPLv2 or later
|
10 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
-
|
12 |
-
Custom Twitter Feeds allows you to display completely customizable Twitter feeds of your user timeline, home timeline, or hashtag on your website.
|
13 |
-
|
14 |
-
== Description ==
|
15 |
-
Display **completely customizable**, **responsive** and **search engine crawlable** versions of your Twitter feed on your website. Completely match the look and feel of the site with tons of customization options!
|
16 |
-
|
17 |
-
= Features =
|
18 |
-
* **Completely Customizable** - by default inherits your theme's styles
|
19 |
-
* Twitter feed content is **crawlable by search engines** adding SEO value to your site
|
20 |
-
* **Completely responsive and mobile optimized** - works on any screen size
|
21 |
-
* Display tweets from any user, your own Twitter account and those you follow, or from a specific hashtag
|
22 |
-
* Display multiple feeds from different Twitter users on multiple pages or widgets
|
23 |
-
* Post caching means that your Twitter feed loads lightning fast and minimizes Twitter API requests
|
24 |
-
* **Infinitely load more** of your Tweets with the 'Load More' button
|
25 |
-
* Built-in easy to use "Custom Twitter Feeds" Widget
|
26 |
-
* Fully internationalized and translatable into any language
|
27 |
-
* Display a beautiful header at the top of your Twitter feed
|
28 |
-
* Enter your own custom CSS for even deeper customization
|
29 |
-
|
30 |
-
For simple step-by-step directions on how to set up the Custom Twitter Feeds plugin please refer to our [setup guide](http://smashballoon.com/custom-twitter-feeds/free/ 'Custom Twitter Feeds setup guide').
|
31 |
-
|
32 |
-
= Benefits =
|
33 |
-
* **Increase social engagement** between you and your users, customers, or fans
|
34 |
-
* **Save time** by using the Custom Twitter Feeds plugin to generate dynamic, search engine crawlable content on your website
|
35 |
-
* **Get more follows** by displaying your Twitter content directly on your site
|
36 |
-
* **Improve your SEO** as all of that quality keyword-rich Twitter content is directly embedded into your website
|
37 |
-
* **Keep users on your site** by letting them reply and like your Tweets directly on your site
|
38 |
-
* Display your Twitter content **your way** to perfectly match your website's style
|
39 |
-
* The plugin is **updated regularly** with new features, bug-fixes and Twitter API changes
|
40 |
-
* Support is quick and effective
|
41 |
-
* We're dedicated to providing the **most customizable**, **robust** and **well supported** Twitter feed plugin in the world!
|
42 |
-
|
43 |
-
[View the reviews](https://wordpress.org/support/plugin/custom-twitter-feeds/reviews/) to see what other users are saying about the Custom Twitter Feeds plugin.
|
44 |
-
|
45 |
-
= Feedback or Support =
|
46 |
-
We're dedicated to providing the most customizable, robust and well supported Twitter feed plugin in the world, so if you have an issue or any feedback on how to improve the plugin then please [let us know](https://smashballoon.com/custom-twitter-feeds/support/ 'Twitter Feed Support').
|
47 |
-
|
48 |
-
If you like the plugin then please consider leaving a review, as it really helps to support the plugin. If you have an issue then please allow us to help you fix it before leaving a review. Just [let us know](https://smashballoon.com/custom-twitter-feeds/support/ 'Twitter Feed Support') what the problem is and we'll get back to you right away.
|
49 |
-
|
50 |
-
= Featured Reviews =
|
51 |
-
"***Great for Customization** - Great plugin! Superb customization options! Am changing all twitter feeds for all my websites to this! I have tried several plugins so far. This is the best I have come across :)*" - [@nehavivekpatil](https://wordpress.org/support/topic/great-for-customization-2/)
|
52 |
-
|
53 |
-
"***Excellent plug-in. Excellent support.** - Excellent instructions and guidance. Patient and prompt support for the newbies. Regular updates. You can't lose. Thank you Smash Balloon.* - [@nuspa](https://wordpress.org/support/topic/excellent-plug-in-excellent-support-2/)
|
54 |
-
|
55 |
-
"***Amazing Support and a Great Twitter Plugin** - I am using the free version of this plugin and identified a real problem in the display on my website. I emailed support and Craig was all over the fix for me. Seven or so emails later (even on a Sunday) the problem was fixed and Craig was still reaching out to make sure all was well.*
|
56 |
-
|
57 |
-
*In a world of crappy support for premium plugins, and even worse support for free plugins, this kind of support (and listening to customers) that Craig and Smash Balloon provided me make their premium products worth every penny. In fact, I am going to buy them on my next project. They deserve it.*
|
58 |
-
|
59 |
-
*Thanks again, Craig!*" - [@kcwebguy](https://wordpress.org/support/topic/amazing-support-and-a-great-twitter-plugin/)
|
60 |
-
|
61 |
-
= Pro Version =
|
62 |
-
We recently released a [Pro version](http://smashballoon.com/custom-twitter-feeds/ 'Custom Twitter Feeds Pro') which includes some awesome additional features:
|
63 |
-
|
64 |
-
* Display Tweets from **multiple users or hashtags in the same feed**
|
65 |
-
* Display **photos**, **videos**, and **gifs** and view them in a **popup lightbox** directly on your site
|
66 |
-
* Multi-column **Masonry layout** [demo](http://smashballoon.com/custom-twitter-feeds/demo/masonry 'Custom Twitter Feeds Pro Masonry Demo')
|
67 |
-
* Allow **filtering** of user timelines include/exclude any/all keywords/hashtags
|
68 |
-
* Fully functional **search endpoint**
|
69 |
-
* Display Tweets you're mentioned in
|
70 |
-
* Tweet-specific **moderation system**
|
71 |
-
* **Twitter cards** displayed with links which support them
|
72 |
-
* Include **Tweet replies** (in reply to tweets)
|
73 |
-
|
74 |
-
Try the Pro version [demo here](http://smashballoon.com/custom-twitter-feeds/demo 'Custom Twitter Feeds Pro Demo')
|
75 |
-
|
76 |
-
== Installation ==
|
77 |
-
1. Install the Custom Twitter Feeds plugin either via the WordPress plugin directory, or by uploading the files to your web server (in the /wp-content/plugins/ directory).
|
78 |
-
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
79 |
-
3. Navigate to the 'Twitter Feed' settings page to configure your Twitter feed.
|
80 |
-
4. Use the shortcode [custom-twitter-feeds] in your page, post or widget to display your feed.
|
81 |
-
5. You can display multiple Twitter feeds with different configurations by specifying the necessary parameters directly in the shortcode: [custom-twitter-feeds hashtag=#smashballoon].
|
82 |
-
|
83 |
-
For simple step-by-step directions on how to set up the Custom Twitter Feeds plugin please refer to our [setup guide](http://smashballoon.com/custom-twitter-feeds/free/ 'Custom Twitter Feeds setup guide').
|
84 |
-
|
85 |
-
= Setting up the Free Custom Twitter Feeds WordPress Plugin =
|
86 |
-
|
87 |
-
The Custom Twitter Feeds plugin is brand new and so we're currently working on improving our documentation for it. If you have an issue or question please submit a support ticket and we'll get back to you as soon as we can.
|
88 |
-
|
89 |
-
1) Once you've installed the Custom Twitter Feeds plugin click on the Twitter Feed item in your WordPress menu
|
90 |
-
|
91 |
-
2) Click on the large blue Twitter login button to get your Twitter Access Token and Twitter Secret. Note; if you have your own Twitter Developer App set up then you can enter your Twitter information manually by enabling the checkbox below the Twitter login button.
|
92 |
-
|
93 |
-
3) Authorize the Custom Twitter Feeds plugin to read your Tweets.
|
94 |
-
Note; the plugin does not obtain permission to edit or write to your Twitter account, only to read your Twitter content.
|
95 |
-
|
96 |
-
4) Twitter sends back your Twitter Access Token and Twitter Secret which are then automatically saved by the Custom Twitter Feeds plugin. This information is required in order to connect to the Twitter API.
|
97 |
-
|
98 |
-
5) Enter a Twitter screenname to display Tweets from. Alternatively, choose to display Tweets from your Twitter home timeline or a Twitter hashtag.
|
99 |
-
|
100 |
-
6) Navigate to the Customize and Style pages to customize your Twitter feed.
|
101 |
-
|
102 |
-
7) Once you've customized your Twitter feed, click on the "Display Your Feed" tab for directions on how to display your Twitter feed (or multiple Twitter feeds).
|
103 |
-
|
104 |
-
8) Copy the [custom-twitter-feeds] shortcode and paste it into any page, post or widget where you want the Twitter feed to appear.
|
105 |
-
|
106 |
-
9) You can paste the [custom-twitter-feeds] shortcode directly into your page editor.
|
107 |
-
|
108 |
-
10) You can use the default WordPress 'Text' widget to display your Twitter Feed in a sidebar or other widget area.
|
109 |
-
|
110 |
-
11) View your website to see your Twitter feed(s) in all their glory!
|
111 |
-
|
112 |
-
== Frequently Asked Questions ==
|
113 |
-
|
114 |
-
= Can I display multiple Twitter feeds on my site or on the same page? =
|
115 |
-
|
116 |
-
Yep. You can display multiple Twitter feeds by using our built-in shortcode options, for example: `[custom-twitter-feeds screenname="smashballoon" num=3]`.
|
117 |
-
|
118 |
-
= How do I embed the Twitter Feed directly into a WordPress page template? =
|
119 |
-
|
120 |
-
You can embed your Twitter feed directly into a template file by using the WordPress [do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) function: `<?php echo do_shortcode('[custom-twitter-feeds]'); ?>`.
|
121 |
-
|
122 |
-
= Is the content of my Twitter feed crawlable by search engines and how does it help improve my SEO? =
|
123 |
-
|
124 |
-
Unlike other Twitter plugins which use iframes to embed your Twitter feed into your page once it's loaded, the Custom Twitter Feeds uses server-side code to embed your Twitter feed content directly into your page. This adds dynamic, search engine crawlable content to your site.
|
125 |
-
|
126 |
-
= Will Custom Twitter Feeds work with W3 Total Cache or other caching plugins? =
|
127 |
-
|
128 |
-
The Custom Twitter Feeds plugin should work in compatibility with most, if not all, caching plugins, but you may need to tweak the settings in order to allow the Twitter feed to update successfully and display your latest posts. If you are experiencing problems with your Twitter feed not updating then try disabling either 'Page Caching' or 'Object Caching' in W3 Total Cache (or any other similar caching plugin) to see whether that fixes the problem and the Twitter feed displays and updates successfully.
|
129 |
-
|
130 |
-
= The font in my Twitter feed isn't inherited from my website =
|
131 |
-
|
132 |
-
Be default your Twitter feed should inherit the font from your website. If this isn't the case then it's possible that something in the theme is preventing this from happening. An issue that we've run into before is that <code> tags are added into the Twitter feed HTML by either the theme, another plugin, or perhaps even the shortcode being wrapped in code tags in your page editor. To fix this;
|
133 |
-
|
134 |
-
1) First – go to your page editor, click on the 'Text' tab in the top right of the editor box, and check whether the [custom-twitter-feeds] shortcode is being wrapped in <code> tags, like so: <code>[custom-twitter-feeds]</code>. If it is, then remove them.
|
135 |
-
|
136 |
-
2) If this doesn't solve the problem then try adding the following to the plugin's "Custom CSS" section (Twitter Feeds > Customize > Custom CSS):
|
137 |
-
|
138 |
-
`#ctf code { font-family: sans-serif; }`
|
139 |
-
|
140 |
-
You can replace the font-family with whatever font your theme is using.
|
141 |
-
|
142 |
-
= Differences between the free version and Pro version of the Custom Twitter Feeds plugin =
|
143 |
-
|
144 |
-
The main differences between the free version and Pro version of the Custom Twitter Feeds plugin are listed below. The extra features available in the Pro version are as follows:
|
145 |
-
|
146 |
-
- Display photos, videos, and gifs in your Tweets, with support for 3rd party services such as YouTube, Vimeo, Vine, and SoundCloud
|
147 |
-
- View media in a pop-up lightbox directly on your site
|
148 |
-
- Display Tweets in a multi-column Masonry layout
|
149 |
-
- Display your Twitter feed in rotating Carousels / Slideshows
|
150 |
-
- Twitter Cards (rich, standout links) are displayed in Tweets for links that support them
|
151 |
-
- Create advanced Twitter "Search" feeds or use the "Mentions" timeline
|
152 |
-
- Combine feeds of multiple types (i.e. User feeds and Hashtag Twitter feeds combined)
|
153 |
-
- Filter feeds by hashtag, word(s), or remove specific tweets
|
154 |
-
- Autoload more tweets when scrolling to the bottom of the Twitter feed
|
155 |
-
- Include Tweet replies ("in reply to")
|
156 |
-
|
157 |
-
You can see the demo of the Custom Twitter Feeds Pro version [here](https://smashballoon.com/custom-twitter-feeds/demo/), and a video screencast [here](https://smashballoon.com/custom-twitter-feeds/#watch-video).
|
158 |
-
|
159 |
-
== Other Notes ==
|
160 |
-
|
161 |
-
= Twitter API Error Message Reference =
|
162 |
-
|
163 |
-
If you receive an error message when trying to display your Twitter Feed then you can use the error reference below to diagnose the issue and find the relevant solution.
|
164 |
-
|
165 |
-
**Error:**
|
166 |
-
Could not authenticate you
|
167 |
-
|
168 |
-
**Causes:**
|
169 |
-
- You may be using Twitter access tokens that are not valid - See #1 below
|
170 |
-
- You checked the box to enter your own Twitter app information, but one or more of the fields are incorrect - See #2 below
|
171 |
-
|
172 |
-
**Error:**
|
173 |
-
Invalid or expired token
|
174 |
-
|
175 |
-
**Causes:**
|
176 |
-
- You may not have entered your Twitter access tokens or they are not valid - See #1 below
|
177 |
-
|
178 |
-
**Error:**
|
179 |
-
Unable to load tweets (with no other explanation)
|
180 |
-
|
181 |
-
**Causes:**
|
182 |
-
- You may need to raise the number of tweets to retrieve and display in your Twitter feed - See #3 below
|
183 |
-
|
184 |
-
**Error:**
|
185 |
-
Sorry, that page does not exist
|
186 |
-
|
187 |
-
**Causes:**
|
188 |
-
- There may be a typo in the Twitter screen name or hashtag you are attempting to use
|
189 |
-
|
190 |
-
**Error:**
|
191 |
-
Over capacity
|
192 |
-
|
193 |
-
**Causes:**
|
194 |
-
- Twitter’s servers are over capacity so the API is unusable. This will correct itself after some time
|
195 |
-
|
196 |
-
**Error:**
|
197 |
-
Connection timed out after 10000 milliseconds
|
198 |
-
|
199 |
-
**Causes:**
|
200 |
-
- Most likely this is due to your server blocking access to the Twitter API – See #4 below
|
201 |
-
|
202 |
-
**Solutions**
|
203 |
-
|
204 |
-
**#1 - Your Twitter access tokens might not be valid**
|
205 |
-
|
206 |
-
The easiest way to verify this is by going back to the Settings page for the Custom Twitter Feeds plugin and clicking the big blue button on the "Configure" tab to get new Twitter access tokens. If you haven't set up your own Twitter App, the only way to use the Custom Twitter Feeds plugin is to click the big blue button to get a Twitter access token and Twitter access token secret that is compatible with the default Twitter client used by Smash Balloon.
|
207 |
-
|
208 |
-
**#2 - You have checked the box to use your own Twitter app information but one or more of the fields are incorrect**
|
209 |
-
|
210 |
-
All four fields, consumer token, consumer secret, access token, and access token secret, need to come from the Twitter app that you set up on Twitter.com. Try returning to your personal Twitter app management page https://apps.twitter.com/ and confirming that all four fields, consumer token, consumer secret, access token, and access token secret, and entered correctly in the corresponding fields on the plugin's "Configure" tab.
|
211 |
-
|
212 |
-
**#3 - You may need to raise the number of tweets to retrieve**
|
213 |
-
|
214 |
-
Navigate to the type of Twitter feed you are trying to display on twitter.com. For example, if you are displaying a feed from the screenname "smashballoon", go to https://twitter.com/smashballoon. Make sure there are tweets visible. Then click on the link "Tweets & replies". If there are a more recent replies than original tweets, there may be too many tweets being filtered out to display any. Replies are removed by default. You can raise the number of tweets to retrieve initially by going to the Custom Twitter Feed Settings page, "Customize" tab, and navigating to the "Advanced" area. Then raise the "Tweet Multiplier" and test to see if your Twitter feed now displays tweets.
|
215 |
-
|
216 |
-
If you're still having trouble displaying your Tweets after trying the common issues above then please [contact support](https://smashballoon.com/custom-twitter-feeds/support/) for assistance.
|
217 |
-
|
218 |
-
== Screenshots ==
|
219 |
-
|
220 |
-
1. Default Custom Twitter Feeds plugin styling
|
221 |
-
2. Custom Twitter Feeds plugin Settings pages
|
222 |
-
|
223 |
-
== Changelog ==
|
224 |
-
= 1.2.
|
225 |
-
* Fix:
|
226 |
-
* Fix:
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
* Fix:
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
* Fix: Fixed an issue
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
*
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
*
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
* Fix: Fixed
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
* Fix:
|
277 |
-
* Fix:
|
278 |
-
|
279 |
-
= 1.
|
280 |
-
*
|
281 |
-
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
* Launched the Custom Twitter Feeds plugin!
|
1 |
+
=== Custom Twitter Feeds ===
|
2 |
+
Author: Smash Balloon
|
3 |
+
Contributors: smashballoon, craig-at-smash-balloon
|
4 |
+
Support Website: http://smashballoon/custom-twitter-feeds/
|
5 |
+
Tags: Twitter, Twitter feed, Tweets, Twitter widget, Custom Twitter Feed
|
6 |
+
Requires at least: 3.0
|
7 |
+
Tested up to: 4.8
|
8 |
+
Stable tag: 1.2.4
|
9 |
+
License: GPLv2 or later
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
|
12 |
+
Custom Twitter Feeds allows you to display completely customizable Twitter feeds of your user timeline, home timeline, or hashtag on your website.
|
13 |
+
|
14 |
+
== Description ==
|
15 |
+
Display **completely customizable**, **responsive** and **search engine crawlable** versions of your Twitter feed on your website. Completely match the look and feel of the site with tons of customization options!
|
16 |
+
|
17 |
+
= Features =
|
18 |
+
* **Completely Customizable** - by default inherits your theme's styles
|
19 |
+
* Twitter feed content is **crawlable by search engines** adding SEO value to your site
|
20 |
+
* **Completely responsive and mobile optimized** - works on any screen size
|
21 |
+
* Display tweets from any user, your own Twitter account and those you follow, or from a specific hashtag
|
22 |
+
* Display multiple feeds from different Twitter users on multiple pages or widgets
|
23 |
+
* Post caching means that your Twitter feed loads lightning fast and minimizes Twitter API requests
|
24 |
+
* **Infinitely load more** of your Tweets with the 'Load More' button
|
25 |
+
* Built-in easy to use "Custom Twitter Feeds" Widget
|
26 |
+
* Fully internationalized and translatable into any language
|
27 |
+
* Display a beautiful header at the top of your Twitter feed
|
28 |
+
* Enter your own custom CSS for even deeper customization
|
29 |
+
|
30 |
+
For simple step-by-step directions on how to set up the Custom Twitter Feeds plugin please refer to our [setup guide](http://smashballoon.com/custom-twitter-feeds/free/ 'Custom Twitter Feeds setup guide').
|
31 |
+
|
32 |
+
= Benefits =
|
33 |
+
* **Increase social engagement** between you and your users, customers, or fans
|
34 |
+
* **Save time** by using the Custom Twitter Feeds plugin to generate dynamic, search engine crawlable content on your website
|
35 |
+
* **Get more follows** by displaying your Twitter content directly on your site
|
36 |
+
* **Improve your SEO** as all of that quality keyword-rich Twitter content is directly embedded into your website
|
37 |
+
* **Keep users on your site** by letting them reply and like your Tweets directly on your site
|
38 |
+
* Display your Twitter content **your way** to perfectly match your website's style
|
39 |
+
* The plugin is **updated regularly** with new features, bug-fixes and Twitter API changes
|
40 |
+
* Support is quick and effective
|
41 |
+
* We're dedicated to providing the **most customizable**, **robust** and **well supported** Twitter feed plugin in the world!
|
42 |
+
|
43 |
+
[View the reviews](https://wordpress.org/support/plugin/custom-twitter-feeds/reviews/) to see what other users are saying about the Custom Twitter Feeds plugin.
|
44 |
+
|
45 |
+
= Feedback or Support =
|
46 |
+
We're dedicated to providing the most customizable, robust and well supported Twitter feed plugin in the world, so if you have an issue or any feedback on how to improve the plugin then please [let us know](https://smashballoon.com/custom-twitter-feeds/support/ 'Twitter Feed Support').
|
47 |
+
|
48 |
+
If you like the plugin then please consider leaving a review, as it really helps to support the plugin. If you have an issue then please allow us to help you fix it before leaving a review. Just [let us know](https://smashballoon.com/custom-twitter-feeds/support/ 'Twitter Feed Support') what the problem is and we'll get back to you right away.
|
49 |
+
|
50 |
+
= Featured Reviews =
|
51 |
+
"***Great for Customization** - Great plugin! Superb customization options! Am changing all twitter feeds for all my websites to this! I have tried several plugins so far. This is the best I have come across :)*" - [@nehavivekpatil](https://wordpress.org/support/topic/great-for-customization-2/)
|
52 |
+
|
53 |
+
"***Excellent plug-in. Excellent support.** - Excellent instructions and guidance. Patient and prompt support for the newbies. Regular updates. You can't lose. Thank you Smash Balloon.* - [@nuspa](https://wordpress.org/support/topic/excellent-plug-in-excellent-support-2/)
|
54 |
+
|
55 |
+
"***Amazing Support and a Great Twitter Plugin** - I am using the free version of this plugin and identified a real problem in the display on my website. I emailed support and Craig was all over the fix for me. Seven or so emails later (even on a Sunday) the problem was fixed and Craig was still reaching out to make sure all was well.*
|
56 |
+
|
57 |
+
*In a world of crappy support for premium plugins, and even worse support for free plugins, this kind of support (and listening to customers) that Craig and Smash Balloon provided me make their premium products worth every penny. In fact, I am going to buy them on my next project. They deserve it.*
|
58 |
+
|
59 |
+
*Thanks again, Craig!*" - [@kcwebguy](https://wordpress.org/support/topic/amazing-support-and-a-great-twitter-plugin/)
|
60 |
+
|
61 |
+
= Pro Version =
|
62 |
+
We recently released a [Pro version](http://smashballoon.com/custom-twitter-feeds/ 'Custom Twitter Feeds Pro') which includes some awesome additional features:
|
63 |
+
|
64 |
+
* Display Tweets from **multiple users or hashtags in the same feed**
|
65 |
+
* Display **photos**, **videos**, and **gifs** and view them in a **popup lightbox** directly on your site
|
66 |
+
* Multi-column **Masonry layout** [demo](http://smashballoon.com/custom-twitter-feeds/demo/masonry 'Custom Twitter Feeds Pro Masonry Demo')
|
67 |
+
* Allow **filtering** of user timelines include/exclude any/all keywords/hashtags
|
68 |
+
* Fully functional **search endpoint**
|
69 |
+
* Display Tweets you're mentioned in
|
70 |
+
* Tweet-specific **moderation system**
|
71 |
+
* **Twitter cards** displayed with links which support them
|
72 |
+
* Include **Tweet replies** (in reply to tweets)
|
73 |
+
|
74 |
+
Try the Pro version [demo here](http://smashballoon.com/custom-twitter-feeds/demo 'Custom Twitter Feeds Pro Demo')
|
75 |
+
|
76 |
+
== Installation ==
|
77 |
+
1. Install the Custom Twitter Feeds plugin either via the WordPress plugin directory, or by uploading the files to your web server (in the /wp-content/plugins/ directory).
|
78 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
79 |
+
3. Navigate to the 'Twitter Feed' settings page to configure your Twitter feed.
|
80 |
+
4. Use the shortcode [custom-twitter-feeds] in your page, post or widget to display your feed.
|
81 |
+
5. You can display multiple Twitter feeds with different configurations by specifying the necessary parameters directly in the shortcode: [custom-twitter-feeds hashtag=#smashballoon].
|
82 |
+
|
83 |
+
For simple step-by-step directions on how to set up the Custom Twitter Feeds plugin please refer to our [setup guide](http://smashballoon.com/custom-twitter-feeds/free/ 'Custom Twitter Feeds setup guide').
|
84 |
+
|
85 |
+
= Setting up the Free Custom Twitter Feeds WordPress Plugin =
|
86 |
+
|
87 |
+
The Custom Twitter Feeds plugin is brand new and so we're currently working on improving our documentation for it. If you have an issue or question please submit a support ticket and we'll get back to you as soon as we can.
|
88 |
+
|
89 |
+
1) Once you've installed the Custom Twitter Feeds plugin click on the Twitter Feed item in your WordPress menu
|
90 |
+
|
91 |
+
2) Click on the large blue Twitter login button to get your Twitter Access Token and Twitter Secret. Note; if you have your own Twitter Developer App set up then you can enter your Twitter information manually by enabling the checkbox below the Twitter login button.
|
92 |
+
|
93 |
+
3) Authorize the Custom Twitter Feeds plugin to read your Tweets.
|
94 |
+
Note; the plugin does not obtain permission to edit or write to your Twitter account, only to read your Twitter content.
|
95 |
+
|
96 |
+
4) Twitter sends back your Twitter Access Token and Twitter Secret which are then automatically saved by the Custom Twitter Feeds plugin. This information is required in order to connect to the Twitter API.
|
97 |
+
|
98 |
+
5) Enter a Twitter screenname to display Tweets from. Alternatively, choose to display Tweets from your Twitter home timeline or a Twitter hashtag.
|
99 |
+
|
100 |
+
6) Navigate to the Customize and Style pages to customize your Twitter feed.
|
101 |
+
|
102 |
+
7) Once you've customized your Twitter feed, click on the "Display Your Feed" tab for directions on how to display your Twitter feed (or multiple Twitter feeds).
|
103 |
+
|
104 |
+
8) Copy the [custom-twitter-feeds] shortcode and paste it into any page, post or widget where you want the Twitter feed to appear.
|
105 |
+
|
106 |
+
9) You can paste the [custom-twitter-feeds] shortcode directly into your page editor.
|
107 |
+
|
108 |
+
10) You can use the default WordPress 'Text' widget to display your Twitter Feed in a sidebar or other widget area.
|
109 |
+
|
110 |
+
11) View your website to see your Twitter feed(s) in all their glory!
|
111 |
+
|
112 |
+
== Frequently Asked Questions ==
|
113 |
+
|
114 |
+
= Can I display multiple Twitter feeds on my site or on the same page? =
|
115 |
+
|
116 |
+
Yep. You can display multiple Twitter feeds by using our built-in shortcode options, for example: `[custom-twitter-feeds screenname="smashballoon" num=3]`.
|
117 |
+
|
118 |
+
= How do I embed the Twitter Feed directly into a WordPress page template? =
|
119 |
+
|
120 |
+
You can embed your Twitter feed directly into a template file by using the WordPress [do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) function: `<?php echo do_shortcode('[custom-twitter-feeds]'); ?>`.
|
121 |
+
|
122 |
+
= Is the content of my Twitter feed crawlable by search engines and how does it help improve my SEO? =
|
123 |
+
|
124 |
+
Unlike other Twitter plugins which use iframes to embed your Twitter feed into your page once it's loaded, the Custom Twitter Feeds uses server-side code to embed your Twitter feed content directly into your page. This adds dynamic, search engine crawlable content to your site.
|
125 |
+
|
126 |
+
= Will Custom Twitter Feeds work with W3 Total Cache or other caching plugins? =
|
127 |
+
|
128 |
+
The Custom Twitter Feeds plugin should work in compatibility with most, if not all, caching plugins, but you may need to tweak the settings in order to allow the Twitter feed to update successfully and display your latest posts. If you are experiencing problems with your Twitter feed not updating then try disabling either 'Page Caching' or 'Object Caching' in W3 Total Cache (or any other similar caching plugin) to see whether that fixes the problem and the Twitter feed displays and updates successfully.
|
129 |
+
|
130 |
+
= The font in my Twitter feed isn't inherited from my website =
|
131 |
+
|
132 |
+
Be default your Twitter feed should inherit the font from your website. If this isn't the case then it's possible that something in the theme is preventing this from happening. An issue that we've run into before is that <code> tags are added into the Twitter feed HTML by either the theme, another plugin, or perhaps even the shortcode being wrapped in code tags in your page editor. To fix this;
|
133 |
+
|
134 |
+
1) First – go to your page editor, click on the 'Text' tab in the top right of the editor box, and check whether the [custom-twitter-feeds] shortcode is being wrapped in <code> tags, like so: <code>[custom-twitter-feeds]</code>. If it is, then remove them.
|
135 |
+
|
136 |
+
2) If this doesn't solve the problem then try adding the following to the plugin's "Custom CSS" section (Twitter Feeds > Customize > Custom CSS):
|
137 |
+
|
138 |
+
`#ctf code { font-family: sans-serif; }`
|
139 |
+
|
140 |
+
You can replace the font-family with whatever font your theme is using.
|
141 |
+
|
142 |
+
= Differences between the free version and Pro version of the Custom Twitter Feeds plugin =
|
143 |
+
|
144 |
+
The main differences between the free version and Pro version of the Custom Twitter Feeds plugin are listed below. The extra features available in the Pro version are as follows:
|
145 |
+
|
146 |
+
- Display photos, videos, and gifs in your Tweets, with support for 3rd party services such as YouTube, Vimeo, Vine, and SoundCloud
|
147 |
+
- View media in a pop-up lightbox directly on your site
|
148 |
+
- Display Tweets in a multi-column Masonry layout
|
149 |
+
- Display your Twitter feed in rotating Carousels / Slideshows
|
150 |
+
- Twitter Cards (rich, standout links) are displayed in Tweets for links that support them
|
151 |
+
- Create advanced Twitter "Search" feeds or use the "Mentions" timeline
|
152 |
+
- Combine feeds of multiple types (i.e. User feeds and Hashtag Twitter feeds combined)
|
153 |
+
- Filter feeds by hashtag, word(s), or remove specific tweets
|
154 |
+
- Autoload more tweets when scrolling to the bottom of the Twitter feed
|
155 |
+
- Include Tweet replies ("in reply to")
|
156 |
+
|
157 |
+
You can see the demo of the Custom Twitter Feeds Pro version [here](https://smashballoon.com/custom-twitter-feeds/demo/), and a video screencast [here](https://smashballoon.com/custom-twitter-feeds/#watch-video).
|
158 |
+
|
159 |
+
== Other Notes ==
|
160 |
+
|
161 |
+
= Twitter API Error Message Reference =
|
162 |
+
|
163 |
+
If you receive an error message when trying to display your Twitter Feed then you can use the error reference below to diagnose the issue and find the relevant solution.
|
164 |
+
|
165 |
+
**Error:**
|
166 |
+
Could not authenticate you
|
167 |
+
|
168 |
+
**Causes:**
|
169 |
+
- You may be using Twitter access tokens that are not valid - See #1 below
|
170 |
+
- You checked the box to enter your own Twitter app information, but one or more of the fields are incorrect - See #2 below
|
171 |
+
|
172 |
+
**Error:**
|
173 |
+
Invalid or expired token
|
174 |
+
|
175 |
+
**Causes:**
|
176 |
+
- You may not have entered your Twitter access tokens or they are not valid - See #1 below
|
177 |
+
|
178 |
+
**Error:**
|
179 |
+
Unable to load tweets (with no other explanation)
|
180 |
+
|
181 |
+
**Causes:**
|
182 |
+
- You may need to raise the number of tweets to retrieve and display in your Twitter feed - See #3 below
|
183 |
+
|
184 |
+
**Error:**
|
185 |
+
Sorry, that page does not exist
|
186 |
+
|
187 |
+
**Causes:**
|
188 |
+
- There may be a typo in the Twitter screen name or hashtag you are attempting to use
|
189 |
+
|
190 |
+
**Error:**
|
191 |
+
Over capacity
|
192 |
+
|
193 |
+
**Causes:**
|
194 |
+
- Twitter’s servers are over capacity so the API is unusable. This will correct itself after some time
|
195 |
+
|
196 |
+
**Error:**
|
197 |
+
Connection timed out after 10000 milliseconds
|
198 |
+
|
199 |
+
**Causes:**
|
200 |
+
- Most likely this is due to your server blocking access to the Twitter API – See #4 below
|
201 |
+
|
202 |
+
**Solutions**
|
203 |
+
|
204 |
+
**#1 - Your Twitter access tokens might not be valid**
|
205 |
+
|
206 |
+
The easiest way to verify this is by going back to the Settings page for the Custom Twitter Feeds plugin and clicking the big blue button on the "Configure" tab to get new Twitter access tokens. If you haven't set up your own Twitter App, the only way to use the Custom Twitter Feeds plugin is to click the big blue button to get a Twitter access token and Twitter access token secret that is compatible with the default Twitter client used by Smash Balloon.
|
207 |
+
|
208 |
+
**#2 - You have checked the box to use your own Twitter app information but one or more of the fields are incorrect**
|
209 |
+
|
210 |
+
All four fields, consumer token, consumer secret, access token, and access token secret, need to come from the Twitter app that you set up on Twitter.com. Try returning to your personal Twitter app management page https://apps.twitter.com/ and confirming that all four fields, consumer token, consumer secret, access token, and access token secret, and entered correctly in the corresponding fields on the plugin's "Configure" tab.
|
211 |
+
|
212 |
+
**#3 - You may need to raise the number of tweets to retrieve**
|
213 |
+
|
214 |
+
Navigate to the type of Twitter feed you are trying to display on twitter.com. For example, if you are displaying a feed from the screenname "smashballoon", go to https://twitter.com/smashballoon. Make sure there are tweets visible. Then click on the link "Tweets & replies". If there are a more recent replies than original tweets, there may be too many tweets being filtered out to display any. Replies are removed by default. You can raise the number of tweets to retrieve initially by going to the Custom Twitter Feed Settings page, "Customize" tab, and navigating to the "Advanced" area. Then raise the "Tweet Multiplier" and test to see if your Twitter feed now displays tweets.
|
215 |
+
|
216 |
+
If you're still having trouble displaying your Tweets after trying the common issues above then please [contact support](https://smashballoon.com/custom-twitter-feeds/support/) for assistance.
|
217 |
+
|
218 |
+
== Screenshots ==
|
219 |
+
|
220 |
+
1. Default Custom Twitter Feeds plugin styling
|
221 |
+
2. Custom Twitter Feeds plugin Settings pages
|
222 |
+
|
223 |
+
== Changelog ==
|
224 |
+
= 1.2.4 =
|
225 |
+
* Fix: Custom date format not working in settings area
|
226 |
+
* Fix: Avatars would disappear from the feed in Firefox for certain accounts
|
227 |
+
* Fix: Changed http: links to https:
|
228 |
+
* Fix: Fixed retweets always being included in persistent caches during the initial tweet retrieval.
|
229 |
+
|
230 |
+
= 1.2.3 =
|
231 |
+
* Fix: Fix php warning when no media in tweets under certain circumstances
|
232 |
+
* Fix: Missing "alt" attributes for avatars
|
233 |
+
|
234 |
+
= 1.2.2 =
|
235 |
+
* Fix: Fixed an issue with include/exclude string to array conversion warning
|
236 |
+
|
237 |
+
= 1.2.1 =
|
238 |
+
* Fix: Fixed an issue where line breaks in tweet text were being ignored
|
239 |
+
* Fix: Fixed an issue where a small line was added to quoted tweets in retweets that have no media
|
240 |
+
|
241 |
+
= 1.2 =
|
242 |
+
* New: The plugin now uses persistent tweet caching for hashtag feeds. By default, when displaying hashtag feed Twitter only returns Tweets from the last 7 days, but the persistent cache now allows you to display these Tweets indefinitely.
|
243 |
+
* New: Tweets with media will have an icon and label that links to the tweet on twitter.com
|
244 |
+
* Fix: Fixed an issue with checkbox settings being changed unintentionally after obtaining a new access token
|
245 |
+
|
246 |
+
= 1.1.8 =
|
247 |
+
* Tweak: Updated plugin links for new WordPress.org repo
|
248 |
+
* Fix: Minor bug fixes
|
249 |
+
|
250 |
+
= 1.1.7 =
|
251 |
+
* Fix: Fixed an issue with the Twitter Access Token and Secrets not automatically being saved when initially obtaining them
|
252 |
+
* Fix: Fixed an issue with some customization settings not saving occasionally
|
253 |
+
|
254 |
+
= 1.1.6 =
|
255 |
+
* Fix: Fixed an issue when creating a Search feed using the built-in Custom Twitter Feeds widget box
|
256 |
+
* Fix: Fixed an issue with the checkbox that allows you to toggle links on/off in the Tweet text
|
257 |
+
|
258 |
+
= 1.1.5 =
|
259 |
+
* Fix: Fixed a rare issue when loading more Tweets
|
260 |
+
* Fix: When there is no bio text in the header then the screenname text is now automatically centered vertically
|
261 |
+
|
262 |
+
= 1.1.4 =
|
263 |
+
* Fix: Fixed an issue with some setting checkboxes
|
264 |
+
* Fix: Fixed a rare encoding issue which occurred on some server configurations
|
265 |
+
* Tested with the upcoming WordPress 4.6 update
|
266 |
+
|
267 |
+
= 1.1.3 =
|
268 |
+
* Fix: Prevented any duplicate Tweets from being shown
|
269 |
+
* Fix: Fixed a rare issue where a couple of settings weren't being saved successfully
|
270 |
+
|
271 |
+
= 1.1.2 =
|
272 |
+
* New: Launched a [Pro version](http://smashballoon.com/custom-twitter-feeds/ 'Custom Twitter Feeds Pro') which includes some awesome additional features!
|
273 |
+
* Fix: Minor bug fixes
|
274 |
+
|
275 |
+
= 1.1.1 =
|
276 |
+
* Fix: Added SSL support for avatar images so https version is used
|
277 |
+
* Fix: Fixed an issue with the "hours" custom text string displaying the "minutes" text instead
|
278 |
+
|
279 |
+
= 1.1 =
|
280 |
+
* New: Added a setting to translate the "Retweeted" text
|
281 |
+
* Tweak: If there aren't enough Tweets to populate the feed them Ajax in more automatically
|
282 |
+
* Fix: Custom JavaScript is now rerun every time the Load More button is used
|
283 |
+
* Fix: CSS display tweaks
|
284 |
+
|
285 |
+
= 1.0.1 =
|
286 |
+
* Bug fixes
|
287 |
+
|
288 |
+
= 1.0 =
|
289 |
* Launched the Custom Twitter Feeds plugin!
|
css/ctf-styles.css
CHANGED
@@ -57,6 +57,15 @@
|
|
57 |
-webkit-border-radius: 40px;
|
58 |
border-radius: 40px;
|
59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
/* Header avatar hover */
|
61 |
#ctf .ctf-header-img-hover,
|
62 |
#ctf .ctf-header-generic-icon{
|
57 |
-webkit-border-radius: 40px;
|
58 |
border-radius: 40px;
|
59 |
}
|
60 |
+
#ctf .ctf-author-avatar {
|
61 |
+
margin: 3px 6px 0 -53px;
|
62 |
+
}
|
63 |
+
#ctf .ctf-author-name {
|
64 |
+
margin-left: 6px;
|
65 |
+
}
|
66 |
+
#ctf .ctf-author-box {
|
67 |
+
margin-left: 53px;
|
68 |
+
}
|
69 |
/* Header avatar hover */
|
70 |
#ctf .ctf-header-img-hover,
|
71 |
#ctf .ctf-header-generic-icon{
|
custom-twitter-feed.php
CHANGED
@@ -1,373 +1,373 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Custom Twitter Feeds
|
4 |
-
Plugin URI: http://smashballoon.com/custom-twitter-feeds
|
5 |
-
Description: Customizable Twitter feeds for your website
|
6 |
-
Version: 1.2.
|
7 |
-
Author: Smash Balloon
|
8 |
-
Author URI: http://smashballoon.com/
|
9 |
-
Text Domain: custom-twitter-feeds
|
10 |
-
*/
|
11 |
-
/*
|
12 |
-
Copyright
|
13 |
-
This program is free software; you can redistribute it and/or modify
|
14 |
-
it under the terms of the GNU General Public License as published by
|
15 |
-
the Free Software Foundation; either version 2 of the License, or
|
16 |
-
(at your option) any later version.
|
17 |
-
This program is distributed in the hope that it will be useful,
|
18 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
-
GNU General Public License for more details.
|
21 |
-
You should have received a copy of the GNU General Public License
|
22 |
-
along with this program; if not, write to the Free Software
|
23 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24 |
-
*/
|
25 |
-
|
26 |
-
define( 'CTF_URL', plugin_dir_path( __FILE__ ) );
|
27 |
-
define( 'CTF_VERSION', '1.2.
|
28 |
-
define( 'CTF_TITLE', 'Custom Twitter Feeds' );
|
29 |
-
define( 'CTF_JS_URL', plugins_url( '/js/ctf-scripts.js?ver=' . CTF_VERSION , __FILE__ ) );
|
30 |
-
define( 'OAUTH_PROCESSOR_URL', 'https://smashballoon.com/ctf-at-retriever/?return_uri=' );
|
31 |
-
|
32 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
33 |
-
|
34 |
-
require_once( CTF_URL . '/inc/widget.php' );
|
35 |
-
|
36 |
-
require_once( CTF_URL . '/inc/admin-hooks.php' );
|
37 |
-
|
38 |
-
function ctf_update_settings() {
|
39 |
-
$existing_deprecated_options = get_option( 'ctf_configure' );
|
40 |
-
$existing_options = get_option( 'ctf_options' );
|
41 |
-
|
42 |
-
update_option( 'ctf_version', CTF_VERSION );
|
43 |
-
|
44 |
-
if ( ! empty( $existing_deprecated_options ) && empty( $existing_options ) ) {
|
45 |
-
$merged_options = $existing_deprecated_options;
|
46 |
-
$merged_options = array_merge( $merged_options, get_option( 'ctf_customize', array() ) );
|
47 |
-
$merged_options = array_merge( $merged_options, get_option( 'ctf_style', array() ) );
|
48 |
-
|
49 |
-
update_option( 'ctf_options', $merged_options );
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* include the admin files only if in the admin area
|
55 |
-
*/
|
56 |
-
if ( is_admin() ) {
|
57 |
-
|
58 |
-
$ctf_version = get_option( 'ctf_version', false );
|
59 |
-
|
60 |
-
if ( ! $ctf_version ) {
|
61 |
-
ctf_update_settings();
|
62 |
-
}
|
63 |
-
require_once( CTF_URL . '/inc/CtfAdmin.php' );
|
64 |
-
require_once( CTF_URL . '/inc/notices.php' );
|
65 |
-
|
66 |
-
$admin = new CtfAdmin;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Generates the Twitter feed wherever the shortcode is placed
|
71 |
-
*
|
72 |
-
* @param $atts array shortcode arguments
|
73 |
-
*
|
74 |
-
* @return string
|
75 |
-
*/
|
76 |
-
function ctf_init( $atts ) {
|
77 |
-
|
78 |
-
include_once( CTF_URL . '/inc/CtfFeed.php' );
|
79 |
-
|
80 |
-
$twitter_feed = CtfFeed::init( $atts );
|
81 |
-
/*
|
82 |
-
echo '<pre>';
|
83 |
-
var_dump( $twitter_feed->tweet_set);
|
84 |
-
echo '</pre>'; */
|
85 |
-
// if there is an error, display the error html, otherwise the feed
|
86 |
-
if ( ! $twitter_feed->tweet_set || $twitter_feed->missing_credentials ) {
|
87 |
-
return $twitter_feed->getErrorHtml();
|
88 |
-
} else {
|
89 |
-
$twitter_feed->maybeCacheTweets();
|
90 |
-
|
91 |
-
$feed_html = $twitter_feed->getFeedOpeningHtml();
|
92 |
-
$feed_html .= $twitter_feed->getTweetSetHtml();
|
93 |
-
$feed_html .= $twitter_feed->getFeedClosingHtml();
|
94 |
-
|
95 |
-
return $feed_html;
|
96 |
-
}
|
97 |
-
}
|
98 |
-
add_shortcode( 'custom-twitter-feed', 'ctf_init' );
|
99 |
-
add_shortcode( 'custom-twitter-feeds', 'ctf_init' );
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Called via ajax to get more posts after the "load more" button is clicked
|
103 |
-
*/
|
104 |
-
function ctf_get_more_posts() {
|
105 |
-
$shortcode_data = json_decode( str_replace( '\"', '"', sanitize_text_field( $_POST['shortcode_data'] ) ), true ); // necessary to unescape quotes
|
106 |
-
$last_id_data = isset( $_POST['last_id_data'] ) ? sanitize_text_field( $_POST['last_id_data'] ) : '';
|
107 |
-
$num_needed = isset( $_POST['num_needed'] ) ? (int)$_POST['num_needed'] : 0;
|
108 |
-
$ids_to_remove = isset( $_POST['ids_to_remove'] ) ? $_POST['ids_to_remove'] : array();
|
109 |
-
$is_pagination = empty( $last_id_data ) ? 0 : 1;
|
110 |
-
$persistent_index = isset( $_POST['persistent_index'] ) ? sanitize_text_field( $_POST['persistent_index'] ) : '';
|
111 |
-
|
112 |
-
include_once( CTF_URL . '/inc/CtfFeed.php' );
|
113 |
-
|
114 |
-
$twitter_feed = CtfFeed::init( $shortcode_data, $last_id_data, $num_needed, $ids_to_remove, $persistent_index );
|
115 |
-
|
116 |
-
if ( ! $twitter_feed->feed_options['persistentcache'] ) {
|
117 |
-
$twitter_feed->maybeCacheTweets();
|
118 |
-
}
|
119 |
-
|
120 |
-
echo $twitter_feed->getTweetSetHtml( $is_pagination );
|
121 |
-
|
122 |
-
die();
|
123 |
-
}
|
124 |
-
add_action( 'wp_ajax_nopriv_ctf_get_more_posts', 'ctf_get_more_posts' );
|
125 |
-
add_action( 'wp_ajax_ctf_get_more_posts', 'ctf_get_more_posts' );
|
126 |
-
|
127 |
-
/**
|
128 |
-
* the html output is controlled by the user selecting which portions of tweets to show
|
129 |
-
*
|
130 |
-
* @param $part string part of the feed in the html
|
131 |
-
* @param $feed_options array options that contain what parts of the tweet to show
|
132 |
-
* @return bool whether or not to show the tweet
|
133 |
-
*/
|
134 |
-
function ctf_show( $part, $feed_options ) {
|
135 |
-
$tweet_excludes = isset( $feed_options['tweet_excludes'] ) ? $feed_options['tweet_excludes'] : '';
|
136 |
-
$tweet_includes = isset( $feed_options['tweet_includes'] ) ? $feed_options['tweet_includes'] : '';
|
137 |
-
|
138 |
-
// if part is in the array of excluded parts or not in the array of included parts, don't show
|
139 |
-
if ( ! empty( $tweet_excludes ) ) {
|
140 |
-
return ( in_array( $part, $tweet_excludes ) === false );
|
141 |
-
} else {
|
142 |
-
return ( in_array( $part, $tweet_includes ) === true );
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* this function returns the properly formatted date string based on user input
|
148 |
-
*
|
149 |
-
* @param $raw_date string the date from the Twitter api
|
150 |
-
* @param $feed_options array options for the feed that contain date formatting settings
|
151 |
-
* @param $utc_offset int offset in seconds for the time display based on timezone
|
152 |
-
* @return string formatted date
|
153 |
-
*/
|
154 |
-
function ctf_get_formatted_date( $raw_date, $feed_options, $utc_offset ) {
|
155 |
-
include_once( CTF_URL . '/inc/CtfDateTime.php' );
|
156 |
-
|
157 |
-
$options = get_option( 'ctf_options' );
|
158 |
-
$timezone = isset( $options['timezone'] ) ? $options['timezone'] : 'default';
|
159 |
-
// use php DateTimeZone class to handle the date formatting and offsets
|
160 |
-
$date_obj = new CtfDateTime( $raw_date, new DateTimeZone( "UTC" ) );
|
161 |
-
|
162 |
-
if( $timezone != 'default' ) {
|
163 |
-
$date_obj->setTimeZone( new DateTimeZone( $timezone ) );
|
164 |
-
$utc_offset = $date_obj->getOffset();
|
165 |
-
}
|
166 |
-
|
167 |
-
$tz_offset_timestamp = $date_obj->getTimestamp() + $utc_offset;
|
168 |
-
|
169 |
-
// use the custom date format if set, otherwise use from the selected defaults
|
170 |
-
if ( ! empty( $feed_options['datecustom'] ) ){
|
171 |
-
$date_str = date_i18n( $feed_options['datecustom'], $tz_offset_timestamp );
|
172 |
-
} else {
|
173 |
-
|
174 |
-
switch ( $feed_options['dateformat'] ) {
|
175 |
-
|
176 |
-
case '2':
|
177 |
-
$date_str = date_i18n( 'F j', $tz_offset_timestamp );
|
178 |
-
break;
|
179 |
-
case '3':
|
180 |
-
$date_str = date_i18n( 'F j, Y', $tz_offset_timestamp );
|
181 |
-
break;
|
182 |
-
case '4':
|
183 |
-
$date_str = date_i18n( 'm.d', $tz_offset_timestamp );
|
184 |
-
break;
|
185 |
-
case '5':
|
186 |
-
$date_str = date_i18n( 'm.d.y', $tz_offset_timestamp );
|
187 |
-
break;
|
188 |
-
default:
|
189 |
-
|
190 |
-
// default format is similar to Twitter
|
191 |
-
$ctf_minute = ! empty( $feed_options['mtime'] ) ? $feed_options['mtime'] : 'm';
|
192 |
-
$ctf_hour = ! empty( $feed_options['htime'] ) ? $feed_options['htime'] : 'h';
|
193 |
-
$ctf_now_str = ! empty( $feed_options['nowtime'] ) ? $feed_options['nowtime'] : 'now';
|
194 |
-
|
195 |
-
$now = time() + $utc_offset;
|
196 |
-
|
197 |
-
$difference = $now - $tz_offset_timestamp;
|
198 |
-
|
199 |
-
if ( $difference < 60 ) {
|
200 |
-
$date_str = $ctf_now_str;
|
201 |
-
} elseif ( $difference < 60*60 ) {
|
202 |
-
$date_str = round( $difference/60 ) . $ctf_minute;
|
203 |
-
} elseif ( $difference < 60*60*24 ) {
|
204 |
-
$date_str = round( $difference/3600 ) . $ctf_hour;
|
205 |
-
} else {
|
206 |
-
$one_year_from_date = new CtfDateTime( $raw_date, new DateTimeZone( "UTC" ) );
|
207 |
-
$one_year_from_date->modify('+1 year');
|
208 |
-
$one_year_from_date_timestamp = $one_year_from_date->getTimestamp();
|
209 |
-
if ( $now > $one_year_from_date_timestamp ) {
|
210 |
-
$date_str = date_i18n( 'j M Y', $tz_offset_timestamp );
|
211 |
-
} else {
|
212 |
-
$date_str = date_i18n( 'j M', $tz_offset_timestamp );
|
213 |
-
}
|
214 |
-
}
|
215 |
-
break;
|
216 |
-
}
|
217 |
-
|
218 |
-
}
|
219 |
-
|
220 |
-
return $date_str;
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Called via ajax to automatically save access token and access token secret
|
225 |
-
* retrieved with the big blue button
|
226 |
-
*/
|
227 |
-
function ctf_auto_save_tokens() {
|
228 |
-
if ( current_user_can( 'edit_posts' ) ) {
|
229 |
-
wp_cache_delete ( 'alloptions', 'options' );
|
230 |
-
|
231 |
-
$options = get_option( 'ctf_options', array() );
|
232 |
-
|
233 |
-
$options['access_token'] = sanitize_text_field( $_POST['access_token'] );
|
234 |
-
$options['access_token_secret'] = sanitize_text_field( $_POST['access_token_secret'] );
|
235 |
-
|
236 |
-
update_option( 'ctf_options', $options );
|
237 |
-
die();
|
238 |
-
}
|
239 |
-
die();
|
240 |
-
}
|
241 |
-
add_action( 'wp_ajax_ctf_auto_save_tokens', 'ctf_auto_save_tokens' );
|
242 |
-
|
243 |
-
/**
|
244 |
-
* manually clears the cached tweets in case of error or user preference
|
245 |
-
*
|
246 |
-
* @return mixed bool whether or not it was successful
|
247 |
-
*/
|
248 |
-
function ctf_clear_cache() {
|
249 |
-
if ( current_user_can( 'edit_posts' ) ) {
|
250 |
-
//Delete all transients
|
251 |
-
global $wpdb;
|
252 |
-
$table_name = $wpdb->prefix . "options";
|
253 |
-
$result = $wpdb->query("
|
254 |
-
DELETE
|
255 |
-
FROM $table_name
|
256 |
-
WHERE `option_name` LIKE ('%\_transient\_ctf\_%')
|
257 |
-
");
|
258 |
-
$wpdb->query("
|
259 |
-
DELETE
|
260 |
-
FROM $table_name
|
261 |
-
WHERE `option_name` LIKE ('%\_transient\_timeout\_ctf\_%')
|
262 |
-
");
|
263 |
-
return $result;
|
264 |
-
} else {
|
265 |
-
return false;
|
266 |
-
}
|
267 |
-
}
|
268 |
-
add_action( 'ctf_cron_job', 'ctf_clear_cache' );
|
269 |
-
add_action( 'wp_ajax_ctf_clear_cache', 'ctf_clear_cache' );
|
270 |
-
|
271 |
-
/**
|
272 |
-
* manually clears the persistent cached tweets
|
273 |
-
*
|
274 |
-
* @return mixed bool whether or not it was successful
|
275 |
-
*/
|
276 |
-
|
277 |
-
function ctf_clear_persistent_cache() {
|
278 |
-
if ( current_user_can( 'edit_posts' ) ) {
|
279 |
-
//Delete all persistent caches (start with ctf_!)
|
280 |
-
global $wpdb;
|
281 |
-
$table_name = $wpdb->prefix . "options";
|
282 |
-
$result = $wpdb->query("
|
283 |
-
DELETE
|
284 |
-
FROM $table_name
|
285 |
-
WHERE `option_name` LIKE ('%ctf\_\!%')
|
286 |
-
");
|
287 |
-
delete_option( 'ctf_cache_list' );
|
288 |
-
return $result;
|
289 |
-
} else {
|
290 |
-
return false;
|
291 |
-
}
|
292 |
-
|
293 |
-
die();
|
294 |
-
}
|
295 |
-
add_action( 'wp_ajax_ctf_clear_persistent_cache', 'ctf_clear_persistent_cache' );
|
296 |
-
|
297 |
-
/**
|
298 |
-
* clear the cache and unschedule an cron jobs when deactivated
|
299 |
-
*/
|
300 |
-
function ctf_deactivate() {
|
301 |
-
ctf_clear_cache();
|
302 |
-
|
303 |
-
wp_clear_scheduled_hook( 'ctf_cron_job' );
|
304 |
-
}
|
305 |
-
register_deactivation_hook( __FILE__, 'ctf_deactivate' );
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Loads the javascript for the plugin front-end. Also localizes the admin-ajax file location for use in ajax calls
|
309 |
-
*/
|
310 |
-
function ctf_scripts_and_styles() {
|
311 |
-
wp_enqueue_style( 'ctf_styles', plugins_url( '/css/ctf-styles.css', __FILE__ ), array(), CTF_VERSION );
|
312 |
-
wp_enqueue_script( 'ctf_twitter_intents', 'https://platform.twitter.com/widgets.js' );
|
313 |
-
wp_enqueue_script( 'ctf_scripts', plugins_url( '/js/ctf-scripts.js', __FILE__ ), array( 'jquery' ), CTF_VERSION, true );
|
314 |
-
wp_localize_script( 'ctf_scripts', 'ctf', array(
|
315 |
-
'ajax_url' => admin_url( 'admin-ajax.php' )
|
316 |
-
)
|
317 |
-
);
|
318 |
-
}
|
319 |
-
add_action( 'wp_enqueue_scripts', 'ctf_scripts_and_styles' );
|
320 |
-
|
321 |
-
/**
|
322 |
-
* outputs the custom js from the "Customize" tab on the Settings page
|
323 |
-
*/
|
324 |
-
function ctf_custom_js() {
|
325 |
-
$options = get_option( 'ctf_options' );
|
326 |
-
$ctf_custom_js = isset( $options[ 'custom_js' ] ) ? $options[ 'custom_js' ] : '';
|
327 |
-
|
328 |
-
if ( ! empty( $ctf_custom_js ) ) {
|
329 |
-
?>
|
330 |
-
<!-- Custom Twitter Feeds JS -->
|
331 |
-
<script type="text/javascript">
|
332 |
-
<?php echo "window.ctf_custom_js = function($){" . stripslashes( $ctf_custom_js ) . "}\r\n"; ?>
|
333 |
-
</script>
|
334 |
-
<?php
|
335 |
-
}
|
336 |
-
}
|
337 |
-
add_action( 'wp_footer', 'ctf_custom_js' );
|
338 |
-
|
339 |
-
/**
|
340 |
-
* outputs the custom css from the "Customize" tab on the Settings page
|
341 |
-
*/
|
342 |
-
function ctf_custom_css() {
|
343 |
-
$options = get_option( 'ctf_options' );
|
344 |
-
$ctf_custom_css = isset( $options[ 'custom_css' ] ) ? $options[ 'custom_css' ] : '';
|
345 |
-
|
346 |
-
if ( ! empty( $ctf_custom_css ) ) {
|
347 |
-
?>
|
348 |
-
<!-- Custom Twitter Feeds CSS -->
|
349 |
-
<style type="text/css">
|
350 |
-
<?php echo stripslashes( $ctf_custom_css ) . "\r\n"; ?>
|
351 |
-
</style>
|
352 |
-
<?php
|
353 |
-
}
|
354 |
-
}
|
355 |
-
add_action( 'wp_head', 'ctf_custom_css' );
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Some CSS and JS needed in the admin area as well
|
359 |
-
*/
|
360 |
-
function ctf_admin_scripts_and_styles() {
|
361 |
-
wp_enqueue_style( 'ctf_admin_styles', plugins_url( '/css/ctf-admin-styles.css', __FILE__ ), array(), CTF_VERSION );
|
362 |
-
wp_enqueue_script( 'ctf_admin_scripts', plugins_url( '/js/ctf-admin-scripts.js', __FILE__ ) , array( 'jquery' ), CTF_VERSION, false );
|
363 |
-
wp_localize_script( 'ctf_admin_scripts', 'ctf', array(
|
364 |
-
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
365 |
-
'sb_nonce' => wp_create_nonce( 'ctf-smash-balloon' )
|
366 |
-
)
|
367 |
-
);
|
368 |
-
wp_enqueue_style( 'wp-color-picker' );
|
369 |
-
wp_enqueue_script(array('wp-color-picker'));
|
370 |
-
}
|
371 |
-
add_action( 'admin_enqueue_scripts', 'ctf_admin_scripts_and_styles' );
|
372 |
-
|
373 |
-
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Custom Twitter Feeds
|
4 |
+
Plugin URI: http://smashballoon.com/custom-twitter-feeds
|
5 |
+
Description: Customizable Twitter feeds for your website
|
6 |
+
Version: 1.2.4
|
7 |
+
Author: Smash Balloon
|
8 |
+
Author URI: http://smashballoon.com/
|
9 |
+
Text Domain: custom-twitter-feeds
|
10 |
+
*/
|
11 |
+
/*
|
12 |
+
Copyright 2017 Smash Balloon LLC (email : hey@smashballoon.com)
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License as published by
|
15 |
+
the Free Software Foundation; either version 2 of the License, or
|
16 |
+
(at your option) any later version.
|
17 |
+
This program is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
You should have received a copy of the GNU General Public License
|
22 |
+
along with this program; if not, write to the Free Software
|
23 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24 |
+
*/
|
25 |
+
|
26 |
+
define( 'CTF_URL', plugin_dir_path( __FILE__ ) );
|
27 |
+
define( 'CTF_VERSION', '1.2.4' );
|
28 |
+
define( 'CTF_TITLE', 'Custom Twitter Feeds' );
|
29 |
+
define( 'CTF_JS_URL', plugins_url( '/js/ctf-scripts.js?ver=' . CTF_VERSION , __FILE__ ) );
|
30 |
+
define( 'OAUTH_PROCESSOR_URL', 'https://smashballoon.com/ctf-at-retriever/?return_uri=' );
|
31 |
+
|
32 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
33 |
+
|
34 |
+
require_once( CTF_URL . '/inc/widget.php' );
|
35 |
+
|
36 |
+
require_once( CTF_URL . '/inc/admin-hooks.php' );
|
37 |
+
|
38 |
+
function ctf_update_settings() {
|
39 |
+
$existing_deprecated_options = get_option( 'ctf_configure' );
|
40 |
+
$existing_options = get_option( 'ctf_options' );
|
41 |
+
|
42 |
+
update_option( 'ctf_version', CTF_VERSION );
|
43 |
+
|
44 |
+
if ( ! empty( $existing_deprecated_options ) && empty( $existing_options ) ) {
|
45 |
+
$merged_options = $existing_deprecated_options;
|
46 |
+
$merged_options = array_merge( $merged_options, get_option( 'ctf_customize', array() ) );
|
47 |
+
$merged_options = array_merge( $merged_options, get_option( 'ctf_style', array() ) );
|
48 |
+
|
49 |
+
update_option( 'ctf_options', $merged_options );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* include the admin files only if in the admin area
|
55 |
+
*/
|
56 |
+
if ( is_admin() ) {
|
57 |
+
|
58 |
+
$ctf_version = get_option( 'ctf_version', false );
|
59 |
+
|
60 |
+
if ( ! $ctf_version ) {
|
61 |
+
ctf_update_settings();
|
62 |
+
}
|
63 |
+
require_once( CTF_URL . '/inc/CtfAdmin.php' );
|
64 |
+
require_once( CTF_URL . '/inc/notices.php' );
|
65 |
+
|
66 |
+
$admin = new CtfAdmin;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Generates the Twitter feed wherever the shortcode is placed
|
71 |
+
*
|
72 |
+
* @param $atts array shortcode arguments
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
function ctf_init( $atts ) {
|
77 |
+
|
78 |
+
include_once( CTF_URL . '/inc/CtfFeed.php' );
|
79 |
+
|
80 |
+
$twitter_feed = CtfFeed::init( $atts );
|
81 |
+
/*
|
82 |
+
echo '<pre>';
|
83 |
+
var_dump( $twitter_feed->tweet_set);
|
84 |
+
echo '</pre>'; */
|
85 |
+
// if there is an error, display the error html, otherwise the feed
|
86 |
+
if ( ! $twitter_feed->tweet_set || $twitter_feed->missing_credentials ) {
|
87 |
+
return $twitter_feed->getErrorHtml();
|
88 |
+
} else {
|
89 |
+
$twitter_feed->maybeCacheTweets();
|
90 |
+
|
91 |
+
$feed_html = $twitter_feed->getFeedOpeningHtml();
|
92 |
+
$feed_html .= $twitter_feed->getTweetSetHtml();
|
93 |
+
$feed_html .= $twitter_feed->getFeedClosingHtml();
|
94 |
+
|
95 |
+
return $feed_html;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
add_shortcode( 'custom-twitter-feed', 'ctf_init' );
|
99 |
+
add_shortcode( 'custom-twitter-feeds', 'ctf_init' );
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Called via ajax to get more posts after the "load more" button is clicked
|
103 |
+
*/
|
104 |
+
function ctf_get_more_posts() {
|
105 |
+
$shortcode_data = json_decode( str_replace( '\"', '"', sanitize_text_field( $_POST['shortcode_data'] ) ), true ); // necessary to unescape quotes
|
106 |
+
$last_id_data = isset( $_POST['last_id_data'] ) ? sanitize_text_field( $_POST['last_id_data'] ) : '';
|
107 |
+
$num_needed = isset( $_POST['num_needed'] ) ? (int)$_POST['num_needed'] : 0;
|
108 |
+
$ids_to_remove = isset( $_POST['ids_to_remove'] ) ? $_POST['ids_to_remove'] : array();
|
109 |
+
$is_pagination = empty( $last_id_data ) ? 0 : 1;
|
110 |
+
$persistent_index = isset( $_POST['persistent_index'] ) ? sanitize_text_field( $_POST['persistent_index'] ) : '';
|
111 |
+
|
112 |
+
include_once( CTF_URL . '/inc/CtfFeed.php' );
|
113 |
+
|
114 |
+
$twitter_feed = CtfFeed::init( $shortcode_data, $last_id_data, $num_needed, $ids_to_remove, $persistent_index );
|
115 |
+
|
116 |
+
if ( ! $twitter_feed->feed_options['persistentcache'] ) {
|
117 |
+
$twitter_feed->maybeCacheTweets();
|
118 |
+
}
|
119 |
+
|
120 |
+
echo $twitter_feed->getTweetSetHtml( $is_pagination );
|
121 |
+
|
122 |
+
die();
|
123 |
+
}
|
124 |
+
add_action( 'wp_ajax_nopriv_ctf_get_more_posts', 'ctf_get_more_posts' );
|
125 |
+
add_action( 'wp_ajax_ctf_get_more_posts', 'ctf_get_more_posts' );
|
126 |
+
|
127 |
+
/**
|
128 |
+
* the html output is controlled by the user selecting which portions of tweets to show
|
129 |
+
*
|
130 |
+
* @param $part string part of the feed in the html
|
131 |
+
* @param $feed_options array options that contain what parts of the tweet to show
|
132 |
+
* @return bool whether or not to show the tweet
|
133 |
+
*/
|
134 |
+
function ctf_show( $part, $feed_options ) {
|
135 |
+
$tweet_excludes = isset( $feed_options['tweet_excludes'] ) ? $feed_options['tweet_excludes'] : '';
|
136 |
+
$tweet_includes = isset( $feed_options['tweet_includes'] ) ? $feed_options['tweet_includes'] : '';
|
137 |
+
|
138 |
+
// if part is in the array of excluded parts or not in the array of included parts, don't show
|
139 |
+
if ( ! empty( $tweet_excludes ) ) {
|
140 |
+
return ( in_array( $part, $tweet_excludes ) === false );
|
141 |
+
} else {
|
142 |
+
return ( in_array( $part, $tweet_includes ) === true );
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* this function returns the properly formatted date string based on user input
|
148 |
+
*
|
149 |
+
* @param $raw_date string the date from the Twitter api
|
150 |
+
* @param $feed_options array options for the feed that contain date formatting settings
|
151 |
+
* @param $utc_offset int offset in seconds for the time display based on timezone
|
152 |
+
* @return string formatted date
|
153 |
+
*/
|
154 |
+
function ctf_get_formatted_date( $raw_date, $feed_options, $utc_offset ) {
|
155 |
+
include_once( CTF_URL . '/inc/CtfDateTime.php' );
|
156 |
+
|
157 |
+
$options = get_option( 'ctf_options' );
|
158 |
+
$timezone = isset( $options['timezone'] ) ? $options['timezone'] : 'default';
|
159 |
+
// use php DateTimeZone class to handle the date formatting and offsets
|
160 |
+
$date_obj = new CtfDateTime( $raw_date, new DateTimeZone( "UTC" ) );
|
161 |
+
|
162 |
+
if( $timezone != 'default' ) {
|
163 |
+
$date_obj->setTimeZone( new DateTimeZone( $timezone ) );
|
164 |
+
$utc_offset = $date_obj->getOffset();
|
165 |
+
}
|
166 |
+
|
167 |
+
$tz_offset_timestamp = $date_obj->getTimestamp() + $utc_offset;
|
168 |
+
|
169 |
+
// use the custom date format if set, otherwise use from the selected defaults
|
170 |
+
if ( ! empty( $feed_options['datecustom'] ) ){
|
171 |
+
$date_str = date_i18n( $feed_options['datecustom'], $tz_offset_timestamp );
|
172 |
+
} else {
|
173 |
+
|
174 |
+
switch ( $feed_options['dateformat'] ) {
|
175 |
+
|
176 |
+
case '2':
|
177 |
+
$date_str = date_i18n( 'F j', $tz_offset_timestamp );
|
178 |
+
break;
|
179 |
+
case '3':
|
180 |
+
$date_str = date_i18n( 'F j, Y', $tz_offset_timestamp );
|
181 |
+
break;
|
182 |
+
case '4':
|
183 |
+
$date_str = date_i18n( 'm.d', $tz_offset_timestamp );
|
184 |
+
break;
|
185 |
+
case '5':
|
186 |
+
$date_str = date_i18n( 'm.d.y', $tz_offset_timestamp );
|
187 |
+
break;
|
188 |
+
default:
|
189 |
+
|
190 |
+
// default format is similar to Twitter
|
191 |
+
$ctf_minute = ! empty( $feed_options['mtime'] ) ? $feed_options['mtime'] : 'm';
|
192 |
+
$ctf_hour = ! empty( $feed_options['htime'] ) ? $feed_options['htime'] : 'h';
|
193 |
+
$ctf_now_str = ! empty( $feed_options['nowtime'] ) ? $feed_options['nowtime'] : 'now';
|
194 |
+
|
195 |
+
$now = time() + $utc_offset;
|
196 |
+
|
197 |
+
$difference = $now - $tz_offset_timestamp;
|
198 |
+
|
199 |
+
if ( $difference < 60 ) {
|
200 |
+
$date_str = $ctf_now_str;
|
201 |
+
} elseif ( $difference < 60*60 ) {
|
202 |
+
$date_str = round( $difference/60 ) . $ctf_minute;
|
203 |
+
} elseif ( $difference < 60*60*24 ) {
|
204 |
+
$date_str = round( $difference/3600 ) . $ctf_hour;
|
205 |
+
} else {
|
206 |
+
$one_year_from_date = new CtfDateTime( $raw_date, new DateTimeZone( "UTC" ) );
|
207 |
+
$one_year_from_date->modify('+1 year');
|
208 |
+
$one_year_from_date_timestamp = $one_year_from_date->getTimestamp();
|
209 |
+
if ( $now > $one_year_from_date_timestamp ) {
|
210 |
+
$date_str = date_i18n( 'j M Y', $tz_offset_timestamp );
|
211 |
+
} else {
|
212 |
+
$date_str = date_i18n( 'j M', $tz_offset_timestamp );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
break;
|
216 |
+
}
|
217 |
+
|
218 |
+
}
|
219 |
+
|
220 |
+
return $date_str;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Called via ajax to automatically save access token and access token secret
|
225 |
+
* retrieved with the big blue button
|
226 |
+
*/
|
227 |
+
function ctf_auto_save_tokens() {
|
228 |
+
if ( current_user_can( 'edit_posts' ) ) {
|
229 |
+
wp_cache_delete ( 'alloptions', 'options' );
|
230 |
+
|
231 |
+
$options = get_option( 'ctf_options', array() );
|
232 |
+
|
233 |
+
$options['access_token'] = sanitize_text_field( $_POST['access_token'] );
|
234 |
+
$options['access_token_secret'] = sanitize_text_field( $_POST['access_token_secret'] );
|
235 |
+
|
236 |
+
update_option( 'ctf_options', $options );
|
237 |
+
die();
|
238 |
+
}
|
239 |
+
die();
|
240 |
+
}
|
241 |
+
add_action( 'wp_ajax_ctf_auto_save_tokens', 'ctf_auto_save_tokens' );
|
242 |
+
|
243 |
+
/**
|
244 |
+
* manually clears the cached tweets in case of error or user preference
|
245 |
+
*
|
246 |
+
* @return mixed bool whether or not it was successful
|
247 |
+
*/
|
248 |
+
function ctf_clear_cache() {
|
249 |
+
if ( current_user_can( 'edit_posts' ) ) {
|
250 |
+
//Delete all transients
|
251 |
+
global $wpdb;
|
252 |
+
$table_name = $wpdb->prefix . "options";
|
253 |
+
$result = $wpdb->query("
|
254 |
+
DELETE
|
255 |
+
FROM $table_name
|
256 |
+
WHERE `option_name` LIKE ('%\_transient\_ctf\_%')
|
257 |
+
");
|
258 |
+
$wpdb->query("
|
259 |
+
DELETE
|
260 |
+
FROM $table_name
|
261 |
+
WHERE `option_name` LIKE ('%\_transient\_timeout\_ctf\_%')
|
262 |
+
");
|
263 |
+
return $result;
|
264 |
+
} else {
|
265 |
+
return false;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
add_action( 'ctf_cron_job', 'ctf_clear_cache' );
|
269 |
+
add_action( 'wp_ajax_ctf_clear_cache', 'ctf_clear_cache' );
|
270 |
+
|
271 |
+
/**
|
272 |
+
* manually clears the persistent cached tweets
|
273 |
+
*
|
274 |
+
* @return mixed bool whether or not it was successful
|
275 |
+
*/
|
276 |
+
|
277 |
+
function ctf_clear_persistent_cache() {
|
278 |
+
if ( current_user_can( 'edit_posts' ) ) {
|
279 |
+
//Delete all persistent caches (start with ctf_!)
|
280 |
+
global $wpdb;
|
281 |
+
$table_name = $wpdb->prefix . "options";
|
282 |
+
$result = $wpdb->query("
|
283 |
+
DELETE
|
284 |
+
FROM $table_name
|
285 |
+
WHERE `option_name` LIKE ('%ctf\_\!%')
|
286 |
+
");
|
287 |
+
delete_option( 'ctf_cache_list' );
|
288 |
+
return $result;
|
289 |
+
} else {
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
|
293 |
+
die();
|
294 |
+
}
|
295 |
+
add_action( 'wp_ajax_ctf_clear_persistent_cache', 'ctf_clear_persistent_cache' );
|
296 |
+
|
297 |
+
/**
|
298 |
+
* clear the cache and unschedule an cron jobs when deactivated
|
299 |
+
*/
|
300 |
+
function ctf_deactivate() {
|
301 |
+
ctf_clear_cache();
|
302 |
+
|
303 |
+
wp_clear_scheduled_hook( 'ctf_cron_job' );
|
304 |
+
}
|
305 |
+
register_deactivation_hook( __FILE__, 'ctf_deactivate' );
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Loads the javascript for the plugin front-end. Also localizes the admin-ajax file location for use in ajax calls
|
309 |
+
*/
|
310 |
+
function ctf_scripts_and_styles() {
|
311 |
+
wp_enqueue_style( 'ctf_styles', plugins_url( '/css/ctf-styles.css', __FILE__ ), array(), CTF_VERSION );
|
312 |
+
wp_enqueue_script( 'ctf_twitter_intents', 'https://platform.twitter.com/widgets.js' );
|
313 |
+
wp_enqueue_script( 'ctf_scripts', plugins_url( '/js/ctf-scripts.js', __FILE__ ), array( 'jquery' ), CTF_VERSION, true );
|
314 |
+
wp_localize_script( 'ctf_scripts', 'ctf', array(
|
315 |
+
'ajax_url' => admin_url( 'admin-ajax.php' )
|
316 |
+
)
|
317 |
+
);
|
318 |
+
}
|
319 |
+
add_action( 'wp_enqueue_scripts', 'ctf_scripts_and_styles' );
|
320 |
+
|
321 |
+
/**
|
322 |
+
* outputs the custom js from the "Customize" tab on the Settings page
|
323 |
+
*/
|
324 |
+
function ctf_custom_js() {
|
325 |
+
$options = get_option( 'ctf_options' );
|
326 |
+
$ctf_custom_js = isset( $options[ 'custom_js' ] ) ? $options[ 'custom_js' ] : '';
|
327 |
+
|
328 |
+
if ( ! empty( $ctf_custom_js ) ) {
|
329 |
+
?>
|
330 |
+
<!-- Custom Twitter Feeds JS -->
|
331 |
+
<script type="text/javascript">
|
332 |
+
<?php echo "window.ctf_custom_js = function($){" . stripslashes( $ctf_custom_js ) . "}\r\n"; ?>
|
333 |
+
</script>
|
334 |
+
<?php
|
335 |
+
}
|
336 |
+
}
|
337 |
+
add_action( 'wp_footer', 'ctf_custom_js' );
|
338 |
+
|
339 |
+
/**
|
340 |
+
* outputs the custom css from the "Customize" tab on the Settings page
|
341 |
+
*/
|
342 |
+
function ctf_custom_css() {
|
343 |
+
$options = get_option( 'ctf_options' );
|
344 |
+
$ctf_custom_css = isset( $options[ 'custom_css' ] ) ? $options[ 'custom_css' ] : '';
|
345 |
+
|
346 |
+
if ( ! empty( $ctf_custom_css ) ) {
|
347 |
+
?>
|
348 |
+
<!-- Custom Twitter Feeds CSS -->
|
349 |
+
<style type="text/css">
|
350 |
+
<?php echo stripslashes( $ctf_custom_css ) . "\r\n"; ?>
|
351 |
+
</style>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
}
|
355 |
+
add_action( 'wp_head', 'ctf_custom_css' );
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Some CSS and JS needed in the admin area as well
|
359 |
+
*/
|
360 |
+
function ctf_admin_scripts_and_styles() {
|
361 |
+
wp_enqueue_style( 'ctf_admin_styles', plugins_url( '/css/ctf-admin-styles.css', __FILE__ ), array(), CTF_VERSION );
|
362 |
+
wp_enqueue_script( 'ctf_admin_scripts', plugins_url( '/js/ctf-admin-scripts.js', __FILE__ ) , array( 'jquery' ), CTF_VERSION, false );
|
363 |
+
wp_localize_script( 'ctf_admin_scripts', 'ctf', array(
|
364 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
365 |
+
'sb_nonce' => wp_create_nonce( 'ctf-smash-balloon' )
|
366 |
+
)
|
367 |
+
);
|
368 |
+
wp_enqueue_style( 'wp-color-picker' );
|
369 |
+
wp_enqueue_script(array('wp-color-picker'));
|
370 |
+
}
|
371 |
+
add_action( 'admin_enqueue_scripts', 'ctf_admin_scripts_and_styles' );
|
372 |
+
|
373 |
+
|
inc/CtfAdmin.php
CHANGED
@@ -706,7 +706,7 @@ class CtfAdmin
|
|
706 |
|
707 |
// Custom Date Format
|
708 |
$this->create_settings_field( array(
|
709 |
-
'name' => '
|
710 |
'title' => '<label for="ctf_custom_date_format">Custom Format</label><code class="ctf_shortcode">datecustom
|
711 |
Eg: datecustom="D M jS, Y"</code>', // label for the input field
|
712 |
'callback' => 'customize_custom_date_format', // name of the function that outputs the html
|
706 |
|
707 |
// Custom Date Format
|
708 |
$this->create_settings_field( array(
|
709 |
+
'name' => 'datecustom',
|
710 |
'title' => '<label for="ctf_custom_date_format">Custom Format</label><code class="ctf_shortcode">datecustom
|
711 |
Eg: datecustom="D M jS, Y"</code>', // label for the input field
|
712 |
'callback' => 'customize_custom_date_format', // name of the function that outputs the html
|
inc/CtfFeed.php
CHANGED
@@ -575,7 +575,6 @@ class CtfFeed
|
|
575 |
}
|
576 |
|
577 |
$this->persistent_index = $this->persistent_index + $this->feed_options['num'];
|
578 |
-
$this->feed_options['includeretweets'] = true;
|
579 |
|
580 |
$this->feed_options['count'] = 200;
|
581 |
|
@@ -1159,7 +1158,7 @@ class CtfFeed
|
|
1159 |
|
1160 |
if ( $feed_options['type'] === 'usertimeline' ) {
|
1161 |
$ctf_header_html .= '<div class="ctf-header' . $ctf_no_bio . '" style="' . $feed_options['headerbgcolor'] . '">';
|
1162 |
-
$ctf_header_html .= '<a href="
|
1163 |
$ctf_header_html .= '<div class="ctf-header-text">';
|
1164 |
$ctf_header_html .= '<p class="ctf-header-user" style="' . $feed_options['headertextcolor'] . '">';
|
1165 |
$ctf_header_html .= '<span class="ctf-header-name">';
|
575 |
}
|
576 |
|
577 |
$this->persistent_index = $this->persistent_index + $this->feed_options['num'];
|
|
|
578 |
|
579 |
$this->feed_options['count'] = 200;
|
580 |
|
1158 |
|
1159 |
if ( $feed_options['type'] === 'usertimeline' ) {
|
1160 |
$ctf_header_html .= '<div class="ctf-header' . $ctf_no_bio . '" style="' . $feed_options['headerbgcolor'] . '">';
|
1161 |
+
$ctf_header_html .= '<a href="https://twitter.com/' . $tweet_set[0]['user']['screen_name'] . '" target="_blank" title="@' . $tweet_set[0]['user']['screen_name'] . '" class="ctf-header-link">';
|
1162 |
$ctf_header_html .= '<div class="ctf-header-text">';
|
1163 |
$ctf_header_html .= '<p class="ctf-header-user" style="' . $feed_options['headertextcolor'] . '">';
|
1164 |
$ctf_header_html .= '<span class="ctf-header-name">';
|