Skip to content

Widgets: Porting of WP.com's Flickr Widget#6942

Merged
eliorivero merged 11 commits intomasterfrom
add/widgets/flickr
Apr 24, 2017
Merged

Widgets: Porting of WP.com's Flickr Widget#6942
eliorivero merged 11 commits intomasterfrom
add/widgets/flickr

Conversation

@Copons
Copy link
Copy Markdown
Contributor

@Copons Copons commented Apr 6, 2017

This is my second PR in the effort of filling the gaps between Jetpack and WP.com, to smooth the AT process out.

Changes proposed in this Pull Request:

  • Adds the Flickr widget as already available on WP.com.

Testing instructions:

  • Add the widget to a sidebar and check if the widget shows up.
  • Check if the photos are retrieved from the correct RSS feed.

Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I just made a few comments about small changes.

<img
alt="<?php echo $photo['title']; ?>"
border="0"
src="<?php echo $photo['src']; ?>"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we could apply Photon to those images if the module is enabled, like we do for the Image and the Text widget.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into it!

<?php foreach ( $photos as $key => $photo ) { ?>
<a href="<?php echo $photo['link']; ?>">
<img
alt="<?php echo $photo['title']; ?>"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we esc_attr here, just in case?

<tr>
<td align="center">
<?php foreach ( $photos as $key => $photo ) { ?>
<a href="<?php echo $photo['link']; ?>">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we escape here too?

alt="<?php echo $photo['title']; ?>"
border="0"
src="<?php echo $photo['src']; ?>"
title="<?php echo $photo['title']; ?>"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we escape here too?

/>
</a><br /><br />
<?php } ?>
<a href="<?php echo $flickr_home; ?>">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we escape here too?

@@ -0,0 +1,33 @@
<!-- Start of Flickr Widget -->
<table
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the table layout? Would it be possible to use regular divs, so folks can customize the layout with a bit less trouble?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, and it has been quite cringeworthy to write! 😄

Fact is: that's the wpcom version code.
The point of this porting is so that wpcom sites will look and behave the same after an AT.
And so, what if someone customized the CSS of their Flickr widget and changing the HTML or the class names will screw it up?

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Pri] Normal and removed [Status] Needs Review This PR is ready for review. labels Apr 7, 2017
Copy link
Copy Markdown
Contributor

@eliorivero eliorivero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comment in the code:

After adding this, I get these in front end:

Notice: rss.php is <strong>deprecated</strong> since version 3.0.0! Use wp-includes/class-simplepie.php instead. in /wp-includes/functions.php on line 3958
Notice: Trying to get property of non-object in /wp-content/plugins/jetpack/modules/widgets/flickr.php on line 84
Notice: Undefined variable: flickr_home in /wp-content/plugins/jetpack/modules/widgets/flickr/widget.php on line 24


<p>
<small>*
<?php esc_html_e( 'To find your Flickr RSS feed, go to your photostream and click the "Edit" tab at the top. Scroll down to the bottom of the page until you see the RSS icon or the Latest link. Right click on either and copy the URL. Paste into the box above.', 'jetpack' ); ?>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

captura de pantalla 2017-04-07 a las 17 41 27

a) This should be updated since there are no tabs now. There's a More link that unfolds a menu. Edit is now there.

b) Would be great if the text could be trimmed down to a point where it fits nicely below the input field, even in more than one line.

@Copons
Copy link
Copy Markdown
Contributor Author

Copons commented Apr 8, 2017

@jeherve All the $photo properties and $flickr_home are escaped during the $photos array creation:

array_push( $photos, array(
'href' => esc_url( $photochannel['link'], array( 'http', 'https' ) ),
'src' => esc_url( $src, array( 'http', 'https' ) ),
'title' => esc_attr( $photo['title'] ),
) );
}
$flickr_home = esc_url( $rss->channel['link'], array( 'http', 'https' ) );

@Copons
Copy link
Copy Markdown
Contributor Author

Copons commented Apr 8, 2017

@eliorivero I was sure I protected those variables in case of undefined, but I might be confusing it with another PR. :/
Gonna see to replace the RSS library and try a leaner explanation text.

@jeherve
Copy link
Copy Markdown
Member

jeherve commented Apr 10, 2017

All the $photo properties and $flickr_home are escaped during the $photos array creation:

array_push( $photos, array(
'href' => esc_url( $photochannel['link'], array( 'http', 'https' ) ),
'src' => esc_url( $src, array( 'http', 'https' ) ),
'title' => esc_attr( $photo['title'] ),
) );
}
$flickr_home = esc_url( $rss->channel['link'], array( 'http', 'https' ) );

Yeah, I noticed that and I think that's fine, but I would still escape them right before they get rendered, as outlined here:
https://vip.wordpress.com/documentation/vip/best-practices/security/validating-sanitizing-escaping/#always-escape-late

@Copons Copons added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 10, 2017
@beaulebens beaulebens changed the title Widgets: Porting of WP.com's Flickr Widgets: Porting of WP.com's Flickr Widget Apr 10, 2017
@sirbrillig sirbrillig self-requested a review April 20, 2017 21:44
Copy link
Copy Markdown
Member

@sirbrillig sirbrillig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

@jeherve jeherve modified the milestone: 4.9 Apr 24, 2017
Copy link
Copy Markdown
Contributor

@dereksmart dereksmart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works well for me

@dereksmart dereksmart 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 Apr 24, 2017
@eliorivero
Copy link
Copy Markdown
Contributor

eliorivero commented Apr 24, 2017

Works fine. Made a small change to the wording to reference always the same input label instead of "feed" which is not found in the UI for this widget. It's good to go and will merge once Travis ends.
I also rebased this branch to update it after the Cookie Law widget was merged.

@eliorivero eliorivero merged commit c420b2c into master Apr 24, 2017
@eliorivero eliorivero deleted the add/widgets/flickr branch April 24, 2017 22:18
@eliorivero eliorivero removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 24, 2017
jeherve added a commit that referenced this pull request Apr 24, 2017
eliorivero pushed a commit that referenced this pull request Apr 25, 2017
* Changelog: initial commit for 4.9 release.

* Changelog: add #6929

* Changelog: move old changelogs to changelog.txt

* Readme: restore deleted release post link.

The post is now live.

* Changelog: add #6853

* Changelog: add #6856

* Changelog: add #6857

* Changelog: add #6884

* Changelog: add #6885

* Changelog: add #6892

* Changelog: add #6894

* Changelog: add #6898

* Changelog: add #6899

* Changelog: add #6900

* Changelog: add #6909

* Changelog: add #6927

* Changelog: add #6947

* Chagelog: add #6958

* Changelog: add #6961

* Changelog: add #6963

* Changelog: add #6965

* Changelog: add #6986

* Changelog: add #7000

* Changelog: add #7013

* Changelog: add #7015

* Changelog: add #7019

* Changelog: add #7028

* Changelog: add #6998

* Changelog: add #6999

* Changelog: add #7044

* Changelog: add #6881

* Changelog: add #6922

* Changelog: add #6940

* Changelog: add #6962

* Changelog: add #6942

* Changelog: add #6959

* Changelog: add #7018

* Changelog: add #6948

* Changelog: add #6657

* Changelog: add #7030

* Changelog: add #7048

* Changelog: add #7031

* Changelog: add #6990

* Changelog: add #6957

* Changelog: add #7027
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.

5 participants