Skip to content

Commit

Permalink
Fixed spelling error
Browse files Browse the repository at this point in the history
  • Loading branch information
justinh-rahb committed Mar 24, 2023
1 parent ecb05c9 commit 18ca644
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions openai-moderation/includes/openai-moderation-moderate.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public function moderate_comment($comment_data)
return $comment_data;
}

$allowed_classifications = get_option('openai_classifications');
$allowed_classifications = array_map('trim', $allowed_classifications);
$disallowed_classifications = get_option('openai_classifications');
$disallowed_classifications = array_map('trim', $disallowed_classifications);

$violates_policies = false;
foreach ($moderation_result['categories'] as $category => $flagged) {
if ($flagged && in_array($category, $allowed_classifications)) {
if ($flagged && in_array($category, $disallowed_classifications)) {
$violates_policies = true;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions openai-moderation/includes/openai-moderation-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function register_settings()

public function settings_page()
{
$allowed_classifications_options = array(
$disallowed_classifications_options = array(
'hate' => __('Hate', 'openai-moderation'),
'hate/threatening' => __('Hate/Threatening', 'openai-moderation'),
'self-harm' => __('Self-Harm', 'openai-moderation'),
Expand All @@ -50,12 +50,12 @@ public function sanitize_classifications($classifications)
return array();
}

$allowed_classifications = array(
$disallowed_classifications = array(
'hate', 'hate/threatening', 'self-harm','sexual/minors', 'violence', 'violence/graphic'
);

return array_values(array_filter($classifications, function ($classification) use ($allowed_classifications) {
return in_array($classification, $allowed_classifications, true);
return array_values(array_filter($classifications, function ($classification) use ($disallowed_classifications) {
return in_array($classification, $disallowed_classifications, true);
}));
}
}
2 changes: 1 addition & 1 deletion openai-moderation/partials/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<tr>
<th scope="row"><?php _e('Disallowed Classifications', 'openai-moderation'); ?></th>
<td>
<?php foreach ($allowed_classifications_options as $classification_key => $classification_label): ?>
<?php foreach ($disallowed_classifications_options as $classification_key => $classification_label): ?>
<input type="checkbox" name="openai_classifications[]" id="openai_classifications_<?php echo $classification_key; ?>" value="<?php echo
esc_attr($classification_key); ?>" <?php checked(in_array($classification_key, $stored_classifications), true); ?> />
<label for="openai_classifications_<?php echo $classification_key; ?>"><?php echo esc_html($classification_label); ?></label><br />
Expand Down

0 comments on commit 18ca644

Please sign in to comment.