0

I Get an error when I want to add color or size in this plugin

Error Details

An error of type E_ERROR was caused in line 18 of the file /home/scrubers/public_html/wp-content/plugins/color-filters/Functions/Update_Admin_Databases.php. Error message: Uncaught Error: Cannot use object of type WP_Error as array in /home/scrubers/public_html/wp-content/plugins/color-filters/Functions/Update_Admin_Databases.php:18 Stack trace: #0 /home/scrubers/public_html/wp-content/plugins/color-filters/Functions/Update_Content.php(9): EWD_UWCF_Add_Color() #1 /home/scrubers/public_html/wp-includes/class-wp-hook.php(287): EWD_UWCF_Update_Content('') #2 /home/scrubers/public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #3 /home/scrubers/public_html/wp-includes/plugin.php(478): WP_Hook->do_action(Array) #4 /home/scrubers/public_html/wp-settings.php(546): do_action('init') #5 /home/scrubers/public_html/wp-config.php(78): require_once('/home/scrubers/...') #6 /home/scrubers/public_html/wp-load.php(37): require_once('/home/scrubers/...') #7 /home/scrubers/public_html/wp-admin/admin.php(34): require_once('/home/scrubers/...') #8 {main} thrown

0

1 Answer 1

0

Here's the relevant code (lines 13, 17 and 18):

$term = wp_insert_term(sanitize_text_field(
    $_POST['Color_Name']), 'product_color', $args);
$wc_term = wp_insert_term(sanitize_text_field(
    $_POST['Color_Name']), 'pa_ewd_uwcf_colors', $args);
update_term_meta($term['term_id'], 'EWD_UWCF_WC_Term_ID', $wc_term['term_id']);

You can see from the stack trace that either $term or $wc_term here must be a WP_Error object meaning that one of the wp_insert_term() calls failed. It would be useful to find out what that error is: I'd suggest adding

error_log( print_r( $term, true ) );
error_log( print_r( $wc_term, true ) );

between those two lines and reproducing the error again, then check your server or PHP error log to see the error details. After that I suggest you talk to the plugin authors and ask them to check is_wp_error($term) and is_wp_error($wc_term) here, and give them the error details too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.