Skip to content

Commit

Permalink
Merge pull request #762 from 10up/fix/allow-new-classification-providers
Browse files Browse the repository at this point in the history
Ensure custom Classification Providers can fully work
  • Loading branch information
iamdharmesh committed May 3, 2024
2 parents c9ee0f9 + f96a83e commit 02c60a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions includes/Classifai/Features/Classification.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@ public function rest_endpoint_callback( WP_REST_Request $request ) {
public function save( int $post_id, array $results, bool $link = true ) {
$provider_instance = $this->get_feature_provider_instance();

/**
* Filter results to be saved.
*
* @since 3.1.0
* @hook classifai_feature_classification_pre_save_results
*
* @param {array} $supported Term results.
* @param {int} $post_id Post ID.
* @param {bool} $link Whether to link the terms or not.
* @param {object} $this Current instance of the class.
*
* @return {array} Term results.
*/
$results = apply_filters( 'classifai_' . static::ID . '_pre_save_results', $results, $post_id, $link, $this );

switch ( $provider_instance::ID ) {
case NLU::ID:
$results = $provider_instance->link( $post_id, $results, $link );
Expand Down
2 changes: 1 addition & 1 deletion src/js/language-processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ import '../scss/language-processing.scss';
previewWatson();

const previewEmbeddings = () => {
if ( 'openai_embeddings' !== provider ) {
if ( 'ibm_watson_nlu' === provider ) {
return;
}

Expand Down

0 comments on commit 02c60a3

Please sign in to comment.