I'm seeing an error while trying to change the colours of a theme:

Notice: Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' in
/var/www/vhosts/xxx/wp-content/themes/consulting/inc/print_styles.php on line 141

The theme creator has given me the following advice, but cannot provide any further detail:

Please contact your hosting provider team and ask to enable (set up) PHP FILE extension in your site. It will solve the problem.

I manage my server, but I have also been in contact with my hosting provider, and neither of us can figure out what needs to be done.

the closest we can find to PHP FILE is the fileinfo extension, which is already installed:

[root]# php -m | grep file

Can anyone shed any light on this?


It's really quite simple. The theme author is using a constant that you can put in wp-config.php, but because you don't use that constant, and the author never checks if it's actually defined, the code throws a PHP warning


Override of default file permissions

The FS_CHMOD_DIR and FS_CHMOD_FILE define statements allow override of default file permissions. These two variables were developed in response to the problem of the core update function failing with hosts running under suexec. If a host uses restrictive file permissions (e.g. 400) for all user files, and refuses to access files which have group or world permissions set, these definitions could solve the problem. Note that the '0755' is an octal value. Octal values must be prefixed with a 0 and are not delineated with single quotes ('). See Also: Changing File Permissions


So Who's to Blame?

The theme author for not checking if a constant is defined before using it. I've never needed this constant and i've worked on a lot of sites, and from the sounds of it neither have you.

The check is an easy thing to do:

$chmod_dir = ( 0755 & ~ umask() );
if ( defined( 'FS_CHMOD_DIR' ) ) {
    $chmod_dir = FS_CHMOD_DIR;

You use a variable, give it a default variable, then assign the constant to it if it exists.

What about this file PHP extension?

It's BS, a red herring, my guess is you've either been fobbed off, or the developer has made a guess, probably the latter. The constant is a WordPress constant, and you should never rely on all constants being defined ( they're mostly optional after all )

Is all of this above board?

Why would your theme need the chmod files and folders? This all sounds very suspicious, themes shouldn't be writing to the disk, especially on the frontend. That's how sites fail to scale or slow down.

I would cast a sceptical eye on the theme, it sounds from the file name like the theme is generating files and saving them in a subfolder, a massive no no, afterall there's a set of APIs for writing to the uploads folder, and you can generate and return a cacheable CSS file via PHP and rewrite rules ( there are security consequences too if you have a writable theme folder )

  • Thank you for your detailed answer. It all seems to make sense, and adding the two define statements to wp-config gets rid of the error, but still the colours don't change. I know this is down to the theme, but I'm struggling to get satisfactory support. Is there anything else I could check before I manually re-style everything in custom CSS? Jan 20 '17 at 11:47
  • Short of sending debug data to your theme author, and making sure that the location it's writing to is actually writable, you'll have to look at the code itself and try to see where it's going wrong. It's likely that the calls to write the files etc don't have error checking on them and are assuming everything worked which might not be the case. Push back in support and try to eliminate any permissions issues you might have on the server
    – Tom J Nowell
    Jan 20 '17 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.