โ† SEO Score API  ยท  Blog

Build a WordPress SEO Audit Plugin in 30 Minutes

Published 2026-02-25

WordPress powers 40%+ of the web. Imagine giving every WordPress admin a one-click SEO score right in their dashboard. Here's how to build it.

What We're Building

A simple WordPress plugin that:

The Plugin (Complete Code)

<?php
/**
 * Plugin Name: SEO Score Checker
 * Description: Shows SEO score for your site using SEO Score API
 * Version: 1.0
 */

// Settings page for API key
add_action('admin_menu', function() {
    add_options_page(
        'SEO Score Settings',
        'SEO Score',
        'manage_options',
        'seo-score',
        'seo_score_settings_page'
    );
});

function seo_score_settings_page() {
    if (isset($_POST['seo_score_api_key'])) {
        update_option('seo_score_api_key',
            sanitize_text_field($_POST['seo_score_api_key']));
        echo '<div class="updated"><p>API key saved.</p></div>';
    }
    $key = get_option('seo_score_api_key', '');
    echo '<div class="wrap">';
    echo '<h1>SEO Score Settings</h1>';
    echo '<form method="post">';
    echo '<p>Get a free API key at ';
    echo '<a href="https://seoscoreapi.com">seoscoreapi.com</a></p>';
    echo '<input type="text" name="seo_score_api_key" ';
    echo 'value="' . esc_attr($key) . '" class="regular-text">';
    echo '<br><br>';
    echo '<input type="submit" class="button-primary" ';
    echo 'value="Save Key">';
    echo '</form></div>';
}

// Dashboard widget
add_action('wp_dashboard_setup', function() {
    wp_add_dashboard_widget(
        'seo_score_widget',
        'SEO Score',
        'seo_score_dashboard_widget'
    );
});

function seo_score_dashboard_widget() {
    $key = get_option('seo_score_api_key');
    if (!$key) {
        echo '<p>Set your API key in Settings โ†’ SEO Score</p>';
        return;
    }

    $url = home_url('/');
    $cached = get_transient('seo_score_result');

    if (!$cached) {
        $response = wp_remote_get(
            'https://seoscoreapi.com/audit?url=' . urlencode($url),
            ['headers' => ['X-API-Key' => $key], 'timeout' => 15]
        );

        if (is_wp_error($response)) {
            echo '<p>Could not fetch score.</p>';
            return;
        }

        $cached = json_decode(wp_remote_retrieve_body($response), true);
        set_transient('seo_score_result', $cached, HOUR_IN_SECONDS);
    }

    $score = $cached['score'] ?? 0;
    $grade = $cached['grade'] ?? '?';
    $color = $score >= 90 ? '#22c55e' : ($score >= 70 ? '#eab308' : '#ef4444');

    echo "<div style='text-align:center;padding:1rem'>";
    echo "<div style='font-size:3rem;font-weight:800;color:{$color}'>";
    echo "{$score}</div>";
    echo "<div style='font-size:1.2rem;color:{$color}'>{$grade}</div>";
    echo "<p>{$url}</p>";
    echo "</div>";

    if (!empty($cached['priorities'])) {
        echo '<h4>Top Priorities:</h4><ul>';
        foreach (array_slice($cached['priorities'], 0, 5) as $p) {
            echo "<li><strong>[{$p['severity']}]</strong> ";
            echo esc_html($p['issue']) . "</li>";
        }
        echo '</ul>';
    }

    echo '<p><a href="https://seoscoreapi.com/report/' ;
    echo parse_url($url, PHP_URL_HOST);
    echo '" target="_blank">View Full Report โ†’</a></p>';
}
?>

Installation

  1. Save the code above as seo-score-checker.php
  2. Upload to wp-content/plugins/seo-score-checker/
  3. Activate in WordPress admin โ†’ Plugins
  4. Go to Settings โ†’ SEO Score, enter your free API key
  5. Check your dashboard โ€” the score widget appears automatically

Next Steps

This is a starter plugin. You could extend it to:

The API handles all the heavy lifting โ€” your plugin just needs to make one HTTP request.

Check your SEO score now

Try the live demo โ€” no signup required.

Try Live Demo โ†’