Skip to main content
Slight cleanup, linked forementioned plugin, Don't add line numbers to code please!
Source Link
Howdy_McGee
  • 20.8k
  • 24
  • 91
  • 175

Check Hello Dolly pluginHello Dolly plugin that goescomes with WordPress;

// File: wp-content/plugins/hello.php
79: // We need some CSS to position the paragraph
80: function dolly_css() {
81:     // This makes sure that the positioning is also good for right-to-left languages
82:     $x = is_rtl() ? 'left' : 'right';
83: 
84:     echo "
85:        <style type='text/css'>
86:            #dolly {
87:                float: $x;
88:                padding-$x: 15px;
89:                padding-top: 5px;       
90:                margin: 0;
91:                font-size: 11px;
92:            }
93:        </style>
94:     ";
95: }
96: 
97: add_action( 'admin_head', 'dolly_css' );

Like @benoti mentioned use wp_head hook in you don't need the admin side:

add_action('wp_head', ...'function_callback' );

BTW, this plugins appends styles, and the same isworks for scripts.

Check Hello Dolly plugin that goes with WordPress;

File: wp-content/plugins/hello.php
79: // We need some CSS to position the paragraph
80: function dolly_css() {
81:     // This makes sure that the positioning is also good for right-to-left languages
82:     $x = is_rtl() ? 'left' : 'right';
83: 
84:     echo "
85:     <style type='text/css'>
86:     #dolly {
87:         float: $x;
88:         padding-$x: 15px;
89:         padding-top: 5px;       
90:         margin: 0;
91:         font-size: 11px;
92:     }
93:     </style>
94:     ";
95: }
96: 
97: add_action( 'admin_head', 'dolly_css' );

Like @benoti mentioned use wp_head hook in you don't need the admin side:

add_action('wp_head', ...

BTW, this plugins appends styles, the same is for scripts.

Check Hello Dolly plugin that comes with WordPress;

// File: wp-content/plugins/hello.php
// We need some CSS to position the paragraph
function dolly_css() {
    // This makes sure that the positioning is also good for right-to-left languages
    $x = is_rtl() ? 'left' : 'right';

    echo "
        <style type='text/css'>
            #dolly {
                float: $x;
                padding-$x: 15px;
                padding-top: 5px;       
                margin: 0;
                font-size: 11px;
            }
        </style>
    ";
}
add_action( 'admin_head', 'dolly_css' );

Like @benoti mentioned use wp_head hook in you don't need the admin side:

add_action('wp_head', 'function_callback' );

BTW, this plugins appends styles and the same works for scripts.

Source Link
prosti
  • 4.3k
  • 4
  • 25
  • 45

Check Hello Dolly plugin that goes with WordPress;

File: wp-content/plugins/hello.php
79: // We need some CSS to position the paragraph
80: function dolly_css() {
81:     // This makes sure that the positioning is also good for right-to-left languages
82:     $x = is_rtl() ? 'left' : 'right';
83: 
84:     echo "
85:     <style type='text/css'>
86:     #dolly {
87:         float: $x;
88:         padding-$x: 15px;
89:         padding-top: 5px;       
90:         margin: 0;
91:         font-size: 11px;
92:     }
93:     </style>
94:     ";
95: }
96: 
97: add_action( 'admin_head', 'dolly_css' );

Like @benoti mentioned use wp_head hook in you don't need the admin side:

add_action('wp_head', ...

BTW, this plugins appends styles, the same is for scripts.