Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Don't tree shake in delete_pattern() (#196)
Browse files Browse the repository at this point in the history
* Don't tree shake on a simple call to delete_pattern()

* Fix linting
  • Loading branch information
kienstra authored Jun 13, 2023
1 parent da4f307 commit bc81bfa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 3 additions & 0 deletions wp-modules/api-data/api-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use WP_REST_Response;
use function \PatternManager\GetVersionControl\get_dismissed_themes;
use function \PatternManager\GetVersionControl\get_version_control_meta_key;
use function \PatternManager\GetWpFilesystem\get_wp_filesystem_api;
use function PatternManager\PatternDataHandlers\tree_shake_theme_images;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -108,6 +110,7 @@ function get_pattern_names() {
*/
function delete_pattern( $request ) {
$is_success = \PatternManager\PatternDataHandlers\delete_pattern( $request->get_params()['patternName'] );
tree_shake_theme_images( get_wp_filesystem_api(), 'copy_dir' );

return $is_success
? new WP_REST_Response(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export default function VersionControlNotice( {
div: <div style={ { marginTop: '1rem' } }></div>,
a: (
<a
target="_blank"
rel="noreferrer"
href={
'https://developer.wpengine.com/knowledge-base/using-git-with-a-wordpress-theme/'
}
Expand Down
5 changes: 1 addition & 4 deletions wp-modules/pattern-data-handlers/pattern-data-handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,7 @@ function update_pattern( $pattern ) {
function delete_pattern( string $pattern_name ): bool {
$wp_filesystem = \PatternManager\GetWpFilesystem\get_wp_filesystem_api();
$pattern_path = get_pattern_path( $pattern_name );
$result = $wp_filesystem && $wp_filesystem->exists( $pattern_path ) && $wp_filesystem->delete( $pattern_path );
tree_shake_theme_images( $wp_filesystem, 'copy_dir' );

return $result;
return $wp_filesystem && $wp_filesystem->exists( $pattern_path ) && $wp_filesystem->delete( $pattern_path );
}

/**
Expand Down

0 comments on commit bc81bfa

Please sign in to comment.