11<?php
22
3+ if ( ! defined ( 'ABSPATH ' ) ) {
4+ exit ;
5+ }
6+
37/**
48 * The admin-specific functionality of the plugin.
59 *
@@ -58,22 +62,33 @@ public function add_media_button( $editor_id ) {
5862 $ icon = '<span class="wp-media-buttons-icon dashicons dashicons-layout" style="font-size:16px;margin-top:-2px;"></span> ' ;
5963
6064 printf ( '<a href="#" class="button gridable-insert-row-button" id="%s" data-editor="%s" title="%s">%s %s</a> ' ,
61- 'gridable-add-row-button- ' . $ editor_id ,
65+ esc_attr ( 'gridable-add-row-button- ' . $ editor_id ) ,
6266 esc_attr ( $ editor_id ),
6367 esc_attr__ ( 'Add Row ' , 'gridable ' ),
64- $ icon ,
68+ wp_kses ( $ icon , array (
69+ 'span ' => array (
70+ 'class ' => true ,
71+ 'style ' => true ,
72+ ),
73+ ) ),
6574 esc_html__ ( 'Add Row ' , 'gridable ' )
6675 );
6776
6877 /**
6978 * Enqueue the editor script only when there is an editor on page.
7079 * We ditch `admin_enqueue_scripts` intentionally since the editor can appear on non-edit pages like theme options
7180 */
72- wp_register_script ( 'select2 ' , plugin_dir_url ( __FILE__ ) . 'js/select2.min.js ' , array ( 'jquery ' ), $ this ->version );
81+ wp_register_script ( 'select2 ' , plugin_dir_url ( __FILE__ ) . 'js/select2.min.js ' , array ( 'jquery ' ), $ this ->version , true );
7382
7483 wp_enqueue_script ( 'gridable-add-row-button ' , plugin_dir_url ( __FILE__ ) . 'js/add-row-button.js ' , array (
84+ 'backbone ' ,
7585 'jquery ' ,
86+ 'media-editor ' ,
87+ 'media-views ' ,
88+ 'quicktags ' ,
89+ 'shortcode ' ,
7690 'wp-color-picker ' ,
91+ 'wp-util ' ,
7792 'select2 ' ,
7893 ), $ this ->version , true );
7994
@@ -116,13 +131,13 @@ public function print_tinymce_templates() {
116131 $ row_classes = array (
117132 'gridable ' ,
118133 'gridable--grid ' ,
119- 'grid '
134+ 'grid ' ,
120135 );
121136 $ col_classes = array (
122- 'grid__item '
137+ 'grid__item ' ,
123138 ); ?>
124- <script type="text/html" id="tmpl-gridable-grider-row"><section contenteditable="false" class="{{data.classes}} <?php echo join ( ' ' , apply_filters ( 'gridable_mce_sh_row_classes ' , $ row_classes ) ); ?> " {{{data.atts}}} data-gridable-row="1" data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
125- <script type="text/html" id="tmpl-gridable-grider-col"><section unselectable="true" contenteditable="true" class="{{data.classes}} <?php echo join ( ' ' , apply_filters ( 'gridable_mce_sh_col_classes ' , $ col_classes ) ); ?> " {{{data.atts}}} data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
139+ <script type="text/html" id="tmpl-gridable-grider-row"><section contenteditable="false" class="{{data.classes}} <?php echo esc_attr ( implode ( ' ' , array_map ( ' sanitize_html_class ' , apply_filters ( 'gridable_mce_sh_row_classes ' , $ row_classes ) ) ) ); ?> " {{{data.atts}}} data-gridable-row="1" data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
140+ <script type="text/html" id="tmpl-gridable-grider-col"><section unselectable="true" contenteditable="true" class="{{data.classes}} <?php echo esc_attr ( implode ( ' ' , array_map ( ' sanitize_html_class ' , apply_filters ( 'gridable_mce_sh_col_classes ' , $ col_classes ) ) ) ); ?> " {{{data.atts}}} data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
126141 <?php
127142 do_action ( 'gridable_print_row_options_templates ' );
128143 do_action ( 'gridable_print_column_options_templates ' );
@@ -150,8 +165,8 @@ public function change_tinymce_settings( $settings ) {
150165
151166 public function styles_scripts () { ?>
152167 <script type="text/javascript">
153- var gridable_params = {
154- l10n: JSON.parse(' <?php echo json_encode ( apply_filters ( 'gridable_editor_l10n_labels ' , array (
168+ window.gridable_params = window. gridable_params || {};
169+ window.gridable_params. l10n = <?php echo wp_json_encode ( apply_filters ( 'gridable_editor_l10n_labels ' , array (
155170 'remove_row ' => esc_html__ ( 'Remove Row ' , 'gridable ' ),
156171 'remove_column ' => esc_html__ ( 'Remove Column ' , 'gridable ' ),
157172 'edit_row ' => esc_html__ ( 'Edit Row Options ' , 'gridable ' ),
@@ -160,8 +175,7 @@ public function styles_scripts() { ?>
160175 'new_column_content ' => esc_html__ ( 'Content ' , 'gridable ' ),
161176 'column ' => esc_html__ ( 'Column ' , 'gridable ' ),
162177 'row ' => esc_html__ ( 'Row ' , 'gridable ' ),
163- ) ) ) ?> ')
164- };
178+ ) ) ); ?> ;
165179 </script>
166180 <?php
167181 }
0 commit comments