Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect WordPress theme slugs #157

Merged
merged 4 commits into from
Feb 4, 2025
Merged

Conversation

swissspidy
Copy link
Contributor

There is a new change in the upcoming WordPress 6.8 release that exposes the slugs of the currently active theme(s) via a class on the <body>.

This makes it easy to track individual theme adoption.


Test websites:

Copy link
Contributor

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swissspidy Thanks for the PR! Looks good overall, though I think tracking this slightly differently would be more efficient for queries.

@swissspidy swissspidy requested a review from felixarntz January 27, 2025 20:28
Copy link
Contributor

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swissspidy LGTM!

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I presume it's not possible to have multiple themes or child themes?

Copy link

github-actions bot commented Feb 4, 2025

https://almanac.httparchive.org/en/2022/

WPT result details

Changed custom metrics values:

{
  "_cms": {
    "wordpress": {
      "theme": {
        "theme": null,
        "child_theme": null
      },
      "block_theme": false,
      "has_embed_block": false,
      "embed_block_count": {
        "total": 0,
        "total_by_type": []
      },
      "scripts": [],
      "content_type": {
        "template": "unknown",
        "post_type": "",
        "taxonomy": ""
      },
      "uses_interactivity_api": false,
      "interactivity_api_usage": {
        "total_regions": 0,
        "total_regions_by_namespace": []
      }
    }
  }
}
https://ma.tt

WPT result details

Changed custom metrics values:

{
  "_cms": {
    "wordpress": {
      "theme": {
        "theme": "twentythirteen",
        "child_theme": "matt"
      },
      "block_theme": false,
      "has_embed_block": true,
      "embed_block_count": {
        "total": 8,
        "total_by_type": {
          "youtube": 6,
          "soundcloud": 1,
          "spotify": 1
        }
      },
      "scripts": [
        {
          "handle": "the-neverending-homepage",
          "src": "https://ma.tt/blog-content/plugins/jetpack/_inc/build/infinite-scroll/infinity.min.js?ver=14.2.1-is5.0.1",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "jp-lite-youtube-embed-script",
          "src": "https://ma.tt/blog-content/mu-plugins/jp-lite-youtube-embed/lite-yt-embed.min.js?ver=0.3.2-5",
          "in_footer": true,
          "async": false,
          "defer": true,
          "intended_strategy": "defer",
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "wp-polyfill",
          "src": "https://ma.tt/blog/wp-includes/js/dist/vendor/wp-polyfill.min.js?ver=3.15.0",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "wp-hooks",
          "src": "https://ma.tt/blog-content/plugins/gutenberg/build/hooks/index.min.js?ver=84e753e2b66eb7028d38",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "wp-i18n",
          "src": "https://ma.tt/blog-content/plugins/gutenberg/build/i18n/index.min.js?ver=bd5a2533e717a1043151",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": 68,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "wp-jp-i18n-loader",
          "src": "https://ma.tt/blog-content/plugins/jetpack-boost/jetpack_vendor/automattic/jetpack-assets/build/i18n-loader.js?minify=true&ver=becd7d9884bc1b331e45",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": 4096,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "wp-url",
          "src": "https://ma.tt/blog-content/plugins/gutenberg/build/url/index.min.js?ver=499ac283dc628dfb623e",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "jetpack-instant-search",
          "src": "https://ma.tt/blog-content/plugins/jetpack/jetpack_vendor/automattic/jetpack-search/build/instant-search/jp-search.js?minify=false&ver=da5ecd9f722e7fcb409e",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": 1489,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "jp-tracks",
          "src": "https://stats.wp.com/w.js?ver=202506",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "wp-parsely-loader",
          "src": "https://ma.tt/blog-content/plugins/wp-parsely/build/loader.js?ver=b681bb9905652ac12735",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "matt-script",
          "src": "https://ma.tt/blog-content/themes/ma.tt/js/matt.js?ver=1719254596",
          "in_footer": true,
          "async": false,
          "defer": true,
          "intended_strategy": "defer",
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "jetpack-carousel",
          "src": "https://ma.tt/blog-content/plugins/jetpack/_inc/build/carousel/jetpack-carousel.min.js?ver=14.2.1",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": 1532,
          "translations_script_size": null
        },
        {
          "handle": "gravatar-enhanced-hovercards",
          "src": "https://ma.tt/blog-content/plugins/gravatar-enhanced/build/hovercards.js?ver=379f2afa46f37169f7a3",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": null,
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "matt-base-theme-functions",
          "src": "https://ma.tt/blog-content/themes/ma.tt/js/base-functions.js?ver=6.8-alpha-59756",
          "in_footer": true,
          "async": false,
          "defer": true,
          "intended_strategy": "defer",
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "tiled-gallery",
          "src": "https://ma.tt/blog-content/plugins/jetpack/_inc/build/tiled-gallery/tiled-gallery/tiled-gallery.min.js?ver=14.2.1",
          "in_footer": true,
          "async": false,
          "defer": true,
          "intended_strategy": "defer",
          "after_script_size": null,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        },
        {
          "handle": "jetpack-stats",
          "src": "https://stats.wp.com/e-202506.js",
          "in_footer": true,
          "async": false,
          "defer": false,
          "intended_strategy": "defer",
          "after_script_size": 219,
          "before_script_size": null,
          "extra_script_size": null,
          "translations_script_size": null
        }
      ],
      "content_type": {
        "template": "home-blog",
        "post_type": "post",
        "taxonomy": ""
      },
      "uses_interactivity_api": false,
      "interactivity_api_usage": {
        "total_regions": 0,
        "total_regions_by_namespace": []
      }
    }
  }
}

@tunetheweb tunetheweb merged commit 8750d94 into HTTPArchive:main Feb 4, 2025
2 checks passed
@felixarntz
Copy link
Contributor

LGTM. I presume it's not possible to have multiple themes or child themes?

Indeed, that's not possible. 👍

@swissspidy swissspidy deleted the add-wp-theme branch February 4, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants