1

i wrote a CSS plugin for TinyMCE to add a new button to the editor's menubar. I click on the button and a popup opens, the content - written in JS - looks like this:

var form = jQuery('<div id="a2ml-form">\ <div
class="a2ml-form-selector">Landingpage Quiz</div>\ <div
class="a2ml-form-selector">AR Quiz</div>\ </div>');

I want to use the class="a2ml-form-selector" - but the CSS which i applied with this code:

function add_to_head() {
    $url = trim(get_bloginfo('url'), "/");
?>
    <link rel="stylesheet" type="text/css" href="<?=$url?>/wp-content/plugins/a2m_landingpages/a2m_landingpages.css">
<?
}

add_action('wp_head', 'add_to_head');

is not loaded into the wp-admin panel - it is loaded to the mainsite. How can use CSS styles in the admin-panel?

Thanks

1
  • You're using the wrong hook. Commented Feb 21, 2013 at 23:15

1 Answer 1

1

You really shouldn't be writing out your own link tags like that. You should be using the admin_enqueue_scripts hook:

function load_custom_wp_admin_style() {
    wp_register_style( 'a2m_landingpages_css', plugin_dir_path( $plugin_filename ) . '/a2m_landingpages/a2m_landingpages.css', false, '1.0.0' );
    wp_enqueue_style( 'a2m_landingpages_css' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts

You might be able to get away with:

add_action('admin_enqueue_scripts', 'add_to_head');

but it's not the best way.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.