Add CSS to Php Wordpress plugin -


i wrote simple plugin sets css code using wp_options. looks similar this:

add_action('init','easy_style');  function easy_style() {     ?>     <style>     #header {         color: <?php echo get_option('topcolor'); ?>;         font-size: <?php echo get_option('topsize'); ?>px;         <?php             if (get_option('topstyle') == "bold")             { echo "font-weight: bold;"; echo "font-style: normal;"; }             elseif (get_option('topstyle') == "italic")             { echo "font-style: italic;"; echo "font-weight: normal;"; }             elseif (get_option('topstyle') == "bolditalic")             { echo "font-weight: bold;"; echo "font-style: italic;"; }             else { echo "font-weight: normal;"; echo "font-style: normal;"; }         ?>;     }      </style>     <?php } 

now works, if activate "contact form 7" plugin, contact form 7 doesn't work anymore. can't send mails. think wrong. if remove piece of code, contact form works again...

i think wrong because css needs loaded in header, no? thought test put same code in header. other css (i don't know where) overwrites these, doesn't work.

i think there wp functions add css code header don't know how exacly.

any ideas?

thanks

a safe way add css plugin use wp_enqueue_style.

/**  * register hook 'wp_enqueue_scripts', can used front end css , javascript  */ add_action( 'wp_enqueue_scripts', 'prefix_add_my_stylesheet' );  /**  * enqueue plugin style-file  */ function prefix_add_my_stylesheet() {     // respects ssl, style.css relative current file     wp_register_style( 'prefix-style', plugins_url('style.css', __file__) );     wp_enqueue_style( 'prefix-style' ); } 

reference.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -