@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | namespace Subway; |
21 | 21 | |
22 | 22 | if (! defined('ABSPATH') ) { |
23 | - return; |
|
23 | + return; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -36,166 +36,166 @@ discard block |
||
36 | 36 | final class Shortcodes |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Class Constructor. |
|
41 | - * |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - private function __construct() |
|
45 | - { |
|
39 | + /** |
|
40 | + * Class Constructor. |
|
41 | + * |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + private function __construct() |
|
45 | + { |
|
46 | 46 | |
47 | - add_action('init', array( $this, 'register')); |
|
47 | + add_action('init', array( $this, 'register')); |
|
48 | 48 | |
49 | - return $this; |
|
49 | + return $this; |
|
50 | 50 | |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Instantiate our class. |
|
55 | - * |
|
56 | - * @return mixed The instance of this class. |
|
57 | - */ |
|
58 | - public static function instance() |
|
59 | - { |
|
53 | + /** |
|
54 | + * Instantiate our class. |
|
55 | + * |
|
56 | + * @return mixed The instance of this class. |
|
57 | + */ |
|
58 | + public static function instance() |
|
59 | + { |
|
60 | 60 | |
61 | - static $instance = null; |
|
62 | - |
|
63 | - if (null === $instance ) { |
|
64 | - |
|
65 | - $instance = new Shortcodes(); |
|
66 | - |
|
67 | - } |
|
68 | - |
|
69 | - return $instance; |
|
70 | - |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Instantiate our class. |
|
75 | - * |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function register() |
|
79 | - { |
|
80 | - |
|
81 | - add_shortcode('subway_login', array( $this, 'loginForm' )); |
|
82 | - |
|
83 | - add_action('login_form_middle', array( $this, 'loginFormAction' ), 10, 2); |
|
84 | - |
|
85 | - add_action('login_form_middle', array( $this, 'lostPasswordLink' ), 10, 2); |
|
86 | - |
|
87 | - return; |
|
88 | - |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Displays the login form |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function loginForm( $atts ) |
|
97 | - { |
|
98 | - $atts = shortcode_atts( array( |
|
99 | - 'echo' => true, |
|
100 | - 'form_id' => 'loginform', |
|
101 | - 'label_username' => __( 'Username', 'subway' ), |
|
102 | - 'label_password' => __( 'Password', 'subway' ), |
|
103 | - 'label_remember' => __( 'Remember Me', 'subway' ), |
|
104 | - 'label_log_in' => __( 'Log In', 'subway' ), |
|
105 | - 'id_username' => 'user_login', |
|
106 | - 'id_password' => 'user_pass', |
|
107 | - 'id_remember' => 'rememberme', |
|
108 | - 'id_submit' => 'wp-submit', |
|
109 | - 'remember' => true, |
|
110 | - 'value_username' => '', |
|
111 | - 'value_remember' => false, |
|
112 | - 'redirect' => home_url(), |
|
113 | - ), $atts ); |
|
114 | - |
|
115 | - return $this->renderTemplate($atts, 'login-form.php'); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Include the specific plugin file if there is no template file. |
|
120 | - * |
|
121 | - * @param mixed $atts The shortcode attribute. |
|
122 | - * @param string $file The shortcode template file. |
|
123 | - * |
|
124 | - * @return string The html template content. |
|
125 | - */ |
|
126 | - protected function renderTemplate( $atts, $file = '' ) |
|
127 | - { |
|
128 | - |
|
129 | - ob_start(); |
|
130 | - |
|
131 | - if (empty($file) ) { |
|
61 | + static $instance = null; |
|
62 | + |
|
63 | + if (null === $instance ) { |
|
64 | + |
|
65 | + $instance = new Shortcodes(); |
|
66 | + |
|
67 | + } |
|
68 | + |
|
69 | + return $instance; |
|
70 | + |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Instantiate our class. |
|
75 | + * |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function register() |
|
79 | + { |
|
80 | + |
|
81 | + add_shortcode('subway_login', array( $this, 'loginForm' )); |
|
82 | + |
|
83 | + add_action('login_form_middle', array( $this, 'loginFormAction' ), 10, 2); |
|
84 | + |
|
85 | + add_action('login_form_middle', array( $this, 'lostPasswordLink' ), 10, 2); |
|
86 | + |
|
87 | + return; |
|
88 | + |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Displays the login form |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function loginForm( $atts ) |
|
97 | + { |
|
98 | + $atts = shortcode_atts( array( |
|
99 | + 'echo' => true, |
|
100 | + 'form_id' => 'loginform', |
|
101 | + 'label_username' => __( 'Username', 'subway' ), |
|
102 | + 'label_password' => __( 'Password', 'subway' ), |
|
103 | + 'label_remember' => __( 'Remember Me', 'subway' ), |
|
104 | + 'label_log_in' => __( 'Log In', 'subway' ), |
|
105 | + 'id_username' => 'user_login', |
|
106 | + 'id_password' => 'user_pass', |
|
107 | + 'id_remember' => 'rememberme', |
|
108 | + 'id_submit' => 'wp-submit', |
|
109 | + 'remember' => true, |
|
110 | + 'value_username' => '', |
|
111 | + 'value_remember' => false, |
|
112 | + 'redirect' => home_url(), |
|
113 | + ), $atts ); |
|
114 | + |
|
115 | + return $this->renderTemplate($atts, 'login-form.php'); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Include the specific plugin file if there is no template file. |
|
120 | + * |
|
121 | + * @param mixed $atts The shortcode attribute. |
|
122 | + * @param string $file The shortcode template file. |
|
123 | + * |
|
124 | + * @return string The html template content. |
|
125 | + */ |
|
126 | + protected function renderTemplate( $atts, $file = '' ) |
|
127 | + { |
|
128 | + |
|
129 | + ob_start(); |
|
130 | + |
|
131 | + if (empty($file) ) { |
|
132 | 132 | |
133 | - return; |
|
133 | + return; |
|
134 | 134 | |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - $template = SUBWAY_DIR_PATH . 'templates/'.$file; |
|
137 | + $template = SUBWAY_DIR_PATH . 'templates/'.$file; |
|
138 | 138 | |
139 | - if (file_exists($template) ) { |
|
139 | + if (file_exists($template) ) { |
|
140 | 140 | |
141 | - $theme_template = locate_template(array('gears/shortcodes/'.$file )); |
|
141 | + $theme_template = locate_template(array('gears/shortcodes/'.$file )); |
|
142 | 142 | |
143 | - if ($theme_template) { |
|
143 | + if ($theme_template) { |
|
144 | 144 | |
145 | - $template = $theme_template; |
|
145 | + $template = $theme_template; |
|
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - include $template; |
|
149 | + include $template; |
|
150 | 150 | |
151 | - } else { |
|
151 | + } else { |
|
152 | 152 | |
153 | - echo sprintf( |
|
154 | - esc_html_e( |
|
155 | - 'Subway Error: Unable to find template file in: %1s', 'subway' |
|
156 | - ), |
|
157 | - $template |
|
158 | - ); |
|
153 | + echo sprintf( |
|
154 | + esc_html_e( |
|
155 | + 'Subway Error: Unable to find template file in: %1s', 'subway' |
|
156 | + ), |
|
157 | + $template |
|
158 | + ); |
|
159 | 159 | |
160 | - } |
|
160 | + } |
|
161 | 161 | |
162 | - return ob_get_clean(); |
|
163 | - } |
|
162 | + return ob_get_clean(); |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * The action for our login form. |
|
167 | - * |
|
168 | - * @param string $__content The current filtered contents. |
|
169 | - * |
|
170 | - * @return string The content of our login form action. |
|
171 | - */ |
|
172 | - public function loginFormAction( $__content ) |
|
173 | - { |
|
165 | + /** |
|
166 | + * The action for our login form. |
|
167 | + * |
|
168 | + * @param string $__content The current filtered contents. |
|
169 | + * |
|
170 | + * @return string The content of our login form action. |
|
171 | + */ |
|
172 | + public function loginFormAction( $__content ) |
|
173 | + { |
|
174 | 174 | |
175 | - ob_start(); |
|
175 | + ob_start(); |
|
176 | 176 | |
177 | - do_action('login_form'); |
|
177 | + do_action('login_form'); |
|
178 | 178 | |
179 | - return $__content . ob_get_clean(); |
|
180 | - |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * The action for our 'lost password' link. |
|
185 | - * |
|
186 | - * @param string $content The current filtered contents. |
|
187 | - * |
|
188 | - * @return string The content of our lost password link. |
|
189 | - */ |
|
190 | - public function lostPasswordLink( $content ) |
|
191 | - { |
|
179 | + return $__content . ob_get_clean(); |
|
180 | + |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * The action for our 'lost password' link. |
|
185 | + * |
|
186 | + * @param string $content The current filtered contents. |
|
187 | + * |
|
188 | + * @return string The content of our lost password link. |
|
189 | + */ |
|
190 | + public function lostPasswordLink( $content ) |
|
191 | + { |
|
192 | 192 | |
193 | - return $content . $this->renderTemplate( |
|
194 | - array(), |
|
195 | - 'login-form-lost-password.php' |
|
196 | - ); |
|
193 | + return $content . $this->renderTemplate( |
|
194 | + array(), |
|
195 | + 'login-form-lost-password.php' |
|
196 | + ); |
|
197 | 197 | |
198 | - } |
|
198 | + } |
|
199 | 199 | |
200 | 200 | } |
201 | 201 |