You are here

wordpress_migrate.module in WordPress Migrate 7.2

Same filename and directory in other branches
  1. 7 wordpress_migrate.module

API and drush commands to support migration of data from WordPress into a Drupal installation.

File

wordpress_migrate.module
View source
<?php

define('WORDPRESS_MIGRATE_ACCESS_MIGRATE', 'migrate wordpress blogs');

/**
 * @file
 * API and drush commands to support migration of data from WordPress
 * into a Drupal installation.
 */

/**
 * Implements hook_permission().
 */
function wordpress_migrate_permission() {
  return array(
    WORDPRESS_MIGRATE_ACCESS_MIGRATE => array(
      'title' => t('Migrate WordPress blogs into Drupal'),
    ),
  );
}

/**
 * Implements hook_stream_wrappers().
 */
function wordpress_migrate_stream_wrappers() {
  $wrappers = array(
    'wordpress' => array(
      'name' => t('Uploaded wordpress files'),
      'class' => 'WordpressMigrateStreamWrapper',
      'description' => t('Uploaded WordPress WXR dumps for import - not to be seen by the world.'),
      'type' => STREAM_WRAPPERS_LOCAL_HIDDEN,
    ),
  );
  return $wrappers;
}

/**
 * Implementation of hook_mail().
 *
 * @param $key
 * @param $message
 * @param $params
 */
function wordpress_migrate_mail($key, &$message, $params) {
  $data['user'] = $params['account'];
  $options['language'] = $message['language'];
  $variables = array();
  user_mail_tokens($variables, $data, $options);
  $variables['!output'] = $params['output'];
  $langcode = $message['language']->language;
  $subject = variable_get('wordpress_migrate_notification_subject', '');
  $message['subject'] = t($subject, $variables, array(
    'langcode' => $langcode,
  ));
  switch ($key) {
    case 'import_complete':
      $body = variable_get('wordpress_migrate_notification_body', '');
      break;
    case 'import_failure':
      $body = variable_get('wordpress_migrate_notification_failure_body', '');
      break;
  }
  $message['body'][] = t($body, $variables, array(
    'langcode' => $langcode,
  ));
}
function wordpress_migrate_blog_class() {
  return variable_get('wordpress_migrate_blog_class', 'WordPressBlog');
}

/**
 * @param $filename
 * @param array $arguments
 *
 * @return WordPressBlog
 */
function wordpress_migrate_blog($filename, $arguments = array()) {
  $blog_class = wordpress_migrate_blog_class();
  return new $blog_class($filename, $arguments);
}