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

Check if post is tailored #43

Closed
ManUtopiK opened this issue Sep 30, 2016 · 4 comments
Closed

Check if post is tailored #43

ManUtopiK opened this issue Sep 30, 2016 · 4 comments

Comments

@ManUtopiK
Copy link
Contributor

There is a function Tailor()->is_canvas() to see if we are on the Tailor canvas (currently editing the page).
There is another function called Tailor()->is_tailoring() but this is not to check if current post was edited with Tailor. I don't understand the purpose of this public function...

It will be nice if we could check in the WP loop if the post was tailored, with a public function like Tailor->is_tailored(). Actually I do that with:

if ( false == get_post_meta( $post->ID, '_tailor_layout', true ) ) {
   // $post not tailored
} else {
    // Tailored $post !
}
@andrew-worsfold
Copy link
Contributor

@ManUtopiK -

Tailor comprises two parts: the "sidebar" and "canvas" (or preview window), presented in an iframe. The is_tailoring() method is simply used to determine whether one is in the "sidebar" portion of the app (as there are styles and scripts unique to the sidebar).

I'm happy to add a check like the one that you proposed, but would like to understand more about the potential use cases for such a check. Do you have an example of when/how you'd use it?

Cheers,
Andrew.

@ManUtopiK
Copy link
Contributor Author

I use it to display information on front-end for logged-in user that got permissions to edit posts. Also, the edit post link in front-end is replaced by a tailor link when the post has been tailored, useful to prevent client mistake about #41.
And I use it to add a class in the article body...
But I think other use-cases can be found!

@andrew-worsfold
Copy link
Contributor

Agreed, I like that idea.

The simple function below returns true if a given post has a Tailor layout.

public function is_tailored( $post_id = null ) { $post = get_post( $post_id ); return $post && false != get_post_meta( $post->ID, '_tailor_layout', true ); }

I have this as a method in the Tailor class, so to access it will be identical to your original example:

tailor()->is_tailored()

How does that look?

@ManUtopiK
Copy link
Contributor Author

That's look perfect! You're awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants