Support » Fixing WordPress » customizing /wp-content/maintenance/template.phtml

  • I see from the following that the .maintenance file in wp-content should no longer be customized.

    //  ATTENTION!
    //
    //  DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
    //  SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
    //  IF YOU REQUIRE TO APPLY CUSTOM MODIFICATIONS, PERFORM THEM IN THE FOLLOWING FILE:
    //  /home/cadre/public_html/wp-content/maintenance/template.phtml

    I’ve searched as best I can to find out how to customize /wp-content/maintenance/template.phtml but am uncertain what must be left intact of the coding (if any)

    Specifically, is the following necessary for the maintenance page to function correctly? Or will the maintenance template page work if the styles are changed in the header, and a customized message with links to alternate sites, while WP is in maintenance are the only things on the page?

        <!--START_TIMER_BLOCK-->
        <?php if (isset($timer)&& $timer['enabled'] === true): ?>
            <section class="timer">
                <div class="timer__item">
                    <div class="timer__data" id="timerResultDays"></div>
                    <div class="timer__type"><?php echo $locale['timer.days']; ?></div>
                </div>:
                <div class="timer__item">
                    <div class="timer__data" id="timerResultHours"></div>
                    <div class="timer__type"><?php echo $locale['timer.hours']; ?></div>
                </div>:
                <div class="timer__item">
                    <div class="timer__data" id="timerResultMinutes"></div>
                    <div class="timer__type"><?php echo $locale['timer.minutes']; ?></div>
                </div>:
                <div class="timer__item">
                    <div class="timer__data" id="timerResultSeconds"></div>
                    <div class="timer__type"><?php echo $locale['timer.seconds']; ?></div>
                </div>
            </section>
            <script type="application/javascript">
                startTimer(<?php echo $timer['days']; ?>, <?php echo $timer['hours']; ?>, <?php echo $timer['minutes']; ?>, <?php echo $startTime; ?>, <?php echo $timeShift; ?>);
            </script>
        <?php endif; ?>
        <!--END_TIMER_BLOCK-->
    
        <!--START_SOCIAL_LINKS_BLOCK-->
        <section class="social-links">
            <?php foreach($socialNetworks as $network => $url): ?>
                <a class="social-links__link" href="<?php echo $url;?>" target="_blank" title="<?php echo ucfirst($network);?>">
                    <span class="icon"><img src="<?php echo $assetsUrl; ?>images/<?php echo $network;?>.svg" alt="<?php echo ucfirst($network);?>"></span>
                </a>
            <?php endforeach; ?>
        </section>
        <!--END_SOCIAL_LINKS_BLOCK-->
    

    I hope this question makes sense and that someone who understands maintenance/template.phtml can point to page(s) that will explain the procedure to the general public.

    Thank you.

    -E. Morris (I know only enough about php to get myself in trouble)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator t-p

    (@t-p)

    There are many plugins to consider: https://wordpress.org/plugins/search/maintenance/

    Thread Starter ejm

    (@llizard)

    Thank you for your reply, t-p.

    Just to clarify, I am hoping NOT to use a plugin. Already, a number of the maintenance mode plugins are no longer compatible with the latest WP version. Additionally, the plugins that are compatible with the latest WP version offer their own templates or a blank template, offering blocks to modify. (I still haven’t wrapped what’s left of my mind around the block editor.)

    What I’m looking for is something that will use the theme of my WP. I have zero plans to change that theme….

    I will try in the developers’ forum to see if someone there can help.

    Thread Starter ejm

    (@llizard)

    I have now moved this question over to https://wordpress.org/support/topic/walk-through-to-customize-maintenance-page-without-a-plugin/

    I do not know how to close this thread. I am reluctant to mark this as “resolved”, because it is not.

    • This reply was modified 10 months, 2 weeks ago by ejm.
    Thread Starter ejm

    (@llizard)

    Alas, the thread I started in the Feedback section of the forum has been removed. How disappointing.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Alas, the thread I started in the Feedback section of the forum has been removed. How disappointing.

    Alas, that was archived as it was a duplicate topic and does not belong in Requests and Feedback. Please do not make duplicate topics or attempt to “move” topics. This is the right place for your topic.

    These statements may contradict each other. 😉

    (I know only enough about php to get myself in trouble)

    Good.

    Just to clarify, I am hoping NOT to use a plugin.

    Not so good. A plugin is just code and it does not do anything bad to your WordPress installation. It does often make your installation more manageable.

    The built in .maintenance is limited as it can lead to problems when users (not necessarily you, I’m just being generic) start attempting to customize it directly in code.

    What I’m looking for is something that will use the theme of my WP. I have zero plans to change that theme….

    Give this a read. I like item #2 myself.

    https://mhthemes.com/support/knb/how-put-wordpress-in-maintenance-mode/

    It’s a bit short and uses wp_die() (which is not bad but makes me twitch, my hangup) but it does have a user role check and may lead you to creating your own message while letting you admin your site.

    Thread Starter ejm

    (@llizard)

    Thank you for your reply, Jan Dembowski.

    By putting the following in my theme’s functions.php, am I correct that “get header” would cause the page to display my theme’s header?

    // Activate WordPress Maintenance Mode
    function wp_maintenance_mode() {
        if (!current_user_can('edit_themes') || !is_user_logged_in()) {
            wp_die('<h1>Under Maintenance</h1><br />Something ain't right, but we're working on it! Check back later.');
        }
    }
    add_action('get_header', 'wp_maintenance_mode');

    However, this would cause the site to show it was in Maintenance mode until the coding was removed, would it not?

    What I am trying to do is use “The maintenance function in WordPress” but avoid the display of a wp-generated splash page that is largely blank (or worse, if I used a plugin, one with someone else’s generic background image) with just a few words on it and nothing else (even if it is for a very short time) that doesn’t not look anything like the expected view of the site.

    WordPress updates shouldn’t take longer than a minute, but during that minute, your site will be replaced by this splash page [- mhthemes.com/support/knb/how-put-wordpress-in-maintenance-mode/#built-in-maintenance-mode]

    In computer time, a minute is an eon.

    I was hoping that someone might be able to explain how I could make the maintenance page show my header and footer (and perhaps modified sidebar), with the maintenance message displayed prominently on the main part of the page. It doesn’t seem like a huge thing to want….

    Until around December, we were able to do that by customizing the maintenance.php in wp-content folder.

    WP is just one aspect of my site. When WP is in maintenance, I would like to be able to offer visitors links to related parts, rather than knowing they will simply leave in impatience.

    Correct me if I’m wrong, but placing the WP php coding on a div to be inserted on a largely HTML based page would not be any more of a security risk than having the WP-generated php page would it?

    -E. Morris

    P.S. The reason I moved the question over into Feedback section was to point out that there is zero explanation of /wp-content/maintenance/template.phtml in the Codex. Or at least, if there is, it is pretty much impossible to find by searching.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘customizing /wp-content/maintenance/template.phtml’ is closed to new replies.