@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once dirname( dirname( __FILE__ ) ) . '/extract.php'; |
|
3 | +require_once dirname(dirname(__FILE__)).'/extract.php'; |
|
4 | 4 | |
5 | 5 | class ExtractTest extends PHPUnit_Framework_TestCase { |
6 | 6 | |
@@ -12,126 +12,126 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | function test_with_just_a_string() { |
15 | - $expected = new Translation_Entry( array( 'singular' => 'baba', 'references' => array('baba.php:1') ) ); |
|
16 | - $result = $this->extractor->extract_from_code('<?php __("baba"); ?>', 'baba.php' ); |
|
17 | - $this->assertEquals( $expected, $result->entries['baba'] ); |
|
15 | + $expected = new Translation_Entry(array('singular' => 'baba', 'references' => array('baba.php:1'))); |
|
16 | + $result = $this->extractor->extract_from_code('<?php __("baba"); ?>', 'baba.php'); |
|
17 | + $this->assertEquals($expected, $result->entries['baba']); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function test_entry_from_call_simple() { |
21 | - $entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba') ), 'baba.php' ); |
|
22 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba' ) ) ); |
|
21 | + $entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba')), 'baba.php'); |
|
22 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba'))); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | function test_entry_from_call_nonexisting_function() { |
26 | - $entry = $this->extractor->entry_from_call( array( 'name' => 'f', 'args' => array('baba') ), 'baba.php' ); |
|
27 | - $this->assertEquals( $entry, null ); |
|
26 | + $entry = $this->extractor->entry_from_call(array('name' => 'f', 'args' => array('baba')), 'baba.php'); |
|
27 | + $this->assertEquals($entry, null); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | function test_entry_from_call_too_few_args() { |
31 | - $entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array() ), 'baba.php' ); |
|
32 | - $this->assertEquals( $entry, null ); |
|
31 | + $entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array()), 'baba.php'); |
|
32 | + $this->assertEquals($entry, null); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | function test_entry_from_call_non_expected_null_arg() { |
36 | - $this->extractor->rules = array( '_nx' => array( 'singular', 'plural', 'context' ) ); |
|
37 | - $entry = $this->extractor->entry_from_call( array( 'name' => '_nx', 'args' => array('%s baba', null, 'noun') ), 'baba.php' ); |
|
38 | - $this->assertEquals( $entry, null ); |
|
36 | + $this->extractor->rules = array('_nx' => array('singular', 'plural', 'context')); |
|
37 | + $entry = $this->extractor->entry_from_call(array('name' => '_nx', 'args' => array('%s baba', null, 'noun')), 'baba.php'); |
|
38 | + $this->assertEquals($entry, null); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function test_entry_from_call_more_args_should_be_ok() { |
42 | - $this->extractor->rules = array( '__' => array('string') ); |
|
43 | - $entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba', 5, 'pijo', null) ), 'baba.php' ); |
|
44 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba' ) ) ); |
|
42 | + $this->extractor->rules = array('__' => array('string')); |
|
43 | + $entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba', 5, 'pijo', null)), 'baba.php'); |
|
44 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba'))); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | function test_entry_from_call_context() { |
49 | - $this->extractor->rules = array( '_x' => array( 'string', 'context' ) ); |
|
50 | - $entry = $this->extractor->entry_from_call( array( 'name' => '_x', 'args' => array('baba', 'noun') ), 'baba.php' ); |
|
51 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'context' => 'noun' ) ) ); |
|
49 | + $this->extractor->rules = array('_x' => array('string', 'context')); |
|
50 | + $entry = $this->extractor->entry_from_call(array('name' => '_x', 'args' => array('baba', 'noun')), 'baba.php'); |
|
51 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'context' => 'noun'))); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | function test_entry_from_call_plural() { |
55 | - $this->extractor->rules = array( '_n' => array( 'singular', 'plural' ) ); |
|
56 | - $entry = $this->extractor->entry_from_call( array( 'name' => '_n', 'args' => array('%s baba', '%s babas') ), 'baba.php' ); |
|
57 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '%s baba', 'plural' => '%s babas' ) ) ); |
|
55 | + $this->extractor->rules = array('_n' => array('singular', 'plural')); |
|
56 | + $entry = $this->extractor->entry_from_call(array('name' => '_n', 'args' => array('%s baba', '%s babas')), 'baba.php'); |
|
57 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => '%s baba', 'plural' => '%s babas'))); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function test_entry_from_call_plural_and_context() { |
61 | - $this->extractor->rules = array( '_nx' => array( 'singular', 'plural', 'context' ) ); |
|
62 | - $entry = $this->extractor->entry_from_call( array( 'name' => '_nx', 'args' => array('%s baba', '%s babas', 'noun') ), 'baba.php' ); |
|
63 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '%s baba', 'plural' => '%s babas', 'context' => 'noun' ) ) ); |
|
61 | + $this->extractor->rules = array('_nx' => array('singular', 'plural', 'context')); |
|
62 | + $entry = $this->extractor->entry_from_call(array('name' => '_nx', 'args' => array('%s baba', '%s babas', 'noun')), 'baba.php'); |
|
63 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => '%s baba', 'plural' => '%s babas', 'context' => 'noun'))); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function test_entry_from_call_extracted_comment() { |
67 | - $entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba'), 'comment' => 'translators: give me back my pants!' ), 'baba.php' ); |
|
68 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'extracted_comments' => "translators: give me back my pants!\n" ) ) ); |
|
67 | + $entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba'), 'comment' => 'translators: give me back my pants!'), 'baba.php'); |
|
68 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'extracted_comments' => "translators: give me back my pants!\n"))); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | function test_entry_from_call_line_number() { |
72 | - $entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('baba'), 'line' => 10 ), 'baba.php' ); |
|
73 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => 'baba', 'references' => array('baba.php:10') ) ) ); |
|
72 | + $entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('baba'), 'line' => 10), 'baba.php'); |
|
73 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => 'baba', 'references' => array('baba.php:10')))); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | function test_entry_from_call_zero() { |
77 | - $entry = $this->extractor->entry_from_call( array( 'name' => '__', 'args' => array('0') ), 'baba.php' ); |
|
78 | - $this->assertEquals( $entry, new Translation_Entry( array( 'singular' => '0' ) ) ); |
|
77 | + $entry = $this->extractor->entry_from_call(array('name' => '__', 'args' => array('0')), 'baba.php'); |
|
78 | + $this->assertEquals($entry, new Translation_Entry(array('singular' => '0'))); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | function test_entry_from_call_multiple() { |
82 | - $this->extractor->rules = array( 'c' => array( 'string', 'singular', 'plural' ) ); |
|
83 | - $entries = $this->extractor->entry_from_call( array( 'name' => 'c', 'args' => array('baba', 'dyado', 'dyados') ), 'baba.php' ); |
|
84 | - $this->assertEquals( array( |
|
85 | - new Translation_Entry( array( 'singular' => 'baba' ) ), new Translation_Entry( array( 'singular' => 'dyado', 'plural' => 'dyados' ) ) ), $entries ); |
|
82 | + $this->extractor->rules = array('c' => array('string', 'singular', 'plural')); |
|
83 | + $entries = $this->extractor->entry_from_call(array('name' => 'c', 'args' => array('baba', 'dyado', 'dyados')), 'baba.php'); |
|
84 | + $this->assertEquals(array( |
|
85 | + new Translation_Entry(array('singular' => 'baba')), new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados')) ), $entries); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | function test_entry_from_call_multiple_first_plural_then_two_strings() { |
89 | - $this->extractor->rules = array( 'c' => array( 'singular', 'plural', null, 'string', 'string' ) ); |
|
90 | - $entries = $this->extractor->entry_from_call( array( 'name' => 'c', 'args' => array('dyado', 'dyados', 'baba', 'foo', 'bar') ), 'baba.php' ); |
|
91 | - $this->assertEquals( array( |
|
92 | - new Translation_Entry( array( 'singular' => 'dyado', 'plural' => 'dyados' ) ), |
|
93 | - new Translation_Entry( array( 'singular' => 'foo' ) ), |
|
94 | - new Translation_Entry( array( 'singular' => 'bar' ) ) ), $entries ); |
|
89 | + $this->extractor->rules = array('c' => array('singular', 'plural', null, 'string', 'string')); |
|
90 | + $entries = $this->extractor->entry_from_call(array('name' => 'c', 'args' => array('dyado', 'dyados', 'baba', 'foo', 'bar')), 'baba.php'); |
|
91 | + $this->assertEquals(array( |
|
92 | + new Translation_Entry(array('singular' => 'dyado', 'plural' => 'dyados')), |
|
93 | + new Translation_Entry(array('singular' => 'foo')), |
|
94 | + new Translation_Entry(array('singular' => 'bar')) ), $entries); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | function test_find_function_calls_one_arg_literal() { |
98 | - $this->assertEquals( array( array( 'name' => '__', 'args' => array( 'baba' ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("baba"); ?>' ) ); |
|
98 | + $this->assertEquals(array(array('name' => '__', 'args' => array('baba'), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("baba"); ?>')); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | function test_find_function_calls_one_arg_zero() { |
102 | - $this->assertEquals( array( array( 'name' => '__', 'args' => array( '0' ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("0"); ?>' ) ); |
|
102 | + $this->assertEquals(array(array('name' => '__', 'args' => array('0'), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("0"); ?>')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | function test_find_function_calls_one_arg_non_literal() { |
106 | - $this->assertEquals( array( array( 'name' => '__', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('__'), '<?php __("baba" . "dudu"); ?>' ) ); |
|
106 | + $this->assertEquals(array(array('name' => '__', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('__'), '<?php __("baba" . "dudu"); ?>')); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | function test_find_function_calls_shouldnt_be_mistaken_by_a_class() { |
110 | - $this->assertEquals( array(), $this->extractor->find_function_calls( array('__'), '<?php class __ { }; ("dyado");' ) ); |
|
110 | + $this->assertEquals(array(), $this->extractor->find_function_calls(array('__'), '<?php class __ { }; ("dyado");')); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | function test_find_function_calls_2_args_bad_literal() { |
114 | - $this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f(5, "baba" ); ' ) ); |
|
114 | + $this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba"), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f(5, "baba" ); ')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | function test_find_function_calls_2_args_bad_literal_bad() { |
118 | - $this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba", null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f(5, "baba", 5 ); ' ) ); |
|
118 | + $this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba", null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f(5, "baba", 5 ); ')); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | function test_find_function_calls_1_arg_bad_concat() { |
122 | - $this->assertEquals( array( array( 'name' => 'f', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( "baba" . "baba" ); ' ) ); |
|
122 | + $this->assertEquals(array(array('name' => 'f', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( "baba" . "baba" ); ')); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function test_find_function_calls_1_arg_bad_function_call() { |
126 | - $this->assertEquals( array( array( 'name' => 'f', 'args' => array( null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( g( "baba" ) ); ' ) ); |
|
126 | + $this->assertEquals(array(array('name' => 'f', 'args' => array(null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( g( "baba" ) ); ')); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | function test_find_function_calls_2_arg_literal_bad() { |
130 | - $this->assertEquals( array( array( 'name' => 'f', 'args' => array( "baba", null ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( "baba", null ); ' ) ); |
|
130 | + $this->assertEquals(array(array('name' => 'f', 'args' => array("baba", null), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( "baba", null ); ')); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | function test_find_function_calls_2_arg_bad_with_parens_literal() { |
134 | - $this->assertEquals( array( array( 'name' => 'f', 'args' => array( null, "baba" ), 'line' => 1 ) ), $this->extractor->find_function_calls( array('f'), '<?php f( g( "dyado", "chicho", "lelya "), "baba" ); ' ) ); |
|
134 | + $this->assertEquals(array(array('name' => 'f', 'args' => array(null, "baba"), 'line' => 1)), $this->extractor->find_function_calls(array('f'), '<?php f( g( "dyado", "chicho", "lelya "), "baba" ); ')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function test_find_function_calls_with_comment() { |
141 | 141 | $this->assertEquals( |
142 | - array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), |
|
143 | - $this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ' ) |
|
142 | + array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')), |
|
143 | + $this->extractor->find_function_calls(array('f'), '<?php /* translators: let your ears fly! */ f( "baba" ); ') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function test_find_function_calls_with_not_immediate_comment() { |
151 | 151 | $this->assertEquals( |
152 | - array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), |
|
153 | - $this->extractor->find_function_calls( array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ' ) |
|
152 | + array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')), |
|
153 | + $this->extractor->find_function_calls(array('f'), '<?php /* translators: let your ears fly! */ $foo = g ( f( "baba" ) ); ') |
|
154 | 154 | ); |
155 | 155 | } |
156 | 156 | |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | */ |
160 | 160 | function test_find_function_calls_with_not_immediate_comment_include_only_latest() { |
161 | 161 | $this->assertEquals( |
162 | - array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'translators: let your ears fly!' ) ), |
|
163 | - $this->extractor->find_function_calls( array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ' ) |
|
162 | + array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'translators: let your ears fly!')), |
|
163 | + $this->extractor->find_function_calls(array('f'), '<?php /* translators: boo */ /* translators: let your ears fly! */ /* baba */ $foo = g ( f( "baba" ) ); ') |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @group comment |
169 | 169 | */ |
170 | 170 | function test_find_function_calls_with_multi_line_comment() { |
171 | - $this->assertEquals( array( array( |
|
172 | - 'name' => '__', 'args' => array( 'on' ), 'line' => 6, |
|
171 | + $this->assertEquals(array(array( |
|
172 | + 'name' => '__', 'args' => array('on'), 'line' => 6, |
|
173 | 173 | 'comment' => "Translators: If there are characters in your language that are not supported by Lato, translate this to 'off'. Do not translate into your own language." |
174 | - ) ), |
|
175 | - $this->extractor->find_function_calls( array( '__' ), |
|
174 | + )), |
|
175 | + $this->extractor->find_function_calls(array('__'), |
|
176 | 176 | "<?php |
177 | 177 | /* |
178 | 178 | * Translators: If there are characters in your language that are not supported |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | */ |
189 | 189 | function test_comment_prefix_should_be_case_insensitive() { |
190 | 190 | $this->assertEquals( |
191 | - array( array( 'name' => 'f', 'args' => array( 'baba' ), 'line' => 1, 'comment' => 'Translators: let your ears fly!' ) ), |
|
192 | - $this->extractor->find_function_calls( array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ' ) |
|
191 | + array(array('name' => 'f', 'args' => array('baba'), 'line' => 1, 'comment' => 'Translators: let your ears fly!')), |
|
192 | + $this->extractor->find_function_calls(array('f'), '<?php /* Translators: let your ears fly! */ f( "baba" ); ') |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | } |
@@ -1,23 +1,23 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! isset($wp_did_header)): |
|
4 | -if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { |
|
3 | +if ( ! isset($wp_did_header)): |
|
4 | +if ( ! file_exists(dirname(__FILE__).'/wp-config.php')) { |
|
5 | 5 | if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; |
6 | 6 | else $path = 'wp-admin/'; |
7 | 7 | |
8 | - require_once( dirname(__FILE__) . '/wp-includes/classes.php'); |
|
9 | - require_once( dirname(__FILE__) . '/wp-includes/functions.php'); |
|
10 | - require_once( dirname(__FILE__) . '/wp-includes/plugin.php'); |
|
11 | - wp_die( sprintf(/*WP_I18N_CONFIG*/'Translation: There doesn\'t seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href=\'http://codex.wordpress.org/Editing_wp-config.php\'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn\'t work for all server setups. The safest way is to manually create the file.</p><p><a href=\'%s\' class=\'button\'>Create a Configuration File</a>' /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ 'Translation: WordPress › Error' /*/WP_I18N_ERROR*/); |
|
8 | + require_once(dirname(__FILE__).'/wp-includes/classes.php'); |
|
9 | + require_once(dirname(__FILE__).'/wp-includes/functions.php'); |
|
10 | + require_once(dirname(__FILE__).'/wp-includes/plugin.php'); |
|
11 | + wp_die(sprintf(/*WP_I18N_CONFIG*/'Translation: There doesn\'t seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href=\'http://codex.wordpress.org/Editing_wp-config.php\'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn\'t work for all server setups. The safest way is to manually create the file.</p><p><a href=\'%s\' class=\'button\'>Create a Configuration File</a>' /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ 'Translation: WordPress › Error' /*/WP_I18N_ERROR*/); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | $wp_did_header = true; |
15 | 15 | |
16 | -require_once( dirname(__FILE__) . '/wp-config.php'); |
|
16 | +require_once(dirname(__FILE__).'/wp-config.php'); |
|
17 | 17 | |
18 | 18 | wp(); |
19 | 19 | |
20 | -require_once(ABSPATH . WPINC . '/template-loader.php'); |
|
20 | +require_once(ABSPATH.WPINC.'/template-loader.php'); |
|
21 | 21 | |
22 | 22 | endif; |
23 | 23 |
@@ -2,8 +2,11 @@ |
||
2 | 2 | |
3 | 3 | if (! isset($wp_did_header)): |
4 | 4 | if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { |
5 | - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; |
|
6 | - else $path = 'wp-admin/'; |
|
5 | + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) { |
|
6 | + $path = ''; |
|
7 | + } else { |
|
8 | + $path = 'wp-admin/'; |
|
9 | + } |
|
7 | 10 | |
8 | 11 | require_once( dirname(__FILE__) . '/wp-includes/classes.php'); |
9 | 12 | require_once( dirname(__FILE__) . '/wp-includes/functions.php'); |
@@ -1,23 +1,23 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! isset($wp_did_header)): |
|
4 | -if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { |
|
3 | +if ( ! isset($wp_did_header)): |
|
4 | +if ( ! file_exists(dirname(__FILE__).'/wp-config.php')) { |
|
5 | 5 | if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; |
6 | 6 | else $path = 'wp-admin/'; |
7 | 7 | |
8 | - require_once( dirname(__FILE__) . '/wp-includes/classes.php'); |
|
9 | - require_once( dirname(__FILE__) . '/wp-includes/functions.php'); |
|
10 | - require_once( dirname(__FILE__) . '/wp-includes/plugin.php'); |
|
11 | - wp_die( sprintf(/*WP_I18N_CONFIG*/" There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='%s' class='button'>Create a Configuration File</a>" /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ "WordPress › Error" /*/WP_I18N_ERROR*/); |
|
8 | + require_once(dirname(__FILE__).'/wp-includes/classes.php'); |
|
9 | + require_once(dirname(__FILE__).'/wp-includes/functions.php'); |
|
10 | + require_once(dirname(__FILE__).'/wp-includes/plugin.php'); |
|
11 | + wp_die(sprintf(/*WP_I18N_CONFIG*/" There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can create a <code>wp-config.php</code> file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.</p><p><a href='%s' class='button'>Create a Configuration File</a>" /*/WP_I18N_CONFIG*/, $path.'setup-config.php'), /*WP_I18N_ERROR*/ "WordPress › Error" /*/WP_I18N_ERROR*/); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | $wp_did_header = true; |
15 | 15 | |
16 | -require_once( dirname(__FILE__) . '/wp-config.php'); |
|
16 | +require_once(dirname(__FILE__).'/wp-config.php'); |
|
17 | 17 | |
18 | 18 | wp(); |
19 | 19 | |
20 | -require_once(ABSPATH . WPINC . '/template-loader.php'); |
|
20 | +require_once(ABSPATH.WPINC.'/template-loader.php'); |
|
21 | 21 | |
22 | 22 | endif; |
23 | 23 |
@@ -2,8 +2,11 @@ |
||
2 | 2 | |
3 | 3 | if (! isset($wp_did_header)): |
4 | 4 | if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { |
5 | - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; |
|
6 | - else $path = 'wp-admin/'; |
|
5 | + if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) { |
|
6 | + $path = ''; |
|
7 | + } else { |
|
8 | + $path = 'wp-admin/'; |
|
9 | + } |
|
7 | 10 | |
8 | 11 | require_once( dirname(__FILE__) . '/wp-includes/classes.php'); |
9 | 12 | require_once( dirname(__FILE__) . '/wp-includes/functions.php'); |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | * @package wordpress-i18n |
6 | 6 | * @subpackage tools |
7 | 7 | */ |
8 | -error_reporting( E_ALL ); |
|
9 | -require_once dirname( dirname( __FILE__ ) ) . '/not-gettexted.php'; |
|
8 | +error_reporting(E_ALL); |
|
9 | +require_once dirname(dirname(__FILE__)).'/not-gettexted.php'; |
|
10 | 10 | |
11 | 11 | class NotGettextedTest extends PHPUnit_Framework_TestCase { |
12 | 12 | |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | |
17 | 17 | function test_make_string_aggregator() { |
18 | 18 | global $baba; |
19 | - $f = $this->ng->make_string_aggregator( 'baba', 'baba.php' ); |
|
20 | - call_user_func( $f, 'x', 'y', 'z' ); |
|
21 | - call_user_func( $f, 'a', 'b', 'c' ); |
|
22 | - $this->assertEquals( array( array( 'x', 'y', 'baba.php', 'z'), array( 'a', 'b', 'baba.php', 'c' ) ), $baba ); |
|
19 | + $f = $this->ng->make_string_aggregator('baba', 'baba.php'); |
|
20 | + call_user_func($f, 'x', 'y', 'z'); |
|
21 | + call_user_func($f, 'a', 'b', 'c'); |
|
22 | + $this->assertEquals(array(array('x', 'y', 'baba.php', 'z'), array('a', 'b', 'baba.php', 'c')), $baba); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | function test_walk() { |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | if ($x == "18181") { wp_die(sprintf(/*WP_I18N_DIE*/\'We died %d times!\'/*WP_I18N_DIE*/)); } |
31 | 31 | ?>'; |
32 | 32 | $tokens = token_get_all($code); |
33 | - $this->assertEquals( '', $this->ng->walk_tokens( $tokens, array($this->ng, 'ignore_token'), array($this->ng, 'ignore_token') ) ); |
|
34 | - $this->assertEquals( '"yes"\'We died %d times!\'', $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'ignore_token') ) ); |
|
35 | - $this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token') ) ); |
|
36 | - $this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token') ) ); |
|
33 | + $this->assertEquals('', $this->ng->walk_tokens($tokens, array($this->ng, 'ignore_token'), array($this->ng, 'ignore_token'))); |
|
34 | + $this->assertEquals('"yes"\'We died %d times!\'', $this->ng->walk_tokens($tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'ignore_token'))); |
|
35 | + $this->assertEquals($code, $this->ng->walk_tokens($tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token'))); |
|
36 | + $this->assertEquals($code, $this->ng->walk_tokens($tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token'))); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function test_replace() { |
40 | 40 | # copy to a new file, so that we don't corrupt the old one |
41 | - copy( 'data/not-gettexted-0.php', 'data/not-gettexted-0-work.php' ); |
|
42 | - $this->ng->command_replace( 'data/not-gettexted-0.mo', 'data/not-gettexted-0-work.php' ); |
|
43 | - $this->assertEquals( file_get_contents( 'data/not-gettexted-0-result.php' ), file_get_contents( 'data/not-gettexted-0-work.php' ) ); |
|
44 | - unlink( 'data/not-gettexted-0-work.php' ); |
|
41 | + copy('data/not-gettexted-0.php', 'data/not-gettexted-0-work.php'); |
|
42 | + $this->ng->command_replace('data/not-gettexted-0.mo', 'data/not-gettexted-0-work.php'); |
|
43 | + $this->assertEquals(file_get_contents('data/not-gettexted-0-result.php'), file_get_contents('data/not-gettexted-0-work.php')); |
|
44 | + unlink('data/not-gettexted-0-work.php'); |
|
45 | 45 | } |
46 | 46 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Console application, which adds textdomain argument |
|
4 | - * to all i18n function calls |
|
5 | - * |
|
6 | - * @package wordpress-i18n |
|
7 | - */ |
|
3 | + * Console application, which adds textdomain argument |
|
4 | + * to all i18n function calls |
|
5 | + * |
|
6 | + * @package wordpress-i18n |
|
7 | + */ |
|
8 | 8 | error_reporting(E_ALL); |
9 | 9 | |
10 | 10 | require_once dirname( __FILE__ ) . '/makepot.php'; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | error_reporting(E_ALL); |
9 | 9 | |
10 | -require_once dirname( __FILE__ ) . '/makepot.php'; |
|
10 | +require_once dirname(__FILE__).'/makepot.php'; |
|
11 | 11 | |
12 | 12 | class AddTextdomain { |
13 | 13 | |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function __construct() { |
21 | 21 | $makepot = new MakePOT; |
22 | - $this->funcs = array_keys( $makepot->rules ); |
|
22 | + $this->funcs = array_keys($makepot->rules); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * PHP4 constructor. |
27 | 27 | */ |
28 | 28 | public function AddTextdomain() { |
29 | - _deprecated_constructor( 'AddTextdomain' , '4.3' ); |
|
29 | + _deprecated_constructor('AddTextdomain', '4.3'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | function usage() { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $parens_balance = 0; |
57 | 57 | $found_domain = false; |
58 | 58 | |
59 | - foreach($tokens as $token) { |
|
59 | + foreach ($tokens as $token) { |
|
60 | 60 | $string_success = false; |
61 | 61 | if (is_array($token)) { |
62 | 62 | list($id, $text) = $token; |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | $token = $text; |
74 | - } elseif ('(' == $token){ |
|
74 | + } elseif ('(' == $token) { |
|
75 | 75 | $args_started = true; |
76 | 76 | ++$parens_balance; |
77 | 77 | } elseif (')' == $token) { |
78 | 78 | --$parens_balance; |
79 | 79 | if ($in_func && 0 == $parens_balance) { |
80 | - $token = $found_domain? ')' : ", '$domain')"; |
|
80 | + $token = $found_domain ? ')' : ", '$domain')"; |
|
81 | 81 | $in_func = false; |
82 | 82 | $args_started = false; |
83 | 83 | $found_domain = false; |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | if ($included_files[0] == __FILE__) { |
102 | 102 | $adddomain = new AddTextdomain; |
103 | 103 | |
104 | - if (!isset($argv[1]) || !isset($argv[2])) { |
|
104 | + if ( ! isset($argv[1]) || ! isset($argv[2])) { |
|
105 | 105 | $adddomain->usage(); |
106 | 106 | } |
107 | 107 | |
108 | 108 | $inplace = false; |
109 | 109 | if ('-i' == $argv[1]) { |
110 | 110 | $inplace = true; |
111 | - if (!isset($argv[3])) $adddomain->usage(); |
|
111 | + if ( ! isset($argv[3])) $adddomain->usage(); |
|
112 | 112 | array_shift($argv); |
113 | 113 | } |
114 | 114 |
@@ -36,10 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | function process_token($token_text, $inplace) { |
39 | - if ($inplace) |
|
40 | - $this->modified_contents .= $token_text; |
|
41 | - else |
|
42 | - echo $token_text; |
|
39 | + if ($inplace) { |
|
40 | + $this->modified_contents .= $token_text; |
|
41 | + } else { |
|
42 | + echo $token_text; |
|
43 | + } |
|
43 | 44 | } |
44 | 45 | |
45 | 46 | |
@@ -108,7 +109,9 @@ discard block |
||
108 | 109 | $inplace = false; |
109 | 110 | if ('-i' == $argv[1]) { |
110 | 111 | $inplace = true; |
111 | - if (!isset($argv[3])) $adddomain->usage(); |
|
112 | + if (!isset($argv[3])) { |
|
113 | + $adddomain->usage(); |
|
114 | + } |
|
112 | 115 | array_shift($argv); |
113 | 116 | } |
114 | 117 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress User Page |
|
4 | - * |
|
5 | - * Handles authentication, registering, resetting passwords, forgot password, |
|
6 | - * and other user handling. |
|
7 | - * |
|
8 | - * @package WordPress |
|
9 | - */ |
|
3 | + * WordPress User Page |
|
4 | + * |
|
5 | + * Handles authentication, registering, resetting passwords, forgot password, |
|
6 | + * and other user handling. |
|
7 | + * |
|
8 | + * @package WordPress |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | /** Make sure that the WordPress bootstrap has run before continuing. */ |
12 | 12 | require( dirname(__FILE__) . '/wp-load.php' ); |
@@ -467,11 +467,11 @@ discard block |
||
467 | 467 | |
468 | 468 | switch ($action) { |
469 | 469 | |
470 | -case 'postpass' : |
|
471 | - require_once ABSPATH . WPINC . '/class-phpass.php'; |
|
472 | - $hasher = new PasswordHash( 8, true ); |
|
470 | + case 'postpass' : |
|
471 | + require_once ABSPATH . WPINC . '/class-phpass.php'; |
|
472 | + $hasher = new PasswordHash( 8, true ); |
|
473 | 473 | |
474 | - /** |
|
474 | + /** |
|
475 | 475 | * Filter the life span of the post password cookie. |
476 | 476 | * |
477 | 477 | * By default, the cookie expires 10 days from creation. To turn this |
@@ -481,28 +481,28 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @param int $expires The expiry time, as passed to setcookie(). |
483 | 483 | */ |
484 | - $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); |
|
485 | - $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
|
486 | - setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
484 | + $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); |
|
485 | + $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
|
486 | + setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
487 | 487 | |
488 | - wp_safe_redirect( wp_get_referer() ); |
|
489 | - exit(); |
|
488 | + wp_safe_redirect( wp_get_referer() ); |
|
489 | + exit(); |
|
490 | 490 | |
491 | -case 'logout' : |
|
492 | - check_admin_referer('log-out'); |
|
491 | + case 'logout' : |
|
492 | + check_admin_referer('log-out'); |
|
493 | 493 | |
494 | - $user = wp_get_current_user(); |
|
494 | + $user = wp_get_current_user(); |
|
495 | 495 | |
496 | - wp_logout(); |
|
496 | + wp_logout(); |
|
497 | 497 | |
498 | - if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
|
499 | - $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to']; |
|
500 | - } else { |
|
501 | - $redirect_to = 'wp-login.php?loggedout=true'; |
|
502 | - $requested_redirect_to = ''; |
|
503 | - } |
|
498 | + if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
|
499 | + $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to']; |
|
500 | + } else { |
|
501 | + $redirect_to = 'wp-login.php?loggedout=true'; |
|
502 | + $requested_redirect_to = ''; |
|
503 | + } |
|
504 | 504 | |
505 | - /** |
|
505 | + /** |
|
506 | 506 | * Filter the log out redirect URL. |
507 | 507 | * |
508 | 508 | * @since 4.2.0 |
@@ -511,52 +511,52 @@ discard block |
||
511 | 511 | * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
512 | 512 | * @param WP_User $user The WP_User object for the user that's logging out. |
513 | 513 | */ |
514 | - $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
515 | - wp_safe_redirect( $redirect_to ); |
|
516 | - exit(); |
|
517 | - |
|
518 | -case 'lostpassword' : |
|
519 | -case 'retrievepassword' : |
|
520 | - |
|
521 | - if ( $http_post ) { |
|
522 | - $errors = retrieve_password(); |
|
523 | - if ( !is_wp_error($errors) ) { |
|
524 | - $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
|
525 | - wp_safe_redirect( $redirect_to ); |
|
526 | - exit(); |
|
514 | + $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
515 | + wp_safe_redirect( $redirect_to ); |
|
516 | + exit(); |
|
517 | + |
|
518 | + case 'lostpassword' : |
|
519 | + case 'retrievepassword' : |
|
520 | + |
|
521 | + if ( $http_post ) { |
|
522 | + $errors = retrieve_password(); |
|
523 | + if ( !is_wp_error($errors) ) { |
|
524 | + $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
|
525 | + wp_safe_redirect( $redirect_to ); |
|
526 | + exit(); |
|
527 | + } |
|
527 | 528 | } |
528 | - } |
|
529 | 529 | |
530 | - if ( isset( $_GET['error'] ) ) { |
|
531 | - if ( 'invalidkey' == $_GET['error'] ) { |
|
532 | - $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); |
|
533 | - } elseif ( 'expiredkey' == $_GET['error'] ) { |
|
534 | - $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); |
|
530 | + if ( isset( $_GET['error'] ) ) { |
|
531 | + if ( 'invalidkey' == $_GET['error'] ) { |
|
532 | + $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); |
|
533 | + } elseif ( 'expiredkey' == $_GET['error'] ) { |
|
534 | + $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); |
|
535 | + } |
|
535 | 536 | } |
536 | - } |
|
537 | 537 | |
538 | - $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
539 | - /** |
|
538 | + $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
539 | + /** |
|
540 | 540 | * Filter the URL redirected to after submitting the lostpassword/retrievepassword form. |
541 | 541 | * |
542 | 542 | * @since 3.0.0 |
543 | 543 | * |
544 | 544 | * @param string $lostpassword_redirect The redirect destination URL. |
545 | 545 | */ |
546 | - $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); |
|
546 | + $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); |
|
547 | 547 | |
548 | - /** |
|
548 | + /** |
|
549 | 549 | * Fires before the lost password form. |
550 | 550 | * |
551 | 551 | * @since 1.5.1 |
552 | 552 | */ |
553 | - do_action( 'lost_password' ); |
|
553 | + do_action( 'lost_password' ); |
|
554 | 554 | |
555 | - login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors); |
|
555 | + login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors); |
|
556 | 556 | |
557 | - $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; |
|
557 | + $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; |
|
558 | 558 | |
559 | -?> |
|
559 | + ?> |
|
560 | 560 | |
561 | 561 | <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> |
562 | 562 | <p> |
@@ -564,68 +564,68 @@ discard block |
||
564 | 564 | <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> |
565 | 565 | </p> |
566 | 566 | <?php |
567 | - /** |
|
567 | + /** |
|
568 | 568 | * Fires inside the lostpassword form tags, before the hidden fields. |
569 | 569 | * |
570 | 570 | * @since 2.1.0 |
571 | 571 | */ |
572 | - do_action( 'lostpassword_form' ); ?> |
|
573 | - <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
572 | + do_action( 'lostpassword_form' ); ?> |
|
573 | + <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
574 | 574 | <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Get New Password'); ?>" /></p> |
575 | 575 | </form> |
576 | 576 | |
577 | 577 | <p id="nav"> |
578 | 578 | <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> |
579 | -<?php |
|
580 | -if ( get_option( 'users_can_register' ) ) : |
|
581 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
579 | + <?php |
|
580 | + if ( get_option( 'users_can_register' ) ) : |
|
581 | + $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
582 | 582 | |
583 | - /** This filter is documented in wp-includes/general-template.php */ |
|
584 | - echo ' | ' . apply_filters( 'register', $registration_url ); |
|
585 | -endif; |
|
586 | -?> |
|
587 | -</p> |
|
583 | + /** This filter is documented in wp-includes/general-template.php */ |
|
584 | + echo ' | ' . apply_filters( 'register', $registration_url ); |
|
585 | + endif; |
|
586 | + ?> |
|
587 | + </p> |
|
588 | 588 | |
589 | -<?php |
|
590 | -login_footer('user_login'); |
|
591 | -break; |
|
592 | - |
|
593 | -case 'resetpass' : |
|
594 | -case 'rp' : |
|
595 | - list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
596 | - $rp_cookie = 'wp-resetpass-' . COOKIEHASH; |
|
597 | - if ( isset( $_GET['key'] ) ) { |
|
598 | - $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); |
|
599 | - setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
600 | - wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); |
|
601 | - exit; |
|
602 | - } |
|
589 | + <?php |
|
590 | + login_footer('user_login'); |
|
591 | + break; |
|
592 | + |
|
593 | + case 'resetpass' : |
|
594 | + case 'rp' : |
|
595 | + list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
596 | + $rp_cookie = 'wp-resetpass-' . COOKIEHASH; |
|
597 | + if ( isset( $_GET['key'] ) ) { |
|
598 | + $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); |
|
599 | + setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
600 | + wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); |
|
601 | + exit; |
|
602 | + } |
|
603 | 603 | |
604 | - if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { |
|
605 | - list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); |
|
606 | - $user = check_password_reset_key( $rp_key, $rp_login ); |
|
607 | - if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { |
|
604 | + if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { |
|
605 | + list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); |
|
606 | + $user = check_password_reset_key( $rp_key, $rp_login ); |
|
607 | + if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { |
|
608 | + $user = false; |
|
609 | + } |
|
610 | + } else { |
|
608 | 611 | $user = false; |
609 | 612 | } |
610 | - } else { |
|
611 | - $user = false; |
|
612 | - } |
|
613 | 613 | |
614 | - if ( ! $user || is_wp_error( $user ) ) { |
|
615 | - setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
616 | - if ( $user && $user->get_error_code() === 'expired_key' ) |
|
617 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
618 | - else |
|
619 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
620 | - exit; |
|
621 | - } |
|
614 | + if ( ! $user || is_wp_error( $user ) ) { |
|
615 | + setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
616 | + if ( $user && $user->get_error_code() === 'expired_key' ) |
|
617 | + wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
618 | + else |
|
619 | + wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
620 | + exit; |
|
621 | + } |
|
622 | 622 | |
623 | - $errors = new WP_Error(); |
|
623 | + $errors = new WP_Error(); |
|
624 | 624 | |
625 | - if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) |
|
626 | - $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
625 | + if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) |
|
626 | + $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
627 | 627 | |
628 | - /** |
|
628 | + /** |
|
629 | 629 | * Fires before the password reset procedure is validated. |
630 | 630 | * |
631 | 631 | * @since 3.5.0 |
@@ -633,23 +633,23 @@ discard block |
||
633 | 633 | * @param object $errors WP Error object. |
634 | 634 | * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. |
635 | 635 | */ |
636 | - do_action( 'validate_password_reset', $errors, $user ); |
|
637 | - |
|
638 | - if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { |
|
639 | - reset_password($user, $_POST['pass1']); |
|
640 | - setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
641 | - login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); |
|
642 | - login_footer(); |
|
643 | - exit; |
|
644 | - } |
|
636 | + do_action( 'validate_password_reset', $errors, $user ); |
|
637 | + |
|
638 | + if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { |
|
639 | + reset_password($user, $_POST['pass1']); |
|
640 | + setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
641 | + login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); |
|
642 | + login_footer(); |
|
643 | + exit; |
|
644 | + } |
|
645 | 645 | |
646 | - wp_enqueue_script('utils'); |
|
647 | - wp_enqueue_script('user-profile'); |
|
646 | + wp_enqueue_script('utils'); |
|
647 | + wp_enqueue_script('user-profile'); |
|
648 | 648 | |
649 | - login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors ); |
|
649 | + login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors ); |
|
650 | 650 | |
651 | -?> |
|
652 | -<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
|
651 | + ?> |
|
652 | + <form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
|
653 | 653 | <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> |
654 | 654 | |
655 | 655 | <p class="user-pass1-wrap"> |
@@ -670,77 +670,77 @@ discard block |
||
670 | 670 | <br class="clear" /> |
671 | 671 | |
672 | 672 | <?php |
673 | - /** |
|
673 | + /** |
|
674 | 674 | * Fires following the 'Strength indicator' meter in the user password reset form. |
675 | 675 | * |
676 | 676 | * @since 3.9.0 |
677 | 677 | * |
678 | 678 | * @param WP_User $user User object of the user whose password is being reset. |
679 | 679 | */ |
680 | - do_action( 'resetpass_form', $user ); |
|
681 | - ?> |
|
682 | - <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
|
680 | + do_action( 'resetpass_form', $user ); |
|
681 | + ?> |
|
682 | + <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
|
683 | 683 | <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p> |
684 | 684 | </form> |
685 | 685 | |
686 | 686 | <p id="nav"> |
687 | 687 | <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
688 | -<?php |
|
689 | -if ( get_option( 'users_can_register' ) ) : |
|
690 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
688 | + <?php |
|
689 | + if ( get_option( 'users_can_register' ) ) : |
|
690 | + $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
691 | 691 | |
692 | - /** This filter is documented in wp-includes/general-template.php */ |
|
693 | - echo ' | ' . apply_filters( 'register', $registration_url ); |
|
694 | -endif; |
|
695 | -?> |
|
696 | -</p> |
|
692 | + /** This filter is documented in wp-includes/general-template.php */ |
|
693 | + echo ' | ' . apply_filters( 'register', $registration_url ); |
|
694 | + endif; |
|
695 | + ?> |
|
696 | + </p> |
|
697 | 697 | |
698 | -<?php |
|
699 | -login_footer('user_pass'); |
|
700 | -break; |
|
698 | + <?php |
|
699 | + login_footer('user_pass'); |
|
700 | + break; |
|
701 | 701 | |
702 | -case 'register' : |
|
703 | - if ( is_multisite() ) { |
|
704 | - /** |
|
702 | + case 'register' : |
|
703 | + if ( is_multisite() ) { |
|
704 | + /** |
|
705 | 705 | * Filter the Multisite sign up URL. |
706 | 706 | * |
707 | 707 | * @since 3.0.0 |
708 | 708 | * |
709 | 709 | * @param string $sign_up_url The sign up URL. |
710 | 710 | */ |
711 | - wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); |
|
712 | - exit; |
|
713 | - } |
|
714 | - |
|
715 | - if ( !get_option('users_can_register') ) { |
|
716 | - wp_redirect( site_url('wp-login.php?registration=disabled') ); |
|
717 | - exit(); |
|
718 | - } |
|
711 | + wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); |
|
712 | + exit; |
|
713 | + } |
|
719 | 714 | |
720 | - $user_login = ''; |
|
721 | - $user_email = ''; |
|
722 | - if ( $http_post ) { |
|
723 | - $user_login = $_POST['user_login']; |
|
724 | - $user_email = $_POST['user_email']; |
|
725 | - $errors = register_new_user($user_login, $user_email); |
|
726 | - if ( !is_wp_error($errors) ) { |
|
727 | - $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
728 | - wp_safe_redirect( $redirect_to ); |
|
715 | + if ( !get_option('users_can_register') ) { |
|
716 | + wp_redirect( site_url('wp-login.php?registration=disabled') ); |
|
729 | 717 | exit(); |
730 | 718 | } |
731 | - } |
|
732 | 719 | |
733 | - $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
734 | - /** |
|
720 | + $user_login = ''; |
|
721 | + $user_email = ''; |
|
722 | + if ( $http_post ) { |
|
723 | + $user_login = $_POST['user_login']; |
|
724 | + $user_email = $_POST['user_email']; |
|
725 | + $errors = register_new_user($user_login, $user_email); |
|
726 | + if ( !is_wp_error($errors) ) { |
|
727 | + $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
728 | + wp_safe_redirect( $redirect_to ); |
|
729 | + exit(); |
|
730 | + } |
|
731 | + } |
|
732 | + |
|
733 | + $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
734 | + /** |
|
735 | 735 | * Filter the registration redirect URL. |
736 | 736 | * |
737 | 737 | * @since 3.0.0 |
738 | 738 | * |
739 | 739 | * @param string $registration_redirect The redirect destination URL. |
740 | 740 | */ |
741 | - $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); |
|
742 | - login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); |
|
743 | -?> |
|
741 | + $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); |
|
742 | + login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); |
|
743 | + ?> |
|
744 | 744 | |
745 | 745 | <form name="registerform" id="registerform" action="<?php echo esc_url( site_url('wp-login.php?action=register', 'login_post') ); ?>" method="post" novalidate="novalidate"> |
746 | 746 | <p> |
@@ -752,14 +752,14 @@ discard block |
||
752 | 752 | <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label> |
753 | 753 | </p> |
754 | 754 | <?php |
755 | - /** |
|
755 | + /** |
|
756 | 756 | * Fires following the 'E-mail' field in the user registration form. |
757 | 757 | * |
758 | 758 | * @since 2.1.0 |
759 | 759 | */ |
760 | - do_action( 'register_form' ); |
|
761 | - ?> |
|
762 | - <p id="reg_passmail"><?php _e( 'Registration confirmation will be e-mailed to you.' ); ?></p> |
|
760 | + do_action( 'register_form' ); |
|
761 | + ?> |
|
762 | + <p id="reg_passmail"><?php _e( 'Registration confirmation will be e-mailed to you.' ); ?></p> |
|
763 | 763 | <br class="clear" /> |
764 | 764 | <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
765 | 765 | <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Register'); ?>" /></p> |
@@ -771,53 +771,53 @@ discard block |
||
771 | 771 | </p> |
772 | 772 | |
773 | 773 | <?php |
774 | -login_footer('user_login'); |
|
775 | -break; |
|
776 | - |
|
777 | -case 'login' : |
|
778 | -default: |
|
779 | - $secure_cookie = ''; |
|
780 | - $customize_login = isset( $_REQUEST['customize-login'] ); |
|
781 | - if ( $customize_login ) |
|
782 | - wp_enqueue_script( 'customize-base' ); |
|
783 | - |
|
784 | - // If the user wants ssl but the session is not ssl, force a secure cookie. |
|
785 | - if ( !empty($_POST['log']) && !force_ssl_admin() ) { |
|
786 | - $user_name = sanitize_user($_POST['log']); |
|
787 | - if ( $user = get_user_by('login', $user_name) ) { |
|
788 | - if ( get_user_option('use_ssl', $user->ID) ) { |
|
789 | - $secure_cookie = true; |
|
790 | - force_ssl_admin(true); |
|
774 | + login_footer('user_login'); |
|
775 | + break; |
|
776 | + |
|
777 | + case 'login' : |
|
778 | + default: |
|
779 | + $secure_cookie = ''; |
|
780 | + $customize_login = isset( $_REQUEST['customize-login'] ); |
|
781 | + if ( $customize_login ) |
|
782 | + wp_enqueue_script( 'customize-base' ); |
|
783 | + |
|
784 | + // If the user wants ssl but the session is not ssl, force a secure cookie. |
|
785 | + if ( !empty($_POST['log']) && !force_ssl_admin() ) { |
|
786 | + $user_name = sanitize_user($_POST['log']); |
|
787 | + if ( $user = get_user_by('login', $user_name) ) { |
|
788 | + if ( get_user_option('use_ssl', $user->ID) ) { |
|
789 | + $secure_cookie = true; |
|
790 | + force_ssl_admin(true); |
|
791 | + } |
|
791 | 792 | } |
792 | 793 | } |
793 | - } |
|
794 | 794 | |
795 | - if ( isset( $_REQUEST['redirect_to'] ) ) { |
|
796 | - $redirect_to = $_REQUEST['redirect_to']; |
|
797 | - // Redirect to https if user wants ssl |
|
798 | - if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) |
|
799 | - $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
800 | - } else { |
|
801 | - $redirect_to = admin_url(); |
|
802 | - } |
|
795 | + if ( isset( $_REQUEST['redirect_to'] ) ) { |
|
796 | + $redirect_to = $_REQUEST['redirect_to']; |
|
797 | + // Redirect to https if user wants ssl |
|
798 | + if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) |
|
799 | + $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
800 | + } else { |
|
801 | + $redirect_to = admin_url(); |
|
802 | + } |
|
803 | 803 | |
804 | - $reauth = empty($_REQUEST['reauth']) ? false : true; |
|
804 | + $reauth = empty($_REQUEST['reauth']) ? false : true; |
|
805 | 805 | |
806 | - $user = wp_signon( '', $secure_cookie ); |
|
806 | + $user = wp_signon( '', $secure_cookie ); |
|
807 | 807 | |
808 | - if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { |
|
809 | - if ( headers_sent() ) { |
|
810 | - $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), |
|
811 | - __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) ); |
|
812 | - } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { |
|
813 | - // If cookies are disabled we can't log in even with a valid user+pass |
|
814 | - $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), |
|
815 | - __( 'https://codex.wordpress.org/Cookies' ) ) ); |
|
808 | + if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { |
|
809 | + if ( headers_sent() ) { |
|
810 | + $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), |
|
811 | + __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) ); |
|
812 | + } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { |
|
813 | + // If cookies are disabled we can't log in even with a valid user+pass |
|
814 | + $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), |
|
815 | + __( 'https://codex.wordpress.org/Cookies' ) ) ); |
|
816 | + } |
|
816 | 817 | } |
817 | - } |
|
818 | 818 | |
819 | - $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
820 | - /** |
|
819 | + $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
820 | + /** |
|
821 | 821 | * Filter the login redirect URL. |
822 | 822 | * |
823 | 823 | * @since 3.0.0 |
@@ -826,62 +826,62 @@ discard block |
||
826 | 826 | * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
827 | 827 | * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
828 | 828 | */ |
829 | - $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
830 | - |
|
831 | - if ( !is_wp_error($user) && !$reauth ) { |
|
832 | - if ( $interim_login ) { |
|
833 | - $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; |
|
834 | - $interim_login = 'success'; |
|
835 | - login_header( '', $message ); ?> |
|
836 | - </div> |
|
829 | + $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
830 | + |
|
831 | + if ( !is_wp_error($user) && !$reauth ) { |
|
832 | + if ( $interim_login ) { |
|
833 | + $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; |
|
834 | + $interim_login = 'success'; |
|
835 | + login_header( '', $message ); ?> |
|
836 | + </div> |
|
837 | 837 | <?php |
838 | - /** This action is documented in wp-login.php */ |
|
839 | - do_action( 'login_footer' ); ?> |
|
840 | - <?php if ( $customize_login ) : ?> |
|
841 | - <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> |
|
838 | + /** This action is documented in wp-login.php */ |
|
839 | + do_action( 'login_footer' ); ?> |
|
840 | + <?php if ( $customize_login ) : ?> |
|
841 | + <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> |
|
842 | 842 | <?php endif; ?> |
843 | - </body></html> |
|
844 | -<?php exit; |
|
845 | - } |
|
843 | + </body></html> |
|
844 | + <?php exit; |
|
845 | + } |
|
846 | 846 | |
847 | - if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
|
848 | - // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
|
849 | - if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) |
|
850 | - $redirect_to = user_admin_url(); |
|
851 | - elseif ( is_multisite() && !$user->has_cap('read') ) |
|
852 | - $redirect_to = get_dashboard_url( $user->ID ); |
|
853 | - elseif ( !$user->has_cap('edit_posts') ) |
|
854 | - $redirect_to = admin_url('profile.php'); |
|
847 | + if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
|
848 | + // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
|
849 | + if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) |
|
850 | + $redirect_to = user_admin_url(); |
|
851 | + elseif ( is_multisite() && !$user->has_cap('read') ) |
|
852 | + $redirect_to = get_dashboard_url( $user->ID ); |
|
853 | + elseif ( !$user->has_cap('edit_posts') ) |
|
854 | + $redirect_to = admin_url('profile.php'); |
|
855 | + } |
|
856 | + wp_safe_redirect($redirect_to); |
|
857 | + exit(); |
|
855 | 858 | } |
856 | - wp_safe_redirect($redirect_to); |
|
857 | - exit(); |
|
858 | - } |
|
859 | 859 | |
860 | - $errors = $user; |
|
861 | - // Clear errors if loggedout is set. |
|
862 | - if ( !empty($_GET['loggedout']) || $reauth ) |
|
863 | - $errors = new WP_Error(); |
|
860 | + $errors = $user; |
|
861 | + // Clear errors if loggedout is set. |
|
862 | + if ( !empty($_GET['loggedout']) || $reauth ) |
|
863 | + $errors = new WP_Error(); |
|
864 | 864 | |
865 | - if ( $interim_login ) { |
|
866 | - if ( ! $errors->get_error_code() ) |
|
867 | - $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
|
868 | - } else { |
|
869 | - // Some parts of this script use the main login form to display a message |
|
870 | - if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) |
|
871 | - $errors->add('loggedout', __('You are now logged out.'), 'message'); |
|
872 | - elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
|
873 | - $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
|
874 | - elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
|
875 | - $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
876 | - elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
|
877 | - $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
878 | - elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
|
879 | - $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
880 | - elseif ( strpos( $redirect_to, 'about.php?updated' ) ) |
|
881 | - $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
882 | - } |
|
865 | + if ( $interim_login ) { |
|
866 | + if ( ! $errors->get_error_code() ) |
|
867 | + $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
|
868 | + } else { |
|
869 | + // Some parts of this script use the main login form to display a message |
|
870 | + if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) |
|
871 | + $errors->add('loggedout', __('You are now logged out.'), 'message'); |
|
872 | + elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
|
873 | + $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
|
874 | + elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
|
875 | + $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
876 | + elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
|
877 | + $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
878 | + elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
|
879 | + $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
880 | + elseif ( strpos( $redirect_to, 'about.php?updated' ) ) |
|
881 | + $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
882 | + } |
|
883 | 883 | |
884 | - /** |
|
884 | + /** |
|
885 | 885 | * Filter the login page errors. |
886 | 886 | * |
887 | 887 | * @since 3.6.0 |
@@ -889,24 +889,24 @@ discard block |
||
889 | 889 | * @param object $errors WP Error object. |
890 | 890 | * @param string $redirect_to Redirect destination URL. |
891 | 891 | */ |
892 | - $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
|
892 | + $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
|
893 | 893 | |
894 | - // Clear any stale cookies. |
|
895 | - if ( $reauth ) |
|
896 | - wp_clear_auth_cookie(); |
|
894 | + // Clear any stale cookies. |
|
895 | + if ( $reauth ) |
|
896 | + wp_clear_auth_cookie(); |
|
897 | 897 | |
898 | - login_header(__('Log In'), '', $errors); |
|
898 | + login_header(__('Log In'), '', $errors); |
|
899 | 899 | |
900 | - if ( isset($_POST['log']) ) |
|
901 | - $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
902 | - $rememberme = ! empty( $_POST['rememberme'] ); |
|
900 | + if ( isset($_POST['log']) ) |
|
901 | + $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
902 | + $rememberme = ! empty( $_POST['rememberme'] ); |
|
903 | 903 | |
904 | - if ( ! empty( $errors->errors ) ) { |
|
905 | - $aria_describedby_error = ' aria-describedby="login_error"'; |
|
906 | - } else { |
|
907 | - $aria_describedby_error = ''; |
|
908 | - } |
|
909 | -?> |
|
904 | + if ( ! empty( $errors->errors ) ) { |
|
905 | + $aria_describedby_error = ' aria-describedby="login_error"'; |
|
906 | + } else { |
|
907 | + $aria_describedby_error = ''; |
|
908 | + } |
|
909 | + ?> |
|
910 | 910 | |
911 | 911 | <form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> |
912 | 912 | <p> |
@@ -918,42 +918,42 @@ discard block |
||
918 | 918 | <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label> |
919 | 919 | </p> |
920 | 920 | <?php |
921 | - /** |
|
921 | + /** |
|
922 | 922 | * Fires following the 'Password' field in the login form. |
923 | 923 | * |
924 | 924 | * @since 2.1.0 |
925 | 925 | */ |
926 | - do_action( 'login_form' ); |
|
927 | - ?> |
|
928 | - <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_attr_e('Remember Me'); ?></label></p> |
|
926 | + do_action( 'login_form' ); |
|
927 | + ?> |
|
928 | + <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_attr_e('Remember Me'); ?></label></p> |
|
929 | 929 | <p class="submit"> |
930 | 930 | <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> |
931 | -<?php if ( $interim_login ) { ?> |
|
932 | - <input type="hidden" name="interim-login" value="1" /> |
|
933 | -<?php } else { ?> |
|
934 | - <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
|
935 | -<?php } ?> |
|
936 | -<?php if ( $customize_login ) : ?> |
|
937 | - <input type="hidden" name="customize-login" value="1" /> |
|
938 | -<?php endif; ?> |
|
931 | + <?php if ( $interim_login ) { ?> |
|
932 | + <input type="hidden" name="interim-login" value="1" /> |
|
933 | + <?php } else { ?> |
|
934 | + <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
|
935 | + <?php } ?> |
|
936 | + <?php if ( $customize_login ) : ?> |
|
937 | + <input type="hidden" name="customize-login" value="1" /> |
|
938 | + <?php endif; ?> |
|
939 | 939 | <input type="hidden" name="testcookie" value="1" /> |
940 | 940 | </p> |
941 | 941 | </form> |
942 | 942 | |
943 | 943 | <?php if ( ! $interim_login ) { ?> |
944 | -<p id="nav"> |
|
945 | -<?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : |
|
946 | - if ( get_option( 'users_can_register' ) ) : |
|
947 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
948 | - |
|
949 | - /** This filter is documented in wp-includes/general-template.php */ |
|
950 | - echo apply_filters( 'register', $registration_url ) . ' | '; |
|
951 | - endif; |
|
952 | - ?> |
|
953 | - <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
|
954 | -<?php endif; ?> |
|
955 | -</p> |
|
956 | -<?php } ?> |
|
944 | + <p id="nav"> |
|
945 | + <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : |
|
946 | + if ( get_option( 'users_can_register' ) ) : |
|
947 | + $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
948 | + |
|
949 | + /** This filter is documented in wp-includes/general-template.php */ |
|
950 | + echo apply_filters( 'register', $registration_url ) . ' | '; |
|
951 | + endif; |
|
952 | + ?> |
|
953 | + <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
|
954 | + <?php endif; ?> |
|
955 | + </p> |
|
956 | + <?php } ?> |
|
957 | 957 | |
958 | 958 | <script type="text/javascript"> |
959 | 959 | function wp_attempt_focus(){ |
@@ -962,8 +962,8 @@ discard block |
||
962 | 962 | d = document.getElementById('user_pass'); |
963 | 963 | d.value = ''; |
964 | 964 | <?php } else { ?> |
965 | -d = document.getElementById('user_login'); |
|
966 | -<?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> |
|
965 | + d = document.getElementById('user_login'); |
|
966 | + <?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> |
|
967 | 967 | if( d.value != '' ) |
968 | 968 | d.value = ''; |
969 | 969 | <?php |
@@ -976,10 +976,10 @@ discard block |
||
976 | 976 | } |
977 | 977 | |
978 | 978 | <?php if ( !$error ) { ?> |
979 | -wp_attempt_focus(); |
|
980 | -<?php } ?> |
|
981 | -if(typeof wpOnload=='function')wpOnload(); |
|
982 | -<?php if ( $interim_login ) { ?> |
|
979 | + wp_attempt_focus(); |
|
980 | + <?php } ?> |
|
981 | + if(typeof wpOnload=='function')wpOnload(); |
|
982 | + <?php if ( $interim_login ) { ?> |
|
983 | 983 | (function(){ |
984 | 984 | try { |
985 | 985 | var i, links = document.getElementsByTagName('a'); |
@@ -990,9 +990,9 @@ discard block |
||
990 | 990 | } catch(e){} |
991 | 991 | }()); |
992 | 992 | <?php } ?> |
993 | -</script> |
|
993 | + </script> |
|
994 | 994 | |
995 | -<?php |
|
996 | -login_footer(); |
|
997 | -break; |
|
995 | + <?php |
|
996 | + login_footer(); |
|
997 | + break; |
|
998 | 998 | } // end action switch |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | /** Make sure that the WordPress bootstrap has run before continuing. */ |
12 | -require( dirname(__FILE__) . '/wp-load.php' ); |
|
12 | +require(dirname(__FILE__).'/wp-load.php'); |
|
13 | 13 | |
14 | 14 | // Redirect to https login if forced to use SSL |
15 | -if ( force_ssl_admin() && ! is_ssl() ) { |
|
16 | - if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { |
|
17 | - wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); |
|
15 | +if (force_ssl_admin() && ! is_ssl()) { |
|
16 | + if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) { |
|
17 | + wp_redirect(set_url_scheme($_SERVER['REQUEST_URI'], 'https')); |
|
18 | 18 | exit(); |
19 | 19 | } else { |
20 | - wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
20 | + wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
21 | 21 | exit(); |
22 | 22 | } |
23 | 23 | } |
@@ -30,20 +30,20 @@ discard block |
||
30 | 30 | * @param string $message Optional. Message to display in header. Default empty. |
31 | 31 | * @param WP_Error $wp_error Optional. The error to pass. Default empty. |
32 | 32 | */ |
33 | -function login_header( $title = 'Log In', $message = '', $wp_error = '' ) { |
|
33 | +function login_header($title = 'Log In', $message = '', $wp_error = '') { |
|
34 | 34 | global $error, $interim_login, $action; |
35 | 35 | |
36 | 36 | // Don't index any of these forms |
37 | - add_action( 'login_head', 'wp_no_robots' ); |
|
37 | + add_action('login_head', 'wp_no_robots'); |
|
38 | 38 | |
39 | - if ( wp_is_mobile() ) |
|
40 | - add_action( 'login_head', 'wp_login_viewport_meta' ); |
|
39 | + if (wp_is_mobile()) |
|
40 | + add_action('login_head', 'wp_login_viewport_meta'); |
|
41 | 41 | |
42 | - if ( empty($wp_error) ) |
|
42 | + if (empty($wp_error)) |
|
43 | 43 | $wp_error = new WP_Error(); |
44 | 44 | |
45 | 45 | // Shake it! |
46 | - $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); |
|
46 | + $shake_error_codes = array('empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password'); |
|
47 | 47 | /** |
48 | 48 | * Filter the error codes array for shaking the login form. |
49 | 49 | * |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param array $shake_error_codes Error codes that shake the login form. |
53 | 53 | */ |
54 | - $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); |
|
54 | + $shake_error_codes = apply_filters('shake_error_codes', $shake_error_codes); |
|
55 | 55 | |
56 | - if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) |
|
57 | - add_action( 'login_head', 'wp_shake_js', 12 ); |
|
56 | + if ($shake_error_codes && $wp_error->get_error_code() && in_array($wp_error->get_error_code(), $shake_error_codes)) |
|
57 | + add_action('login_head', 'wp_shake_js', 12); |
|
58 | 58 | |
59 | 59 | ?><!DOCTYPE html> |
60 | 60 | <!--[if IE 8]> |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | <title><?php bloginfo('name'); ?> › <?php echo $title; ?></title> |
69 | 69 | <?php |
70 | 70 | |
71 | - wp_admin_css( 'login', true ); |
|
71 | + wp_admin_css('login', true); |
|
72 | 72 | |
73 | 73 | /* |
74 | 74 | * Remove all stored post data on logging out. |
75 | 75 | * This could be added by add_action('login_head'...) like wp_shake_js(), |
76 | 76 | * but maybe better if it's not removable by plugins |
77 | 77 | */ |
78 | - if ( 'loggedout' == $wp_error->get_error_code() ) { |
|
78 | + if ('loggedout' == $wp_error->get_error_code()) { |
|
79 | 79 | ?> |
80 | 80 | <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script> |
81 | 81 | <?php |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @since 3.1.0 |
88 | 88 | */ |
89 | - do_action( 'login_enqueue_scripts' ); |
|
89 | + do_action('login_enqueue_scripts'); |
|
90 | 90 | /** |
91 | 91 | * Fires in the login page header after scripts are enqueued. |
92 | 92 | * |
93 | 93 | * @since 2.1.0 |
94 | 94 | */ |
95 | - do_action( 'login_head' ); |
|
95 | + do_action('login_head'); |
|
96 | 96 | |
97 | - if ( is_multisite() ) { |
|
97 | + if (is_multisite()) { |
|
98 | 98 | $login_header_url = network_home_url(); |
99 | 99 | $login_header_title = get_current_site()->site_name; |
100 | 100 | } else { |
101 | - $login_header_url = __( 'https://wordpress.org/' ); |
|
102 | - $login_header_title = __( 'Powered by WordPress' ); |
|
101 | + $login_header_url = __('https://wordpress.org/'); |
|
102 | + $login_header_title = __('Powered by WordPress'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param string $login_header_url Login header logo URL. |
111 | 111 | */ |
112 | - $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); |
|
112 | + $login_header_url = apply_filters('login_headerurl', $login_header_url); |
|
113 | 113 | /** |
114 | 114 | * Filter the title attribute of the header logo above login form. |
115 | 115 | * |
@@ -117,23 +117,23 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param string $login_header_title Login header logo title attribute. |
119 | 119 | */ |
120 | - $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); |
|
120 | + $login_header_title = apply_filters('login_headertitle', $login_header_title); |
|
121 | 121 | |
122 | - $classes = array( 'login-action-' . $action, 'wp-core-ui' ); |
|
123 | - if ( wp_is_mobile() ) |
|
122 | + $classes = array('login-action-'.$action, 'wp-core-ui'); |
|
123 | + if (wp_is_mobile()) |
|
124 | 124 | $classes[] = 'mobile'; |
125 | - if ( is_rtl() ) |
|
125 | + if (is_rtl()) |
|
126 | 126 | $classes[] = 'rtl'; |
127 | - if ( $interim_login ) { |
|
127 | + if ($interim_login) { |
|
128 | 128 | $classes[] = 'interim-login'; |
129 | 129 | ?> |
130 | 130 | <style type="text/css">html{background-color: transparent;}</style> |
131 | 131 | <?php |
132 | 132 | |
133 | - if ( 'success' === $interim_login ) |
|
133 | + if ('success' === $interim_login) |
|
134 | 134 | $classes[] = 'interim-login-success'; |
135 | 135 | } |
136 | - $classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
|
136 | + $classes[] = ' locale-'.sanitize_html_class(strtolower(str_replace('_', '-', get_locale()))); |
|
137 | 137 | |
138 | 138 | /** |
139 | 139 | * Filter the login page body classes. |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | * @param array $classes An array of body classes. |
144 | 144 | * @param string $action The action that brought the visitor to the login page. |
145 | 145 | */ |
146 | - $classes = apply_filters( 'login_body_class', $classes, $action ); |
|
146 | + $classes = apply_filters('login_body_class', $classes, $action); |
|
147 | 147 | |
148 | 148 | ?> |
149 | 149 | </head> |
150 | - <body class="login <?php echo esc_attr( implode( ' ', $classes ) ); ?>"> |
|
150 | + <body class="login <?php echo esc_attr(implode(' ', $classes)); ?>"> |
|
151 | 151 | <div id="login"> |
152 | - <h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
|
152 | + <h1><a href="<?php echo esc_url($login_header_url); ?>" title="<?php echo esc_attr($login_header_title); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1> |
|
153 | 153 | <?php |
154 | 154 | |
155 | - unset( $login_header_url, $login_header_title ); |
|
155 | + unset($login_header_url, $login_header_title); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Filter the message to display above the login form. |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param string $message Login message text. |
163 | 163 | */ |
164 | - $message = apply_filters( 'login_message', $message ); |
|
165 | - if ( !empty( $message ) ) |
|
166 | - echo $message . "\n"; |
|
164 | + $message = apply_filters('login_message', $message); |
|
165 | + if ( ! empty($message)) |
|
166 | + echo $message."\n"; |
|
167 | 167 | |
168 | 168 | // In case a plugin uses $error rather than the $wp_errors object |
169 | - if ( !empty( $error ) ) { |
|
169 | + if ( ! empty($error)) { |
|
170 | 170 | $wp_error->add('error', $error); |
171 | 171 | unset($error); |
172 | 172 | } |
173 | 173 | |
174 | - if ( $wp_error->get_error_code() ) { |
|
174 | + if ($wp_error->get_error_code()) { |
|
175 | 175 | $errors = ''; |
176 | 176 | $messages = ''; |
177 | - foreach ( $wp_error->get_error_codes() as $code ) { |
|
178 | - $severity = $wp_error->get_error_data( $code ); |
|
179 | - foreach ( $wp_error->get_error_messages( $code ) as $error_message ) { |
|
180 | - if ( 'message' == $severity ) |
|
181 | - $messages .= ' ' . $error_message . "<br />\n"; |
|
177 | + foreach ($wp_error->get_error_codes() as $code) { |
|
178 | + $severity = $wp_error->get_error_data($code); |
|
179 | + foreach ($wp_error->get_error_messages($code) as $error_message) { |
|
180 | + if ('message' == $severity) |
|
181 | + $messages .= ' '.$error_message."<br />\n"; |
|
182 | 182 | else |
183 | - $errors .= ' ' . $error_message . "<br />\n"; |
|
183 | + $errors .= ' '.$error_message."<br />\n"; |
|
184 | 184 | } |
185 | 185 | } |
186 | - if ( ! empty( $errors ) ) { |
|
186 | + if ( ! empty($errors)) { |
|
187 | 187 | /** |
188 | 188 | * Filter the error messages displayed above the login form. |
189 | 189 | * |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @param string $errors Login error message. |
193 | 193 | */ |
194 | - echo '<div id="login_error">' . apply_filters( 'login_errors', $errors ) . "</div>\n"; |
|
194 | + echo '<div id="login_error">'.apply_filters('login_errors', $errors)."</div>\n"; |
|
195 | 195 | } |
196 | - if ( ! empty( $messages ) ) { |
|
196 | + if ( ! empty($messages)) { |
|
197 | 197 | /** |
198 | 198 | * Filter instructional messages displayed above the login form. |
199 | 199 | * |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @param string $messages Login messages. |
203 | 203 | */ |
204 | - echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; |
|
204 | + echo '<p class="message">'.apply_filters('login_messages', $messages)."</p>\n"; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | } // End of login_header() |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | global $interim_login; |
216 | 216 | |
217 | 217 | // Don't allow interim logins to navigate away from the page. |
218 | - if ( ! $interim_login ): ?> |
|
219 | - <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php esc_attr_e( 'Are you lost?' ); ?>"><?php printf( __( '← Back to %s' ), get_bloginfo( 'title', 'display' ) ); ?></a></p> |
|
218 | + if ( ! $interim_login): ?> |
|
219 | + <p id="backtoblog"><a href="<?php echo esc_url(home_url('/')); ?>" title="<?php esc_attr_e('Are you lost?'); ?>"><?php printf(__('← Back to %s'), get_bloginfo('title', 'display')); ?></a></p> |
|
220 | 220 | <?php endif; ?> |
221 | 221 | |
222 | 222 | </div> |
223 | 223 | |
224 | - <?php if ( !empty($input_id) ) : ?> |
|
224 | + <?php if ( ! empty($input_id)) : ?> |
|
225 | 225 | <script type="text/javascript"> |
226 | 226 | try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){} |
227 | 227 | if(typeof wpOnload=='function')wpOnload(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @since 3.1.0 |
236 | 236 | */ |
237 | - do_action( 'login_footer' ); ?> |
|
237 | + do_action('login_footer'); ?> |
|
238 | 238 | <div class="clear"></div> |
239 | 239 | </body> |
240 | 240 | </html> |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @since 3.0.0 |
246 | 246 | */ |
247 | 247 | function wp_shake_js() { |
248 | - if ( wp_is_mobile() ) |
|
248 | + if (wp_is_mobile()) |
|
249 | 249 | return; |
250 | 250 | ?> |
251 | 251 | <script type="text/javascript"> |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | |
281 | 281 | $errors = new WP_Error(); |
282 | 282 | |
283 | - if ( empty( $_POST['user_login'] ) ) { |
|
283 | + if (empty($_POST['user_login'])) { |
|
284 | 284 | $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.')); |
285 | - } elseif ( strpos( $_POST['user_login'], '@' ) ) { |
|
286 | - $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) ); |
|
287 | - if ( empty( $user_data ) ) |
|
285 | + } elseif (strpos($_POST['user_login'], '@')) { |
|
286 | + $user_data = get_user_by('email', trim($_POST['user_login'])); |
|
287 | + if (empty($user_data)) |
|
288 | 288 | $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); |
289 | 289 | } else { |
290 | 290 | $login = trim($_POST['user_login']); |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @since 2.1.0 |
298 | 298 | */ |
299 | - do_action( 'lostpassword_post' ); |
|
299 | + do_action('lostpassword_post'); |
|
300 | 300 | |
301 | - if ( $errors->get_error_code() ) |
|
301 | + if ($errors->get_error_code()) |
|
302 | 302 | return $errors; |
303 | 303 | |
304 | - if ( !$user_data ) { |
|
304 | + if ( ! $user_data) { |
|
305 | 305 | $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.')); |
306 | 306 | return $errors; |
307 | 307 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @param string $user_login The user login name. |
320 | 320 | */ |
321 | - do_action( 'retreive_password', $user_login ); |
|
321 | + do_action('retreive_password', $user_login); |
|
322 | 322 | |
323 | 323 | /** |
324 | 324 | * Fires before a new password is retrieved. |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @param string $user_login The user login name. |
329 | 329 | */ |
330 | - do_action( 'retrieve_password', $user_login ); |
|
330 | + do_action('retrieve_password', $user_login); |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * Filter whether to allow a password to be reset. |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | * @param bool true Whether to allow the password to be reset. Default true. |
338 | 338 | * @param int $user_data->ID The ID of the user attempting to reset a password. |
339 | 339 | */ |
340 | - $allow = apply_filters( 'allow_password_reset', true, $user_data->ID ); |
|
340 | + $allow = apply_filters('allow_password_reset', true, $user_data->ID); |
|
341 | 341 | |
342 | - if ( ! $allow ) { |
|
343 | - return new WP_Error( 'no_password_reset', __('Password reset is not allowed for this user') ); |
|
344 | - } elseif ( is_wp_error( $allow ) ) { |
|
342 | + if ( ! $allow) { |
|
343 | + return new WP_Error('no_password_reset', __('Password reset is not allowed for this user')); |
|
344 | + } elseif (is_wp_error($allow)) { |
|
345 | 345 | return $allow; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Generate something random for a password reset key. |
349 | - $key = wp_generate_password( 20, false ); |
|
349 | + $key = wp_generate_password(20, false); |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Fires when a password reset key is generated. |
@@ -356,24 +356,24 @@ discard block |
||
356 | 356 | * @param string $user_login The username for the user. |
357 | 357 | * @param string $key The generated password reset key. |
358 | 358 | */ |
359 | - do_action( 'retrieve_password_key', $user_login, $key ); |
|
359 | + do_action('retrieve_password_key', $user_login, $key); |
|
360 | 360 | |
361 | 361 | // Now insert the key, hashed, into the DB. |
362 | - if ( empty( $wp_hasher ) ) { |
|
363 | - require_once ABSPATH . WPINC . '/class-phpass.php'; |
|
364 | - $wp_hasher = new PasswordHash( 8, true ); |
|
362 | + if (empty($wp_hasher)) { |
|
363 | + require_once ABSPATH.WPINC.'/class-phpass.php'; |
|
364 | + $wp_hasher = new PasswordHash(8, true); |
|
365 | 365 | } |
366 | - $hashed = time() . ':' . $wp_hasher->HashPassword( $key ); |
|
367 | - $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user_login ) ); |
|
366 | + $hashed = time().':'.$wp_hasher->HashPassword($key); |
|
367 | + $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login)); |
|
368 | 368 | |
369 | - $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n"; |
|
370 | - $message .= network_home_url( '/' ) . "\r\n\r\n"; |
|
371 | - $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; |
|
372 | - $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n"; |
|
373 | - $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; |
|
374 | - $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n"; |
|
369 | + $message = __('Someone requested that the password be reset for the following account:')."\r\n\r\n"; |
|
370 | + $message .= network_home_url('/')."\r\n\r\n"; |
|
371 | + $message .= sprintf(__('Username: %s'), $user_login)."\r\n\r\n"; |
|
372 | + $message .= __('If this was a mistake, just ignore this email and nothing will happen.')."\r\n\r\n"; |
|
373 | + $message .= __('To reset your password, visit the following address:')."\r\n\r\n"; |
|
374 | + $message .= '<'.network_site_url("wp-login.php?action=rp&key=$key&login=".rawurlencode($user_login), 'login').">\r\n"; |
|
375 | 375 | |
376 | - if ( is_multisite() ) |
|
376 | + if (is_multisite()) |
|
377 | 377 | $blogname = $GLOBALS['current_site']->site_name; |
378 | 378 | else |
379 | 379 | /* |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
384 | 384 | |
385 | - $title = sprintf( __('[%s] Password Reset'), $blogname ); |
|
385 | + $title = sprintf(__('[%s] Password Reset'), $blogname); |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Filter the subject of the password reset email. |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param string $title Default email title. |
393 | 393 | */ |
394 | - $title = apply_filters( 'retrieve_password_title', $title ); |
|
394 | + $title = apply_filters('retrieve_password_title', $title); |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Filter the message body of the password reset mail. |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | * @param string $user_login The username for the user. |
405 | 405 | * @param WP_User $user_data WP_User object. |
406 | 406 | */ |
407 | - $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); |
|
407 | + $message = apply_filters('retrieve_password_message', $message, $key, $user_login, $user_data); |
|
408 | 408 | |
409 | - if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) |
|
410 | - wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); |
|
409 | + if ($message && ! wp_mail($user_email, wp_specialchars_decode($title), $message)) |
|
410 | + wp_die(__('The e-mail could not be sent.')."<br />\n".__('Possible reason: your host may have disabled the mail() function.')); |
|
411 | 411 | |
412 | 412 | return true; |
413 | 413 | } |
@@ -419,38 +419,38 @@ discard block |
||
419 | 419 | $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
420 | 420 | $errors = new WP_Error(); |
421 | 421 | |
422 | -if ( isset($_GET['key']) ) |
|
422 | +if (isset($_GET['key'])) |
|
423 | 423 | $action = 'resetpass'; |
424 | 424 | |
425 | 425 | // validate action so as to default to the login screen |
426 | -if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) ) |
|
426 | +if ( ! in_array($action, array('postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login'), true) && false === has_filter('login_form_'.$action)) |
|
427 | 427 | $action = 'login'; |
428 | 428 | |
429 | 429 | nocache_headers(); |
430 | 430 | |
431 | 431 | header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); |
432 | 432 | |
433 | -if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set |
|
434 | - if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) |
|
435 | - $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); |
|
433 | +if (defined('RELOCATE') && RELOCATE) { // Move flag is set |
|
434 | + if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) |
|
435 | + $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
436 | 436 | |
437 | - $url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) ); |
|
438 | - if ( $url != get_option( 'siteurl' ) ) |
|
439 | - update_option( 'siteurl', $url ); |
|
437 | + $url = dirname(set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'])); |
|
438 | + if ($url != get_option('siteurl')) |
|
439 | + update_option('siteurl', $url); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | //Set a cookie now to see if they are supported by the browser. |
443 | -$secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) && 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
|
444 | -setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
445 | -if ( SITECOOKIEPATH != COOKIEPATH ) |
|
446 | - setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
443 | +$secure = ('https' === parse_url(site_url(), PHP_URL_SCHEME) && 'https' === parse_url(home_url(), PHP_URL_SCHEME)); |
|
444 | +setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
445 | +if (SITECOOKIEPATH != COOKIEPATH) |
|
446 | + setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure); |
|
447 | 447 | |
448 | 448 | /** |
449 | 449 | * Fires when the login form is initialized. |
450 | 450 | * |
451 | 451 | * @since 3.2.0 |
452 | 452 | */ |
453 | -do_action( 'login_init' ); |
|
453 | +do_action('login_init'); |
|
454 | 454 | /** |
455 | 455 | * Fires before a specified login form action. |
456 | 456 | * |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @since 2.8.0 |
462 | 462 | */ |
463 | -do_action( 'login_form_' . $action ); |
|
463 | +do_action('login_form_'.$action); |
|
464 | 464 | |
465 | 465 | $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); |
466 | 466 | $interim_login = isset($_REQUEST['interim-login']); |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | switch ($action) { |
469 | 469 | |
470 | 470 | case 'postpass' : |
471 | - require_once ABSPATH . WPINC . '/class-phpass.php'; |
|
472 | - $hasher = new PasswordHash( 8, true ); |
|
471 | + require_once ABSPATH.WPINC.'/class-phpass.php'; |
|
472 | + $hasher = new PasswordHash(8, true); |
|
473 | 473 | |
474 | 474 | /** |
475 | 475 | * Filter the life span of the post password cookie. |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @param int $expires The expiry time, as passed to setcookie(). |
483 | 483 | */ |
484 | - $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS ); |
|
485 | - $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
|
486 | - setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
484 | + $expire = apply_filters('post_password_expires', time() + 10 * DAY_IN_SECONDS); |
|
485 | + $secure = ('https' === parse_url(home_url(), PHP_URL_SCHEME)); |
|
486 | + setcookie('wp-postpass_'.COOKIEHASH, $hasher->HashPassword(wp_unslash($_POST['post_password'])), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
487 | 487 | |
488 | - wp_safe_redirect( wp_get_referer() ); |
|
488 | + wp_safe_redirect(wp_get_referer()); |
|
489 | 489 | exit(); |
490 | 490 | |
491 | 491 | case 'logout' : |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | |
496 | 496 | wp_logout(); |
497 | 497 | |
498 | - if ( ! empty( $_REQUEST['redirect_to'] ) ) { |
|
498 | + if ( ! empty($_REQUEST['redirect_to'])) { |
|
499 | 499 | $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to']; |
500 | 500 | } else { |
501 | 501 | $redirect_to = 'wp-login.php?loggedout=true'; |
@@ -511,31 +511,31 @@ discard block |
||
511 | 511 | * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
512 | 512 | * @param WP_User $user The WP_User object for the user that's logging out. |
513 | 513 | */ |
514 | - $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
515 | - wp_safe_redirect( $redirect_to ); |
|
514 | + $redirect_to = apply_filters('logout_redirect', $redirect_to, $requested_redirect_to, $user); |
|
515 | + wp_safe_redirect($redirect_to); |
|
516 | 516 | exit(); |
517 | 517 | |
518 | 518 | case 'lostpassword' : |
519 | 519 | case 'retrievepassword' : |
520 | 520 | |
521 | - if ( $http_post ) { |
|
521 | + if ($http_post) { |
|
522 | 522 | $errors = retrieve_password(); |
523 | - if ( !is_wp_error($errors) ) { |
|
524 | - $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
|
525 | - wp_safe_redirect( $redirect_to ); |
|
523 | + if ( ! is_wp_error($errors)) { |
|
524 | + $redirect_to = ! empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm'; |
|
525 | + wp_safe_redirect($redirect_to); |
|
526 | 526 | exit(); |
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
530 | - if ( isset( $_GET['error'] ) ) { |
|
531 | - if ( 'invalidkey' == $_GET['error'] ) { |
|
532 | - $errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) ); |
|
533 | - } elseif ( 'expiredkey' == $_GET['error'] ) { |
|
534 | - $errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) ); |
|
530 | + if (isset($_GET['error'])) { |
|
531 | + if ('invalidkey' == $_GET['error']) { |
|
532 | + $errors->add('invalidkey', __('Your password reset link appears to be invalid. Please request a new link below.')); |
|
533 | + } elseif ('expiredkey' == $_GET['error']) { |
|
534 | + $errors->add('expiredkey', __('Your password reset link has expired. Please request a new link below.')); |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | - $lostpassword_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
538 | + $lostpassword_redirect = ! empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; |
|
539 | 539 | /** |
540 | 540 | * Filter the URL redirected to after submitting the lostpassword/retrievepassword form. |
541 | 541 | * |
@@ -543,22 +543,22 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @param string $lostpassword_redirect The redirect destination URL. |
545 | 545 | */ |
546 | - $redirect_to = apply_filters( 'lostpassword_redirect', $lostpassword_redirect ); |
|
546 | + $redirect_to = apply_filters('lostpassword_redirect', $lostpassword_redirect); |
|
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Fires before the lost password form. |
550 | 550 | * |
551 | 551 | * @since 1.5.1 |
552 | 552 | */ |
553 | - do_action( 'lost_password' ); |
|
553 | + do_action('lost_password'); |
|
554 | 554 | |
555 | - login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors); |
|
555 | + login_header(__('Lost Password'), '<p class="message">'.__('Please enter your username or email address. You will receive a link to create a new password via email.').'</p>', $errors); |
|
556 | 556 | |
557 | 557 | $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''; |
558 | 558 | |
559 | 559 | ?> |
560 | 560 | |
561 | -<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post"> |
|
561 | +<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url(network_site_url('wp-login.php?action=lostpassword', 'login_post')); ?>" method="post"> |
|
562 | 562 | <p> |
563 | 563 | <label for="user_login" ><?php _e('Username or E-mail:') ?><br /> |
564 | 564 | <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> |
@@ -569,19 +569,19 @@ discard block |
||
569 | 569 | * |
570 | 570 | * @since 2.1.0 |
571 | 571 | */ |
572 | - do_action( 'lostpassword_form' ); ?> |
|
573 | - <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
572 | + do_action('lostpassword_form'); ?> |
|
573 | + <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
|
574 | 574 | <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Get New Password'); ?>" /></p> |
575 | 575 | </form> |
576 | 576 | |
577 | 577 | <p id="nav"> |
578 | -<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a> |
|
578 | +<a href="<?php echo esc_url(wp_login_url()); ?>"><?php _e('Log in') ?></a> |
|
579 | 579 | <?php |
580 | -if ( get_option( 'users_can_register' ) ) : |
|
581 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
580 | +if (get_option('users_can_register')) : |
|
581 | + $registration_url = sprintf('<a href="%s">%s</a>', esc_url(wp_registration_url()), __('Register')); |
|
582 | 582 | |
583 | 583 | /** This filter is documented in wp-includes/general-template.php */ |
584 | - echo ' | ' . apply_filters( 'register', $registration_url ); |
|
584 | + echo ' | '.apply_filters('register', $registration_url); |
|
585 | 585 | endif; |
586 | 586 | ?> |
587 | 587 | </p> |
@@ -592,38 +592,38 @@ discard block |
||
592 | 592 | |
593 | 593 | case 'resetpass' : |
594 | 594 | case 'rp' : |
595 | - list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
596 | - $rp_cookie = 'wp-resetpass-' . COOKIEHASH; |
|
597 | - if ( isset( $_GET['key'] ) ) { |
|
598 | - $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) ); |
|
599 | - setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
600 | - wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) ); |
|
595 | + list($rp_path) = explode('?', wp_unslash($_SERVER['REQUEST_URI'])); |
|
596 | + $rp_cookie = 'wp-resetpass-'.COOKIEHASH; |
|
597 | + if (isset($_GET['key'])) { |
|
598 | + $value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key'])); |
|
599 | + setcookie($rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true); |
|
600 | + wp_safe_redirect(remove_query_arg(array('key', 'login'))); |
|
601 | 601 | exit; |
602 | 602 | } |
603 | 603 | |
604 | - if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) { |
|
605 | - list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 ); |
|
606 | - $user = check_password_reset_key( $rp_key, $rp_login ); |
|
607 | - if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) { |
|
604 | + if (isset($_COOKIE[$rp_cookie]) && 0 < strpos($_COOKIE[$rp_cookie], ':')) { |
|
605 | + list($rp_login, $rp_key) = explode(':', wp_unslash($_COOKIE[$rp_cookie]), 2); |
|
606 | + $user = check_password_reset_key($rp_key, $rp_login); |
|
607 | + if (isset($_POST['pass1']) && ! hash_equals($rp_key, $_POST['rp_key'])) { |
|
608 | 608 | $user = false; |
609 | 609 | } |
610 | 610 | } else { |
611 | 611 | $user = false; |
612 | 612 | } |
613 | 613 | |
614 | - if ( ! $user || is_wp_error( $user ) ) { |
|
615 | - setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
616 | - if ( $user && $user->get_error_code() === 'expired_key' ) |
|
617 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
614 | + if ( ! $user || is_wp_error($user)) { |
|
615 | + setcookie($rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true); |
|
616 | + if ($user && $user->get_error_code() === 'expired_key') |
|
617 | + wp_redirect(site_url('wp-login.php?action=lostpassword&error=expiredkey')); |
|
618 | 618 | else |
619 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
619 | + wp_redirect(site_url('wp-login.php?action=lostpassword&error=invalidkey')); |
|
620 | 620 | exit; |
621 | 621 | } |
622 | 622 | |
623 | 623 | $errors = new WP_Error(); |
624 | 624 | |
625 | - if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) |
|
626 | - $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
625 | + if (isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2']) |
|
626 | + $errors->add('password_reset_mismatch', __('The passwords do not match.')); |
|
627 | 627 | |
628 | 628 | /** |
629 | 629 | * Fires before the password reset procedure is validated. |
@@ -633,12 +633,12 @@ discard block |
||
633 | 633 | * @param object $errors WP Error object. |
634 | 634 | * @param WP_User|WP_Error $user WP_User object if the login and reset key match. WP_Error object otherwise. |
635 | 635 | */ |
636 | - do_action( 'validate_password_reset', $errors, $user ); |
|
636 | + do_action('validate_password_reset', $errors, $user); |
|
637 | 637 | |
638 | - if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) { |
|
638 | + if (( ! $errors->get_error_code()) && isset($_POST['pass1']) && ! empty($_POST['pass1'])) { |
|
639 | 639 | reset_password($user, $_POST['pass1']); |
640 | - setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
|
641 | - login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' ); |
|
640 | + setcookie($rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true); |
|
641 | + login_header(__('Password Reset'), '<p class="message reset-pass">'.__('Your password has been reset.').' <a href="'.esc_url(wp_login_url()).'">'.__('Log in').'</a></p>'); |
|
642 | 642 | login_footer(); |
643 | 643 | exit; |
644 | 644 | } |
@@ -646,19 +646,19 @@ discard block |
||
646 | 646 | wp_enqueue_script('utils'); |
647 | 647 | wp_enqueue_script('user-profile'); |
648 | 648 | |
649 | - login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors ); |
|
649 | + login_header(__('Reset Password'), '<p class="message reset-pass">'.__('Enter your new password below.').'</p>', $errors); |
|
650 | 650 | |
651 | 651 | ?> |
652 | -<form name="resetpassform" id="resetpassform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=resetpass', 'login_post' ) ); ?>" method="post" autocomplete="off"> |
|
653 | - <input type="hidden" id="user_login" value="<?php echo esc_attr( $rp_login ); ?>" autocomplete="off" /> |
|
652 | +<form name="resetpassform" id="resetpassform" action="<?php echo esc_url(network_site_url('wp-login.php?action=resetpass', 'login_post')); ?>" method="post" autocomplete="off"> |
|
653 | + <input type="hidden" id="user_login" value="<?php echo esc_attr($rp_login); ?>" autocomplete="off" /> |
|
654 | 654 | |
655 | 655 | <p class="user-pass1-wrap"> |
656 | 656 | <label for="pass1"><?php _e('New password') ?></label><br /> |
657 | 657 | <div class="wp-pwd"> |
658 | 658 | <span class="password-input-wrapper"> |
659 | - <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" /> |
|
659 | + <input type="password" data-reveal="1" data-pw="<?php echo esc_attr(wp_generate_password(16)); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" /> |
|
660 | 660 | </span> |
661 | - <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> |
|
661 | + <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e('Strength indicator'); ?></div> |
|
662 | 662 | </div> |
663 | 663 | </p> |
664 | 664 | <p class="user-pass2-wrap"> |
@@ -677,20 +677,20 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @param WP_User $user User object of the user whose password is being reset. |
679 | 679 | */ |
680 | - do_action( 'resetpass_form', $user ); |
|
680 | + do_action('resetpass_form', $user); |
|
681 | 681 | ?> |
682 | - <input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>" /> |
|
682 | + <input type="hidden" name="rp_key" value="<?php echo esc_attr($rp_key); ?>" /> |
|
683 | 683 | <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Reset Password'); ?>" /></p> |
684 | 684 | </form> |
685 | 685 | |
686 | 686 | <p id="nav"> |
687 | -<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
|
687 | +<a href="<?php echo esc_url(wp_login_url()); ?>"><?php _e('Log in'); ?></a> |
|
688 | 688 | <?php |
689 | -if ( get_option( 'users_can_register' ) ) : |
|
690 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
689 | +if (get_option('users_can_register')) : |
|
690 | + $registration_url = sprintf('<a href="%s">%s</a>', esc_url(wp_registration_url()), __('Register')); |
|
691 | 691 | |
692 | 692 | /** This filter is documented in wp-includes/general-template.php */ |
693 | - echo ' | ' . apply_filters( 'register', $registration_url ); |
|
693 | + echo ' | '.apply_filters('register', $registration_url); |
|
694 | 694 | endif; |
695 | 695 | ?> |
696 | 696 | </p> |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'register' : |
703 | - if ( is_multisite() ) { |
|
703 | + if (is_multisite()) { |
|
704 | 704 | /** |
705 | 705 | * Filter the Multisite sign up URL. |
706 | 706 | * |
@@ -708,29 +708,29 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @param string $sign_up_url The sign up URL. |
710 | 710 | */ |
711 | - wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) ); |
|
711 | + wp_redirect(apply_filters('wp_signup_location', network_site_url('wp-signup.php'))); |
|
712 | 712 | exit; |
713 | 713 | } |
714 | 714 | |
715 | - if ( !get_option('users_can_register') ) { |
|
716 | - wp_redirect( site_url('wp-login.php?registration=disabled') ); |
|
715 | + if ( ! get_option('users_can_register')) { |
|
716 | + wp_redirect(site_url('wp-login.php?registration=disabled')); |
|
717 | 717 | exit(); |
718 | 718 | } |
719 | 719 | |
720 | 720 | $user_login = ''; |
721 | 721 | $user_email = ''; |
722 | - if ( $http_post ) { |
|
722 | + if ($http_post) { |
|
723 | 723 | $user_login = $_POST['user_login']; |
724 | 724 | $user_email = $_POST['user_email']; |
725 | 725 | $errors = register_new_user($user_login, $user_email); |
726 | - if ( !is_wp_error($errors) ) { |
|
727 | - $redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
728 | - wp_safe_redirect( $redirect_to ); |
|
726 | + if ( ! is_wp_error($errors)) { |
|
727 | + $redirect_to = ! empty($_POST['redirect_to']) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered'; |
|
728 | + wp_safe_redirect($redirect_to); |
|
729 | 729 | exit(); |
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
733 | - $registration_redirect = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
733 | + $registration_redirect = ! empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; |
|
734 | 734 | /** |
735 | 735 | * Filter the registration redirect URL. |
736 | 736 | * |
@@ -738,18 +738,18 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @param string $registration_redirect The redirect destination URL. |
740 | 740 | */ |
741 | - $redirect_to = apply_filters( 'registration_redirect', $registration_redirect ); |
|
742 | - login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors); |
|
741 | + $redirect_to = apply_filters('registration_redirect', $registration_redirect); |
|
742 | + login_header(__('Registration Form'), '<p class="message register">'.__('Register For This Site').'</p>', $errors); |
|
743 | 743 | ?> |
744 | 744 | |
745 | -<form name="registerform" id="registerform" action="<?php echo esc_url( site_url('wp-login.php?action=register', 'login_post') ); ?>" method="post" novalidate="novalidate"> |
|
745 | +<form name="registerform" id="registerform" action="<?php echo esc_url(site_url('wp-login.php?action=register', 'login_post')); ?>" method="post" novalidate="novalidate"> |
|
746 | 746 | <p> |
747 | 747 | <label for="user_login"><?php _e('Username') ?><br /> |
748 | 748 | <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label> |
749 | 749 | </p> |
750 | 750 | <p> |
751 | 751 | <label for="user_email"><?php _e('E-mail') ?><br /> |
752 | - <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label> |
|
752 | + <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(wp_unslash($user_email)); ?>" size="25" /></label> |
|
753 | 753 | </p> |
754 | 754 | <?php |
755 | 755 | /** |
@@ -757,17 +757,17 @@ discard block |
||
757 | 757 | * |
758 | 758 | * @since 2.1.0 |
759 | 759 | */ |
760 | - do_action( 'register_form' ); |
|
760 | + do_action('register_form'); |
|
761 | 761 | ?> |
762 | - <p id="reg_passmail"><?php _e( 'Registration confirmation will be e-mailed to you.' ); ?></p> |
|
762 | + <p id="reg_passmail"><?php _e('Registration confirmation will be e-mailed to you.'); ?></p> |
|
763 | 763 | <br class="clear" /> |
764 | - <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" /> |
|
764 | + <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
|
765 | 765 | <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Register'); ?>" /></p> |
766 | 766 | </form> |
767 | 767 | |
768 | 768 | <p id="nav"> |
769 | -<a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> | |
|
770 | -<a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ) ?>"><?php _e( 'Lost your password?' ); ?></a> |
|
769 | +<a href="<?php echo esc_url(wp_login_url()); ?>"><?php _e('Log in'); ?></a> | |
|
770 | +<a href="<?php echo esc_url(wp_lostpassword_url()); ?>" title="<?php esc_attr_e('Password Lost and Found') ?>"><?php _e('Lost your password?'); ?></a> |
|
771 | 771 | </p> |
772 | 772 | |
773 | 773 | <?php |
@@ -777,25 +777,25 @@ discard block |
||
777 | 777 | case 'login' : |
778 | 778 | default: |
779 | 779 | $secure_cookie = ''; |
780 | - $customize_login = isset( $_REQUEST['customize-login'] ); |
|
781 | - if ( $customize_login ) |
|
782 | - wp_enqueue_script( 'customize-base' ); |
|
780 | + $customize_login = isset($_REQUEST['customize-login']); |
|
781 | + if ($customize_login) |
|
782 | + wp_enqueue_script('customize-base'); |
|
783 | 783 | |
784 | 784 | // If the user wants ssl but the session is not ssl, force a secure cookie. |
785 | - if ( !empty($_POST['log']) && !force_ssl_admin() ) { |
|
785 | + if ( ! empty($_POST['log']) && ! force_ssl_admin()) { |
|
786 | 786 | $user_name = sanitize_user($_POST['log']); |
787 | - if ( $user = get_user_by('login', $user_name) ) { |
|
788 | - if ( get_user_option('use_ssl', $user->ID) ) { |
|
787 | + if ($user = get_user_by('login', $user_name)) { |
|
788 | + if (get_user_option('use_ssl', $user->ID)) { |
|
789 | 789 | $secure_cookie = true; |
790 | 790 | force_ssl_admin(true); |
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
794 | 794 | |
795 | - if ( isset( $_REQUEST['redirect_to'] ) ) { |
|
795 | + if (isset($_REQUEST['redirect_to'])) { |
|
796 | 796 | $redirect_to = $_REQUEST['redirect_to']; |
797 | 797 | // Redirect to https if user wants ssl |
798 | - if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) |
|
798 | + if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) |
|
799 | 799 | $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
800 | 800 | } else { |
801 | 801 | $redirect_to = admin_url(); |
@@ -803,20 +803,20 @@ discard block |
||
803 | 803 | |
804 | 804 | $reauth = empty($_REQUEST['reauth']) ? false : true; |
805 | 805 | |
806 | - $user = wp_signon( '', $secure_cookie ); |
|
806 | + $user = wp_signon('', $secure_cookie); |
|
807 | 807 | |
808 | - if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) { |
|
809 | - if ( headers_sent() ) { |
|
810 | - $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ), |
|
811 | - __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' ) ) ); |
|
812 | - } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { |
|
808 | + if (empty($_COOKIE[LOGGED_IN_COOKIE])) { |
|
809 | + if (headers_sent()) { |
|
810 | + $user = new WP_Error('test_cookie', sprintf(__('<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.'), |
|
811 | + __('https://codex.wordpress.org/Cookies'), __('https://wordpress.org/support/'))); |
|
812 | + } elseif (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) { |
|
813 | 813 | // If cookies are disabled we can't log in even with a valid user+pass |
814 | - $user = new WP_Error( 'test_cookie', sprintf( __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ), |
|
815 | - __( 'https://codex.wordpress.org/Cookies' ) ) ); |
|
814 | + $user = new WP_Error('test_cookie', sprintf(__('<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.'), |
|
815 | + __('https://codex.wordpress.org/Cookies'))); |
|
816 | 816 | } |
817 | 817 | } |
818 | 818 | |
819 | - $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
819 | + $requested_redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; |
|
820 | 820 | /** |
821 | 821 | * Filter the login redirect URL. |
822 | 822 | * |
@@ -826,31 +826,31 @@ discard block |
||
826 | 826 | * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
827 | 827 | * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
828 | 828 | */ |
829 | - $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user ); |
|
829 | + $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user); |
|
830 | 830 | |
831 | - if ( !is_wp_error($user) && !$reauth ) { |
|
832 | - if ( $interim_login ) { |
|
833 | - $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; |
|
831 | + if ( ! is_wp_error($user) && ! $reauth) { |
|
832 | + if ($interim_login) { |
|
833 | + $message = '<p class="message">'.__('You have logged in successfully.').'</p>'; |
|
834 | 834 | $interim_login = 'success'; |
835 | - login_header( '', $message ); ?> |
|
835 | + login_header('', $message); ?> |
|
836 | 836 | </div> |
837 | 837 | <?php |
838 | 838 | /** This action is documented in wp-login.php */ |
839 | - do_action( 'login_footer' ); ?> |
|
840 | - <?php if ( $customize_login ) : ?> |
|
839 | + do_action('login_footer'); ?> |
|
840 | + <?php if ($customize_login) : ?> |
|
841 | 841 | <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> |
842 | 842 | <?php endif; ?> |
843 | 843 | </body></html> |
844 | 844 | <?php exit; |
845 | 845 | } |
846 | 846 | |
847 | - if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
|
847 | + if ((empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url())) { |
|
848 | 848 | // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
849 | - if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) |
|
849 | + if (is_multisite() && ! get_active_blog_for_user($user->ID) && ! is_super_admin($user->ID)) |
|
850 | 850 | $redirect_to = user_admin_url(); |
851 | - elseif ( is_multisite() && !$user->has_cap('read') ) |
|
852 | - $redirect_to = get_dashboard_url( $user->ID ); |
|
853 | - elseif ( !$user->has_cap('edit_posts') ) |
|
851 | + elseif (is_multisite() && ! $user->has_cap('read')) |
|
852 | + $redirect_to = get_dashboard_url($user->ID); |
|
853 | + elseif ( ! $user->has_cap('edit_posts')) |
|
854 | 854 | $redirect_to = admin_url('profile.php'); |
855 | 855 | } |
856 | 856 | wp_safe_redirect($redirect_to); |
@@ -859,26 +859,26 @@ discard block |
||
859 | 859 | |
860 | 860 | $errors = $user; |
861 | 861 | // Clear errors if loggedout is set. |
862 | - if ( !empty($_GET['loggedout']) || $reauth ) |
|
862 | + if ( ! empty($_GET['loggedout']) || $reauth) |
|
863 | 863 | $errors = new WP_Error(); |
864 | 864 | |
865 | - if ( $interim_login ) { |
|
866 | - if ( ! $errors->get_error_code() ) |
|
865 | + if ($interim_login) { |
|
866 | + if ( ! $errors->get_error_code()) |
|
867 | 867 | $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
868 | 868 | } else { |
869 | 869 | // Some parts of this script use the main login form to display a message |
870 | - if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) |
|
870 | + if (isset($_GET['loggedout']) && true == $_GET['loggedout']) |
|
871 | 871 | $errors->add('loggedout', __('You are now logged out.'), 'message'); |
872 | - elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
|
872 | + elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) |
|
873 | 873 | $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
874 | - elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
|
874 | + elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) |
|
875 | 875 | $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
876 | - elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
|
876 | + elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) |
|
877 | 877 | $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
878 | - elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
|
878 | + elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) |
|
879 | 879 | $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
880 | - elseif ( strpos( $redirect_to, 'about.php?updated' ) ) |
|
881 | - $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
880 | + elseif (strpos($redirect_to, 'about.php?updated')) |
|
881 | + $errors->add('updated', __('<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.'), 'message'); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -889,29 +889,29 @@ discard block |
||
889 | 889 | * @param object $errors WP Error object. |
890 | 890 | * @param string $redirect_to Redirect destination URL. |
891 | 891 | */ |
892 | - $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
|
892 | + $errors = apply_filters('wp_login_errors', $errors, $redirect_to); |
|
893 | 893 | |
894 | 894 | // Clear any stale cookies. |
895 | - if ( $reauth ) |
|
895 | + if ($reauth) |
|
896 | 896 | wp_clear_auth_cookie(); |
897 | 897 | |
898 | 898 | login_header(__('Log In'), '', $errors); |
899 | 899 | |
900 | - if ( isset($_POST['log']) ) |
|
901 | - $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
902 | - $rememberme = ! empty( $_POST['rememberme'] ); |
|
900 | + if (isset($_POST['log'])) |
|
901 | + $user_login = ('incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code()) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
902 | + $rememberme = ! empty($_POST['rememberme']); |
|
903 | 903 | |
904 | - if ( ! empty( $errors->errors ) ) { |
|
904 | + if ( ! empty($errors->errors)) { |
|
905 | 905 | $aria_describedby_error = ' aria-describedby="login_error"'; |
906 | 906 | } else { |
907 | 907 | $aria_describedby_error = ''; |
908 | 908 | } |
909 | 909 | ?> |
910 | 910 | |
911 | -<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post"> |
|
911 | +<form name="loginform" id="loginform" action="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?>" method="post"> |
|
912 | 912 | <p> |
913 | 913 | <label for="user_login"><?php _e('Username') ?><br /> |
914 | - <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label> |
|
914 | + <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label> |
|
915 | 915 | </p> |
916 | 916 | <p> |
917 | 917 | <label for="user_pass"><?php _e('Password') ?><br /> |
@@ -923,34 +923,34 @@ discard block |
||
923 | 923 | * |
924 | 924 | * @since 2.1.0 |
925 | 925 | */ |
926 | - do_action( 'login_form' ); |
|
926 | + do_action('login_form'); |
|
927 | 927 | ?> |
928 | - <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked( $rememberme ); ?> /> <?php esc_attr_e('Remember Me'); ?></label></p> |
|
928 | + <p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" <?php checked($rememberme); ?> /> <?php esc_attr_e('Remember Me'); ?></label></p> |
|
929 | 929 | <p class="submit"> |
930 | 930 | <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Log In'); ?>" /> |
931 | -<?php if ( $interim_login ) { ?> |
|
931 | +<?php if ($interim_login) { ?> |
|
932 | 932 | <input type="hidden" name="interim-login" value="1" /> |
933 | 933 | <?php } else { ?> |
934 | 934 | <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> |
935 | 935 | <?php } ?> |
936 | -<?php if ( $customize_login ) : ?> |
|
936 | +<?php if ($customize_login) : ?> |
|
937 | 937 | <input type="hidden" name="customize-login" value="1" /> |
938 | 938 | <?php endif; ?> |
939 | 939 | <input type="hidden" name="testcookie" value="1" /> |
940 | 940 | </p> |
941 | 941 | </form> |
942 | 942 | |
943 | -<?php if ( ! $interim_login ) { ?> |
|
943 | +<?php if ( ! $interim_login) { ?> |
|
944 | 944 | <p id="nav"> |
945 | -<?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) : |
|
946 | - if ( get_option( 'users_can_register' ) ) : |
|
947 | - $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) ); |
|
945 | +<?php if ( ! isset($_GET['checkemail']) || ! in_array($_GET['checkemail'], array('confirm', 'newpass'))) : |
|
946 | + if (get_option('users_can_register')) : |
|
947 | + $registration_url = sprintf('<a href="%s">%s</a>', esc_url(wp_registration_url()), __('Register')); |
|
948 | 948 | |
949 | 949 | /** This filter is documented in wp-includes/general-template.php */ |
950 | - echo apply_filters( 'register', $registration_url ) . ' | '; |
|
950 | + echo apply_filters('register', $registration_url).' | '; |
|
951 | 951 | endif; |
952 | 952 | ?> |
953 | - <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>" title="<?php esc_attr_e( 'Password Lost and Found' ); ?>"><?php _e( 'Lost your password?' ); ?></a> |
|
953 | + <a href="<?php echo esc_url(wp_lostpassword_url()); ?>" title="<?php esc_attr_e('Password Lost and Found'); ?>"><?php _e('Lost your password?'); ?></a> |
|
954 | 954 | <?php endif; ?> |
955 | 955 | </p> |
956 | 956 | <?php } ?> |
@@ -958,12 +958,12 @@ discard block |
||
958 | 958 | <script type="text/javascript"> |
959 | 959 | function wp_attempt_focus(){ |
960 | 960 | setTimeout( function(){ try{ |
961 | -<?php if ( $user_login ) { ?> |
|
961 | +<?php if ($user_login) { ?> |
|
962 | 962 | d = document.getElementById('user_pass'); |
963 | 963 | d.value = ''; |
964 | 964 | <?php } else { ?> |
965 | 965 | d = document.getElementById('user_login'); |
966 | -<?php if ( 'invalid_username' == $errors->get_error_code() ) { ?> |
|
966 | +<?php if ('invalid_username' == $errors->get_error_code()) { ?> |
|
967 | 967 | if( d.value != '' ) |
968 | 968 | d.value = ''; |
969 | 969 | <?php |
@@ -975,11 +975,11 @@ discard block |
||
975 | 975 | }, 200); |
976 | 976 | } |
977 | 977 | |
978 | -<?php if ( !$error ) { ?> |
|
978 | +<?php if ( ! $error) { ?> |
|
979 | 979 | wp_attempt_focus(); |
980 | 980 | <?php } ?> |
981 | 981 | if(typeof wpOnload=='function')wpOnload(); |
982 | -<?php if ( $interim_login ) { ?> |
|
982 | +<?php if ($interim_login) { ?> |
|
983 | 983 | (function(){ |
984 | 984 | try { |
985 | 985 | var i, links = document.getElementsByTagName('a'); |
@@ -36,11 +36,13 @@ discard block |
||
36 | 36 | // Don't index any of these forms |
37 | 37 | add_action( 'login_head', 'wp_no_robots' ); |
38 | 38 | |
39 | - if ( wp_is_mobile() ) |
|
40 | - add_action( 'login_head', 'wp_login_viewport_meta' ); |
|
39 | + if ( wp_is_mobile() ) { |
|
40 | + add_action( 'login_head', 'wp_login_viewport_meta' ); |
|
41 | + } |
|
41 | 42 | |
42 | - if ( empty($wp_error) ) |
|
43 | - $wp_error = new WP_Error(); |
|
43 | + if ( empty($wp_error) ) { |
|
44 | + $wp_error = new WP_Error(); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | // Shake it! |
46 | 48 | $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' ); |
@@ -53,8 +55,9 @@ discard block |
||
53 | 55 | */ |
54 | 56 | $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); |
55 | 57 | |
56 | - if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) |
|
57 | - add_action( 'login_head', 'wp_shake_js', 12 ); |
|
58 | + if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) { |
|
59 | + add_action( 'login_head', 'wp_shake_js', 12 ); |
|
60 | + } |
|
58 | 61 | |
59 | 62 | ?><!DOCTYPE html> |
60 | 63 | <!--[if IE 8]> |
@@ -120,18 +123,21 @@ discard block |
||
120 | 123 | $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); |
121 | 124 | |
122 | 125 | $classes = array( 'login-action-' . $action, 'wp-core-ui' ); |
123 | - if ( wp_is_mobile() ) |
|
124 | - $classes[] = 'mobile'; |
|
125 | - if ( is_rtl() ) |
|
126 | - $classes[] = 'rtl'; |
|
126 | + if ( wp_is_mobile() ) { |
|
127 | + $classes[] = 'mobile'; |
|
128 | + } |
|
129 | + if ( is_rtl() ) { |
|
130 | + $classes[] = 'rtl'; |
|
131 | + } |
|
127 | 132 | if ( $interim_login ) { |
128 | 133 | $classes[] = 'interim-login'; |
129 | 134 | ?> |
130 | 135 | <style type="text/css">html{background-color: transparent;}</style> |
131 | 136 | <?php |
132 | 137 | |
133 | - if ( 'success' === $interim_login ) |
|
134 | - $classes[] = 'interim-login-success'; |
|
138 | + if ( 'success' === $interim_login ) { |
|
139 | + $classes[] = 'interim-login-success'; |
|
140 | + } |
|
135 | 141 | } |
136 | 142 | $classes[] =' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
137 | 143 | |
@@ -162,8 +168,9 @@ discard block |
||
162 | 168 | * @param string $message Login message text. |
163 | 169 | */ |
164 | 170 | $message = apply_filters( 'login_message', $message ); |
165 | - if ( !empty( $message ) ) |
|
166 | - echo $message . "\n"; |
|
171 | + if ( !empty( $message ) ) { |
|
172 | + echo $message . "\n"; |
|
173 | + } |
|
167 | 174 | |
168 | 175 | // In case a plugin uses $error rather than the $wp_errors object |
169 | 176 | if ( !empty( $error ) ) { |
@@ -177,10 +184,11 @@ discard block |
||
177 | 184 | foreach ( $wp_error->get_error_codes() as $code ) { |
178 | 185 | $severity = $wp_error->get_error_data( $code ); |
179 | 186 | foreach ( $wp_error->get_error_messages( $code ) as $error_message ) { |
180 | - if ( 'message' == $severity ) |
|
181 | - $messages .= ' ' . $error_message . "<br />\n"; |
|
182 | - else |
|
183 | - $errors .= ' ' . $error_message . "<br />\n"; |
|
187 | + if ( 'message' == $severity ) { |
|
188 | + $messages .= ' ' . $error_message . "<br />\n"; |
|
189 | + } else { |
|
190 | + $errors .= ' ' . $error_message . "<br />\n"; |
|
191 | + } |
|
184 | 192 | } |
185 | 193 | } |
186 | 194 | if ( ! empty( $errors ) ) { |
@@ -245,9 +253,10 @@ discard block |
||
245 | 253 | * @since 3.0.0 |
246 | 254 | */ |
247 | 255 | function wp_shake_js() { |
248 | - if ( wp_is_mobile() ) |
|
249 | - return; |
|
250 | -?> |
|
256 | + if ( wp_is_mobile() ) { |
|
257 | + return; |
|
258 | + } |
|
259 | + ?> |
|
251 | 260 | <script type="text/javascript"> |
252 | 261 | addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; |
253 | 262 | function s(id,pos){g(id).left=pos+'px';} |
@@ -284,8 +293,9 @@ discard block |
||
284 | 293 | $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.')); |
285 | 294 | } elseif ( strpos( $_POST['user_login'], '@' ) ) { |
286 | 295 | $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) ); |
287 | - if ( empty( $user_data ) ) |
|
288 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); |
|
296 | + if ( empty( $user_data ) ) { |
|
297 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.')); |
|
298 | + } |
|
289 | 299 | } else { |
290 | 300 | $login = trim($_POST['user_login']); |
291 | 301 | $user_data = get_user_by('login', $login); |
@@ -298,8 +308,9 @@ discard block |
||
298 | 308 | */ |
299 | 309 | do_action( 'lostpassword_post' ); |
300 | 310 | |
301 | - if ( $errors->get_error_code() ) |
|
302 | - return $errors; |
|
311 | + if ( $errors->get_error_code() ) { |
|
312 | + return $errors; |
|
313 | + } |
|
303 | 314 | |
304 | 315 | if ( !$user_data ) { |
305 | 316 | $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.')); |
@@ -373,14 +384,15 @@ discard block |
||
373 | 384 | $message .= __('To reset your password, visit the following address:') . "\r\n\r\n"; |
374 | 385 | $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n"; |
375 | 386 | |
376 | - if ( is_multisite() ) |
|
377 | - $blogname = $GLOBALS['current_site']->site_name; |
|
378 | - else |
|
379 | - /* |
|
387 | + if ( is_multisite() ) { |
|
388 | + $blogname = $GLOBALS['current_site']->site_name; |
|
389 | + } else { |
|
390 | + /* |
|
380 | 391 | * The blogname option is escaped with esc_html on the way into the database |
381 | 392 | * in sanitize_option we want to reverse this for the plain text arena of emails. |
382 | 393 | */ |
383 | 394 | $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
395 | + } |
|
384 | 396 | |
385 | 397 | $title = sprintf( __('[%s] Password Reset'), $blogname ); |
386 | 398 | |
@@ -406,8 +418,9 @@ discard block |
||
406 | 418 | */ |
407 | 419 | $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); |
408 | 420 | |
409 | - if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) |
|
410 | - wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); |
|
421 | + if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) { |
|
422 | + wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.') ); |
|
423 | + } |
|
411 | 424 | |
412 | 425 | return true; |
413 | 426 | } |
@@ -419,31 +432,36 @@ discard block |
||
419 | 432 | $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
420 | 433 | $errors = new WP_Error(); |
421 | 434 | |
422 | -if ( isset($_GET['key']) ) |
|
435 | +if ( isset($_GET['key']) ) { |
|
423 | 436 | $action = 'resetpass'; |
437 | +} |
|
424 | 438 | |
425 | 439 | // validate action so as to default to the login screen |
426 | -if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) ) |
|
440 | +if ( !in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login' ), true ) && false === has_filter( 'login_form_' . $action ) ) { |
|
427 | 441 | $action = 'login'; |
442 | +} |
|
428 | 443 | |
429 | 444 | nocache_headers(); |
430 | 445 | |
431 | 446 | header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); |
432 | 447 | |
433 | 448 | if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set |
434 | - if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) |
|
435 | - $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); |
|
449 | + if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) ) { |
|
450 | + $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); |
|
451 | + } |
|
436 | 452 | |
437 | 453 | $url = dirname( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] ) ); |
438 | - if ( $url != get_option( 'siteurl' ) ) |
|
439 | - update_option( 'siteurl', $url ); |
|
440 | -} |
|
454 | + if ( $url != get_option( 'siteurl' ) ) { |
|
455 | + update_option( 'siteurl', $url ); |
|
456 | + } |
|
457 | + } |
|
441 | 458 | |
442 | 459 | //Set a cookie now to see if they are supported by the browser. |
443 | 460 | $secure = ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) && 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
444 | 461 | setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
445 | -if ( SITECOOKIEPATH != COOKIEPATH ) |
|
462 | +if ( SITECOOKIEPATH != COOKIEPATH ) { |
|
446 | 463 | setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); |
464 | +} |
|
447 | 465 | |
448 | 466 | /** |
449 | 467 | * Fires when the login form is initialized. |
@@ -613,17 +631,19 @@ discard block |
||
613 | 631 | |
614 | 632 | if ( ! $user || is_wp_error( $user ) ) { |
615 | 633 | setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); |
616 | - if ( $user && $user->get_error_code() === 'expired_key' ) |
|
617 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
618 | - else |
|
619 | - wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
634 | + if ( $user && $user->get_error_code() === 'expired_key' ) { |
|
635 | + wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) ); |
|
636 | + } else { |
|
637 | + wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) ); |
|
638 | + } |
|
620 | 639 | exit; |
621 | 640 | } |
622 | 641 | |
623 | 642 | $errors = new WP_Error(); |
624 | 643 | |
625 | - if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) |
|
626 | - $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
644 | + if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) { |
|
645 | + $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) ); |
|
646 | + } |
|
627 | 647 | |
628 | 648 | /** |
629 | 649 | * Fires before the password reset procedure is validated. |
@@ -778,8 +798,9 @@ discard block |
||
778 | 798 | default: |
779 | 799 | $secure_cookie = ''; |
780 | 800 | $customize_login = isset( $_REQUEST['customize-login'] ); |
781 | - if ( $customize_login ) |
|
782 | - wp_enqueue_script( 'customize-base' ); |
|
801 | + if ( $customize_login ) { |
|
802 | + wp_enqueue_script( 'customize-base' ); |
|
803 | + } |
|
783 | 804 | |
784 | 805 | // If the user wants ssl but the session is not ssl, force a secure cookie. |
785 | 806 | if ( !empty($_POST['log']) && !force_ssl_admin() ) { |
@@ -795,8 +816,9 @@ discard block |
||
795 | 816 | if ( isset( $_REQUEST['redirect_to'] ) ) { |
796 | 817 | $redirect_to = $_REQUEST['redirect_to']; |
797 | 818 | // Redirect to https if user wants ssl |
798 | - if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) |
|
799 | - $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
819 | + if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') ) { |
|
820 | + $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
821 | + } |
|
800 | 822 | } else { |
801 | 823 | $redirect_to = admin_url(); |
802 | 824 | } |
@@ -846,12 +868,13 @@ discard block |
||
846 | 868 | |
847 | 869 | if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) { |
848 | 870 | // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. |
849 | - if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) |
|
850 | - $redirect_to = user_admin_url(); |
|
851 | - elseif ( is_multisite() && !$user->has_cap('read') ) |
|
852 | - $redirect_to = get_dashboard_url( $user->ID ); |
|
853 | - elseif ( !$user->has_cap('edit_posts') ) |
|
854 | - $redirect_to = admin_url('profile.php'); |
|
871 | + if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) { |
|
872 | + $redirect_to = user_admin_url(); |
|
873 | + } elseif ( is_multisite() && !$user->has_cap('read') ) { |
|
874 | + $redirect_to = get_dashboard_url( $user->ID ); |
|
875 | + } elseif ( !$user->has_cap('edit_posts') ) { |
|
876 | + $redirect_to = admin_url('profile.php'); |
|
877 | + } |
|
855 | 878 | } |
856 | 879 | wp_safe_redirect($redirect_to); |
857 | 880 | exit(); |
@@ -859,26 +882,29 @@ discard block |
||
859 | 882 | |
860 | 883 | $errors = $user; |
861 | 884 | // Clear errors if loggedout is set. |
862 | - if ( !empty($_GET['loggedout']) || $reauth ) |
|
863 | - $errors = new WP_Error(); |
|
885 | + if ( !empty($_GET['loggedout']) || $reauth ) { |
|
886 | + $errors = new WP_Error(); |
|
887 | + } |
|
864 | 888 | |
865 | 889 | if ( $interim_login ) { |
866 | - if ( ! $errors->get_error_code() ) |
|
867 | - $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
|
890 | + if ( ! $errors->get_error_code() ) { |
|
891 | + $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); |
|
892 | + } |
|
868 | 893 | } else { |
869 | 894 | // Some parts of this script use the main login form to display a message |
870 | - if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) |
|
871 | - $errors->add('loggedout', __('You are now logged out.'), 'message'); |
|
872 | - elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) |
|
873 | - $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
|
874 | - elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) |
|
875 | - $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
876 | - elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) |
|
877 | - $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
878 | - elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) |
|
879 | - $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
880 | - elseif ( strpos( $redirect_to, 'about.php?updated' ) ) |
|
881 | - $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
895 | + if ( isset($_GET['loggedout']) && true == $_GET['loggedout'] ) { |
|
896 | + $errors->add('loggedout', __('You are now logged out.'), 'message'); |
|
897 | + } elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) { |
|
898 | + $errors->add('registerdisabled', __('User registration is currently not allowed.')); |
|
899 | + } elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) { |
|
900 | + $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message'); |
|
901 | + } elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) { |
|
902 | + $errors->add('newpass', __('Check your e-mail for your new password.'), 'message'); |
|
903 | + } elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) { |
|
904 | + $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message'); |
|
905 | + } elseif ( strpos( $redirect_to, 'about.php?updated' ) ) { |
|
906 | + $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what’s new.' ), 'message' ); |
|
907 | + } |
|
882 | 908 | } |
883 | 909 | |
884 | 910 | /** |
@@ -892,13 +918,15 @@ discard block |
||
892 | 918 | $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); |
893 | 919 | |
894 | 920 | // Clear any stale cookies. |
895 | - if ( $reauth ) |
|
896 | - wp_clear_auth_cookie(); |
|
921 | + if ( $reauth ) { |
|
922 | + wp_clear_auth_cookie(); |
|
923 | + } |
|
897 | 924 | |
898 | 925 | login_header(__('Log In'), '', $errors); |
899 | 926 | |
900 | - if ( isset($_POST['log']) ) |
|
901 | - $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
927 | + if ( isset($_POST['log']) ) { |
|
928 | + $user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : ''; |
|
929 | + } |
|
902 | 930 | $rememberme = ! empty( $_POST['rememberme'] ); |
903 | 931 | |
904 | 932 | if ( ! empty( $errors->errors ) ) { |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Loads the WordPress environment and template. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - */ |
|
3 | + * Loads the WordPress environment and template. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | if ( !isset($wp_did_header) ) { |
9 | 9 |
@@ -5,14 +5,14 @@ |
||
5 | 5 | * @package WordPress |
6 | 6 | */ |
7 | 7 | |
8 | -if ( !isset($wp_did_header) ) { |
|
8 | +if ( ! isset($wp_did_header)) { |
|
9 | 9 | |
10 | 10 | $wp_did_header = true; |
11 | 11 | |
12 | - require_once( dirname(__FILE__) . '/wp-load.php' ); |
|
12 | + require_once(dirname(__FILE__).'/wp-load.php'); |
|
13 | 13 | |
14 | 14 | wp(); |
15 | 15 | |
16 | - require_once( ABSPATH . WPINC . '/template-loader.php' ); |
|
16 | + require_once(ABSPATH.WPINC.'/template-loader.php'); |
|
17 | 17 | |
18 | 18 | } |
@@ -43,15 +43,15 @@ |
||
43 | 43 | <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" /> |
44 | 44 | <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" /> |
45 | 45 | <?php |
46 | - /** |
|
47 | - * Add additional APIs to the Really Simple Discovery (RSD) endpoint. |
|
48 | - * |
|
49 | - * @link http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html |
|
46 | + /** |
|
47 | + * Add additional APIs to the Really Simple Discovery (RSD) endpoint. |
|
50 | 48 | * |
51 | - * @since 3.5.0 |
|
52 | - */ |
|
53 | - do_action( 'xmlrpc_rsd_apis' ); |
|
54 | - ?> |
|
49 | + * @link http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html |
|
50 | + * |
|
51 | + * @since 3.5.0 |
|
52 | + */ |
|
53 | + do_action( 'xmlrpc_rsd_apis' ); |
|
54 | + ?> |
|
55 | 55 | </apis> |
56 | 56 | </service> |
57 | 57 | </rsd> |
@@ -17,19 +17,19 @@ discard block |
||
17 | 17 | |
18 | 18 | // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, |
19 | 19 | // but we can do it ourself. |
20 | -if ( !isset( $HTTP_RAW_POST_DATA ) ) { |
|
21 | - $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); |
|
20 | +if ( ! isset($HTTP_RAW_POST_DATA)) { |
|
21 | + $HTTP_RAW_POST_DATA = file_get_contents('php://input'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | // fix for mozBlog and other cases where '<?xml' isn't on the very first line |
25 | -if ( isset($HTTP_RAW_POST_DATA) ) |
|
25 | +if (isset($HTTP_RAW_POST_DATA)) |
|
26 | 26 | $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); |
27 | 27 | |
28 | 28 | /** Include the bootstrap for setting up WordPress environment */ |
29 | -include( dirname( __FILE__ ) . '/wp-load.php' ); |
|
29 | +include(dirname(__FILE__).'/wp-load.php'); |
|
30 | 30 | |
31 | -if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html |
|
32 | -header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); |
|
31 | +if (isset($_GET['rsd'])) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html |
|
32 | +header('Content-Type: text/xml; charset='.get_option('blog_charset'), true); |
|
33 | 33 | ?> |
34 | 34 | <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> |
35 | 35 | <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd"> |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @since 3.5.0 |
52 | 52 | */ |
53 | - do_action( 'xmlrpc_rsd_apis' ); |
|
53 | + do_action('xmlrpc_rsd_apis'); |
|
54 | 54 | ?> |
55 | 55 | </apis> |
56 | 56 | </service> |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | exit; |
60 | 60 | } |
61 | 61 | |
62 | -include_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
63 | -include_once(ABSPATH . WPINC . '/class-IXR.php'); |
|
64 | -include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php'); |
|
62 | +include_once(ABSPATH.'wp-admin/includes/admin.php'); |
|
63 | +include_once(ABSPATH.WPINC.'/class-IXR.php'); |
|
64 | +include_once(ABSPATH.WPINC.'/class-wp-xmlrpc-server.php'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Posts submitted via the XML-RPC interface get that title |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param string $class The name of the XML-RPC server class. |
79 | 79 | */ |
80 | -$wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' ); |
|
80 | +$wp_xmlrpc_server_class = apply_filters('wp_xmlrpc_server_class', 'wp_xmlrpc_server'); |
|
81 | 81 | $wp_xmlrpc_server = new $wp_xmlrpc_server_class; |
82 | 82 | |
83 | 83 | // Fire off the request |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @param string $io Whether input or output |
95 | 95 | * @param string $msg Information describing logging reason. |
96 | 96 | */ |
97 | -function logIO( $io, $msg ) { |
|
98 | - _deprecated_function( __FUNCTION__, '3.4', 'error_log()' ); |
|
99 | - if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) |
|
100 | - error_log( $io . ' - ' . $msg ); |
|
97 | +function logIO($io, $msg) { |
|
98 | + _deprecated_function(__FUNCTION__, '3.4', 'error_log()'); |
|
99 | + if ( ! empty($GLOBALS['xmlrpc_logging'])) |
|
100 | + error_log($io.' - '.$msg); |
|
101 | 101 | } |
102 | 102 | \ No newline at end of file |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | // fix for mozBlog and other cases where '<?xml' isn't on the very first line |
25 | -if ( isset($HTTP_RAW_POST_DATA) ) |
|
25 | +if ( isset($HTTP_RAW_POST_DATA) ) { |
|
26 | 26 | $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); |
27 | +} |
|
27 | 28 | |
28 | 29 | /** Include the bootstrap for setting up WordPress environment */ |
29 | 30 | include( dirname( __FILE__ ) . '/wp-load.php' ); |
@@ -96,6 +97,7 @@ discard block |
||
96 | 97 | */ |
97 | 98 | function logIO( $io, $msg ) { |
98 | 99 | _deprecated_function( __FUNCTION__, '3.4', 'error_log()' ); |
99 | - if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) |
|
100 | - error_log( $io . ' - ' . $msg ); |
|
101 | -} |
|
102 | 100 | \ No newline at end of file |
101 | + if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) { |
|
102 | + error_log( $io . ' - ' . $msg ); |
|
103 | + } |
|
104 | + } |
|
103 | 105 | \ No newline at end of file |
@@ -723,10 +723,10 @@ |
||
723 | 723 | </div> |
724 | 724 | <?php |
725 | 725 | /** |
726 | - * Fires after the sign-up forms, before wp_footer. |
|
727 | - * |
|
728 | - * @since 3.0.0 |
|
729 | - */ |
|
726 | + * Fires after the sign-up forms, before wp_footer. |
|
727 | + * |
|
728 | + * @since 3.0.0 |
|
729 | + */ |
|
730 | 730 | do_action( 'after_signup_form' ); ?> |
731 | 731 | |
732 | 732 | <?php get_footer(); ?> |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** Sets up the WordPress Environment. */ |
4 | -require( dirname(__FILE__) . '/wp-load.php' ); |
|
4 | +require(dirname(__FILE__).'/wp-load.php'); |
|
5 | 5 | |
6 | -add_action( 'wp_head', 'wp_no_robots' ); |
|
6 | +add_action('wp_head', 'wp_no_robots'); |
|
7 | 7 | |
8 | -require( dirname( __FILE__ ) . '/wp-blog-header.php' ); |
|
8 | +require(dirname(__FILE__).'/wp-blog-header.php'); |
|
9 | 9 | |
10 | -if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) { |
|
11 | - wp_redirect( network_home_url() ); |
|
10 | +if (is_array(get_site_option('illegal_names')) && isset($_GET['new']) && in_array($_GET['new'], get_site_option('illegal_names'))) { |
|
11 | + wp_redirect(network_home_url()); |
|
12 | 12 | die(); |
13 | 13 | } |
14 | 14 | |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @since 3.0.0 |
25 | 25 | */ |
26 | - do_action( 'signup_header' ); |
|
26 | + do_action('signup_header'); |
|
27 | 27 | } |
28 | -add_action( 'wp_head', 'do_signup_header' ); |
|
28 | +add_action('wp_head', 'do_signup_header'); |
|
29 | 29 | |
30 | -if ( !is_multisite() ) { |
|
31 | - wp_redirect( site_url('wp-login.php?action=register') ); |
|
30 | +if ( ! is_multisite()) { |
|
31 | + wp_redirect(site_url('wp-login.php?action=register')); |
|
32 | 32 | die(); |
33 | 33 | } |
34 | 34 | |
35 | -if ( !is_main_site() ) { |
|
36 | - wp_redirect( network_site_url( 'wp-signup.php' ) ); |
|
35 | +if ( ! is_main_site()) { |
|
36 | + wp_redirect(network_site_url('wp-signup.php')); |
|
37 | 37 | die(); |
38 | 38 | } |
39 | 39 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <?php |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'wp_head', 'wpmu_signup_stylesheet' ); |
|
68 | +add_action('wp_head', 'wpmu_signup_stylesheet'); |
|
69 | 69 | get_header(); |
70 | 70 | |
71 | 71 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @since 3.0.0 |
75 | 75 | */ |
76 | -do_action( 'before_signup_form' ); |
|
76 | +do_action('before_signup_form'); |
|
77 | 77 | ?> |
78 | 78 | <div id="content" class="widecolumn"> |
79 | 79 | <div class="mu_register"> |
@@ -87,35 +87,35 @@ discard block |
||
87 | 87 | * @param string $blog_title The new site title |
88 | 88 | * @param array $errors |
89 | 89 | */ |
90 | -function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { |
|
90 | +function show_blog_form($blogname = '', $blog_title = '', $errors = '') { |
|
91 | 91 | $current_site = get_current_site(); |
92 | 92 | // Blog name |
93 | - if ( !is_subdomain_install() ) |
|
94 | - echo '<label for="blogname">' . __('Site Name:') . '</label>'; |
|
93 | + if ( ! is_subdomain_install()) |
|
94 | + echo '<label for="blogname">'.__('Site Name:').'</label>'; |
|
95 | 95 | else |
96 | - echo '<label for="blogname">' . __('Site Domain:') . '</label>'; |
|
96 | + echo '<label for="blogname">'.__('Site Domain:').'</label>'; |
|
97 | 97 | |
98 | - if ( $errmsg = $errors->get_error_message('blogname') ) { ?> |
|
98 | + if ($errmsg = $errors->get_error_message('blogname')) { ?> |
|
99 | 99 | <p class="error"><?php echo $errmsg ?></p> |
100 | 100 | <?php } |
101 | 101 | |
102 | - if ( !is_subdomain_install() ) |
|
103 | - echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />'; |
|
102 | + if ( ! is_subdomain_install()) |
|
103 | + echo '<span class="prefix_address">'.$current_site->domain.$current_site->path.'</span><input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><br />'; |
|
104 | 104 | else |
105 | - echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />'; |
|
105 | + echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.'.($site_domain = preg_replace('|^www\.|', '', $current_site->domain)).'</span><br />'; |
|
106 | 106 | |
107 | - if ( !is_user_logged_in() ) { |
|
108 | - if ( !is_subdomain_install() ) |
|
109 | - $site = $current_site->domain . $current_site->path . __( 'sitename' ); |
|
107 | + if ( ! is_user_logged_in()) { |
|
108 | + if ( ! is_subdomain_install()) |
|
109 | + $site = $current_site->domain.$current_site->path.__('sitename'); |
|
110 | 110 | else |
111 | - $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; |
|
112 | - echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>'; |
|
111 | + $site = __('domain').'.'.$site_domain.$current_site->path; |
|
112 | + echo '<p>(<strong>'.sprintf(__('Your address will be %s.'), $site).'</strong>) '.__('Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!').'</p>'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // Blog Title |
116 | 116 | ?> |
117 | 117 | <label for="blog_title"><?php _e('Site Title:') ?></label> |
118 | - <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> |
|
118 | + <?php if ($errmsg = $errors->get_error_message('blog_title')) { ?> |
|
119 | 119 | <p class="error"><?php echo $errmsg ?></p> |
120 | 120 | <?php } |
121 | 121 | echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />'; |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | <div id="privacy"> |
125 | 125 | <p class="privacy-intro"> |
126 | 126 | <label for="blog_public_on"><?php _e('Privacy:') ?></label> |
127 | - <?php _e( 'Allow search engines to index this site.' ); ?> |
|
127 | + <?php _e('Allow search engines to index this site.'); ?> |
|
128 | 128 | <br style="clear:both" /> |
129 | 129 | <label class="checkbox" for="blog_public_on"> |
130 | - <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> /> |
|
131 | - <strong><?php _e( 'Yes' ); ?></strong> |
|
130 | + <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( ! isset($_POST['blog_public']) || $_POST['blog_public'] == '1') { ?>checked="checked"<?php } ?> /> |
|
131 | + <strong><?php _e('Yes'); ?></strong> |
|
132 | 132 | </label> |
133 | 133 | <label class="checkbox" for="blog_public_off"> |
134 | - <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> /> |
|
135 | - <strong><?php _e( 'No' ); ?></strong> |
|
134 | + <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if (isset($_POST['blog_public']) && $_POST['blog_public'] == '0') { ?>checked="checked"<?php } ?> /> |
|
135 | + <strong><?php _e('No'); ?></strong> |
|
136 | 136 | </label> |
137 | 137 | </p> |
138 | 138 | </div> |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param array $errors An array possibly containing 'blogname' or 'blog_title' errors. |
147 | 147 | */ |
148 | - do_action( 'signup_blogform', $errors ); |
|
148 | + do_action('signup_blogform', $errors); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function validate_blog_form() { |
159 | 159 | $user = ''; |
160 | - if ( is_user_logged_in() ) |
|
160 | + if (is_user_logged_in()) |
|
161 | 161 | $user = wp_get_current_user(); |
162 | 162 | |
163 | 163 | return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); |
@@ -174,22 +174,22 @@ discard block |
||
174 | 174 | */ |
175 | 175 | function show_user_form($user_name = '', $user_email = '', $errors = '') { |
176 | 176 | // User name |
177 | - echo '<label for="user_name">' . __('Username:') . '</label>'; |
|
178 | - if ( $errmsg = $errors->get_error_message('user_name') ) { |
|
177 | + echo '<label for="user_name">'.__('Username:').'</label>'; |
|
178 | + if ($errmsg = $errors->get_error_message('user_name')) { |
|
179 | 179 | echo '<p class="error">'.$errmsg.'</p>'; |
180 | 180 | } |
181 | - echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />'; |
|
182 | - _e( '(Must be at least 4 characters, letters and numbers only.)' ); |
|
181 | + echo '<input name="user_name" type="text" id="user_name" value="'.esc_attr($user_name).'" maxlength="60" /><br />'; |
|
182 | + _e('(Must be at least 4 characters, letters and numbers only.)'); |
|
183 | 183 | ?> |
184 | 184 | |
185 | - <label for="user_email"><?php _e( 'Email Address:' ) ?></label> |
|
186 | - <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> |
|
185 | + <label for="user_email"><?php _e('Email Address:') ?></label> |
|
186 | + <?php if ($errmsg = $errors->get_error_message('user_email')) { ?> |
|
187 | 187 | <p class="error"><?php echo $errmsg ?></p> |
188 | 188 | <?php } ?> |
189 | 189 | <input name="user_email" type="email" id="user_email" value="<?php echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?> |
190 | 190 | <?php |
191 | - if ( $errmsg = $errors->get_error_message('generic') ) { |
|
192 | - echo '<p class="error">' . $errmsg . '</p>'; |
|
191 | + if ($errmsg = $errors->get_error_message('generic')) { |
|
192 | + echo '<p class="error">'.$errmsg.'</p>'; |
|
193 | 193 | } |
194 | 194 | /** |
195 | 195 | * Fires at the end of the user registration form on the site sign-up form. |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @param array $errors An array possibly containing 'user_name' or 'user_email' errors. |
200 | 200 | */ |
201 | - do_action( 'signup_extra_fields', $errors ); |
|
201 | + do_action('signup_extra_fields', $errors); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param string $blog_title The new blog title |
222 | 222 | * @param array $errors |
223 | 223 | */ |
224 | -function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { |
|
224 | +function signup_another_blog($blogname = '', $blog_title = '', $errors = '') { |
|
225 | 225 | $current_user = wp_get_current_user(); |
226 | 226 | |
227 | - if ( ! is_wp_error($errors) ) { |
|
227 | + if ( ! is_wp_error($errors)) { |
|
228 | 228 | $errors = new WP_Error(); |
229 | 229 | } |
230 | 230 | |
@@ -247,34 +247,34 @@ discard block |
||
247 | 247 | * @type array $errors An array possibly containing 'blogname' or 'blog_title' errors. |
248 | 248 | * } |
249 | 249 | */ |
250 | - $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); |
|
250 | + $filtered_results = apply_filters('signup_another_blog_init', $signup_defaults); |
|
251 | 251 | |
252 | 252 | $blogname = $filtered_results['blogname']; |
253 | 253 | $blog_title = $filtered_results['blog_title']; |
254 | 254 | $errors = $filtered_results['errors']; |
255 | 255 | |
256 | - echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_current_site()->site_name ) . '</h2>'; |
|
256 | + echo '<h2>'.sprintf(__('Get <em>another</em> %s site in seconds'), get_current_site()->site_name).'</h2>'; |
|
257 | 257 | |
258 | - if ( $errors->get_error_code() ) { |
|
259 | - echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; |
|
258 | + if ($errors->get_error_code()) { |
|
259 | + echo '<p>'.__('There was a problem, please correct the form below and try again.').'</p>'; |
|
260 | 260 | } |
261 | 261 | ?> |
262 | - <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ) ?></p> |
|
262 | + <p><?php printf(__('Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!'), $current_user->display_name) ?></p> |
|
263 | 263 | |
264 | 264 | <?php |
265 | 265 | $blogs = get_blogs_of_user($current_user->ID); |
266 | - if ( !empty($blogs) ) { ?> |
|
266 | + if ( ! empty($blogs)) { ?> |
|
267 | 267 | |
268 | - <p><?php _e( 'Sites you are already a member of:' ) ?></p> |
|
268 | + <p><?php _e('Sites you are already a member of:') ?></p> |
|
269 | 269 | <ul> |
270 | - <?php foreach ( $blogs as $blog ) { |
|
271 | - $home_url = get_home_url( $blog->userblog_id ); |
|
272 | - echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; |
|
270 | + <?php foreach ($blogs as $blog) { |
|
271 | + $home_url = get_home_url($blog->userblog_id); |
|
272 | + echo '<li><a href="'.esc_url($home_url).'">'.$home_url.'</a></li>'; |
|
273 | 273 | } ?> |
274 | 274 | </ul> |
275 | 275 | <?php } ?> |
276 | 276 | |
277 | - <p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p> |
|
277 | + <p><?php _e('If you’re not going to use a great site domain, leave it for a new user. Now have at it!') ?></p> |
|
278 | 278 | <form id="setupform" method="post" action="wp-signup.php"> |
279 | 279 | <input type="hidden" name="stage" value="gimmeanotherblog" /> |
280 | 280 | <?php |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | * @param string $context A string describing the steps of the sign-up process. The value can be |
287 | 287 | * 'create-another-site', 'validate-user', or 'validate-site'. |
288 | 288 | */ |
289 | - do_action( 'signup_hidden_fields', 'create-another-site' ); |
|
289 | + do_action('signup_hidden_fields', 'create-another-site'); |
|
290 | 290 | ?> |
291 | 291 | <?php show_blog_form($blogname, $blog_title, $errors); ?> |
292 | - <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p> |
|
292 | + <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Create Site') ?>" /></p> |
|
293 | 293 | </form> |
294 | 294 | <?php |
295 | 295 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | function validate_another_blog_signup() { |
306 | 306 | global $wpdb, $blogname, $blog_title, $errors, $domain, $path; |
307 | 307 | $current_user = wp_get_current_user(); |
308 | - if ( ! is_user_logged_in() ) { |
|
308 | + if ( ! is_user_logged_in()) { |
|
309 | 309 | die(); |
310 | 310 | } |
311 | 311 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $blog_title = $result['blog_title']; |
319 | 319 | $errors = $result['errors']; |
320 | 320 | |
321 | - if ( $errors->get_error_code() ) { |
|
321 | + if ($errors->get_error_code()) { |
|
322 | 322 | signup_another_blog($blogname, $blog_title, $errors); |
323 | 323 | return false; |
324 | 324 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param array $blog_meta_defaults An array of default blog meta variables. |
340 | 340 | */ |
341 | - $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults ); |
|
341 | + $meta_defaults = apply_filters('signup_create_blog_meta', $blog_meta_defaults); |
|
342 | 342 | /** |
343 | 343 | * Filter the new default site meta variables. |
344 | 344 | * |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false. |
352 | 352 | * } |
353 | 353 | */ |
354 | - $meta = apply_filters( 'add_signup_meta', $meta_defaults ); |
|
354 | + $meta = apply_filters('add_signup_meta', $meta_defaults); |
|
355 | 355 | |
356 | - wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid ); |
|
356 | + wpmu_create_blog($domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid); |
|
357 | 357 | confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); |
358 | 358 | return true; |
359 | 359 | } |
@@ -369,11 +369,11 @@ discard block |
||
369 | 369 | * @param string $user_email The user's email address |
370 | 370 | * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup() |
371 | 371 | */ |
372 | -function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array() ) { |
|
372 | +function confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email = '', $meta = array()) { |
|
373 | 373 | ?> |
374 | - <h2><?php printf( __( 'The site %s is yours.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> |
|
374 | + <h2><?php printf(__('The site %s is yours.'), "<a href='http://{$domain}{$path}'>{$blog_title}</a>") ?></h2> |
|
375 | 375 | <p> |
376 | - <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name ) ?> |
|
376 | + <?php printf(__('<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.'), $domain.$path, $domain.$path, "http://".$domain.$path."wp-login.php", $user_name) ?> |
|
377 | 377 | </p> |
378 | 378 | <?php |
379 | 379 | /** |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @since 3.0.0 |
383 | 383 | */ |
384 | - do_action( 'signup_finished' ); |
|
384 | + do_action('signup_finished'); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -393,13 +393,13 @@ discard block |
||
393 | 393 | * @param string $user_email The user's email |
394 | 394 | * @param array $errors |
395 | 395 | */ |
396 | -function signup_user( $user_name = '', $user_email = '', $errors = '' ) { |
|
396 | +function signup_user($user_name = '', $user_email = '', $errors = '') { |
|
397 | 397 | global $active_signup; |
398 | 398 | |
399 | - if ( !is_wp_error($errors) ) |
|
399 | + if ( ! is_wp_error($errors)) |
|
400 | 400 | $errors = new WP_Error(); |
401 | 401 | |
402 | - $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; |
|
402 | + $signup_for = isset($_POST['signup_for']) ? esc_html($_POST['signup_for']) : 'blog'; |
|
403 | 403 | |
404 | 404 | $signup_user_defaults = array( |
405 | 405 | 'user_name' => $user_name, |
@@ -420,32 +420,32 @@ discard block |
||
420 | 420 | * @type array $errors An array of possible errors relevant to the sign-up user. |
421 | 421 | * } |
422 | 422 | */ |
423 | - $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults ); |
|
423 | + $filtered_results = apply_filters('signup_user_init', $signup_user_defaults); |
|
424 | 424 | $user_name = $filtered_results['user_name']; |
425 | 425 | $user_email = $filtered_results['user_email']; |
426 | 426 | $errors = $filtered_results['errors']; |
427 | 427 | |
428 | 428 | ?> |
429 | 429 | |
430 | - <h2><?php printf( __( 'Get your own %s account in seconds' ), get_current_site()->site_name ) ?></h2> |
|
430 | + <h2><?php printf(__('Get your own %s account in seconds'), get_current_site()->site_name) ?></h2> |
|
431 | 431 | <form id="setupform" method="post" action="wp-signup.php" novalidate="novalidate"> |
432 | 432 | <input type="hidden" name="stage" value="validate-user-signup" /> |
433 | 433 | <?php |
434 | 434 | /** This action is documented in wp-signup.php */ |
435 | - do_action( 'signup_hidden_fields', 'validate-user' ); |
|
435 | + do_action('signup_hidden_fields', 'validate-user'); |
|
436 | 436 | ?> |
437 | 437 | <?php show_user_form($user_name, $user_email, $errors); ?> |
438 | 438 | |
439 | 439 | <p> |
440 | - <?php if ( $active_signup == 'blog' ) { ?> |
|
440 | + <?php if ($active_signup == 'blog') { ?> |
|
441 | 441 | <input id="signupblog" type="hidden" name="signup_for" value="blog" /> |
442 | - <?php } elseif ( $active_signup == 'user' ) { ?> |
|
442 | + <?php } elseif ($active_signup == 'user') { ?> |
|
443 | 443 | <input id="signupblog" type="hidden" name="signup_for" value="user" /> |
444 | 444 | <?php } else { ?> |
445 | - <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> /> |
|
445 | + <input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked($signup_for, 'blog'); ?> /> |
|
446 | 446 | <label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label> |
447 | 447 | <br /> |
448 | - <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> /> |
|
448 | + <input id="signupuser" type="radio" name="signup_for" value="user" <?php checked($signup_for, 'user'); ?> /> |
|
449 | 449 | <label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label> |
450 | 450 | <?php } ?> |
451 | 451 | </p> |
@@ -468,18 +468,18 @@ discard block |
||
468 | 468 | $user_email = $result['user_email']; |
469 | 469 | $errors = $result['errors']; |
470 | 470 | |
471 | - if ( $errors->get_error_code() ) { |
|
471 | + if ($errors->get_error_code()) { |
|
472 | 472 | signup_user($user_name, $user_email, $errors); |
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - if ( 'blog' == $_POST['signup_for'] ) { |
|
476 | + if ('blog' == $_POST['signup_for']) { |
|
477 | 477 | signup_blog($user_name, $user_email); |
478 | 478 | return false; |
479 | 479 | } |
480 | 480 | |
481 | 481 | /** This filter is documented in wp-signup.php */ |
482 | - wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) ); |
|
482 | + wpmu_signup_user($user_name, $user_email, apply_filters('add_signup_meta', array())); |
|
483 | 483 | |
484 | 484 | confirm_user_signup($user_name, $user_email); |
485 | 485 | return true; |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | */ |
496 | 496 | function confirm_user_signup($user_name, $user_email) { |
497 | 497 | ?> |
498 | - <h2><?php printf( __( '%s is your new username' ), $user_name) ?></h2> |
|
499 | - <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p> |
|
500 | - <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email ); ?></p> |
|
501 | - <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p> |
|
498 | + <h2><?php printf(__('%s is your new username'), $user_name) ?></h2> |
|
499 | + <p><?php _e('But, before you can start using your new username, <strong>you must activate it</strong>.') ?></p> |
|
500 | + <p><?php printf(__('Check your inbox at <strong>%s</strong> and click the link given.'), $user_email); ?></p> |
|
501 | + <p><?php _e('If you do not activate your username within two days, you will have to sign up again.'); ?></p> |
|
502 | 502 | <?php |
503 | 503 | /** This action is documented in wp-signup.php */ |
504 | - do_action( 'signup_finished' ); |
|
504 | + do_action('signup_finished'); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @param array $errors |
517 | 517 | */ |
518 | 518 | function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { |
519 | - if ( !is_wp_error($errors) ) |
|
519 | + if ( ! is_wp_error($errors)) |
|
520 | 520 | $errors = new WP_Error(); |
521 | 521 | |
522 | 522 | $signup_blog_defaults = array( |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @type array $errors An array of possible errors relevant to new site creation variables. |
543 | 543 | * } |
544 | 544 | */ |
545 | - $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults ); |
|
545 | + $filtered_results = apply_filters('signup_blog_init', $signup_blog_defaults); |
|
546 | 546 | |
547 | 547 | $user_name = $filtered_results['user_name']; |
548 | 548 | $user_email = $filtered_results['user_email']; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | $blog_title = $filtered_results['blog_title']; |
551 | 551 | $errors = $filtered_results['errors']; |
552 | 552 | |
553 | - if ( empty($blogname) ) |
|
553 | + if (empty($blogname)) |
|
554 | 554 | $blogname = $user_name; |
555 | 555 | ?> |
556 | 556 | <form id="setupform" method="post" action="wp-signup.php"> |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" /> |
560 | 560 | <?php |
561 | 561 | /** This action is documented in wp-signup.php */ |
562 | - do_action( 'signup_hidden_fields', 'validate-site' ); |
|
562 | + do_action('signup_hidden_fields', 'validate-site'); |
|
563 | 563 | ?> |
564 | 564 | <?php show_blog_form($blogname, $blog_title, $errors); ?> |
565 | 565 | <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p> |
@@ -576,33 +576,33 @@ discard block |
||
576 | 576 | */ |
577 | 577 | function validate_blog_signup() { |
578 | 578 | // Re-validate user info. |
579 | - $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] ); |
|
579 | + $user_result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); |
|
580 | 580 | $user_name = $user_result['user_name']; |
581 | 581 | $user_email = $user_result['user_email']; |
582 | 582 | $user_errors = $user_result['errors']; |
583 | 583 | |
584 | - if ( $user_errors->get_error_code() ) { |
|
585 | - signup_user( $user_name, $user_email, $user_errors ); |
|
584 | + if ($user_errors->get_error_code()) { |
|
585 | + signup_user($user_name, $user_email, $user_errors); |
|
586 | 586 | return false; |
587 | 587 | } |
588 | 588 | |
589 | - $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] ); |
|
589 | + $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']); |
|
590 | 590 | $domain = $result['domain']; |
591 | 591 | $path = $result['path']; |
592 | 592 | $blogname = $result['blogname']; |
593 | 593 | $blog_title = $result['blog_title']; |
594 | 594 | $errors = $result['errors']; |
595 | 595 | |
596 | - if ( $errors->get_error_code() ) { |
|
596 | + if ($errors->get_error_code()) { |
|
597 | 597 | signup_blog($user_name, $user_email, $blogname, $blog_title, $errors); |
598 | 598 | return false; |
599 | 599 | } |
600 | 600 | |
601 | 601 | $public = (int) $_POST['blog_public']; |
602 | - $signup_meta = array ('lang_id' => 1, 'public' => $public); |
|
602 | + $signup_meta = array('lang_id' => 1, 'public' => $public); |
|
603 | 603 | |
604 | 604 | /** This filter is documented in wp-signup.php */ |
605 | - $meta = apply_filters( 'add_signup_meta', $signup_meta ); |
|
605 | + $meta = apply_filters('add_signup_meta', $signup_meta); |
|
606 | 606 | |
607 | 607 | wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); |
608 | 608 | confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); |
@@ -621,29 +621,29 @@ discard block |
||
621 | 621 | * @param string $user_email The user's email address |
622 | 622 | * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup() |
623 | 623 | */ |
624 | -function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) { |
|
624 | +function confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array()) { |
|
625 | 625 | ?> |
626 | - <h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> |
|
626 | + <h2><?php printf(__('Congratulations! Your new site, %s, is almost ready.'), "<a href='http://{$domain}{$path}'>{$blog_title}</a>") ?></h2> |
|
627 | 627 | |
628 | - <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p> |
|
629 | - <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email) ?></p> |
|
630 | - <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p> |
|
631 | - <h2><?php _e( 'Still waiting for your email?' ); ?></h2> |
|
628 | + <p><?php _e('But, before you can start using your site, <strong>you must activate it</strong>.') ?></p> |
|
629 | + <p><?php printf(__('Check your inbox at <strong>%s</strong> and click the link given.'), $user_email) ?></p> |
|
630 | + <p><?php _e('If you do not activate your site within two days, you will have to sign up again.'); ?></p> |
|
631 | + <h2><?php _e('Still waiting for your email?'); ?></h2> |
|
632 | 632 | <p> |
633 | - <?php _e( 'If you haven’t received your email yet, there are a number of things you can do:' ) ?> |
|
633 | + <?php _e('If you haven’t received your email yet, there are a number of things you can do:') ?> |
|
634 | 634 | <ul id="noemail-tips"> |
635 | - <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li> |
|
636 | - <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li> |
|
637 | - <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.' ), $user_email ) ?></li> |
|
635 | + <li><p><strong><?php _e('Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.') ?></strong></p></li> |
|
636 | + <li><p><?php _e('Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.') ?></p></li> |
|
637 | + <li><?php printf(__('Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.'), $user_email) ?></li> |
|
638 | 638 | </ul> |
639 | 639 | </p> |
640 | 640 | <?php |
641 | 641 | /** This action is documented in wp-signup.php */ |
642 | - do_action( 'signup_finished' ); |
|
642 | + do_action('signup_finished'); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | // Main |
646 | -$active_signup = get_site_option( 'registration', 'none' ); |
|
646 | +$active_signup = get_site_option('registration', 'none'); |
|
647 | 647 | /** |
648 | 648 | * Filter the type of site sign-up. |
649 | 649 | * |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | * @param string $active_signup String that returns registration type. The value can be |
653 | 653 | * 'all', 'none', 'blog', or 'user'. |
654 | 654 | */ |
655 | -$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); |
|
655 | +$active_signup = apply_filters('wpmu_active_signup', $active_signup); |
|
656 | 656 | |
657 | 657 | // Make the signup type translatable. |
658 | 658 | $i18n_signup['all'] = _x('all', 'Multisite active signup type'); |
@@ -660,60 +660,60 @@ discard block |
||
660 | 660 | $i18n_signup['blog'] = _x('blog', 'Multisite active signup type'); |
661 | 661 | $i18n_signup['user'] = _x('user', 'Multisite active signup type'); |
662 | 662 | |
663 | -if ( is_super_admin() ) |
|
664 | - echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>'; |
|
663 | +if (is_super_admin()) |
|
664 | + echo '<div class="mu_alert">'.sprintf(__('Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your <a href="%s">Options page</a>.'), $i18n_signup[$active_signup], esc_url(network_admin_url('settings.php'))).'</div>'; |
|
665 | 665 | |
666 | 666 | $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; |
667 | 667 | |
668 | 668 | $current_user = wp_get_current_user(); |
669 | -if ( $active_signup == 'none' ) { |
|
670 | - _e( 'Registration has been disabled.' ); |
|
671 | -} elseif ( $active_signup == 'blog' && !is_user_logged_in() ) { |
|
672 | - $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( network_site_url( 'wp-signup.php' ) ) ); |
|
673 | - echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); |
|
669 | +if ($active_signup == 'none') { |
|
670 | + _e('Registration has been disabled.'); |
|
671 | +} elseif ($active_signup == 'blog' && ! is_user_logged_in()) { |
|
672 | + $login_url = site_url('wp-login.php?redirect_to='.urlencode(network_site_url('wp-signup.php'))); |
|
673 | + echo sprintf(__('You must first <a href="%s">log in</a>, and then you can create a new site.'), $login_url); |
|
674 | 674 | } else { |
675 | - $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; |
|
676 | - switch ( $stage ) { |
|
675 | + $stage = isset($_POST['stage']) ? $_POST['stage'] : 'default'; |
|
676 | + switch ($stage) { |
|
677 | 677 | case 'validate-user-signup' : |
678 | - if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) |
|
678 | + if ($active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user') |
|
679 | 679 | validate_user_signup(); |
680 | 680 | else |
681 | - _e( 'User registration has been disabled.' ); |
|
681 | + _e('User registration has been disabled.'); |
|
682 | 682 | break; |
683 | 683 | case 'validate-blog-signup': |
684 | - if ( $active_signup == 'all' || $active_signup == 'blog' ) |
|
684 | + if ($active_signup == 'all' || $active_signup == 'blog') |
|
685 | 685 | validate_blog_signup(); |
686 | 686 | else |
687 | - _e( 'Site registration has been disabled.' ); |
|
687 | + _e('Site registration has been disabled.'); |
|
688 | 688 | break; |
689 | 689 | case 'gimmeanotherblog': |
690 | 690 | validate_another_blog_signup(); |
691 | 691 | break; |
692 | 692 | case 'default': |
693 | 693 | default : |
694 | - $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : ''; |
|
694 | + $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; |
|
695 | 695 | /** |
696 | 696 | * Fires when the site sign-up form is sent. |
697 | 697 | * |
698 | 698 | * @since 3.0.0 |
699 | 699 | */ |
700 | - do_action( 'preprocess_signup_form' ); |
|
701 | - if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) |
|
700 | + do_action('preprocess_signup_form'); |
|
701 | + if (is_user_logged_in() && ($active_signup == 'all' || $active_signup == 'blog')) |
|
702 | 702 | signup_another_blog($newblogname); |
703 | - elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) |
|
704 | - signup_user( $newblogname, $user_email ); |
|
705 | - elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) |
|
706 | - _e( 'Sorry, new registrations are not allowed at this time.' ); |
|
703 | + elseif ( ! is_user_logged_in() && ($active_signup == 'all' || $active_signup == 'user')) |
|
704 | + signup_user($newblogname, $user_email); |
|
705 | + elseif ( ! is_user_logged_in() && ($active_signup == 'blog')) |
|
706 | + _e('Sorry, new registrations are not allowed at this time.'); |
|
707 | 707 | else |
708 | - _e( 'You are logged in already. No need to register again!' ); |
|
708 | + _e('You are logged in already. No need to register again!'); |
|
709 | 709 | |
710 | - if ( $newblogname ) { |
|
711 | - $newblog = get_blogaddress_by_name( $newblogname ); |
|
710 | + if ($newblogname) { |
|
711 | + $newblog = get_blogaddress_by_name($newblogname); |
|
712 | 712 | |
713 | - if ( $active_signup == 'blog' || $active_signup == 'all' ) |
|
714 | - printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog ); |
|
713 | + if ($active_signup == 'blog' || $active_signup == 'all') |
|
714 | + printf('<p><em>'.__('The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!').'</em></p>', $newblog); |
|
715 | 715 | else |
716 | - printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog ); |
|
716 | + printf('<p><em>'.__('The site you were looking for, <strong>%s</strong>, does not exist.').'</em></p>', $newblog); |
|
717 | 717 | } |
718 | 718 | break; |
719 | 719 | } |
@@ -727,6 +727,6 @@ discard block |
||
727 | 727 | * |
728 | 728 | * @since 3.0.0 |
729 | 729 | */ |
730 | -do_action( 'after_signup_form' ); ?> |
|
730 | +do_action('after_signup_form'); ?> |
|
731 | 731 | |
732 | 732 | <?php get_footer(); ?> |
@@ -90,25 +90,28 @@ discard block |
||
90 | 90 | function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { |
91 | 91 | $current_site = get_current_site(); |
92 | 92 | // Blog name |
93 | - if ( !is_subdomain_install() ) |
|
94 | - echo '<label for="blogname">' . __('Site Name:') . '</label>'; |
|
95 | - else |
|
96 | - echo '<label for="blogname">' . __('Site Domain:') . '</label>'; |
|
93 | + if ( !is_subdomain_install() ) { |
|
94 | + echo '<label for="blogname">' . __('Site Name:') . '</label>'; |
|
95 | + } else { |
|
96 | + echo '<label for="blogname">' . __('Site Domain:') . '</label>'; |
|
97 | + } |
|
97 | 98 | |
98 | 99 | if ( $errmsg = $errors->get_error_message('blogname') ) { ?> |
99 | 100 | <p class="error"><?php echo $errmsg ?></p> |
100 | 101 | <?php } |
101 | 102 | |
102 | - if ( !is_subdomain_install() ) |
|
103 | - echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />'; |
|
104 | - else |
|
105 | - echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />'; |
|
103 | + if ( !is_subdomain_install() ) { |
|
104 | + echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />'; |
|
105 | + } else { |
|
106 | + echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />'; |
|
107 | + } |
|
106 | 108 | |
107 | 109 | if ( !is_user_logged_in() ) { |
108 | - if ( !is_subdomain_install() ) |
|
109 | - $site = $current_site->domain . $current_site->path . __( 'sitename' ); |
|
110 | - else |
|
111 | - $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; |
|
110 | + if ( !is_subdomain_install() ) { |
|
111 | + $site = $current_site->domain . $current_site->path . __( 'sitename' ); |
|
112 | + } else { |
|
113 | + $site = __( 'domain' ) . '.' . $site_domain . $current_site->path; |
|
114 | + } |
|
112 | 115 | echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>'; |
113 | 116 | } |
114 | 117 | |
@@ -157,8 +160,9 @@ discard block |
||
157 | 160 | */ |
158 | 161 | function validate_blog_form() { |
159 | 162 | $user = ''; |
160 | - if ( is_user_logged_in() ) |
|
161 | - $user = wp_get_current_user(); |
|
163 | + if ( is_user_logged_in() ) { |
|
164 | + $user = wp_get_current_user(); |
|
165 | + } |
|
162 | 166 | |
163 | 167 | return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); |
164 | 168 | } |
@@ -396,8 +400,9 @@ discard block |
||
396 | 400 | function signup_user( $user_name = '', $user_email = '', $errors = '' ) { |
397 | 401 | global $active_signup; |
398 | 402 | |
399 | - if ( !is_wp_error($errors) ) |
|
400 | - $errors = new WP_Error(); |
|
403 | + if ( !is_wp_error($errors) ) { |
|
404 | + $errors = new WP_Error(); |
|
405 | + } |
|
401 | 406 | |
402 | 407 | $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog'; |
403 | 408 | |
@@ -516,8 +521,9 @@ discard block |
||
516 | 521 | * @param array $errors |
517 | 522 | */ |
518 | 523 | function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { |
519 | - if ( !is_wp_error($errors) ) |
|
520 | - $errors = new WP_Error(); |
|
524 | + if ( !is_wp_error($errors) ) { |
|
525 | + $errors = new WP_Error(); |
|
526 | + } |
|
521 | 527 | |
522 | 528 | $signup_blog_defaults = array( |
523 | 529 | 'user_name' => $user_name, |
@@ -550,8 +556,9 @@ discard block |
||
550 | 556 | $blog_title = $filtered_results['blog_title']; |
551 | 557 | $errors = $filtered_results['errors']; |
552 | 558 | |
553 | - if ( empty($blogname) ) |
|
554 | - $blogname = $user_name; |
|
559 | + if ( empty($blogname) ) { |
|
560 | + $blogname = $user_name; |
|
561 | + } |
|
555 | 562 | ?> |
556 | 563 | <form id="setupform" method="post" action="wp-signup.php"> |
557 | 564 | <input type="hidden" name="stage" value="validate-blog-signup" /> |
@@ -660,8 +667,9 @@ discard block |
||
660 | 667 | $i18n_signup['blog'] = _x('blog', 'Multisite active signup type'); |
661 | 668 | $i18n_signup['user'] = _x('user', 'Multisite active signup type'); |
662 | 669 | |
663 | -if ( is_super_admin() ) |
|
670 | +if ( is_super_admin() ) { |
|
664 | 671 | echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing “%s” registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>'; |
672 | +} |
|
665 | 673 | |
666 | 674 | $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; |
667 | 675 | |
@@ -675,16 +683,18 @@ discard block |
||
675 | 683 | $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; |
676 | 684 | switch ( $stage ) { |
677 | 685 | case 'validate-user-signup' : |
678 | - if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) |
|
679 | - validate_user_signup(); |
|
680 | - else |
|
681 | - _e( 'User registration has been disabled.' ); |
|
686 | + if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) { |
|
687 | + validate_user_signup(); |
|
688 | + } else { |
|
689 | + _e( 'User registration has been disabled.' ); |
|
690 | + } |
|
682 | 691 | break; |
683 | 692 | case 'validate-blog-signup': |
684 | - if ( $active_signup == 'all' || $active_signup == 'blog' ) |
|
685 | - validate_blog_signup(); |
|
686 | - else |
|
687 | - _e( 'Site registration has been disabled.' ); |
|
693 | + if ( $active_signup == 'all' || $active_signup == 'blog' ) { |
|
694 | + validate_blog_signup(); |
|
695 | + } else { |
|
696 | + _e( 'Site registration has been disabled.' ); |
|
697 | + } |
|
688 | 698 | break; |
689 | 699 | case 'gimmeanotherblog': |
690 | 700 | validate_another_blog_signup(); |
@@ -698,22 +708,24 @@ discard block |
||
698 | 708 | * @since 3.0.0 |
699 | 709 | */ |
700 | 710 | do_action( 'preprocess_signup_form' ); |
701 | - if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) |
|
702 | - signup_another_blog($newblogname); |
|
703 | - elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) |
|
704 | - signup_user( $newblogname, $user_email ); |
|
705 | - elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) |
|
706 | - _e( 'Sorry, new registrations are not allowed at this time.' ); |
|
707 | - else |
|
708 | - _e( 'You are logged in already. No need to register again!' ); |
|
711 | + if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) { |
|
712 | + signup_another_blog($newblogname); |
|
713 | + } elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) { |
|
714 | + signup_user( $newblogname, $user_email ); |
|
715 | + } elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) { |
|
716 | + _e( 'Sorry, new registrations are not allowed at this time.' ); |
|
717 | + } else { |
|
718 | + _e( 'You are logged in already. No need to register again!' ); |
|
719 | + } |
|
709 | 720 | |
710 | 721 | if ( $newblogname ) { |
711 | 722 | $newblog = get_blogaddress_by_name( $newblogname ); |
712 | 723 | |
713 | - if ( $active_signup == 'blog' || $active_signup == 'all' ) |
|
714 | - printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog ); |
|
715 | - else |
|
716 | - printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog ); |
|
724 | + if ( $active_signup == 'blog' || $active_signup == 'all' ) { |
|
725 | + printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog ); |
|
726 | + } else { |
|
727 | + printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog ); |
|
728 | + } |
|
717 | 729 | } |
718 | 730 | break; |
719 | 731 | } |