Old version of Roots - create_function() is deprecated in Roots cleanup.php

Hello! I recently updated Wordpress to the latest version and have hit a site crashing error. I turned on wp-debug and am finding a bunch of “create_function()” is deprecated errors - specifically in the Roots cleanup.php file. Any help would be appreciated:

 * Root relative URLs
 * WordPress likes to use absolute URLs on everything - let's clean that up.
 * Inspired by http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/
 * You can enable/disable this feature in config.php:
 * current_theme_supports('root-relative-urls');
 * @author Scott Walkinshaw <scott.walkinshaw@gmail.com>
function roots_root_relative_url($input) {
  $output = preg_replace_callback(
      // If full URL is home_url("/") and this isn't a subdir install, return a slash for relative root
      'if (isset($matches[0]) && $matches[0] === home_url("/") && str_replace("http://", "", home_url("/", "http"))==$_SERVER["HTTP_HOST"]) { return "/";' .
      // If domain is equal to home_url("/"), then make URL relative
      '} elseif (isset($matches[0]) && strpos($matches[0], home_url("/")) !== false) { return $matches[2];' .
      // If domain is not equal to home_url("/"), do not make external link relative
      '} else { return $matches[0]; };'

  return $output;

What Sage version is this? Is there a CHANGELOG file?

There is no changelog file from what I can tell. I believe this is a version of the “Roots” theme before Sage existed but I could be wrong.

In this case it should be very easy to refactor this:
create_function can be replaced by function() { }
https://tomasvotruba.com/blog/2018/12/17/function-create-function-is-deprecated-in-php-72-how-to-migrate/). This theme seems to be very ancient.

As a short term solution you could simply turn off PHP notices/warnings.

As a longer term solution it may be advisable to update the theme to a newer Sage release.

1 Like

Thank you! I’ll have a look.

This topic was automatically closed after 42 days. New replies are no longer allowed.