Skip to content

Commit 6ae9c69

Browse files
fix: labels display
1 parent ac636a8 commit 6ae9c69

5 files changed

Lines changed: 110 additions & 77 deletions

File tree

includes/layouts/feedzy-tutorial.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</ul>
4848
<br/>
4949
<div>
50-
<a href="<?php echo esc_url( add_query_arg( 'post_type', 'feedzy_imports', admin_url( 'post-new.php' ) ) ); ?>" class="btn btn-outline-primary" target="_blank">
50+
<a href="<?php echo esc_url( add_query_arg( 'post_type', 'feedzy_imports', admin_url( 'post-new.php' ) ) ); ?>" class="btn btn-outline-primary">
5151
<?php esc_html_e( 'Import your first feed', 'feedzy-rss-feeds' ); ?>
5252
</a>
5353
</div>

includes/layouts/settings.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,6 @@ class="<?php echo $_tab === $active_tab ? esc_attr( 'active' ) : ''; ?>"
179179
<a href="javascript:;" class="feedzy-remove-media btn btn-outline-primary <?php echo $default_thumbnail_id ? esc_attr( 'is-show' ) : ''; ?>"><?php esc_html_e( 'Remove', 'feedzy-rss-feeds' ); ?></a>
180180
<input type="hidden" name="default-thumbnail-id" id="feed-post-default-thumbnail" value="<?php echo esc_attr( $default_thumbnail_id ); ?>">
181181
</div>
182-
<div class="help-text">
183-
<?php
184-
echo wp_kses(
185-
__( '<strong>How it works:</strong> When importing posts from RSS feeds, some items may not include images. This fallback image ensures all your <strong>imported posts</strong> have visual content by automatically applying this image as the featured image when needed.', 'feedzy-rss-feeds' ),
186-
array(
187-
'strong' => true,
188-
)
189-
);
190-
?>
191-
</div>
192182
</div>
193183
</div>
194184
<div class="form-block">
@@ -388,11 +378,11 @@ class="form-label"
388378
</label>
389379
</div>
390380
<div class="help-text pt-8">
391-
<?php esc_html_e( 'Send an email with the errors encountered. The frequency can be changed (once per week is the default).', 'feedzy-rss-feeds' ); ?>
381+
<?php esc_html_e( 'Enable email alerts for feed errors.', 'feedzy-rss-feeds' ); ?>
392382
</div>
393383
</div>
394384
<div
395-
class="fz-form-group <?php echo esc_attr( ! $email_error_enabled ? 'fz-hidden' : '' ); ?>"
385+
class="fz-form-group fz-log-email-address <?php echo esc_attr( ! $email_error_enabled ? 'fz-hidden' : '' ); ?>"
396386
>
397387
<label class="form-label fz-email-error-text">
398388
<?php esc_html_e( 'Email address', 'feedzy-rss-feeds' ); ?>
@@ -406,7 +396,7 @@ class="form-control"
406396
>
407397
</div>
408398
<div
409-
class="fz-form-group <?php echo esc_attr( ! $email_error_enabled ? 'fz-hidden' : '' ); ?>"
399+
class="fz-form-group fz-log-email-freq <?php echo esc_attr( ! $email_error_enabled ? 'fz-hidden' : '' ); ?>"
410400
>
411401
<label class="form-label" for="fz-logs-email-frequency">
412402
<?php esc_html_e( 'Email Reporting Frequency', 'feedzy-rss-feeds' ); ?>

js/FeedzyLoop/edit.js

Lines changed: 92 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
/**
33
* WordPress dependencies.
44
*/
5+
6+
import { __, sprintf } from '@wordpress/i18n';
7+
58
import {
69
store as blocksStore,
710
createBlocksFromInnerBlocksTemplate,
@@ -17,12 +20,13 @@ import {
1720

1821
import {
1922
Placeholder as BlockEditorPlaceholder,
23+
Notice,
2024
Spinner,
2125
} from '@wordpress/components';
2226

2327
import { useDispatch, useSelect } from '@wordpress/data';
2428

25-
import { useState } from '@wordpress/element';
29+
import { Fragment, useEffect, useState } from '@wordpress/element';
2630

2731
import ServerSideRender from '@wordpress/server-side-render';
2832

@@ -46,6 +50,7 @@ const Edit = ({ attributes, setAttributes, clientId }) => {
4650

4751
const [isEditing, setIsEditing] = useState(!attributes?.feed?.source);
4852
const [isPreviewing, setIsPreviewing] = useState(true);
53+
const [showPreviewNotice, setShowPreviewNotice] = useState(false);
4954

5055
const { clearSelectedBlock, replaceInnerBlocks } =
5156
useDispatch(blockEditorStore);
@@ -109,64 +114,43 @@ const Edit = ({ attributes, setAttributes, clientId }) => {
109114
});
110115
};
111116

112-
if (isEditing) {
113-
return (
114-
<div {...blockProps}>
115-
<Placeholder
116-
attributes={attributes}
117-
setAttributes={setAttributes}
118-
onSaveFeed={onSaveFeed}
119-
/>
120-
</div>
117+
useEffect(() => {
118+
const isPreviewNoticeHidden = localStorage.getItem(
119+
'feedzy-hide-preview-notice'
121120
);
122-
}
123-
124-
if ((!isSelected || isPreviewing) && innerBlocksContent) {
125-
return (
126-
<>
127-
<Controls
128-
attributes={attributes}
129-
isEditing={isEditing}
130-
isPreviewing={isPreviewing}
131-
setAttributes={setAttributes}
132-
onChangeLayout={onChangeLayout}
133-
onChangeQuery={onChangeQuery}
134-
setIsEditing={setIsEditing}
135-
setIsPreviewing={setIsPreviewing}
136-
/>
137-
138-
<div {...blockProps}>
139-
<ServerSideRender
140-
block="feedzy-rss-feeds/loop"
141-
attributes={{
142-
...attributes,
143-
innerBlocksContent,
144-
}}
145-
LoadingResponsePlaceholder={LoadingResponsePlaceholder}
146-
/>
147-
</div>
148-
</>
149-
);
150-
}
121+
if (!isPreviewNoticeHidden) {
122+
setShowPreviewNotice(true);
123+
}
124+
}, []);
151125

152126
const setVariations = (nextVariation = defaultVariation) => {
153127
if (nextVariation) {
154128
setAttributes({
155129
layout: {
156130
name: nextVariation.name,
157-
} ,
158-
...nextVariation.attributes
131+
},
132+
...nextVariation.attributes,
159133
});
160134

161135
replaceInnerBlocks(
162136
clientId,
163-
createBlocksFromInnerBlocksTemplate(
164-
nextVariation.innerBlocks
165-
),
137+
createBlocksFromInnerBlocksTemplate(nextVariation.innerBlocks),
166138
true
167139
);
168140
clearSelectedBlock();
169141
}
142+
};
143+
144+
if (isEditing) {
145+
return (
146+
<div {...blockProps}>
147+
<Placeholder
148+
attributes={attributes}
149+
setAttributes={setAttributes}
150+
onSaveFeed={onSaveFeed}
151+
/>
152+
</div>
153+
);
170154
}
171155

172156
return (
@@ -183,16 +167,71 @@ const Edit = ({ attributes, setAttributes, clientId }) => {
183167
variations={variations}
184168
setVariations={setVariations}
185169
/>
186-
187170
<div {...blockProps}>
188-
{hasInnerBlocks ? (
189-
<InnerBlocks />
190-
) : (
191-
<BlockVariationPicker
192-
variations={variations}
193-
onSelect={setVariations}
194-
/>
195-
)}
171+
{(() => {
172+
if ((!isSelected || isPreviewing) && innerBlocksContent) {
173+
return (
174+
<Fragment>
175+
{showPreviewNotice && (
176+
<Notice
177+
status="info"
178+
isDismissible={true}
179+
onRemove={() => {
180+
setShowPreviewNotice(false);
181+
localStorage.setItem(
182+
'feedzy-hide-preview-notice',
183+
'true'
184+
);
185+
}}
186+
>
187+
<p>
188+
<strong>
189+
{__(
190+
"You're in Preview Mode – This shows how your feed will look to visitors.",
191+
'feedzy-rss-feeds'
192+
)}
193+
</strong>
194+
</p>
195+
<p>
196+
{sprintf(
197+
// translators: %1$s is button label "Hide Preview".
198+
__(
199+
'To customize each element (title, meta, description) and adjust layouts, spacing, colors, and typography, click "%1$s" in the toolbar above to enter the advanced editor.',
200+
'feedzy-rss-feeds'
201+
),
202+
__(
203+
'Hide Preview',
204+
'feedzy-rss-feeds'
205+
)
206+
)}
207+
</p>
208+
</Notice>
209+
)}
210+
<ServerSideRender
211+
block="feedzy-rss-feeds/loop"
212+
attributes={{
213+
...attributes,
214+
innerBlocksContent,
215+
}}
216+
LoadingResponsePlaceholder={
217+
LoadingResponsePlaceholder
218+
}
219+
/>
220+
</Fragment>
221+
);
222+
}
223+
224+
if (hasInnerBlocks) {
225+
return <InnerBlocks />;
226+
}
227+
228+
return (
229+
<BlockVariationPicker
230+
variations={variations}
231+
onSelect={setVariations}
232+
/>
233+
);
234+
})()}
196235
</div>
197236
</>
198237
);

js/feedzy-setting.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,15 @@ jQuery(function ($) {
173173

174174
// Disable the Add Schedule button until all fields are filled.
175175
const validateScheduleForm = () => {
176+
const button = $('#fz-add-schedule');
177+
178+
if (!button.length) {
179+
return;
180+
}
181+
176182
const interval = $('#fz-schedule-interval').val().trim();
177183
const display = $('#fz-schedule-display').val().trim();
178184
const name = $('#fz-schedule-name').val().trim();
179-
const button = $('#fz-add-schedule');
180185

181186
const isValid = interval && display && name;
182187
button.prop('disabled', !isValid);
@@ -336,11 +341,15 @@ jQuery(function ($) {
336341
*/
337342
const toggleEmailErrorField = () => {
338343
const checkbox = $('#feedzy-email-error-enabled');
339-
const emailField = checkbox
340-
.closest('.fz-form-group')
341-
.next('.fz-form-group');
342344

343-
emailField.toggleClass('fz-hidden', !checkbox.is(':checked'));
345+
$('.fz-log-email-address').toggleClass(
346+
'fz-hidden',
347+
!checkbox.is(':checked')
348+
);
349+
$('.fz-log-email-freq').toggleClass(
350+
'fz-hidden',
351+
!checkbox.is(':checked')
352+
);
344353
};
345354

346355
$('#feedzy-email-error-enabled').on('change', toggleEmailErrorField);

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,11 +1655,6 @@ parameters:
16551655
count: 2
16561656
path: includes/layouts/settings.php
16571657

1658-
-
1659-
message: "#^Parameter \\#2 \\$allowed_html of function wp_kses expects array\\<array\\>\\|string, array\\<string, true\\> given\\.$#"
1660-
count: 1
1661-
path: includes/layouts/settings.php
1662-
16631658
-
16641659
message: "#^Variable \\$this might not be defined\\.$#"
16651660
count: 4

0 commit comments

Comments
 (0)