• 0

Why WordPress codebase is so horrible?


Question

From the user's perspective, Wordpress is hands down the best CMS out there. The UI, the menu organization, ability to toggle friendly permalinks on the fly and plethora of plugins makes it quite good.

But it's codebase is horrible. More I look at its code, all I see is sphagetti mess. I'm not sure how anyone would be ok with such a mess. Here's an example of the type of nightmare I'm talking about:

Source: https://github.com/WordPress/WordPress/blob/master/wp-activate.php

/**
 * Loads styles specific to this page.
 *
 * @since MU
 */
function wpmu_activate_stylesheet() {
    ?>
    <style type="text/css">
        form { margin-top: 2em; }
        #submit, #key { width: 90%; font-size: 24px; }
        #language { margin-top: .5em; }
        .error { background: #f66; }
        span.h3 { padding: 0 8px; font-size: 1.3em; font-weight: bold; }
    </style>
    <?php
}
add_action( 'wp_head', 'wpmu_activate_stylesheet' );
get_header( 'wp-activate' );
?>

<div id="signup-content" class="widecolumn">
    <div class="wp-activate-container">
    <?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>

        <h2><?php _e('Activation Key Required') ?></h2>
        <form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
            <p>
                <label for="key"><?php _e('Activation Key:') ?></label>
                <br /><input type="text" name="key" id="key" value="" size="50" />
            </p>
            <p class="submit">
                <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e('Activate') ?>" />
            </p>
        </form>

    <?php } else {
        $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
        $result = wpmu_activate_signup( $key );
        if ( is_wp_error($result) ) {
            if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
                $signup = $result->get_error_data();
                ?>
                <h2><?php _e('Your account is now active!'); ?></h2>
                <?php
                echo '<p class="lead-in">';
                if ( $signup->domain . $signup->path == '' ) {
                    printf( __('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, wp_lostpassword_url() );
                } else {
                    printf( __('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url() );
                }
                echo '</p>';
            } else {
                ?>
                <h2><?php _e('An error occurred during the activation'); ?></h2>
                <?php
                echo '<p>'.$result->get_error_message().'</p>';
            }
        } else {
            $url = isset( $result['blog_id'] ) ? get_blogaddress_by_id( (int) $result['blog_id'] ) : '';
            $user = get_userdata( (int) $result['user_id'] );
            ?>
            <h2><?php _e('Your account is now active!'); ?></h2>

            <div id="signup-welcome">
                <p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
                <p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p>
            </div>

            <?php if ( $url && $url != network_home_url( '', 'http' ) ) :
                switch_to_blog( (int) $result['blog_id'] ); 
                $login_url = wp_login_url(); 
                restore_current_blog(); 
                ?>
                <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) ); ?></p>
            <?php else: ?>
                <p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url('wp-login.php', 'login'), network_home_url() ); ?></p>
            <?php endif;
        }
    }
    ?>
    </div>
</div>
<script type="text/javascript">
    var key_input = document.getElementById('key');
    key_input && key_input.focus();
</script>
<?php get_footer( 'wp-activate' );

 

Whether you are making your own software or contributing to another one, wouldn't you want other's codes to be more readable and well organized?

Can you tell me why it's an acceptable practice in the Wordpress community?

11 answers to this question

Recommended Posts

  • 0

Wordpress wants to be everything for everyone every time. You can imagine how that tends to work out.

The code structure itself that you posted above isn't that bad. At least it's indented properly. Could use a LOT more comments though.

  • Like 1
  • 0

Because 80% of all Wordpress "developers" share these "qualities":

  • They have between 3 to 6 months of experience and use titles like "Senior Web Developer Developers with vast experience" (freelancing websites are full of them)
  • Concepts like MVC, OOP, separation between logic and presentation, etc. are beyond their understanding and can't understand anything more complicated than "echo 'Hello World'; "
  • Laziness...why build a proper web app or website when you can just throw in some free plugins and themes and call it a website?

 

  • 0
  On 06/11/2015 at 15:02, john_alex said:

Because 80% of all Wordpress "developers" share these "qualities":

  • They have between 3 to 6 months of experience and use titles like "Senior Web Developer Developers with vast experience" (freelancing websites are full of them)
  • Concepts like MVC, OOP, separation between logic and presentation, etc. are beyond their understanding and can't understand anything more complicated than "echo 'Hello World'; "
  • Laziness...why build a proper web app or website when you can just throw in some free plugins and themes and call it a website?

 

He is talking about the CMS code base, not a garbage site built with it.

  • 0
  On 06/11/2015 at 15:03, adrynalyne said:

He is talking about the CMS code base, not a garbage site built with it.

