@@ -25,7 +25,7 @@ function classifai_test_mock_http_requests( $preempt, $parsed_args, $url ) {
25
25
$ response = file_get_contents ( __DIR__ . '/chatgpt.json ' );
26
26
} elseif ( strpos ( $ url , 'https://api.openai.com/v1/chat/completions ' ) !== false ) {
27
27
$ response = file_get_contents ( __DIR__ . '/chatgpt.json ' );
28
- $ body_json = isset ( $ parsed_args ['body ' ] ) ? wp_unslash ( $ parsed_args [ ' body ' ] ) : false ;
28
+ $ body_json = $ parsed_args ['body ' ] ?? false ;
29
29
30
30
if ( $ body_json ) {
31
31
$ body = json_decode ( $ body_json , JSON_OBJECT_AS_ARRAY );
@@ -34,11 +34,11 @@ function classifai_test_mock_http_requests( $preempt, $parsed_args, $url ) {
34
34
35
35
if ( str_contains ( $ prompt , 'Increase the content ' ) || str_contains ( $ prompt , 'Decrease the content ' ) ) {
36
36
$ response = file_get_contents ( __DIR__ . '/resize-content.json ' );
37
- } else if ( 'This is a custom excerpt prompt ' === $ prompt ) {
37
+ } else if ( str_contains ( $ prompt , 'This is a custom excerpt prompt ' ) ) {
38
38
$ response = file_get_contents ( __DIR__ . '/chatgpt-custom-excerpt-prompt.json ' );
39
- } else if ( 'This is a custom title prompt ' === $ prompt ) {
39
+ } else if ( str_contains ( $ prompt , 'This is a custom title prompt ' ) ) {
40
40
$ response = file_get_contents ( __DIR__ . '/chatgpt-custom-title-prompt.json ' );
41
- } else if ( 'This is a custom shrink prompt ' === $ prompt || 'This is a custom grow prompt ' === $ prompt ) {
41
+ } else if ( str_contains ( $ prompt , 'This is a custom shrink prompt ' ) || str_contains ( $ prompt , 'This is a custom grow prompt ' ) ) {
42
42
$ response = file_get_contents ( __DIR__ . '/resize-content-custom-prompt.json ' );
43
43
}
44
44
}
0 commit comments