[wp-trac] [WordPress Trac] #44051: Improve `WP_Privacy_Policy_Content::get_default_content()` readability

WordPress Trac noreply at wordpress.org
Mon May 14 09:04:39 UTC 2018


#44051: Improve `WP_Privacy_Policy_Content::get_default_content()` readability
----------------------------+-------------------------------
 Reporter:  desrosj         |       Owner:  (none)
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  4.9.7
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch gdpr  |     Focuses:  coding-standards
----------------------------+-------------------------------

Comment (by azaozz):

 This follows the pattern from
 [https://core.trac.wordpress.org/browser/tags/4.9.5/src/wp-includes
 /script-loader.php#L71 script-loader.php]:
 {{{
 did_action( 'init' ) && $scripts->localize()...
 }}}

 Don't think that is really "clever" code, pretty standard pattern for many
 repeated `if ( true )` statements.

 > Replacing these with if ( $descr ) {} is much less clever, but more
 readable.

 I'm not so sure this makes it more readable. The part that needs to be
 readable is the text strings rather than the conditionals. Multiple `if`
 were the first thing I tried but repeating `if ( $descr ) {` 20  times
 felt wrong. Also it makes the strings less readable because of the
 indentation.

 Nevertheless I'm still not happy with the readability there. Maybe we can
 try something like:
 {{{
 $descr && $content .= '<div class="wp-suggested-text">';
           $content .= '<h2>' . __( 'Who we are' ) . '</h2>';
 $descr && $content .= '<p class="privacy-policy-tutorial">' . __( 'In this
 section you should note your site URL, as well as the name of the company,
 organization, or individual behind it, and some accurate contact
 information.' ) . '</p>';
 $descr && $content .= '<p class="privacy-policy-tutorial">' . __( 'The
 amount of information you may be required to show will vary depending on
 your local or national business regulations. You may, for example, be
 required to display a physical address, a registered address, or your
 company registration number.' ) . '</p>';
           $content .= '<p>' . $suggested_text . sprintf( __( 'Our website
 address is: %s.' ), get_bloginfo( 'url', 'display' ) ) . '</p>';

           $content .= '<h2>' . __( 'What personal data we collect and why
 we collect it' ) . '</h2>';
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44051#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list