And that poor excuse of a codebase is not garbage?

I understand that fixing this would  require a full rewrite but they're not even trying.

  • 0
  On 06/11/2015 at 15:05, john_alex said:

And that poor excuse of a codebase is not garbage?

I understand that fixing this would  require a full rewrite but they're not even trying.

I didn't say it wasn't. However, going on about web developers with building proper web apps and just tossing in plugins for features is not what he was talking about. You two were discussing different things.

  • 0
  On 06/11/2015 at 15:07, adrynalyne said:

I didn't say it wasn't. However, going on about web developers with building proper web apps and just tossing in plugins for features is not what he was talking about. You two were discussing different things.

At the risk of sounding snarky, there is a simple economy available here - both questions actually have the same answer

Answer: It's PHP.

 

  • 0
  On 09/11/2015 at 05:08, _Alexander said:

Well ... it is definitely hard to read that considering it is a mix of frontend and backend code...

Using a function that contains frontend and backend code is not the end of the world. Visually, it's a good practice to separate the backend code from the front-end. If they at least used the heredoc syntax to separate the front-end from the backend logic or concatenate strings, etc, It would be much easier to dissect what the heck is going on.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • >Mozilla's Firefox has been left behind over time in terms of market share, as it has not been able to keep up with Chromium-based browsers in the performance department. I have no problems with Firefox's performance whatsoever. I suspect the reason Firefox is lagging in market share is that average consumers haven't heard of it and are fine with what was installed on their systems.
    • The Expanse: Osiris Reborn is a new narrative-driven sci-fi RPG inspired by Mass Effect by Pulasthi Ariyasinghe Out of nowhere, a narrative-driven sci-fi action RPG has been announced that will take players into the universe of The Expanse TV show and novels. The reveal trailer landed today during the Future Games Showcase, offering both a cinematic look at the setting as well as snippets of gameplay. Check out the The Expanse: Osiris Reborn debut trailer above. The studio behind the project is Owlcat Games. Some may remember that name from being involved in the role-playing titles Pathfinder: Kingmaker, Pathfinder: Wrath of the Righteous, as well as the most recent hugely well-received RPG Warhammer 40,000: Rogue Trader. Now, the studio's sights are set on The Expanse universe, and it's going for the over-the-shoulder third-person gameplay route for the first time. “We’ve been dreaming about building a sci-fi action RPG of this scale for a long time, and The Expanse is the perfect universe to bring that vision to life,” says Owlcat’s Creative Director, Alexander Mishulin. “It’s a world grounded in realism and complexity, perfect for telling a story the way we like it— mature and character-driven, where your choices truly matter." The story will have players taking the role of a custom captain that can be from the Earth, Mars, or the Belt to take control of the most advanced ship currently available. There's a crew to meet and lead, tactical third-person combat, and, as expected from this franchise, a divided solar system to navigate and make decisions on. The studio was also very direct about this experience being inspired by BioWare's Mass Effect trilogy. Aside from the action-heavy gameplay seen in the trailer, Owlcat is promising plenty of political intrigue, as well as romance options for players to dive into. Game Design Producer Yuliya Chernenko added "many of us first played it in our teenage years, and it left a lasting impression," and that "we are building on that legacy and expanding what players anticipate from this experience." The Expanse: Osiris Reborn does not have a release window just yet, but it will be coming out on PC (Steam, Epic Games Store, GOG), Xbox Series X|S, and PlayStation 5.
    • I don't know of anyway other than winareo tweaker to set the font type in Win11. They took that option away!   No wonder people are staying with Win10, or 7.   It's not our computer with Win11.... it's theirs!
    • It makes no sense to name it iOS 26 after iOS 18 but logic has left the building a long time ago (remember Microsoft and their Windows 8, 8.1 and 10 or Windows 7 that was actually 6.2)? Not to mention the stupid trend of "rapid releases" where minor releases with some bug fixes and UI changes (basically unnoticeable) masquerade as major releases...
    • Have you tried setting your font to Aptos? Its specifically designed to display better.
  • Recent Achievements

    • Conversation Starter
      Naomi723 earned a badge
      Conversation Starter
    • Week One Done
      abortretryfail earned a badge
      Week One Done
    • First Post
      Mr bot earned a badge
      First Post
    • First Post
      Bkl211 earned a badge
      First Post
    • One Year In
      Mido gaber earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      488
    2. 2
      +FloatingFatMan
      256
    3. 3
      snowy owl
      246
    4. 4
      ATLien_0
      222
    5. 5
      +Edouard
      191
  • Tell a friend

    Love Neowin? Tell a friend!