Support » Theme: Classic » Classic Theme throwing multi-PHP undefined constant warnings

  • My hosting account got swamped by a 1GB+ xxxx.php.error.log file – too large to read; so started a new one. The new one is full of (only) the following two error messages:

    [17-Mar-2020 13:15:22 UTC] PHP Warning: Use of undefined constant ‘template_redirect’ – assumed ‘‘template_redirect’’ (this will throw an Error in a future version of PHP) in /home/account/public_html/genealogy/wp-content/themes/classic/functions.php on line 14
    [17-Mar-2020 13:15:22 UTC] PHP Warning: Use of undefined constant ‘bwp_template_redirect’ – assumed ‘‘bwp_template_redirect’’ (this will throw an Error in a future version of PHP) in /home/account/public_html/genealogy/wp-content/themes/classic/functions.php on line 14

    My hosting company tell me this is a theme issue and I should look for help there – which is where I hope I now am.

    My WordPress is up-to-date at version 5.3.2–en_GB
    The Classic theme is up-to-date
    PHP is at version 7.3

    Any ideas? Can I hack the theme?
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • there is no such code in functions.php of Classic 1.6; see https://themes.svn.wordpress.org/classic/1.6/functions.php

    did you edit the theme in any way?

    where did you download it from?

    Thread Starter df58

    (@df58)

    Thanks – I think you have found the issue!

    Many years ago I would have installed WordPress (and associated themes) from my hosting company’s Software Library. I should think since then it will all have been over-written by official up-dates (certainly Classic 1.6 is reasonably recent).

    My functions.php reads:

    <?php
    /**
     * @package WordPress
     * @subpackage Classic_Theme
     */
    
    add_theme_support( 'automatic-feed-links' );
    /** Below: lines recommended by https://www.sitepoint.com/ways-to-keep-your-wordpress-site-secure/ */
    /** 6. Hide the WordPress Version Number */
    remove_action('wp_head', 'wp_generator');
    /** 26. Remove Error Messages from Your Login Page */
    add_filter('login_errors',create_function('$a', "return null;"));
    /** 28. Hide Author Usernames */
    add_action('template_redirect', 'bwp_template_redirect');
    function bwp_template_redirect()
    {
    if (is_author())
    {
    wp_redirect( home_url() ); exit;
    }
    }
    /** Above: lines recommended by https://www.sitepoint.com/ways-to-keep-your-wordpress-site-secure/ */
    
    if ( function_exists('register_sidebar') )
    	register_sidebar(array(
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '',
    		'after_title' => '',
    	));
    
    ?>

    Pretty obviously I have got an extra bit “added in” – checking the claimed source, it looks legit (even if unexplained). The source post-dates my original installation – so it won’t be my hosting company. I don’t recall editing it; my php knowledge is at least 20 years out-of-date and I don’t like the idea of maintaining “personal changes” through update processes – seen too many burn their fingers doing that – I would rather rely on staying “vanilla” with regular official updates.

    So short term it looks as if I should restore functions.php to “vanilla as downloaded”. The question then is “do the ‘Sitepoint’ code changes look worth officially updating and maintaining?

    I need to check whether any of the other ‘Sitepoint’ code changes are in my installation.

    For future reference is the specific code issue in my OP due to php being due to becoming stricter about certain aspects of syntax?

    thanks
    David

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Classic Theme throwing multi-PHP undefined constant warnings’ is closed to new replies.