-
Notifications
You must be signed in to change notification settings - Fork 11
/
activate.php
144 lines (96 loc) · 3.52 KB
/
activate.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
global $gw_activate_template;
define( 'WP_INSTALLING', true );
$gw_activate_template = new GWActivateTemplate();
$gw_activate_template->template();
class GWActivateTemplate {
public $template_folder;
public $result;
function __construct( $args = array() ) {
/**
* @var $template_folder
*/
extract( wp_parse_args( $args, array(
'template_folder' => basename( dirname( __FILE__ ) )
) ) );
$this->template_folder = $template_folder;
$this->load_gfur_signup_functionality();
$this->hooks();
}
function load_gfur_signup_functionality() {
if( function_exists( 'gf_user_registration' ) ) {
$signups = gf_user_registration()->get_base_path() . '/includes/signups.php';
} else {
$signups = GFUser::get_base_path() . '/includes/signups.php';
}
// include GF User Registration functionality
require_once( $signups );
GFUserSignups::prep_signups_functionality();
}
function hooks() {
add_action('body_class', function( $classes ) { $classes[] = 'gfur-activate'; return $classes; } );
}
function do_activate_header() {
do_action( 'activate_wp_head' );
}
function wpmu_activate_stylesheet() {
?>
<style type="text/css">
form { margin-top: 2em; }
#submit, #key { width: 90%; font-size: 24px; }
#language { margin-top: .5em; }
.error { background: #f66; }
span.h3 { padding: 0 8px; font-size: 1.3em; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-weight: bold; color: #333; }
</style>
<?php
}
function has_activation_key() {
return ! empty( $_GET['key'] )
|| ( isset( $_GET['gfur_activation' ] ) && ! empty( $_GET['gfur_activation' ] ) )
|| ! empty( $_POST['key'] );
}
function get_activation_key() {
if ( isset( $_GET['key'] ) && $_GET['key'] ) {
return $_GET['key'];
}
if ( isset( $_GET['gfur_activation'] ) && $_GET['gfur_activation'] ) {
return $_GET['gfur_activation'];
}
if ( isset( $_POST['key'] ) && $_POST['key'] ) {
return $_POST['key'];
}
return false;
}
function is_blog_taken( $result ) {
return 'blog_taken' == $result->get_error_code();
}
function is_blog_already_active( $result ) {
return 'already_active' == $result->get_error_code();
}
function template() {
do_action( 'activate_header' );
add_action( 'wp_head', array( $this, 'do_activate_header' ) );
add_action( 'wp_head', array( $this, 'wpmu_activate_stylesheet' ) );
get_header();
?>
<div id="content" class="widecolumn">
<?php if ( !$this->has_activation_key() ) {
get_template_part( $this->template_folder . '/activate', 'no-key' );
} else {
$key = $this->get_activation_key();
$this->result = GFUserSignups::activate_signup($key);
if ( is_wp_error( $this->result ) ) {
get_template_part( $this->template_folder . '/activate', 'error' );
} else {
get_template_part( $this->template_folder . '/activate', 'success' );
}
} ?>
</div>
<script type="text/javascript">
var key_input = document.getElementById('key');
key_input && key_input.focus();
</script>
<?php
get_footer();
}
}