Scripts n Styles - Version 3.5

Version Description

  • Fix some functionality for Gutenberg
  • Add arbitrary HTML fields
Download this release

Release Info

Developer WraithKenny
Plugin Icon wp plugin Scripts n Styles
Version 3.5
Comparing to
See all releases

Code changes from version 3.4.5 to 3.5

README.txt CHANGED
@@ -1,13 +1,14 @@
1
  === Scripts n Styles ===
2
  Contributors: WraithKenny, CaptainN
3
  Tags: admin, CSS, javascript, code, custom, Style
4
- Requires at least: 4.9.8
5
- Tested up to: 5.0
6
- Stable tag: 3.4.5
 
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
10
- This plugin allows Admin users to individually add custom CSS, Classes and JavaScript directly to Post, Pages or any other custom post types.
11
 
12
  == Description ==
13
 
@@ -23,11 +24,11 @@ Because only well trusted users should ever be allowed to insert JavaScript dire
23
  * CSS Styles are embeded, not linked, at the bottom of the `head` element with `style` tags by using `wp-head`. If your theme doesn't have this hook, this plugin (as well as most others) won't work.
24
  * JavaScript is embeded, not linked, at the bottom of the `body` (or `head`) element with `script` tags by using `wp-footer` (or `wp-head`). If your theme doesn't have this hook, this plugin (as well as most others) won't work.
25
  * **There is no input validation.** This plugin puts exactly what you type in the meta box directly into the `html` with no error checking. You are an Admin, and we trust you to be carefull. Try not to break anything.
26
- * Do to the licensing of the libraries used, this plugin is released "GPL 3.0 or later" if you care about those things.
27
 
28
  = Contact: =
29
 
30
- You'll have better luck contacting the other if you try me on [Twitter](http://twitter.com/WraithKenny1) and [Github](https://github.com/unFocus/Scripts-n-Styles/issues). If that fails, I have an [open thread](http://wordpress.org/support/topic/contacting-scripts-n-styles-author "Contacting Scripts n Styles' author") on the support forums that will trigger an email.
31
 
32
  == Installation ==
33
 
@@ -58,6 +59,10 @@ Sure, if you are an Admin, just go to the plugin editor and wipe out the uninsta
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 3.4.4 =
62
  * Rename codemirror handle for compatibility
63
 
1
  === Scripts n Styles ===
2
  Contributors: WraithKenny, CaptainN
3
  Tags: admin, CSS, javascript, code, custom, Style
4
+ Requires at least: 5.0
5
+ Tested up to: 5.0.2
6
+ Requires PHP: 5.4
7
+ Stable tag: 3.5
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
+ This plugin allows Admin users to individually add HTML, custom CSS, Classes and JavaScript directly to Post, Pages or any other custom post types.
12
 
13
  == Description ==
14
 
24
  * CSS Styles are embeded, not linked, at the bottom of the `head` element with `style` tags by using `wp-head`. If your theme doesn't have this hook, this plugin (as well as most others) won't work.
25
  * JavaScript is embeded, not linked, at the bottom of the `body` (or `head`) element with `script` tags by using `wp-footer` (or `wp-head`). If your theme doesn't have this hook, this plugin (as well as most others) won't work.
26
  * **There is no input validation.** This plugin puts exactly what you type in the meta box directly into the `html` with no error checking. You are an Admin, and we trust you to be carefull. Try not to break anything.
27
+ * Do to the licensing of the libraries used, this plugin is released "GPL 3.0 or later" if you care about those things.
28
 
29
  = Contact: =
30
 
31
+ You'll have better luck contacting me if you try me on [Twitter](http://twitter.com/WraithKenny1) and [Github](https://github.com/unFocus/Scripts-n-Styles/issues). I also have a day job at [Ashworth Creative](https://ashworthcreative.com/); check us out!
32
 
33
  == Installation ==
34
 
59
 
60
  == Changelog ==
61
 
62
+ = 3.5 =
63
+ * Fix some functionality for Gutenberg
64
+ * Add arbitrary HTML fields
65
+
66
  = 3.4.4 =
67
  * Rename codemirror handle for compatibility
68
 
css/meta-box.css CHANGED
@@ -2,7 +2,7 @@
2
  .CodeMirror{height:200px;border:1px solid #DFDFDF;}
3
  .autoheight .CodeMirror{height:auto;}
4
  .autoheight .CodeMirror-scroll{overflow-x:auto;overflow-y:hidden;}
5
- .style,.script,.less,.coffee{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background-color:white;margin:8px 0;background-clip:padding-box;font-family:"Courier New",Courier,monospace;}.style:before,.script:before,.less:before,.coffee:before,.style:after,.script:after,.less:after,.coffee:after{border:1px solid #dfdfdf;position:relative;z-index:3;display:block;padding:.5em;background-color:#f5f5f5;color:#333;font-family:"Courier New",Courier,monospace;line-height:1em;text-shadow:none;}
6
  .style:before,.script:before,.less:before,.coffee:before{border-bottom:0 none;border-radius:5px 5px 0px 0px;}
7
  .style:after,.script:after,.less:after,.coffee:after{border-top:0 none;border-radius:0px 0px 5px 5px;}
8
  .style:before{content:'<style type="text/css">';}
2
  .CodeMirror{height:200px;border:1px solid #DFDFDF;}
3
  .autoheight .CodeMirror{height:auto;}
4
  .autoheight .CodeMirror-scroll{overflow-x:auto;overflow-y:hidden;}
5
+ .style,.script,.less,.coffee{background-color:white;margin:8px 0;background-clip:padding-box;font-family:"Courier New",Courier,monospace;}.style:before,.script:before,.less:before,.coffee:before,.style:after,.script:after,.less:after,.coffee:after{border:1px solid #dfdfdf;position:relative;z-index:3;display:block;padding:.5em;background-color:#f5f5f5;color:#333;font-family:"Courier New",Courier,monospace;line-height:1em;text-shadow:none;}
6
  .style:before,.script:before,.less:before,.coffee:before{border-bottom:0 none;border-radius:5px 5px 0px 0px;}
7
  .style:after,.script:after,.less:after,.coffee:after{border-top:0 none;border-radius:0px 0px 5px 5px;}
8
  .style:before{content:'<style type="text/css">';}
includes/class-sns-ajax.php CHANGED
@@ -6,11 +6,13 @@ class SnS_AJAX
6
  add_action( 'wp_ajax_sns_update_tab', array( __CLASS__, 'update_tab' ) );
7
  // TinyMCE requests a css file.
8
  add_action( 'wp_ajax_sns_tinymce_styles', array( __CLASS__, 'tinymce_styles' ) );
 
9
 
10
  // Ajax Saves.
11
  add_action( 'wp_ajax_sns_classes', array( __CLASS__, 'classes' ) );
12
  add_action( 'wp_ajax_sns_scripts', array( __CLASS__, 'scripts' ) );
13
  add_action( 'wp_ajax_sns_styles', array( __CLASS__, 'styles' ) );
 
14
  add_action( 'wp_ajax_sns_dropdown', array( __CLASS__, 'dropdown' ) );
15
  add_action( 'wp_ajax_sns_delete_class', array( __CLASS__, 'delete_class' ) );
16
  add_action( 'wp_ajax_sns_shortcodes', array( __CLASS__, 'shortcodes' ) );
@@ -118,8 +120,6 @@ class SnS_AJAX
118
  exit();
119
  }
120
  static function tinymce_styles() {
121
- check_ajax_referer( 'sns_tinymce_styles' );
122
-
123
  if ( empty( $_REQUEST[ 'post_id' ] ) ) exit( 'Bad post ID.' );
124
  $post_id = absint( $_REQUEST[ 'post_id' ] );
125
 
@@ -200,6 +200,37 @@ class SnS_AJAX
200
 
201
  exit();
202
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  static function styles() {
204
  check_ajax_referer( Scripts_n_Styles::$file );
205
  if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) exit( 'Insufficient Privileges.' );
@@ -418,4 +449,4 @@ class SnS_AJAX
418
  update_post_meta( $id, $name, $meta );
419
  }
420
  }
421
- }
6
  add_action( 'wp_ajax_sns_update_tab', array( __CLASS__, 'update_tab' ) );
7
  // TinyMCE requests a css file.
8
  add_action( 'wp_ajax_sns_tinymce_styles', array( __CLASS__, 'tinymce_styles' ) );
9
+ add_action( 'wp_ajax_nopriv_sns_tinymce_styles', array( __CLASS__, 'tinymce_styles' ) );
10
 
11
  // Ajax Saves.
12
  add_action( 'wp_ajax_sns_classes', array( __CLASS__, 'classes' ) );
13
  add_action( 'wp_ajax_sns_scripts', array( __CLASS__, 'scripts' ) );
14
  add_action( 'wp_ajax_sns_styles', array( __CLASS__, 'styles' ) );
15
+ add_action( 'wp_ajax_sns_html', array( __CLASS__, 'html' ) );
16
  add_action( 'wp_ajax_sns_dropdown', array( __CLASS__, 'dropdown' ) );
17
  add_action( 'wp_ajax_sns_delete_class', array( __CLASS__, 'delete_class' ) );
18
  add_action( 'wp_ajax_sns_shortcodes', array( __CLASS__, 'shortcodes' ) );
120
  exit();
121
  }
122
  static function tinymce_styles() {
 
 
123
  if ( empty( $_REQUEST[ 'post_id' ] ) ) exit( 'Bad post ID.' );
124
  $post_id = absint( $_REQUEST[ 'post_id' ] );
125
 
200
 
201
  exit();
202
  }
203
+ static function html() {
204
+ check_ajax_referer( Scripts_n_Styles::$file );
205
+ if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) exit( 'Insufficient Privileges.' );
206
+
207
+ if ( empty( $_REQUEST[ 'post_id' ] ) ) exit( 'Bad post ID.' );
208
+ if ( ! isset( $_REQUEST[ 'html_in_footer' ], $_REQUEST[ 'html_in_head' ] ) ) exit( 'Data incorrectly sent.' );
209
+
210
+ $post_id = absint( $_REQUEST[ 'post_id' ] );
211
+ $SnS = get_post_meta( $post_id, '_SnS', true );
212
+ $SnS = is_array( $SnS ) ? $SnS: array();
213
+ $html = isset( $SnS['html'] ) ? $SnS[ 'html' ]: array();
214
+
215
+ $html = self::maybe_set( $html, 'html_in_head' );
216
+ $html = self::maybe_set( $html, 'html_in_footer' );
217
+
218
+ if ( empty( $html ) ) {
219
+ if ( isset( $SnS['html'] ) )
220
+ unset( $SnS['html'] );
221
+ } else {
222
+ $SnS[ 'html' ] = $html;
223
+ }
224
+ self::maybe_update( $post_id, '_SnS', $SnS );
225
+
226
+ header('Content-Type: application/json; charset=UTF-8');
227
+ echo json_encode( array(
228
+ "html_in_footer" => $_REQUEST[ 'html_in_footer' ]
229
+ , "html_in_head" => $_REQUEST[ 'html_in_head' ]
230
+ ) );
231
+
232
+ exit();
233
+ }
234
  static function styles() {
235
  check_ajax_referer( Scripts_n_Styles::$file );
236
  if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) exit( 'Insufficient Privileges.' );
449
  update_post_meta( $id, $name, $meta );
450
  }
451
  }
452
+ }
includes/class-sns-global-page.php CHANGED
@@ -45,6 +45,12 @@ class SnS_Global_Page
45
  SnS_Admin::OPTION_GROUP,
46
  'SnS_options' );
47
 
 
 
 
 
 
 
48
  add_settings_section(
49
  'global_styles',
50
  __( 'Blog Wide CSS Styles', 'scripts-n-styles' ),
@@ -71,6 +77,38 @@ class SnS_Global_Page
71
  SnS_Admin::MENU_SLUG,
72
  'global_scripts',
73
  array( 'label_for' => 'coffee' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  add_settings_field(
75
  'styles',
76
  __( '<strong>CSS Styles:</strong> ', 'scripts-n-styles' ),
@@ -198,4 +236,17 @@ class SnS_Global_Page
198
  </div>
199
  <?php
200
  }
201
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  SnS_Admin::OPTION_GROUP,
46
  'SnS_options' );
47
 
48
+ add_settings_section(
49
+ 'global_html',
50
+ __( 'Blog Wide HTML', 'scripts-n-styles' ),
51
+ array( __CLASS__, 'global_html_section' ),
52
+ SnS_Admin::MENU_SLUG );
53
+
54
  add_settings_section(
55
  'global_styles',
56
  __( 'Blog Wide CSS Styles', 'scripts-n-styles' ),
77
  SnS_Admin::MENU_SLUG,
78
  'global_scripts',
79
  array( 'label_for' => 'coffee' ) );
80
+ add_settings_field(
81
+ 'html_in_head',
82
+ __( '<strong>HTML<br>(<code>head</code> tag):</strong> ', 'scripts-n-styles' ),
83
+ array( 'SnS_Form', 'textarea' ),
84
+ SnS_Admin::MENU_SLUG,
85
+ 'global_html',
86
+ array(
87
+ 'label_for' => 'html_in_head',
88
+ 'setting' => 'SnS_options',
89
+ 'class' => 'code html',
90
+ 'wrap_class' => 'html',
91
+ 'rows' => 5,
92
+ 'cols' => 40,
93
+ 'style' => 'min-width: 500px; width:97%;',
94
+ 'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">The HTML will be included in <code>&lt;head></code> element of your pages.</span>', 'scripts-n-styles' )
95
+ ) );
96
+ add_settings_field(
97
+ 'html_in_footer',
98
+ __( '<strong>HTML<br>(end of the <code>body</code> tag):</strong> ', 'scripts-n-styles' ),
99
+ array( 'SnS_Form', 'textarea' ),
100
+ SnS_Admin::MENU_SLUG,
101
+ 'global_html',
102
+ array(
103
+ 'label_for' => 'html_in_footer',
104
+ 'setting' => 'SnS_options',
105
+ 'class' => 'code html',
106
+ 'wrap_class' => 'html',
107
+ 'rows' => 5,
108
+ 'cols' => 40,
109
+ 'style' => 'min-width: 500px; width:97%;',
110
+ 'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">The HTML will be included at the bottom of the <code>&lt;body></code> element of your pages.</span>', 'scripts-n-styles' )
111
+ ) );
112
  add_settings_field(
113
  'styles',
114
  __( '<strong>CSS Styles:</strong> ', 'scripts-n-styles' ),
236
  </div>
237
  <?php
238
  }
239
+
240
+ /**
241
+ * Settings Page
242
+ * Outputs Description text for the Global Section.
243
+ */
244
+ static function global_html_section() {
245
+ ?>
246
+ <div style="max-width: 55em;">
247
+ <p><?php _e( 'HTML entered here will be included in <em>every page (and post) of your site</em>, including the homepage and archives. The code will appear <strong>before</strong> HTML added to individual posts and pages.', 'scripts-n-styles' )?></p>
248
+ <p><?php _e( 'You can place <strong>any</strong> HTML here. In the <code>head</code> tag, please stick to appropriate elements, like <code>script</code>, <code>style</code>, <code>link</code>, and <code>meta</code> html tags.' ); ?></p>
249
+ </div>
250
+ <?php
251
+ }
252
+ }
includes/class-sns-meta-box.php CHANGED
@@ -75,12 +75,12 @@ class SnS_Admin_Meta_Box
75
  * Adds a styles sheet to TinyMCE via ajax that contains the current styles data.
76
  */
77
  static function mce_css( $mce_css ) {
78
- global $post;
79
  $url = admin_url( 'admin-ajax.php' );
80
  $url = wp_nonce_url( $url, 'sns_tinymce_styles' );
81
- $url = add_query_arg( 'post_id', $post->ID, $url );
82
  $url = add_query_arg( 'action', 'sns_tinymce_styles', $url );
83
- $mce_css .= ',' . $url;
 
84
  return $mce_css;
85
  }
86
 
@@ -99,7 +99,7 @@ class SnS_Admin_Meta_Box
99
  add_filter( 'contextual_help', array( 'SnS_Admin', 'help' ) );
100
  add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
101
  add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ) );
102
- add_filter( 'mce_css', array( __CLASS__, 'mce_css' ) );
103
  }
104
  }
105
  }
@@ -124,9 +124,10 @@ class SnS_Admin_Meta_Box
124
  $SnS = is_array( $SnS ) ? $SnS: array();
125
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
126
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
 
127
 
128
  $position = get_user_option( "current_sns_tab" );
129
- if ( ! in_array( $position, array( 's0', 's1', 's2', 's3', 's4', 's5' ) ) ) $position = 's0';
130
  wp_nonce_field( Scripts_n_Styles::$file, self::NONCE_NAME );
131
  ?>
132
  <ul class="wp-tab-bar">
@@ -136,6 +137,7 @@ class SnS_Admin_Meta_Box
136
  <li<?php echo ( 's3' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_enqueue_scripts-tab"><?php _e( 'Include Scripts', 'scripts-n-styles' ) ?></a></li>
137
  <li<?php echo ( 's4' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_shortcodes-tab"><?php _e( 'Shortcodes', 'scripts-n-styles' ) ?></a></li>
138
  <li<?php echo ( 's5' == $position ) ? ' class="wp-tab-active"': ''; ?> style="display:none"><a href="#SnS_post_styles-tab"><?php _e( 'Dropdown', 'scripts-n-styles' ) ?></a></li>
 
139
  </ul>
140
 
141
  <div class="wp-tab-panel" id="SnS_scripts-tab">
@@ -271,6 +273,20 @@ class SnS_Admin_Meta_Box
271
  </div>
272
  </div>
273
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  <?php
275
  }
276
 
@@ -340,6 +356,7 @@ class SnS_Admin_Meta_Box
340
  $SnS = is_array( $SnS ) ? $SnS: array(); // automatic array conversion became an error in PHP 7.1
341
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
342
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
 
343
 
344
  $scripts = self::maybe_set( $scripts, 'scripts_in_head' );
345
  $scripts = self::maybe_set( $scripts, 'scripts' );
@@ -347,6 +364,8 @@ class SnS_Admin_Meta_Box
347
  $styles = self::maybe_set( $styles, 'styles' );
348
  $styles = self::maybe_set( $styles, 'classes_body' );
349
  $styles = self::maybe_set( $styles, 'classes_post' );
 
 
350
 
351
  $shortcodes = array();
352
  $SnS_shortcodes = isset( $_REQUEST[ 'SnS_shortcodes' ] ) ? $_REQUEST[ 'SnS_shortcodes' ]: array();
@@ -396,6 +415,13 @@ class SnS_Admin_Meta_Box
396
  $SnS['styles'] = $styles;
397
  }
398
 
 
 
 
 
 
 
 
399
  if ( empty( $shortcodes ) ) {
400
  if ( isset( $SnS['shortcodes'] ) )
401
  unset( $SnS['shortcodes'] );
75
  * Adds a styles sheet to TinyMCE via ajax that contains the current styles data.
76
  */
77
  static function mce_css( $mce_css ) {
 
78
  $url = admin_url( 'admin-ajax.php' );
79
  $url = wp_nonce_url( $url, 'sns_tinymce_styles' );
80
+ $url = add_query_arg( 'post_id', get_the_ID(), $url );
81
  $url = add_query_arg( 'action', 'sns_tinymce_styles', $url );
82
+ add_theme_support( 'editor-styles' );
83
+ add_editor_style( $url );
84
  return $mce_css;
85
  }
86
 
99
  add_filter( 'contextual_help', array( 'SnS_Admin', 'help' ) );
100
  add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
101
  add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ) );
102
+ add_filter( 'replace_editor', array( __CLASS__, 'mce_css' ) );
103
  }
104
  }
105
  }
124
  $SnS = is_array( $SnS ) ? $SnS: array();
125
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
126
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
127
+ $html = isset( $SnS['html'] ) ? $SnS[ 'html' ]: array();
128
 
129
  $position = get_user_option( "current_sns_tab" );
130
+ if ( ! in_array( $position, array( 's0', 's1', 's2', 's3', 's4', 's5', 's6' ) ) ) $position = 's0';
131
  wp_nonce_field( Scripts_n_Styles::$file, self::NONCE_NAME );
132
  ?>
133
  <ul class="wp-tab-bar">
137
  <li<?php echo ( 's3' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_enqueue_scripts-tab"><?php _e( 'Include Scripts', 'scripts-n-styles' ) ?></a></li>
138
  <li<?php echo ( 's4' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_shortcodes-tab"><?php _e( 'Shortcodes', 'scripts-n-styles' ) ?></a></li>
139
  <li<?php echo ( 's5' == $position ) ? ' class="wp-tab-active"': ''; ?> style="display:none"><a href="#SnS_post_styles-tab"><?php _e( 'Dropdown', 'scripts-n-styles' ) ?></a></li>
140
+ <li<?php echo ( 's6' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_html-tab"><?php _e( 'HTML', 'scripts-n-styles' ) ?></a></li>
141
  </ul>
142
 
143
  <div class="wp-tab-panel" id="SnS_scripts-tab">
273
  </div>
274
  </div>
275
  </div>
276
+
277
+ <div class="wp-tab-panel" id="SnS_html-tab">
278
+ <p><em><?php _e( "<strong>HTML</strong> for the <code>head</code> element", 'scripts-n-styles' ) ?> ...</em></p>
279
+ <label for="SnS_html_in_head" class="title"><?php _e( '<strong>HTML</strong> (for the <code>head</code> element):', 'scripts-n-styles' ) ?> </label>
280
+ <div class="html">
281
+ <textarea class="codemirror html" name="SnS_html_in_head" id="SnS_html_in_head" rows="5" cols="40" style="width: 98%;"><?php echo isset( $html[ 'html_in_head' ] ) ? esc_textarea( $html[ 'html_in_head' ] ) : ''; ?></textarea>
282
+ </div>
283
+ <p>&nbsp;</p>
284
+ <p><em><?php _e( "<strong>HTML</strong> for the <code>bottom of the body</code> element", 'scripts-n-styles' ) ?> ...</em></p>
285
+ <label for="SnS_html_in_footer" class="title"><strong><?php _e( '<strong>HTML</strong> (for the <code>bottom of the body</code>):', 'scripts-n-styles' ) ?></strong>: </label>
286
+ <div class="html">
287
+ <textarea class="codemirror html" name="SnS_html_in_footer" id="SnS_html_in_footer" rows="5" cols="40" style="width: 98%;"><?php echo isset( $html[ 'html_in_footer' ] ) ? esc_textarea( $html[ 'html_in_footer' ] ) : ''; ?></textarea>
288
+ </div>
289
+ </div>
290
  <?php
291
  }
292
 
356
  $SnS = is_array( $SnS ) ? $SnS: array(); // automatic array conversion became an error in PHP 7.1
357
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
358
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
359
+ $html = isset( $SnS['html'] ) ? $SnS[ 'html' ]: array();
360
 
361
  $scripts = self::maybe_set( $scripts, 'scripts_in_head' );
362
  $scripts = self::maybe_set( $scripts, 'scripts' );
364
  $styles = self::maybe_set( $styles, 'styles' );
365
  $styles = self::maybe_set( $styles, 'classes_body' );
366
  $styles = self::maybe_set( $styles, 'classes_post' );
367
+ $html = self::maybe_set( $html, 'html_in_head' );
368
+ $html = self::maybe_set( $html, 'html_in_footer' );
369
 
370
  $shortcodes = array();
371
  $SnS_shortcodes = isset( $_REQUEST[ 'SnS_shortcodes' ] ) ? $_REQUEST[ 'SnS_shortcodes' ]: array();
415
  $SnS['styles'] = $styles;
416
  }
417
 
418
+ if ( empty( $html ) ) {
419
+ if ( isset( $SnS['html'] ) )
420
+ unset( $SnS['html'] );
421
+ } else {
422
+ $SnS['html'] = $html;
423
+ }
424
+
425
  if ( empty( $shortcodes ) ) {
426
  if ( isset( $SnS['shortcodes'] ) )
427
  unset( $SnS['shortcodes'] );
js/global-page.js CHANGED
@@ -24,6 +24,10 @@ jQuery( document ).ready( function( $ ) {
24
  CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "css", theme: theme } );
25
  });
26
 
 
 
 
 
27
  lessOutput = CodeMirror.fromTextArea( $( '#compiled' ).get(0), { lineNumbers: true, mode: "css", theme: theme, readOnly: true } );
28
  coffeeOutput = CodeMirror.fromTextArea( $( '#coffee_compiled' ).get(0), { lineNumbers: true, mode: "javascript", theme: theme, readOnly: true } );
29
 
24
  CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "css", theme: theme } );
25
  });
26
 
27
+ $( "textarea.html" ).each( function() {
28
+ CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "text/html", theme: theme } );
29
+ });
30
+
31
  lessOutput = CodeMirror.fromTextArea( $( '#compiled' ).get(0), { lineNumbers: true, mode: "css", theme: theme, readOnly: true } );
32
  coffeeOutput = CodeMirror.fromTextArea( $( '#coffee_compiled' ).get(0), { lineNumbers: true, mode: "javascript", theme: theme, readOnly: true } );
33
 
js/meta-box.js CHANGED
@@ -2,9 +2,14 @@ jQuery( document ).ready( function( $ ) {
2
 
3
  var context = '#SnS_meta_box',
4
  currentCodeMirror = [], keys = [],
 
5
  nonce = $( '#scripts_n_styles_noncename' ).val(),
6
  theme = codemirror_options.theme ? codemirror_options.theme: 'default';
7
 
 
 
 
 
8
  // For CPTs that don't have an editor, prevent "tinyMCEPreInit is 'undefined'"
9
  var initDatas = ( typeof tinyMCEPreInit !== 'undefined' && tinyMCEPreInit.mceInit ) ? tinyMCEPreInit.mceInit: false;
10
  for ( var prop in initDatas ) {
@@ -34,7 +39,20 @@ jQuery( document ).ready( function( $ ) {
34
 
35
  refreshDeleteBtns();
36
 
37
-
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  $('#sns-ajax-update-scripts').click(function( event ){
40
  event.preventDefault();
@@ -49,6 +67,19 @@ jQuery( document ).ready( function( $ ) {
49
  $.post( ajaxurl, args, function() { refreshMCE(); } );
50
  });
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  $('#sns-ajax-update-styles').click(function( event ){
53
  event.preventDefault();
54
  $(this).next().show();
@@ -192,30 +223,40 @@ jQuery( document ).ready( function( $ ) {
192
  * Returns the body_class of TinyMCE minus the Scripts n Styles values.
193
  */
194
  function getMCEBodyClasses() {
195
- var t = [], a = [];
196
- $(keys).each(function(index, element) {
 
 
 
 
 
 
197
  var data = initDatas[element];
198
- if ( data.body_class )
199
- t = data.body_class.split(' ');
 
200
 
201
- var bc = $('#SnS_classes_body').val().split(' ');
202
- var pc = $('#SnS_classes_post').val().split(' ');
203
- var p;
204
  for ( var i = 0; i < t.length; i++ ) {
205
- p = $.inArray( bc[i], t )
206
- if ( -1 != p )
207
  t.splice( p, 1 );
 
208
  }
209
  for ( var i = 0; i < t.length; i++ ) {
210
- p = $.inArray( pc[i], t )
211
- if ( -1 != p )
212
  t.splice( p, 1 );
 
213
  }
214
- t = t.join(' ');
215
 
216
  a[element] = t;
217
  });
218
- return a;
 
219
  }
220
 
221
  /*
@@ -231,6 +272,14 @@ jQuery( document ).ready( function( $ ) {
231
  + '</div>'
232
  );
233
 
 
 
 
 
 
 
 
 
234
  $('#SnS_styles-tab').append(
235
  '<div class="sns-ajax-wrap">'
236
  + '<a id="sns-ajax-update-styles" href="#" class="button">Update Styles</a>'
@@ -352,6 +401,15 @@ jQuery( document ).ready( function( $ ) {
352
  indentUnit: 4,
353
  indentWithTabs: true
354
  };
 
 
 
 
 
 
 
 
 
355
  else if ( $(this).hasClass( 'css' ) )
356
  settings = {
357
  mode: "text/css",
@@ -403,47 +461,57 @@ jQuery( document ).ready( function( $ ) {
403
  * Refresh after AJAX.
404
  */
405
  function refreshDeleteBtns() {
 
 
 
 
 
406
  $(keys).each(function(index, key) {
407
  var initData = initDatas[key]
408
-
409
- // responsible for clearing out Delete Buttons, and Adding new ones.
410
- // initData should always contain the latest settings.
411
  if ( initData.style_formats && initData.style_formats.length ) {
412
- $( '#delete-mce-dropdown-names .sns-ajax-delete-p' ).remove();
413
- $( '#delete-mce-dropdown-names', context ).show();
414
- var formats = initData.style_formats;
415
- for ( var i = 0; i < formats.length; i++ ) {
416
- var deleteBtn = {};
417
- if ( formats[i].inline ) {
418
- deleteBtn.element = formats[i].inline;
419
- deleteBtn.wrapper = '';
420
- } else if ( formats[i].block ) {
421
- deleteBtn.element = formats[i].block;
422
- if ( formats[i].wrapper )
423
- deleteBtn.wrapper = ' (wrapper)';
424
- else
425
- deleteBtn.wrapper = '';
426
- } else if ( formats[i].selector ) {
427
- deleteBtn.element = formats[i].selector;
428
- deleteBtn.wrapper = '';
429
- } else {
430
- console.log( 'ERROR!' );
431
- }
432
- deleteBtn.title = formats[i].title;
433
- deleteBtn.classes = formats[i].classes;
434
- $( '#instructions-mce-dropdown-names', context ).after(
435
- '<p class="sns-ajax-delete-p"><a title="delete" class="sns-ajax-delete" id="'
436
- + deleteBtn.title + '">X</a> "'
437
- + deleteBtn.title + '" <code>&lt;'
438
- + deleteBtn.element + ' class="'
439
- + deleteBtn.classes + '"&gt;</code>'
440
- + deleteBtn.wrapper + '</p>'
441
- );
442
- }
443
- } else {
444
- $( '#delete-mce-dropdown-names', context ).hide();
445
  }
446
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  }
448
  function refreshBodyClass( data ) {
449
  $(keys).each(function(index, key) {
@@ -452,50 +520,58 @@ jQuery( document ).ready( function( $ ) {
452
  refreshMCE();
453
  }
454
  function refreshStyleFormats( data ) {
 
455
  $(keys).each(function(index, key) {
456
- var initData = initDatas[key]
457
- // error check
458
- //console.log(data.classes_mce);
459
- if ( typeof data.classes_mce === 'undefined' ) {
460
- console.log( data );
461
- /*$( '.sns-ajax-loading' ).hide();
462
- return;*/ // Don't block
463
- } else if ( data.classes_mce.length && data.classes_mce != 'Empty' ) {
464
- var style_formats = [];
465
-
466
- for ( var i = 0; i < data.classes_mce.length; i++ ) { // loop returned classes_mce
467
- var format = {};
468
- format.title = data.classes_mce[i].title;
469
-
470
- if ( data.classes_mce[i].inline )
471
- format.inline = data.classes_mce[i].inline;
472
- else if ( data.classes_mce[i].block ) {
473
- format.block = data.classes_mce[i].block;
474
- if (data.classes_mce[i].wrapper)
475
- format.wrapper = true;
476
- } else if ( data.classes_mce[i].selector )
477
- format.selector = data.classes_mce[i].selector;
478
- else
479
- console.log('dropdown format has bad type.');
480
-
481
- format.classes = data.classes_mce[i].classes;
482
- style_formats.push( format );
483
- }
484
- initData.style_formats = style_formats;
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  if ( initData.toolbar2.indexOf( "styleselect" ) == -1 ) {
487
  var tempString = "styleselect,";
488
  initData.toolbar2 = tempString.concat(initData.toolbar2);
489
  }
 
490
 
491
- $( '#delete-mce-dropdown-names', context ).show();
492
- } else {
 
493
  delete initData.style_formats;
494
  initData.toolbar2 = initData.toolbar2.replace("styleselect,", "");
495
-
496
- $( '#delete-mce-dropdown-names', context ).hide();
497
  }
498
- });
 
 
499
  refreshDeleteBtns();
500
  refreshMCE();
501
  }
@@ -575,6 +651,9 @@ jQuery( document ).ready( function( $ ) {
575
  $( '.sns-ajax-loading' ).hide();
576
  }
577
  function refreshMCEhelper( ed ) {
 
 
 
578
  ed.save();
579
  ed.destroy();
580
  ed.remove();
@@ -584,5 +663,4 @@ jQuery( document ).ready( function( $ ) {
584
  ed.render();
585
  ed.hide();
586
  }
587
-
588
  });
2
 
3
  var context = '#SnS_meta_box',
4
  currentCodeMirror = [], keys = [],
5
+ gutenMCE = false,
6
  nonce = $( '#scripts_n_styles_noncename' ).val(),
7
  theme = codemirror_options.theme ? codemirror_options.theme: 'default';
8
 
9
+ if ( window.wpEditorL10n && wpEditorL10n.tinymce && wpEditorL10n.tinymce.settings ) {
10
+ gutenMCE = wpEditorL10n.tinymce.settings;
11
+ }
12
+
13
  // For CPTs that don't have an editor, prevent "tinyMCEPreInit is 'undefined'"
14
  var initDatas = ( typeof tinyMCEPreInit !== 'undefined' && tinyMCEPreInit.mceInit ) ? tinyMCEPreInit.mceInit: false;
15
  for ( var prop in initDatas ) {
39
 
40
  refreshDeleteBtns();
41
 
42
+ if ( wp.data && wp.data.select ) {
43
+ var editPost = wp.data.select( 'core/edit-post' );
44
+ wp.data.subscribe( function() {
45
+ if ( editPost.isSavingMetaBoxes() ) {
46
+ $( currentCodeMirror ).each( function() {
47
+ this.save();
48
+ });
49
+ } else {
50
+ $( currentCodeMirror ).each( function() {
51
+ this.refresh();
52
+ });
53
+ }
54
+ });
55
+ }
56
 
57
  $('#sns-ajax-update-scripts').click(function( event ){
58
  event.preventDefault();
67
  $.post( ajaxurl, args, function() { refreshMCE(); } );
68
  });
69
 
70
+ $('#sns-ajax-update-html').click(function( event ){
71
+ event.preventDefault();
72
+ $(this).next().show();
73
+ $(currentCodeMirror).each(function (){ this.save(); });
74
+ var args = { _ajax_nonce: nonce, post_id: $( '#post_ID' ).val(), };
75
+
76
+ args.action = 'sns_html';
77
+ args.html_in_footer = $( '#SnS_html_in_footer' ).val();
78
+ args.html_in_head = $( '#SnS_html_in_head' ).val();
79
+
80
+ $.post( ajaxurl, args, function(res) { console.log('post sent'); refreshMCE(); } );
81
+ });
82
+
83
  $('#sns-ajax-update-styles').click(function( event ){
84
  event.preventDefault();
85
  $(this).next().show();
223
  * Returns the body_class of TinyMCE minus the Scripts n Styles values.
224
  */
225
  function getMCEBodyClasses() {
226
+ var t = [],
227
+ a = [],
228
+ b = [],
229
+ c = [];
230
+ if ( gutenMCE.body_class ) {
231
+ b = gutenMCE.body_class.trim().split( ' ' );
232
+ }
233
+ $( keys ).each( function( index, element ) {
234
  var data = initDatas[element];
235
+ if ( data.body_class ) {
236
+ t = data.body_class.split( ' ' );
237
+ }
238
 
239
+ var bc = $( '#SnS_classes_body' ).val().split( ' ' ),
240
+ pc = $( '#SnS_classes_post' ).val().split( ' ' ),
241
+ p;
242
  for ( var i = 0; i < t.length; i++ ) {
243
+ p = $.inArray( bc[i], t );
244
+ if ( -1 != p ) {
245
  t.splice( p, 1 );
246
+ }
247
  }
248
  for ( var i = 0; i < t.length; i++ ) {
249
+ p = $.inArray( pc[i], t );
250
+ if ( -1 != p ) {
251
  t.splice( p, 1 );
252
+ }
253
  }
254
+ t = t.join( ' ' );
255
 
256
  a[element] = t;
257
  });
258
+ c = a.concat( b );
259
+ return c;
260
  }
261
 
262
  /*
272
  + '</div>'
273
  );
274
 
275
+ $('#SnS_html-tab').append(
276
+ '<div class="sns-ajax-wrap">'
277
+ + '<a id="sns-ajax-update-html" href="#" class="button">Update HTML</a>'
278
+ + ' '
279
+ + '<span class="sns-ajax-loading"><span class="spinner" style="display: inline-block;"></span></span>'
280
+ + '</div>'
281
+ );
282
+
283
  $('#SnS_styles-tab').append(
284
  '<div class="sns-ajax-wrap">'
285
  + '<a id="sns-ajax-update-styles" href="#" class="button">Update Styles</a>'
401
  indentUnit: 4,
402
  indentWithTabs: true
403
  };
404
+ else if ( $(this).hasClass( 'html' ) )
405
+ settings = {
406
+ mode: "text/html",
407
+ theme: theme,
408
+ lineNumbers: true,
409
+ tabMode: "shift",
410
+ indentUnit: 4,
411
+ indentWithTabs: true
412
+ };
413
  else if ( $(this).hasClass( 'css' ) )
414
  settings = {
415
  mode: "text/css",
461
  * Refresh after AJAX.
462
  */
463
  function refreshDeleteBtns() {
464
+
465
+ // responsible for clearing out Delete Buttons, and Adding new ones.
466
+ // initData should always contain the latest settings.
467
+ var formats = [];
468
+
469
  $(keys).each(function(index, key) {
470
  var initData = initDatas[key]
 
 
 
471
  if ( initData.style_formats && initData.style_formats.length ) {
472
+ formats = initData.style_formats;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  }
474
  });
475
+ if ( gutenMCE.style_formats && gutenMCE.style_formats.length ) {
476
+ formats = gutenMCE.style_formats;
477
+ }
478
+
479
+ if ( ! formats.length ) {
480
+ $( '#delete-mce-dropdown-names', context ).hide();
481
+ return;
482
+ }
483
+
484
+ $( '#delete-mce-dropdown-names .sns-ajax-delete-p' ).remove();
485
+ $( '#delete-mce-dropdown-names', context ).show();
486
+
487
+ for ( var i = 0; i < formats.length; i++ ) {
488
+ var deleteBtn = {};
489
+ if ( formats[i].inline ) {
490
+ deleteBtn.element = formats[i].inline;
491
+ deleteBtn.wrapper = '';
492
+ } else if ( formats[i].block ) {
493
+ deleteBtn.element = formats[i].block;
494
+ if ( formats[i].wrapper )
495
+ deleteBtn.wrapper = ' (wrapper)';
496
+ else
497
+ deleteBtn.wrapper = '';
498
+ } else if ( formats[i].selector ) {
499
+ deleteBtn.element = formats[i].selector;
500
+ deleteBtn.wrapper = '';
501
+ } else {
502
+ console.log( 'ERROR!' );
503
+ }
504
+ deleteBtn.title = formats[i].title;
505
+ deleteBtn.classes = formats[i].classes;
506
+ $( '#instructions-mce-dropdown-names', context ).after(
507
+ '<p class="sns-ajax-delete-p"><a title="delete" class="sns-ajax-delete" id="'
508
+ + deleteBtn.title + '">X</a> "'
509
+ + deleteBtn.title + '" <code>&lt;'
510
+ + deleteBtn.element + ' class="'
511
+ + deleteBtn.classes + '"&gt;</code>'
512
+ + deleteBtn.wrapper + '</p>'
513
+ );
514
+ }
515
  }
516
  function refreshBodyClass( data ) {
517
  $(keys).each(function(index, key) {
520
  refreshMCE();
521
  }
522
  function refreshStyleFormats( data ) {
523
+ var initData = false;
524
  $(keys).each(function(index, key) {
525
+ initData = initDatas[key];
526
+ });
527
+ if ( ! initData && gutenMCE ) {
528
+ initData = gutenMCE;
529
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
+ // error check
532
+ //console.log(data.classes_mce);
533
+ if ( typeof data.classes_mce === 'undefined' ) {
534
+ console.log( data );
535
+ /*$( '.sns-ajax-loading' ).hide();
536
+ return;*/ // Don't block
537
+ } else if ( data.classes_mce.length && data.classes_mce != 'Empty' ) {
538
+ var style_formats = [];
539
+
540
+ for ( var i = 0; i < data.classes_mce.length; i++ ) { // loop returned classes_mce
541
+ var format = {};
542
+ format.title = data.classes_mce[i].title;
543
+
544
+ if ( data.classes_mce[i].inline )
545
+ format.inline = data.classes_mce[i].inline;
546
+ else if ( data.classes_mce[i].block ) {
547
+ format.block = data.classes_mce[i].block;
548
+ if (data.classes_mce[i].wrapper)
549
+ format.wrapper = true;
550
+ } else if ( data.classes_mce[i].selector )
551
+ format.selector = data.classes_mce[i].selector;
552
+ else
553
+ console.log('dropdown format has bad type.');
554
+
555
+ format.classes = data.classes_mce[i].classes;
556
+ style_formats.push( format );
557
+ }
558
+ if ( initData ) {
559
+ initData.style_formats = style_formats;
560
  if ( initData.toolbar2.indexOf( "styleselect" ) == -1 ) {
561
  var tempString = "styleselect,";
562
  initData.toolbar2 = tempString.concat(initData.toolbar2);
563
  }
564
+ }
565
 
566
+ $( '#delete-mce-dropdown-names', context ).show();
567
+ } else {
568
+ if ( initData ) {
569
  delete initData.style_formats;
570
  initData.toolbar2 = initData.toolbar2.replace("styleselect,", "");
 
 
571
  }
572
+ $( '#delete-mce-dropdown-names', context ).hide();
573
+ }
574
+
575
  refreshDeleteBtns();
576
  refreshMCE();
577
  }
651
  $( '.sns-ajax-loading' ).hide();
652
  }
653
  function refreshMCEhelper( ed ) {
654
+ if ( gutenMCE ) {
655
+ return;
656
+ }
657
  ed.save();
658
  ed.destroy();
659
  ed.remove();
663
  ed.render();
664
  ed.hide();
665
  }
 
666
  });
scripts-n-styles.php CHANGED
@@ -1,17 +1,19 @@
1
  <?php
2
  /*
3
- Plugin Name: Scripts n Styles
4
- Plugin URI: http://www.unfocus.com/projects/scripts-n-styles/
5
- Description: Allows WordPress admin users the ability to add custom CSS and JavaScript directly to individual Post, Pages or custom post types.
6
- Author: unFocus Projects
7
- Author URI: http://www.unfocus.com/
8
- Version: 3.4.5
9
- License: GPLv3 or later
10
- Text Domain: scripts-n-styles
 
 
11
  */
12
 
13
  /* The Scripts n Styles WordPress Plugin
14
- Copyright (c) 2010-2017 Kenneth Newman <http://www.unfocus.com/>
15
  Copyright (c) 2012 Kevin Newman <http://www.unfocus.com/>
16
  Copyright (c) 2012-2013 adcSTUDIO LLC <http://www.adcstudio.com/>
17
 
@@ -60,9 +62,9 @@ endif;
60
  * @link http://www.unfocus.com/projects/scripts-n-styles/ Plugin URI
61
  * @author unFocus Projects
62
  * @link http://www.unfocus.com/ Author URI
63
- * @version 3.4.5
64
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
65
- * @copyright Copyright (c) 2010 - 2017, Kenneth Newman
66
  * @copyright Copyright (c) 2012, Kevin Newman
67
  * @copyright Copyright (c) 2012 - 2013, adcSTUDIO LLC
68
  *
@@ -78,7 +80,7 @@ class Scripts_n_Styles
78
  /**#@+
79
  * @static
80
  */
81
- const VERSION = '3.4.5';
82
  static $file = __FILE__;
83
  static $cm_themes = array( 'default', '3024-day', '3024-night', 'ambiance',
84
  'base16-dark', 'base16-light',
@@ -112,6 +114,8 @@ class Scripts_n_Styles
112
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ), 11 );
113
  add_action( 'wp_head', array( __CLASS__, 'scripts_in_head' ), 11 );
114
  add_action( 'wp_footer', array( __CLASS__, 'scripts' ), 11 );
 
 
115
 
116
  add_action( 'plugins_loaded', array( __CLASS__, 'add_shortcodes' ) );
117
  add_action( 'widgets_init', array( __CLASS__, 'add_widget' ) );
@@ -262,14 +266,14 @@ class Scripts_n_Styles
262
  // Global
263
  $options = get_option( 'SnS_options' );
264
  if ( ! empty( $options ) && ! empty( $options[ 'styles' ] ) ) {
265
- ?><style type="text/css" id="sns_global_styles"><?php
266
  echo $options[ 'styles' ];
267
- ?></style><?php
268
  }
269
  if ( ! empty( $options ) && ! empty( $options[ 'compiled' ] ) ) {
270
- ?><style type="text/css" id="sns_global_less_compiled"><?php
271
  echo $options[ 'compiled' ];
272
- ?></style><?php
273
  }
274
 
275
  if ( ! is_singular() ) return;
@@ -278,9 +282,9 @@ class Scripts_n_Styles
278
  $SnS = get_post_meta( $post->ID, '_SnS', true );
279
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
280
  if ( ! empty( $styles ) && ! empty( $styles[ 'styles' ] ) ) {
281
- ?><style type="text/css" id="sns_styles"><?php
282
  echo $styles[ 'styles' ];
283
- ?></style><?php
284
  }
285
  }
286
 
@@ -292,14 +296,14 @@ class Scripts_n_Styles
292
  // Global
293
  $options = get_option( 'SnS_options' );
294
  if ( ! empty( $options ) && ! empty( $options[ 'scripts' ] ) ) {
295
- ?><script type="text/javascript" id="sns_global_scripts"><?php
296
  echo $options[ 'scripts' ];
297
- ?></script><?php
298
  }
299
  if ( ! empty( $options ) && ! empty( $options[ 'coffee_compiled' ] ) ) {
300
- ?><script type="text/javascript" id="sns_global_coffee_compiled"><?php
301
  echo $options[ 'coffee_compiled' ];
302
- ?></script><?php
303
  }
304
 
305
  if ( ! is_singular() ) return;
@@ -308,9 +312,9 @@ class Scripts_n_Styles
308
  $SnS = get_post_meta( $post->ID, '_SnS', true );
309
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
310
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts' ] ) ) {
311
- ?><script type="text/javascript" id="sns_scripts"><?php
312
  echo $scripts[ 'scripts' ];
313
- ?></script><?php
314
  }
315
  }
316
 
@@ -322,9 +326,9 @@ class Scripts_n_Styles
322
  // Global
323
  $options = get_option( 'SnS_options' );
324
  if ( ! empty( $options ) && ! empty( $options[ 'scripts_in_head' ] ) ) {
325
- ?><script type="text/javascript" id="sns_global_scripts_in_head"><?php
326
  echo $options[ 'scripts_in_head' ];
327
- ?></script><?php
328
  }
329
 
330
  if ( ! is_singular() ) return;
@@ -333,9 +337,51 @@ class Scripts_n_Styles
333
  $SnS = get_post_meta( $post->ID, '_SnS', true );
334
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
335
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts_in_head' ] ) ) {
336
- ?><script type="text/javascript" id="sns_scripts_in_head"><?php
337
  echo $scripts[ 'scripts_in_head' ];
338
- ?></script><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  }
340
  }
341
 
1
  <?php
2
  /*
3
+ Plugin Name: Scripts n Styles
4
+ Plugin URI: http://www.unfocus.com/projects/scripts-n-styles/
5
+ Description: Allows WordPress admin users the ability to add custom CSS and JavaScript directly to individual Post, Pages or custom post types.
6
+ Author: unFocus Projects
7
+ Author URI: http://www.unfocus.com/
8
+ Version: 3.5.0
9
+ License: GPLv3 or later
10
+ License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
+ Text Domain: scripts-n-styles
12
+ Domain Path: /languages
13
  */
14
 
15
  /* The Scripts n Styles WordPress Plugin
16
+ Copyright (c) 2010-2019 Kenneth Newman <http://www.unfocus.com/>
17
  Copyright (c) 2012 Kevin Newman <http://www.unfocus.com/>
18
  Copyright (c) 2012-2013 adcSTUDIO LLC <http://www.adcstudio.com/>
19
 
62
  * @link http://www.unfocus.com/projects/scripts-n-styles/ Plugin URI
63
  * @author unFocus Projects
64
  * @link http://www.unfocus.com/ Author URI
65
+ * @version 3.5.0
66
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
67
+ * @copyright Copyright (c) 2010 - 2019, Kenneth Newman
68
  * @copyright Copyright (c) 2012, Kevin Newman
69
  * @copyright Copyright (c) 2012 - 2013, adcSTUDIO LLC
70
  *
80
  /**#@+
81
  * @static
82
  */
83
+ const VERSION = '3.5.0';
84
  static $file = __FILE__;
85
  static $cm_themes = array( 'default', '3024-day', '3024-night', 'ambiance',
86
  'base16-dark', 'base16-light',
114
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ), 11 );
115
  add_action( 'wp_head', array( __CLASS__, 'scripts_in_head' ), 11 );
116
  add_action( 'wp_footer', array( __CLASS__, 'scripts' ), 11 );
117
+ add_action( 'wp_head', array( __CLASS__, 'html_in_head' ), 11 );
118
+ add_action( 'wp_footer', array( __CLASS__, 'html_in_footer' ), 11 );
119
 
120
  add_action( 'plugins_loaded', array( __CLASS__, 'add_shortcodes' ) );
121
  add_action( 'widgets_init', array( __CLASS__, 'add_widget' ) );
266
  // Global
267
  $options = get_option( 'SnS_options' );
268
  if ( ! empty( $options ) && ! empty( $options[ 'styles' ] ) ) {
269
+ echo '<style type="text/css" id="sns_global_styles">';
270
  echo $options[ 'styles' ];
271
+ echo '</style>';
272
  }
273
  if ( ! empty( $options ) && ! empty( $options[ 'compiled' ] ) ) {
274
+ echo '<style type="text/css" id="sns_global_less_compiled">';
275
  echo $options[ 'compiled' ];
276
+ echo '</style>';
277
  }
278
 
279
  if ( ! is_singular() ) return;
282
  $SnS = get_post_meta( $post->ID, '_SnS', true );
283
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
284
  if ( ! empty( $styles ) && ! empty( $styles[ 'styles' ] ) ) {
285
+ echo '<style type="text/css" id="sns_styles">';
286
  echo $styles[ 'styles' ];
287
+ echo '</style>';
288
  }
289
  }
290
 
296
  // Global
297
  $options = get_option( 'SnS_options' );
298
  if ( ! empty( $options ) && ! empty( $options[ 'scripts' ] ) ) {
299
+ echo '<script type="text/javascript" id="sns_global_scripts">';
300
  echo $options[ 'scripts' ];
301
+ echo '</script>';
302
  }
303
  if ( ! empty( $options ) && ! empty( $options[ 'coffee_compiled' ] ) ) {
304
+ echo '<script type="text/javascript" id="sns_global_coffee_compiled">';
305
  echo $options[ 'coffee_compiled' ];
306
+ echo '</script>';
307
  }
308
 
309
  if ( ! is_singular() ) return;
312
  $SnS = get_post_meta( $post->ID, '_SnS', true );
313
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
314
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts' ] ) ) {
315
+ echo '<script type="text/javascript" id="sns_scripts">';
316
  echo $scripts[ 'scripts' ];
317
+ echo '</script>';
318
  }
319
  }
320
 
326
  // Global
327
  $options = get_option( 'SnS_options' );
328
  if ( ! empty( $options ) && ! empty( $options[ 'scripts_in_head' ] ) ) {
329
+ echo '<script type="text/javascript" id="sns_global_scripts_in_head">';
330
  echo $options[ 'scripts_in_head' ];
331
+ echo '</script>';
332
  }
333
 
334
  if ( ! is_singular() ) return;
337
  $SnS = get_post_meta( $post->ID, '_SnS', true );
338
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
339
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts_in_head' ] ) ) {
340
+ echo '<script type="text/javascript" id="sns_scripts_in_head">';
341
  echo $scripts[ 'scripts_in_head' ];
342
+ echo '</script>';
343
+ }
344
+ }
345
+
346
+ /**
347
+ * Theme Action: 'wp_head()'
348
+ * Outputs the globally and individually set HTML in the Theme's head element.
349
+ */
350
+ static function html_in_head() {
351
+ // Global
352
+ $options = get_option( 'SnS_options' );
353
+ if ( ! empty( $options ) && ! empty( $options[ 'html_in_head' ] ) ) {
354
+ echo $options[ 'html_in_head' ];
355
+ }
356
+
357
+ if ( ! is_singular() ) return;
358
+ // Individual
359
+ global $post;
360
+ $SnS = get_post_meta( $post->ID, '_SnS', true );
361
+ $html = isset( $SnS['html'] ) ? $SnS[ 'html' ]: array();
362
+ if ( ! empty( $html ) && ! empty( $html[ 'html_in_head' ] ) ) {
363
+ echo $html[ 'html_in_head' ];
364
+ }
365
+ }
366
+
367
+ /**
368
+ * Theme Action: 'wp_footer()'
369
+ * Outputs the globally and individually set Scripts at the end of the Theme's body element.
370
+ */
371
+ static function html_in_footer() {
372
+ // Global
373
+ $options = get_option( 'SnS_options' );
374
+ if ( ! empty( $options ) && ! empty( $options[ 'html_in_footer' ] ) ) {
375
+ echo $options[ 'html_in_footer' ];
376
+ }
377
+
378
+ if ( ! is_singular() ) return;
379
+ // Individual
380
+ global $post;
381
+ $SnS = get_post_meta( $post->ID, '_SnS', true );
382
+ $html = isset( $SnS['html'] ) ? $SnS[ 'html' ]: array();
383
+ if ( ! empty( $html ) && ! empty( $html[ 'html_in_footer' ] ) ) {
384
+ echo $html[ 'html_in_footer' ];
385
  }
386
  }
387