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

Commit

Permalink
Browse files Browse the repository at this point in the history
…into try/add-new-categories-in-editor-ui
  • Loading branch information
mike-day committed Jun 14, 2023
2 parents 4a57894 + bc81bfa commit 9dc9099
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 35 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
3 changes: 2 additions & 1 deletion wp-modules/app/js/src/components/App/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ html body.toplevel_page_pattern-manager {
margin-right: 0;

span {
font-weight: 600;
margin-left: 2px;
text-decoration: none;
}
}
}
Expand Down
33 changes: 29 additions & 4 deletions wp-modules/app/js/src/components/VersionControlNotice/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// WP dependencies
import { __ } from '@wordpress/i18n';
import { Notice } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { Notice, Dashicon } from '@wordpress/components';

type Props = {
isVisible: boolean;
Expand All @@ -19,9 +20,33 @@ export default function VersionControlNotice( {
status="warning"
onRemove={ handleDismiss }
>
{ __(
'No version control detected for this theme. We recommend adding version control so you do not lose your patterns during theme updates.',
'pattern-manager'
{ createInterpolateElement(
__(
'No version control detected for this theme. We recommend adding version control so you do not lose your patterns during theme updates. <div></div>Learn how to set up git for your theme in <a></a>.',
'pattern-manager'
),
{
div: <div style={ { marginTop: '1rem' } }></div>,
a: (
<a
href={
'https://developer.wpengine.com/knowledge-base/using-git-with-a-wordpress-theme/'
}
target="_blank"
rel="noopener noreferrer"
aria-label="Link to our Git Guide (opens in new tab)"
>
{ __( 'our Git Guide', 'pattern-manager' ) }
<span className="screen-reader-text">
{ __(
'(opens in a new tab)',
'pattern-manager'
) }
</span>
<Dashicon icon={ 'external' } />
</a>
),
}
) }
</Notice>
) : null;
Expand Down
55 changes: 29 additions & 26 deletions wp-modules/editor/js/src/blocks/pattern-block/PatternEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Panel,
PanelBody,
Placeholder,
Tooltip,
} from '@wordpress/components';
import { useState } from '@wordpress/element';
import { Icon, image, lock } from '@wordpress/icons';
Expand Down Expand Up @@ -120,34 +121,36 @@ export default function PatternEdit( {
{ __( 'Replace Pattern', 'pattern-manager' ) }
</Button>
</BlockControls>
<div
style={ {
right: '10px',
top: '10px',
position: 'absolute',
height: '35px',
width: '35px',
background: '#fff',
zIndex: '20',
borderRadius: '500px',
display: 'flex',
gap: '10px',
alignItems: 'center',
fontFamily:
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',
fontSize: '16px',
padding: '5px',
border: 'solid 1px rgba(0,0,0,.1)',
boxSizing: 'border-box',
} }
>
<Icon
icon={ lock }
<Tooltip text="Patterns shown within the Pattern Block are locked.">
<div
style={ {
width: '25px',
right: '10px',
top: '10px',
position: 'absolute',
height: '35px',
width: '35px',
background: '#fff',
zIndex: '20',
borderRadius: '500px',
display: 'flex',
gap: '10px',
alignItems: 'center',
fontFamily:
'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',
fontSize: '16px',
padding: '5px',
border: 'solid 1px rgba(0,0,0,.1)',
boxSizing: 'border-box',
} }
/>
</div>
>
<Icon
icon={ lock }
style={ {
width: '25px',
} }
/>
</div>
</Tooltip>
<ServerSideRender
block="core/pattern"
className="pm-pattern-container"
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 @@ -325,10 +325,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 9dc9099

Please sign in to comment.