Skip to content

Commit 739d834

Browse files
authored
Avoid passing $this to WP_Error in static methods (#12)
Fixes #11
1 parent 11645fb commit 739d834

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wp-user-signups/includes/classes/class-wp-signup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public static function get_instance( $signup ) {
167167
}
168168

169169
if ( ! is_numeric( $signup ) ) {
170-
return new WP_Error( 'wp_signups_invalid_id', esc_html__( 'Signup not found.', 'wp-user-signups' ), $this );
170+
return new WP_Error( 'wp_signups_invalid_id', esc_html__( 'Signup not found.', 'wp-user-signups' ), $signup );
171171
}
172172

173173
// Check cache first
@@ -207,7 +207,7 @@ public static function create( $args = array() ) {
207207

208208
// Bail if missing login or email
209209
if ( empty( $r['user_login'] ) || empty( $r['user_email'] ) ) {
210-
return new WP_Error( 'wp_signups_empty_id', esc_html__( 'Signup not found.', 'wp-user-signups' ), $this );
210+
return new WP_Error( 'wp_signups_empty_id', esc_html__( 'Signup not found.', 'wp-user-signups' ), $r );
211211
}
212212

213213
// Check for previous signup
@@ -219,7 +219,7 @@ public static function create( $args = array() ) {
219219

220220
// Domain exists already...
221221
if ( ! empty( $existing ) ) {
222-
return new WP_Error( 'wp_signups_domain_exists', esc_html__( 'That signup already exists.', 'wp-user-signups' ), $this );
222+
return new WP_Error( 'wp_signups_domain_exists', esc_html__( 'That signup already exists.', 'wp-user-signups' ), $existing );
223223
}
224224

225225
// Create the signup!
@@ -240,7 +240,7 @@ public static function create( $args = array() ) {
240240
$wpdb->print_error( $error['error_str'] );
241241
}
242242

243-
return new WP_Error( 'wp_signups_insert_failed', esc_html__( 'Signup creation failed.', 'wp-user-signups' ), $this );
243+
return new WP_Error( 'wp_signups_insert_failed', esc_html__( 'Signup creation failed.', 'wp-user-signups' ), $recent_errors );
244244
}
245245

246246
// Ensure the cache is flushed

0 commit comments

Comments
 (0)