Skip to content

Commit 55d3949

Browse files
feat: improve taxonomy setting UI
1 parent 5835fea commit 55d3949

File tree

4 files changed

+91
-37
lines changed

4 files changed

+91
-37
lines changed

css/settings.css

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

@@ -665,6 +679,7 @@ public function save_feedzy_import_feed_meta( $post_id, $post ) {
665679
$data_meta['import_use_external_image'] = isset( $data_meta['import_use_external_image'] ) ? $data_meta['import_use_external_image'] : 'no';
666680
// Check feeds remove html checkbox checked OR not.
667681
$data_meta['import_remove_html'] = isset( $data_meta['import_remove_html'] ) ? $data_meta['import_remove_html'] : 'no';
682+
$data_meta['import_post_term'] = isset( $data_meta['import_post_term'] ) ? $data_meta['import_post_term'] : '';
668683

669684
// If it is filter_conditions we want to escape it.
670685
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: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
function update_taxonomy() {
160160
var selected = $(this).val();
161161
var tax_selected = $(this).data("tax");
162+
const custom_tag = $(this).data('custom-tag');
162163
if (typeof tax_selected !== "undefined") {
163164
tax_selected = tax_selected.split(",");
164165
} else {
@@ -216,11 +217,33 @@
216217
}
217218
});
218219
tax_selected = tax_selected.filter( function(item) { return '' !== item; } );
219-
if ( tax_selected.length > 0 && $("#feedzy_post_terms").hasClass('fz-chosen-custom-tag') ) {
220+
const selected_tax_length = tax_selected.length;
221+
if ( ! feedzy.i10n.is_pro ) {
222+
options += '<optgroup class="feedzy-pro-terms" label="Pro">';
223+
}
224+
options += '<option class="feedzy-separator">separator</option>'
225+
$.each(custom_tag, function (key, customTag) {
226+
let is_selected = '';
227+
if ( in_array(key, tax_selected) ) {
228+
is_selected = 'selected';
229+
const index = tax_selected.indexOf(key);
230+
231+
if (-1 !== index) {
232+
tax_selected.splice(index, 1);
233+
}
234+
}
235+
options += '<option class="' + ( ! feedzy.i10n.is_pro ? 'feedzy-pro-term' : '' ) + '" value="' + key + '"' + is_selected +'>' + customTag + '</option></a>';
236+
} );
237+
238+
if ( selected_tax_length > 0 && $("#feedzy_post_terms").hasClass('fz-chosen-custom-tag') ) {
220239
$.each(tax_selected, function (index, customTag) {
221240
options += '<option value="' + customTag + '" selected>' + customTag + '</option>';
222241
} );
223242
}
243+
244+
if ( ! feedzy.i10n.is_pro ) {
245+
options += "</optgroup>";
246+
}
224247
} else {
225248
show_terms = false;
226249
options = $("#empty_select_tpl").html();

0 commit comments

Comments
 (0)