Code Duplication    Length = 17-18 lines in 2 locations

includes/abstracts/abstract-wc-rest-posts-controller.php 1 location

@@ 447-463 (lines=17) @@
444
		// If we're forcing, then delete permanently.
445
		if ( $force ) {
446
			$result = wp_delete_post( $id, true );
447
		} else {
448
			// If we don't support trashing for this type, error out.
449
			if ( ! $supports_trash ) {
450
				/* translators: %s: post type */
451
				return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
452
			}
453
454
			// Otherwise, only trash if we haven't already.
455
			if ( 'trash' === $post->post_status ) {
456
				/* translators: %s: post type */
457
				return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
458
			}
459
460
			// (Note that internally this falls through to `wp_delete_post` if
461
			// the trash is disabled.)
462
			$result = wp_trash_post( $id );
463
		}
464
465
		if ( ! $result ) {
466
			/* translators: %s: post type */

includes/api/v1/class-wc-rest-products-controller.php 1 location

@@ 1684-1701 (lines=18) @@
1681
1682
			$product->delete( true );
1683
			$result = ! ( $product->get_id() > 0 );
1684
		} else {
1685
			// If we don't support trashing for this type, error out.
1686
			if ( ! $supports_trash ) {
1687
				/* translators: %s: post type */
1688
				return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
1689
			}
1690
1691
			// Otherwise, only trash if we haven't already.
1692
			if ( 'trash' === $post->post_status ) {
1693
				/* translators: %s: post type */
1694
				return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
1695
			}
1696
1697
			// (Note that internally this falls through to `wp_delete_post` if
1698
			// the trash is disabled.)
1699
			$product->delete();
1700
			$result = 'trash' === $product->get_status();
1701
		}
1702
1703
		if ( ! $result ) {
1704
			/* translators: %s: post type */