Skip to content

Commit

Permalink
remove more dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Feb 2, 2024
1 parent 4a624e3 commit 54fa81c
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 112 deletions.
46 changes: 0 additions & 46 deletions includes/Classifai/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,6 @@ function get_plugin() {
return Plugin::get_instance();
}

/**
* Returns the ClassifAI plugin's stored settings in the WP options.
*
* @param string $service The service to get settings from, defaults to the ServiceManager class.
* @param string $provider The provider service name to get settings from, defaults to the first one found.
* @return array The array of ClassifAi settings.
*/
function get_plugin_settings( string $service = '', string $provider = '' ): array {
$services = Plugin::$instance->services;
if ( empty( $services ) || empty( $services['service_manager'] ) || ! $services['service_manager'] instanceof ServicesManager ) {
return [];
}

/** @var ServicesManager $service_manager Instance of the services manager class. */
$service_manager = $services['service_manager'];
if ( empty( $service ) ) {
return $service_manager->get_settings();
}

if ( ! isset( $service_manager->service_classes[ $service ] ) || ! $service_manager->service_classes[ $service ] instanceof Service ) {
return [];
}

// Ensure we have at least one provider.
$providers = $service_manager->service_classes[ $service ]->provider_classes;

if ( empty( $providers ) ) {
return [];
}

// If we want settings for a specific provider, find the proper provider service.
if ( ! empty( $provider ) ) {
foreach ( $providers as $provider_class ) {
if ( $provider_class->provider_service_name === $provider ) {
return $provider_class->get_settings();
}
}

return [];
}

/** @var Provider $provider An instance or extension of the provider abstract class. */
$provider = $providers[0];
return $provider->get_settings();
}

/**
* Overwrites the ClassifAI plugin's stored settings. Expected format is,
*
Expand Down
55 changes: 0 additions & 55 deletions includes/Classifai/Providers/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,13 @@ abstract class Provider {
*/
const ID = '';

/**
* @var string The display name for the provider, i.e. Azure
*/
public $provider_name;

/**
* @var string $provider_service_name Formal name of the provider, i.e AI Vision, NLU, Rekongnition.
*/
public $provider_service_name;

/**
* Feature instance.
*
* @var \Classifai\Features\Feature
*/
protected $feature_instance = null;

/**
* @var array $features Array of features provided by this provider.
*/
protected $features = array();


/**
* Provides the provider name.
*
* @return string
*/
public function get_provider_name(): string {
return $this->provider_name;
}

/**
* Get provider features.
*
* @return array
*/
public function get_features(): array {
return $this->features;
}

/**
* Default settings for Provider.
*
* @return array
*/
public function get_default_settings(): array {
return [];
}

/**
* Common entry point for all REST endpoints for this provider.
*
* @param mixed $item The item we're processing.
* @param string $route_to_call The name of the route we're going to be processing.
* @param array $args Optional arguments to pass to the route.
* @return mixed
*/
public function rest_endpoint_callback( $item, string $route_to_call, array $args = [] ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
return null;
}

/**
* Format the result of most recent request.
*
Expand Down
2 changes: 0 additions & 2 deletions includes/Classifai/Providers/Watson/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

use Classifai\Features\Classification;

use function Classifai\get_plugin_settings;

/**
* Returns the currently configured Watson API URL. Lookup order is,
*
Expand Down
1 change: 0 additions & 1 deletion includes/Classifai/Services/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public function get_display_name(): string {
* Render the start of a settings page. The rest is added by the providers
*/
public function render_settings_page() {
$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',
Expand Down
8 changes: 0 additions & 8 deletions tests/Classifai/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ function test_it_has_a_plugin_instance() {
$this->assertInstanceOf( '\Classifai\Plugin', $actual );
}

function test_it_has_plugin_settings() {
$this->markTestSkipped();
update_option( 'classifai_settings', [ 'post_types' => [ 'foo' ] ] );

$actual = get_plugin_settings();
$this->assertEquals( [ 'foo' ], $actual['post_types'] );
}

function test_it_has_default_supported_post_types() {
$actual = get_supported_post_types();
$this->assertEquals( ['post'], $actual );
Expand Down

0 comments on commit 54fa81c

Please sign in to comment.