public function run() { $header = file_get_contents(get_template_directory() . '/header.php'); $has_head = false; if ($header) { $header = GRAV_TESTS::remove_comments($header); } else { return array('pass' => false, 'message' => 'Your Theme seems to be missing "header.php"', 'location' => ''); } if (strpos($header, 'wp_head()') !== false || strpos($header, 'wp_head ()') !== false) { $has_head = true; } else { return array('pass' => false, 'message' => 'header.php is missing "wp_head();"', 'location' => get_template_directory() . '/header.php'); } $footer = file_get_contents(get_template_directory() . '/footer.php'); $has_footer = false; if ($footer) { $footer = GRAV_TESTS::remove_comments($footer); } else { return array('pass' => false, 'message' => 'Your Theme seems to be missing "footer.php"', 'location' => ''); } if (strpos($footer, 'wp_footer()') !== false || strpos($footer, 'wp_footer ()') !== false) { $has_footer = true; } else { return array('pass' => false, 'message' => 'footer.php is missing "wp_footer();"', 'location' => get_template_directory() . '/footer.php'); } if ($has_footer && $has_head) { return array('pass' => true, 'message' => 'Found both wp_head() and wp_footer()', 'location' => ''); } return array('pass' => false, 'message' => 'Error finding wp_head() or wp_footer()', 'location' => ''); }
public function can_fix() { if (GRAV_TESTS::is_editable()) { $path = $this->get_wp_config_path(); if ($path && wp_is_writable($path)) { if ($contents = file_get_contents($path)) { $contents = GRAV_TESTS::remove_comments($contents); if (preg_match('/define[^;]*WP_DEBUG.*(true|TRUE)[^;]*/s', $contents, $matches)) { return true; } } } } return false; }