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

Enable Post::convert() to convert also single WP_Posts #1439

Merged
merged 5 commits into from Jun 12, 2017

Conversation

@luism-s
Copy link
Contributor

luism-s commented May 31, 2017

Issue

When a developer tries to use get_field on a relationship or repeater field, Timber returns an array with instances of TimberPost. However, that didn't happen for Post Object fields, and a WP_Post was returned instead.

Solution

In the convert function used by get_field, a if condition was added to check if the argument given is an instance of WP_Post (and not an array of course), and returns an instance of TimberPost.

Impact

None that I'm aware of.

Usage

Ability to use get_field() on a Post Object field and get a TimberPost

Considerations

None

Testing

{% set post_obj = post.get_field('single_post') %}
{{ post_obj.thumbnail.src.('medium) }}

The last line would fail because post_obj wouldn't be a TimberPost, but a WP_Post

@coveralls

This comment has been minimized.

Copy link

coveralls commented May 31, 2017

Coverage Status

Coverage decreased (-0.03%) to 93.282% when pulling 1901c14 on luism-s:develop into ddf0031 on timber:master.

@codecov

This comment has been minimized.

Copy link

codecov bot commented May 31, 2017

Codecov Report

Merging #1439 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1439      +/-   ##
============================================
+ Coverage     93.94%   93.94%   +<.01%     
- Complexity     1410     1411       +1     
============================================
  Files            46       46              
  Lines          3402     3404       +2     
============================================
+ Hits           3196     3198       +2     
  Misses          206      206
Impacted Files Coverage Δ Complexity Δ
lib/Post.php 93.58% <100%> (+0.03%) 203 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a927fb...7655f17. Read the comment docs.

@coveralls

This comment has been minimized.

Copy link

coveralls commented Jun 7, 2017

Coverage Status

Coverage decreased (-0.03%) to 93.282% when pulling cff8a04 on luism-s:develop into ddf0031 on timber:master.

1 similar comment
@coveralls

This comment has been minimized.

Copy link

coveralls commented Jun 7, 2017

Coverage Status

Coverage decreased (-0.03%) to 93.282% when pulling cff8a04 on luism-s:develop into ddf0031 on timber:master.

luism-s added 2 commits Jun 7, 2017
@coveralls

This comment has been minimized.

Copy link

coveralls commented Jun 7, 2017

Coverage Status

Coverage decreased (-0.03%) to 93.282% when pulling 3aa2fd9 on luism-s:develop into ddf0031 on timber:master.

@coveralls

This comment has been minimized.

Copy link

coveralls commented Jun 7, 2017

Coverage Status

Coverage increased (+0.004%) to 93.314% when pulling 5cfd646 on luism-s:develop into ddf0031 on timber:master.

@jarednova

This comment has been minimized.

Copy link
Member

jarednova commented Jun 12, 2017

Awesome, thanks @luism-s! And with a test! I'm just re-running tests based on the newest master then I'll merge this in!

@coveralls

This comment has been minimized.

Copy link

coveralls commented Jun 12, 2017

Coverage Status

Coverage increased (+0.004%) to 93.408% when pulling 7655f17 on luism-s:develop into 5a927fb on timber:master.

@jarednova jarednova merged commit 179175e into timber:master Jun 12, 2017
5 checks passed
5 checks passed
Scrutinizer 1 new issues, 1 updated code elements
Details
codecov/patch 100% of diff hit (target 93.94%)
Details
codecov/project 93.94% (+<.01%) compared to 5a927fb
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.004%) to 93.408%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.