No unsafe-inline
Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context. Cross-site scripting (XSS) is a type of security vulnerability that can be found in some web applications. XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls like the same-origin policy. Looking at National Vulnerability Database run by US NIST, more than 1100 (November 2025) vulnerabilities are reported as XSS for WordPress’ plugins and themes. Keeping your site up-to-date with the latest versions of plugins and themes is the first line of defense to ensure your site’s security. The second thing to do, is to deploy a strict Content Security Policy. The main problem The main problem with Content Security Policies implemented in the real world is that they are too weak to really protect your site and that many of them can be trivially bypassed by an attacker. The proposed solution Google researchers recommend, instead of whole host whitelisting, to activate individual scripts via a CSP nonces approach. In addition, in order to facilitate the adoption of nonce-based CSP, they proposed the ’strict-dynamic’ keyword. The problem(s) with CSP in WordPress Manual creation of a policy Usually, a WordPress project is a mix of code written by different authors who contributed to the Core and or wrote plugins and themes. If it is possible to whitelist every external script loaded from a , the real truth is that in a WordPress project you can have dozens of those scripts included with your plugins and calculate a cryptographic hash for each of them to be included in your CSP header can be a frustrating job. However, there are many browser extensions and WordPress’ plugins that can help you in this job. Inline scripts WordPress core, and plugins, use inline scripts. For these scripts, you can compute hashes to be inserted manually into your policy, only if these scripts do not change at any page load. Unfortunately, this is not very common, as it is frequent to include variable values calculated server side in inline scripts. And it means that your inline scripts change too frequently to manually add their hashes to your policy. This commonly happens when scripts are “localized”. WordPress has no API to implement nonces for CSP Even if it is easy to generate a nonce for each page view, this nonce has to be inserted in every script tag used to embed inline scripts in your page as doWhatever(); and in your script-src directive: script-src 'nonce-rAnd0m'; And, of course, a nonce must be unique for each HTTP response. Unsafe hashes / Inline styles Sometimes, HTML elements as images or buttons use HTML Event Attributes (onclick, onsubmit…) to let events trigger actions in a browser. You cannot use hashes or nonces for script included in event attributes and, adopting a strict CSP, requires refactoring those patterns into safer alternatives or to use ‘unsafe-hashes’. You got a similar problem when inline styles are used in HTML tags: This is a heading This is a paragraph. CSP Level 2 browsers may be ok with just putting the hash in your style-src directive. However, to allow hashes in the style attribute on inline CSS on browsers that support CSP Level 3, you may get an error like this Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'sha256-nMxMqdZhkHxz5vAuW/PAoLvECzzsmeAxD/BNwG15HuA='". Either the 'unsafe-inline' keyword, a hash ('sha256-nMxMqdZhkHxz5vAuW/PAoLvECzzsmeAxD/BNwG15HuA='), or a nonce ('nonce-...') is required to enable inline execution. To allow inline styles you need to use ‘unsafe-hashes’ in your style-src directive (that is, in facts, unsafe). ^ This plugin approach This plugin affords those problems in this way: During a capture phase, it detects the scripts, styles and other embedded content present in the pages of your site and stores them in the database. Then you have to whitelist these contents from plugin admin. The plugin uses machine learning to cluster inline scripts trying to aggregate scripts generated by the same server side (PHP) code. So, you can authorize one script example to authorize all scripts that the classifier predicts to label as whitelisted clusters. You can choose to use hashes to authorize external scripts (and the plugin will allow you to include Subresource Integrity in your and ) You can use hashes or nonces to authorize inline scripts. You can ask the plugin to refactor your page to not use event attributes (converted in a inline script) and inline styles (converted in an internal CSS). You can set one or more violations’ report endpoints. The plugin supports multisite installations and has (too) many options documented in inline help. Creating a Content Security Policy After plugin activation, go to Settings menu and search for CSP Settings submenu. The steps you are supposed to do are the following. From the Tools tab, activate the capture of the tags and use your site by visiting all the pages or having your users visit them for a long time long period based on the use of your site (hours or days). From the Tools tab, perform the data clustering in the database (it can use many server resources). Go to the Base rules tab and include in the CSP directives the desired values (help you with the table at the bottom of the page). Go to the external scripts tab, inline scripts tab and scripts invoked by event handlers tab and authorize the execution of all the legitimate scripts present on the pages of your site. Leaving the tag capture active, activate the policy test (at this stage the plugin will generate some violations of the temporary policy used to record additional values to be included in the directives of your “content security policy”). After visiting again your site pages, disable the capture of the tags and repeat the previous steps 2, 3 and 4. Enable site protection. N.B. When you update plugins or themes, if something doesn’t work properly on your site pages, temporarily deactivate the protection and repeat steps 1 to 7. Plugin hooks Filters nunil_output_csp_headers_header_csp nunil_output_csp_headers_header_csp is available since version 1.2.3 and can be used to modify the Content-Security-Policy header before it is sent to browser no_unsafe_inline_not_sri_sources no_unsafe_inline_not_sri_sources can be used to modify the list of external resources that do not support SRI (Subresource Integrity) no_unsafe_inline_final_output no_unsafe_inline_final_output is an internal filter used to manipulate the output of the WordPress process just before the output is sent to the browser. no_unsafe_inline_meta_injector no_unsafe_inline_meta_injector is an internal filter hook used to inject meta http-equiv=”Content-Security-Policy” if variable is set Actions nunil_upgrade Functions hooked on nunil_upgrade will run when the plugin is upgraded nunil_output_csp_headers Functions hooked to nunil_output_csp_headers will run when the plugin output the CSP HTTP response header Code and libraries This version of the plugin uses: * to parse HTML: * ivopetkov/HTML5DOMDocument on PHP 2.13.09 * \Dom\HTMLDocument: The new ext-dom features with HTML5 support on PHP>8.4 * RubixML for machine learning from version 1.1.0 – PHP-ML was used in versions 1.0.x; * opctim/php-nilsimsa to calculate and compare Nilsimsa digests. The log functions have been taken from * perfectyorg/perfecty-push-wp, something you should really try if you want to implement web Push notifications in your site. The complete list of dependencies used in this plugin can be seen in dependency graph on GitHub. Contributions, Issues, Bugs Plugin code is hosted on a public repository on GitHub. Reach me over there to help and suggest.
Top keywords
- inline23×1.74%
- scripts21×1.59%
- csp18×1.36%
- policy11×0.83%
- site11×0.83%
- output9×0.68%
- security9×0.68%
- content8×0.61%
- inline scripts8×0.61%
- unsafe8×0.61%
- wordpress8×0.61%
- hashes7×0.53%
Yoast SEO – Advanced SEO with real-time guidance and built-in AI
Real-time SEO guidance, schema, and AI built in. Help search engines and AI systems understand your content. All AI tools included, no hidden fees. Yoast SEO: the #1 WordPress SEO plugin Since 2008, Yoast SEO has helped site owners get their content found. More than 10 million websites now run it, from small local businesses to some of the most visited sites on the web. Our mission is SEO for everyone. You should not need a specialist, a big budget, or a technical background to give your content a fair chance of being discovered. Yoast SEO gives you everything you need to manage your on-site SEO. The Yoast SEO Premium plugin and its extensions unlock more advanced and AI-powered tools. Ready for search, and ready for AI People no longer only type queries into Google. They ask AI assistants, and those answers are built from content the AI has crawled, understood, and trusted. Yoast SEO helps you prepare for both. Schema.org structured data, so search engines and AI systems can understand what your content is actually about. Premium outputs significantly more schema types, including the E-E-A-T signals (experience, expertise, authoritativeness, and trustworthiness) that help AI systems understand who you are. Schema aggregation for NLWeb (Premium), which combines your site’s structured data into a single, deduplicated graph, so AI agents get a complete picture of your content in one request. Turn it on with a single toggle. LLMs.txt management, to guide how large language models interact with your content, including manual control over which pages are included. Bot blocker (Premium), to control which AI crawlers can use your content for training, including GPTBot, CCBot, and Google-Extended. Abilities API, so AI tools, dashboards, and automated workflows can read your SEO, readability, and inclusive language scores directly. Algorithm changes have been arriving for over 15 years, and Yoast has tracked every one of them. Keeping the plugin updated means you benefit from ongoing technical improvements, schema updates, and AI advancements automatically, all guided by our signature traffic light approach. Real-time guidance while you write SEO is one of the most consistent and cost-effective sources of website traffic, though it can be complex. Whether you are just starting out or you have done this for years, Yoast SEO tells you what to fix before you publish, not after. Red, orange, green. That is the whole idea. You get in-depth content and readability analysis that helps you create content designed to perform well in search, without needing to learn a new discipline first. Quick and easy setup Setting up Yoast SEO is quick and straightforward. No technical background required. Our step-by-step configuration wizard walks you through the essentials, so Yoast SEO can generate accurate structured data that helps search engines understand your site. Switching from another SEO plugin? Migration is seamless. You can import your existing SEO data and settings safely with our built-in import and export tools. AI tools built into your workflow Yoast’s AI tools come with Yoast SEO Premium, and they sit inside the editor you already use. There is no separate AI subscription, no extra login, and no credit top-up to buy. Every suggestion waits for your approval before anything saves. Yoast AI Generate: creates five SEO-friendly titles and meta descriptions instantly, with one-click regeneration for more options. Yoast AI Optimize: suggests improvements to keyphrase placement, including introduction, distribution, and density, with the option to apply or dismiss each edit. Yoast AI Summarize: generates a quick summary of your post to place anywhere in the block editor, so readers grasp the value fast. Yoast AI Content Planner (Premium): suggests five site-specific post ideas and builds a structured starter draft the moment you open a new post. Ideas are grounded in your own site, not generic topics, so your team never begins from a blank page. Bulk editor with AI drafts: review and fix titles, meta descriptions, and focus keyphrases across your whole site from one workspace, with search and status filters and a dedicated view per content type. The bulk editor is free. With Premium, select what needs work and AI drafts the metadata, including social sharing titles and descriptions, for you to approve. All AI tools included: no extra accounts, no separate credit purchase, no hidden costs. Content analysis and optimization SEO analysis to guide your keyword targeting, with up to 5 keyphrases in Premium and support for 20+ languages. Readability analysis for clear, engaging, user-friendly writing. Inclusive language analysis, so your content is more considerate and accessible. SERP previews for both desktop and mobile results. HowTo and FAQ blocks with built-in schema support. Breadcrumbs block for improved navigation. Semrush integration for keyword research directly inside Yoast SEO. Wincher integration to track keyword performance from your dashboard. Elementor integration for optimization inside your favorite builder. Technical SEO, handled for you Yoast SEO takes care of much of your site’s technical SEO automatically, which frees you to focus on your content. Automated meta tag optimization right out of the box. Canonical URLs to prevent duplicate content issues. Advanced XML sitemaps for clear site indexing. Deep Schema.org integration to improve how search engines and AI systems understand your site. Complete breadcrumb control for visitors and crawlers. Performance improvements that help reduce load times. Crawl settings to manage how bots access your site and reduce unnecessary server load. Every update delivers ongoing technical SEO enhancements automatically. Keep your website in perfect shape Whether you are a creator, a business owner, or a developer, Yoast SEO helps you maintain your site’s SEO health: Cornerstone content tools to organize and prioritize your key pages. Front-end SEO inspector to view and edit titles, descriptions, and schema live. SEO roles to delegate plugin access securely across your team. Regular 2-week update cycle, so you stay compatible with the latest SEO standards and search engine changes. Powerful integrations Yoast SEO works seamlessly with popular WordPress tools: Google Site Kit: access insights from Search Console, Analytics, and PageSpeed inside WordPress. Advanced Custom Fields (ACF): combine with ACF Content Analysis for Yoast SEO for advanced field optimization. Elementor: use full Yoast SEO functionality inside Elementor’s editor. Algolia: improve internal search accuracy and performance. Semrush: discover and optimize for high-value keywords. Wincher: track keyword positions and trends in Google Search. Jetpack: manage SEO and social previews in one place. Easy Digital Downloads (EDD): improve digital product visibility with integrated schema. Mastodon: verify your website on Mastodon with Yoast SEO Premium. WooCommerce: optimize ecommerce SEO with the dedicated WooCommerce extension. Yoast SEO Premium: AI-powered SEO for WordPress Yoast SEO Premium builds on everything above with advanced automation, AI tools, and professional support. It helps you optimize efficiently for both traditional search and AI-driven discovery. What it helps you tackle: Keeping pace with algorithm changes and AI search. Reaching the right audience. Automating redirects, crawl controls, and internal linking. Finding orphaned content and improving your site structure. Getting expert help when you need it. Premium highlights: AI-generated titles and meta descriptions, page by page or in bulk. AI Content Planner, so you never open a blank page. Smart internal linking suggestions to strengthen your site structure. Social previews for Facebook and X. Redirect manager with bulk tools, CSV import and export, and automatic prompts when you move or delete content. Bot blocker for AI crawlers, including GPTBot, CCBot, and Google-Extended. Schema aggregation for NLWeb, plus significantly more schema types than free. IndexNow integration, so search engines hear about your updates the moment you publish. Front-end SEO inspector for real-time editing. SEO workouts for orphaned and cornerstone content. Task list, unlocked in full, showing what to work on next with priority levels and time estimates. Google Docs add-on, so writers can run the full Yoast analysis before content ever reaches WordPress. One seat included. 24/7 premium support from SEO specialists. Included at no extra cost: Yoast Local SEO: help nearby customers find you, with local schema, a store locator, and opening hours management. Yoast Video SEO: help Google understand your videos, with video sitemaps and schema. Yoast News SEO: help your news content get discovered in Google News and Top Stories. Yoast WooCommerce SEO: advanced SEO for online stores Yoast WooCommerce SEO builds on Yoast SEO Premium with ecommerce-specific tools for your store’s visibility. Key ecommerce features: WooCommerce-specific XML sitemap that excludes non-shopping content. Product structured data for rich results, including price, reviews, and availability. Canonical URL management to prevent duplicates. Ecommerce-focused content analysis for GTINs, SKUs, and short descriptions. AI Generate for ecommerce: optimized titles and meta descriptions for product and category pages, at page level or drafted in bulk for products and categories. What that gets you: Better product visibility through automated structured data. More efficient crawling for large catalogs. Time saved through metadata templates and automation. Metadata across your whole catalog without editing rows one at a time. Built for WooCommerce, trusted by thousands of online stores worldwide. For developers Yoast SEO is built with developers in mind. With modern APIs, hooks, and a unified indexables system, you can extend or integrate SEO functionality across custom themes, plugins, or headless setups. REST API Retrieve SEO metadata for any post or URL, including meta tags, Open Graph, Twitter Cards, and Schema.org data. Learn more about the REST API. Surfaces API Access SEO data directly in code via YoastSEO()->meta->for_current_page(). Supports titles, descriptions, canonicals, and schema. Read the Surfaces API documentation. Metadata API Use the Metadata API to filter, override, or extend meta tags with WordPress hooks such as wpseo_title, wpseo_metadesc, and wpseo_canonical. Schema API The Schema API lets you modify or extend Schema.org graph pieces, including Article, Organization, Person, Breadcrumb, and WebPage entities. Abilities API integration Let AI tools, dashboards, and automated workflows read Yoast SEO data programmatically, including SEO, readability, and inclusive language scores for recent posts. Block editor compatibility Yoast SEO integrates directly with the WordPress block editor. It outputs schema for HowTo and FAQ blocks by default, and you can extend schema for custom blocks. Indexables At the core of Yoast SEO lies the indexables system, unifying all SEO data for faster queries and consistent metadata across outputs. Ongoing support and education Yoast is powered by expert developers, testers, and SEO specialists who keep improving the plugin. We are committed to helping you grow your SEO skills: Yoast SEO Academy: free and premium SEO courses, included in all paid plans. Yoast SEO blog, newsletter, and webinars. Yoast SEO Update podcast for the latest SEO insights. Bug reports on GitHub, for issue tracking rather than support. Yoast SEO: built to make search optimization accessible, reliable, and ready for the future of AI search.