Embedded Stylesheet

wordpress

#1

Hi everyone!

Hope someone can help us! We are developing a Wordpress theme for Themeforest but we have seen in the Requirements page that you can’t use inline style, however it doesn’t talk about the embedded style. Here’s what they say:

No hardcoded inline styles are allowed anywhere. Dynamic inline styles are permitted where necessary, and wp_add_inline_style() should be used where possible.

Could they reject a theme with an embedded style like this?

<style type="text/css" scoped>
.text-page-header h2.title-page-header {
color:<?php echo of_get_option('404-title-colorpicker'); ?>;
}
.text-page-header p.text-page-header {
color:<?php echo of_get_option('404-text-colorpicker'); ?>;
}
.text-page-header .header-page-bottom-line {
background-color:<?php echo of_get_option('404-line-colorpicker'); ?>;
}
</style>

Please, we would be very grateful if someone can clear our doubts about this matter. Thank you everyone! :smile:


#2

I am not sure if it will be rejected or not but why would you ever need to use it like this?


#3

If you want your theme options to change css then put your code inside php file and insert it in your header, or if you like me don’t want to insert php file as css file then create a simple php function to generate a css file from your php file using $wp_filesystem and fire this function when user save theme option.

hope this help :smile:


How to Put/Send Data to CSS or JS File from WordPress Dashboard
#4

I think such embedded styles can pass the review. Hardcoded inline style means inline static CSS without any dynamic values. I think I’ve seen an official reply about this somewhere but can’t remember where…


#5

How would you do it?


#6

As always wp_add _inline _style() works for me! What do you prefer ?


#7

Thank you for your answer @parag150k. Sorry for my ignorance, I knew that function ( wp_add _inline _style() ) but I don’t know how to use it inside a loop. Is it possible? Thank you for your feedback!


#8

What’s your requirement ?
we can talk in messages if you want.


#9

Wow, thank you for the information @Znashty! We didn’t know about $wp_filesystem but definitely we will take a look and consider your advice. Thank you again!


#10

Ok, thank you for your reply! :smile: