mardi 3 mars 2015

Cannot use object of type WP_Error as array


Using a WordPress Plugin WPML I have been getting this error on saving a draft post:



PHP Fatal error: Cannot use object of type WP_Error as array in /home/user/http://ift.tt/1zHnWXt on line 1018


On that line I have



$new_term = wp_insert_term( $term_name, $taxonomy, array( 'slug' => self::term_unique_slug( sanitize_title( $term_name ), $taxonomy, $post_lang ) ) );
if ( isset( $new_term[ 'term_taxonomy_id' ] ) ) {
$ttid_in_correct_lang = $new_term[ 'term_taxonomy_id' ];
$trid = false;
if ( $bulk ) {
$trid = $sitepress->get_element_trid( $ttid, 'tax_' . $taxonomy );
}
$sitepress->set_element_language_details( $ttid_in_correct_lang, 'tax_' . $taxonomy, $trid, $post_lang );
}
}


In another thread I read about a similar issue, but not quite the same where a plugin was trying to access an object as an array. Any ideas how I could work this out?





Aucun commentaire:

Enregistrer un commentaire