Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions wordpress-coding-standards/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,34 @@ Correct (Single Line):
<input name="<?php echo esc_attr( $name ); ?>" />
```

When embedding single lines of PHP within an HTML block, the PHP open and close tags must be on the same line as the PHP code, surrounding it.

Correct:

```php
<div class="hfeed">
<?php while ( have_posts() ) : the_post(); ?>
<article id="someid class="someclass">
<!-- ... -->
</article>
<?php endwhile; ?>
</div>
```

Incorrect:

```php
if ( $a === $b ) { ?>
<some html>
<?php }
<div class="hfeed">
<?php
while ( have_posts() ) : the_post();
?>
<article id="someid class="someclass">
<!-- ... -->
</article>
<?php
endwhile;
?>
</div>
```

<h3>No Shorthand PHP Tags</h3>
Expand Down