Ticket #22344: 22344-hybrid.diff

File 22344-hybrid.diff, 8.5 KB (added by rmccue, 6 months ago)

Hybrid version, uses {{ for escaping, {{{ for interpolating and <# for executing

Line 
1diff --git wp-includes/js/media-models.js wp-includes/js/media-models.js
2index e9776b4..917c245 100644
3--- wp-includes/js/media-models.js
4+++ wp-includes/js/media-models.js
5@@ -60,7 +60,12 @@ window.wp = window.wp || {};
6                template: _.memoize( function( id ) {
7                        var compiled;
8                        return function( data ) {
9-                               compiled = compiled || _.template( $( '#tmpl-' + id ).html() );
10+                               var options = {
11+                                       evaluate:    /<#([\s\S]+?)#>/g,
12+                                       interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
13+                                       escape:      /\{\{([\s\S]+?)\}\}/g
14+                               }
15+                               compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
16                                return compiled( data );
17                        };
18                }),
19diff --git wp-includes/media.php wp-includes/media.php
20index 079aab5..493e5d7 100644
21--- wp-includes/media.php
22+++ wp-includes/media.php
23@@ -1297,7 +1297,7 @@ function wp_print_media_templates( $attachment ) {
24        ?>
25        <script type="text/html" id="tmpl-media-modal">
26                <div class="media-modal">
27-                       <h3 class="media-modal-title"><%- title %></h3>
28+                       <h3 class="media-modal-title">{{ title }}</h3>
29                        <a class="media-modal-close" href="" title="<?php esc_attr_e('Close'); ?>">&times;</a>
30                </div>
31                <div class="media-modal-backdrop">
32@@ -1320,98 +1320,98 @@ function wp_print_media_templates( $attachment ) {
33        </script>
34 
35        <script type="text/html" id="tmpl-attachment">
36-               <div class="attachment-preview type-<%- type %> subtype-<%- subtype %> <%- orientation %>">
37-                       <% if ( uploading ) { %>
38+               <div class="attachment-preview type-{{ type }} subtype-{{ subtype }} {{ orientation }}">
39+                       <# if ( uploading ) { #>
40                                <div class="media-progress-bar"><div></div></div>
41-                       <% } else if ( 'image' === type ) { %>
42+                       <# } else if ( 'image' === type ) { #>
43                                <div class="thumbnail">
44                                        <div class="centered">
45-                                               <img src="<%- url %>" draggable="false" />
46+                                               <img src="{{ url }}" draggable="false" />
47                                        </div>
48                                </div>
49-                       <% } else { %>
50-                               <img src="<%- icon %>" class="icon" draggable="false" />
51-                               <div class="filename"><%- filename %></div>
52-                       <% } %>
53+                       <# } else { #>
54+                               <img src="{{ icon }}" class="icon" draggable="false" />
55+                               <div class="filename">{{ filename }}</div>
56+                       <# } #>
57 
58-                       <% if ( buttons.close ) { %>
59+                       <# if ( buttons.close ) { #>
60                                <a class="close button" href="#">&times;</a>
61-                       <% } %>
62+                       <# } #>
63                </div>
64-               <% if ( describe ) { %>
65-                       <% if ( 'image' === type ) { %>
66+               <# if ( describe ) { #>
67+                       <# if ( 'image' === type ) { #>
68                                <textarea class="describe"
69                                        placeholder="<?php esc_attr_e('Describe this image&hellip;'); ?>"
70-                                       ><%- caption %></textarea>
71-                       <% } else { %>
72+                                       >{{ caption }}</textarea>
73+                       <# } else { #>
74                                <textarea class="describe"
75-                                       <% if ( 'video' === type ) { %>
76+                                       <# if ( 'video' === type ) { #>
77                                                placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
78-                                       <% } else if ( 'audio' === type ) { %>
79+                                       <# } else if ( 'audio' === type ) { #>
80                                                placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
81-                                       <% } else { %>
82+                                       <# } else { #>
83                                                placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
84-                                       <% } %>
85-                                       ><%- title %></textarea>
86-                       <% } %>
87-               <% } %>
88+                                       <# } #>
89+                                       >{{ title }}</textarea>
90+                       <# } #>
91+               <# } #>
92        </script>
93 
94        <script type="text/html" id="tmpl-attachment-details">
95                <h3><?php _e('Edit Attachment Details'); ?></h3>
96-               <div class="attachment-preview attachment-details-preview type-<%- type %> subtype-<%- subtype %> <%- orientation %>">
97-                       <% if ( uploading ) { %>
98+               <div class="attachment-preview attachment-details-preview type-{{ type }} subtype-{{ subtype }} {{ orientation }}">
99+                       <# if ( uploading ) { #>
100                                <div class="media-progress-bar"><div></div></div>
101-                       <% } else if ( 'image' === type ) { %>
102+                       <# } else if ( 'image' === type ) { #>
103                                <div class="thumbnail">
104-                                       <img src="<%- url %>" draggable="false" />
105+                                       <img src="{{ url }}" draggable="false" />
106                                </div>
107-                       <% } else { %>
108+                       <# } else { #>
109                                <div class="icon-thumbnail">
110-                                       <img src="<%- icon %>" class="icon" draggable="false" />
111-                                       <div class="filename"><%- filename %></div>
112+                                       <img src="{{ icon }}" class="icon" draggable="false" />
113+                                       <div class="filename">{{ filename }}</div>
114                                </div>
115-                       <% } %>
116+                       <# } #>
117                </div>
118 
119-               <% if ( 'image' === type ) { %>
120+               <# if ( 'image' === type ) { #>
121                        <textarea class="describe"
122                                placeholder="<?php esc_attr_e('Describe this image&hellip;'); ?>"
123-                               ><%- caption %></textarea>
124-               <% } else { %>
125+                               >{{ caption }}</textarea>
126+               <# } else { #>
127                        <textarea class="describe"
128-                               <% if ( 'video' === type ) { %>
129+                               <# if ( 'video' === type ) { #>
130                                        placeholder="<?php esc_attr_e('Describe this video&hellip;'); ?>"
131-                               <% } else if ( 'audio' === type ) { %>
132+                               <# } else if ( 'audio' === type ) { #>
133                                        placeholder="<?php esc_attr_e('Describe this audio file&hellip;'); ?>"
134-                               <% } else { %>
135+                               <# } else { #>
136                                        placeholder="<?php esc_attr_e('Describe this media file&hellip;'); ?>"
137-                               <% } %>
138-                               ><%- title %></textarea>
139-               <% } %>
140+                               <# } #>
141+                               >{{ title }}</textarea>
142+               <# } #>
143        </script>
144 
145        <script type="text/html" id="tmpl-media-selection">
146                <div class="selection-info">
147                        <span class="count"></span>
148-                       <% if ( clearable ) { %>
149+                       <# if ( clearable ) { #>
150                                <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
151-                       <% } %>
152+                       <# } #>
153                </div>
154                <div class="selection-view"></div>
155        </script>
156 
157        <script type="text/html" id="tmpl-media-selection-preview">
158-               <div class="selected-img selected-count-<%- count %>">
159-                       <% if ( thumbnail ) { %>
160-                               <img src="<%- thumbnail %>" draggable="false" />
161-                       <% } %>
162+               <div class="selected-img selected-count-{{ count }}">
163+                       <# if ( thumbnail ) { #>
164+                               <img src="{{ thumbnail }}" draggable="false" />
165+                       <# } #>
166 
167-                       <span class="count"><%- count %></span>
168+                       <span class="count">{{ count }}</span>
169                </div>
170-               <% if ( clearable ) { %>
171+               <# if ( clearable ) { #>
172                        <a class="clear-selection" href="#"><?php _e('Clear selection'); ?></a>
173-               <% } %>
174+               <# } #>
175        </script>
176 
177        <script type="text/html" id="tmpl-attachment-display-settings">
178@@ -1459,21 +1459,21 @@ function wp_print_media_templates( $attachment ) {
179                <h4><?php _e('Gallery Columns'); ?></h4>
180 
181                <select class="columns" name="columns" data-setting="columns">
182-                       <% _.times( 9, function( i ) { %>
183-                               <option value="<%- i %>"><%- i %></option>
184-                       <% }); %>
185+                       <# _.times( 9, function( i ) { #>
186+                               <option value="{{ i }}">{{ i }}</option>
187+                       <# }); }}
188                </select>
189        </script>
190 
191        <script type="text/html" id="tmpl-editor-attachment">
192                <div class="editor-attachment-preview">
193-                       <% if ( url ) { %>
194-                               <img src="<%- url %>" width="<%- width %>" height="<%- height %>" draggable="false" />
195-                       <% } %>
196+                       <# if ( url ) { #>
197+                               <img src="{{ url }}" width="{{ width }}" height="{{ height }}" draggable="false" />
198+                       <# } #>
199 
200-                       <% if ( uploading ) { %>
201+                       <# if ( uploading ) { #>
202                                <div class="media-progress-bar"><div></div></div>
203-                       <% } %>
204+                       <# } #>
205                        <div class="overlay">
206                                <div class="button close">&times;</div>
207                        </div>
208@@ -1482,9 +1482,9 @@ function wp_print_media_templates( $attachment ) {
209        </script>
210 
211        <script type="text/html" id="tmpl-editor-gallery">
212-               <% if ( url ) { %>
213-                       <img src="<%- url %>" draggable="false" />
214-               <% } %>
215+               <# if ( url ) { #>
216+                       <img src="{{ url }}" draggable="false" />
217+               <# } #>
218 
219                <div class="overlay">
220                        <div class="button close">&times;</div>
221@@ -1493,30 +1493,30 @@ function wp_print_media_templates( $attachment ) {
222        </script>
223 
224        <script type="text/html" id="tmpl-attachments-css">
225-               <style type="text/css" id="<%- id %>-css">
226-                       #<%- id %> {
227-                               padding: 0 <%- gutter %>px;
228+               <style type="text/css" id="{{ id }}-css">
229+                       #{{ id }} {
230+                               padding: 0 {{ gutter }}px;
231                        }
232 
233-                       #<%- id %> .attachment {
234-                               margin: <%- gutter %>px;
235-                               width: <%- edge %>px;
236+                       #{{ id }} .attachment {
237+                               margin: {{ gutter }}px;
238+                               width: {{ edge }}px;
239                        }
240 
241-                       #<%- id %> .attachment-preview,
242-                       #<%- id %> .attachment-preview .thumbnail {
243-                               width: <%- edge %>px;
244-                               height: <%- edge %>px;
245+                       #{{ id }} .attachment-preview,
246+                       #{{ id }} .attachment-preview .thumbnail {
247+                               width: {{ edge }}px;
248+                               height: {{ edge }}px;
249                        }
250 
251-                       #<%- id %> .portrait .thumbnail img {
252-                               width: <%- edge %>px;
253+                       #{{ id }} .portrait .thumbnail img {
254+                               width: {{ edge }}px;
255                                height: auto;
256                        }
257 
258-                       #<%- id %> .landscape .thumbnail img {
259+                       #{{ id }} .landscape .thumbnail img {
260                                width: auto;
261-                               height: <%- edge %>px;
262+                               height: {{ edge }}px;
263                        }
264                </style>
265        </script>