Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add a stylesheet to the options page for my plugin - code looks like this:

add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' );

function rps_paypal_add_css() {
wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) );
}


add_action( 'admin_menu', 'rps_myplugin_add_page' );

function rps_myplugin_add_page() {
add_options_page(
    'My PayPal Plugin',
    'My PayPal Plugin',
    'manage_options',
    'rps-paypal',
    'rps_myplugin_option_page'
);
}

Can't figure out why it's not showing up...

share|improve this question

2 Answers 2

up vote 1 down vote accepted

the call to add_options_page will return the string literal to use for your RSS, so it should look something like this:

$page = add_options_page( ... );
add_action( 'admin_print_styles-' . $page, 'rps_paypal_add_css' );

More info here: http://codex.wordpress.org/Function_Reference/wp_enqueue_style

share|improve this answer
    
Hi Kovshenin, that did it! Many thanks. –  Richard Sweeney Apr 29 '11 at 11:37
    
You're welcome Richard. What Rast said below is true as well, you shouldn't hard-code your plugin name during the call to plugins_rss. –  kovshenin Apr 29 '11 at 11:39

First I am not sure you get hook suffix right. It is return of add_options_page() function and from quick test should be something like admin_page_rps-paypal in your case. But really you should save that return in the variable and use that rather than hardcode it.

Second your plugins_url() usage is little off, your plugin's folder name is not guaranteed to be that. More robust to use it like:

plugins_url('/css/rps-paypal.css', __FILE__);
share|improve this answer
    
Hi Rarst, Thanks so much for this - this is my first attempt at writing a plugin so all advice is greatly appreciated! - R –  Richard Sweeney Apr 29 '11 at 12:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.