do_action( 'wpml_delete_package', string $package_name, string $package_kind_slug )
- Type
- action
- Category
- Inserting Content
- WPML Version
- 2.2
Description
Deletes a string translation package*. When this action is called, all the data related to the package is deleted: package, strings, strings translations and jobs.
*String translation packages are registered with wpml_register_string and their translations retrieved with wpml_translate_string
Note: This hook requires the WPML String Translation module
Arguments
- $package_name
- (string) (Required) The unique name of the package as it was registered with wpml_register_string
- $package_kind_slug
- (string) (Required) The package kind slug as used when it was registered using wpml_register_string
Example usage
Example using Layouts
add_action( 'before_delete_post', 'my_deleted_post' );
function my_deleted_post( $post_id ) {
$is_a_layout_delete_action = isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'delete_layout_record';
$layout_ids_to_delete = isset( $_POST[ 'layout_id' ] ) ? (array)$_POST[ 'layout_id' ] : array();
if ( $is_a_layout_delete_action && in_array($post_id, $layout_ids_to_delete) ) {
$package_name = $post_id;
$package_kind_slug = 'layout';
do_action( 'wpml_delete_package', $package_name, $package_kind_slug );
}
}
Related hooks
wpml_set_element_language_details, wpml_make_post_duplicates, wpml_admin_make_post_duplicates, wpml_copy_post_to_language, wpml_import_get_trid_from_imported_translations, wpml_register_string, wpml_register_single_string, wpml_show_package_language_ui, wpml_delete_package_action