Skip to content

Commit ccb3588

Browse files
feat: improve taxonomy setting UI
1 parent d26b431 commit ccb3588

File tree

4 files changed

+136
-57
lines changed

4 files changed

+136
-57
lines changed

css/settings.css

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,40 @@ fieldset[disabled] .form-control {
560560
}
561561
.fz-form-wrap .chosen-container .chosen-results li{
562562
padding: 8px;
563-
font-weight: 500;
563+
font-weight: 600;
564564
font-size: 16px;
565565
line-height: 19px;
566566
color: #050505;
567567
}
568+
.fz-form-wrap .chosen-container .chosen-results li.group-result{
569+
font-weight: normal;
570+
text-transform: uppercase;
571+
color: #000000bd;
572+
pointer-events: none;
573+
}
574+
.fz-form-wrap .chosen-container .chosen-results li.feedzy-pro-terms{
575+
pointer-events: none;
576+
font-weight: 500;
577+
}
578+
.fz-form-wrap .chosen-container .chosen-results li.feedzy-separator{
579+
font-size: 0;
580+
padding: 0;
581+
border-bottom: 1px solid #757575;
582+
height: 0;
583+
}
584+
.fz-form-wrap .chosen-container .chosen-results li.feedzy-pro-term{
585+
display: flex;
586+
align-items: center;
587+
gap: 10px;
588+
color: #757575;
589+
pointer-events: none;
590+
}
591+
.fz-form-wrap .chosen-container .chosen-results li.feedzy-pro-term .pro-label{
592+
background: #80a2ff;
593+
padding-left: 7px;
594+
padding-right: 7px;
595+
border-radius: 5px;
596+
}
568597
.fz-form-wrap .chosen-container .chosen-results li:hover,
569598
.fz-form-wrap .chosen-container .chosen-results li.result-selected{
570599
background: #F2F2F2;

includes/admin/feedzy-rss-feeds-import.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public function enqueue_styles() {
188188
feedzy_is_pro() ? 'dashicons-upload' : 'dashicons-lock',
189189
esc_html__( 'Upload Import', 'feedzy-rss-feeds' )
190190
),
191+
'is_pro' => feedzy_is_pro(),
191192
),
192193
)
193194
);
@@ -502,6 +503,19 @@ public function feedzy_import_feed_options() {
502503
$import_post_term = '[#auto_categories]';
503504
}
504505

506+
if ( feedzy_is_pro() ) {
507+
$custom_terms = array(
508+
'[#item_categories]' => __( 'Item Categories', 'feedzy-rss-feeds' ),
509+
'[#auto_categories]' => __( 'Auto Categories by keyword', 'feedzy-rss-feeds' ),
510+
);
511+
} elseif ( ! feedzy_is_pro() ) {
512+
$custom_terms = array(
513+
'[#item_categories]' => __( 'Item Categories', 'feedzy-rss-feeds' ) . sprintf( '<span class="pro-label">%s</span>', __( 'PRO', 'feedzy-rss-feeds' ) ),
514+
'[#auto_categories]' => __( 'Auto Categories by keyword', 'feedzy-rss-feeds' ) . sprintf( '<span class="pro-label">%s</span>', __( 'PRO', 'feedzy-rss-feeds' ) ),
515+
);
516+
}
517+
$custom_post_term = wp_json_encode( $custom_terms );
518+
505519
$import_link_author_admin = get_post_meta( $post->ID, 'import_link_author_admin', true );
506520
$import_link_author_public = get_post_meta( $post->ID, 'import_link_author_public', true );
507521

