Skip to content

Widgets/Shortcodes: Twitter Timeline: remove widget ID requirement#4198

Merged
jeherve merged 3 commits intomasterfrom
update/twitter-remove-widget-ids
Jun 28, 2016
Merged

Widgets/Shortcodes: Twitter Timeline: remove widget ID requirement#4198
jeherve merged 3 commits intomasterfrom
update/twitter-remove-widget-ids

Conversation

@nylen
Copy link
Copy Markdown
Contributor

@nylen nylen commented Jun 22, 2016

This PR updates the Twitter Timeline widget and shortcode to no loner require a Twitter widget ID, per #3993.

Also contains lots of miscellaneous cleanup to this code, including:

  • Added validation and documentation of width and height constraints (determined from playing around with the interface at publish.twitter.com)
  • Tried to clean up long lines of HTML/PHP soup
  • Removed "No Scrollbar" option which is not working for me

Closes #3993; also closes #3283 by moving the width and height attributes as follows:

- <a width="..." height="...">
+ <a data-width="..." data-height="...">

To test - Widget

Before applying this patch, add a Twitter timeline widget to your site. Here is a widget ID you can use to show tweets about corgis - 741284449141334020

Apply the patch and test the following:

  • Existing timeline widgets display correctly on the site and in the admin settings (type should be set to "Widget ID")
  • New timeline widgets are added with type set to "Profile", and display correctly on the site when a Twitter username is entered
  • Changing the type of the widget changes the label of the next field to either "Twitter Username" or "Widget ID" (and this label loads correctly for existing widgets)

Test configuring the widget in both wp-admin/widgets.php and the Customizer. Ensure that all settings still work, and that the new validation for width and height works correctly.

To test - Shortcode

To test the [twitter-timeline] shortcode, specify either the username parameter (now supported without a widget ID) or the id parameter with an existing Twitter widget ID (now supported without a username, because the widget ID overrides the username anyway).

More info

The new features of the Twitter widget and shortcode are documented at https://en.support.wordpress.com/widgets/twitter-timeline-widget/ . Note that there are 3 places where the widget settings will link to the Jetpack documentation page:

The Jetpack documentation page should be updated to be similar to the WordPress.com page when these changes go live.

The changes introduced here have been deployed on WordPress.com, but this PR does not quite bring the Twitter Timeline widget into sync with WP.com because of #3543. Per #3543 (comment) there is still some work left to do by the Jetpack team to merge these changes back.

cc @westonruter - I don't understand the selective refresh changes in #3543 very well and would like to make sure I didn't break anything introduced there.

@eliorivero
Copy link
Copy Markdown
Contributor

@nylen

Widget
I had a Twitter Timeline widget added to one of the sidebars, and after applying the patch and immediately reloading the front end, I got this notice (in debug.log, also visible with Query Monitor plugin):

Undefined index: type in /example/wp-content/plugins/jetpack/modules/widgets/twitter-timeline.php on line 112

dynamic_sidebar() /example/wp-content/themes/twentysixteen/sidebar.php:13
call_user_func_array:{/example/wp-includes/widgets.php:738}() /example/wp-includes/widgets.php:738
WP_Widget->display_callback() /example/wp-includes/widgets.php:738
Jetpack_Twitter_Timeline_Widget->widget() /example/wp-includes/class-wp-widget.php:3

The line 112 is a switch statement. The tweets continue to display normally. The only issue is the notice.

Adding this before the line fixes the issue:

if ( ! isset( $instance['type'] ) ) {
    $instance['type'] = '';
}

Shortcode
It's working fine.

@eliorivero eliorivero added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] Needs Review This PR is ready for review. labels Jun 26, 2016
@nylen
Copy link
Copy Markdown
Contributor Author

nylen commented Jun 27, 2016

Fixed the notice in 7bed014.

@nylen nylen removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jun 27, 2016
@westonruter
Copy link
Copy Markdown
Contributor

I don't understand the selective refresh changes in #3543 very well and would like to make sure I didn't break anything introduced there.

I don't see a problem here. If the actual widget ID was removed, the id attribute in HTML, then that would be a problem. But this is something different.

@eliorivero eliorivero added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jun 28, 2016
@eliorivero
Copy link
Copy Markdown
Contributor

It's good to go now! 💯

@eliorivero eliorivero modified the milestones: 4.1, 4.2 Jun 28, 2016
@jeherve
Copy link
Copy Markdown
Member

jeherve commented Jun 28, 2016

It seems to work in my tests. Merging.

@jeherve jeherve merged commit a089196 into master Jun 28, 2016
@jeherve jeherve deleted the update/twitter-remove-widget-ids branch June 28, 2016 14:00
@jeherve jeherve removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jun 28, 2016
jeherve added a commit that referenced this pull request Jun 28, 2016
@nylen
Copy link
Copy Markdown
Contributor Author

nylen commented Jun 28, 2016

🎉 Thanks everyone for reviewing!

jeherve added a commit that referenced this pull request Jan 19, 2017
The option was removed in #4198, but it is still supported by Twitter:
https://dev.twitter.com/web/embedded-timelines#customization

To be be able to hide the scrollbar, you should not specify a number of tweets in the widget.
If you do, the `data-tweet-limit` attribute will be added to the widget and the timeline will automatically adjust its height to fit the
specified number of Tweets. That's most likely why we thought the option didn't work when testing in #4198.

Reported here:
https://twitter.com/LorrieW_Art/status/822005258096406529
georgestephanis pushed a commit that referenced this pull request Mar 22, 2017
From review at #4198

Merges r137943-wpcom.
samhotchkiss pushed a commit that referenced this pull request Mar 28, 2017
* Widgets: Facebook Like Box: Fallback to WordPress locale or English for unknown locale

