Title: admin_print_scripts
Published: April 25, 2014
Last modified: February 24, 2026

---

# do_action( ‘admin_print_scripts’ )

## In this article

 * [More Information](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#wp--skip-link--target)

Fires when scripts are printed for all admin pages.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#more-information)󠁿

 * `admin_print_scripts` mainly used to echo inline javascript in admin pages header.
 * `admin_print_scripts` **should not be used to enqueue styles or scripts** on 
   the admin pages. Use `[admin_enqueue_scripts](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts)`
   instead.
 * `admin_print_scripts` could be used to insert inline script in admin pages header
   while `admin_print_footer_scripts` could be used to insert inline script in admin
   pages footer.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#source)󠁿

    ```php
    do_action( 'admin_print_scripts' );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/admin-header.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/admin-header.php#L151)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/admin-header.php#L151-L151)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#related)󠁿

| Used by | Description | 
| [iframe_header()](https://developer.wordpress.org/reference/functions/iframe_header/)`wp-admin/includes/template.php` |

Generic Iframe header for use with Thickbox.

  | 
| [wp_iframe()](https://developer.wordpress.org/reference/functions/wp_iframe/)`wp-admin/includes/media.php` |

Outputs the iframe to display the media upload page.

  | 
| [WP_Customize_Widgets::print_scripts()](https://developer.wordpress.org/reference/classes/wp_customize_widgets/print_scripts/)`wp-includes/class-wp-customize-widgets.php` |

Calls admin_print_scripts-widgets.php and admin_print_scripts hooks to allow custom scripts from plugins.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/admin_print_scripts/?output_format=md#comment-content-4142)
 2.    [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/admin_print_scripts/#comment-4142)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fadmin_print_scripts%2F%23comment-4142)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fadmin_print_scripts%2F%23comment-4142)
 4.  Migrate from Codex:
 5.  Basic Examples:
 6.      ```php
         function admin_inline_js(){ 
            echo "<script type='text/javascript'>\n";
            echo 'var pluginUrl = ' . wp_json_encode( WP_PLUGIN_URL . '/my_plugin/' ) . ';'; 
            echo "\n</script>"; 
         } 
         add_action( 'admin_print_scripts', 'admin_inline_js' );
         ```
     
 7.  Result:
      <script type=’text/javascript’> var pluginUrl = “http://website.com/wp-
     content/plugins/my_plugin/”; </script>
 8.  Note that we use [wp_json_encode()](https://developer.wordpress.org/reference/functions/wp_json_encode/)
     to prepare the value for pluginURL before embedding it in the JavaScript code.
     It is important to always use [wp_json_encode()](https://developer.wordpress.org/reference/functions/wp_json_encode/)
     when passing values from PHP to JavaScript, to avoid the possibility of XSS security
     vulnerabilities.
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fadmin_print_scripts%2F%3Freplytocom%3D4142%23feedback-editor-4142)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fadmin_print_scripts%2F)
before being able to contribute a note or feedback.