From fac19df00e8da8d37d24cd4ba2fa2a4ff2c3efad Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 26 May 2023 13:12:32 -0600 Subject: [PATCH 1/3] Ensure all of our custom filters have proper dockblocks so they show in our hook doc site --- .../Providers/Azure/ComputerVision.php | 8 ++-- includes/Classifai/Providers/Azure/OCR.php | 48 +++++++++---------- includes/Classifai/Providers/Azure/Read.php | 40 +++++++++++----- .../Providers/Azure/SmartCropping.php | 11 +++-- .../Providers/Azure/TextToSpeech.php | 20 +++++--- 5 files changed, 76 insertions(+), 51 deletions(-) diff --git a/includes/Classifai/Providers/Azure/ComputerVision.php b/includes/Classifai/Providers/Azure/ComputerVision.php index fb7b9d2c6..23f5dcd20 100644 --- a/includes/Classifai/Providers/Azure/ComputerVision.php +++ b/includes/Classifai/Providers/Azure/ComputerVision.php @@ -659,11 +659,11 @@ public function ocr_processing( array $metadata = [], int $attachment_id = 0, bo * @since 1.6.0 * @hook classifai_should_ocr_scan_image * - * @param bool $should_ocr_scan Whether to run OCR scanning. The default value is set in ComputerVision settings. - * @param array $metadata Image metadata. - * @param int $attachment_id The attachment ID. + * @param {bool} $should_ocr_scan Whether to run OCR scanning. The default value is set in ComputerVision settings. + * @param {array} $metadata Image metadata. + * @param {int} $attachment_id The attachment ID. * - * @return bool Whether to run OCR scanning. + * @return {bool} Whether to run OCR scanning. */ if ( ! $force && ! apply_filters( 'classifai_should_ocr_scan_image', $should_ocr_scan, $metadata, $attachment_id ) ) { return $metadata; diff --git a/includes/Classifai/Providers/Azure/OCR.php b/includes/Classifai/Providers/Azure/OCR.php index 85b511794..e07725ab0 100644 --- a/includes/Classifai/Providers/Azure/OCR.php +++ b/includes/Classifai/Providers/Azure/OCR.php @@ -122,10 +122,10 @@ public function should_process( int $attachment_id ) { * @since 1.6.0 * @hook classifai_ocr_approved_media_types * - * @param array $media_types The media types to process. - * @param int $attachment_id The attachment ID. + * @param {array} $media_types The media types to process. + * @param {int} $attachment_id The attachment ID. * - * @return array Filtered media types. + * @return {array} Filtered media types. */ $approved_media_types = apply_filters( 'classifai_ocr_approved_media_types', $this->media_to_process, $attachment_id ); @@ -145,11 +145,11 @@ public function should_process( int $attachment_id ) { * @since 1.6.0 * @hook classifai_ocr_tags * - * @param array $tags Tags to look for. Default handwriting and text. - * @param int $attachment_id The attachment ID. - * @param bool|object $scan Previosly run scan. + * @param {array} $tags Tags to look for. Default handwriting and text. + * @param {int} $attachment_id The attachment ID. + * @param {bool|object} $scan Previously run scan. * - * @return array Filtered tags. + * @return {array} Filtered tags. */ $tags = apply_filters( 'classifai_ocr_tags', [ 'handwriting', 'text' ], $attachment_id, $this->scan ); @@ -159,11 +159,11 @@ public function should_process( int $attachment_id ) { * @since 1.6.0 * @hook classifai_ocr_tag_confidence * - * @param int $confidence The mininum confidence level. Default 90. - * @param int $attachment_id The attachment ID. - * @param bool|object $scan Previosly run scan. + * @param {int} $confidence The minimum confidence level. Default 90. + * @param {int} $attachment_id The attachment ID. + * @param {bool|object} $scan Previously run scan. * - * @return int Confidence level. + * @return {int} Confidence level. */ $tag_confidence = apply_filters( 'classifai_ocr_tag_confidence', 90, $attachment_id, $this->scan ); @@ -181,11 +181,11 @@ public function should_process( int $attachment_id ) { * @since 1.6.0 * @hook classifai_ocr_should_process * - * @param bool $process Whether to run OCR processing or not. - * @param int $attachment_id The attachment ID. - * @param bool|object $scan Previosly run scan. + * @param {bool} $process Whether to run OCR processing or not. + * @param {int} $attachment_id The attachment ID. + * @param {bool|object} $scan Previously run scan. * - * @return bool Whether this attachment should have OCR processing. + * @return {bool} Whether this attachment should have OCR processing. */ return apply_filters( 'classifai_ocr_should_process', $process, $attachment_id, $this->scan ); } @@ -246,10 +246,10 @@ public function generate_ocr_data( array $metadata, int $attachment_id ) { * @since 1.6.0 * @hook classifai_ocr_text * - * @param string $text The returned text data. - * @param object $scan The full scan results from the API. + * @param {string} $text The returned text data. + * @param {object} $scan The full scan results from the API. * - * @return string The filtered text data. + * @return {string} The filtered text data. */ $text = apply_filters( 'classifai_ocr_text', implode( ' ', $text ), $scan ); @@ -267,13 +267,13 @@ public function generate_ocr_data( array $metadata, int $attachment_id ) { * @since 1.6.0 * @hook classifai_ocr_text_post_args * - * @param string $post_args Array of post data for the attachment post update. Defaults to `ID` and `post_content`. - * @param int $attachment_id ID of the attachment post. - * @param object $scan The full scan results from the API. - * @param string $text The text data to be saved. - * @param object $scan The full scan results from the API. + * @param {string} $post_args Array of post data for the attachment post update. Defaults to `ID` and `post_content`. + * @param {int} $attachment_id ID of the attachment post. + * @param {object} $scan The full scan results from the API. + * @param {string} $text The text data to be saved. + * @param {object} $scan The full scan results from the API. * - * @return string The filtered text data. + * @return {string} The filtered text data. */ $post_args = apply_filters( 'classifai_ocr_text_post_args', $post_args, $attachment_id, $text, $scan ); diff --git a/includes/Classifai/Providers/Azure/Read.php b/includes/Classifai/Providers/Azure/Read.php index e656a3b77..2385534bd 100644 --- a/includes/Classifai/Providers/Azure/Read.php +++ b/includes/Classifai/Providers/Azure/Read.php @@ -98,12 +98,13 @@ public function should_process() { /** * Filters whether to run Read processing on this attachment item * + * @since 1.7.0 * @hook classifai_azure_read_should_process * - * @param bool $process Whether to run OCR processing or not. - * @param int $attachment_id The attachment ID. + * @param {bool} $process Whether to run OCR processing or not. + * @param {int} $attachment_id The attachment ID. * - * @return bool Whether this attachment should have OCR processing. + * @return {bool} Whether this attachment should have OCR processing. */ return apply_filters( 'classifai_azure_read_should_process', $process, $this->attachment_id ); } @@ -145,12 +146,13 @@ public function read_document() { /** * Filters the request arguments sent to Read endpoint. * + * @since 1.7.0 * @hook classifai_azure_read_should_process * - * @param array $args Whether to run OCR processing or not. - * @param int $attachment_id The attachment ID. + * @param {array} $args Whether to run OCR processing or not. + * @param {int} $attachment_id The attachment ID. * - * @return array Filtered request arguments. + * @return {array} Filtered request arguments. */ $request_args = apply_filters( 'classifai_azure_read_request_args', [], $this->attachment_id ); @@ -251,6 +253,16 @@ public function check_read_result( $operation_url ) { case 'notStarted': case 'running': $this->update_status( $body ); + /** + * Filters the Read retry interval. + * + * @since 1.7.0 + * @hook classifai_azure_read_retry_interval + * + * @param {int} $seconds How many seconds should the interval be? Default 60. + * + * @return {int} Filtered interval. + */ $retry_interval = apply_filters( 'classifai_azure_read_retry_interval', MINUTE_IN_SECONDS ); wp_schedule_single_event( time() + $retry_interval, 'classifai_retry_get_read_result', [ $operation_url, $this->attachment_id ] ); break; @@ -280,13 +292,14 @@ public function update_document_description( $data ) { } /** - * Filter the text max pages can be processed. + * Filter the max pages that can be processed. * + * @since 1.7.0 * @hook classifai_azure_read_result_max_page * - * @param int $max_page The attachment ID. + * @param {int} $max_page The maximum pages that are read. * - * @return int + * @return {int} Filtered max pages. */ $max_page = min( apply_filters( 'classifai_azure_read_result_max_page', 2 ), count( $data['analyzeResult']['readResults'] ) ); @@ -301,13 +314,14 @@ public function update_document_description( $data ) { /** * Filter the text result returned from Read API. * + * @since 1.7.0 * @hook classifai_azure_read_text_result * - * @param array $lines_of_text Array of text extracted from the response. - * @param int $attachment_id The attachment ID. - * @param array $data Read result. + * @param {array} $lines_of_text Array of text extracted from the response. + * @param {int} $attachment_id The attachment ID. + * @param {array} $data Read result. * - * @return array + * @return {array} Filtered array of text. */ $lines_of_text = apply_filters( 'classifai_azure_read_text_result', $lines_of_text, $this->attachment_id, $data ); diff --git a/includes/Classifai/Providers/Azure/SmartCropping.php b/includes/Classifai/Providers/Azure/SmartCropping.php index a8c75bfb4..0be3bae0f 100644 --- a/includes/Classifai/Providers/Azure/SmartCropping.php +++ b/includes/Classifai/Providers/Azure/SmartCropping.php @@ -103,7 +103,7 @@ public function get_max_pixel_dimension() { * @since 1.5.0 * @hook classifai_smart_crop_max_pixel_dimension * - * @param {int} max The max width/height in pixels. + * @param {int} $max The max width/height in pixels. Default 1024. * * @return {int} Filtered max dimension in pixels. */ @@ -264,10 +264,13 @@ public function get_cropped_thumbnail( $attachment_id, $size_data ) { * the original file in the file system. * * @since 1.5.0 + * @hook classifai_smart_cropping_thumb_file_name * - * @param string Default file name. - * @param int The ID of the attachment being processed. - * @param array Width and height data for the image. + * @param {string} Default file name. + * @param {int} The ID of the attachment being processed. + * @param {array} Width and height data for the image. + * + * @return {string} Filtered file name. */ $new_thumb_file_name = apply_filters( 'classifai_smart_cropping_thumb_file_name', diff --git a/includes/Classifai/Providers/Azure/TextToSpeech.php b/includes/Classifai/Providers/Azure/TextToSpeech.php index 633b68396..d9d3d6253 100644 --- a/includes/Classifai/Providers/Azure/TextToSpeech.php +++ b/includes/Classifai/Providers/Azure/TextToSpeech.php @@ -502,10 +502,15 @@ public function render_post_audio_controls( $content ) { } /** - * Filter to disable Text to Speech synthesis for a post by post ID. + * Filter to disable the rendering of the Text to Speech block. * - * @param boolean 'is_disabled' Boolean to toggle the service. By default - false. - * @param boolean 'post_id' Post ID. + * @since 2.2.0 + * @hook classifai_disable_post_to_audio_block + * + * @param {bool} $is_disabled Whether to disable the display or not. By default - false. + * @param {bool} $post_id Post ID. + * + * @return {bool} Whether the audio block should be shown. */ if ( apply_filters( 'classifai_disable_post_to_audio_block', false, $post->ID ) ) { return $content; @@ -555,10 +560,13 @@ public function render_post_audio_controls( $content ) { /** * Hook to filter the text next to the audio controls on the frontend. * - * @param string The text to filter. - * @param integer The Post ID. + * @since 2.2.0 + * @hook classifai_listen_to_this_post_text + * + * @param {string} The text to filter. + * @param {int} Post ID. * - * @return string + * @return {string} Filtered text. */ apply_filters( 'classifai_listen_to_this_post_text', '%s %s', $post->ID ), esc_html__( 'Listen to this', 'classifai' ), From 51c56c309e60ae2e36c467305296ff96853a7854 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 26 May 2023 13:14:45 -0600 Subject: [PATCH 2/3] Ensure all of our custom actions have proper docblocks so they show in our hook doc site --- .../Classifai/Providers/Azure/ComputerVision.php | 8 ++++---- includes/Classifai/Providers/Azure/OCR.php | 8 ++++---- includes/Classifai/Providers/Azure/Read.php | 8 ++++---- includes/Classifai/Providers/Azure/SmartCropping.php | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/includes/Classifai/Providers/Azure/ComputerVision.php b/includes/Classifai/Providers/Azure/ComputerVision.php index 23f5dcd20..00ee86901 100644 --- a/includes/Classifai/Providers/Azure/ComputerVision.php +++ b/includes/Classifai/Providers/Azure/ComputerVision.php @@ -815,8 +815,8 @@ protected function generate_alt_tags( $captions, $attachment_id ) { * @since 1.5.0 * @hook classifai_computer_vision_caption_failed * - * @param array $tags The caption data. - * @param int $threshold The caption_threshold setting. + * @param {array} $tags The caption data. + * @param {int} $threshold The caption_threshold setting. */ do_action( 'classifai_computer_vision_caption_failed', $captions, $threshold ); } @@ -928,8 +928,8 @@ protected function generate_image_tags( $tags, $attachment_id ) { * @since 1.5.0 * @hook classifai_computer_vision_image_tag_failed * - * @param array $tags The image tag data. - * @param int $threshold The tag_threshold setting. + * @param {array} $tags The image tag data. + * @param {int} $threshold The tag_threshold setting. */ do_action( 'classifai_computer_vision_image_tag_failed', $tags, $threshold ); } diff --git a/includes/Classifai/Providers/Azure/OCR.php b/includes/Classifai/Providers/Azure/OCR.php index e07725ab0..2cccfc89a 100644 --- a/includes/Classifai/Providers/Azure/OCR.php +++ b/includes/Classifai/Providers/Azure/OCR.php @@ -326,8 +326,8 @@ public function process( string $url ) { * @since 1.6.0 * @hook classifai_ocr_after_request * - * @param array|WP_Error Response data or a WP_Error if the request failed. - * @param string The attachment URL. + * @param {array|WP_Error} Response data or a WP_Error if the request failed. + * @param {string} The attachment URL. */ do_action( 'classifai_ocr_after_request', $response, $url ); @@ -349,8 +349,8 @@ public function process( string $url ) { * @since 1.6.0 * @hook classifai_ocr_unsuccessful_response * - * @param array|WP_Error Response data or a WP_Error if the request failed. - * @param string The attachment URL. + * @param {array|WP_Error} Response data or a WP_Error if the request failed. + * @param {string} The attachment URL. */ do_action( 'classifai_ocr_unsuccessful_response', $response, $url ); diff --git a/includes/Classifai/Providers/Azure/Read.php b/includes/Classifai/Providers/Azure/Read.php index 2385534bd..b7b9ed49e 100644 --- a/includes/Classifai/Providers/Azure/Read.php +++ b/includes/Classifai/Providers/Azure/Read.php @@ -188,10 +188,10 @@ public function read_document() { * @since 1.5.0 * @hook classifai_azure_read_after_request * - * @param array|WP_Error Response data or a WP_Error if the request failed. - * @param string The request URL with query args added. - * @param int The document ID. - * @param string The document URL. + * @param {array|WP_Error} Response data or a WP_Error if the request failed. + * @param {string} The request URL with query args added. + * @param {int} The document ID. + * @param {string} The document URL. */ do_action( 'classifai_azure_read_after_request', $response, $url, $this->attachment_id, $document_url ); diff --git a/includes/Classifai/Providers/Azure/SmartCropping.php b/includes/Classifai/Providers/Azure/SmartCropping.php index 0be3bae0f..c46f86419 100644 --- a/includes/Classifai/Providers/Azure/SmartCropping.php +++ b/includes/Classifai/Providers/Azure/SmartCropping.php @@ -337,9 +337,9 @@ public function request_cropped_thumbnail( $data ) { * @since 1.5.0 * @hook classifai_smart_cropping_after_request * - * @param array|WP_Error Response data or a WP_Error if the request failed. - * @param string The request URL with query args added. - * @param array Array containing the image height and width. + * @param {array|WP_Error} Response data or a WP_Error if the request failed. + * @param {string} The request URL with query args added. + * @param {array} Array containing the image height and width. */ do_action( 'classifai_smart_cropping_after_request', $response, $url, $data ); @@ -361,9 +361,9 @@ public function request_cropped_thumbnail( $data ) { * @since 1.5.0 * @hook classifai_smart_cropping_unsuccessful_response * - * @param array|WP_Error Response data or a WP_Error if the request failed. - * @param string The request URL with query args added. - * @param array Array containing the image height and width. + * @param {array|WP_Error} Response data or a WP_Error if the request failed. + * @param {string} The request URL with query args added. + * @param {array} Array containing the image height and width. */ do_action( 'classifai_smart_cropping_unsuccessful_response', $response, $url, $data ); From 63b6918dec28a770f9a3c18da019adb76cd8d73b Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 26 May 2023 13:18:53 -0600 Subject: [PATCH 3/3] Add link to doc site at top of readmes --- README.md | 2 ++ readme.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 30807c6d2..eccb40fa3 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [![E2E Testing](https://github.com/10up/classifai/actions/workflows/cypress.yml/badge.svg)](https://github.com/10up/classifai/actions/workflows/cypress.yml) [![PHPUnit Testing](https://github.com/10up/classifai/actions/workflows/test.yml/badge.svg)](https://github.com/10up/classifai/actions/workflows/test.yml) [![Linting](https://github.com/10up/classifai/actions/workflows/lint.yml/badge.svg)](https://github.com/10up/classifai/actions/workflows/lint.yml) [![CodeQL](https://github.com/10up/classifai/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/10up/classifai/actions/workflows/codeql-analysis.yml) [![Dependency Review](https://github.com/10up/classifai/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/10up/classifai/actions/workflows/dependency-review.yml) +*You can learn more about ClassifAI's features at [ClassifAIPlugin.com](https://classifaiplugin.com/) and documentation at the [ClassifAI documentation site](https://10up.github.io/classifai/).* + ## Table of Contents * [Overview](#overview) * [Features](#features) diff --git a/readme.txt b/readme.txt index 9b686015c..a5885e742 100644 --- a/readme.txt +++ b/readme.txt @@ -14,6 +14,8 @@ Supercharge WordPress Content Workflows and Engagement with Artificial Intellige Tap into leading cloud-based services like [OpenAI](https://openai.com/), [Microsoft Azure AI](https://azure.microsoft.com/en-us/overview/ai-platform/), and [IBM Watson](https://www.ibm.com/watson) to augment your WordPress-powered websites. Publish content faster while improving SEO performance and increasing audience engagement. ClassifAI integrates Artificial Intelligence and Machine Learning technologies to lighten your workload and eliminate tedious tasks, giving you more time to create original content that matters. +*You can learn more about ClassifAI's features at [ClassifAIPlugin.com](https://classifaiplugin.com/) and documentation at the [ClassifAI documentation site](https://10up.github.io/classifai/).* + **Features** * Generate a summary of post content and store it as an excerpt using [OpenAI's ChatGPT API](https://platform.openai.com/docs/guides/chat)