See: r117058
See: https://[private link]

Merges r120105-wpcom.

* Facebook Like Box Widget: Restore 'width' option to support widget areas wider than 340px.

We recently removed the width option from this widget in order to allow it to be responsive. However, it defaults to 340px at largest, which is a problem for wider widget areas.

This is a partial revert of r119494-wpcom.

https://[private link]
ed2c2a9
https://[private link]#comment-33575

Merges r121114-wpcom.

* Widgets: Facebook Page Plugin: Update the wp-admin strings for "Like Box" to read "Page Plugin" instead, since the code now loads the Facebook page plugin code instead.

Merges r123111-wpcom.

* Widgets: rename `widget` pageview stat to something more useful: `widget_view`, see #7805.

Merges r144861-wpcom.

* Widgets: minor code and comments cleanup in Facebook Page Plugin.

See #6421.

Merges r148069-wpcom.

* Widgets: Facebook Page Plugin: better UX for min/max height and width values.

Fixes https://github.com/Automattic/customization/issues/53

Merges r148071-wpcom.

* Widgets: more attribute escaping for Facebook Page Plugin widget.

See r148071.

Merges r148072-wpcom.

* Widgets: add pageview tracking to more active WP.com widgets, see #7805.

Merges r144867-wpcom.

* Widgets: minor documentation fixes, code style for Google Translate widget.

See #7805

Merges r145017-wpcom.

* Widgets: rename `widget` pageview stat to something more useful: `widget_view`, see #7805.

Merges r144861-wpcom.

* Widgets: sync stats bumps with latest Jetpack changes.

See #5488

Merges r144995-wpcom.

* Widgets: add pageview tracking to more active WP.com widgets, see #7805.

Merges r144867-wpcom.

* Widgets: fix a few Jetpack stats bumps, see #7805.

Ref: #5488

Merges r144925-wpcom.

* Widgets: sync stats bumps with latest Jetpack changes.

See #5488

Merges r144995-wpcom.

* Widgets: minor documentation fixes, code style for Google Translate widget.

See #7805

Merges r145017-wpcom.

* Widgets: add Flickr to the services available in the Social Media Icons widget.

See #5156

Merges r148065-wpcom.

* Widgets: add pageview tracking to more active WP.com widgets, see #7805.

Merges r144867-wpcom.

* Widgets: sync stats bumps with latest Jetpack changes.

See #5488

Merges r144995-wpcom.

* Widgets: fix grid layout for Top Posts and Pages to show correct avatar fallback image size of 200 pixels square.

FIxes #6664.

Merges r148090-wpcom.

* Widgets: Update URL to create a Twitter widget

This is just a stopgap until we can fully integrate with the new
publish.twitter.com setup.  See https://github.com/Automattic/io/issues/601 for
more info.

Merges r137075-wpcom.

* Widgets: Update Twitter Timeline to not require a widget ID

https://[private link]

Merges r137600-wpcom.

* Widgets: Twitter Timeline: Use data-width= instead of width=

Same for height, and a couple of other cleanups.  See:

#3283

Merges r137659-wpcom.

* Widgets: Twitter Timeline: Fix a PHP notice

From review at #4198

Merges r137943-wpcom.

* Widgets: rename `widget` pageview stat to something more useful: `widget_view`, see #7805.

Merges r144861-wpcom.

* Widgets: fix a few Jetpack stats bumps, see #7805.

Ref: #5488

Merges r144925-wpcom.

* Widgets: sync stats bumps with latest Jetpack changes.

See #5488

Merges r144995-wpcom.

* Widgets: fix Twitter Timeline height (not used any more) and set maximum number of tweets to 20.

Fixes https://github.com/Automattic/customization/issues/74

Merges r148193-wpcom.

* Widgets: still honor Twitter Timeline 'height' value if it was previously set.

See r148193 and https://github.com/Automattic/customization/issues/74

However, Twitter might not honor it.

Merges r148239-wpcom.

* Widgets: revert the height changes to Twitter Timeline in r148193.

Needs more investigation on why they are ignored by Twitter's embed.

See https://github.com/Automattic/customization/issues/74

Merges r148240-wpcom.

* Widgets: further improvements to Twitter Timeline tweet limit and height values.

Per recommendations by Niall Kennedy: #6021 (comment)

 * When a valid tweet limit is set, ignore the user given height.
 * Properly validate the integer value of tweet limit.

See r148240 and https://github.com/Automattic/customization/issues/74

Merges r148835-wpcom.

* Apply timezone offsets to the upcomingevents shortcode

This patch adds changes to the calendar shortcode so that it applies a users timezone to all of the rendered events

See https://[private link]
Differential Revision: https://[private link]

Merges r151822-wpcom.

* Apply timezone offsets to the upcomingevents shortcode

This patch adds changes to the calendar shortcode so that it applies a users timezone to all of the rendered events

See https://[private link]
Differential Revision: https://[private link]

Merges r151822-wpcom.

* Fix calendar reader timezone offsets

This revision aims at fixing an issue in the `iCalendarReader` class
The function that applies timezone offsets calculates the time difference for timezones using the current date instead of the date thats actually associated with the event. This leads to Daylight Savings Time confusions if today is standard time and the event occurs in daylight savings time. Today (3-8-2017) an event for 3-15-2017 6:30pm will show up as 3-15-2017 5:30pm

For effected users see:
  - https://[private link]
  - https://[private link]
  - https://[private link]

Merges r152463-wpcom.

* Remove duplicated method.

Must have been a merge gone bad.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Twitter timeline: remove widget ID requirement

4 participants