Make WordPress Core

Changeset 62193


Ignore:
Timestamp:
04/01/2026 03:53:17 PM (11 hours ago)
Author:
jorgefilipecosta
Message:

Fix: Register Akismet Anti-Spam as a connector.

Akismet comes with core but the connectors screen was not showing akismet even if akismet was on the file system. This commit fixes the issue.

Props jorgefilipecosta, bluefuton, gziolo.
Fixes #65012.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/connectors.php

    r62192 r62193  
    210210        _wp_connectors_register_default_ai_providers( $registry );
    211211    }
     212
     213    // Non-AI default connectors.
     214    $registry->register(
     215        'akismet',
     216        array(
     217            'name'           => __( 'Akismet Anti-spam' ),
     218            'description'    => __( 'Protect your site from spam.' ),
     219            'type'           => 'spam_filtering',
     220            'plugin'         => array(
     221                'file' => 'akismet/akismet.php',
     222            ),
     223            'authentication' => array(
     224                'method'          => 'api_key',
     225                'credentials_url' => 'https://akismet.com/get/',
     226                'setting_name'    => 'wordpress_api_key',
     227                'constant_name'   => 'WPCOM_API_KEY',
     228            ),
     229        )
     230    );
    212231
    213232    /**
  • trunk/tests/phpunit/tests/connectors/wpConnectorsGetConnectorSettings.php

    r62056 r62193  
    3838        $this->assertArrayHasKey( 'openai', $connectors );
    3939        $this->assertArrayHasKey( 'anthropic', $connectors );
     40        $this->assertArrayHasKey( 'akismet', $connectors );
    4041        $this->assertArrayHasKey( 'mock-connectors-test', $connectors );
    41         $this->assertCount( 4, $connectors );
     42        $this->assertCount( 5, $connectors );
    4243    }
    4344
     
    5758            $this->assertIsString( $connector_data['description'], "Connector '{$connector_id}' description should be a string." );
    5859            $this->assertArrayHasKey( 'type', $connector_data, "Connector '{$connector_id}' is missing 'type'." );
    59             $this->assertContains( $connector_data['type'], array( 'ai_provider' ), "Connector '{$connector_id}' has unexpected type '{$connector_data['type']}'." );
     60            $this->assertContains( $connector_data['type'], array( 'ai_provider', 'spam_filtering' ), "Connector '{$connector_id}' has unexpected type '{$connector_data['type']}'." );
    6061            $this->assertArrayHasKey( 'authentication', $connector_data, "Connector '{$connector_id}' is missing 'authentication'." );
    6162            $this->assertIsArray( $connector_data['authentication'], "Connector '{$connector_id}' authentication should be an array." );
     
    8081
    8182            $this->assertArrayHasKey( 'setting_name', $connector_data['authentication'], "Connector '{$connector_id}' authentication is missing 'setting_name'." );
    82             $this->assertSame(
    83                 'connectors_ai_' . str_replace( '-', '_', $connector_id ) . '_api_key',
    84                 $connector_data['authentication']['setting_name'] ?? null,
    85                 "Connector '{$connector_id}' setting_name does not match expected format."
    86             );
     83
     84            // AI providers use the connectors_ai_{id}_api_key convention.
     85            // Non-AI connectors may use custom setting names.
     86            if ( 'ai_provider' === $connector_data['type'] ) {
     87                $this->assertSame(
     88                    'connectors_ai_' . str_replace( '-', '_', $connector_id ) . '_api_key',
     89                    $connector_data['authentication']['setting_name'] ?? null,
     90                    "Connector '{$connector_id}' setting_name does not match expected format."
     91                );
     92            }
    8793        }
    8894
  • trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php

    r62058 r62193  
    120120            'default_comment_status',
    121121            'site_icon', // Registered in wp-includes/blocks/site-logo.php
     122            'wordpress_api_key', // Registered by Akismet connector.
    122123            'wp_collaboration_enabled',
    123124        );
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r62081 r62193  
    1101211012                    ],
    1101311013                    "args": {
     11014                        "wordpress_api_key": {
     11015                            "title": "Akismet Anti-spam API Key",
     11016                            "description": "API key for the Akismet Anti-spam connector.",
     11017                            "type": "string",
     11018                            "required": false
     11019                        },
    1101411020                        "title": {
    1101511021                            "title": "Title",
     
    1454514551
    1454614552mockedApiResponse.settings = {
     14553    "wordpress_api_key": "",
    1454714554    "title": "Test Blog",
    1454814555    "description": "",
Note: See TracChangeset for help on using the changeset viewer.