Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vr shortcode #5917

Merged
merged 11 commits into from Dec 19, 2016
Merged

Add vr shortcode #5917

merged 11 commits into from Dec 19, 2016

Conversation

mkaz
Copy link
Contributor

@mkaz mkaz commented Dec 15, 2016

Add VR shortcode feature

Testing instructions:

  • Add vr shortcode to post: [vr url=path-to-photo.jpg view=360]
  • Confirm the 360 photo displays properly

See: https://en.support.wordpress.com/embedding-360-photos-and-virtual-reality-vr-content/

Proposed changelog entry for your changes:

  • Adds VR shortcode to embed 360° photos

Copy link
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.

Hi @mkaz, thanks for porting this, looks awesome. In addition to the two comments in the code:

  • functions must be prefixed with jetpack_
  • functions need inline documentation
  • the branch needs a git rebase master to catch up. The tests are not working due to this.

Thanks!

return vr_viewer_get_html( $url_params );
}

return '[vr] shortcode requires a data source to be given';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok to output this string? Maybe it can be displayed only to current_user_can( 'edit_posts' )? Or maybe in a comment?


$this->assertContains( $img, $shortcode_content );
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Needs at least one more test covering the case when there's not a valid source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test added in 1b8e7cc

@eliorivero eliorivero added [Feature] Shortcodes / Embeds [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Dec 16, 2016
function jetpack_vr_viewer_get_html( $url_params ) {
$iframe = add_query_arg( $url_params, 'https://vr.me.sh/view/' );

$rtn = '<div style="position: relative; max-width: 720px; margin-left: auto; margin-right: auto; overflow: hidden;">';
Copy link
Member

Choose a reason for hiding this comment

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

Instead of forcing the width here, what would you say about using $content_width to define the maximum width of the embeds?

}

// add check for user
if ( current_user_can('editor') || current_user_can('administrator') ) {
Copy link
Member

Choose a reason for hiding this comment

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

Since some folks use plugins like Members to customize capabilities for existing roles or to create new roles, it might be best to look for a capability (edit_others_posts) instead of checking for 2 roles?

You'll also want to add spaces between braces and quotes, as per the WP coding standards.

Thanks!

@@ -68,7 +68,12 @@ function jetpack_vr_viewer_shortcode( $atts ) {
return jetpack_vr_viewer_get_html( $url_params );
}

return '[vr] shortcode requires a data source to be given';
// add check for user
if ( current_user_can('editor') || current_user_can('administrator') ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO it's better to check specifically for edit_posts since an administrator might have been set by another admin to manage some options of the site but not edit posts, maybe due to privacy. Besides, we only need to make one check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another example is a new role basic_editor created with Members plugin with only the edit_posts capability. It's not editor nor administrator but it can still edit the posts.

@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Dec 16, 2016
@eliorivero
Copy link
Contributor

Only thing pending for this to be ready for merge is to add inline docs to functions.

@eliorivero
Copy link
Contributor

eliorivero commented Dec 19, 2016

I just tested adding this to a post

[vr url=https://en-blog.files.wordpress.com/2016/12/regents_park.jpg]

and got a PHP notice.

 Notice: Undefined index: view in /.../wp-content/plugins/jetpack/modules/shortcodes/vr.php on line 74

and the image was rendered like this:
vr

If 'view' is set by default to '360' here, the notice is gone and the image is properly rendered.
I know your testing instructions were

Add vr shortcode to post: [vr url=path-to-photo.jpg view=360]

but we need to take into account the case where a user might inadvertently add only the URL.

@eliorivero eliorivero added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Dec 19, 2016
@mkaz
Copy link
Contributor Author

mkaz commented Dec 19, 2016

That actually works as intended, but seems very strange since you are using a 360 photo.
The default view is for viewing panoramas (which we call cinema mode). It is setup this way since there are more panoramic photos than 360 photos.

So looks better if using a panoramic image URL such as this one: https://mfkaz.files.wordpress.com/2016/11/nobhill-pano.jpg

See Post at: https://mkaz.blog/2016/10/02/nob-hill-pano/

Or behavior in GIF here:
pano

@eliorivero
Copy link
Contributor

That's cool, what about the PHP notice?

@mkaz mkaz removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Dec 19, 2016
@eliorivero
Copy link
Contributor

LGTM! 🐑

@eliorivero eliorivero added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Dec 19, 2016
@samhotchkiss samhotchkiss merged commit f07dbf5 into master Dec 19, 2016
@samhotchkiss samhotchkiss deleted the add/vr-shortcode branch December 19, 2016 22:21
@dereksmart dereksmart restored the add/vr-shortcode branch December 20, 2016 13:59
@dereksmart
Copy link
Member

ported to 4.5 in 2553bc8

@jeherve jeherve added this to the 4.5 milestone Dec 23, 2016
jeherve added a commit that referenced this pull request Dec 23, 2016
dereksmart pushed a commit that referenced this pull request Jan 17, 2017
@see 18012a3

Changelog: add #5976, #5978, #5983

Changelog: add #5917

Changelog: add #5832
dereksmart pushed a commit that referenced this pull request Jan 17, 2017
Changelog: add #5867

Changelog: add #5874

Changelog: add #5905

Changelog: add #5906

Changelog: add #5931

Changelog: add #5933

Changelog: add #5934

Bring over 4.4.2 changelog from branch-4.4

@see 18012a3

Changelog: add #5976, #5978, #5983

Changelog: add #5917

Changelog: add #5832

Changelog: add 4.4.2 release post link.

CHangelog: add #5457

Changelog: add #5487

Changelog: add #5708

Changelog: add #5879

Changelog: add #5932

Changelog: add #5963

Changelog: add #5968

Changelog: add #5996

Changelog: add #5998

Changelog: add #5999

Changelog: add #6012

Changelog: add #6013

Changelog: add #6014

Changelog: add #6015

Changelog: add #6023

Changelog: add #6024

Changelog: add #6030

Changelog: add #5465

CHangelog: add #6063

Changelog: add #6025

Changelog: add #5974

Changelog: add #6059

Changelog: add #6046

Changelog: add #5418

Changelog: move things around and add missing information.

Changelog: add #5565

Changelog: add #6087

Changelog: add #6095

Readme: add @tyxla to the list of contributors.

Improved changelog for your readability and enjoyment

updated the release date

finalizing the changelog with a few more edits
@kraftbj kraftbj removed the [Status] Ready to Merge Go ahead, you can push that green button! label Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Shortcodes / Embeds Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants