• Hi,

    I’m very confused by the use of hard to read and “verbose” php code I find in wordpress instead of pure, simple html.
    See

    <div class="site-info">
    <?php do_action( 'twentyfourteen_credits' ); ?>
      <a href="<?php echo esc_url( __( 'https://www.ads-software.com/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>.
     Copyright ?<?php echo date( 'Y' ); ?>
    </div>

    instead of

    <div class="site-info">
     <a href="https://www.ads-software.com">Proudly powered by WordPress</a>.
     Copyright ?2015
    </div>

    And since more people know html than php, I wonder if there is a purpose for making WordPress coding so complicated. Or is it just php for php’s sake?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The PHP code within the <a> tag is so the text “Proudly powered by WordPress” can be translated into other languages. As long as your theme includes the appropriate language translation files, you can switch your site language in your Dashboard and the text will be displayed in the appropriate language. One benefit of this system is that a theme author doesn’t need to know different languages; an interested user can translate the theme and provide the appropriate language files to the author.

    The PHP code in the copyright line automatically outputs the current year. Without it, you’d have to manually update the copyright line every year. (Granted, this isn’t an extreme hardship, but every little bit helps.)

    Thread Starter Kavouras

    (@kavouras)

    Thanks for your reply.
    I would easily trade off translation-ability and changing the year once a year, for much cleaner, readable code, any day. Furthermore, aren’t all these php requests slowing down page loading?

    With all this brainstorming going on in the wp community, all the frameworks and builders and starter themes etc. I can’t believe I’m the only one who would like to see simpler code by substituting some superfluous php with html.

    Furthermore, aren’t all these php requests slowing down page loading?

    No. The sizes of the PHP files are about the last thing I would look at when determining why a particular site is loading slowly.

    I can’t believe I’m the only one who would like to see simpler code by substituting some superfluous php with html.

    The thing is, though, that PHP code isn’t superfluous at all; if a theme author wants his or her theme to be ready for localization, that code is required. You may not find localization very important, but the authors of the Twenty Fourteen theme do.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Php vs Html’ is closed to new replies.