-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcodeigniter-wordpress-bridge.php
More file actions
41 lines (36 loc) · 1.28 KB
/
Copy pathcodeigniter-wordpress-bridge.php
File metadata and controls
41 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Plugin Name: CodeIgniter WordPress Bridge
* Description: Authenticate subscribers using a trusted CodeIgniter 3 database session.
* Version: 2.0.0
* Author: Yash Desai
* Author URI: https://github.com/yashdesai87
* Requires at least: 6.8
* Requires PHP: 7.4
*
* @author Yash Desai
*/
defined('ABSPATH') || exit;
// Configuration lives in wp-config.php; an unconfigured plugin does nothing.
if (!defined('CIWP_BRIDGE') || !is_array(CIWP_BRIDGE)
|| !isset(CIWP_BRIDGE['enabled']) || CIWP_BRIDGE['enabled'] !== true) {
return;
}
require_once __DIR__ . '/includes/SessionDecoder.php';
require_once __DIR__ . '/includes/Bridge.php';
$ciwp_bridge = new \CIWPBridge\Bridge(CIWP_BRIDGE);
add_filter('determine_current_user', array($ciwp_bridge, 'authenticate'), 30);
add_filter('rest_authentication_errors', array($ciwp_bridge, 'authenticateRest'), 99);
// This helps caches that run after plugins load. A CDN or advanced-cache.php
// must independently bypass cache whenever the configured CI cookie is present.
if ($ciwp_bridge->hasCookie()) {
if (!defined('DONOTCACHEPAGE')) {
define('DONOTCACHEPAGE', true);
}
add_action('init', static function () {
if (!headers_sent()) {
nocache_headers();
}
}, 0);
}
unset($ciwp_bridge);