Skip to content

Commit 795319e

Browse files
committed
Release: (285ad68) Merge branch 'develop' into trunk
1 parent 2ce9980 commit 795319e

File tree

9 files changed

+129
-104
lines changed

9 files changed

+129
-104
lines changed

includes/Classifai/Admin/Onboarding.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Classifai\Services\ServicesManager;
77

88
class Onboarding {
9+
910
/**
1011
* @var string $setup_url The admin onboarding URL.
1112
*/
@@ -18,7 +19,6 @@ public function __construct() {
1819
$this->setup_url = admin_url( 'admin.php?page=classifai_setup' );
1920
}
2021

21-
2222
/**
2323
* Inintialize the class and register the actions needed.
2424
*/
@@ -64,6 +64,7 @@ public function render_setup_page() {
6464
),
6565
);
6666
?>
67+
6768
<div class="classifai-content classifai-setup-page">
6869
<?php
6970
include_once 'templates/classifai-header.php';
@@ -143,6 +144,7 @@ public function render_setup_page() {
143144
</div>
144145

145146
</div>
147+
146148
<?php
147149
}
148150

@@ -421,19 +423,22 @@ public function get_features() {
421423
$display_name = $service->get_display_name();
422424
$service_slug = $service->get_menu_slug();
423425
$features = array();
426+
424427
foreach ( $service->provider_classes as $provider_class ) {
425428
$options = $provider_class->get_onboarding_options();
426429
if ( ! empty( $options ) && ! empty( $options['features'] ) ) {
427430
$features[ $provider_class->get_option_name() ] = $options['features'];
428431
}
429432
}
433+
430434
if ( ! empty( $features ) ) {
431435
$onboarding_features[ $service_slug ] = array(
432436
'title' => $display_name,
433437
'features' => $features,
434438
);
435439
}
436440
}
441+
437442
return $onboarding_features;
438443
}
439444

@@ -457,6 +462,7 @@ public function get_providers() {
457462
$providers[ $provider_class->get_option_name() ] = $provider_class;
458463
}
459464
}
465+
460466
return $providers;
461467
}
462468

@@ -535,9 +541,11 @@ public function handle_skip_setup_step() {
535541
$onboarding_options = array(
536542
'step_completed' => $step,
537543
);
544+
538545
if ( 3 === $step ) {
539546
$onboarding_options['status'] = 'completed';
540547
}
548+
541549
$this->update_onboarding_options( $onboarding_options );
542550

543551
// Redirect to next step.
@@ -578,6 +586,7 @@ public function get_next_provider( $current_provider ) {
578586
$enabled_providers = $this->get_enabled_providers();
579587
$keys = array_keys( $enabled_providers );
580588
$index = array_search( $current_provider, $keys, true );
589+
581590
if ( false === $index ) {
582591
return false;
583592
}
@@ -615,11 +624,13 @@ public function prevent_direct_step_visits() {
615624
*/
616625
public function has_configured_providers() {
617626
$providers = $this->get_providers();
627+
618628
foreach ( $providers as $provider ) {
619629
if ( $provider->is_configured() ) {
620630
return true;
621631
}
622632
}
633+
623634
return false;
624635
}
625636

@@ -631,6 +642,7 @@ public function has_configured_providers() {
631642
public function get_configured_features() {
632643
$features = $this->get_features();
633644
$configured_features = array();
645+
634646
foreach ( $features as $feature ) {
635647
foreach ( $feature['features'] as $provider_key => $provider_features ) {
636648
foreach ( $provider_features as $feature_key => $feature_options ) {
@@ -640,6 +652,8 @@ public function get_configured_features() {
640652
}
641653
}
642654
}
655+
643656
return $configured_features;
644657
}
658+
645659
}

includes/Classifai/Providers/Azure/ComputerVision.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct( $service ) {
4545
'enable_image_tagging' => __( 'Automatically tag images', 'classifai' ),
4646
'enable_smart_cropping' => __( 'Smart crop images', 'classifai' ),
4747
'enable_ocr' => __( 'Scan images for text', 'classifai' ),
48+
'enable_read_pdf' => __( 'Scan PDFs for text', 'classifai' ),
4849
),
4950
);
5051
}
@@ -103,7 +104,7 @@ public function get_alt_text_settings() {
103104
}
104105

105106
foreach ( $settings['enable_image_captions'] as $key => $value ) {
106-
if ( '0' !== $value ) {
107+
if ( 0 !== $value && '0' !== $value ) {
107108
$enabled_fields[] = $key;
108109
}
109110
}
@@ -1162,6 +1163,8 @@ public function sanitize_settings( $settings ) {
11621163

11631164
if ( isset( $settings['image_tag_taxonomy'] ) && taxonomy_exists( $settings['image_tag_taxonomy'] ) ) {
11641165
$new_settings['image_tag_taxonomy'] = $settings['image_tag_taxonomy'];
1166+
} elseif ( taxonomy_exists( 'classifai-image-tags' ) ) {
1167+
$new_settings['image_tag_taxonomy'] = 'classifai-image-tags';
11651168
}
11661169

11671170
if ( isset( $settings['enable_image_captions'] ) ) {

includes/Classifai/Providers/OpenAI/ChatGPT.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ public function sanitize_settings( $settings ) {
207207

208208
if ( isset( $settings['roles'] ) && is_array( $settings['roles'] ) ) {
209209
$new_settings['roles'] = array_map( 'sanitize_text_field', $settings['roles'] );
210+
} else {
211+
$new_settings['roles'] = array_keys( get_editable_roles() ?? [] );
210212
}
211213

212214
if ( isset( $settings['length'] ) && is_numeric( $settings['length'] ) && (int) $settings['length'] >= 0 ) {

includes/Classifai/Providers/OpenAI/DallE.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ public function sanitize_settings( $settings ) {
285285

286286
if ( isset( $settings['roles'] ) && is_array( $settings['roles'] ) ) {
287287
$new_settings['roles'] = array_map( 'sanitize_text_field', $settings['roles'] );
288+
} else {
289+
$new_settings['roles'] = array_keys( get_editable_roles() ?? [] );
288290
}
289291

290292
if ( isset( $settings['number'] ) && is_numeric( $settings['number'] ) && (int) $settings['number'] >= 1 && (int) $settings['number'] <= 10 ) {

0 commit comments

Comments
 (0)