Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,32 @@ li.draggable-item .components-panel__body-toggle.components-button{
border-bottom: 0;
padding: 24px 0 0;
}
.fz-fallback-images {
display: flex;
flex-wrap: wrap;
gap: 1em;
margin: 1em 0 1em;
}
.feedzy-wrap .fz-spacing{
margin: 1em 0 1em;
}
.fz-radio-label {
font-weight: 600;
color: #333;
margin-bottom: 4px;
}
.fz-radio-description {
color: #666;
font-size: 13px;
line-height: 1.4;
display: block;
}
.fz-radio-title {
font-size: 16px;
font-weight: 600;
color: #050505;
}

@-webkit-keyframes spin {
100% { -webkit-transform: rotate(360deg); }
}
Expand Down
10 changes: 3 additions & 7 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,16 +524,12 @@ public function feedzy_import_feed_options() {
$import_feed_limit = 10;
}

$default_thumbnail_id = 0;
$default_thumbnail_id = 0;
$inherited_thumbnail_id = ! empty( $this->free_settings['general']['default-thumbnail-id'] ) ? (int) $this->free_settings['general']['default-thumbnail-id'] : 0;
if ( feedzy_is_pro() ) {
$default_thumbnail_id = get_post_meta( $post->ID, 'default_thumbnail_id', true );
if (
empty( $default_thumbnail_id ) &&
'0' !== $default_thumbnail_id // Can use the fallback image from Global Settings.
) {
$default_thumbnail_id = ! empty( $this->free_settings['general']['default-thumbnail-id'] ) ? (int) $this->free_settings['general']['default-thumbnail-id'] : 0;
}
}

$import_schedule = array(
'fz_cron_schedule' => ! empty( $this->free_settings['general']['fz_cron_schedule'] ) ? $this->free_settings['general']['fz_cron_schedule'] : '',
);
Expand Down
183 changes: 151 additions & 32 deletions includes/views/import-metabox-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,42 +702,154 @@ class="fz-switch-toggle" type="checkbox" value="yes"
<div class="form-block form-block-two-column <?php echo esc_attr( apply_filters( 'feedzy_upsell_class', '' ) ); ?>">
<?php echo wp_kses_post( apply_filters( 'feedzy_upsell_content', '', 'fallback-image', 'import' ) ); ?>
<div class="fz-left">
<h4 class="h4"><?php esc_html_e( 'Fallback Image', 'feedzy-rss-feeds' ); ?> <?php echo ! feedzy_is_pro() ? ' <span class="pro-label">PRO</span>' : ''; ?></h4>
<h4 class="h4">
<?php esc_html_e( 'Fallback Image', 'feedzy-rss-feeds' ); ?> <?php echo ! feedzy_is_pro() ? ' <span class="pro-label">PRO</span>' : ''; ?>
</h4>
</div>
<div class="fz-right">
<div class="fz-form-group">
<label class="form-label"><?php esc_html_e( 'Select an image to be the fallback featured image.', 'feedzy-rss-feeds' ); ?></label>
<?php
$btn_label = esc_html__( 'Choose image', 'feedzy-rss-feeds' );
$default_thumbnail_id = ! empty( $default_thumbnail_id ) ? explode( ',', (string) $default_thumbnail_id ) : array();
if ( ! empty( $default_thumbnail_id ) ) :
$btn_label = esc_html__( 'Replace image', 'feedzy-rss-feeds' );
?>
<div class="fz-form-group mb-20 feedzy-media-preview">
<?php
if ( count( $default_thumbnail_id ) > 1 ) {
<div class="form-label">
<?php esc_html_e( 'Which fallback featured image should be used for this feed?', 'feedzy-rss-feeds' ); ?>
</div>

<?php
$fallback_option = ! empty( $default_thumbnail_id ) ? 'custom' : 'general';
?>

<div class="fz-spacing">
<input
type="radio"
id="use-general-fallback"
name="feedzy_meta_data[fallback_image_option]"
value="general"
<?php checked( $fallback_option, 'general' ); ?>
>
<label for="use-general-fallback" class="fz-radio-label">
<strong class="fz-radio-title">
<?php esc_html_e( 'Use general setting', 'feedzy-rss-feeds' ); ?>
</strong>
<br>
<span class="fz-radio-description">
<?php esc_html_e( 'Updates automatically when the general fallback image changes.', 'feedzy-rss-feeds' ); ?>
</span>
</label>
</div>

<div
id="general-fallback-preview"
class="fz-spacing"
style="<?php echo 'general' === $fallback_option ? '' : 'display: none;'; ?>"
>
<?php if ( ! empty( $inherited_thumbnail_id ) ) : ?>
<div class="fz-form-group">
<?php
$image = wp_get_attachment_image( $inherited_thumbnail_id, 'thumbnail' );
if ( $image ) {
echo wp_kses_post( $image );
} else {
echo '<div class="help-text">' . esc_html__( 'General fallback image not found (may have been deleted)', 'feedzy-rss-feeds' ) . '</div>';
}
?>
<a href="javascript:;" class="btn btn-outline-primary feedzy-images-selected">
<?php
// translators: %d select images count.
echo esc_html( sprintf( __( '(%d) images selected', 'feedzy-rss-feeds' ), count( $default_thumbnail_id ) ) );
</div>
<?php else : ?>
<div class="fz-form-group mb-20">
<div class="help-text">
<?php
echo wp_kses_post(
__( 'No general fallback image set. ', 'feedzy-rss-feeds' )
);
?>
</a>
<?php
} else {
echo wp_get_attachment_image( reset( $default_thumbnail_id ), 'thumbnail' );
}
</div>
</div>
<?php endif; ?>

