Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Fixed Action Scheduler time issue with the old method
- Fixed Global Fallback image issue
- Fixed Feedzy Loop button not working with Groups
  • Loading branch information
vytisbulkevicius authored Jan 10, 2025
2 parents 848610b + bfd76b9 commit 0e21337
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 16 deletions.
6 changes: 5 additions & 1 deletion includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,10 @@ public function manage_feedzy_import_columns( $column, $post_id ) {
if ( ! $next ) {
$next = Feedzy_Rss_Feeds_Util_Scheduler::is_scheduled( 'feedzy_cron' );
}
if ( $next ) {
if ( is_numeric( $next ) ) {
echo wp_kses_post( human_time_diff( $next, time() ) );
} elseif ( $next ) {
echo esc_html__( 'in-progress', 'feedzy-rss-feeds' );
}
break;
default:
Expand Down Expand Up @@ -1469,6 +1471,8 @@ private function run_job( $job, $max ) {
if ( feedzy_is_pro() ) {
$default_thumbnail = get_post_meta( $job->ID, 'default_thumbnail_id', true );
$default_thumbnail = ! empty( $default_thumbnail ) ? explode( ',', (string) $default_thumbnail ) : $global_fallback_thumbnail;
} else {
$default_thumbnail = $global_fallback_thumbnail;
}

// Note: this implementation will only work if only one of the fields is allowed to provide
Expand Down
7 changes: 3 additions & 4 deletions includes/util/feedzy-rss-feeds-util-scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ class Feedzy_Rss_Feeds_Util_Scheduler {
* @return bool|int
*/
public static function is_scheduled( string $hook, array $args = array() ) {
if ( function_exists( 'as_has_scheduled_action' ) ) {
return as_has_scheduled_action( $hook, $args );
}

if ( function_exists( 'as_next_scheduled_action' ) ) {
// For older versions of AS.
return as_next_scheduled_action( $hook, $args );
}
if ( function_exists( 'as_has_scheduled_action' ) ) {
return as_has_scheduled_action( $hook, $args );
}

return wp_next_scheduled( $hook, $args );
}
Expand Down
6 changes: 3 additions & 3 deletions includes/views/import-metabox-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ class="fz-switch-toggle" type="checkbox" value="yes"
<?php echo esc_attr( $import_feed_delete_media ); ?>>
<label class="feedzy-inline form-label" for="delete-attached-media"><?php esc_html_e( 'Delete attached featured image', 'feedzy-rss-feeds' ); ?></label>
</div>
</div>
<div class="help-text">
<?php echo wp_sprintf( esc_html__( 'Helpful if you want to delete attached featured image when posts are automatically deleted.', 'feedzy-rss-feeds' ) ); ?>
<div class="help-text">
<?php echo wp_sprintf( esc_html__( 'Helpful if you want to delete attached featured image when posts are automatically deleted.', 'feedzy-rss-feeds' ) ); ?>
</div>
</div>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions js/FeedzyLoop/components/FeedControl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';

import { useState, useEffect, useRef } from '@wordpress/element';

const FeedControl = ({ value, options, onChange }) => {
Expand Down Expand Up @@ -80,7 +82,10 @@ const FeedControl = ({ value, options, onChange }) => {
value={selectedOption ? selectedOption.label : inputValue}
onChange={handleInputChange}
onBlur={handleInputBlur}
placeholder="Enter URLs or select a category"
placeholder={__(
'Enter URLs or select a Feed Group',
'feedzy-rss-feeds'
)}
disabled={selectedOption !== null}
className="fz-input-field"
/>
Expand All @@ -89,7 +94,7 @@ const FeedControl = ({ value, options, onChange }) => {
<button
onClick={handleClear}
className="fz-clear-button"
title="Clear selection"
title={__('Clear', 'feedzy-rss-feeds')}
>
<svg
width="14"
Expand All @@ -111,6 +116,7 @@ const FeedControl = ({ value, options, onChange }) => {
<button
onClick={() => setIsOpen(!isOpen)}
className="fz-dropdown-button"
title={__('Select Feed Group', 'feedzy-rss-feeds')}
>
<svg
width="12"
Expand Down
5 changes: 1 addition & 4 deletions js/FeedzyLoop/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ const BlockPlaceholder = ({ attributes, setAttributes, onSaveFeed }) => {
<Button
variant="primary"
onClick={() => {
if (
attributes?.feed?.source &&
attributes?.feed?.source.length > 0
) {
if (attributes?.feed?.source) {
onSaveFeed();
}
}}
Expand Down
37 changes: 35 additions & 2 deletions tests/e2e/specs/loop.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ test.describe('Feedzy Loop', () => {
const POST_TITLE = `Feedzy Loop Test ${Math.floor(Math.random() * 1000)}`;

test('add Feedzy Loop Block', async ({ editor, page }) => {
await page.goto('/wp-admin/post-new.php?post_type=feedzy_categories');
await page.getByLabel('Add title').click();
await page.keyboard.type('Group One');

await page.locator('textarea[name="feedzy_category_feed"]').click();
await page.keyboard.type(FEED_URL);
await page
.getByRole('button', { name: 'Publish', exact: true })
.click();
await page.waitForTimeout(1000);

await page.goto('/wp-admin/post-new.php');

if (
Expand Down Expand Up @@ -36,13 +47,35 @@ test.describe('Feedzy Loop', () => {
await page.getByPlaceholder('Enter URLs or select a').click();
await page.keyboard.type(FEED_URL);

const loadFeedButton = await page.getByRole('button', {
name: 'Load Feed',
exact: true,
});
const isDisabled = await loadFeedButton.isDisabled();
expect(isDisabled).toBe(false);
await loadFeedButton.click();
await page.waitForTimeout(1000);

await page.getByLabel('Display curated RSS content').click();
await page.waitForTimeout(1000);

// Now that we have tested we can insert URL, we can test the Feed Group.

await page
.getByLabel('Block: Feedzy Loop')
.locator('div')
.nth(1)
.click();
await page.getByRole('button', { name: 'Edit Feed' }).click();

await page.getByRole('button', { name: 'Select Feed Group' }).click();
await page.locator('.fz-dropdown-item').first().click();

await page
.getByRole('button', { name: 'Load Feed', exact: true })
.click();
await page.waitForTimeout(1000);

await page.getByLabel('Display curated RSS content').click();

await page
.getByRole('button', { name: 'Publish', exact: true })
.click();
Expand Down

0 comments on commit 0e21337

Please sign in to comment.