{"action":"created","issue":{"url":"https://api.github.com/repos/jarednova/timber/issues/876","repository_url":"https://api.github.com/repos/jarednova/timber","labels_url":"https://api.github.com/repos/jarednova/timber/issues/876/labels{/name}","comments_url":"https://api.github.com/repos/jarednova/timber/issues/876/comments","events_url":"https://api.github.com/repos/jarednova/timber/issues/876/events","html_url":"https://github.com/jarednova/timber/pull/876","id":137805451,"number":876,"title":"[Needs Review] Ref #836 - Allow to preview when using TimberPost","user":{"login":"connorjburton","id":10538031,"avatar_url":"https://avatars.githubusercontent.com/u/10538031?v=3","gravatar_id":"","url":"https://api.github.com/users/connorjburton","html_url":"https://github.com/connorjburton","followers_url":"https://api.github.com/users/connorjburton/followers","following_url":"https://api.github.com/users/connorjburton/following{/other_user}","gists_url":"https://api.github.com/users/connorjburton/gists{/gist_id}","starred_url":"https://api.github.com/users/connorjburton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/connorjburton/subscriptions","organizations_url":"https://api.github.com/users/connorjburton/orgs","repos_url":"https://api.github.com/users/connorjburton/repos","events_url":"https://api.github.com/users/connorjburton/events{/privacy}","received_events_url":"https://api.github.com/users/connorjburton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jarednova","id":1298086,"avatar_url":"https://avatars.githubusercontent.com/u/1298086?v=3","gravatar_id":"","url":"https://api.github.com/users/jarednova","html_url":"https://github.com/jarednova","followers_url":"https://api.github.com/users/jarednova/followers","following_url":"https://api.github.com/users/jarednova/following{/other_user}","gists_url":"https://api.github.com/users/jarednova/gists{/gist_id}","starred_url":"https://api.github.com/users/jarednova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarednova/subscriptions","organizations_url":"https://api.github.com/users/jarednova/orgs","repos_url":"https://api.github.com/users/jarednova/repos","events_url":"https://api.github.com/users/jarednova/events{/privacy}","received_events_url":"https://api.github.com/users/jarednova/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-03-02T08:21:16Z","updated_at":"2016-03-02T18:04:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jarednova/timber/pulls/876","html_url":"https://github.com/jarednova/timber/pull/876","diff_url":"https://github.com/jarednova/timber/pull/876.diff","patch_url":"https://github.com/jarednova/timber/pull/876.patch"},"body":"This solves #836. This needs review as it touches a few important bits of code. @jarednova \r\n\r\nAlso still needs tests that I will write once functionality is complete.\r\n\r\n#### Issue\r\nIf you use `TimberPost` in your PHP files and try to preview the page it won't show any previews.\r\n\r\n#### Solution\r\nIf `$_GET['preview']` is set and the `nonce` verifies we then go onto to test if the current user _should_ be seeing this post/page, if they are we get the latest revision and return the ID of that post.\r\n\r\nThe ID will also fall back to the original post if a revision isn't found or the user doesn't have permissions to see the post preview.\r\n\r\n#### Impact\r\nPossibly bad ones if we miss something.\r\n\r\n#### Usage\r\nNo change\r\n\r\n#### Considerations\r\nOkay a few things:\r\n\r\n1. I'm using `$_GET` - is there a wrapper around this? I don't see why `$_GET` wouldn't be fine in this situation, just wondering for consistency\r\n2. At the moment I just check for `edit_posts/pages` and `edit_others_posts/pages`, however does this cover custom post types? I don't think so. What about if a user should be able to see the post but not necessarily be able to edit the page/post, is there another capability type for that?\r\n3. Is there an easier way to do this? The original issue said he just changed it to `Timber::query_post` and it worked, can we hook into that?\r\n4. Do we need to check for passworded posts?"},"comment":{"url":"https://api.github.com/repos/jarednova/timber/issues/comments/191352519","html_url":"https://github.com/jarednova/timber/pull/876#issuecomment-191352519","issue_url":"https://api.github.com/repos/jarednova/timber/issues/876","id":191352519,"user":{"login":"connorjburton","id":10538031,"avatar_url":"https://avatars.githubusercontent.com/u/10538031?v=3","gravatar_id":"","url":"https://api.github.com/users/connorjburton","html_url":"https://github.com/connorjburton","followers_url":"https://api.github.com/users/connorjburton/followers","following_url":"https://api.github.com/users/connorjburton/following{/other_user}","gists_url":"https://api.github.com/users/connorjburton/gists{/gist_id}","starred_url":"https://api.github.com/users/connorjburton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/connorjburton/subscriptions","organizations_url":"https://api.github.com/users/connorjburton/orgs","repos_url":"https://api.github.com/users/connorjburton/repos","events_url":"https://api.github.com/users/connorjburton/events{/privacy}","received_events_url":"https://api.github.com/users/connorjburton/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T18:04:18Z","updated_at":"2016-03-02T18:04:18Z","body":"@scottfatbeehive - I did look at that, but `is_preview` seems to assume that `$wp_query` is already the previewed post, however the issue here is that `$wp_query` isn't yet the previewed post until we do the checks in the PR. Unless I am wrong here?\r\n\r\n@jarednova - okay thanks for checking, leave it with me and I will try and write a test for this use case. If I can figure it out. I'll let you know when it's all okay to merge."}}