You are here

function wp_blog_requirements in WP Blog - a WordPress-style blogging module. 7

Implements hook_requirements().

File

./wp_blog.install, line 13
Install functions for the WP Blog module.

Code

function wp_blog_requirements($phase) {
  $t = get_t();

  // The blog-post URL structure works best with:
  // - pathauto enabled.
  // - the path set to /blog/YYYY/MM/DD/title
  $requirements = array();
  if ($phase == 'runtime') {
    $has_pathauto = module_exists('pathauto');
    $has_correct_path = variable_get('pathauto_node_wp_blog_pattern', '') == WP_BLOG_DEFAULT_NODE_PATH;
    if (!$has_pathauto) {
      $requirements['wp_blog'] = array(
        'title' => $t('WP Blog'),
        'description' => $t("Pathauto is recommended to provide WP Blog's recommended URL structure. Download pathauto from the <a href='@pathauto_url'>pathauto project page</a>.", array(
          '@pathauto_url' => 'http://drupal.org/project/pathauto',
        )),
        'value' => $t('Missing pathauto'),
        'severity' => REQUIREMENT_WARNING,
      );
    }
    elseif (!$has_correct_path) {
      $requirements['wp_blog'] = array(
        'title' => $t('WP Blog'),
        'description' => $t("The pattern for all WP blog post paths is not set to the recommended pattern.<br />It's currently %current_pattern and should be %recommended_pattern.  This can be changed on the <a href='@url_patterns_url'>URL aliases' patterns page</a>.", array(
          '%current_pattern' => variable_get('pathauto_node_wp_blog_pattern', $t('not set')),
          '%recommended_pattern' => $recommended_url_path,
          '@url_patterns_url' => url('admin/config/search/path/patterns'),
        )),
        'value' => $t('Incorrect URL alias pattern'),
        'severity' => REQUIREMENT_WARNING,
      );
    }
    else {
      $requirements['wp_blog'] = array(
        'title' => $t('WP Blog'),
        'description' => $t("Pathauto is enabled and the WP Blog path is correctly set."),
        'value' => $t('Configuration correct'),
        'severity' => REQUIREMENT_OK,
      );
    }
  }
  return $requirements;
}