-
Notifications
You must be signed in to change notification settings - Fork 475
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
Templates: clean up task #1194
Templates: clean up task #1194
Conversation
So. After I saw the Travis CI Unit Test results and seeing this and this test failing, I looked up the source of |
|
Ah, yeah - I did test the later two pull request extensions, but the template files should be tested as well. I ain't got shortcodes anywhere. |
While I appreciate the pull, you have completely neglected the WordPress coding standards in your updated template files. We may have some spaces / tabs mixed together inappropriately, but we try (and largely succeed) to follow the WP coding standards. This pull is pretty far off. If you'd like examples, let me know, I"ll be happy to draw them up :) |
Yeah, please do that. Afaik the WP coding "standards" use Egyptian brackets. N/P reworking it as I got it on the side. :) The main problem I got with the previous version is the line length. Everything above 80-100 chars per line is unreadable on GitHub and in most IDEs that have a sidebar for e.g. source lookup, etc. It's still not 100%, but it's imo far better. Then there's the problem (and old discussion) with |
Here's a quick list:
Not
Other notes:
|
Don't see any Spaces aside from aligning. Please point me at them if you found any. From a brief check there weren't any.
Ups, done! :)
Actually there're several reasons for using
Even if I don't like it, I changed it to WP coding "style" ;) |
I will review and test it as soon as I can. Thanks for the updates! |
While not a standard noted directly, based on the default themes, etc, I think template files should use conditionals like:
It feels less "PHPy" and more "templatey" -- And then you don't need comments like |
I agree with Spencer. It's easier to read. |
Agree with Kaiser. Endifs are hard to work with when you've got to find where they end. |
You don't need endif comments if you use a standard editor with braces. Not sure why you couldn't put "meaningfully comments" either eay |
|
First off if they are editing a template file either they know PHP (in
|
I still disagree. Just because they SHOULD have knowledge of PHP if editing files, doesn't mean they do, and we should consider that and make it as easy as possible for them. |
And of course, we can always point to the handbook.....no endifs there If they don't know PHP, likely they'd use an IDE like Visual Studio, or dare I say it, Dreamweaver, both of which can't find the ends of "endif" statements. If anything's easier for them it's using braces. I'd love to find an example of someone who doesn't know PHP AND who is not afraid of editing the files AND is doing it by themselves AND and has no idea what braces are AND is using a resource to learn PHP that uses endifs over braces AND know what templates are AND what they are used for AND where they are found AND how they are used. Odds: Less than getting mauled by a Polar bear, Brown bear, and black bear on the same day. In Guatemala. If they use any online assistance to help them, say W3CSchools, which alot of beginners do, they use braces. Then there's project consistency. We use braces everywhere else. Why not here? At the very least, the 0.0000000001% of users that now fit this criteria, could benefit from learning what braces are. However, isn't the point of templates to help the 99.99999999999% that use them? Like the theme devs, or users with PHP experience who actually even know what templates are, what they are used for, where they are found, and how they are used? |
@@ -1,4 +1,5 @@ | |||
<?php | |||
! defined( 'ABSPATH' ) AND exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should stick to what we use everywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than ! defined( 'ABSPATH' ) AND exit;
, I'd prefer defined( 'ABSPATH' ) OR exit;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely agree. That's exactly what I use in every of my own plugins and themes for files that shouldn't get loaded outside the context.
Template files are the exception to the rule, simply because they are the part that users interact with. |
Was that a comment to the code comment? |
There aren't any in the handbook yes, but like I said, look at any of the default themes, and all template files use them. I agree, braces should be used in all other instances, but anything related to the theme, or when PHP and HTML are commingling is an exception in my book |
No, I agreed with the ABSPATH comment. I"m saying template files are the exception for using endif, endwhile, etc, in stead of brackets. In order to keep with WordPress standards, I'm requiring that we use endif / endwhile. All of the default WP themes do it that way and it is more semantic for non-developers. The way default WP themes are setup is a lot of user's first experiences with code, so when they are editing simple HTML we should try to adhere to that as much as possible. Sorry but I"m putting my foot down. |
I can see that. As two of us participating in this discussion agree and two don't agree, we got a patt situation. So I'd suggest the following, which allows a sane use of the IDE (folding, highlighting, etc.) and still explains the 0.0^10% of those users what it's about:
This imho is much more readable that |
This I am fascinated by: why is {} better than endforeach/endif, but AND / OR is better than && and ||? They seem like the same thing to me, though I do realize that I don't like AND and OR :P |
Yeah I don't like AND/OR either. |
I already explained it in a comment above:
Ad the difference between operators
No, they are not. I already mentioned it above. Anyway, I'm not putting my heart into this pull request and the result must please the majority. |
Thanks for taking the time anyway. |
Trac ticket: http://core.trac.wordpress.org/ticket/24549 |
No problem. |
All the templates packaged with the plugins were in terrible shape: Mixed Tabs/Spaces, closing PHP tags at the end of the files, endless line length that needed horizontal scrolling on GitHub, etc.
The pull request focuses on code readability and code structure that allows easier reading and understanding of HTML element nesting. Cleaned up all Tabs/Spaces, etc. Added missing
id
s to match the labels and what-not-else.I'm pretty sure that lots of the edges could be ironed out with simply reworking the if/else statements. This would as well flatten the structure allowing for longer lines. Overall this is just a starting point and should serve as base for further improvements.