0

simple-job-board Plugin throws an error on live server (on local server everything is working fine). The error occurs in template-function file. It doesn't recognize $default_path variable. Here is the error log:

Use of undefined constant DIR - assumed 'DIR' in /wp-content/plugins/simple-job-board/public/partials/simple-job-board-template-functions.php on line:

And the part of the code in which $default_path goes undefined:

// Get default template
if (!$template && $default_path !== false) {
  $default_path = $default_path ? $default_path : untrailingslashit(plugin_dir_path(dirname(__DIR__))) . '/templates/';

  if (file_exists(trailingslashit($default_path) . $template_name)) {
    $template = trailingslashit($default_path) . $template_name;
  }
}

Warning: include() [function.include]: Filename cannot be empty in /wp-content/plugins/simple-job-board/public/partials/simple-job-board-template-functions.php on line:

include( locate_simple_job_board_template($template_name, $template_path, $default_path) );

closed as off-topic by Krzysiek Dróżdż, Jacob Peattie, Fayaz, cjbj, Andy Macaulay-Brook Jul 4 '18 at 16:33

This question appears to be off-topic. The users who voted to close gave these specific reasons:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

Most probably you're using very old PHP version.

Why do I think so? Because the first warning says that __DIR__ is unrecognized. It's one of PHPs magical constants and it should contain the directory of the file.

It was introduced in PHP 5.3.0, so if such error occurs, then you have to be using older version.

And this problem causes another one... $default_path is set to DIR/templates/ instead of correct path to templates folder. So the next condition (checking if file exists) is false and the $template_name is never set...

How to fix that problem?

Upgrade your PHP version. 5.6 is the least version that is still supported (only security support).

http://php.net/supported-versions.php

  • I thought I must rollback the version of the plugin not php. It helped, thanks – Ani Naslyan Jul 1 '18 at 14:12

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