-
Notifications
You must be signed in to change notification settings - Fork 0
/
rfg-sso-snippet.php
64 lines (54 loc) · 1.85 KB
/
rfg-sso-snippet.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
Plugin Name: RFG SSO Snippet
Plugin URI: https://www.pivotalagency.com.au/
Description: Inserts RFG Single-Sign-On (SSO) snippet into wp-login.php programmatically.
Version: 1.0.1
Author: Pivotal Agency
Author URI: https://www.pivotalagency.com.au/
Text Domain: rfg-sso-snippet
License: GPL3+
*/
// Only load class if it hasn't already been loaded
if ( !class_exists( 'RfgSsoSnippet' ) ) {
// RFG SSO Code Snippet - All the magic happens here!
class RfgSsoSnippet {
static $didInit = false;
public function __construct() {
if (!self::$didInit) {
$this->init();
self::$didInit = true;
}
}
private function init() {
// Internationalization
load_plugin_textdomain( 'rfg-sso-snippet', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
// Add Actions
add_action( 'login_enqueue_scripts', array( $this, 'admin_enqueue_scripts_styles' ) ); // Enqueue styles on relevant page
add_action( 'login_form', array( $this, 'output_snippet' ) ); // Code output
}
/**
* Adds JS/CSS to admin login screen
*/
public function admin_enqueue_scripts_styles() {
wp_register_style( 'rfg_sso_snippets_css', plugins_url( '/css/style.css', __FILE__), array(), null );
wp_enqueue_style( 'rfg_sso_snippets_css' );
}
/**
* Outputs the actual SSO snippet
*/
public function output_snippet() {
?>
<div class="sso-container">
<?php if (!empty($_GET['saml-error'])) { ?>
<p class="sso-error"><?php echo $_GET['saml-error'];?></p>
<?php } ?>
<a href="?option=saml_user_login&redirect_to=/wp-admin" class="button button-primary button-large sso-button">
RFG Login
</a>
</div>
<?php
}
}
}
new RfgSsoSnippet();