Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Assign imported posts to categories based on the keywords #1035

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

HardeepAsrani
Copy link
Member

Summary

Information here: https://github.com/Codeinwp/feedzy-rss-feeds-pro/pull/802

Check before Pull Request is ready:

Closes #https://github.com/Codeinwp/feedzy-rss-feeds-pro/issues/768.

@HardeepAsrani HardeepAsrani added the pr-checklist-skip Allow this Pull Request to skip checklist. label Dec 18, 2024
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Dec 18, 2024
@pirate-bot
Copy link
Contributor

Plugin build for 39e0490 is ready 🛎️!

Comment on lines +678 to +684
$auto_categories = array_filter( $auto_categories, function( $item ) {
if ( ! empty( $item['keywords'] ) && is_numeric( $item['category'] ) ) {
$item['keywords'] = sanitize_text_field( $item['keywords'] );
return true;
}
return false;
} );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to have a separate context here. A filter should filter the items, a map should modify the items.

$auto_categories = array_filter( $auto_categories, function( $item ) {
    return ! empty( $item['keywords'] ) && is_numeric( $item['category'] );
});

$auto_categories = array_map(function( $item ) {
    $item['keywords'] = sanitize_text_field( $item['keywords'] );
    return $item;
}, $auto_categories);

<div class="help-text pt-8">
<?php
printf(
// translators: %s is a placeholder for the auto categories tag.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tip here is to include the actual value in the translator's comment to give them a better context. You can append it like this (like "[#auto_categories]").

Copy link
Contributor

@Soare-Robert-Daniel Soare-Robert-Daniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I left some suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants