Skip to content

Commit 0e815c2

Browse files
committed
feat: qa testing enhancements
1 parent 910d22f commit 0e815c2

File tree

6 files changed

+308
-223
lines changed

6 files changed

+308
-223
lines changed

includes/gutenberg/feedzy-rss-feeds-loop-block.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,17 @@ public function register_block() {
100100
public function render_callback( $attributes, $content ) {
101101
$content = empty( $content ) ? ( $attributes['innerBlocksContent'] ?? '' ) : $content;
102102
$is_preview = isset( $attributes['innerBlocksContent'] ) && ! empty( $attributes['innerBlocksContent'] );
103+
$feed_urls = array();
103104

104105
if ( isset( $attributes['feed']['type'] ) && 'group' === $attributes['feed']['type'] && isset( $attributes['feed']['source'] ) && is_numeric( $attributes['feed']['source'] ) ) {
105106
$group = $attributes['feed']['source'];
106107
$value = get_post_meta( $group, 'feedzy_category_feed', true );
107108
$value = trim( $value );
108-
$value = !empty( $value ) ? explode( ',', $value ) : array();
109-
$feed_urls = ( count( $value ) === 1 ) ? esc_url( $value[0] ) : $value;
109+
$feed_urls = !empty( $value ) ? explode( ',', $value ) : array();
110110
}
111111

112112
if ( isset( $attributes['feed']['type'] ) && 'url' === $attributes['feed']['type'] && isset( $attributes['feed']['source'] ) && is_array( $attributes['feed']['source'] ) ) {
113-
$value = $attributes['feed']['source'];
114-
$feed_urls = ( count( $value ) === 1 ) ? esc_url( $value[0] ) : $value;
113+
$feed_urls = $attributes['feed']['source'];
115114
}
116115

117116
if ( empty( $feed_urls ) ) {
@@ -130,6 +129,7 @@ public function render_callback( $attributes, $content ) {
130129
$filters = isset( $attributes['conditions'] ) ? $attributes['conditions'] : array();
131130

132131
$options = array(
132+
'feeds' => implode( ',', $feed_urls ),
133133
'max' => $query['max'],
134134
'sort' => $query['sort'],
135135
'offset' => 0,
@@ -157,8 +157,7 @@ public function render_callback( $attributes, $content ) {
157157
return '<div>' . esc_html__( 'An error occurred while fetching the feed.', 'feedzy-rss-feeds' ) . '</div>';
158158
}
159159

160-
$sizes = apply_filters( 'feedzy_thumb_sizes', $sizes, $feed_urls );
161-
$feed_items = apply_filters( 'feedzy_get_feed_array', array(), $options, $feed, $feed_urls, $sizes );
160+
$feed_items = apply_filters( 'feedzy_get_feed_array', array(), $options, $feed, implode( ',', $feed_urls ), $sizes );
162161
$loop = '';
163162

164163
foreach ($feed_items as $key => $item) {

includes/util/feedzy-rss-feeds-conditions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function migrate_conditions( $conditions ): string {
177177
*/
178178
public function is_condition_met( $condition, $value ): bool {
179179
$operator = $condition['operator'];
180-
$condition_value = trim( $condition['value'] );
180+
$condition_value = trim( $condition['value'] ?? '' );
181181
$value = trim( $value );
182182

183183
switch ( $operator ) {

js/FeedzyLoop/controls.js

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/**
2+
* WordPress dependencies.
3+
*/
4+
import { __ } from '@wordpress/i18n';
5+
6+
import { BlockControls, InspectorControls } from '@wordpress/block-editor';
7+
8+
import {
9+
Button,
10+
PanelBody,
11+
RangeControl,
12+
SelectControl,
13+
ToolbarButton,
14+
ToolbarGroup,
15+
} from '@wordpress/components';
16+
17+
/**
18+
* Internal dependencies.
19+
*/
20+
import ConditionsControl from '../Conditions/ConditionsControl';
21+
22+
const Controls = ({
23+
attributes,
24+
isEditing,
25+
isPreviewing,
26+
setAttributes,
27+
onChangeLayout,
28+
onChangeQuery,
29+
setIsEditing,
30+
setIsPreviewing,
31+
}) => (
32+
<>
33+
<BlockControls>
34+
<ToolbarGroup>
35+
<ToolbarButton
36+
icon="edit"
37+
title={__('Edit Feed', 'feedzy-rss-feeds')}
38+
onClick={() => setIsEditing(true)}
39+
/>
40+
</ToolbarGroup>
41+
42+
<ToolbarGroup>
43+
<ToolbarButton onClick={() => setIsPreviewing(!isPreviewing)}>
44+
{isPreviewing
45+
? __('Hide Preview', 'feedzy-rss-feeds')
46+
: __('Show Preview', 'feedzy-rss-feeds')}
47+
</ToolbarButton>
48+
</ToolbarGroup>
49+
</BlockControls>
50+
51+
<InspectorControls>
52+
{!isEditing && (
53+
<PanelBody
54+
initialOpen={false}
55+
title={__('Feed Source', 'feedzy-rss-feeds')}
56+
key="source"
57+
>
58+
<Button
59+
variant="secondary"
60+
onClick={() => setIsEditing(true)}
61+
style={{
62+
width: '100%',
63+
justifyContent: 'center',
64+
}}
65+
>
66+
{__('Edit Feed', 'feedzy-rss-feeds')}
67+
</Button>
68+
</PanelBody>
69+
)}
70+
71+
<PanelBody
72+
title={__('Settings', 'feedzy-rss-feeds')}
73+
key="settings"
74+
>
75+
<RangeControl
76+
label={__('Column Count', 'feedzy-rss-feeds')}
77+
value={attributes?.layout?.columnCount || 1}
78+
onChange={(value) =>
79+
onChangeLayout({ type: 'columnCount', value })
80+
}
81+
min={1}
82+
max={5}
83+
/>
84+
85+
<RangeControl
86+
label={__('Number of Items', 'feedzy-rss-feeds')}
87+
value={attributes?.query?.max || 5}
88+
onChange={(value) => onChangeQuery({ type: 'max', value })}
89+
min={1}
90+
max={20}
91+
/>
92+
93+
<SelectControl
94+
label={__('Sorting Order', 'feedzy-rss-feeds')}
95+
value={attributes?.query?.sort}
96+
options={[
97+
{
98+
label: __('Default', 'feedzy-rss-feeds'),
99+
value: 'default',
100+
},
101+
{
102+
label: __('Date Descending', 'feedzy-rss-feeds'),
103+
value: 'date_desc',
104+
},
105+
{
106+
label: __('Date Ascending', 'feedzy-rss-feeds'),
107+
value: 'date_asc',
108+
},
109+
{
110+
label: __('Title Descending', 'feedzy-rss-feeds'),
111+
value: 'title_desc',
112+
},
113+
{
114+
label: __('Title Ascending', 'feedzy-rss-feeds'),
115+
value: 'title_asc',
116+
},
117+
]}
118+
onChange={(value) => onChangeQuery({ type: 'sort', value })}
119+
/>
120+
121+
<SelectControl
122+
label={__('Feed Caching Time', 'feedzy-rss-feeds')}
123+
value={attributes?.query?.refresh || '12_hours'}
124+
options={[
125+
{
126+
label: __('1 Hour', 'feedzy-rss-feeds'),
127+
value: '1_hours',
128+
},
129+
{
130+
label: __('2 Hours', 'feedzy-rss-feeds'),
131+
value: '3_hours',
132+
},
133+
{
134+
label: __('12 Hours', 'feedzy-rss-feeds'),
135+
value: '12_hours',
136+
},
137+
{
138+
label: __('1 Day', 'feedzy-rss-feeds'),
139+
value: '1_days',
140+
},
141+
{
142+
label: __('3 Days', 'feedzy-rss-feeds'),
143+
value: '3_days',
144+
},
145+
{
146+
label: __('15 Days', 'feedzy-rss-feeds'),
147+
value: '15_days',
148+
},
149+
]}
150+
onChange={(value) =>
151+
onChangeQuery({ type: 'refresh', value })
152+
}
153+
/>
154+
</PanelBody>
155+
156+
<PanelBody
157+
title={[
158+
__('Filter items', 'feedzy-rss-feeds'),
159+
!window.feedzyData.isPro && (
160+
<span className="fz-pro-label">Pro</span>
161+
),
162+
]}
163+
initialOpen={false}
164+
key="filters"
165+
className={
166+
window.feedzyData.isPro
167+
? 'feedzy-item-filter'
168+
: 'feedzy-item-filter fz-locked'
169+
}
170+
>
171+
<ConditionsControl
172+
conditions={
173+
attributes?.conditions || {
174+
conditions: [],
175+
match: 'all',
176+
}
177+
}
178+
setConditions={(conditions) => {
179+
setAttributes({ conditions });
180+
}}
181+
/>
182+
</PanelBody>
183+
</InspectorControls>
184+
</>
185+
);
186+
187+
export default Controls;

0 commit comments

Comments
 (0)