Embedded Stylesheet

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:

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

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:

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…

1 Like

How would you do it?

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

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!

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

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!

Ok, thank you for your reply! :smile: