php opening & closing tags break code blocks
-
With a recent update, some of my code blocks broke: it closed the php shortcode automatically when there were multiple php opening and closing tags in the snippet.
Example:
[php] add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_due_date', 10, 2 ); function wpo_wcpdf_due_date ($template_type, $order) { if ($template_type == 'invoice') { // put due date only on invoice $invoice_date = get_post_meta( $order->id, '_wcpdf_invoice_date', true ); $due_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date . ' + 14 days') ); ?> <tr class="due-date"> <th>Due Date:</th> <td><?php echo $due_date; ?></td> </tr> <?php } } [/php]
would save as (note the small but significant change in the first line):
[php][/php] add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_due_date', 10, 2 ); function wpo_wcpdf_due_date ($template_type, $order) { if ($template_type == 'invoice') { // put due date only on invoice $invoice_date = get_post_meta( $order->id, '_wcpdf_invoice_date', true ); $due_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date . ' + 14 days') ); ?> <tr class="due-date"> <th>Due Date:</th> <td><?php echo $due_date; ?></td> </tr> <?php } } [/php]
This could be fixed by doing:
[php] <?php add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_due_date', 10, 2 ); function wpo_wcpdf_due_date ($template_type, $order) { if ($template_type == 'invoice') { // put due date only on invoice $invoice_date = get_post_meta( $order->id, '_wcpdf_invoice_date', true ); $due_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date . ' + 14 days') ); ?> <tr class="due-date"> <th>Due Date:</th> <td><?php echo $due_date; ?></td> </tr> <?php } } ?> [/php]
but that’s not what I want because I don’t want my customers to put the php tags in there theme functions (when blindly copy pasting).
Is there any other way to prevent this? Is this a bug or a feature?
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘php opening & closing tags break code blocks’ is closed to new replies.