MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: unmaintained
Description Scans every new article produced in the wiki for some given text and automatically creates a blog entry in a WordPress 'collective' blog. Works greatly in combination with the extensions WordPress Comments, and Semantic Forms or CreateBox.
Author(s) Jean-Francois Gariepy
Vinodh Rajan
Latest version 0.5 (2008-09-04)
MediaWiki 1.13.0
License GNU GPL
Download see below
Example EmuWiki.com - The Encyclopedia of Emulation
Check usage and version matrix.


Some people may have been using WordPress Comments, an extension that allows comments made in a Wordpress blog to be displayed in a Wiki page, and even allowing Wiki users to comment directly from the wiki, thus replacing the usual Talk Page system which is rather counter-intuitive for new users. The extension did a great job, but the problem for me was that I wanted not only wiki users to be able to add comments to WordPress, but I also wanted new pages created by wiki users to appear as new posts on the Word Press blog. The extension here does just that.


Can be used in combination with WordPress Comments, Semantic Forms or CreateBox and optionally DynamicPageList to produce a complete free post & comment collective blog, similar to the news system of EmuWiki.com. As of version 0.5 of the extension, it is compatible with MediaWiki 1.13 and does not need to be installed on the WordPress side anymore, it will actually break WordPress if included in the plugins panels.


1. Install Wordpress in any directory of your server. Wordpress and Mediawiki should share the same Database.

2. Copy the code in a file called WikiToWordPress.php and place that file in /extensions.

3. You will need to make 3 changes to the code:

  • Set $SearchString for whatever you want the extension to look for in an article to publish the article to the WordPress blog.
  • Set $PassFlag to 7 if you want only new articles to be published to WordPress, or to 8 if you want every edit of an article to republish another post to WordPress.

4. Include the extension in MediaWiki by changing and adding this line to your LocalSettings.php:


WikiToWordPress is now installed, and it will publish in your Wordpress blog any newly created MediaWiki article that contains a given string ($SearchString). But I strongly encourage you to install WordPress Comments, CreateBox or Semantic Forms, and optionally DynamicPageList because WikiToWordPress was designed to be used with these extensions just like we did for the news system at EmuWiki.com. Sorry for crappy code, this is my first PHP program and I'm not a programmer.



if (!defined('MEDIAWIKI')) die();

//Extension credits that show up on Special:Version
$wgExtensionCredits['other'][] = array(
        'name' => 'WikiToWordPress',
        'version' => '0.5',
        'author' => 'Jean-Francois Gariépy & Vinodh Rajan',
        'url' => 'http://www.mediawiki.org/wiki/Extension:WikiToWordPress',
        'description' => 'WikiToWordPress allows you to catch any article created in MediaWiki and publish it as a blog post on your WordPress blog.',

$wgHooks['ArticleSaveComplete'][] = 'post_a_wiki_news';

function current_time_ext($type, $gmt = 0) {
	switch ($type) {
		case 'mysql':
			if ( $gmt ) $d = gmdate('Y-m-d H:i:s');
			else $d = gmdate('Y-m-d H:i:s', (time() + (12 * 3600)));
			return $d;
		case 'timestamp':
			if ( $gmt ) $d = time();
			else $d = time() + (12 * 3600);
			return $d;

function post_a_wiki_news(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, $revision) {

global $wgOut;
global $wgDBname;

$wordPressURL = 'http://www.emuwiki.com/blog/';

if ((strpos($text,$SearchString) == 1)&&(strpos($text,'$SearchString') != 1))
if (strpos($flags,$PassFlag))

$positionOfContent = strpos($text,"|Content=")+9;
$endOfContent = strpos($text,"|Machine Category=")-1;

$newsContent = substr($text,$positionOfContent,$endOfContent-$positionOfContent);
$post_date = current_time_ext('mysql');
$post_date_gmt = current_time_ext('mysql', 1);
$post_status = 'publish';
$post_type = 'post';
$post_title = $article->getTitle();
$post_title = $post_title->getText();
$comment_status = 'open';
$ping_status = 'open';
$post_name = strtolower(str_replace(' ','-',$post_title));

$wgOut->parserOptions()->setEditSection( false );

$post_content = $wgOut->parse($newsContent);

			"INSERT INTO wp_posts
			(post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid)
			('2', '$post_date', '$post_date_gmt', '$post_content', '', '$post_title', '', '$post_status', '$post_type', '$comment_status', '$ping_status', '', '$post_name', '', '', '$post_date', '$post_date_gmt', '0', '0', '', 'http://www.emuwiki.com/blog/?p=156')");

$dbr =& wfGetDB(DB_SLAVE);
$res = $dbr->select( 'wp_posts', array('ID'), array( 'post_date' => $post_date ));
$row = $dbr->fetchObject( $res );
$ID = $row->ID;
$dbr->freeResult( $res );

$sql = 'UPDATE `'.$wgDBname.'`.`wp_posts` SET `guid` = \''.$wordPressURL.'?p='.$ID.'\' WHERE `wp_posts`.`ID` = '.$ID.' LIMIT 1;';

return true;

return true;


Related extensionsEdit