<div class="help-text pt-8">
<?php
echo wp_kses_post(
sprintf(
/* translators: %s is replaced with a link to the Feedzy Settings page */
__( 'You can update the general fallback image in %s.', 'feedzy-rss-feeds' ),
'<a href="' . esc_url( admin_url( 'admin.php?page=feedzy-settings' ) ) . '" target="_blank">' . esc_html__( 'Feedzy Settings', 'feedzy-rss-feeds' ) . '</a>'
)
);
?>
</div>
<?php endif; ?>
<div class="fz-cta-group pb-8">
<a href="javascript:;" class="feedzy-open-media btn btn-outline-primary"><?php echo esc_html( $btn_label ); ?></a>
<a href="javascript:;" class="feedzy-remove-media btn btn-outline-primary <?php echo ! empty( $default_thumbnail_id ) ? esc_attr( 'is-show' ) : ''; ?>"><?php esc_html_e( 'Remove', 'feedzy-rss-feeds' ); ?></a>
<input type="hidden" name="feedzy_meta_data[default_thumbnail_id]" id="feed-post-default-thumbnail" value="<?php echo esc_attr( implode( ',', $default_thumbnail_id ) ); ?>">
</div>
<div class="help-text pt-8">
<?php esc_html_e( 'Helpful for setting a fallback image for feed items without an image. If multiple fallback images are selected, one of them will be randomly assigned to each post without an image during the import process.', 'feedzy-rss-feeds' ); ?>

<div class="fz-spacing">
<input
type="radio"
id="use-custom-fallback"
name="feedzy_meta_data[fallback_image_option]"
value="custom"
<?php checked( $fallback_option, 'custom' ); ?>
>
<label for="use-custom-fallback" class="fz-radio-label">
<strong class="fz-radio-title">
<?php esc_html_e( 'Add custom fallback image', 'feedzy-rss-feeds' ); ?>
</strong>
<br>
<span class="fz-radio-description small">
<?php esc_html_e( 'Use a specific image just for this feed.', 'feedzy-rss-feeds' ); ?>
</span>
</label>
</div>

<div
id="custom-fallback-section"
style="<?php echo 'custom' === $fallback_option ? '' : 'display: none;'; ?>"
>
<?php
$btn_label = esc_html__( 'Choose image', 'feedzy-rss-feeds' );
$saved_fallback_thumbnail_ids = is_string( $default_thumbnail_id ) ? explode( ',', $default_thumbnail_id ) : array();
$valid_thumbnail_ids = array_filter( $saved_fallback_thumbnail_ids, 'is_numeric' );
$valid_thumbnail_ids = array_filter(
$valid_thumbnail_ids,
function ( $id ) {
return wp_attachment_is_image( intval( $id ) );
}
);

if ( ! empty( $valid_thumbnail_ids ) ) :
$btn_label = esc_html__( 'Replace image', 'feedzy-rss-feeds' );
?>
<div class="fz-form-group feedzy-media-preview ">
<div class="fz-fallback-images">
<?php
foreach ( $valid_thumbnail_ids as $thumbnail_id ) {
echo wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
}
?>
</div>
</div>
<?php endif; ?>

<div class="fz-cta-group pb-8">
<a
href="javascript:;"
class="feedzy-open-media btn btn-outline-primary"
>
<?php
echo esc_html( $btn_label );
?>
</a>
<a
href="javascript:;"
class="feedzy-remove-media btn btn-outline-primary <?php echo ! empty( $valid_thumbnail_ids ) ? esc_attr( 'is-show' ) : ''; ?>"
>
<?php esc_html_e( 'Remove', 'feedzy-rss-feeds' ); ?>
</a>
<input
type="hidden"
name="feedzy_meta_data[default_thumbnail_id]"
id="feed-post-default-thumbnail"
value="<?php echo esc_attr( implode( ',', $valid_thumbnail_ids ) ); ?>"
>
</div>
</div>
</div>
<div class="help-text pt-8">
<?php esc_html_e( 'Helpful for setting a fallback image for feed items without an image during the import process.', 'feedzy-rss-feeds' ); ?>
</div>
</div>
</div>
Expand All @@ -748,15 +860,22 @@ class="fz-switch-toggle" type="checkbox" value="yes"

<div class="form-block form-block-two-column no-border">
<div class="fz-left">
<h4 class="h4"><?php esc_html_e( 'Remove Duplicates', 'feedzy-rss-feeds' ); ?></h4>
<h4 class="h4">
<?php esc_html_e( 'Remove Duplicates', 'feedzy-rss-feeds' ); ?>
</h4>
</div>
<div class="fz-right">
<div class="fz-form-group">
<div class="fz-form-switch">
<input id="remove-duplicates" name="feedzy_meta_data[import_remove_duplicates]"
class="fz-switch-toggle" type="checkbox" value="yes"
<?php echo esc_attr( $import_remove_duplicates ); ?>>
<label class="feedzy-inline form-label" for="remove-duplicates"><?php esc_html_e( 'Remove Duplicate Items', 'feedzy-rss-feeds' ); ?></label>
<input
id="remove-duplicates"
name="feedzy_meta_data[import_remove_duplicates]"
class="fz-switch-toggle" type="checkbox" value="yes"
<?php echo esc_attr( $import_remove_duplicates ); ?>
>
<label class="feedzy-inline form-label" for="remove-duplicates">
<?php esc_html_e( 'Remove Duplicate Items', 'feedzy-rss-feeds' ); ?>
</label>
</div>
</div>
<div class="help-text">
Expand Down
Loading
Loading