Custom Login - Version 3.1

Version Description

Download this release

Release Info

Developer austyfrosty
Plugin Icon 128x128 Custom Login
Version 3.1
Comparing to
See all releases

Code changes from version 3.0.8.1 to 3.1

css/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
css/chosen/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
css/login/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
custom-login.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Custom Login
4
  * Plugin URI: https://frosty.media/plugins/custom-login
5
  * Description: A simple way to customize your WordPress <code>wp-login.php</code> screen! A <a href="https://frosty.media/">Frosty Media</a> plugin.
6
- * Version: 3.0.8.1
7
  * Author: Austin Passy
8
  * Author URI: https://austin.passy.co
9
  * Text Domain: custom-login
@@ -27,7 +27,7 @@ if ( !class_exists( 'Custom_Login' ) ) :
27
  /**
28
  * Main Custom_Login Class
29
  *
30
- * @since 1.0
31
  */
32
  final class Custom_Login {
33
 
@@ -38,7 +38,7 @@ final class Custom_Login {
38
  * Plugin vars
39
  * @return string
40
  */
41
- var $version = '3.0.8.1',
42
  $menu_page,
43
  $prefix;
44
 
@@ -158,7 +158,7 @@ final class Custom_Login {
158
  add_action( 'wp_head', array( $this, 'cl_version_in_header' ) );
159
  add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
160
  add_action( 'admin_init', array( $this, 'load_settings' ), 8 );
161
- add_action( $this->prefix . '_after_sanatize_options', array( $this, 'delete_transients' ), 8 );
162
 
163
  add_action( 'admin_notices', array( $this, 'show_notifications' ) );
164
  add_action( 'admin_init', array( $this, 'notification_ignore' ) );
@@ -207,7 +207,7 @@ final class Custom_Login {
207
  */
208
  public function load_settings() {
209
 
210
- include_once( trailingslashit( CUSTOM_LOGIN_DIR ) . 'includes/default-settings.php' );
211
  $this->settings_api = new CL_Settings_API(
212
  $sections,
213
  $fields,
@@ -226,7 +226,7 @@ final class Custom_Login {
226
  }
227
 
228
  /**
229
- * Hook into the 'sanatize_options' hook in the Settings API
230
  * and remove the transient settings for the style and script.
231
  *
232
  * @since 3.0.0
@@ -242,8 +242,7 @@ final class Custom_Login {
242
  */
243
  function show_notifications() {
244
 
245
- $screen = get_current_screen();
246
- $is_cl_screen = isset( $screen->id ) ? $screen->id === 'settings_page_' . CUSTOM_LOGIN_DIRNAME : false;
247
  $transient_key = CL_Common::get_transient_key( 'announcement' );
248
  $ignore_key = CUSTOM_LOGIN_OPTION . '_ignore_announcement';
249
  $old_message = get_option( CUSTOM_LOGIN_OPTION . '_announcement_message' );
@@ -256,10 +255,14 @@ final class Custom_Login {
256
  update_option( CUSTOM_LOGIN_OPTION . '_announcement_message', '' ); //*/
257
 
258
  // Current user can't manage options
259
- if ( !current_user_can( $capability ) ) return;
 
260
 
261
  if ( !$is_cl_screen ) {
262
 
 
 
 
263
  // Global notifications
264
  if ( 'off' === CL_Common::get_option( 'admin_notices', 'general', 'on' ) )
265
  return;
3
  * Plugin Name: Custom Login
4
  * Plugin URI: https://frosty.media/plugins/custom-login
5
  * Description: A simple way to customize your WordPress <code>wp-login.php</code> screen! A <a href="https://frosty.media/">Frosty Media</a> plugin.
6
+ * Version: 3.1
7
  * Author: Austin Passy
8
  * Author URI: https://austin.passy.co
9
  * Text Domain: custom-login
27
  /**
28
  * Main Custom_Login Class
29
  *
30
+ * @since 2.0
31
  */
32
  final class Custom_Login {
33
 
38
  * Plugin vars
39
  * @return string
40
  */
41
+ var $version = '3.1',
42
  $menu_page,
43
  $prefix;
44
 
158
  add_action( 'wp_head', array( $this, 'cl_version_in_header' ) );
159
  add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
160
  add_action( 'admin_init', array( $this, 'load_settings' ), 8 );
161
+ add_action( $this->prefix . '_after_sanitize_options', array( $this, 'delete_transients' ), 8 );
162
 
163
  add_action( 'admin_notices', array( $this, 'show_notifications' ) );
164
  add_action( 'admin_init', array( $this, 'notification_ignore' ) );
207
  */
208
  public function load_settings() {
209
 
210
+ include( trailingslashit( CUSTOM_LOGIN_DIR ) . 'includes/default-settings.php' );
211
  $this->settings_api = new CL_Settings_API(
212
  $sections,
213
  $fields,
226
  }
227
 
228
  /**
229
+ * Hook into the 'sanitize_options' hook in the Settings API
230
  * and remove the transient settings for the style and script.
231
  *
232
  * @since 3.0.0
242
  */
243
  function show_notifications() {
244
 
245
+ $is_cl_screen = CL_Common::is_settings_page();
 
246
  $transient_key = CL_Common::get_transient_key( 'announcement' );
247
  $ignore_key = CUSTOM_LOGIN_OPTION . '_ignore_announcement';
248
  $old_message = get_option( CUSTOM_LOGIN_OPTION . '_announcement_message' );
255
  update_option( CUSTOM_LOGIN_OPTION . '_announcement_message', '' ); //*/
256
 
257
  // Current user can't manage options
258
+ if ( !current_user_can( $capability ) )
259
+ return;
260
 
261
  if ( !$is_cl_screen ) {
262
 
263
+ // Let's not show this at all if not on out menu page. @since 3.1
264
+ return;
265
+
266
  // Global notifications
267
  if ( 'off' === CL_Common::get_option( 'admin_notices', 'general', 'on' ) )
268
  return;
includes/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
includes/admin/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
includes/admin/import-export.php CHANGED
@@ -15,7 +15,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
15
  * Usage tracking
16
  *
17
  * @access public
18
- * @since 3.0.7
19
  * @return void
20
  */
21
  class CL_Import_Export {
@@ -25,7 +25,8 @@ class CL_Import_Export {
25
  *
26
  * @access private
27
  */
28
- private $menu_page;
 
29
 
30
  /**
31
  * Get things going
@@ -34,74 +35,244 @@ class CL_Import_Export {
34
  * @return void
35
  */
36
  public function __construct() {
37
-
 
38
  add_action( CUSTOM_LOGIN_OPTION . '_settings_sidebars', array( $this, 'settings_sidebar' ), 30 );
39
- add_action( 'admin_action_' . CUSTOM_LOGIN_OPTION . '_import_settings', array( $this, 'import_settings' ) );
40
- add_action( 'admin_action_' . CUSTOM_LOGIN_OPTION . '_export_settings', array( $this, 'export_settings' ) );
41
  }
42
 
43
  /**
44
- * Box with a link to the extensions page.
 
 
45
  */
46
- function settings_sidebar( $args ) {
47
 
48
- $import_url = wp_nonce_url(
49
- add_query_arg( array( 'action' => CUSTOM_LOGIN_OPTION . '_import_settings' ),
50
- admin_url( 'admin.php' )
 
 
 
 
51
  ),
52
- 'import',
53
- 'cl_nonce'
54
- );
55
- $export_url = wp_nonce_url(
56
- add_query_arg( array( 'action' => CUSTOM_LOGIN_OPTION . '_export_settings' ),
57
- admin_url( 'admin.php' )
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  ),
59
- 'export',
60
- 'cl_nonce'
61
  );
62
 
63
- if ( CUSTOM_LOGIN_VERSION < '3.1.0' ) {
64
- $content = __( 'Coming in version 3.1', CUSTOM_LOGIN_DIRNAME );
65
- }
66
- else {
67
- $content = '<ul>';
68
- $content .= sprintf( __( '<li><a href="%s">Import</a></li>', CUSTOM_LOGIN_DIRNAME ), esc_url( $import_url ) );
69
- $content .= sprintf( __( '<li><textarea></textarea></li>', CUSTOM_LOGIN_DIRNAME ), esc_url( $import_url ) );
70
- $content .= '</ul>';
71
- $content .= '<div id="import-export-wrapper"></div>';
72
- }
73
-
74
- CUSTOMLOGIN()->settings_api->postbox( 'custom-login-import-export', __( 'Settings Import/Export', CUSTOM_LOGIN_DIRNAME ), $content );
75
  }
76
 
77
  /**
78
- * Import some settings into Custom Login.
79
  *
80
- * @access public
81
- * @return array
82
  */
83
- function import_settings() {
 
 
 
84
 
85
- if ( !isset( $_GET['cl_nonce']) || !wp_verify_nonce( $_GET['cl_nonce'], 'import' ) ) {
 
86
  }
87
 
88
- wp_redirect( remove_query_arg( array( 'action', 'cl_nonce' ) ) );
89
- exit;
 
90
  }
 
 
 
 
 
 
 
 
 
 
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  /**
93
- * Export Custom Logins settings.
94
- *
95
- * @access public
96
- * @return void
97
  */
98
- function export_settings() {
 
 
 
 
99
 
100
- if ( !isset( $_GET['cl_nonce']) || !wp_verify_nonce( $_GET['cl_nonce'], 'import' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- wp_redirect( remove_query_arg( array( 'action', 'cl_nonce' ) ) );
104
- exit;
105
  }
106
 
107
  }
15
  * Usage tracking
16
  *
17
  * @access public
18
+ * @since 3.1
19
  * @return void
20
  */
21
  class CL_Import_Export {
25
  *
26
  * @access private
27
  */
28
+ private $settings_api;
29
+ private $settings_id;
30
 
31
  /**
32
  * Get things going
35
  * @return void
36
  */
37
  public function __construct() {
38
+
39
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
40
  add_action( CUSTOM_LOGIN_OPTION . '_settings_sidebars', array( $this, 'settings_sidebar' ), 30 );
41
+ add_action( CUSTOM_LOGIN_OPTION . '_after_settings_sections_form', array( $this, 'after_settings_sections_form' ), 11 );
42
+ add_action( 'admin_action_' . CUSTOM_LOGIN_OPTION . '_download_export', array( $this, 'download_export' ) );
43
  }
44
 
45
  /**
46
+ * Set our settings fields
47
+ *
48
+ * @access private
49
  */
50
+ private function settings_fields() {
51
 
52
+ $fields [ $this->settings_id ] = array(
53
+ array(
54
+ 'name' => 'import',
55
+ 'label' => __( 'Import', CUSTOM_LOGIN_DIRNAME ),
56
+ 'desc' => '',
57
+ 'type' => 'textarea',
58
+ 'sanitize' => '__return_empty_string',
59
  ),
60
+
61
+ array(
62
+ 'name' => 'export',
63
+ 'label' => __( 'Export', CUSTOM_LOGIN_DIRNAME ),
64
+ 'desc' => sprintf( __( 'This textarea is always pre-filled with the current settings. Copy these settings for import at a later time, or <a href="%s">download</a> them.', CUSTOM_LOGIN_DIRNAME ),
65
+ wp_nonce_url(
66
+ add_query_arg( array( 'action' => CUSTOM_LOGIN_OPTION . '_download_export' ),
67
+ ''
68
+ ),
69
+ 'export',
70
+ 'cl_nonce'
71
+ )
72
+ ),
73
+ 'default' => $this->get_custom_login_settings(),
74
+ 'type' => 'textarea',
75
+ 'extra' => array(
76
+ 'readonly' => 'readonly'
77
+ ),
78
+ 'sanitize' => '__return_empty_string',
79
  ),
80
+
 
81
  );
82
 
83
+ return $fields;
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
 
86
  /**
87
+ * Return the full array of settings
88
  *
89
+ * @access private
 
90
  */
91
+ private function get_custom_login_settings() {
92
+
93
+ $settings = array();
94
+ include( trailingslashit( CUSTOM_LOGIN_DIR ) . 'includes/default-settings.php' );
95
 
96
+ foreach ( $sections as $section ) {
97
+ $settings[ $section['id'] ] = get_option( $section['id'] );
98
  }
99
 
100
+ return base64_encode( maybe_serialize( $settings ) );
101
+
102
+ # var_dump( $settings ); exit;
103
  }
104
+
105
+ public function admin_init() {
106
+
107
+ $this->settings_api = CUSTOMLOGIN()->settings_api;
108
+ $this->settings_id = CUSTOM_LOGIN_OPTION . '_import_export';
109
+
110
+ add_settings_section( $this->settings_id, __( 'Import/Export Custom Login Settings', CUSTOM_LOGIN_DIRNAME ), '__return_false', $this->settings_id );
111
+
112
+ foreach( $this->settings_fields() as $section => $field ) {
113
+ foreach ( $field as $option ) {
114
 
115
+ $type = isset( $option['type'] ) ? $option['type'] : 'text';
116
+
117
+ $args = array(
118
+ 'id' => $option['name'],
119
+ 'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
120
+ 'name' => $option['label'],
121
+ 'section' => $section,
122
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
123
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
124
+ 'default' => isset( $option['default'] ) ? $option['default'] : '',
125
+ 'sanitize' => isset( $option['sanitize'] ) ? $option['sanitize'] : '',
126
+ );
127
+ $args = wp_parse_args( $args, $option );
128
+
129
+ add_settings_field( $section . '[' . $option['name'] . ']', $option['label'], array( $this->settings_api, 'callback_' . $type ), $section, $section, $args );
130
+ }
131
+ }
132
+
133
+ register_setting( $this->settings_id, $this->settings_id, array( $this, 'sanitize_options' ) );
134
+ }
135
+
136
  /**
137
+ * Box with a link to the extensions page.
 
 
 
138
  */
139
+ function settings_sidebar( $args ) {
140
+
141
+ $html = '<ul class="cl-sections-menu">';
142
+ $html .= sprintf( '<li><a href="#%1$s">%2$s</a></li>', $this->settings_id, __( 'Import/Export Settings' ) );
143
+ $html .= '</ul>';
144
 
145
+ echo $html;
146
+ }
147
+
148
+ /**
149
+ * Show the import/export settings form.
150
+ */
151
+ function after_settings_sections_form() {
152
+ ?>
153
+ <div id="<?php echo $this->settings_id; ?>" class="group">
154
+ <form action="options.php" id="<?php echo $this->settings_id; ?>form" method="post" >
155
+ <?php settings_fields( $this->settings_id ); ?>
156
+ <?php do_settings_sections( $this->settings_id ); ?>
157
+ <?php submit_button(); ?>
158
+ </form>
159
+ </div><?php
160
+ }
161
+
162
+ /**
163
+ * Sanitize callback for Settings API before input into database.
164
+ *
165
+ * @ref http://stackoverflow.com/a/10797086/558561
166
+ */
167
+ private function maybe_import_settings( $options ) {
168
+
169
+ if ( !empty( $options['import'] ) && ( base64_encode( base64_decode( $options['import'], true ) ) === $options['import'] ) ) {
170
+ $import = maybe_unserialize( base64_decode( $options['import'] ) );
171
+ # var_dump( $import ); exit;
172
+ if ( is_array( $import ) ) {
173
+ foreach( $import as $setting_key => $settings ) {
174
+ if ( false !== $settings ) {
175
+ if ( update_option( $setting_key, $settings ) ) {
176
+ add_settings_error(
177
+ $this->settings_id ,
178
+ esc_attr( 'settings_updated' ),
179
+ __( 'Custom Login settings successfully imported', CUSTOM_LOGIN_DIRNAME ),
180
+ 'updated'
181
+ );
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Sanitize callback for Settings API
191
+ */
192
+ function sanitize_options( $options ) {
193
+
194
+ $this->maybe_import_settings( $options );
195
+
196
+ foreach( $options as $option_slug => $option_value ) {
197
+ $sanitize_callback = $this->get_sanitize_callback( $option_slug );
198
+
199
+ // If callback is set, call it
200
+ if ( $sanitize_callback ) {
201
+ $options[ $option_slug ] = call_user_func( $sanitize_callback, $option_value );
202
+ continue;
203
+ }
204
+
205
+ // Treat everything that's not an array as a string
206
+ if ( !is_array( $option_value ) ) {
207
+ $options[ $option_slug ] = sanitize_text_field( $option_value );
208
+ continue;
209
+ }
210
+ }
211
+
212
+ $options = $this->after_sanitize_options( $options );
213
+
214
+ return $options;
215
+ }
216
+
217
+ /**
218
+ * Get sanitization callback for given option slug
219
+ *
220
+ * @param string $slug option slug
221
+ *
222
+ * @return mixed string or bool false
223
+ */
224
+ function get_sanitize_callback( $slug = '' ) {
225
+
226
+ if ( empty( $slug ) )
227
+ return false;
228
+
229
+ // Iterate over registered fields and see if we can find proper callback
230
+ foreach( $this->settings_fields() as $section => $options ) {
231
+ foreach ( $options as $option ) {
232
+ if ( $option['name'] != $slug )
233
+ continue;
234
+ // Return the callback name
235
+ return isset( $option['sanitize'] ) && is_callable( $option['sanitize'] ) ? $option['sanitize'] : false;
236
+ }
237
  }
238
+ return false;
239
+ }
240
+
241
+ function after_sanitize_options( $options ) {
242
+
243
+ foreach( $this->settings_fields() as $section => $field ) {
244
+ foreach ( $field as $option ) {
245
+ unset( $options[ $option['name'] ] );
246
+ }
247
+ }
248
+
249
+ return $options;
250
+ }
251
+
252
+ /**
253
+ * Export the settings.
254
+ *
255
+ * @ref http://stackoverflow.com/a/16440501/558561
256
+ */
257
+ function download_export() {
258
+
259
+ if ( !isset( $_GET['cl_nonce']) || !wp_verify_nonce( $_GET['cl_nonce'], 'export' ) ) {
260
+ wp_redirect( remove_query_arg( array( 'action', 'cl_nonce' ) ) );
261
+ exit;
262
+ }
263
+
264
+ $month = date( 'n' );
265
+ $year = date( 'Y' );
266
+
267
+ ignore_user_abort(true);
268
+
269
+ nocache_headers();
270
+ header( 'Content-type: text/plain; charset=utf-8' );
271
+ header( 'Content-Disposition: attachment; filename=cl-export-' . $month . '-' . $year . '.txt' );
272
+ header( 'Expires: 0' );
273
 
274
+ echo $this->get_custom_login_settings();
275
+ exit;
276
  }
277
 
278
  }
includes/admin/tracking.php CHANGED
@@ -41,12 +41,12 @@ class CL_Tracking {
41
  $this->api = defined( 'WP_LOCAL_DEV' ) ? 'http://frosty.media.dev/cl-checkin-api/?edd_action=cl_checkin' : CUSTOM_LOGIN_API_URL . 'cl-checkin-api/?edd_action=cl_checkin';
42
  $this->schedule_send();
43
 
44
- add_action( CUSTOM_LOGIN_OPTION . '_after_sanatize_options', array( $this, 'check_for_settings_optin' ) );
 
 
45
  add_action( 'admin_action_cl_opt_into_tracking', array( $this, 'check_for_optin' ) );
46
  add_action( 'admin_action_cl_opt_out_of_tracking', array( $this, 'check_for_optout' ) );
47
- add_action( 'admin_notices', array( $this, 'admin_notice' ) );
48
-
49
- register_activation_hook( CUSTOM_LOGIN_FILE, array( $this, 'activate' ) );
50
  }
51
 
52
  /**
@@ -140,14 +140,14 @@ class CL_Tracking {
140
 
141
  $response = wp_remote_post( $this->api, array(
142
  'method' => 'POST',
143
- 'timeout' => 20,
144
  'redirection' => 5,
145
  'body' => $this->data,
146
  'user-agent' => 'CustomLogin/' . CUSTOM_LOGIN_VERSION . '; ' . get_bloginfo( 'url' )
147
  ) );
148
 
149
  if ( !is_wp_error( $response ) ) {
150
- update_option( 'cl_tracking_last_send', time() );
151
  }
152
 
153
  }
@@ -184,7 +184,7 @@ class CL_Tracking {
184
 
185
  $options['tracking'] = 'on';
186
  update_option( $this->option, $options );
187
- update_option( 'cl_tracking_notice', '1' );
188
 
189
  $this->send_checkin( true, array( 'on_activation' => 'admin notice', 'mailchimp_sub' => 'yes' ) );
190
 
@@ -206,7 +206,7 @@ class CL_Tracking {
206
 
207
  $options['tracking'] = 'off';
208
  update_option( $this->option, $options );
209
- update_option( 'cl_tracking_notice', '1' );
210
 
211
  wp_redirect( remove_query_arg( 'action' ) );
212
  exit;
@@ -219,7 +219,7 @@ class CL_Tracking {
219
  * @return false/string
220
  */
221
  private function get_last_send() {
222
- return get_option( 'cl_tracking_last_send' );
223
  }
224
 
225
  /**
@@ -230,7 +230,7 @@ class CL_Tracking {
230
  */
231
  private function schedule_send() {
232
  // We send once a week (while tracking is allowed) to check in, which can be used to determine active sites
233
- add_action( 'cl_weekly_scheduled_events', array( $this, 'send_checkin' ) );
234
  }
235
 
236
  /**
@@ -241,15 +241,16 @@ class CL_Tracking {
241
  */
242
  public function admin_notice() {
243
 
244
- $options = get_option( $this->option, array() );
245
- $hide_notice = get_option( 'cl_tracking_notice' );
246
 
247
- if ( $hide_notice ) return;
 
248
 
249
  if ( isset( $options['admin_notices'] ) && 'off' === $options['admin_notices'] )
250
  return;
251
 
252
- if ( isset( $options['tracking'] ) && 'on' === $options['tracking'] )
253
  return;
254
 
255
  if ( ! current_user_can( 'manage_options' ) )
@@ -260,7 +261,7 @@ class CL_Tracking {
260
  stristr( network_site_url( '/' ), 'localhost' ) !== false ||
261
  stristr( network_site_url( '/' ), ':8888' ) !== false // This is common with MAMP on OS X
262
  ) {
263
- update_option( 'cl_tracking_notice', '1' ); // Don't update the notice in case someone pushes local to live? Maybe return.
264
  }
265
  else {
266
  $admin_url = admin_url( 'admin.php' );
41
  $this->api = defined( 'WP_LOCAL_DEV' ) ? 'http://frosty.media.dev/cl-checkin-api/?edd_action=cl_checkin' : CUSTOM_LOGIN_API_URL . 'cl-checkin-api/?edd_action=cl_checkin';
42
  $this->schedule_send();
43
 
44
+ register_activation_hook( CUSTOM_LOGIN_FILE, array( $this, 'activate' ) );
45
+
46
+ add_action( CUSTOM_LOGIN_OPTION . '_after_sanitize_options', array( $this, 'check_for_settings_optin' ) );
47
  add_action( 'admin_action_cl_opt_into_tracking', array( $this, 'check_for_optin' ) );
48
  add_action( 'admin_action_cl_opt_out_of_tracking', array( $this, 'check_for_optout' ) );
49
+ # add_action( 'admin_notices', array( $this, 'admin_notice' ) );
 
 
50
  }
51
 
52
  /**
140
 
141
  $response = wp_remote_post( $this->api, array(
142
  'method' => 'POST',
143
+ 'timeout' => apply_filters( 'cl_wp_remote_post_timeout', (int) 15 ),
144
  'redirection' => 5,
145
  'body' => $this->data,
146
  'user-agent' => 'CustomLogin/' . CUSTOM_LOGIN_VERSION . '; ' . get_bloginfo( 'url' )
147
  ) );
148
 
149
  if ( !is_wp_error( $response ) ) {
150
+ update_option( 'custom_login_tracking_last_send', time() );
151
  }
152
 
153
  }
184
 
185
  $options['tracking'] = 'on';
186
  update_option( $this->option, $options );
187
+ update_option( 'custom_login_hide_tracking_notice', '1' );
188
 
189
  $this->send_checkin( true, array( 'on_activation' => 'admin notice', 'mailchimp_sub' => 'yes' ) );
190
 
206
 
207
  $options['tracking'] = 'off';
208
  update_option( $this->option, $options );
209
+ update_option( 'custom_login_hide_tracking_notice', '1' );
210
 
211
  wp_redirect( remove_query_arg( 'action' ) );
212
  exit;
219
  * @return false/string
220
  */
221
  private function get_last_send() {
222
+ return get_option( 'custom_login_tracking_last_send' );
223
  }
224
 
225
  /**
230
  */
231
  private function schedule_send() {
232
  // We send once a week (while tracking is allowed) to check in, which can be used to determine active sites
233
+ add_action( 'custom_login_weekly_scheduled_events', array( $this, 'send_checkin' ) );
234
  }
235
 
236
  /**
241
  */
242
  public function admin_notice() {
243
 
244
+ $options = get_option( $this->option, array() );
245
+ $hide_notice = get_option( 'custom_login_hide_tracking_notice' );
246
 
247
+ if ( $hide_notice )
248
+ return;
249
 
250
  if ( isset( $options['admin_notices'] ) && 'off' === $options['admin_notices'] )
251
  return;
252
 
253
+ if ( isset( $options['tracking'] ) )
254
  return;
255
 
256
  if ( ! current_user_can( 'manage_options' ) )
261
  stristr( network_site_url( '/' ), 'localhost' ) !== false ||
262
  stristr( network_site_url( '/' ), ':8888' ) !== false // This is common with MAMP on OS X
263
  ) {
264
+ update_option( 'custom_login_hide_tracking_notice', '1' ); // Don't update the notice in case someone pushes local to live? Maybe return.
265
  }
266
  else {
267
  $admin_url = admin_url( 'admin.php' );
includes/class-cl-common.php CHANGED
@@ -95,12 +95,12 @@ class CL_Common {
95
  }
96
 
97
  /**
98
- * Get all values of a settings section
99
- *
100
- * @param string $subsection the section name this field belongs to
101
  *
102
- * @return array
103
- */
 
 
104
  public static function get_options( $subsection = 'design' ) {
105
 
106
  $section = CUSTOM_LOGIN_OPTION . '_' . $subsection;
@@ -110,11 +110,11 @@ class CL_Common {
110
  }
111
 
112
  /**
113
- * Helper function to make remote calls
114
  *
115
  * @since 3.0.0
116
  * @updated 3.0.8
117
- */
118
  public static function wp_remote_get( $url = false, $transient_key, $expiration = null, $user_agent = 'WordPress' ) {
119
 
120
  if ( !$url ) return false;
@@ -166,4 +166,32 @@ class CL_Common {
166
  return $json;
167
  }
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
95
  }
96
 
97
  /**
98
+ * Get all values of a settings section
 
 
99
  *
100
+ * @param string $subsection the section name this field belongs to
101
+ *
102
+ * @return array
103
+ */
104
  public static function get_options( $subsection = 'design' ) {
105
 
106
  $section = CUSTOM_LOGIN_OPTION . '_' . $subsection;
110
  }
111
 
112
  /**
113
+ * Helper function to make remote calls
114
  *
115
  * @since 3.0.0
116
  * @updated 3.0.8
117
+ */
118
  public static function wp_remote_get( $url = false, $transient_key, $expiration = null, $user_agent = 'WordPress' ) {
119
 
120
  if ( !$url ) return false;
166
  return $json;
167
  }
168
 
169
+ /**
170
+ * Helper function check if we're on our settings page.
171
+ *
172
+ * @since 3.0.9
173
+ */
174
+ public static function is_settings_page( $page = '' ) {
175
+
176
+ $return = true;
177
+ $screen = get_current_screen();
178
+
179
+ if ( null !== $screen ) {
180
+
181
+ if ( $screen->id != ( CUSTOMLOGIN()->menu_page ) )
182
+ $return = false;
183
+ }
184
+ else {
185
+ global $pagenow;
186
+
187
+ if ( 'options-general.php' != $pagenow )
188
+ $return = false;
189
+
190
+ if ( !isset( $_GET['page'] ) || CUSTOM_LOGIN_DIRNAME != $_GET['page'] )
191
+ $return = false;
192
+ }
193
+
194
+ return $return;
195
+ }
196
+
197
  }
includes/class-cl-cron.php CHANGED
@@ -67,8 +67,8 @@ class CL_Cron {
67
  * @return void
68
  */
69
  private function weekly_events() {
70
- if ( ! wp_next_scheduled( 'cl_weekly_scheduled_events' ) ) {
71
- wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'cl_weekly_scheduled_events' );
72
  }
73
  }
74
 
@@ -80,8 +80,8 @@ class CL_Cron {
80
  * @return void
81
  */
82
  private function daily_events() {
83
- if ( ! wp_next_scheduled( 'cl_daily_scheduled_events' ) ) {
84
- wp_schedule_event( current_time( 'timestamp' ), 'daily', 'cl_daily_scheduled_events' );
85
  }
86
  }
87
 
67
  * @return void
68
  */
69
  private function weekly_events() {
70
+ if ( ! wp_next_scheduled( 'custom_login_weekly_scheduled_events' ) ) {
71
+ wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'custom_login_weekly_scheduled_events' );
72
  }
73
  }
74
 
80
  * @return void
81
  */
82
  private function daily_events() {
83
+ if ( ! wp_next_scheduled( 'custom_login_daily_scheduled_events' ) ) {
84
+ wp_schedule_event( current_time( 'timestamp' ), 'daily', 'custom_login_daily_scheduled_events' );
85
  }
86
  }
87
 
includes/class-cl-extensions.php CHANGED
@@ -60,11 +60,16 @@ class CL_Extensions {
60
  wp_enqueue_style( CUSTOM_LOGIN_DIRNAME, plugins_url( 'css/admin.css', CUSTOM_LOGIN_FILE ), false, CUSTOM_LOGIN_VERSION, 'screen' );
61
  }
62
 
63
- /**
64
- * Load the remote installer
 
 
65
  */
66
  public function remote_install_client() {
67
 
 
 
 
68
  if ( !class_exists( 'CL_Remote_Install_Client' ) )
69
  require_once( trailingslashit( CUSTOM_LOGIN_DIR ) . 'includes/libraries/edd-remote-install-client/EDD_Remote_Install_Client.php' );
70
 
60
  wp_enqueue_style( CUSTOM_LOGIN_DIRNAME, plugins_url( 'css/admin.css', CUSTOM_LOGIN_FILE ), false, CUSTOM_LOGIN_VERSION, 'screen' );
61
  }
62
 
63
+ /**
64
+ * Load the remote installer on our setting page only.
65
+ *
66
+ * @updated 3.1
67
  */
68
  public function remote_install_client() {
69
 
70
+ if ( !CL_Common::is_settings_page() )
71
+ return;
72
+
73
  if ( !class_exists( 'CL_Remote_Install_Client' ) )
74
  require_once( trailingslashit( CUSTOM_LOGIN_DIR ) . 'includes/libraries/edd-remote-install-client/EDD_Remote_Install_Client.php' );
75
 
includes/class-cl-settings-api.php CHANGED
@@ -69,8 +69,8 @@ class CL_Settings_API {
69
 
70
  /* Core */
71
  wp_enqueue_media();
72
- wp_enqueue_script( 'wp-color-picker' );
73
- wp_enqueue_style( 'wp-color-picker' );
74
 
75
  /* jQuery Chosen */
76
  wp_enqueue_script( 'chosen', plugins_url( 'js/chosen.jquery.min.js', $this->settings['file'] ), array( 'jquery' ), '1.3.0', true );
@@ -551,7 +551,7 @@ class CL_Settings_API {
551
  */
552
  function sanitize_options( $options ) {
553
 
554
- do_action( $this->settings['prefix'] . '_before_sanatize_options', $options );
555
 
556
  foreach( $options as $option_slug => $option_value ) {
557
  $sanitize_callback = $this->get_sanitize_callback( $option_slug );
@@ -569,7 +569,7 @@ class CL_Settings_API {
569
  }
570
  }
571
 
572
- do_action( $this->settings['prefix'] . '_after_sanatize_options', $options );
573
 
574
  return $options;
575
  }
@@ -676,11 +676,12 @@ class CL_Settings_API {
676
  <?php settings_fields( $form['id'] ); ?>
677
  <?php do_settings_sections( $form['id'] ); ?>
678
  <?php do_action( $this->settings['prefix'] . '_form_bottom_' . $form['id'], $form ); ?>
679
- <?php if ( isset( $form['submit'] ) && $form['submit'] ) submit_button( ); ?>
680
  </form>
681
  </div><?php
682
  # var_dump( $form_id, get_option( $form_id ) );
683
  }
 
684
  }
685
 
686
  /**
69
 
70
  /* Core */
71
  wp_enqueue_media();
72
+ wp_enqueue_script( array( 'wp-color-picker', 'plugin-install' ) );
73
+ wp_enqueue_style( array( 'wp-color-picker', 'thickbox', 'plugin-install' ) );
74
 
75
  /* jQuery Chosen */
76
  wp_enqueue_script( 'chosen', plugins_url( 'js/chosen.jquery.min.js', $this->settings['file'] ), array( 'jquery' ), '1.3.0', true );
551
  */
552
  function sanitize_options( $options ) {
553
 
554
+ do_action( $this->settings['prefix'] . '_before_sanitize_options', $options );
555
 
556
  foreach( $options as $option_slug => $option_value ) {
557
  $sanitize_callback = $this->get_sanitize_callback( $option_slug );
569
  }
570
  }
571
 
572
+ do_action( $this->settings['prefix'] . '_after_sanitize_options', $options );
573
 
574
  return $options;
575
  }
676
  <?php settings_fields( $form['id'] ); ?>
677
  <?php do_settings_sections( $form['id'] ); ?>
678
  <?php do_action( $this->settings['prefix'] . '_form_bottom_' . $form['id'], $form ); ?>
679
+ <?php if ( isset( $form['submit'] ) && $form['submit'] ) submit_button(); ?>
680
  </form>
681
  </div><?php
682
  # var_dump( $form_id, get_option( $form_id ) );
683
  }
684
+ do_action( $this->settings['prefix'] . '_after_settings_sections_form' );
685
  }
686
 
687
  /**
includes/class-cl-wp-login.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package CustomLogin
4
- * @subpackage Classes/CL_Common
5
  * @author Austin Passy <http://austin.passy.co>
6
  * @copyright Copyright (c) 2014-2015, Austin Passy
7
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
@@ -52,8 +52,8 @@ class CL_WP_Login {
52
 
53
  private function filters() {
54
 
55
- # add_filter( 'auth_cookie_expiration', array( $this, 'auth_cookie_expiration' ), 99, 3 );
56
- add_filter( 'allow_password_reset', array( $this, 'allow_password_reset' ) );
57
  add_filter( 'gettext', array( $this, 'remove_lostpassword_text' ), 20, 2 );
58
  }
59
 
@@ -204,7 +204,9 @@ class CL_WP_Login {
204
  *
205
  * @added 3.0.5
206
  * @updated 3.0.8
 
207
  * @ref https://wordpress.org/plugins/configure-login-timeout/
 
208
  */
209
  public function auth_cookie_expiration( $seconds, $user_id, $remember ) {
210
 
@@ -232,7 +234,10 @@ class CL_WP_Login {
232
  /**
233
  * Allow password reset.
234
  *
 
 
235
  * @updated 3.0.5
 
236
  */
237
  public function allow_password_reset( $user_id ) {
238
  if ( 'on' === CL_Common::get_option( 'allow_password_reset', 'general', 'off' ) )
1
  <?php
2
  /**
3
  * @package CustomLogin
4
+ * @subpackage Classes/CL_WP_Login
5
  * @author Austin Passy <http://austin.passy.co>
6
  * @copyright Copyright (c) 2014-2015, Austin Passy
7
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
52
 
53
  private function filters() {
54
 
55
+ # add_filter( 'auth_cookie_expiration', array( $this, 'auth_cookie_expiration' ), 99, 3 ); // @removed 3.1
56
+ # add_filter( 'allow_password_reset', array( $this, 'allow_password_reset' ) ); // @removed 3.1
57
  add_filter( 'gettext', array( $this, 'remove_lostpassword_text' ), 20, 2 );
58
  }
59
 
204
  *
205
  * @added 3.0.5
206
  * @updated 3.0.8
207
+ * @disabled 3.1.0
208
  * @ref https://wordpress.org/plugins/configure-login-timeout/
209
+ * @removed 3.1
210
  */
211
  public function auth_cookie_expiration( $seconds, $user_id, $remember ) {
212
 
234
  /**
235
  * Allow password reset.
236
  *
237
+ * 'on' equals don't allow. :/
238
+ *
239
  * @updated 3.0.5
240
+ * @removed 3.1
241
  */
242
  public function allow_password_reset( $user_id ) {
243
  if ( 'on' === CL_Common::get_option( 'allow_password_reset', 'general', 'off' ) )
includes/default-settings.php CHANGED
@@ -484,44 +484,4 @@ $fields [CUSTOM_LOGIN_OPTION . '_general'] = array(
484
  'desc' => __( 'Remove the "Lost Password?" text. This does <strong>not<strong> disable the lost password function.', CUSTOM_LOGIN_DIRNAME ),
485
  'type' => 'checkbox'
486
  ),
487
- array(
488
- 'name' => 'allow_password_reset',
489
- 'label' => __( 'Disable lost password', CUSTOM_LOGIN_DIRNAME ),
490
- 'desc' => __( 'Disable the lost password reset function.', CUSTOM_LOGIN_DIRNAME ),
491
- 'type' => 'checkbox'
492
- ),
493
-
494
- /** BREAK **/
495
- array(
496
- 'name' => 'break_4',
497
- 'label' => sprintf( '<h4>%s</h4>', __( 'Sessions', CUSTOM_LOGIN_DIRNAME ) ),
498
- 'desc' => '',
499
- 'type' => 'html',
500
- ),
501
- /** BREAK **/
502
-
503
- array(
504
- 'name' => 'auth_timeout',
505
- 'label' => __( 'Auth timeout', CUSTOM_LOGIN_DIRNAME ),
506
- 'desc' => __( 'Authentication timeout <strong>without</strong> "remember me" checked at login.', CUSTOM_LOGIN_DIRNAME ),
507
- 'type' => 'text_number',
508
- 'size' => 'small',
509
- 'default' => '2',
510
- 'sanitize' => 'absint',
511
- ),
512
- array(
513
- 'name' => 'auth_timeout_remember',
514
- 'label' => __( 'Auth timeout', CUSTOM_LOGIN_DIRNAME ),
515
- 'desc' => __( 'Authentication timeout <strong>with</strong> "remember me" checked at login.', CUSTOM_LOGIN_DIRNAME ),
516
- 'type' => 'text_number',
517
- 'size' => 'small',
518
- 'default' => '14',
519
- 'sanitize' => 'absint',
520
- ),
521
- array(
522
- 'name' => 'break_5',
523
- 'label' => '',
524
- 'desc' => sprintf( '<small>%s</small>', __( 'The default WordPress behavior for logging a user out is to make a login session cookie that expires in 48 hours or when the browser is closed. If the "Remember Me" box is checked, WordPress will give you 14 days before forcing you to authenticate again. Never set below "0".', CUSTOM_LOGIN_DIRNAME ) ),
525
- 'type' => 'html',
526
- ),
527
  );
484
  'desc' => __( 'Remove the "Lost Password?" text. This does <strong>not<strong> disable the lost password function.', CUSTOM_LOGIN_DIRNAME ),
485
  'type' => 'checkbox'
486
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  );
includes/libraries/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
includes/libraries/edd-remote-install-client/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
includes/libraries/edd-remote-install-client/css/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
includes/libraries/edd-remote-install-client/js/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
js/_notes/dwsync.xml DELETED
@@ -1 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8" ?>
 
js/admin.js CHANGED
@@ -356,7 +356,7 @@
356
  }
357
 
358
  } // get_setting()
359
-
360
  }); // (document)
361
 
362
  /**
356
  }
357
 
358
  } // get_setting()
359
+
360
  }); // (document)
361
 
362
  /**
readme.txt CHANGED
@@ -113,6 +113,14 @@ Custom Login showcase on the [Flickr group](http://flickr.com/groups/custom-logi
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
 
 
116
  = Version 3.0.8 (01/14/15) =
117
 
118
  * Add: Auth timout setting when remember me is checked and not.
113
 
114
  == Changelog ==
115
 
116
+ = Version 3.1 (01/14/15) =
117
+
118
+ * Update: Disable auth cookie expiration function.
119
+ * Update: All prefixed 'cl_' to 'custom_login_'.
120
+ * Update: Spelling error 'sanitize'.
121
+ * Tweak: Speed imporovments.
122
+ * Add: CL_Common::is_settings_page().
123
+
124
  = Version 3.0.8 (01/14/15) =
125
 
126
  * Add: Auth timout setting when remember me is checked and not.
uninstall.php CHANGED
@@ -23,9 +23,9 @@ foreach ( $sections as $section ) {
23
 
24
  delete_option( CUSTOM_LOGIN_OPTION . '_announcement_message' );
25
  delete_option( CUSTOM_LOGIN_OPTION . '_version' );
26
- delete_option( 'cl_tracking_last_send' );
27
- delete_option( 'cl_tracking_notice' );
28
 
29
  /** Cleanup Cron Events */
30
- wp_clear_scheduled_hook( 'cl_daily_scheduled_events' );
31
- wp_clear_scheduled_hook( 'cl_weekly_scheduled_events' );
23
 
24
  delete_option( CUSTOM_LOGIN_OPTION . '_announcement_message' );
25
  delete_option( CUSTOM_LOGIN_OPTION . '_version' );
26
+ delete_option( 'custom_login_tracking_last_send' );
27
+ delete_option( 'custom_login_hide_tracking_notice' );
28
 
29
  /** Cleanup Cron Events */
30
+ wp_clear_scheduled_hook( 'custom_login_daily_scheduled_events' );
31
+ wp_clear_scheduled_hook( 'custom_login_weekly_scheduled_events' );