Skip to content

Commit 4af43ab

Browse files
committed
Add default content
1 parent 7affd63 commit 4af43ab

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

additional-javascript.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Plugin URI: https://github.com/soderlind/additional-javascript
1313
* GitHub Plugin URI: https://github.com/soderlind/additional-javascript
1414
* Description: Add additional JavaScript using the WordPress Customizer.
15-
* Version: 0.0.1
15+
* Version: 1.0.0
1616
* Author: Per Soderlind
1717
* Author URI: https://soderlind.no
1818
* Text Domain: additional-javascript
@@ -31,6 +31,17 @@
3131
add_action( 'customize_preview_init', __NAMESPACE__ . '\customize_preview_additional_javascript' );
3232
add_action( 'customize_controls_enqueue_scripts', __NAMESPACE__ . '\on_customize_controls_enqueue_scripts' );
3333

34+
function default_js_template() {
35+
return <<<EOTEMPLATE
36+
(function( $ ) {
37+
38+
"use strict";
39+
40+
// JavaScript code here.
41+
42+
})(jQuery);
43+
EOTEMPLATE;
44+
}
3445

3546
function register_post_type_javascript() {
3647

@@ -96,7 +107,7 @@ function register_additional_javascript( $wp_customize ) {
96107
$custom_javascript_setting = new Soderlind_Customize_Custom_JavaScript_Setting(
97108
$wp_customize, sprintf( 'custom_javascript[%s]', get_stylesheet() ), array(
98109
'capability' => 'unfiltered_html',
99-
'default' => '',
110+
'default' => default_js_template(),
100111
)
101112
);
102113

assets/additional-javascript.png

53.5 KB
Loading

0 commit comments

Comments
 (0)