Skip to content

Commit 2947c8b

Browse files
authored
Merge pull request #698 from 10up/feature/672
Show deprecation message on the Recommended Content feature
2 parents c711d06 + 6870c44 commit 2947c8b

File tree

5 files changed

+72
-7
lines changed

5 files changed

+72
-7
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Tap into leading cloud-based services like [OpenAI](https://openai.com/), [Micro
4444
* Moderate incoming comments for sensitive content using [OpenAI's Moderation API](https://platform.openai.com/docs/guides/moderation)
4545
* Convert text content into audio and output a "read-to-me" feature on the front-end to play this audio using [Microsoft Azure's Text to Speech API](https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/text-to-speech)
4646
* Classify post content using [IBM Watson's Natural Language Understanding API](https://www.ibm.com/watson/services/natural-language-understanding/) and [OpenAI's Embedding API](https://platform.openai.com/docs/guides/embeddings)
47-
* BETA: Recommend content based on overall site traffic via [Microsoft Azure's AI Personalizer API](https://azure.microsoft.com/en-us/services/cognitive-services/personalizer/) _(note that we're gathering feedback on this feature and may significantly iterate depending on community input)_
47+
* BETA: Recommend content based on overall site traffic via [Microsoft Azure's AI Personalizer API](https://azure.microsoft.com/en-us/services/cognitive-services/personalizer/) *(note that this service has been [deprecated by Microsoft](https://learn.microsoft.com/en-us/azure/ai-services/personalizer/) and as such, will no longer work. We are looking to replace this with a new provider to maintain the same functionality (see [issue#392](https://github.com/10up/classifai/issues/392))*
4848
* Generate image alt text, image tags, and smartly crop images using [Microsoft Azure's AI Vision API](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/)
4949
* Scan images and PDF files for embedded text and save for use in post meta using [Microsoft Azure's AI Vision API](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/)
5050
* Bulk classify content with [WP-CLI](https://wp-cli.org/)
@@ -393,6 +393,8 @@ Note that [Azure AI Vision](https://docs.microsoft.com/en-us/azure/cognitive-ser
393393

394394
## Set Up Recommended Content (via Microsoft Azure AI Personalizer)
395395

396+
Azure AI Personalizer has been retired by Microsoft [as of September 2023](https://learn.microsoft.com/en-us/azure/ai-services/personalizer/). The service will continue to work until 2026 but Personalizer resources can no longer be created. As such, consider this provider deprecated and be aware that we will be removing this in the near future. We are hoping to replace with a new provider to maintain the same functionality (see [issue#392](https://github.com/10up/classifai/issues/392)).
397+
396398
Note that [Personalizer](https://azure.microsoft.com/en-us/services/cognitive-services/personalizer/) requires sufficient data volume to enable Personalizer to learn. In general, we recommend a minimum of ~1,000 events per day to ensure Personalizer learns effectively. If Personalizer doesn't receive sufficient data, the service takes longer to determine the best actions.
397399

398400
### 1. Sign up for Azure services

includes/Classifai/Features/RecommendedContent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct() {
2727

2828
// Contains just the providers this feature supports.
2929
$this->supported_providers = [
30-
PersonalizerProvider::ID => __( 'Microsoft AI Personalizer', 'classifai' ),
30+
PersonalizerProvider::ID => __( 'Microsoft Azure AI Personalizer', 'classifai' ),
3131
];
3232
}
3333

includes/Classifai/Providers/Azure/Personalizer.php

+41-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function __construct( $feature_instance = null ) {
4747
* Register the functionality.
4848
*/
4949
public function register() {
50+
add_action( 'classifai_before_feature_nav', [ $this, 'show_deprecation_message' ] );
51+
5052
if ( ( new RecommendedContent() )->is_feature_enabled() ) {
5153
add_action( 'wp_ajax_classifai_render_recommended_content', [ $this, 'ajax_render_recommended_content' ] );
5254
add_action( 'wp_ajax_nopriv_classifai_render_recommended_content', [ $this, 'ajax_render_recommended_content' ] );
@@ -55,6 +57,41 @@ public function register() {
5557
}
5658
}
5759

60+
/**
61+
* Show a deprecation message for the provider.
62+
*
63+
* @param string $active_feature Feature currently shown.
64+
*/
65+
public function show_deprecation_message( string $active_feature ) {
66+
if ( 'feature_recommended_content' !== $active_feature ) {
67+
return;
68+
}
69+
?>
70+
71+
<div class="notice notice-warning">
72+
<p>
73+
<?php
74+
printf(
75+
wp_kses(
76+
// translators: 1 - link to Personalizer documentation; 2 - link to GitHub issue.
77+
__( '<a href="%1$s" target="_blank">As of September 2023</a>, new Personalizer resources can no longer be created in Azure. This is currently the only provider available for the Recommended Content feature and as such, this feature will not work unless you had previously created a Personalizer resource. The Azure AI Personalizer provider is deprecated and will be removed in a future release. We hope to replace this provider with another one in a coming release to continue to support this feature (see <a href="%2$s" target="_blank">issue#392</a>).', 'classifai' ),
78+
array(
79+
'a' => array(
80+
'href' => array(),
81+
'target' => array(),
82+
),
83+
)
84+
),
85+
'https://learn.microsoft.com/en-us/azure/ai-services/personalizer/',
86+
'https://github.com/10up/classifai/issues/392'
87+
)
88+
?>
89+
</p>
90+
</div>
91+
92+
<?php
93+
}
94+
5895
/**
5996
* Render the provider fields.
6097
*/
@@ -75,16 +112,17 @@ public function render_provider_fields() {
75112
'class' => 'large-text classifai-provider-field hidden provider-scope-' . static::ID, // Important to add this.
76113
'description' => sprintf(
77114
wp_kses(
78-
// translators: 1 - link to create a Personalizer resource.
79-
__( 'Azure AI Personalizer Endpoint, <a href="%1$s" target="_blank">create a Personalizer resource</a> in the Azure portal to get your key and endpoint.', 'classifai' ),
115+
// translators: 1 - link to create a Personalizer resource; 2 - link to GitHub issue.
116+
__( 'Azure AI Personalizer Endpoint; <a href="%1$s" target="_blank">create a Personalizer resource</a> in the Azure portal to get your key and endpoint. Note that <a href="%2$s" target="_blank">as of September 2023</a>, it is no longer possible to create this resource. Previously created Personalizer resources can still be used.', 'classifai' ),
80117
array(
81118
'a' => array(
82119
'href' => array(),
83120
'target' => array(),
84121
),
85122
)
86123
),
87-
esc_url( 'https://portal.azure.com/#create/Microsoft.CognitiveServicesPersonalizer' )
124+
'https://portal.azure.com/#create/Microsoft.CognitiveServicesPersonalizer',
125+
'https://learn.microsoft.com/en-us/azure/ai-services/personalizer/'
88126
),
89127
]
90128
);

includes/Classifai/Services/Service.php

+26-1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public function render_settings_page() {
149149
<?php
150150
include_once CLASSIFAI_PLUGIN_DIR . '/includes/Classifai/Admin/templates/classifai-header.php';
151151
?>
152+
152153
<div class="classifai-wrap wrap wrap--nlu">
153154
<h2><?php echo esc_html( $this->display_name ); ?></h2>
154155

@@ -160,6 +161,18 @@ public function render_settings_page() {
160161
}
161162
?>
162163

164+
<?php
165+
/**
166+
* Fires before the feature tab navigation.
167+
*
168+
* @since 3.0.0
169+
* @hook classifai_before_feature_nav
170+
*
171+
* @param {string} $active_feature Current active feature.
172+
*/
173+
do_action( 'classifai_before_feature_nav', $active_feature );
174+
?>
175+
163176
<h2 class="nav-tab-wrapper">
164177
<?php foreach ( $this->feature_classes as $feature_class ) : ?>
165178
<a href="<?php echo esc_url( add_query_arg( 'feature', $feature_class::ID, $base_url ) ); ?>" class="nav-tab <?php echo $feature_class::ID === $active_feature ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $feature_class->get_label() ); ?></a>
@@ -169,6 +182,18 @@ public function render_settings_page() {
169182
<?php settings_errors(); ?>
170183

171184
<div class="classifai-nlu-sections">
185+
<?php
186+
/**
187+
* Fires before the settings form for a feature.
188+
*
189+
* @since 3.0.0
190+
* @hook classifai_before_feature_settings_form
191+
*
192+
* @param {string} $active_feature Current active feature.
193+
*/
194+
do_action( 'classifai_before_feature_settings_form', $active_feature );
195+
?>
196+
172197
<form method="post" action="options.php">
173198
<?php
174199
settings_fields( 'classifai_' . $active_feature );
@@ -184,7 +209,7 @@ public function render_settings_page() {
184209
* @since 3.0.0
185210
* @hook classifai_after_feature_settings_form
186211
*
187-
* @param {array} $active_feature Array of active features.
212+
* @param {string} $active_feature Current active feature.
188213
*/
189214
do_action( 'classifai_after_feature_settings_form', $active_feature );
190215
?>

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Tap into leading cloud-based services like [OpenAI](https://openai.com/), [Micro
2525
* Generate transcripts of audio files using [OpenAI's Whisper API](https://platform.openai.com/docs/guides/speech-to-text)
2626
* Convert text content into audio and output a "read-to-me" feature on the front-end to play this audio using [Microsoft Azure's Text to Speech API](https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/text-to-speech)
2727
* Classify post content using [IBM Watson's Natural Language Understanding API](https://www.ibm.com/watson/services/natural-language-understanding/) and [OpenAI's Embedding API](https://platform.openai.com/docs/guides/embeddings)
28-
* BETA: Recommend content based on overall site traffic via [Microsoft Azure's AI Personalizer API](https://azure.microsoft.com/en-us/services/cognitive-services/personalizer/) _(note that we're gathering feedback on this feature and may significantly iterate depending on community input)_
28+
* BETA: Recommend content based on overall site traffic via [Microsoft Azure's AI Personalizer API](https://azure.microsoft.com/en-us/services/cognitive-services/personalizer/) _(note that this service has been deprecated by Microsoft and as such, will no longer work. We are looking to replace this with a new provider to maintain the same functionality)_
2929
* Generate image alt text, image tags, and smartly crop images using [Microsoft Azure's AI Vision API](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/)
3030
* Scan images and PDF files for embedded text and save for use in post meta using [Microsoft Azure's AI Vision API](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/)
3131
* Bulk classify content with [WP-CLI](https://wp-cli.org/)

0 commit comments

Comments
 (0)