Skip to content

Inline the custom JavaScript using wp_print_inline_script_tag() #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [1.1.6] - 2025-08-11

### Fixed
- Inline the custom javascript using ` ()`
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name appears to be incomplete or corrupted. It should be wp_print_inline_script_tag() instead of just the backticks with a tab character.

Suggested change
- Inline the custom javascript using ` ()`
- Inline the custom javascript using `wp_print_inline_script_tag()`

Copilot uses AI. Check for mistakes.

- Ensure the script is printed in the footer

## [1.1.5] - 2025-07-16

### Fixed
Expand Down
10 changes: 3 additions & 7 deletions additional-javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin URI: https://github.com/soderlind/additional-javascript
* GitHub Plugin URI: https://github.com/soderlind/additional-javascript
* Description: Add additional JavaScript using the WordPress Customizer.
* Version: 1.1.5
* Version: 1.1.6
* Author: Per Soderlind
* Author URI: https://soderlind.no
* Text Domain: additional-javascript
Expand Down Expand Up @@ -44,7 +44,7 @@
);

add_action( 'init', __NAMESPACE__ . '\register_post_type_javascript', 0 );
add_action( 'wp_head', __NAMESPACE__ . '\soderlind_custom_javascript_cb', 110 );
add_action( 'wp_footer', __NAMESPACE__ . '\soderlind_custom_javascript_cb', 110 );
add_action( 'customize_register', __NAMESPACE__ . '\register_additional_javascript' );
add_action( 'customize_preview_init', __NAMESPACE__ . '\customize_preview_additional_javascript' );
add_action( 'customize_controls_enqueue_scripts', __NAMESPACE__ . '\on_customize_controls_enqueue_scripts' );
Expand Down Expand Up @@ -120,11 +120,7 @@ function register_post_type_javascript() {
function soderlind_custom_javascript_cb() {
$javascript = soderlind_get_custom_javascript();
if ( $javascript || is_customize_preview() ) {
?>
<script id="soderlind-custom-javascript">
<?php echo $javascript; ?>
</script>
<?php
wp_print_inline_script_tag( $javascript, [ 'id' => 'soderlind-custom-javascript' ] );
}
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "additional-javascript",
"version": "1.1.5",
"version": "1.1.6",
"description": "Add additional JavaScript using the WordPress Customizer.",
"keywords": [
"wordpress",
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: javascript, customizer, code, custom code, js
Donate link: https://paypal.me/PerSoderlind
Requires at least: 6.5
Tested up to: 6.8
Stable tag: 1.1.5
Stable tag: 1.1.6
Requires PHP: 8.2
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Expand Down Expand Up @@ -62,6 +62,10 @@ The JavaScript is added at the end of the `<head>` section of your site with a p

== Changelog ==

= 1.1.6 =
* Inline the custom javascript using `wp_print_inline_script_tag()`
* Ensure the script is printed in the footer

= 1.1.5 =
* Fixed deprecated PHP string interpolation syntax for PHP 8.2+ compatibility

Expand Down