Skip to content

Commit

Permalink
phpcs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Nov 7, 2023
1 parent 5572af7 commit 24fbc92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion includes/Classifai/Providers/OpenAI/OpenAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ function() {
/**
* Sanitize the API key, showing an error message if needed.
*
* @param array $new_settings New settings being saved.
* @param array $old_settings Existing settings, if any.
* @return array
*/
Expand Down
23 changes: 14 additions & 9 deletions includes/Classifai/Services/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ abstract class Service {
protected $providers;

/**
* @var array Array of class instances.
* @var array Array of provider instances.
*/
public $provider_classes;

/**
* @var string[] array Array of feature classes for this service
*/
public $features = [];

/**
* @var \Classifai\Features\Feature[] Array of feature instances.
*/
public $feature_classes = [];

/**
Expand Down Expand Up @@ -69,7 +75,6 @@ public function init() {
$this->provider_classes[] = new $provider( $this->menu_slug );
}
}
// $this->register_providers();
}

$this->features = apply_filters( "{$this->menu_slug}_features", $this->features );
Expand Down Expand Up @@ -100,6 +105,9 @@ public function register_providers() {
}
}

/**
* Initializes the functionality for this services features.
*/
public function register_features() {
if ( ! empty( $this->feature_classes ) ) {
foreach ( $this->feature_classes as $feature ) {
Expand Down Expand Up @@ -130,17 +138,17 @@ public function get_display_name() {
* Render the start of a settings page. The rest is added by the providers
*/
public function render_settings_page() {
$active_tab = $this->provider_classes ? $this->provider_classes[0]->get_settings_section() : '';
$active_tab = isset( $_GET['provider'] ) ? sanitize_text_field( wp_unslash( $_GET['provider'] ) ) : $active_tab; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$base_url = add_query_arg(
$active_tab = $this->provider_classes ? $this->provider_classes[0]->get_settings_section() : '';
$active_tab = isset( $_GET['provider'] ) ? sanitize_text_field( wp_unslash( $_GET['provider'] ) ) : $active_tab; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$base_url = add_query_arg(
array(
'page' => 'classifai',
'tab' => $this->get_menu_slug(),
),
admin_url( 'tools.php' )
);
$active_feature = $this->feature_classes ? $this->feature_classes[0]::ID : '';
$active_feature = isset( $_GET['feature'] ) ? sanitize_text_field( wp_unslash( $_GET['feature'] ) ) : $active_feature;
$active_feature = isset( $_GET['feature'] ) ? sanitize_text_field( wp_unslash( $_GET['feature'] ) ) : $active_feature; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
?>
<div class="classifai-content">
<?php
Expand Down Expand Up @@ -168,9 +176,6 @@ public function render_settings_page() {
<div class="classifai-nlu-sections">
<form method="post" action="options.php">
<?php
// settings_fields( 'classifai_' . $active_tab );
// do_settings_sections( 'classifai_' . $active_tab );

settings_fields( 'classifai_' . $active_feature );
do_settings_sections( 'classifai_' . $active_feature );
submit_button();
Expand Down

0 comments on commit 24fbc92

Please sign in to comment.