Comments (3)
I now had time to look at this. Yes, the inline styles can be changed to use wp_add_inline_style()
, and that will be implemented in the next version. Thanks!
from relevanssi.
The inline <script>
tag – no problem, I've fixed that (for WP 5.7+ users).
The inline styles in the related posts are a trickier case to solve. The styles are related to a template, which may or may not be loaded. Adding a CSS file loaded when the template is used is possible, but it seems somewhat complicated. Also, part of the CSS depends on the user settings. wp_add_inline_style()
requires a stylesheet where the inline style is added, and Relevanssi Premium has no stylesheet in itself, so that's not an option.
At the moment, I think this can be left as is. The current solution is convenient for most users, and if you need to avoid inline styles, it's easy to create a version of the template without the inline CSS and simply place the CSS in your theme stylesheet.
from relevanssi.
Hi @msaari
Thanks for your reply and willing to change the inline <script>
tags. For inline styles this could be a solution:
function add_inline_styles() {
$custom_css = "
body {
background-color: #ff0000;
}
";
$handle = 'custom-inline-styles';
wp_register_style( $handle, false );
wp_add_inline_style( $handle, $custom_css );
wp_enqueue_style( $handle );
}
add_action('wp_enqueue_scripts', 'add_inline_styles');
Registering a stylesheet without src (set to false) is possible and valid and Wordpress core is using this too. Using wp_add_inline_style
makes it more easy to add a nonce.
from relevanssi.
Related Issues (20)
- Relevanssi breaks the Media Library grid search
- Premium 2.14.5: empty search queries are a DoS risk? HOT 5
- $progress not defined when used in wp-cli HOT 1
- Certain complex tax_query structures don't work
- Oxygen revisions are indexed
- function relevanssi_total_queries performance problem HOT 2
- Using search result highlighting breaks <code>-blocks HOT 6
- How to get in touch regarding a security concern HOT 1
- 4.16.0 showing as available in wpackagist but no release/tag exists HOT 4
- YITH Badge Management problem with Relevanssi active HOT 4
- Bug: Highlighting causing broken HTML HOT 2
- Relevanssi Premium, relevanssi_do_query returns stdClasses HOT 3
- relevanssi_render_block not called HOT 2
- Exact match boost not working with capital accented letters HOT 2
- PHP8.1 and relevanssi_meta_query_from_query_vars() HOT 5
- relevanssi_post_date_throttle_join replaces Join instead of adding something HOT 2
- Homepage displaying unwanted search results HOT 2
- Feature Request: Increase compatibility with Elementor HOT 6
- Bug: Pagination prev/next mixed up HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relevanssi.