summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--plugins/wordpress/BridgeWordpress.php14
-rw-r--r--plugins/wordpress/wordpress.module20
3 files changed, 36 insertions, 1 deletions
diff --git a/README.md b/README.md
index d5c73d9..55974bf 100644
--- a/README.md
+++ b/README.md
@@ -14,9 +14,10 @@ Currently implemented bridges:
* Drupal 7.x
* Drupal 8.x (unstable)
* SMF 2.x
+* WordPress 4.4+
* Apache htpasswd
-Potential candidates for further bridges are WordPress, MediaWiki, Joomla! and Moodle.
+Potential candidates for further bridges are MediaWiki, Joomla! and Moodle.
Installation
------------
diff --git a/plugins/wordpress/BridgeWordpress.php b/plugins/wordpress/BridgeWordpress.php
new file mode 100644
index 0000000..a159523
--- /dev/null
+++ b/plugins/wordpress/BridgeWordpress.php
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * Implements EjabberdAuthBridge.
+ */
+class BridgeWordpress extends EjabberdAuthBridge {
+ function isuser($username, $server) {
+ return get_user_by('login', $username) != FALSE;
+ }
+
+ function auth($username, $server, $password) {
+ return wp_authenticate_username_password(NULL, $username, $password) instanceof WP_User;
+ }
+}
diff --git a/plugins/wordpress/wordpress.module b/plugins/wordpress/wordpress.module
new file mode 100644
index 0000000..c84db9e
--- /dev/null
+++ b/plugins/wordpress/wordpress.module
@@ -0,0 +1,20 @@
+<?php
+
+function wordpress_init($config) {
+ require_once $config['root_path'] . 'wp-load.php';
+ require_once $config['root_path'] . 'wp-includes/user.php';
+ ob_end_clean(); // Basically voodoo.
+
+ // Load the plugin.
+ require_once __DIR__ . '/BridgeWordpress.php';
+ return new BridgeWordpress();
+}
+
+function wordpress_session($config) {
+ require_once $config['root_path'] . 'wp-load.php';
+ require_once $config['root_path'] . 'wp-includes/user.php';
+
+ $id = wp_validate_logged_in_cookie(NULL);
+ if ($id) return (new WP_User($id))->user_login;
+}
+