Regarding internationalization which of the two would be the proper correct way to process the translation.

echo '<p>' . esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipisicing', 'textdomain' ) . '</p>';


printf( '<p>%1$s</p>', esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipisicing', 'textdomain' ) );

And if i need to add wrap the following within p tags i would just need to add the p tags as allowed HTML tags. As shown below

printf( wp_kses( __( '<p>Ready to publish your first post? <a href="%1$s">Get started here</a>.</p>', 'maker_' ), array( 'a' => array( 'href' => array() ), 'p' => array() ) ), esc_url( admin_url( 'post-new.php' ) ) );

The two are exactly the same but I would go for the first one:

  • Easier to read
  • No interpolation, keep interpolation for variables

And, including the tags inside the format is making things more complicated, I can think of designers being tempted to use more tags if they see you are using them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.