@@ -661,6 +675,7 @@ public function save_feedzy_import_feed_meta( $post_id, $post ) {
661675
$data_meta['import_use_external_image'] = isset( $data_meta['import_use_external_image'] ) ? $data_meta['import_use_external_image'] : 'no';
662676
// Check feeds remove html checkbox checked OR not.
663677
$data_meta['import_remove_html'] = isset( $data_meta['import_remove_html'] ) ? $data_meta['import_remove_html'] : 'no';
678+
$data_meta['import_post_term'] = isset( $data_meta['import_post_term'] ) ? $data_meta['import_post_term'] : '';
664679

665680
// If it is filter_conditions we want to escape it.
666681
if ( isset( $data_meta['filter_conditions'] ) ) {

includes/views/import-metabox-edit.php

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class="dashicons dashicons-arrow-down-alt2"></span>
160160
<label class="form-label"><?php esc_html_e( 'The post type you want to use for the generated post.', 'feedzy-rss-feeds' ); ?></label>
161161
<div class="mx-320">
162162
<select id="feedzy_post_type" class="form-control feedzy-chosen" name="feedzy_meta_data[import_post_type]"
163-
data-tax="<?php echo esc_attr( $import_post_term ); ?>">
163+
data-tax="<?php echo esc_attr( $import_post_term ); ?>" data-custom-tag="<?php echo esc_attr( isset( $custom_post_term ) ? $custom_post_term : '' ); ?>">
164164
<?php
165165
foreach ( $post_types as $_post_type ) {
166166
?>
@@ -181,57 +181,44 @@ class="dashicons dashicons-arrow-down-alt2"></span>
181181
</div>
182182
<div class="fz-right">
183183
<div class="fz-form-group">
184-
<label class="form-label"><?php esc_html_e( 'Assigns the post to a Category', 'feedzy-rss-feeds' ); ?></label>
185184
<div class="mx-320">
186185
<select id="feedzy_post_terms" multiple class="form-control feedzy-chosen<?php echo feedzy_is_pro() ? ' fz-chosen-custom-tag' : ''; ?>"
187186
name="feedzy_meta_data[import_post_term][]">
188187
</select>
189188
</div>
190189
<div class="help-text pt-8">
191-
<?php esc_html_e( 'The imported post will be assigned to a selected taxonomy. Leave it blank if you don\'t need a taxonomy.', 'feedzy-rss-feeds' ); ?>
190+
<?php esc_html_e( 'If you don\'t select at least one taxonomy, posts will be assigned to Uncategorized by default.', 'feedzy-rss-feeds' ); ?>
192191
</div>
193192
</div>
194-
<?php if ( ! feedzy_is_pro() ) : ?>
195-
<div class="upgrade-alert">
193+
<?php if ( feedzy_is_pro() ) : ?>
194+
<div class="help-text pt-8">
196195
<?php
197196
echo wp_kses_post(
198197
sprintf(
199-
// translators: %1$s: opening anchor tag, %2$s: closing anchor tag.
200-
__( 'Add more advanced tags, like item categories and custom field, by %1$s upgrading to Feedzy Pro %2$s', 'feedzy-rss-feeds' ),
201-
'<a href="' . esc_url( tsdk_translate_link( tsdk_utmify( FEEDZY_UPSELL_LINK, 'moreadvanced' ) ) ) . '" target="_blank">',
198+
// translators: %1$s: magic tag, %2$s: opening anchor tag, %3$s: closing anchor tag.
199+
__( 'Auto-create categories from source: %1$s %2$s Learn More %3$s', 'feedzy-rss-feeds' ),
200+
'<strong>[#item_categories]</strong>',
201+
'<a href="' . esc_url( 'https://docs.themeisle.com/article/1154-how-to-use-feed-to-post-feature-in-feedzy#dynamic-post-taxonomy' ) . '" target="_blank">',
202202
'</a>'
203203
)
204204
);
205205
?>
206206
</div>
207-
<?php endif; ?>
208-
<div class="help-text pt-8">
209-
<?php
210-
echo wp_kses_post(
211-
sprintf(
212-
// translators: %1$s: magic tag, %2$s: opening anchor tag, %3$s: closing anchor tag.
213-
__( 'You can automatically create categories with a magic tag %1$s or use custom tag parsing %2$s Read More %3$s .', 'feedzy-rss-feeds' ),
214-
'<strong>[#item_categories]</strong>',
215-
'<a href="' . esc_url( 'https://docs.themeisle.com/article/1154-how-to-use-feed-to-post-feature-in-feedzy#dynamic-post-taxonomy' ) . '" target="_blank">',
216-
'</a>'
217-
)
218-
);
219-
?>
220-
</div>
221-
<div class="help-text pt-8">
222-
<?php
223-
// phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
224-
echo wp_kses_post(
225-
sprintf(
226-
// translators: %1$s: magic tag, %2$s: opening anchor tag, %3$s: closing anchor tag.
227-
__( 'You can automatically assign categories with a magic tag %1$s by the keywords used in title. Configure it %2$s here%3$s .', 'feedzy-rss-feeds' ),
228-
'<strong>[#auto_categories]</strong>',
229-
'<a href="' . esc_url( get_admin_url( null, 'admin.php?page=feedzy-settings' ) ) . '" target="_blank">',
230-
'</a>'
231-
)
232-
);
207+
<div class="help-text pt-8">
208+
<?php
209+
// phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
210+
echo wp_kses_post(
211+
sprintf(
212+
// translators: %1$s: magic tag, %2$s: opening anchor tag, %3$s: closing anchor tag.
213+
__( 'Auto-assign by title keywords: %1$s %2$s Configure %3$s', 'feedzy-rss-feeds' ),
214+
'<strong>[#auto_categories]</strong>',
215+
'<a href="' . esc_url( get_admin_url( null, 'admin.php?page=feedzy-settings' ) ) . '" target="_blank">',
216+
'</a>'
217+
)
218+
);
233219
?>
234-
</div>
220+
</div>
221+
<?php endif; ?>
235222
</div>
236223
</div>
237224

includes/views/js/import-metabox-edit.js

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
function update_taxonomy() {
171171
const selected = $(this).val();
172172
let tax_selected = $(this).data('tax');
173+
const custom_tag = $(this).data('custom-tag');
173174
if (typeof tax_selected !== 'undefined') {
174175
tax_selected = tax_selected.split(',');
175176
} else {
@@ -239,8 +240,37 @@
239240
tax_selected = tax_selected.filter(function (item) {
240241
return '' !== item;
241242
});
243+
const selected_tax_length = tax_selected.length;
244+
if (!feedzy.i10n.is_pro) {
245+
options +=
246+
'<optgroup class="feedzy-pro-terms" label="Pro">';
247+
}
248+
options +=
249+
'<option class="feedzy-separator">separator</option>';
250+
$.each(custom_tag, function (key, customTag) {
251+
let is_selected = '';
252+
if (in_array(key, tax_selected)) {
253+
is_selected = 'selected';
254+
const index = tax_selected.indexOf(key);
255+
256+
if (-1 !== index) {
257+
tax_selected.splice(index, 1);
258+
}
259+
}
260+
options +=
261+
'<option class="' +
262+
(!feedzy.i10n.is_pro ? 'feedzy-pro-term' : '') +
263+
'" value="' +
264+
key +
265+
'"' +
266+
is_selected +
267+
'>' +
268+
customTag +
269+
'</option></a>';
270+
});
271+
242272
if (
243-
tax_selected.length > 0 &&
273+
selected_tax_length > 0 &&
244274
$('#feedzy_post_terms').hasClass('fz-chosen-custom-tag')
245275
) {
246276
$.each(tax_selected, function (index, customTag) {
@@ -252,6 +282,10 @@
252282
'</option>';
253283
});
254284
}
285+
286+
if (!feedzy.i10n.is_pro) {
287+
options += '</optgroup>';
288+
}
255289
} else {
256290
show_terms = false;
257291
options = $('#empty_select_tpl').html();
@@ -1146,22 +1180,22 @@
11461180
}
11471181

11481182
function feedzyTab() {
1149-
$(".fz-tabs-menu a").click(function () {
1150-
$(this).parents(".fz-tabs-menu").find("a").removeClass("active");
1151-
$(this).addClass("active");
1152-
var tagid = $(this).data("id");
1183+
$('.fz-tabs-menu a').click(function () {
1184+
$(this).parents('.fz-tabs-menu').find('a').removeClass('active');
1185+
$(this).addClass('active');
1186+
const tagid = $(this).data('id');
11531187
$(this)
1154-
.parents(".feedzy-accordion-item__content")
1155-
.find(".fz-tabs-content .fz-tab-content")
1188+
.parents('.feedzy-accordion-item__content')
1189+
.find('.fz-tabs-content .fz-tab-content')
11561190
.hide();
1157-
$("#" + tagid).show();
1191+
$('#' + tagid).show();
11581192
});
1159-
$(".fz-tabs-content .fz-tab-content").hide();
1160-
$(".fz-tabs-menu").each(function() {
1161-
$(this).find("a").first().addClass("active");
1193+
$('.fz-tabs-content .fz-tab-content').hide();
1194+
$('.fz-tabs-menu').each(function () {
1195+
$(this).find('a').first().addClass('active');
11621196
});
1163-
$(".fz-tabs-content").each(function() {
1164-
$(this).find(".fz-tab-content").first().show();
1197+
$('.fz-tabs-content').each(function () {
1198+
$(this).find('.fz-tab-content').first().show();
11651199
});
11661200
}
11671201

@@ -1279,7 +1313,7 @@
12791313

12801314
$('.feedzy-remove-media').on('click', function () {
12811315
if (
1282-
$('#use-inherited-thumbnail').length &&
1316+
$('#use-inherited-thumbnail').length &&
12831317
$('#use-inherited-thumbnail').is(':checked')
12841318
) {
12851319
return false;
@@ -1290,25 +1324,39 @@
12901324
'change',
12911325
function () {
12921326
const selectedValue = $(this).val();
1293-
const thumbnailValue = $('input[name="feedzy_meta_data[default_thumbnail_id]"]').val();
1294-
const hasImagePreview = $('#custom-fallback-section .feedzy-media-preview').length > 0;
1295-
const hasThumbnails = (thumbnailValue && thumbnailValue !== '' && thumbnailValue !== '0') || hasImagePreview;
1327+
const thumbnailValue = $(
1328+
'input[name="feedzy_meta_data[default_thumbnail_id]"]'
1329+
).val();
1330+
const hasImagePreview =
1331+
$('#custom-fallback-section .feedzy-media-preview').length >
1332+
0;
1333+
const hasThumbnails =
1334+
(thumbnailValue &&
1335+
thumbnailValue !== '' &&
1336+
thumbnailValue !== '0') ||
1337+
hasImagePreview;
12961338

12971339
if (selectedValue === 'custom') {
12981340
$('#custom-fallback-section').show();
12991341
$('#general-fallback-preview').hide();
1300-
1342+
13011343
if (hasThumbnails) {
1302-
$('.feedzy-open-media').html(feedzy.i10n.action_btn_text_2);
1344+
$('.feedzy-open-media').html(
1345+
feedzy.i10n.action_btn_text_2
1346+
);
13031347
$('.feedzy-remove-media').addClass('is-show');
13041348
} else {
1305-
$('.feedzy-open-media').html(feedzy.i10n.action_btn_text_1);
1349+
$('.feedzy-open-media').html(
1350+
feedzy.i10n.action_btn_text_1
1351+
);
13061352
$('.feedzy-remove-media').removeClass('is-show');
13071353
}
13081354
} else if (selectedValue === 'general') {
13091355
$('#custom-fallback-section').hide();
13101356
$('#general-fallback-preview').show();
1311-
$('input[name="feedzy_meta_data[default_thumbnail_id]"]').val('');
1357+
$(
1358+
'input[name="feedzy_meta_data[default_thumbnail_id]"]'
1359+
).val('');
13121360
}
13131361
}
13141362
);

0 commit comments

Comments
 (0)