Error 503 with wp_delete_attachment
Question
I´m doing a plugin which must do an import from an api.
Inside this import, I have to removed phisicaly pictures before saving new ones.
For some reasons this line code wp_delete_attachment( $attachment_id, true );
make this 503 error :
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
this code is wrapped in a hook to overwrite WPML :
public function delete_attachment_translations( $attachment_id ) {
remove_action( 'delete_attachment', 'delete_attachment_translations' );
$langs = apply_filters( 'wpml_active_languages', [] );
if ( ! empty( $langs ) ) {
global $wp_filter;
$hooks = $wp_filter['wp_delete_file']->callbacks[10];
unset( $wp_filter['wp_delete_file']->callbacks[10] );
wp_delete_attachment( $attachment_id, true );
$wp_filter['wp_delete_file']->callbacks[10] = $hooks;
}
add_action( 'delete_attachment', 'delete_attachment_translations' );
}
Someone has got an idea why and how to fix this ?
0
error-503, plugin-wpml, wp-delete-attachment
8 months
0 Answers
105 views
0
Leave an answer
You must login or register to add a new answer .