Skip to content

Commit b26ee6b

Browse files
authored
Merge pull request #9 from circuscode/review-issue-enqueueing-styles
Enqueue CSS
2 parents ff364e6 + b537edd commit b26ee6b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tootpress_plugin.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,32 @@
1717
*/
1818

1919
function tootpress_blogs_css() {
20+
// Load CSS only on Toots Page
2021
if ( tootpress_toot_here() ){
22+
// Load CSS only if Option is set
2123
if(get_option('tootpress_css')) {
22-
$add_css='<link rel="stylesheet" id="mathilda-css" href="'. plugins_url() .'/tootpress/tootpress_toots.css" type="text/css" media="all">';
23-
echo $add_css;
24+
wp_register_style( 'tootpress', plugins_url( 'tootpress_toots.css' ) );
25+
wp_enqueue_style( 'tootpress' );
2426
}
2527
}
2628
}
27-
28-
add_action('wp_head','tootpress_blogs_css');
29+
add_action('wp_enqueue_scripts','tootpress_blogs_css');
2930

3031
/**
3132
* Adds Admin CSS
3233
*
3334
* @since 0.1
3435
*/
3536

36-
function tootpress_admin_css() {
37-
$add_css='<link rel="stylesheet" id="tootpress-css" href="'. plugins_url() .'/tootpress/tootpress_tools.css" type="text/css" media="all">';
38-
echo $add_css;
37+
function tootpress_admin_css($hook) {
38+
// Load CSS only on Toots Tools Page
39+
if ( 'tools_page_tootpress-tools-menu' != $hook ) {
40+
return;
41+
}
42+
wp_register_style( 'tootpress', plugins_url( 'tootpress_tools.css' ) );
43+
wp_enqueue_style( 'tootpress' );
3944
}
40-
add_action( 'admin_head', 'tootpress_admin_css' );
45+
add_action( 'admin_enqueue_scripts', 'tootpress_admin_css' );
4146

4247
/**
4348
* Adds Mathilda Flag

0 commit comments

Comments
 (0)