@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | function yourls_html_logo() { |
8 | - yourls_do_action( 'pre_html_logo' ); |
|
9 | - ?> |
|
8 | + yourls_do_action( 'pre_html_logo' ); |
|
9 | + ?> |
|
10 | 10 | <header role="banner"> |
11 | 11 | <h1> |
12 | 12 | <a href="<?php echo yourls_admin_url( 'index.php' ) ?>" title="YOURLS"><span>YOURLS</span>: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener<br/> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | </h1> |
15 | 15 | </header> |
16 | 16 | <?php |
17 | - yourls_do_action( 'html_logo' ); |
|
17 | + yourls_do_action( 'html_logo' ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -25,60 +25,60 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function yourls_html_head( $context = 'index', $title = '' ) { |
27 | 27 | |
28 | - yourls_do_action( 'pre_html_head', $context, $title ); |
|
29 | - |
|
30 | - // All components to false, except when specified true |
|
31 | - $share = $insert = $tablesorter = $tabs = $cal = $charts = false; |
|
32 | - |
|
33 | - // Load components as needed |
|
34 | - switch ( $context ) { |
|
35 | - case 'infos': |
|
36 | - $share = $tabs = $charts = true; |
|
37 | - break; |
|
38 | - |
|
39 | - case 'bookmark': |
|
40 | - $share = $insert = $tablesorter = true; |
|
41 | - break; |
|
42 | - |
|
43 | - case 'index': |
|
44 | - $insert = $tablesorter = $cal = $share = true; |
|
45 | - break; |
|
46 | - |
|
47 | - case 'plugins': |
|
48 | - case 'tools': |
|
49 | - $tablesorter = true; |
|
50 | - break; |
|
51 | - |
|
52 | - case 'install': |
|
53 | - case 'login': |
|
54 | - case 'new': |
|
55 | - case 'upgrade': |
|
56 | - break; |
|
57 | - } |
|
58 | - |
|
59 | - // Force no cache for all admin pages |
|
60 | - if( yourls_is_admin() && !headers_sent() ) { |
|
61 | - header( 'Expires: Thu, 23 Mar 1972 07:00:00 GMT' ); |
|
62 | - header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
|
63 | - header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); |
|
64 | - header( 'Pragma: no-cache' ); |
|
65 | - yourls_content_type_header( yourls_apply_filter( 'html_head_content-type', 'text/html' ) ); |
|
66 | - yourls_do_action( 'admin_headers', $context, $title ); |
|
67 | - } |
|
68 | - |
|
69 | - // Store page context |
|
70 | - yourls_set_html_context($context); |
|
71 | - |
|
72 | - // Body class |
|
73 | - $bodyclass = yourls_apply_filter( 'bodyclass', '' ); |
|
74 | - $bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' ); |
|
75 | - |
|
76 | - // Page title |
|
77 | - $_title = 'YOURLS — Your Own URL Shortener | ' . yourls_link(); |
|
78 | - $title = $title ? $title . " « " . $_title : $_title; |
|
79 | - $title = yourls_apply_filter( 'html_title', $title, $context ); |
|
80 | - |
|
81 | - ?> |
|
28 | + yourls_do_action( 'pre_html_head', $context, $title ); |
|
29 | + |
|
30 | + // All components to false, except when specified true |
|
31 | + $share = $insert = $tablesorter = $tabs = $cal = $charts = false; |
|
32 | + |
|
33 | + // Load components as needed |
|
34 | + switch ( $context ) { |
|
35 | + case 'infos': |
|
36 | + $share = $tabs = $charts = true; |
|
37 | + break; |
|
38 | + |
|
39 | + case 'bookmark': |
|
40 | + $share = $insert = $tablesorter = true; |
|
41 | + break; |
|
42 | + |
|
43 | + case 'index': |
|
44 | + $insert = $tablesorter = $cal = $share = true; |
|
45 | + break; |
|
46 | + |
|
47 | + case 'plugins': |
|
48 | + case 'tools': |
|
49 | + $tablesorter = true; |
|
50 | + break; |
|
51 | + |
|
52 | + case 'install': |
|
53 | + case 'login': |
|
54 | + case 'new': |
|
55 | + case 'upgrade': |
|
56 | + break; |
|
57 | + } |
|
58 | + |
|
59 | + // Force no cache for all admin pages |
|
60 | + if( yourls_is_admin() && !headers_sent() ) { |
|
61 | + header( 'Expires: Thu, 23 Mar 1972 07:00:00 GMT' ); |
|
62 | + header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
|
63 | + header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); |
|
64 | + header( 'Pragma: no-cache' ); |
|
65 | + yourls_content_type_header( yourls_apply_filter( 'html_head_content-type', 'text/html' ) ); |
|
66 | + yourls_do_action( 'admin_headers', $context, $title ); |
|
67 | + } |
|
68 | + |
|
69 | + // Store page context |
|
70 | + yourls_set_html_context($context); |
|
71 | + |
|
72 | + // Body class |
|
73 | + $bodyclass = yourls_apply_filter( 'bodyclass', '' ); |
|
74 | + $bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' ); |
|
75 | + |
|
76 | + // Page title |
|
77 | + $_title = 'YOURLS — Your Own URL Shortener | ' . yourls_link(); |
|
78 | + $title = $title ? $title . " « " . $_title : $_title; |
|
79 | + $title = yourls_apply_filter( 'html_title', $title, $context ); |
|
80 | + |
|
81 | + ?> |
|
82 | 82 | <!DOCTYPE html> |
83 | 83 | <html <?php yourls_html_language_attributes(); ?>> |
84 | 84 | <head> |
@@ -149,20 +149,20 @@ discard block |
||
149 | 149 | $num_queries = ''; |
150 | 150 | } |
151 | 151 | |
152 | - ?> |
|
152 | + ?> |
|
153 | 153 | </div><?php // wrap ?> |
154 | 154 | <footer id="footer" role="contentinfo"><p> |
155 | 155 | <?php |
156 | - $footer = yourls_s( 'Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v ' . YOURLS_VERSION ); |
|
157 | - $footer .= $num_queries; |
|
158 | - echo yourls_apply_filter( 'html_footer_text', $footer ); |
|
159 | - ?> |
|
156 | + $footer = yourls_s( 'Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v ' . YOURLS_VERSION ); |
|
157 | + $footer .= $num_queries; |
|
158 | + echo yourls_apply_filter( 'html_footer_text', $footer ); |
|
159 | + ?> |
|
160 | 160 | </p></footer> |
161 | 161 | <?php if( yourls_get_debug_mode() ) { |
162 | - echo '<div style="text-align:left"><pre>'; |
|
163 | - echo join( "\n", yourls_get_debug_log() ); |
|
164 | - echo '</pre></div>'; |
|
165 | - } ?> |
|
162 | + echo '<div style="text-align:left"><pre>'; |
|
163 | + echo join( "\n", yourls_get_debug_log() ); |
|
164 | + echo '</pre></div>'; |
|
165 | + } ?> |
|
166 | 166 | <?php yourls_do_action( 'html_footer', yourls_get_html_context() ); ?> |
167 | 167 | </body> |
168 | 168 | </html> |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if ( false !== $pre ) { |
181 | 181 | return $pre; |
182 | 182 | } |
183 | - ?> |
|
183 | + ?> |
|
184 | 184 | <main role="main"> |
185 | 185 | <div id="new_url"> |
186 | 186 | <div> |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $date_first = $params['date_first']; |
227 | 227 | $date_second = $params['date_second']; |
228 | 228 | |
229 | - ?> |
|
229 | + ?> |
|
230 | 230 | <tfoot> |
231 | 231 | <tr> |
232 | 232 | <th colspan="6"> |
@@ -235,70 +235,70 @@ discard block |
||
235 | 235 | <div id="filter_options"> |
236 | 236 | <?php |
237 | 237 | |
238 | - // First search control: text to search |
|
239 | - $_input = '<input aria-label="' .yourls__( 'Search for' ). '" type="text" name="search" class="text" size="12" value="' . yourls_esc_attr( $search_text ) . '" />'; |
|
240 | - $_options = array( |
|
238 | + // First search control: text to search |
|
239 | + $_input = '<input aria-label="' .yourls__( 'Search for' ). '" type="text" name="search" class="text" size="12" value="' . yourls_esc_attr( $search_text ) . '" />'; |
|
240 | + $_options = array( |
|
241 | 241 | 'all' => yourls__( 'All fields' ), |
242 | - 'keyword' => yourls__( 'Short URL' ), |
|
243 | - 'url' => yourls__( 'URL' ), |
|
244 | - 'title' => yourls__( 'Title' ), |
|
245 | - 'ip' => yourls__( 'IP' ), |
|
246 | - ); |
|
247 | - $_select = yourls_html_select( 'search_in', $_options, $search_in, false, yourls__( 'Search in' ) ); |
|
248 | - /* //translators: "Search for <input field with text to search> in <select dropdown with URL, title...>" */ |
|
249 | - yourls_se( 'Search for %1$s in %2$s', $_input , $_select ); |
|
250 | - echo "–\n"; |
|
251 | - |
|
252 | - // Second search control: order by |
|
253 | - $_options = array( |
|
254 | - 'keyword' => yourls__( 'Short URL' ), |
|
255 | - 'url' => yourls__( 'URL' ), |
|
256 | - 'title' => yourls__( 'Title' ), |
|
257 | - 'timestamp' => yourls__( 'Date' ), |
|
258 | - 'ip' => yourls__( 'IP' ), |
|
259 | - 'clicks' => yourls__( 'Clicks' ), |
|
260 | - ); |
|
261 | - $_select = yourls_html_select( 'sort_by', $_options, $sort_by, false, yourls__( 'Sort by' ) ); |
|
262 | - $sort_order = isset( $sort_order ) ? $sort_order : 'desc' ; |
|
263 | - $_options = array( |
|
264 | - 'asc' => yourls__( 'Ascending' ), |
|
265 | - 'desc' => yourls__( 'Descending' ), |
|
266 | - ); |
|
267 | - $_select2 = yourls_html_select( 'sort_order', $_options, $sort_order, false, yourls__( 'Sort order' ) ); |
|
268 | - /* //translators: "Order by <criteria dropdown (date, clicks...)> in <order dropdown (Descending or Ascending)>" */ |
|
269 | - yourls_se( 'Order by %1$s %2$s', $_select , $_select2 ); |
|
270 | - echo "–\n"; |
|
271 | - |
|
272 | - // Third search control: Show XX rows |
|
273 | - /* //translators: "Show <text field> rows" */ |
|
242 | + 'keyword' => yourls__( 'Short URL' ), |
|
243 | + 'url' => yourls__( 'URL' ), |
|
244 | + 'title' => yourls__( 'Title' ), |
|
245 | + 'ip' => yourls__( 'IP' ), |
|
246 | + ); |
|
247 | + $_select = yourls_html_select( 'search_in', $_options, $search_in, false, yourls__( 'Search in' ) ); |
|
248 | + /* //translators: "Search for <input field with text to search> in <select dropdown with URL, title...>" */ |
|
249 | + yourls_se( 'Search for %1$s in %2$s', $_input , $_select ); |
|
250 | + echo "–\n"; |
|
251 | + |
|
252 | + // Second search control: order by |
|
253 | + $_options = array( |
|
254 | + 'keyword' => yourls__( 'Short URL' ), |
|
255 | + 'url' => yourls__( 'URL' ), |
|
256 | + 'title' => yourls__( 'Title' ), |
|
257 | + 'timestamp' => yourls__( 'Date' ), |
|
258 | + 'ip' => yourls__( 'IP' ), |
|
259 | + 'clicks' => yourls__( 'Clicks' ), |
|
260 | + ); |
|
261 | + $_select = yourls_html_select( 'sort_by', $_options, $sort_by, false, yourls__( 'Sort by' ) ); |
|
262 | + $sort_order = isset( $sort_order ) ? $sort_order : 'desc' ; |
|
263 | + $_options = array( |
|
264 | + 'asc' => yourls__( 'Ascending' ), |
|
265 | + 'desc' => yourls__( 'Descending' ), |
|
266 | + ); |
|
267 | + $_select2 = yourls_html_select( 'sort_order', $_options, $sort_order, false, yourls__( 'Sort order' ) ); |
|
268 | + /* //translators: "Order by <criteria dropdown (date, clicks...)> in <order dropdown (Descending or Ascending)>" */ |
|
269 | + yourls_se( 'Order by %1$s %2$s', $_select , $_select2 ); |
|
270 | + echo "–\n"; |
|
271 | + |
|
272 | + // Third search control: Show XX rows |
|
273 | + /* //translators: "Show <text field> rows" */ |
|
274 | 274 | $_input = '<input aria-label="' .yourls__( 'Number of rows to show' ). '" type="text" name="perpage" class="text" size="2" value="' . $perpage . '" />'; |
275 | - yourls_se( 'Show %s rows', $_input ); |
|
276 | - echo "<br/>\n"; |
|
277 | - |
|
278 | - // Fourth search control: Show links with more than XX clicks |
|
279 | - $_options = array( |
|
280 | - 'more' => yourls__( 'more' ), |
|
281 | - 'less' => yourls__( 'less' ), |
|
282 | - ); |
|
283 | - $_select = yourls_html_select( 'click_filter', $_options, $click_filter, false, yourls__( 'Show links with' ) ); |
|
284 | - $_input = '<input aria-label="' .yourls__( 'Number of clicks' ). '" type="text" name="click_limit" class="text" size="4" value="' . $click_limit . '" /> '; |
|
285 | - /* //translators: "Show links with <more/less> than <text field> clicks" */ |
|
286 | - yourls_se( 'Show links with %1$s than %2$s clicks', $_select, $_input ); |
|
287 | - echo "<br/>\n"; |
|
288 | - |
|
289 | - // Fifth search control: Show links created before/after/between ... |
|
290 | - $_options = array( |
|
291 | - 'before' => yourls__('before'), |
|
292 | - 'after' => yourls__('after'), |
|
293 | - 'between' => yourls__('between'), |
|
294 | - ); |
|
295 | - $_select = yourls_html_select( 'date_filter', $_options, $date_filter, false, yourls__('Show links created') ); |
|
296 | - $_input = '<input aria-label="' .yourls__('Select a date') . '" type="text" name="date_first" id="date_first" class="text" size="12" value="' . $date_first . '" />'; |
|
297 | - $_and = '<span id="date_and"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '> & </span>'; |
|
298 | - $_input2 = '<input aria-label="' .yourls__('Select an end date') . '" type="text" name="date_second" id="date_second" class="text" size="12" value="' . $date_second . '"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '/>'; |
|
299 | - /* //translators: "Show links created <before/after/between> <date input> <"and" if applicable> <date input if applicable>" */ |
|
300 | - yourls_se( 'Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2 ); |
|
301 | - ?> |
|
275 | + yourls_se( 'Show %s rows', $_input ); |
|
276 | + echo "<br/>\n"; |
|
277 | + |
|
278 | + // Fourth search control: Show links with more than XX clicks |
|
279 | + $_options = array( |
|
280 | + 'more' => yourls__( 'more' ), |
|
281 | + 'less' => yourls__( 'less' ), |
|
282 | + ); |
|
283 | + $_select = yourls_html_select( 'click_filter', $_options, $click_filter, false, yourls__( 'Show links with' ) ); |
|
284 | + $_input = '<input aria-label="' .yourls__( 'Number of clicks' ). '" type="text" name="click_limit" class="text" size="4" value="' . $click_limit . '" /> '; |
|
285 | + /* //translators: "Show links with <more/less> than <text field> clicks" */ |
|
286 | + yourls_se( 'Show links with %1$s than %2$s clicks', $_select, $_input ); |
|
287 | + echo "<br/>\n"; |
|
288 | + |
|
289 | + // Fifth search control: Show links created before/after/between ... |
|
290 | + $_options = array( |
|
291 | + 'before' => yourls__('before'), |
|
292 | + 'after' => yourls__('after'), |
|
293 | + 'between' => yourls__('between'), |
|
294 | + ); |
|
295 | + $_select = yourls_html_select( 'date_filter', $_options, $date_filter, false, yourls__('Show links created') ); |
|
296 | + $_input = '<input aria-label="' .yourls__('Select a date') . '" type="text" name="date_first" id="date_first" class="text" size="12" value="' . $date_first . '" />'; |
|
297 | + $_and = '<span id="date_and"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '> & </span>'; |
|
298 | + $_input2 = '<input aria-label="' .yourls__('Select an end date') . '" type="text" name="date_second" id="date_second" class="text" size="12" value="' . $date_second . '"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '/>'; |
|
299 | + /* //translators: "Show links created <before/after/between> <date input> <"and" if applicable> <date input if applicable>" */ |
|
300 | + yourls_se( 'Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2 ); |
|
301 | + ?> |
|
302 | 302 | |
303 | 303 | <div id="filter_buttons"> |
304 | 304 | <input type="submit" id="submit-sort" value="<?php yourls_e('Search'); ?>" class="button primary" /> |
@@ -311,43 +311,43 @@ discard block |
||
311 | 311 | </div> |
312 | 312 | |
313 | 313 | <?php |
314 | - // Remove empty keys from the $params array so it doesn't clutter the pagination links |
|
315 | - $params = array_filter( $params, 'yourls_return_if_not_empty_string' ); // remove empty keys |
|
314 | + // Remove empty keys from the $params array so it doesn't clutter the pagination links |
|
315 | + $params = array_filter( $params, 'yourls_return_if_not_empty_string' ); // remove empty keys |
|
316 | 316 | |
317 | - if( isset( $search_text ) ) { |
|
318 | - $params['search'] = $search_text; |
|
319 | - unset( $params['search_text'] ); |
|
320 | - } |
|
321 | - ?> |
|
317 | + if( isset( $search_text ) ) { |
|
318 | + $params['search'] = $search_text; |
|
319 | + unset( $params['search_text'] ); |
|
320 | + } |
|
321 | + ?> |
|
322 | 322 | |
323 | 323 | <div id="pagination"> |
324 | 324 | <span class="navigation"> |
325 | 325 | <?php if( $total_pages > 1 ) { ?> |
326 | 326 | <span class="nav_total"><?php echo sprintf( yourls_n( '1 page', '%s pages', $total_pages ), $total_pages ); ?></span> |
327 | 327 | <?php |
328 | - $base_page = yourls_admin_url( 'index.php' ); |
|
329 | - // Pagination offsets: min( max ( zomg! ) ); |
|
330 | - $p_start = max( min( $total_pages - 4, $page - 2 ), 1 ); |
|
331 | - $p_end = min( max( 5, $page + 2 ), $total_pages ); |
|
332 | - if( $p_start >= 2 ) { |
|
333 | - $link = yourls_add_query_arg( array_merge( $params, array( 'page' => 1 ) ), $base_page ); |
|
334 | - echo '<span class="nav_link nav_first"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to First Page') . '">' . yourls__( '« First' ) . '</a></span>'; |
|
335 | - echo '<span class="nav_link nav_prev"></span>'; |
|
336 | - } |
|
337 | - for( $i = $p_start ; $i <= $p_end; $i++ ) { |
|
338 | - if( $i == $page ) { |
|
339 | - echo "<span class='nav_link nav_current'>$i</span>"; |
|
340 | - } else { |
|
341 | - $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $i ) ), $base_page ); |
|
342 | - echo '<span class="nav_link nav_goto"><a href="' . $link . '" title="' . sprintf( yourls_esc_attr( 'Page %s' ), $i ) .'">'.$i.'</a></span>'; |
|
343 | - } |
|
344 | - } |
|
345 | - if( ( $p_end ) < $total_pages ) { |
|
346 | - $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $total_pages ) ), $base_page ); |
|
347 | - echo '<span class="nav_link nav_next"></span>'; |
|
348 | - echo '<span class="nav_link nav_last"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to Last Page') . '">' . yourls__( 'Last »' ) . '</a></span>'; |
|
349 | - } |
|
350 | - ?> |
|
328 | + $base_page = yourls_admin_url( 'index.php' ); |
|
329 | + // Pagination offsets: min( max ( zomg! ) ); |
|
330 | + $p_start = max( min( $total_pages - 4, $page - 2 ), 1 ); |
|
331 | + $p_end = min( max( 5, $page + 2 ), $total_pages ); |
|
332 | + if( $p_start >= 2 ) { |
|
333 | + $link = yourls_add_query_arg( array_merge( $params, array( 'page' => 1 ) ), $base_page ); |
|
334 | + echo '<span class="nav_link nav_first"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to First Page') . '">' . yourls__( '« First' ) . '</a></span>'; |
|
335 | + echo '<span class="nav_link nav_prev"></span>'; |
|
336 | + } |
|
337 | + for( $i = $p_start ; $i <= $p_end; $i++ ) { |
|
338 | + if( $i == $page ) { |
|
339 | + echo "<span class='nav_link nav_current'>$i</span>"; |
|
340 | + } else { |
|
341 | + $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $i ) ), $base_page ); |
|
342 | + echo '<span class="nav_link nav_goto"><a href="' . $link . '" title="' . sprintf( yourls_esc_attr( 'Page %s' ), $i ) .'">'.$i.'</a></span>'; |
|
343 | + } |
|
344 | + } |
|
345 | + if( ( $p_end ) < $total_pages ) { |
|
346 | + $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $total_pages ) ), $base_page ); |
|
347 | + echo '<span class="nav_link nav_next"></span>'; |
|
348 | + echo '<span class="nav_link nav_last"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to Last Page') . '">' . yourls__( 'Last »' ) . '</a></span>'; |
|
349 | + } |
|
350 | + ?> |
|
351 | 351 | <?php } ?> |
352 | 352 | </span> |
353 | 353 | </div> |
@@ -371,17 +371,17 @@ discard block |
||
371 | 371 | * @return string HTML content of the select element |
372 | 372 | */ |
373 | 373 | function yourls_html_select( $name, $options, $selected = '', $display = false, $label = '' ) { |
374 | - $html = "<select aria-label='$label' name='$name' id='$name' size='1'>\n"; |
|
375 | - foreach( $options as $value => $text ) { |
|
376 | - $html .= "<option value='$value' "; |
|
377 | - $html .= $selected == $value ? ' selected="selected"' : ''; |
|
378 | - $html .= ">$text</option>\n"; |
|
379 | - } |
|
380 | - $html .= "</select>\n"; |
|
381 | - $html = yourls_apply_filter( 'html_select', $html, $name, $options, $selected, $display ); |
|
382 | - if( $display ) |
|
383 | - echo $html; |
|
384 | - return $html; |
|
374 | + $html = "<select aria-label='$label' name='$name' id='$name' size='1'>\n"; |
|
375 | + foreach( $options as $value => $text ) { |
|
376 | + $html .= "<option value='$value' "; |
|
377 | + $html .= $selected == $value ? ' selected="selected"' : ''; |
|
378 | + $html .= ">$text</option>\n"; |
|
379 | + } |
|
380 | + $html .= "</select>\n"; |
|
381 | + $html = yourls_apply_filter( 'html_select', $html, $name, $options, $selected, $display ); |
|
382 | + if( $display ) |
|
383 | + echo $html; |
|
384 | + return $html; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -389,30 +389,30 @@ discard block |
||
389 | 389 | * |
390 | 390 | */ |
391 | 391 | function yourls_share_box( $longurl, $shorturl, $title = '', $text='', $shortlink_title = '', $share_title = '', $hidden = false ) { |
392 | - if ( $shortlink_title == '' ) |
|
393 | - $shortlink_title = '<h2>' . yourls__( 'Your short link' ) . '</h2>'; |
|
394 | - if ( $share_title == '' ) |
|
395 | - $share_title = '<h2>' . yourls__( 'Quick Share' ) . '</h2>'; |
|
396 | - |
|
397 | - // Allow plugins to short-circuit the whole function |
|
398 | - $pre = yourls_apply_filter( 'shunt_share_box', false ); |
|
399 | - if ( false !== $pre ) |
|
400 | - return $pre; |
|
401 | - |
|
402 | - $text = ( $text ? '"'.$text.'" ' : '' ); |
|
403 | - $title = ( $title ? "$title " : '' ); |
|
404 | - $share = yourls_esc_textarea( $title.$text.$shorturl ); |
|
405 | - $count = 280 - strlen( $share ); |
|
406 | - $hidden = ( $hidden ? 'style="display:none;"' : '' ); |
|
407 | - |
|
408 | - // Allow plugins to filter all data |
|
409 | - $data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' ); |
|
410 | - $data = yourls_apply_filter( 'share_box_data', $data ); |
|
411 | - extract( $data ); |
|
412 | - |
|
413 | - $_share = rawurlencode( $share ); |
|
414 | - $_url = rawurlencode( $shorturl ); |
|
415 | - ?> |
|
392 | + if ( $shortlink_title == '' ) |
|
393 | + $shortlink_title = '<h2>' . yourls__( 'Your short link' ) . '</h2>'; |
|
394 | + if ( $share_title == '' ) |
|
395 | + $share_title = '<h2>' . yourls__( 'Quick Share' ) . '</h2>'; |
|
396 | + |
|
397 | + // Allow plugins to short-circuit the whole function |
|
398 | + $pre = yourls_apply_filter( 'shunt_share_box', false ); |
|
399 | + if ( false !== $pre ) |
|
400 | + return $pre; |
|
401 | + |
|
402 | + $text = ( $text ? '"'.$text.'" ' : '' ); |
|
403 | + $title = ( $title ? "$title " : '' ); |
|
404 | + $share = yourls_esc_textarea( $title.$text.$shorturl ); |
|
405 | + $count = 280 - strlen( $share ); |
|
406 | + $hidden = ( $hidden ? 'style="display:none;"' : '' ); |
|
407 | + |
|
408 | + // Allow plugins to filter all data |
|
409 | + $data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' ); |
|
410 | + $data = yourls_apply_filter( 'share_box_data', $data ); |
|
411 | + extract( $data ); |
|
412 | + |
|
413 | + $_share = rawurlencode( $share ); |
|
414 | + $_url = rawurlencode( $shorturl ); |
|
415 | + ?> |
|
416 | 416 | |
417 | 417 | <div id="shareboxes" <?php echo $hidden; ?>> |
418 | 418 | |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | <a id="share_tw" href="https://twitter.com/intent/tweet?text=<?php echo $_share; ?>" title="<?php yourls_e( 'Tweet this!' ); ?>" onclick="share('tw');return false">Twitter</a> |
442 | 442 | <a id="share_fb" href="https://www.facebook.com/share.php?u=<?php echo $_url; ?>" title="<?php yourls_e( 'Share on Facebook' ); ?>" onclick="share('fb');return false;">Facebook</a> |
443 | 443 | <?php |
444 | - yourls_do_action( 'share_links', $longurl, $shorturl, $title, $text ); |
|
445 | - // Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn. |
|
446 | - ?> |
|
444 | + yourls_do_action( 'share_links', $longurl, $shorturl, $title, $text ); |
|
445 | + // Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn. |
|
446 | + ?> |
|
447 | 447 | </p> |
448 | 448 | </div> |
449 | 449 | |
@@ -461,20 +461,20 @@ discard block |
||
461 | 461 | function yourls_die( $message = '', $title = '', $header_code = 200 ) { |
462 | 462 | yourls_do_action( 'pre_yourls_die', $message, $title, $header_code ); |
463 | 463 | |
464 | - yourls_status_header( $header_code ); |
|
464 | + yourls_status_header( $header_code ); |
|
465 | 465 | |
466 | - if( !yourls_did_action( 'html_head' ) ) { |
|
467 | - yourls_html_head(); |
|
468 | - yourls_html_logo(); |
|
469 | - } |
|
470 | - echo yourls_apply_filter( 'die_title', "<h2>$title</h2>" ); |
|
471 | - echo yourls_apply_filter( 'die_message', "<p>$message</p>" ); |
|
466 | + if( !yourls_did_action( 'html_head' ) ) { |
|
467 | + yourls_html_head(); |
|
468 | + yourls_html_logo(); |
|
469 | + } |
|
470 | + echo yourls_apply_filter( 'die_title', "<h2>$title</h2>" ); |
|
471 | + echo yourls_apply_filter( 'die_message', "<p>$message</p>" ); |
|
472 | 472 | // Hook into 'yourls_die' to add more elements or messages to that page |
473 | - yourls_do_action( 'yourls_die' ); |
|
474 | - if( !yourls_did_action( 'html_footer' ) ) { |
|
475 | - yourls_html_footer(false); |
|
476 | - } |
|
477 | - die(); |
|
473 | + yourls_do_action( 'yourls_die' ); |
|
474 | + if( !yourls_did_action( 'html_footer' ) ) { |
|
475 | + yourls_html_footer(false); |
|
476 | + } |
|
477 | + die(); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -485,33 +485,33 @@ discard block |
||
485 | 485 | */ |
486 | 486 | function yourls_table_edit_row( $keyword ) { |
487 | 487 | $keyword = yourls_sanitize_keyword($keyword); |
488 | - $id = yourls_string2htmlid( $keyword ); // used as HTML #id |
|
489 | - $url = yourls_get_keyword_longurl( $keyword ); |
|
490 | - $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) ); |
|
491 | - $safe_url = yourls_esc_attr( rawurldecode( $url ) ); |
|
492 | - $safe_title = yourls_esc_attr( $title ); |
|
493 | - $safe_keyword = yourls_esc_attr( $keyword ); |
|
488 | + $id = yourls_string2htmlid( $keyword ); // used as HTML #id |
|
489 | + $url = yourls_get_keyword_longurl( $keyword ); |
|
490 | + $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) ); |
|
491 | + $safe_url = yourls_esc_attr( rawurldecode( $url ) ); |
|
492 | + $safe_title = yourls_esc_attr( $title ); |
|
493 | + $safe_keyword = yourls_esc_attr( $keyword ); |
|
494 | 494 | |
495 | 495 | // Make strings sprintf() safe: '%' -> '%%' |
496 | 496 | $safe_url = str_replace( '%', '%%', $safe_url ); |
497 | 497 | $safe_title = str_replace( '%', '%%', $safe_title ); |
498 | 498 | |
499 | - $www = yourls_link(); |
|
499 | + $www = yourls_link(); |
|
500 | 500 | |
501 | - $nonce = yourls_create_nonce( 'edit-save_'.$id ); |
|
501 | + $nonce = yourls_create_nonce( 'edit-save_'.$id ); |
|
502 | 502 | |
503 | - if( $url ) { |
|
504 | - $return = <<<RETURN |
|
503 | + if( $url ) { |
|
504 | + $return = <<<RETURN |
|
505 | 505 | <tr id="edit-$id" class="edit-row"><td colspan="5" class="edit-row"><strong>%s</strong>:<input type="text" id="edit-url-$id" name="edit-url-$id" value="$safe_url" class="text" size="70" /><br/><strong>%s</strong>: $www<input type="text" id="edit-keyword-$id" name="edit-keyword-$id" value="$safe_keyword" class="text" size="10" /><br/><strong>%s</strong>: <input type="text" id="edit-title-$id" name="edit-title-$id" value="$safe_title" class="text" size="60" /></td><td colspan="1"><input type="button" id="edit-submit-$id" name="edit-submit-$id" value="%s" title="%s" class="button" onclick="edit_link_save('$id');" /> <input type="button" id="edit-close-$id" name="edit-close-$id" value="%s" title="%s" class="button" onclick="edit_link_hide('$id');" /><input type="hidden" id="old_keyword_$id" value="$safe_keyword"/><input type="hidden" id="nonce_$id" value="$nonce"/></td></tr> |
506 | 506 | RETURN; |
507 | - $return = sprintf( $return, yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) ); |
|
508 | - } else { |
|
509 | - $return = '<tr class="edit-row notfound"><td colspan="6" class="edit-row notfound">' . yourls__( 'Error, URL not found' ) . '</td></tr>'; |
|
510 | - } |
|
507 | + $return = sprintf( $return, yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) ); |
|
508 | + } else { |
|
509 | + $return = '<tr class="edit-row notfound"><td colspan="6" class="edit-row notfound">' . yourls__( 'Error, URL not found' ) . '</td></tr>'; |
|
510 | + } |
|
511 | 511 | |
512 | - $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title ); |
|
512 | + $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title ); |
|
513 | 513 | |
514 | - return $return; |
|
514 | + return $return; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -521,116 +521,116 @@ discard block |
||
521 | 521 | */ |
522 | 522 | function yourls_table_add_row( $keyword, $url, $title = '', $ip, $clicks, $timestamp ) { |
523 | 523 | $keyword = yourls_sanitize_keyword($keyword); |
524 | - $id = yourls_string2htmlid( $keyword ); // used as HTML #id |
|
525 | - $shorturl = yourls_link( $keyword ); |
|
526 | - |
|
527 | - $statlink = yourls_statlink( $keyword ); |
|
528 | - |
|
529 | - $delete_link = yourls_nonce_url( 'delete-link_'.$id, |
|
530 | - yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
531 | - ); |
|
532 | - |
|
533 | - $edit_link = yourls_nonce_url( 'edit-link_'.$id, |
|
534 | - yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
535 | - ); |
|
536 | - |
|
537 | - // Action link buttons: the array |
|
538 | - $actions = array( |
|
539 | - 'stats' => array( |
|
540 | - 'href' => $statlink, |
|
541 | - 'id' => "statlink-$id", |
|
542 | - 'title' => yourls_esc_attr__( 'Stats' ), |
|
543 | - 'anchor' => yourls__( 'Stats' ), |
|
544 | - ), |
|
545 | - 'share' => array( |
|
546 | - 'href' => '', |
|
547 | - 'id' => "share-button-$id", |
|
548 | - 'title' => yourls_esc_attr__( 'Share' ), |
|
549 | - 'anchor' => yourls__( 'Share' ), |
|
550 | - 'onclick' => "toggle_share('$id');return false;", |
|
551 | - ), |
|
552 | - 'edit' => array( |
|
553 | - 'href' => $edit_link, |
|
554 | - 'id' => "edit-button-$id", |
|
555 | - 'title' => yourls_esc_attr__( 'Edit' ), |
|
556 | - 'anchor' => yourls__( 'Edit' ), |
|
557 | - 'onclick' => "edit_link_display('$id');return false;", |
|
558 | - ), |
|
559 | - 'delete' => array( |
|
560 | - 'href' => $delete_link, |
|
561 | - 'id' => "delete-button-$id", |
|
562 | - 'title' => yourls_esc_attr__( 'Delete' ), |
|
563 | - 'anchor' => yourls__( 'Delete' ), |
|
564 | - 'onclick' => "remove_link('$id');return false;", |
|
565 | - ) |
|
566 | - ); |
|
567 | - $actions = yourls_apply_filter( 'table_add_row_action_array', $actions, $keyword ); |
|
568 | - |
|
569 | - // Action link buttons: the HTML |
|
570 | - $action_links = ''; |
|
571 | - foreach( $actions as $key => $action ) { |
|
572 | - $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ; |
|
573 | - $action_links .= sprintf( '<a href="%s" id="%s" title="%s" class="%s" %s>%s</a>', |
|
574 | - $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor'] |
|
575 | - ); |
|
576 | - } |
|
577 | - $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp ); |
|
578 | - |
|
579 | - if( ! $title ) |
|
580 | - $title = $url; |
|
581 | - |
|
582 | - $protocol_warning = ''; |
|
583 | - if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) ) |
|
584 | - $protocol_warning = yourls_apply_filter( 'add_row_protocol_warning', '<span class="warning" title="' . yourls__( 'Not a common link' ) . '">★</span>' ); |
|
585 | - |
|
586 | - // Row cells: the array |
|
587 | - $cells = array( |
|
588 | - 'keyword' => array( |
|
589 | - 'template' => '<a href="%shorturl%">%keyword_html%</a>', |
|
590 | - 'shorturl' => yourls_esc_url( $shorturl ), |
|
591 | - 'keyword_html' => yourls_esc_html( $keyword ), |
|
592 | - ), |
|
593 | - 'url' => array( |
|
594 | - 'template' => '<a href="%long_url%" title="%title_attr%">%title_html%</a><br/><small>%warning%<a href="%long_url%">%long_url_html%</a></small>', |
|
595 | - 'long_url' => yourls_esc_url( $url ), |
|
596 | - 'title_attr' => yourls_esc_attr( $title ), |
|
597 | - 'title_html' => yourls_esc_html( yourls_trim_long_string( $title ) ), |
|
598 | - 'long_url_html' => yourls_esc_html( yourls_trim_long_string( $url ) ), |
|
599 | - 'warning' => $protocol_warning, |
|
600 | - ), |
|
601 | - 'timestamp' => array( |
|
602 | - 'template' => '<span class="timestamp" aria-hidden="true">%timestamp%</span> %date%', |
|
524 | + $id = yourls_string2htmlid( $keyword ); // used as HTML #id |
|
525 | + $shorturl = yourls_link( $keyword ); |
|
526 | + |
|
527 | + $statlink = yourls_statlink( $keyword ); |
|
528 | + |
|
529 | + $delete_link = yourls_nonce_url( 'delete-link_'.$id, |
|
530 | + yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
531 | + ); |
|
532 | + |
|
533 | + $edit_link = yourls_nonce_url( 'edit-link_'.$id, |
|
534 | + yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
535 | + ); |
|
536 | + |
|
537 | + // Action link buttons: the array |
|
538 | + $actions = array( |
|
539 | + 'stats' => array( |
|
540 | + 'href' => $statlink, |
|
541 | + 'id' => "statlink-$id", |
|
542 | + 'title' => yourls_esc_attr__( 'Stats' ), |
|
543 | + 'anchor' => yourls__( 'Stats' ), |
|
544 | + ), |
|
545 | + 'share' => array( |
|
546 | + 'href' => '', |
|
547 | + 'id' => "share-button-$id", |
|
548 | + 'title' => yourls_esc_attr__( 'Share' ), |
|
549 | + 'anchor' => yourls__( 'Share' ), |
|
550 | + 'onclick' => "toggle_share('$id');return false;", |
|
551 | + ), |
|
552 | + 'edit' => array( |
|
553 | + 'href' => $edit_link, |
|
554 | + 'id' => "edit-button-$id", |
|
555 | + 'title' => yourls_esc_attr__( 'Edit' ), |
|
556 | + 'anchor' => yourls__( 'Edit' ), |
|
557 | + 'onclick' => "edit_link_display('$id');return false;", |
|
558 | + ), |
|
559 | + 'delete' => array( |
|
560 | + 'href' => $delete_link, |
|
561 | + 'id' => "delete-button-$id", |
|
562 | + 'title' => yourls_esc_attr__( 'Delete' ), |
|
563 | + 'anchor' => yourls__( 'Delete' ), |
|
564 | + 'onclick' => "remove_link('$id');return false;", |
|
565 | + ) |
|
566 | + ); |
|
567 | + $actions = yourls_apply_filter( 'table_add_row_action_array', $actions, $keyword ); |
|
568 | + |
|
569 | + // Action link buttons: the HTML |
|
570 | + $action_links = ''; |
|
571 | + foreach( $actions as $key => $action ) { |
|
572 | + $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ; |
|
573 | + $action_links .= sprintf( '<a href="%s" id="%s" title="%s" class="%s" %s>%s</a>', |
|
574 | + $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor'] |
|
575 | + ); |
|
576 | + } |
|
577 | + $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp ); |
|
578 | + |
|
579 | + if( ! $title ) |
|
580 | + $title = $url; |
|
581 | + |
|
582 | + $protocol_warning = ''; |
|
583 | + if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) ) |
|
584 | + $protocol_warning = yourls_apply_filter( 'add_row_protocol_warning', '<span class="warning" title="' . yourls__( 'Not a common link' ) . '">★</span>' ); |
|
585 | + |
|
586 | + // Row cells: the array |
|
587 | + $cells = array( |
|
588 | + 'keyword' => array( |
|
589 | + 'template' => '<a href="%shorturl%">%keyword_html%</a>', |
|
590 | + 'shorturl' => yourls_esc_url( $shorturl ), |
|
591 | + 'keyword_html' => yourls_esc_html( $keyword ), |
|
592 | + ), |
|
593 | + 'url' => array( |
|
594 | + 'template' => '<a href="%long_url%" title="%title_attr%">%title_html%</a><br/><small>%warning%<a href="%long_url%">%long_url_html%</a></small>', |
|
595 | + 'long_url' => yourls_esc_url( $url ), |
|
596 | + 'title_attr' => yourls_esc_attr( $title ), |
|
597 | + 'title_html' => yourls_esc_html( yourls_trim_long_string( $title ) ), |
|
598 | + 'long_url_html' => yourls_esc_html( yourls_trim_long_string( $url ) ), |
|
599 | + 'warning' => $protocol_warning, |
|
600 | + ), |
|
601 | + 'timestamp' => array( |
|
602 | + 'template' => '<span class="timestamp" aria-hidden="true">%timestamp%</span> %date%', |
|
603 | 603 | 'timestamp' => $timestamp, |
604 | - 'date' => yourls_date_i18n( yourls_get_datetime_format('M d, Y H:i'), yourls_get_timestamp( $timestamp )), |
|
605 | - ), |
|
606 | - 'ip' => array( |
|
607 | - 'template' => '%ip%', |
|
608 | - 'ip' => $ip, |
|
609 | - ), |
|
610 | - 'clicks' => array( |
|
611 | - 'template' => '%clicks%', |
|
612 | - 'clicks' => yourls_number_format_i18n( $clicks, 0, '', '' ), |
|
613 | - ), |
|
614 | - 'actions' => array( |
|
615 | - 'template' => '%actions% <input type="hidden" id="keyword_%id%" value="%keyword%"/>', |
|
616 | - 'actions' => $action_links, |
|
617 | - 'id' => $id, |
|
618 | - 'keyword' => $keyword, |
|
619 | - ), |
|
620 | - ); |
|
621 | - $cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
622 | - |
|
623 | - // Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value. |
|
624 | - $row = "<tr id=\"id-$id\">"; |
|
625 | - foreach( $cells as $cell_id => $elements ) { |
|
626 | - $row .= sprintf( '<td class="%s" id="%s">', $cell_id, $cell_id . '-' . $id ); |
|
627 | - $row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] ); |
|
628 | - $row .= '</td>'; |
|
629 | - } |
|
630 | - $row .= "</tr>"; |
|
631 | - $row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
632 | - |
|
633 | - return $row; |
|
604 | + 'date' => yourls_date_i18n( yourls_get_datetime_format('M d, Y H:i'), yourls_get_timestamp( $timestamp )), |
|
605 | + ), |
|
606 | + 'ip' => array( |
|
607 | + 'template' => '%ip%', |
|
608 | + 'ip' => $ip, |
|
609 | + ), |
|
610 | + 'clicks' => array( |
|
611 | + 'template' => '%clicks%', |
|
612 | + 'clicks' => yourls_number_format_i18n( $clicks, 0, '', '' ), |
|
613 | + ), |
|
614 | + 'actions' => array( |
|
615 | + 'template' => '%actions% <input type="hidden" id="keyword_%id%" value="%keyword%"/>', |
|
616 | + 'actions' => $action_links, |
|
617 | + 'id' => $id, |
|
618 | + 'keyword' => $keyword, |
|
619 | + ), |
|
620 | + ); |
|
621 | + $cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
622 | + |
|
623 | + // Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value. |
|
624 | + $row = "<tr id=\"id-$id\">"; |
|
625 | + foreach( $cells as $cell_id => $elements ) { |
|
626 | + $row .= sprintf( '<td class="%s" id="%s">', $cell_id, $cell_id . '-' . $id ); |
|
627 | + $row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] ); |
|
628 | + $row .= '</td>'; |
|
629 | + } |
|
630 | + $row .= "</tr>"; |
|
631 | + $row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
632 | + |
|
633 | + return $row; |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -638,23 +638,23 @@ discard block |
||
638 | 638 | * |
639 | 639 | */ |
640 | 640 | function yourls_table_head() { |
641 | - $start = '<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"><thead><tr>'."\n"; |
|
642 | - echo yourls_apply_filter( 'table_head_start', $start ); |
|
643 | - |
|
644 | - $cells = yourls_apply_filter( 'table_head_cells', array( |
|
645 | - 'shorturl' => yourls__( 'Short URL' ), |
|
646 | - 'longurl' => yourls__( 'Original URL' ), |
|
647 | - 'date' => yourls__( 'Date' ), |
|
648 | - 'ip' => yourls__( 'IP' ), |
|
649 | - 'clicks' => yourls__( 'Clicks' ), |
|
650 | - 'actions' => yourls__( 'Actions' ) |
|
651 | - ) ); |
|
652 | - foreach( $cells as $k => $v ) { |
|
653 | - echo "<th id='main_table_head_$k'>$v</th>\n"; |
|
654 | - } |
|
655 | - |
|
656 | - $end = "</tr></thead>\n"; |
|
657 | - echo yourls_apply_filter( 'table_head_end', $end ); |
|
641 | + $start = '<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"><thead><tr>'."\n"; |
|
642 | + echo yourls_apply_filter( 'table_head_start', $start ); |
|
643 | + |
|
644 | + $cells = yourls_apply_filter( 'table_head_cells', array( |
|
645 | + 'shorturl' => yourls__( 'Short URL' ), |
|
646 | + 'longurl' => yourls__( 'Original URL' ), |
|
647 | + 'date' => yourls__( 'Date' ), |
|
648 | + 'ip' => yourls__( 'IP' ), |
|
649 | + 'clicks' => yourls__( 'Clicks' ), |
|
650 | + 'actions' => yourls__( 'Actions' ) |
|
651 | + ) ); |
|
652 | + foreach( $cells as $k => $v ) { |
|
653 | + echo "<th id='main_table_head_$k'>$v</th>\n"; |
|
654 | + } |
|
655 | + |
|
656 | + $end = "</tr></thead>\n"; |
|
657 | + echo yourls_apply_filter( 'table_head_end', $end ); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * |
663 | 663 | */ |
664 | 664 | function yourls_table_tbody_start() { |
665 | - echo yourls_apply_filter( 'table_tbody_start', '<tbody>' ); |
|
665 | + echo yourls_apply_filter( 'table_tbody_start', '<tbody>' ); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * |
671 | 671 | */ |
672 | 672 | function yourls_table_tbody_end() { |
673 | - echo yourls_apply_filter( 'table_tbody_end', '</tbody>' ); |
|
673 | + echo yourls_apply_filter( 'table_tbody_end', '</tbody>' ); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * |
679 | 679 | */ |
680 | 680 | function yourls_table_end() { |
681 | - echo yourls_apply_filter( 'table_end', '</table></main>' ); |
|
681 | + echo yourls_apply_filter( 'table_end', '</table></main>' ); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -686,12 +686,12 @@ discard block |
||
686 | 686 | * |
687 | 687 | */ |
688 | 688 | function yourls_html_link( $href, $title = '', $element = '' ) { |
689 | - if( !$title ) |
|
690 | - $title = $href; |
|
691 | - if( $element ) |
|
692 | - $element = sprintf( 'id="%s"', yourls_esc_attr( $element ) ); |
|
693 | - $link = sprintf( '<a href="%s" %s>%s</a>', yourls_esc_url( $href ), $element, yourls_esc_html( $title ) ); |
|
694 | - echo yourls_apply_filter( 'html_link', $link ); |
|
689 | + if( !$title ) |
|
690 | + $title = $href; |
|
691 | + if( $element ) |
|
692 | + $element = sprintf( 'id="%s"', yourls_esc_attr( $element ) ); |
|
693 | + $link = sprintf( '<a href="%s" %s>%s</a>', yourls_esc_url( $href ), $element, yourls_esc_html( $title ) ); |
|
694 | + echo yourls_apply_filter( 'html_link', $link ); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -699,20 +699,20 @@ discard block |
||
699 | 699 | * |
700 | 700 | */ |
701 | 701 | function yourls_login_screen( $error_msg = '' ) { |
702 | - yourls_html_head( 'login' ); |
|
702 | + yourls_html_head( 'login' ); |
|
703 | 703 | |
704 | - $action = ( isset( $_GET['action'] ) && $_GET['action'] == 'logout' ? '?' : '' ); |
|
704 | + $action = ( isset( $_GET['action'] ) && $_GET['action'] == 'logout' ? '?' : '' ); |
|
705 | 705 | |
706 | - yourls_html_logo(); |
|
707 | - ?> |
|
706 | + yourls_html_logo(); |
|
707 | + ?> |
|
708 | 708 | <div id="login"> |
709 | 709 | <form method="post" action="<?php echo $action; ?>"> <?php // reset any QUERY parameters ?> |
710 | 710 | <?php |
711 | - if( !empty( $error_msg ) ) { |
|
712 | - echo '<p class="error">'.$error_msg.'</p>'; |
|
713 | - } |
|
714 | - yourls_do_action( 'login_form_top' ); |
|
715 | - ?> |
|
711 | + if( !empty( $error_msg ) ) { |
|
712 | + echo '<p class="error">'.$error_msg.'</p>'; |
|
713 | + } |
|
714 | + yourls_do_action( 'login_form_top' ); |
|
715 | + ?> |
|
716 | 716 | <p> |
717 | 717 | <label for="username"><?php yourls_e( 'Username' ); ?></label><br /> |
718 | 718 | <input type="text" id="username" name="username" size="30" class="text" /> |
@@ -722,20 +722,20 @@ discard block |
||
722 | 722 | <input type="password" id="password" name="password" size="30" class="text" /> |
723 | 723 | </p> |
724 | 724 | <?php |
725 | - yourls_do_action( 'login_form_bottom' ); |
|
726 | - ?> |
|
725 | + yourls_do_action( 'login_form_bottom' ); |
|
726 | + ?> |
|
727 | 727 | <p style="text-align: right;"> |
728 | 728 | <input type="submit" id="submit" name="submit" value="<?php yourls_e( 'Login' ); ?>" class="button" /> |
729 | 729 | </p> |
730 | 730 | <?php |
731 | - yourls_do_action( 'login_form_end' ); |
|
732 | - ?> |
|
731 | + yourls_do_action( 'login_form_end' ); |
|
732 | + ?> |
|
733 | 733 | </form> |
734 | 734 | <script type="text/javascript">$('#username').focus();</script> |
735 | 735 | </div> |
736 | 736 | <?php |
737 | - yourls_html_footer(); |
|
738 | - die(); |
|
737 | + yourls_html_footer(); |
|
738 | + die(); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
@@ -744,71 +744,71 @@ discard block |
||
744 | 744 | */ |
745 | 745 | function yourls_html_menu() { |
746 | 746 | |
747 | - // Build menu links |
|
748 | - if( defined( 'YOURLS_USER' ) ) { |
|
749 | - $logout_link = yourls_apply_filter( 'logout_link', sprintf( yourls__('Hello <strong>%s</strong>'), YOURLS_USER ) . ' (<a href="' . yourls_admin_url() . '?action=logout" title="' . yourls_esc_attr__( 'Logout' ) . '">' . yourls__( 'Logout' ) . '</a>)' ); |
|
750 | - } else { |
|
751 | - $logout_link = yourls_apply_filter( 'logout_link', '' ); |
|
752 | - } |
|
753 | - $help_link = yourls_apply_filter( 'help_link', '<a href="' . yourls_site_url( false ) .'/readme.html">' . yourls__( 'Help' ) . '</a>' ); |
|
754 | - |
|
755 | - $admin_links = array(); |
|
756 | - $admin_sublinks = array(); |
|
757 | - |
|
758 | - $admin_links['admin'] = array( |
|
759 | - 'url' => yourls_admin_url( 'index.php' ), |
|
760 | - 'title' => yourls__( 'Go to the admin interface' ), |
|
761 | - 'anchor' => yourls__( 'Admin interface' ) |
|
762 | - ); |
|
763 | - |
|
764 | - if( yourls_is_admin() ) { |
|
765 | - $admin_links['tools'] = array( |
|
766 | - 'url' => yourls_admin_url( 'tools.php' ), |
|
767 | - 'anchor' => yourls__( 'Tools' ) |
|
768 | - ); |
|
769 | - $admin_links['plugins'] = array( |
|
770 | - 'url' => yourls_admin_url( 'plugins.php' ), |
|
771 | - 'anchor' => yourls__( 'Manage Plugins' ) |
|
772 | - ); |
|
773 | - $admin_sublinks['plugins'] = yourls_list_plugin_admin_pages(); |
|
774 | - } |
|
775 | - |
|
776 | - $admin_links = yourls_apply_filter( 'admin_links', $admin_links ); |
|
777 | - $admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks ); |
|
778 | - |
|
779 | - // Now output menu |
|
780 | - echo '<nav role="navigation"><ul id="admin_menu">'."\n"; |
|
781 | - if ( yourls_is_private() && !empty( $logout_link ) ) |
|
782 | - echo '<li id="admin_menu_logout_link">' . $logout_link .'</li>'; |
|
783 | - |
|
784 | - foreach( (array)$admin_links as $link => $ar ) { |
|
785 | - if( isset( $ar['url'] ) ) { |
|
786 | - $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
|
787 | - $title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
|
788 | - printf( '<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor ); |
|
789 | - } |
|
790 | - // Output submenu if any. TODO: clean up, too many code duplicated here |
|
791 | - if( isset( $admin_sublinks[$link] ) ) { |
|
792 | - echo "<ul>\n"; |
|
793 | - foreach( $admin_sublinks[$link] as $link => $ar ) { |
|
794 | - if( isset( $ar['url'] ) ) { |
|
795 | - $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
|
796 | - $title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
|
797 | - printf( '<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor ); |
|
798 | - } |
|
799 | - } |
|
800 | - echo "</ul>\n"; |
|
801 | - } |
|
802 | - } |
|
803 | - |
|
804 | - if ( isset( $help_link ) ) |
|
805 | - echo '<li id="admin_menu_help_link">' . $help_link .'</li>'; |
|
806 | - |
|
807 | - yourls_do_action( 'admin_menu' ); |
|
808 | - echo "</ul></nav>\n"; |
|
809 | - yourls_do_action( 'admin_notices' ); |
|
810 | - yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice' |
|
811 | - /* |
|
747 | + // Build menu links |
|
748 | + if( defined( 'YOURLS_USER' ) ) { |
|
749 | + $logout_link = yourls_apply_filter( 'logout_link', sprintf( yourls__('Hello <strong>%s</strong>'), YOURLS_USER ) . ' (<a href="' . yourls_admin_url() . '?action=logout" title="' . yourls_esc_attr__( 'Logout' ) . '">' . yourls__( 'Logout' ) . '</a>)' ); |
|
750 | + } else { |
|
751 | + $logout_link = yourls_apply_filter( 'logout_link', '' ); |
|
752 | + } |
|
753 | + $help_link = yourls_apply_filter( 'help_link', '<a href="' . yourls_site_url( false ) .'/readme.html">' . yourls__( 'Help' ) . '</a>' ); |
|
754 | + |
|
755 | + $admin_links = array(); |
|
756 | + $admin_sublinks = array(); |
|
757 | + |
|
758 | + $admin_links['admin'] = array( |
|
759 | + 'url' => yourls_admin_url( 'index.php' ), |
|
760 | + 'title' => yourls__( 'Go to the admin interface' ), |
|
761 | + 'anchor' => yourls__( 'Admin interface' ) |
|
762 | + ); |
|
763 | + |
|
764 | + if( yourls_is_admin() ) { |
|
765 | + $admin_links['tools'] = array( |
|
766 | + 'url' => yourls_admin_url( 'tools.php' ), |
|
767 | + 'anchor' => yourls__( 'Tools' ) |
|
768 | + ); |
|
769 | + $admin_links['plugins'] = array( |
|
770 | + 'url' => yourls_admin_url( 'plugins.php' ), |
|
771 | + 'anchor' => yourls__( 'Manage Plugins' ) |
|
772 | + ); |
|
773 | + $admin_sublinks['plugins'] = yourls_list_plugin_admin_pages(); |
|
774 | + } |
|
775 | + |
|
776 | + $admin_links = yourls_apply_filter( 'admin_links', $admin_links ); |
|
777 | + $admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks ); |
|
778 | + |
|
779 | + // Now output menu |
|
780 | + echo '<nav role="navigation"><ul id="admin_menu">'."\n"; |
|
781 | + if ( yourls_is_private() && !empty( $logout_link ) ) |
|
782 | + echo '<li id="admin_menu_logout_link">' . $logout_link .'</li>'; |
|
783 | + |
|
784 | + foreach( (array)$admin_links as $link => $ar ) { |
|
785 | + if( isset( $ar['url'] ) ) { |
|
786 | + $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
|
787 | + $title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
|
788 | + printf( '<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor ); |
|
789 | + } |
|
790 | + // Output submenu if any. TODO: clean up, too many code duplicated here |
|
791 | + if( isset( $admin_sublinks[$link] ) ) { |
|
792 | + echo "<ul>\n"; |
|
793 | + foreach( $admin_sublinks[$link] as $link => $ar ) { |
|
794 | + if( isset( $ar['url'] ) ) { |
|
795 | + $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
|
796 | + $title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
|
797 | + printf( '<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor ); |
|
798 | + } |
|
799 | + } |
|
800 | + echo "</ul>\n"; |
|
801 | + } |
|
802 | + } |
|
803 | + |
|
804 | + if ( isset( $help_link ) ) |
|
805 | + echo '<li id="admin_menu_help_link">' . $help_link .'</li>'; |
|
806 | + |
|
807 | + yourls_do_action( 'admin_menu' ); |
|
808 | + echo "</ul></nav>\n"; |
|
809 | + yourls_do_action( 'admin_notices' ); |
|
810 | + yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice' |
|
811 | + /* |
|
812 | 812 | To display a notice: |
813 | 813 | $message = "<div>OMG, dude, I mean!</div>" ); |
814 | 814 | yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } ); |
@@ -820,9 +820,9 @@ discard block |
||
820 | 820 | * |
821 | 821 | */ |
822 | 822 | function yourls_add_notice( $message, $style = 'notice' ) { |
823 | - // Escape single quotes in $message to avoid breaking the anonymous function |
|
824 | - $message = yourls_notice_box( strtr( $message, array( "'" => "\'" ) ), $style ); |
|
825 | - yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } ); |
|
823 | + // Escape single quotes in $message to avoid breaking the anonymous function |
|
824 | + $message = yourls_notice_box( strtr( $message, array( "'" => "\'" ) ), $style ); |
|
825 | + yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } ); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | * |
831 | 831 | */ |
832 | 832 | function yourls_notice_box( $message, $style = 'notice' ) { |
833 | - return <<<HTML |
|
833 | + return <<<HTML |
|
834 | 834 | <div class="$style"> |
835 | 835 | <p>$message</p> |
836 | 836 | </div> |
@@ -848,12 +848,12 @@ discard block |
||
848 | 848 | */ |
849 | 849 | function yourls_page( $page ) { |
850 | 850 | if( !yourls_is_page($page)) { |
851 | - yourls_die( yourls_s('Page "%1$s" not found', $page), yourls__('Not found'), 404 ); |
|
851 | + yourls_die( yourls_s('Page "%1$s" not found', $page), yourls__('Not found'), 404 ); |
|
852 | 852 | } |
853 | 853 | |
854 | - yourls_do_action( 'pre_page', $page ); |
|
855 | - include_once( YOURLS_PAGEDIR . "/$page.php" ); |
|
856 | - yourls_do_action( 'post_page', $page ); |
|
854 | + yourls_do_action( 'pre_page', $page ); |
|
855 | + include_once( YOURLS_PAGEDIR . "/$page.php" ); |
|
856 | + yourls_do_action( 'post_page', $page ); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -865,24 +865,24 @@ discard block |
||
865 | 865 | * @since 1.6 |
866 | 866 | */ |
867 | 867 | function yourls_html_language_attributes() { |
868 | - $attributes = array(); |
|
869 | - $output = ''; |
|
870 | - |
|
871 | - $attributes[] = ( yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"' ); |
|
872 | - |
|
873 | - $doctype = yourls_apply_filter( 'html_language_attributes_doctype', 'html' ); |
|
874 | - // Experimental: get HTML lang from locale. Should work. Convert fr_FR -> fr-FR |
|
875 | - if ( $lang = str_replace( '_', '-', yourls_get_locale() ) ) { |
|
876 | - if( $doctype == 'xhtml' ) { |
|
877 | - $attributes[] = "xml:lang=\"$lang\""; |
|
878 | - } else { |
|
879 | - $attributes[] = "lang=\"$lang\""; |
|
880 | - } |
|
881 | - } |
|
882 | - |
|
883 | - $output = implode( ' ', $attributes ); |
|
884 | - $output = yourls_apply_filter( 'html_language_attributes', $output ); |
|
885 | - echo $output; |
|
868 | + $attributes = array(); |
|
869 | + $output = ''; |
|
870 | + |
|
871 | + $attributes[] = ( yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"' ); |
|
872 | + |
|
873 | + $doctype = yourls_apply_filter( 'html_language_attributes_doctype', 'html' ); |
|
874 | + // Experimental: get HTML lang from locale. Should work. Convert fr_FR -> fr-FR |
|
875 | + if ( $lang = str_replace( '_', '-', yourls_get_locale() ) ) { |
|
876 | + if( $doctype == 'xhtml' ) { |
|
877 | + $attributes[] = "xml:lang=\"$lang\""; |
|
878 | + } else { |
|
879 | + $attributes[] = "lang=\"$lang\""; |
|
880 | + } |
|
881 | + } |
|
882 | + |
|
883 | + $output = implode( ' ', $attributes ); |
|
884 | + $output = yourls_apply_filter( 'html_language_attributes', $output ); |
|
885 | + echo $output; |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -891,16 +891,16 @@ discard block |
||
891 | 891 | * @since 1.6 |
892 | 892 | */ |
893 | 893 | function yourls_l10n_calendar_strings() { |
894 | - echo "\n<script>\n"; |
|
895 | - echo "var l10n_cal_month = " . json_encode( array_values( yourls_l10n_months() ) ) . ";\n"; |
|
896 | - echo "var l10n_cal_days = " . json_encode( array_values( yourls_l10n_weekday_initial() ) ) . ";\n"; |
|
897 | - echo "var l10n_cal_today = \"" . yourls_esc_js( yourls__( 'Today' ) ) . "\";\n"; |
|
898 | - echo "var l10n_cal_close = \"" . yourls_esc_js( yourls__( 'Close' ) ) . "\";\n"; |
|
899 | - echo "</script>\n"; |
|
900 | - |
|
901 | - // Dummy returns, to initialize l10n strings used in the calendar |
|
902 | - yourls__( 'Today' ); |
|
903 | - yourls__( 'Close' ); |
|
894 | + echo "\n<script>\n"; |
|
895 | + echo "var l10n_cal_month = " . json_encode( array_values( yourls_l10n_months() ) ) . ";\n"; |
|
896 | + echo "var l10n_cal_days = " . json_encode( array_values( yourls_l10n_weekday_initial() ) ) . ";\n"; |
|
897 | + echo "var l10n_cal_today = \"" . yourls_esc_js( yourls__( 'Today' ) ) . "\";\n"; |
|
898 | + echo "var l10n_cal_close = \"" . yourls_esc_js( yourls__( 'Close' ) ) . "\";\n"; |
|
899 | + echo "</script>\n"; |
|
900 | + |
|
901 | + // Dummy returns, to initialize l10n strings used in the calendar |
|
902 | + yourls__( 'Today' ); |
|
903 | + yourls__( 'Close' ); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | |
@@ -911,13 +911,13 @@ discard block |
||
911 | 911 | */ |
912 | 912 | function yourls_new_core_version_notice() { |
913 | 913 | |
914 | - $checks = yourls_get_option( 'core_version_checks' ); |
|
914 | + $checks = yourls_get_option( 'core_version_checks' ); |
|
915 | 915 | $latest = isset($checks->last_result->latest) ? yourls_sanitize_version($checks->last_result->latest) : false; |
916 | 916 | |
917 | - if( $latest AND version_compare( $latest, YOURLS_VERSION, '>' ) ) { |
|
918 | - $msg = yourls_s( '<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $latest ); |
|
919 | - yourls_add_notice( $msg ); |
|
920 | - } |
|
917 | + if( $latest AND version_compare( $latest, YOURLS_VERSION, '>' ) ) { |
|
918 | + $msg = yourls_s( '<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $latest ); |
|
919 | + yourls_add_notice( $msg ); |
|
920 | + } |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -929,12 +929,12 @@ discard block |
||
929 | 929 | */ |
930 | 930 | function yourls_content_type_header( $type ) { |
931 | 931 | yourls_do_action( 'content_type_header', $type ); |
932 | - if( !headers_sent() ) { |
|
933 | - $charset = yourls_apply_filter( 'content_type_header_charset', 'utf-8' ); |
|
934 | - header( "Content-Type: $type; charset=$charset" ); |
|
935 | - return true; |
|
936 | - } |
|
937 | - return false; |
|
932 | + if( !headers_sent() ) { |
|
933 | + $charset = yourls_apply_filter( 'content_type_header_charset', 'utf-8' ); |
|
934 | + header( "Content-Type: $type; charset=$charset" ); |
|
935 | + return true; |
|
936 | + } |
|
937 | + return false; |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | /** |
@@ -949,15 +949,15 @@ discard block |
||
949 | 949 | * @return string Search string |
950 | 950 | */ |
951 | 951 | function yourls_get_search_text() { |
952 | - $search = ''; |
|
953 | - if( isset( $_GET['search_protocol'] ) ) |
|
954 | - $search .= $_GET['search_protocol']; |
|
955 | - if( isset( $_GET['search_slashes'] ) ) |
|
956 | - $search .= $_GET['search_slashes']; |
|
957 | - if( isset( $_GET['search'] ) ) |
|
958 | - $search .= $_GET['search']; |
|
959 | - |
|
960 | - return htmlspecialchars( trim( $search ) ); |
|
952 | + $search = ''; |
|
953 | + if( isset( $_GET['search_protocol'] ) ) |
|
954 | + $search .= $_GET['search_protocol']; |
|
955 | + if( isset( $_GET['search_slashes'] ) ) |
|
956 | + $search .= $_GET['search_slashes']; |
|
957 | + if( isset( $_GET['search'] ) ) |
|
958 | + $search .= $_GET['search']; |
|
959 | + |
|
960 | + return htmlspecialchars( trim( $search ) ); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -5,16 +5,16 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | function yourls_html_logo() { |
8 | - yourls_do_action( 'pre_html_logo' ); |
|
8 | + yourls_do_action('pre_html_logo'); |
|
9 | 9 | ?> |
10 | 10 | <header role="banner"> |
11 | 11 | <h1> |
12 | - <a href="<?php echo yourls_admin_url( 'index.php' ) ?>" title="YOURLS"><span>YOURLS</span>: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener<br/> |
|
12 | + <a href="<?php echo yourls_admin_url('index.php') ?>" title="YOURLS"><span>YOURLS</span>: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener<br/> |
|
13 | 13 | <img src="<?php yourls_site_url(); ?>/images/yourls-logo.svg" id="yourls-logo" alt="YOURLS" title="YOURLS" /></a> |
14 | 14 | </h1> |
15 | 15 | </header> |
16 | 16 | <?php |
17 | - yourls_do_action( 'html_logo' ); |
|
17 | + yourls_do_action('html_logo'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | * @param string $context Context of the page (stats, index, infos, ...) |
24 | 24 | * @param string $title HTML title of the page |
25 | 25 | */ |
26 | -function yourls_html_head( $context = 'index', $title = '' ) { |
|
26 | +function yourls_html_head($context = 'index', $title = '') { |
|
27 | 27 | |
28 | - yourls_do_action( 'pre_html_head', $context, $title ); |
|
28 | + yourls_do_action('pre_html_head', $context, $title); |
|
29 | 29 | |
30 | 30 | // All components to false, except when specified true |
31 | 31 | $share = $insert = $tablesorter = $tabs = $cal = $charts = false; |
32 | 32 | |
33 | 33 | // Load components as needed |
34 | - switch ( $context ) { |
|
34 | + switch ($context) { |
|
35 | 35 | case 'infos': |
36 | 36 | $share = $tabs = $charts = true; |
37 | 37 | break; |
@@ -57,33 +57,33 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | // Force no cache for all admin pages |
60 | - if( yourls_is_admin() && !headers_sent() ) { |
|
61 | - header( 'Expires: Thu, 23 Mar 1972 07:00:00 GMT' ); |
|
62 | - header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
|
63 | - header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); |
|
64 | - header( 'Pragma: no-cache' ); |
|
65 | - yourls_content_type_header( yourls_apply_filter( 'html_head_content-type', 'text/html' ) ); |
|
66 | - yourls_do_action( 'admin_headers', $context, $title ); |
|
60 | + if (yourls_is_admin() && !headers_sent()) { |
|
61 | + header('Expires: Thu, 23 Mar 1972 07:00:00 GMT'); |
|
62 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
63 | + header('Cache-Control: no-cache, must-revalidate, max-age=0'); |
|
64 | + header('Pragma: no-cache'); |
|
65 | + yourls_content_type_header(yourls_apply_filter('html_head_content-type', 'text/html')); |
|
66 | + yourls_do_action('admin_headers', $context, $title); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Store page context |
70 | 70 | yourls_set_html_context($context); |
71 | 71 | |
72 | 72 | // Body class |
73 | - $bodyclass = yourls_apply_filter( 'bodyclass', '' ); |
|
74 | - $bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' ); |
|
73 | + $bodyclass = yourls_apply_filter('bodyclass', ''); |
|
74 | + $bodyclass .= (yourls_is_mobile_device() ? 'mobile' : 'desktop'); |
|
75 | 75 | |
76 | 76 | // Page title |
77 | - $_title = 'YOURLS — Your Own URL Shortener | ' . yourls_link(); |
|
78 | - $title = $title ? $title . " « " . $_title : $_title; |
|
79 | - $title = yourls_apply_filter( 'html_title', $title, $context ); |
|
77 | + $_title = 'YOURLS — Your Own URL Shortener | '.yourls_link(); |
|
78 | + $title = $title ? $title." « ".$_title : $_title; |
|
79 | + $title = yourls_apply_filter('html_title', $title, $context); |
|
80 | 80 | |
81 | 81 | ?> |
82 | 82 | <!DOCTYPE html> |
83 | 83 | <html <?php yourls_html_language_attributes(); ?>> |
84 | 84 | <head> |
85 | 85 | <title><?php echo $title ?></title> |
86 | - <meta http-equiv="Content-Type" content="<?php echo yourls_apply_filter( 'html_head_meta_content-type', 'text/html; charset=utf-8' ); ?>" /> |
|
86 | + <meta http-equiv="Content-Type" content="<?php echo yourls_apply_filter('html_head_meta_content-type', 'text/html; charset=utf-8'); ?>" /> |
|
87 | 87 | <meta name="generator" content="YOURLS <?php echo YOURLS_VERSION ?>" /> |
88 | 88 | <meta name="description" content="YOURLS » Your Own URL Shortener' | <?php yourls_site_url(); ?>" /> |
89 | 89 | <?php yourls_do_action('html_head_meta', $context); ?> |
@@ -92,29 +92,29 @@ discard block |
||
92 | 92 | <script src="<?php yourls_site_url(); ?>/js/common.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
93 | 93 | <script src="<?php yourls_site_url(); ?>/js/jquery.notifybar.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
94 | 94 | <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/style.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
95 | - <?php if ( $tabs ) { ?> |
|
95 | + <?php if ($tabs) { ?> |
|
96 | 96 | <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/infos.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
97 | 97 | <script src="<?php yourls_site_url(); ?>/js/infos.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
98 | 98 | <?php } ?> |
99 | - <?php if ( $tablesorter ) { ?> |
|
99 | + <?php if ($tablesorter) { ?> |
|
100 | 100 | <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/tablesorter.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
101 | 101 | <script src="<?php yourls_site_url(); ?>/js/jquery-3.tablesorter.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
102 | 102 | <script src="<?php yourls_site_url(); ?>/js/tablesorte.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
103 | 103 | <?php } ?> |
104 | - <?php if ( $insert ) { ?> |
|
104 | + <?php if ($insert) { ?> |
|
105 | 105 | <script src="<?php yourls_site_url(); ?>/js/insert.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
106 | 106 | <?php } ?> |
107 | - <?php if ( $share ) { ?> |
|
107 | + <?php if ($share) { ?> |
|
108 | 108 | <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
109 | 109 | <script src="<?php yourls_site_url(); ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
110 | 110 | <script src="<?php yourls_site_url(); ?>/js/clipboard.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
111 | 111 | <?php } ?> |
112 | - <?php if ( $cal ) { ?> |
|
112 | + <?php if ($cal) { ?> |
|
113 | 113 | <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/cal.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" /> |
114 | 114 | <?php yourls_l10n_calendar_strings(); ?> |
115 | 115 | <script src="<?php yourls_site_url(); ?>/js/jquery.cal.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script> |
116 | 116 | <?php } ?> |
117 | - <?php if ( $charts ) { ?> |
|
117 | + <?php if ($charts) { ?> |
|
118 | 118 | <script type="text/javascript" src="https://www.google.com/jsapi"></script> |
119 | 119 | <script type="text/javascript"> |
120 | 120 | google.load('visualization', '1.0', {'packages':['corechart', 'geochart']}); |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | <?php } ?> |
123 | 123 | <script type="text/javascript"> |
124 | 124 | //<![CDATA[ |
125 | - var ajaxurl = '<?php echo yourls_admin_url( 'admin-ajax.php' ); ?>'; |
|
125 | + var ajaxurl = '<?php echo yourls_admin_url('admin-ajax.php'); ?>'; |
|
126 | 126 | //]]> |
127 | 127 | </script> |
128 | - <?php yourls_do_action( 'html_head', $context ); ?> |
|
128 | + <?php yourls_do_action('html_head', $context); ?> |
|
129 | 129 | </head> |
130 | 130 | <body class="<?php echo $context; ?> <?php echo $bodyclass; ?>"> |
131 | 131 | <div id="wrap"> |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @return void |
143 | 143 | */ |
144 | 144 | function yourls_html_footer($can_query = true) { |
145 | - if($can_query & yourls_get_debug_mode()) { |
|
145 | + if ($can_query & yourls_get_debug_mode()) { |
|
146 | 146 | $num_queries = yourls_get_num_queries(); |
147 | - $num_queries = ' – '. sprintf( yourls_n( '1 query', '%s queries', $num_queries ), $num_queries ); |
|
147 | + $num_queries = ' – '.sprintf(yourls_n('1 query', '%s queries', $num_queries), $num_queries); |
|
148 | 148 | } else { |
149 | 149 | $num_queries = ''; |
150 | 150 | } |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | </div><?php // wrap ?> |
154 | 154 | <footer id="footer" role="contentinfo"><p> |
155 | 155 | <?php |
156 | - $footer = yourls_s( 'Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v ' . YOURLS_VERSION ); |
|
156 | + $footer = yourls_s('Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v '.YOURLS_VERSION); |
|
157 | 157 | $footer .= $num_queries; |
158 | - echo yourls_apply_filter( 'html_footer_text', $footer ); |
|
158 | + echo yourls_apply_filter('html_footer_text', $footer); |
|
159 | 159 | ?> |
160 | 160 | </p></footer> |
161 | - <?php if( yourls_get_debug_mode() ) { |
|
161 | + <?php if (yourls_get_debug_mode()) { |
|
162 | 162 | echo '<div style="text-align:left"><pre>'; |
163 | - echo join( "\n", yourls_get_debug_log() ); |
|
163 | + echo join("\n", yourls_get_debug_log()); |
|
164 | 164 | echo '</pre></div>'; |
165 | 165 | } ?> |
166 | - <?php yourls_do_action( 'html_footer', yourls_get_html_context() ); ?> |
|
166 | + <?php yourls_do_action('html_footer', yourls_get_html_context()); ?> |
|
167 | 167 | </body> |
168 | 168 | </html> |
169 | 169 | <?php |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * @param string $url URL to prefill the input with |
176 | 176 | * @param string $keyword Keyword to prefill the input with |
177 | 177 | */ |
178 | -function yourls_html_addnew( $url = '', $keyword = '' ) { |
|
179 | - $pre = yourls_apply_filter( 'shunt_html_addnew', false, $url, $keyword ); |
|
180 | - if ( false !== $pre ) { |
|
178 | +function yourls_html_addnew($url = '', $keyword = '') { |
|
179 | + $pre = yourls_apply_filter('shunt_html_addnew', false, $url, $keyword); |
|
180 | + if (false !== $pre) { |
|
181 | 181 | return $pre; |
182 | 182 | } |
183 | 183 | ?> |
@@ -186,17 +186,17 @@ discard block |
||
186 | 186 | <div> |
187 | 187 | <form id="new_url_form" action="" method="get"> |
188 | 188 | <div> |
189 | - <label for="add-url"><strong><?php yourls_e( 'Enter the URL' ); ?></strong></label>: |
|
189 | + <label for="add-url"><strong><?php yourls_e('Enter the URL'); ?></strong></label>: |
|
190 | 190 | <input type="text" id="add-url" name="url" value="<?php echo $url; ?>" class="text" size="80" placeholder="https://" /> |
191 | - <label for="add-keyword"><?php yourls_e( 'Optional '); ?> : <strong><?php yourls_e('Custom short URL'); ?></strong></label>: |
|
191 | + <label for="add-keyword"><?php yourls_e('Optional '); ?> : <strong><?php yourls_e('Custom short URL'); ?></strong></label>: |
|
192 | 192 | <input type="text" id="add-keyword" name="keyword" value="<?php echo $keyword; ?>" class="text" size="8" /> |
193 | - <?php yourls_nonce_field( 'add_url', 'nonce-add' ); ?> |
|
194 | - <input type="button" id="add-button" name="add-button" value="<?php yourls_e( 'Shorten The URL' ); ?>" class="button" onclick="add_link();" /> |
|
193 | + <?php yourls_nonce_field('add_url', 'nonce-add'); ?> |
|
194 | + <input type="button" id="add-button" name="add-button" value="<?php yourls_e('Shorten The URL'); ?>" class="button" onclick="add_link();" /> |
|
195 | 195 | </div> |
196 | 196 | </form> |
197 | 197 | <div id="feedback" style="display:none"></div> |
198 | 198 | </div> |
199 | - <?php yourls_do_action( 'html_addnew' ); ?> |
|
199 | + <?php yourls_do_action('html_addnew'); ?> |
|
200 | 200 | </div> |
201 | 201 | <?php |
202 | 202 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param array $params Array of all required parameters |
210 | 210 | * @return string Result |
211 | 211 | */ |
212 | -function yourls_html_tfooter( $params = array() ) { |
|
212 | +function yourls_html_tfooter($params = array()) { |
|
213 | 213 | // Manually extract all parameters from the array. We prefer doing it this way, over using extract(), |
214 | 214 | // to make things clearer and more explicit about what var is used. |
215 | 215 | $search = $params['search']; |
@@ -236,54 +236,54 @@ discard block |
||
236 | 236 | <?php |
237 | 237 | |
238 | 238 | // First search control: text to search |
239 | - $_input = '<input aria-label="' .yourls__( 'Search for' ). '" type="text" name="search" class="text" size="12" value="' . yourls_esc_attr( $search_text ) . '" />'; |
|
239 | + $_input = '<input aria-label="'.yourls__('Search for').'" type="text" name="search" class="text" size="12" value="'.yourls_esc_attr($search_text).'" />'; |
|
240 | 240 | $_options = array( |
241 | - 'all' => yourls__( 'All fields' ), |
|
242 | - 'keyword' => yourls__( 'Short URL' ), |
|
243 | - 'url' => yourls__( 'URL' ), |
|
244 | - 'title' => yourls__( 'Title' ), |
|
245 | - 'ip' => yourls__( 'IP' ), |
|
241 | + 'all' => yourls__('All fields'), |
|
242 | + 'keyword' => yourls__('Short URL'), |
|
243 | + 'url' => yourls__('URL'), |
|
244 | + 'title' => yourls__('Title'), |
|
245 | + 'ip' => yourls__('IP'), |
|
246 | 246 | ); |
247 | - $_select = yourls_html_select( 'search_in', $_options, $search_in, false, yourls__( 'Search in' ) ); |
|
247 | + $_select = yourls_html_select('search_in', $_options, $search_in, false, yourls__('Search in')); |
|
248 | 248 | /* //translators: "Search for <input field with text to search> in <select dropdown with URL, title...>" */ |
249 | - yourls_se( 'Search for %1$s in %2$s', $_input , $_select ); |
|
249 | + yourls_se('Search for %1$s in %2$s', $_input, $_select); |
|
250 | 250 | echo "–\n"; |
251 | 251 | |
252 | 252 | // Second search control: order by |
253 | 253 | $_options = array( |
254 | - 'keyword' => yourls__( 'Short URL' ), |
|
255 | - 'url' => yourls__( 'URL' ), |
|
256 | - 'title' => yourls__( 'Title' ), |
|
257 | - 'timestamp' => yourls__( 'Date' ), |
|
258 | - 'ip' => yourls__( 'IP' ), |
|
259 | - 'clicks' => yourls__( 'Clicks' ), |
|
254 | + 'keyword' => yourls__('Short URL'), |
|
255 | + 'url' => yourls__('URL'), |
|
256 | + 'title' => yourls__('Title'), |
|
257 | + 'timestamp' => yourls__('Date'), |
|
258 | + 'ip' => yourls__('IP'), |
|
259 | + 'clicks' => yourls__('Clicks'), |
|
260 | 260 | ); |
261 | - $_select = yourls_html_select( 'sort_by', $_options, $sort_by, false, yourls__( 'Sort by' ) ); |
|
262 | - $sort_order = isset( $sort_order ) ? $sort_order : 'desc' ; |
|
261 | + $_select = yourls_html_select('sort_by', $_options, $sort_by, false, yourls__('Sort by')); |
|
262 | + $sort_order = isset($sort_order) ? $sort_order : 'desc'; |
|
263 | 263 | $_options = array( |
264 | - 'asc' => yourls__( 'Ascending' ), |
|
265 | - 'desc' => yourls__( 'Descending' ), |
|
264 | + 'asc' => yourls__('Ascending'), |
|
265 | + 'desc' => yourls__('Descending'), |
|
266 | 266 | ); |
267 | - $_select2 = yourls_html_select( 'sort_order', $_options, $sort_order, false, yourls__( 'Sort order' ) ); |
|
267 | + $_select2 = yourls_html_select('sort_order', $_options, $sort_order, false, yourls__('Sort order')); |
|
268 | 268 | /* //translators: "Order by <criteria dropdown (date, clicks...)> in <order dropdown (Descending or Ascending)>" */ |
269 | - yourls_se( 'Order by %1$s %2$s', $_select , $_select2 ); |
|
269 | + yourls_se('Order by %1$s %2$s', $_select, $_select2); |
|
270 | 270 | echo "–\n"; |
271 | 271 | |
272 | 272 | // Third search control: Show XX rows |
273 | 273 | /* //translators: "Show <text field> rows" */ |
274 | - $_input = '<input aria-label="' .yourls__( 'Number of rows to show' ). '" type="text" name="perpage" class="text" size="2" value="' . $perpage . '" />'; |
|
275 | - yourls_se( 'Show %s rows', $_input ); |
|
274 | + $_input = '<input aria-label="'.yourls__('Number of rows to show').'" type="text" name="perpage" class="text" size="2" value="'.$perpage.'" />'; |
|
275 | + yourls_se('Show %s rows', $_input); |
|
276 | 276 | echo "<br/>\n"; |
277 | 277 | |
278 | 278 | // Fourth search control: Show links with more than XX clicks |
279 | 279 | $_options = array( |
280 | - 'more' => yourls__( 'more' ), |
|
281 | - 'less' => yourls__( 'less' ), |
|
280 | + 'more' => yourls__('more'), |
|
281 | + 'less' => yourls__('less'), |
|
282 | 282 | ); |
283 | - $_select = yourls_html_select( 'click_filter', $_options, $click_filter, false, yourls__( 'Show links with' ) ); |
|
284 | - $_input = '<input aria-label="' .yourls__( 'Number of clicks' ). '" type="text" name="click_limit" class="text" size="4" value="' . $click_limit . '" /> '; |
|
283 | + $_select = yourls_html_select('click_filter', $_options, $click_filter, false, yourls__('Show links with')); |
|
284 | + $_input = '<input aria-label="'.yourls__('Number of clicks').'" type="text" name="click_limit" class="text" size="4" value="'.$click_limit.'" /> '; |
|
285 | 285 | /* //translators: "Show links with <more/less> than <text field> clicks" */ |
286 | - yourls_se( 'Show links with %1$s than %2$s clicks', $_select, $_input ); |
|
286 | + yourls_se('Show links with %1$s than %2$s clicks', $_select, $_input); |
|
287 | 287 | echo "<br/>\n"; |
288 | 288 | |
289 | 289 | // Fifth search control: Show links created before/after/between ... |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | 'after' => yourls__('after'), |
293 | 293 | 'between' => yourls__('between'), |
294 | 294 | ); |
295 | - $_select = yourls_html_select( 'date_filter', $_options, $date_filter, false, yourls__('Show links created') ); |
|
296 | - $_input = '<input aria-label="' .yourls__('Select a date') . '" type="text" name="date_first" id="date_first" class="text" size="12" value="' . $date_first . '" />'; |
|
297 | - $_and = '<span id="date_and"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '> & </span>'; |
|
298 | - $_input2 = '<input aria-label="' .yourls__('Select an end date') . '" type="text" name="date_second" id="date_second" class="text" size="12" value="' . $date_second . '"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '/>'; |
|
295 | + $_select = yourls_html_select('date_filter', $_options, $date_filter, false, yourls__('Show links created')); |
|
296 | + $_input = '<input aria-label="'.yourls__('Select a date').'" type="text" name="date_first" id="date_first" class="text" size="12" value="'.$date_first.'" />'; |
|
297 | + $_and = '<span id="date_and"'.($date_filter === 'between' ? ' style="display:inline"' : '').'> & </span>'; |
|
298 | + $_input2 = '<input aria-label="'.yourls__('Select an end date').'" type="text" name="date_second" id="date_second" class="text" size="12" value="'.$date_second.'"'.($date_filter === 'between' ? ' style="display:inline"' : '').'/>'; |
|
299 | 299 | /* //translators: "Show links created <before/after/between> <date input> <"and" if applicable> <date input if applicable>" */ |
300 | - yourls_se( 'Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2 ); |
|
300 | + yourls_se('Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2); |
|
301 | 301 | ?> |
302 | 302 | |
303 | 303 | <div id="filter_buttons"> |
@@ -312,40 +312,40 @@ discard block |
||
312 | 312 | |
313 | 313 | <?php |
314 | 314 | // Remove empty keys from the $params array so it doesn't clutter the pagination links |
315 | - $params = array_filter( $params, 'yourls_return_if_not_empty_string' ); // remove empty keys |
|
315 | + $params = array_filter($params, 'yourls_return_if_not_empty_string'); // remove empty keys |
|
316 | 316 | |
317 | - if( isset( $search_text ) ) { |
|
317 | + if (isset($search_text)) { |
|
318 | 318 | $params['search'] = $search_text; |
319 | - unset( $params['search_text'] ); |
|
319 | + unset($params['search_text']); |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | |
323 | 323 | <div id="pagination"> |
324 | 324 | <span class="navigation"> |
325 | - <?php if( $total_pages > 1 ) { ?> |
|
326 | - <span class="nav_total"><?php echo sprintf( yourls_n( '1 page', '%s pages', $total_pages ), $total_pages ); ?></span> |
|
325 | + <?php if ($total_pages > 1) { ?> |
|
326 | + <span class="nav_total"><?php echo sprintf(yourls_n('1 page', '%s pages', $total_pages), $total_pages); ?></span> |
|
327 | 327 | <?php |
328 | - $base_page = yourls_admin_url( 'index.php' ); |
|
328 | + $base_page = yourls_admin_url('index.php'); |
|
329 | 329 | // Pagination offsets: min( max ( zomg! ) ); |
330 | - $p_start = max( min( $total_pages - 4, $page - 2 ), 1 ); |
|
331 | - $p_end = min( max( 5, $page + 2 ), $total_pages ); |
|
332 | - if( $p_start >= 2 ) { |
|
333 | - $link = yourls_add_query_arg( array_merge( $params, array( 'page' => 1 ) ), $base_page ); |
|
334 | - echo '<span class="nav_link nav_first"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to First Page') . '">' . yourls__( '« First' ) . '</a></span>'; |
|
330 | + $p_start = max(min($total_pages - 4, $page - 2), 1); |
|
331 | + $p_end = min(max(5, $page + 2), $total_pages); |
|
332 | + if ($p_start >= 2) { |
|
333 | + $link = yourls_add_query_arg(array_merge($params, array('page' => 1)), $base_page); |
|
334 | + echo '<span class="nav_link nav_first"><a href="'.$link.'" title="'.yourls_esc_attr__('Go to First Page').'">'.yourls__('« First').'</a></span>'; |
|
335 | 335 | echo '<span class="nav_link nav_prev"></span>'; |
336 | 336 | } |
337 | - for( $i = $p_start ; $i <= $p_end; $i++ ) { |
|
338 | - if( $i == $page ) { |
|
337 | + for ($i = $p_start; $i <= $p_end; $i++) { |
|
338 | + if ($i == $page) { |
|
339 | 339 | echo "<span class='nav_link nav_current'>$i</span>"; |
340 | 340 | } else { |
341 | - $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $i ) ), $base_page ); |
|
342 | - echo '<span class="nav_link nav_goto"><a href="' . $link . '" title="' . sprintf( yourls_esc_attr( 'Page %s' ), $i ) .'">'.$i.'</a></span>'; |
|
341 | + $link = yourls_add_query_arg(array_merge($params, array('page' => $i)), $base_page); |
|
342 | + echo '<span class="nav_link nav_goto"><a href="'.$link.'" title="'.sprintf(yourls_esc_attr('Page %s'), $i).'">'.$i.'</a></span>'; |
|
343 | 343 | } |
344 | 344 | } |
345 | - if( ( $p_end ) < $total_pages ) { |
|
346 | - $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $total_pages ) ), $base_page ); |
|
345 | + if (($p_end) < $total_pages) { |
|
346 | + $link = yourls_add_query_arg(array_merge($params, array('page' => $total_pages)), $base_page); |
|
347 | 347 | echo '<span class="nav_link nav_next"></span>'; |
348 | - echo '<span class="nav_link nav_last"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to Last Page') . '">' . yourls__( 'Last »' ) . '</a></span>'; |
|
348 | + echo '<span class="nav_link nav_last"><a href="'.$link.'" title="'.yourls_esc_attr__('Go to Last Page').'">'.yourls__('Last »').'</a></span>'; |
|
349 | 349 | } |
350 | 350 | ?> |
351 | 351 | <?php } ?> |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | </div> |
354 | 354 | </th> |
355 | 355 | </tr> |
356 | - <?php yourls_do_action( 'html_tfooter' ); ?> |
|
356 | + <?php yourls_do_action('html_tfooter'); ?> |
|
357 | 357 | </tfoot> |
358 | 358 | <?php |
359 | 359 | } |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param string $label ARIA label of the element |
371 | 371 | * @return string HTML content of the select element |
372 | 372 | */ |
373 | -function yourls_html_select( $name, $options, $selected = '', $display = false, $label = '' ) { |
|
373 | +function yourls_html_select($name, $options, $selected = '', $display = false, $label = '') { |
|
374 | 374 | $html = "<select aria-label='$label' name='$name' id='$name' size='1'>\n"; |
375 | - foreach( $options as $value => $text ) { |
|
375 | + foreach ($options as $value => $text) { |
|
376 | 376 | $html .= "<option value='$value' "; |
377 | 377 | $html .= $selected == $value ? ' selected="selected"' : ''; |
378 | 378 | $html .= ">$text</option>\n"; |
379 | 379 | } |
380 | 380 | $html .= "</select>\n"; |
381 | - $html = yourls_apply_filter( 'html_select', $html, $name, $options, $selected, $display ); |
|
382 | - if( $display ) |
|
381 | + $html = yourls_apply_filter('html_select', $html, $name, $options, $selected, $display); |
|
382 | + if ($display) |
|
383 | 383 | echo $html; |
384 | 384 | return $html; |
385 | 385 | } |
@@ -388,48 +388,48 @@ discard block |
||
388 | 388 | * Display the Quick Share box |
389 | 389 | * |
390 | 390 | */ |
391 | -function yourls_share_box( $longurl, $shorturl, $title = '', $text='', $shortlink_title = '', $share_title = '', $hidden = false ) { |
|
392 | - if ( $shortlink_title == '' ) |
|
393 | - $shortlink_title = '<h2>' . yourls__( 'Your short link' ) . '</h2>'; |
|
394 | - if ( $share_title == '' ) |
|
395 | - $share_title = '<h2>' . yourls__( 'Quick Share' ) . '</h2>'; |
|
391 | +function yourls_share_box($longurl, $shorturl, $title = '', $text = '', $shortlink_title = '', $share_title = '', $hidden = false) { |
|
392 | + if ($shortlink_title == '') |
|
393 | + $shortlink_title = '<h2>'.yourls__('Your short link').'</h2>'; |
|
394 | + if ($share_title == '') |
|
395 | + $share_title = '<h2>'.yourls__('Quick Share').'</h2>'; |
|
396 | 396 | |
397 | 397 | // Allow plugins to short-circuit the whole function |
398 | - $pre = yourls_apply_filter( 'shunt_share_box', false ); |
|
399 | - if ( false !== $pre ) |
|
398 | + $pre = yourls_apply_filter('shunt_share_box', false); |
|
399 | + if (false !== $pre) |
|
400 | 400 | return $pre; |
401 | 401 | |
402 | - $text = ( $text ? '"'.$text.'" ' : '' ); |
|
403 | - $title = ( $title ? "$title " : '' ); |
|
404 | - $share = yourls_esc_textarea( $title.$text.$shorturl ); |
|
405 | - $count = 280 - strlen( $share ); |
|
406 | - $hidden = ( $hidden ? 'style="display:none;"' : '' ); |
|
402 | + $text = ($text ? '"'.$text.'" ' : ''); |
|
403 | + $title = ($title ? "$title " : ''); |
|
404 | + $share = yourls_esc_textarea($title.$text.$shorturl); |
|
405 | + $count = 280 - strlen($share); |
|
406 | + $hidden = ($hidden ? 'style="display:none;"' : ''); |
|
407 | 407 | |
408 | 408 | // Allow plugins to filter all data |
409 | - $data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' ); |
|
410 | - $data = yourls_apply_filter( 'share_box_data', $data ); |
|
411 | - extract( $data ); |
|
409 | + $data = compact('longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden'); |
|
410 | + $data = yourls_apply_filter('share_box_data', $data); |
|
411 | + extract($data); |
|
412 | 412 | |
413 | - $_share = rawurlencode( $share ); |
|
414 | - $_url = rawurlencode( $shorturl ); |
|
413 | + $_share = rawurlencode($share); |
|
414 | + $_url = rawurlencode($shorturl); |
|
415 | 415 | ?> |
416 | 416 | |
417 | 417 | <div id="shareboxes" <?php echo $hidden; ?>> |
418 | 418 | |
419 | - <?php yourls_do_action( 'shareboxes_before', $longurl, $shorturl, $title, $text ); ?> |
|
419 | + <?php yourls_do_action('shareboxes_before', $longurl, $shorturl, $title, $text); ?> |
|
420 | 420 | |
421 | 421 | <div id="copybox" class="share"> |
422 | 422 | <?php echo $shortlink_title; ?> |
423 | - <p><input id="copylink" class="text" size="32" value="<?php echo yourls_esc_url( $shorturl ); ?>" /></p> |
|
424 | - <p><small><?php yourls_e( 'Long link' ); ?>: <a id="origlink" href="<?php echo yourls_esc_url( $longurl ); ?>"><?php echo yourls_esc_url( $longurl ); ?></a></small> |
|
425 | - <?php if( yourls_do_log_redirect() ) { ?> |
|
426 | - <br/><small><?php yourls_e( 'Stats' ); ?>: <a id="statlink" href="<?php echo yourls_esc_url( $shorturl ); ?>+"><?php echo yourls_esc_url( $shorturl ); ?>+</a></small> |
|
427 | - <input type="hidden" id="titlelink" value="<?php echo yourls_esc_attr( $title ); ?>" /> |
|
423 | + <p><input id="copylink" class="text" size="32" value="<?php echo yourls_esc_url($shorturl); ?>" /></p> |
|
424 | + <p><small><?php yourls_e('Long link'); ?>: <a id="origlink" href="<?php echo yourls_esc_url($longurl); ?>"><?php echo yourls_esc_url($longurl); ?></a></small> |
|
425 | + <?php if (yourls_do_log_redirect()) { ?> |
|
426 | + <br/><small><?php yourls_e('Stats'); ?>: <a id="statlink" href="<?php echo yourls_esc_url($shorturl); ?>+"><?php echo yourls_esc_url($shorturl); ?>+</a></small> |
|
427 | + <input type="hidden" id="titlelink" value="<?php echo yourls_esc_attr($title); ?>" /> |
|
428 | 428 | <?php } ?> |
429 | 429 | </p> |
430 | 430 | </div> |
431 | 431 | |
432 | - <?php yourls_do_action( 'shareboxes_middle', $longurl, $shorturl, $title, $text ); ?> |
|
432 | + <?php yourls_do_action('shareboxes_middle', $longurl, $shorturl, $title, $text); ?> |
|
433 | 433 | |
434 | 434 | <div id="sharebox" class="share"> |
435 | 435 | <?php echo $share_title; ?> |
@@ -437,17 +437,17 @@ discard block |
||
437 | 437 | <span id="charcount" class="hide-if-no-js"><?php echo $count; ?></span> |
438 | 438 | <textarea id="tweet_body"><?php echo $share; ?></textarea> |
439 | 439 | </div> |
440 | - <p id="share_links"><?php yourls_e( 'Share with' ); ?> |
|
441 | - <a id="share_tw" href="https://twitter.com/intent/tweet?text=<?php echo $_share; ?>" title="<?php yourls_e( 'Tweet this!' ); ?>" onclick="share('tw');return false">Twitter</a> |
|
442 | - <a id="share_fb" href="https://www.facebook.com/share.php?u=<?php echo $_url; ?>" title="<?php yourls_e( 'Share on Facebook' ); ?>" onclick="share('fb');return false;">Facebook</a> |
|
440 | + <p id="share_links"><?php yourls_e('Share with'); ?> |
|
441 | + <a id="share_tw" href="https://twitter.com/intent/tweet?text=<?php echo $_share; ?>" title="<?php yourls_e('Tweet this!'); ?>" onclick="share('tw');return false">Twitter</a> |
|
442 | + <a id="share_fb" href="https://www.facebook.com/share.php?u=<?php echo $_url; ?>" title="<?php yourls_e('Share on Facebook'); ?>" onclick="share('fb');return false;">Facebook</a> |
|
443 | 443 | <?php |
444 | - yourls_do_action( 'share_links', $longurl, $shorturl, $title, $text ); |
|
444 | + yourls_do_action('share_links', $longurl, $shorturl, $title, $text); |
|
445 | 445 | // Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn. |
446 | 446 | ?> |
447 | 447 | </p> |
448 | 448 | </div> |
449 | 449 | |
450 | - <?php yourls_do_action( 'shareboxes_after', $longurl, $shorturl, $title, $text ); ?> |
|
450 | + <?php yourls_do_action('shareboxes_after', $longurl, $shorturl, $title, $text); ?> |
|
451 | 451 | |
452 | 452 | </div> |
453 | 453 | |
@@ -458,20 +458,20 @@ discard block |
||
458 | 458 | * Die die die |
459 | 459 | * |
460 | 460 | */ |
461 | -function yourls_die( $message = '', $title = '', $header_code = 200 ) { |
|
462 | - yourls_do_action( 'pre_yourls_die', $message, $title, $header_code ); |
|
461 | +function yourls_die($message = '', $title = '', $header_code = 200) { |
|
462 | + yourls_do_action('pre_yourls_die', $message, $title, $header_code); |
|
463 | 463 | |
464 | - yourls_status_header( $header_code ); |
|
464 | + yourls_status_header($header_code); |
|
465 | 465 | |
466 | - if( !yourls_did_action( 'html_head' ) ) { |
|
466 | + if (!yourls_did_action('html_head')) { |
|
467 | 467 | yourls_html_head(); |
468 | 468 | yourls_html_logo(); |
469 | 469 | } |
470 | - echo yourls_apply_filter( 'die_title', "<h2>$title</h2>" ); |
|
471 | - echo yourls_apply_filter( 'die_message', "<p>$message</p>" ); |
|
470 | + echo yourls_apply_filter('die_title', "<h2>$title</h2>"); |
|
471 | + echo yourls_apply_filter('die_message', "<p>$message</p>"); |
|
472 | 472 | // Hook into 'yourls_die' to add more elements or messages to that page |
473 | - yourls_do_action( 'yourls_die' ); |
|
474 | - if( !yourls_did_action( 'html_footer' ) ) { |
|
473 | + yourls_do_action('yourls_die'); |
|
474 | + if (!yourls_did_action('html_footer')) { |
|
475 | 475 | yourls_html_footer(false); |
476 | 476 | } |
477 | 477 | die(); |
@@ -483,33 +483,33 @@ discard block |
||
483 | 483 | * @param string $keyword Keyword to edit |
484 | 484 | * @return string HTML of the edit row |
485 | 485 | */ |
486 | -function yourls_table_edit_row( $keyword ) { |
|
486 | +function yourls_table_edit_row($keyword) { |
|
487 | 487 | $keyword = yourls_sanitize_keyword($keyword); |
488 | - $id = yourls_string2htmlid( $keyword ); // used as HTML #id |
|
489 | - $url = yourls_get_keyword_longurl( $keyword ); |
|
490 | - $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) ); |
|
491 | - $safe_url = yourls_esc_attr( rawurldecode( $url ) ); |
|
492 | - $safe_title = yourls_esc_attr( $title ); |
|
493 | - $safe_keyword = yourls_esc_attr( $keyword ); |
|
488 | + $id = yourls_string2htmlid($keyword); // used as HTML #id |
|
489 | + $url = yourls_get_keyword_longurl($keyword); |
|
490 | + $title = htmlspecialchars(yourls_get_keyword_title($keyword)); |
|
491 | + $safe_url = yourls_esc_attr(rawurldecode($url)); |
|
492 | + $safe_title = yourls_esc_attr($title); |
|
493 | + $safe_keyword = yourls_esc_attr($keyword); |
|
494 | 494 | |
495 | 495 | // Make strings sprintf() safe: '%' -> '%%' |
496 | - $safe_url = str_replace( '%', '%%', $safe_url ); |
|
497 | - $safe_title = str_replace( '%', '%%', $safe_title ); |
|
496 | + $safe_url = str_replace('%', '%%', $safe_url); |
|
497 | + $safe_title = str_replace('%', '%%', $safe_title); |
|
498 | 498 | |
499 | 499 | $www = yourls_link(); |
500 | 500 | |
501 | - $nonce = yourls_create_nonce( 'edit-save_'.$id ); |
|
501 | + $nonce = yourls_create_nonce('edit-save_'.$id); |
|
502 | 502 | |
503 | - if( $url ) { |
|
503 | + if ($url) { |
|
504 | 504 | $return = <<<RETURN |
505 | 505 | <tr id="edit-$id" class="edit-row"><td colspan="5" class="edit-row"><strong>%s</strong>:<input type="text" id="edit-url-$id" name="edit-url-$id" value="$safe_url" class="text" size="70" /><br/><strong>%s</strong>: $www<input type="text" id="edit-keyword-$id" name="edit-keyword-$id" value="$safe_keyword" class="text" size="10" /><br/><strong>%s</strong>: <input type="text" id="edit-title-$id" name="edit-title-$id" value="$safe_title" class="text" size="60" /></td><td colspan="1"><input type="button" id="edit-submit-$id" name="edit-submit-$id" value="%s" title="%s" class="button" onclick="edit_link_save('$id');" /> <input type="button" id="edit-close-$id" name="edit-close-$id" value="%s" title="%s" class="button" onclick="edit_link_hide('$id');" /><input type="hidden" id="old_keyword_$id" value="$safe_keyword"/><input type="hidden" id="nonce_$id" value="$nonce"/></td></tr> |
506 | 506 | RETURN; |
507 | - $return = sprintf( $return, yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) ); |
|
507 | + $return = sprintf($return, yourls__('Long URL'), yourls__('Short URL'), yourls__('Title'), yourls__('Save'), yourls__('Save new values'), yourls__('Cancel'), yourls__('Cancel editing')); |
|
508 | 508 | } else { |
509 | - $return = '<tr class="edit-row notfound"><td colspan="6" class="edit-row notfound">' . yourls__( 'Error, URL not found' ) . '</td></tr>'; |
|
509 | + $return = '<tr class="edit-row notfound"><td colspan="6" class="edit-row notfound">'.yourls__('Error, URL not found').'</td></tr>'; |
|
510 | 510 | } |
511 | 511 | |
512 | - $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title ); |
|
512 | + $return = yourls_apply_filter('table_edit_row', $return, $keyword, $url, $title); |
|
513 | 513 | |
514 | 514 | return $return; |
515 | 515 | } |
@@ -519,19 +519,19 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string HTML of the edit row |
521 | 521 | */ |
522 | -function yourls_table_add_row( $keyword, $url, $title = '', $ip, $clicks, $timestamp ) { |
|
523 | - $keyword = yourls_sanitize_keyword($keyword); |
|
524 | - $id = yourls_string2htmlid( $keyword ); // used as HTML #id |
|
525 | - $shorturl = yourls_link( $keyword ); |
|
522 | +function yourls_table_add_row($keyword, $url, $title = '', $ip, $clicks, $timestamp) { |
|
523 | + $keyword = yourls_sanitize_keyword($keyword); |
|
524 | + $id = yourls_string2htmlid($keyword); // used as HTML #id |
|
525 | + $shorturl = yourls_link($keyword); |
|
526 | 526 | |
527 | - $statlink = yourls_statlink( $keyword ); |
|
527 | + $statlink = yourls_statlink($keyword); |
|
528 | 528 | |
529 | - $delete_link = yourls_nonce_url( 'delete-link_'.$id, |
|
530 | - yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
529 | + $delete_link = yourls_nonce_url('delete-link_'.$id, |
|
530 | + yourls_add_query_arg(array('id' => $id, 'action' => 'delete', 'keyword' => $keyword), yourls_admin_url('admin-ajax.php')) |
|
531 | 531 | ); |
532 | 532 | |
533 | - $edit_link = yourls_nonce_url( 'edit-link_'.$id, |
|
534 | - yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) |
|
533 | + $edit_link = yourls_nonce_url('edit-link_'.$id, |
|
534 | + yourls_add_query_arg(array('id' => $id, 'action' => 'edit', 'keyword' => $keyword), yourls_admin_url('admin-ajax.php')) |
|
535 | 535 | ); |
536 | 536 | |
537 | 537 | // Action link buttons: the array |
@@ -539,69 +539,69 @@ discard block |
||
539 | 539 | 'stats' => array( |
540 | 540 | 'href' => $statlink, |
541 | 541 | 'id' => "statlink-$id", |
542 | - 'title' => yourls_esc_attr__( 'Stats' ), |
|
543 | - 'anchor' => yourls__( 'Stats' ), |
|
542 | + 'title' => yourls_esc_attr__('Stats'), |
|
543 | + 'anchor' => yourls__('Stats'), |
|
544 | 544 | ), |
545 | 545 | 'share' => array( |
546 | 546 | 'href' => '', |
547 | 547 | 'id' => "share-button-$id", |
548 | - 'title' => yourls_esc_attr__( 'Share' ), |
|
549 | - 'anchor' => yourls__( 'Share' ), |
|
548 | + 'title' => yourls_esc_attr__('Share'), |
|
549 | + 'anchor' => yourls__('Share'), |
|
550 | 550 | 'onclick' => "toggle_share('$id');return false;", |
551 | 551 | ), |
552 | 552 | 'edit' => array( |
553 | 553 | 'href' => $edit_link, |
554 | 554 | 'id' => "edit-button-$id", |
555 | - 'title' => yourls_esc_attr__( 'Edit' ), |
|
556 | - 'anchor' => yourls__( 'Edit' ), |
|
555 | + 'title' => yourls_esc_attr__('Edit'), |
|
556 | + 'anchor' => yourls__('Edit'), |
|
557 | 557 | 'onclick' => "edit_link_display('$id');return false;", |
558 | 558 | ), |
559 | 559 | 'delete' => array( |
560 | 560 | 'href' => $delete_link, |
561 | 561 | 'id' => "delete-button-$id", |
562 | - 'title' => yourls_esc_attr__( 'Delete' ), |
|
563 | - 'anchor' => yourls__( 'Delete' ), |
|
562 | + 'title' => yourls_esc_attr__('Delete'), |
|
563 | + 'anchor' => yourls__('Delete'), |
|
564 | 564 | 'onclick' => "remove_link('$id');return false;", |
565 | 565 | ) |
566 | 566 | ); |
567 | - $actions = yourls_apply_filter( 'table_add_row_action_array', $actions, $keyword ); |
|
567 | + $actions = yourls_apply_filter('table_add_row_action_array', $actions, $keyword); |
|
568 | 568 | |
569 | 569 | // Action link buttons: the HTML |
570 | 570 | $action_links = ''; |
571 | - foreach( $actions as $key => $action ) { |
|
572 | - $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ; |
|
573 | - $action_links .= sprintf( '<a href="%s" id="%s" title="%s" class="%s" %s>%s</a>', |
|
571 | + foreach ($actions as $key => $action) { |
|
572 | + $onclick = isset($action['onclick']) ? 'onclick="'.$action['onclick'].'"' : ''; |
|
573 | + $action_links .= sprintf('<a href="%s" id="%s" title="%s" class="%s" %s>%s</a>', |
|
574 | 574 | $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor'] |
575 | 575 | ); |
576 | 576 | } |
577 | - $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp ); |
|
577 | + $action_links = yourls_apply_filter('action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp); |
|
578 | 578 | |
579 | - if( ! $title ) |
|
579 | + if (!$title) |
|
580 | 580 | $title = $url; |
581 | 581 | |
582 | 582 | $protocol_warning = ''; |
583 | - if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) ) |
|
584 | - $protocol_warning = yourls_apply_filter( 'add_row_protocol_warning', '<span class="warning" title="' . yourls__( 'Not a common link' ) . '">★</span>' ); |
|
583 | + if (!in_array(yourls_get_protocol($url), array('http://', 'https://'))) |
|
584 | + $protocol_warning = yourls_apply_filter('add_row_protocol_warning', '<span class="warning" title="'.yourls__('Not a common link').'">★</span>'); |
|
585 | 585 | |
586 | 586 | // Row cells: the array |
587 | 587 | $cells = array( |
588 | 588 | 'keyword' => array( |
589 | 589 | 'template' => '<a href="%shorturl%">%keyword_html%</a>', |
590 | - 'shorturl' => yourls_esc_url( $shorturl ), |
|
591 | - 'keyword_html' => yourls_esc_html( $keyword ), |
|
590 | + 'shorturl' => yourls_esc_url($shorturl), |
|
591 | + 'keyword_html' => yourls_esc_html($keyword), |
|
592 | 592 | ), |
593 | 593 | 'url' => array( |
594 | 594 | 'template' => '<a href="%long_url%" title="%title_attr%">%title_html%</a><br/><small>%warning%<a href="%long_url%">%long_url_html%</a></small>', |
595 | - 'long_url' => yourls_esc_url( $url ), |
|
596 | - 'title_attr' => yourls_esc_attr( $title ), |
|
597 | - 'title_html' => yourls_esc_html( yourls_trim_long_string( $title ) ), |
|
598 | - 'long_url_html' => yourls_esc_html( yourls_trim_long_string( $url ) ), |
|
595 | + 'long_url' => yourls_esc_url($url), |
|
596 | + 'title_attr' => yourls_esc_attr($title), |
|
597 | + 'title_html' => yourls_esc_html(yourls_trim_long_string($title)), |
|
598 | + 'long_url_html' => yourls_esc_html(yourls_trim_long_string($url)), |
|
599 | 599 | 'warning' => $protocol_warning, |
600 | 600 | ), |
601 | 601 | 'timestamp' => array( |
602 | 602 | 'template' => '<span class="timestamp" aria-hidden="true">%timestamp%</span> %date%', |
603 | 603 | 'timestamp' => $timestamp, |
604 | - 'date' => yourls_date_i18n( yourls_get_datetime_format('M d, Y H:i'), yourls_get_timestamp( $timestamp )), |
|
604 | + 'date' => yourls_date_i18n(yourls_get_datetime_format('M d, Y H:i'), yourls_get_timestamp($timestamp)), |
|
605 | 605 | ), |
606 | 606 | 'ip' => array( |
607 | 607 | 'template' => '%ip%', |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | ), |
610 | 610 | 'clicks' => array( |
611 | 611 | 'template' => '%clicks%', |
612 | - 'clicks' => yourls_number_format_i18n( $clicks, 0, '', '' ), |
|
612 | + 'clicks' => yourls_number_format_i18n($clicks, 0, '', ''), |
|
613 | 613 | ), |
614 | 614 | 'actions' => array( |
615 | 615 | 'template' => '%actions% <input type="hidden" id="keyword_%id%" value="%keyword%"/>', |
@@ -618,17 +618,17 @@ discard block |
||
618 | 618 | 'keyword' => $keyword, |
619 | 619 | ), |
620 | 620 | ); |
621 | - $cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
621 | + $cells = yourls_apply_filter('table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp); |
|
622 | 622 | |
623 | 623 | // Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value. |
624 | 624 | $row = "<tr id=\"id-$id\">"; |
625 | - foreach( $cells as $cell_id => $elements ) { |
|
626 | - $row .= sprintf( '<td class="%s" id="%s">', $cell_id, $cell_id . '-' . $id ); |
|
627 | - $row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] ); |
|
625 | + foreach ($cells as $cell_id => $elements) { |
|
626 | + $row .= sprintf('<td class="%s" id="%s">', $cell_id, $cell_id.'-'.$id); |
|
627 | + $row .= preg_replace_callback('/%([^%]+)?%/', function($match) use ($elements) { return $elements[$match[1]]; }, $elements['template']); |
|
628 | 628 | $row .= '</td>'; |
629 | 629 | } |
630 | 630 | $row .= "</tr>"; |
631 | - $row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp ); |
|
631 | + $row = yourls_apply_filter('table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp); |
|
632 | 632 | |
633 | 633 | return $row; |
634 | 634 | } |
@@ -639,22 +639,22 @@ discard block |
||
639 | 639 | */ |
640 | 640 | function yourls_table_head() { |
641 | 641 | $start = '<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"><thead><tr>'."\n"; |
642 | - echo yourls_apply_filter( 'table_head_start', $start ); |
|
643 | - |
|
644 | - $cells = yourls_apply_filter( 'table_head_cells', array( |
|
645 | - 'shorturl' => yourls__( 'Short URL' ), |
|
646 | - 'longurl' => yourls__( 'Original URL' ), |
|
647 | - 'date' => yourls__( 'Date' ), |
|
648 | - 'ip' => yourls__( 'IP' ), |
|
649 | - 'clicks' => yourls__( 'Clicks' ), |
|
650 | - 'actions' => yourls__( 'Actions' ) |
|
651 | - ) ); |
|
652 | - foreach( $cells as $k => $v ) { |
|
642 | + echo yourls_apply_filter('table_head_start', $start); |
|
643 | + |
|
644 | + $cells = yourls_apply_filter('table_head_cells', array( |
|
645 | + 'shorturl' => yourls__('Short URL'), |
|
646 | + 'longurl' => yourls__('Original URL'), |
|
647 | + 'date' => yourls__('Date'), |
|
648 | + 'ip' => yourls__('IP'), |
|
649 | + 'clicks' => yourls__('Clicks'), |
|
650 | + 'actions' => yourls__('Actions') |
|
651 | + )); |
|
652 | + foreach ($cells as $k => $v) { |
|
653 | 653 | echo "<th id='main_table_head_$k'>$v</th>\n"; |
654 | 654 | } |
655 | 655 | |
656 | 656 | $end = "</tr></thead>\n"; |
657 | - echo yourls_apply_filter( 'table_head_end', $end ); |
|
657 | + echo yourls_apply_filter('table_head_end', $end); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * |
663 | 663 | */ |
664 | 664 | function yourls_table_tbody_start() { |
665 | - echo yourls_apply_filter( 'table_tbody_start', '<tbody>' ); |
|
665 | + echo yourls_apply_filter('table_tbody_start', '<tbody>'); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * |
671 | 671 | */ |
672 | 672 | function yourls_table_tbody_end() { |
673 | - echo yourls_apply_filter( 'table_tbody_end', '</tbody>' ); |
|
673 | + echo yourls_apply_filter('table_tbody_end', '</tbody>'); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -678,57 +678,57 @@ discard block |
||
678 | 678 | * |
679 | 679 | */ |
680 | 680 | function yourls_table_end() { |
681 | - echo yourls_apply_filter( 'table_end', '</table></main>' ); |
|
681 | + echo yourls_apply_filter('table_end', '</table></main>'); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
685 | 685 | * Echo HTML tag for a link |
686 | 686 | * |
687 | 687 | */ |
688 | -function yourls_html_link( $href, $title = '', $element = '' ) { |
|
689 | - if( !$title ) |
|
688 | +function yourls_html_link($href, $title = '', $element = '') { |
|
689 | + if (!$title) |
|
690 | 690 | $title = $href; |
691 | - if( $element ) |
|
692 | - $element = sprintf( 'id="%s"', yourls_esc_attr( $element ) ); |
|
693 | - $link = sprintf( '<a href="%s" %s>%s</a>', yourls_esc_url( $href ), $element, yourls_esc_html( $title ) ); |
|
694 | - echo yourls_apply_filter( 'html_link', $link ); |
|
691 | + if ($element) |
|
692 | + $element = sprintf('id="%s"', yourls_esc_attr($element)); |
|
693 | + $link = sprintf('<a href="%s" %s>%s</a>', yourls_esc_url($href), $element, yourls_esc_html($title)); |
|
694 | + echo yourls_apply_filter('html_link', $link); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
698 | 698 | * Display the login screen. Nothing past this point. |
699 | 699 | * |
700 | 700 | */ |
701 | -function yourls_login_screen( $error_msg = '' ) { |
|
702 | - yourls_html_head( 'login' ); |
|
701 | +function yourls_login_screen($error_msg = '') { |
|
702 | + yourls_html_head('login'); |
|
703 | 703 | |
704 | - $action = ( isset( $_GET['action'] ) && $_GET['action'] == 'logout' ? '?' : '' ); |
|
704 | + $action = (isset($_GET['action']) && $_GET['action'] == 'logout' ? '?' : ''); |
|
705 | 705 | |
706 | 706 | yourls_html_logo(); |
707 | 707 | ?> |
708 | 708 | <div id="login"> |
709 | 709 | <form method="post" action="<?php echo $action; ?>"> <?php // reset any QUERY parameters ?> |
710 | 710 | <?php |
711 | - if( !empty( $error_msg ) ) { |
|
711 | + if (!empty($error_msg)) { |
|
712 | 712 | echo '<p class="error">'.$error_msg.'</p>'; |
713 | 713 | } |
714 | - yourls_do_action( 'login_form_top' ); |
|
714 | + yourls_do_action('login_form_top'); |
|
715 | 715 | ?> |
716 | 716 | <p> |
717 | - <label for="username"><?php yourls_e( 'Username' ); ?></label><br /> |
|
717 | + <label for="username"><?php yourls_e('Username'); ?></label><br /> |
|
718 | 718 | <input type="text" id="username" name="username" size="30" class="text" /> |
719 | 719 | </p> |
720 | 720 | <p> |
721 | - <label for="password"><?php yourls_e( 'Password' ); ?></label><br /> |
|
721 | + <label for="password"><?php yourls_e('Password'); ?></label><br /> |
|
722 | 722 | <input type="password" id="password" name="password" size="30" class="text" /> |
723 | 723 | </p> |
724 | 724 | <?php |
725 | - yourls_do_action( 'login_form_bottom' ); |
|
725 | + yourls_do_action('login_form_bottom'); |
|
726 | 726 | ?> |
727 | 727 | <p style="text-align: right;"> |
728 | - <input type="submit" id="submit" name="submit" value="<?php yourls_e( 'Login' ); ?>" class="button" /> |
|
728 | + <input type="submit" id="submit" name="submit" value="<?php yourls_e('Login'); ?>" class="button" /> |
|
729 | 729 | </p> |
730 | 730 | <?php |
731 | - yourls_do_action( 'login_form_end' ); |
|
731 | + yourls_do_action('login_form_end'); |
|
732 | 732 | ?> |
733 | 733 | </form> |
734 | 734 | <script type="text/javascript">$('#username').focus();</script> |
@@ -745,69 +745,69 @@ discard block |
||
745 | 745 | function yourls_html_menu() { |
746 | 746 | |
747 | 747 | // Build menu links |
748 | - if( defined( 'YOURLS_USER' ) ) { |
|
749 | - $logout_link = yourls_apply_filter( 'logout_link', sprintf( yourls__('Hello <strong>%s</strong>'), YOURLS_USER ) . ' (<a href="' . yourls_admin_url() . '?action=logout" title="' . yourls_esc_attr__( 'Logout' ) . '">' . yourls__( 'Logout' ) . '</a>)' ); |
|
748 | + if (defined('YOURLS_USER')) { |
|
749 | + $logout_link = yourls_apply_filter('logout_link', sprintf(yourls__('Hello <strong>%s</strong>'), YOURLS_USER).' (<a href="'.yourls_admin_url().'?action=logout" title="'.yourls_esc_attr__('Logout').'">'.yourls__('Logout').'</a>)'); |
|
750 | 750 | } else { |
751 | - $logout_link = yourls_apply_filter( 'logout_link', '' ); |
|
751 | + $logout_link = yourls_apply_filter('logout_link', ''); |
|
752 | 752 | } |
753 | - $help_link = yourls_apply_filter( 'help_link', '<a href="' . yourls_site_url( false ) .'/readme.html">' . yourls__( 'Help' ) . '</a>' ); |
|
753 | + $help_link = yourls_apply_filter('help_link', '<a href="'.yourls_site_url(false).'/readme.html">'.yourls__('Help').'</a>'); |
|
754 | 754 | |
755 | 755 | $admin_links = array(); |
756 | 756 | $admin_sublinks = array(); |
757 | 757 | |
758 | 758 | $admin_links['admin'] = array( |
759 | - 'url' => yourls_admin_url( 'index.php' ), |
|
760 | - 'title' => yourls__( 'Go to the admin interface' ), |
|
761 | - 'anchor' => yourls__( 'Admin interface' ) |
|
759 | + 'url' => yourls_admin_url('index.php'), |
|
760 | + 'title' => yourls__('Go to the admin interface'), |
|
761 | + 'anchor' => yourls__('Admin interface') |
|
762 | 762 | ); |
763 | 763 | |
764 | - if( yourls_is_admin() ) { |
|
764 | + if (yourls_is_admin()) { |
|
765 | 765 | $admin_links['tools'] = array( |
766 | - 'url' => yourls_admin_url( 'tools.php' ), |
|
767 | - 'anchor' => yourls__( 'Tools' ) |
|
766 | + 'url' => yourls_admin_url('tools.php'), |
|
767 | + 'anchor' => yourls__('Tools') |
|
768 | 768 | ); |
769 | 769 | $admin_links['plugins'] = array( |
770 | - 'url' => yourls_admin_url( 'plugins.php' ), |
|
771 | - 'anchor' => yourls__( 'Manage Plugins' ) |
|
770 | + 'url' => yourls_admin_url('plugins.php'), |
|
771 | + 'anchor' => yourls__('Manage Plugins') |
|
772 | 772 | ); |
773 | 773 | $admin_sublinks['plugins'] = yourls_list_plugin_admin_pages(); |
774 | 774 | } |
775 | 775 | |
776 | - $admin_links = yourls_apply_filter( 'admin_links', $admin_links ); |
|
777 | - $admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks ); |
|
776 | + $admin_links = yourls_apply_filter('admin_links', $admin_links); |
|
777 | + $admin_sublinks = yourls_apply_filter('admin_sublinks', $admin_sublinks); |
|
778 | 778 | |
779 | 779 | // Now output menu |
780 | 780 | echo '<nav role="navigation"><ul id="admin_menu">'."\n"; |
781 | - if ( yourls_is_private() && !empty( $logout_link ) ) |
|
782 | - echo '<li id="admin_menu_logout_link">' . $logout_link .'</li>'; |
|
783 | - |
|
784 | - foreach( (array)$admin_links as $link => $ar ) { |
|
785 | - if( isset( $ar['url'] ) ) { |
|
786 | - $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
|
787 | - $title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
|
788 | - printf( '<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor ); |
|
781 | + if (yourls_is_private() && !empty($logout_link)) |
|
782 | + echo '<li id="admin_menu_logout_link">'.$logout_link.'</li>'; |
|
783 | + |
|
784 | + foreach ((array) $admin_links as $link => $ar) { |
|
785 | + if (isset($ar['url'])) { |
|
786 | + $anchor = isset($ar['anchor']) ? $ar['anchor'] : $link; |
|
787 | + $title = isset($ar['title']) ? 'title="'.$ar['title'].'"' : ''; |
|
788 | + printf('<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor); |
|
789 | 789 | } |
790 | 790 | // Output submenu if any. TODO: clean up, too many code duplicated here |
791 | - if( isset( $admin_sublinks[$link] ) ) { |
|
791 | + if (isset($admin_sublinks[$link])) { |
|
792 | 792 | echo "<ul>\n"; |
793 | - foreach( $admin_sublinks[$link] as $link => $ar ) { |
|
794 | - if( isset( $ar['url'] ) ) { |
|
795 | - $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link; |
|
796 | - $title = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : ''; |
|
797 | - printf( '<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor ); |
|
793 | + foreach ($admin_sublinks[$link] as $link => $ar) { |
|
794 | + if (isset($ar['url'])) { |
|
795 | + $anchor = isset($ar['anchor']) ? $ar['anchor'] : $link; |
|
796 | + $title = isset($ar['title']) ? 'title="'.$ar['title'].'"' : ''; |
|
797 | + printf('<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor); |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | echo "</ul>\n"; |
801 | 801 | } |
802 | 802 | } |
803 | 803 | |
804 | - if ( isset( $help_link ) ) |
|
805 | - echo '<li id="admin_menu_help_link">' . $help_link .'</li>'; |
|
804 | + if (isset($help_link)) |
|
805 | + echo '<li id="admin_menu_help_link">'.$help_link.'</li>'; |
|
806 | 806 | |
807 | - yourls_do_action( 'admin_menu' ); |
|
807 | + yourls_do_action('admin_menu'); |
|
808 | 808 | echo "</ul></nav>\n"; |
809 | - yourls_do_action( 'admin_notices' ); |
|
810 | - yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice' |
|
809 | + yourls_do_action('admin_notices'); |
|
810 | + yourls_do_action('admin_notice'); // because I never remember if it's 'notices' or 'notice' |
|
811 | 811 | /* |
812 | 812 | To display a notice: |
813 | 813 | $message = "<div>OMG, dude, I mean!</div>" ); |
@@ -819,17 +819,17 @@ discard block |
||
819 | 819 | * Wrapper function to display admin notices |
820 | 820 | * |
821 | 821 | */ |
822 | -function yourls_add_notice( $message, $style = 'notice' ) { |
|
822 | +function yourls_add_notice($message, $style = 'notice') { |
|
823 | 823 | // Escape single quotes in $message to avoid breaking the anonymous function |
824 | - $message = yourls_notice_box( strtr( $message, array( "'" => "\'" ) ), $style ); |
|
825 | - yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } ); |
|
824 | + $message = yourls_notice_box(strtr($message, array("'" => "\'")), $style); |
|
825 | + yourls_add_action('admin_notices', function() use ($message) { echo (string) $message; } ); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
829 | 829 | * Return a formatted notice |
830 | 830 | * |
831 | 831 | */ |
832 | -function yourls_notice_box( $message, $style = 'notice' ) { |
|
832 | +function yourls_notice_box($message, $style = 'notice') { |
|
833 | 833 | return <<<HTML |
834 | 834 | <div class="$style"> |
835 | 835 | <p>$message</p> |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | * @since 1.0 |
847 | 847 | * @param $page PHP file to display |
848 | 848 | */ |
849 | -function yourls_page( $page ) { |
|
850 | - if( !yourls_is_page($page)) { |
|
851 | - yourls_die( yourls_s('Page "%1$s" not found', $page), yourls__('Not found'), 404 ); |
|
849 | +function yourls_page($page) { |
|
850 | + if (!yourls_is_page($page)) { |
|
851 | + yourls_die(yourls_s('Page "%1$s" not found', $page), yourls__('Not found'), 404); |
|
852 | 852 | } |
853 | 853 | |
854 | - yourls_do_action( 'pre_page', $page ); |
|
855 | - include_once( YOURLS_PAGEDIR . "/$page.php" ); |
|
856 | - yourls_do_action( 'post_page', $page ); |
|
854 | + yourls_do_action('pre_page', $page); |
|
855 | + include_once(YOURLS_PAGEDIR."/$page.php"); |
|
856 | + yourls_do_action('post_page', $page); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -868,20 +868,20 @@ discard block |
||
868 | 868 | $attributes = array(); |
869 | 869 | $output = ''; |
870 | 870 | |
871 | - $attributes[] = ( yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"' ); |
|
871 | + $attributes[] = (yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"'); |
|
872 | 872 | |
873 | - $doctype = yourls_apply_filter( 'html_language_attributes_doctype', 'html' ); |
|
873 | + $doctype = yourls_apply_filter('html_language_attributes_doctype', 'html'); |
|
874 | 874 | // Experimental: get HTML lang from locale. Should work. Convert fr_FR -> fr-FR |
875 | - if ( $lang = str_replace( '_', '-', yourls_get_locale() ) ) { |
|
876 | - if( $doctype == 'xhtml' ) { |
|
875 | + if ($lang = str_replace('_', '-', yourls_get_locale())) { |
|
876 | + if ($doctype == 'xhtml') { |
|
877 | 877 | $attributes[] = "xml:lang=\"$lang\""; |
878 | 878 | } else { |
879 | 879 | $attributes[] = "lang=\"$lang\""; |
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
883 | - $output = implode( ' ', $attributes ); |
|
884 | - $output = yourls_apply_filter( 'html_language_attributes', $output ); |
|
883 | + $output = implode(' ', $attributes); |
|
884 | + $output = yourls_apply_filter('html_language_attributes', $output); |
|
885 | 885 | echo $output; |
886 | 886 | } |
887 | 887 | |
@@ -892,15 +892,15 @@ discard block |
||
892 | 892 | */ |
893 | 893 | function yourls_l10n_calendar_strings() { |
894 | 894 | echo "\n<script>\n"; |
895 | - echo "var l10n_cal_month = " . json_encode( array_values( yourls_l10n_months() ) ) . ";\n"; |
|
896 | - echo "var l10n_cal_days = " . json_encode( array_values( yourls_l10n_weekday_initial() ) ) . ";\n"; |
|
897 | - echo "var l10n_cal_today = \"" . yourls_esc_js( yourls__( 'Today' ) ) . "\";\n"; |
|
898 | - echo "var l10n_cal_close = \"" . yourls_esc_js( yourls__( 'Close' ) ) . "\";\n"; |
|
895 | + echo "var l10n_cal_month = ".json_encode(array_values(yourls_l10n_months())).";\n"; |
|
896 | + echo "var l10n_cal_days = ".json_encode(array_values(yourls_l10n_weekday_initial())).";\n"; |
|
897 | + echo "var l10n_cal_today = \"".yourls_esc_js(yourls__('Today'))."\";\n"; |
|
898 | + echo "var l10n_cal_close = \"".yourls_esc_js(yourls__('Close'))."\";\n"; |
|
899 | 899 | echo "</script>\n"; |
900 | 900 | |
901 | 901 | // Dummy returns, to initialize l10n strings used in the calendar |
902 | - yourls__( 'Today' ); |
|
903 | - yourls__( 'Close' ); |
|
902 | + yourls__('Today'); |
|
903 | + yourls__('Close'); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | |
@@ -911,12 +911,12 @@ discard block |
||
911 | 911 | */ |
912 | 912 | function yourls_new_core_version_notice() { |
913 | 913 | |
914 | - $checks = yourls_get_option( 'core_version_checks' ); |
|
914 | + $checks = yourls_get_option('core_version_checks'); |
|
915 | 915 | $latest = isset($checks->last_result->latest) ? yourls_sanitize_version($checks->last_result->latest) : false; |
916 | 916 | |
917 | - if( $latest AND version_compare( $latest, YOURLS_VERSION, '>' ) ) { |
|
918 | - $msg = yourls_s( '<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $latest ); |
|
919 | - yourls_add_notice( $msg ); |
|
917 | + if ($latest AND version_compare($latest, YOURLS_VERSION, '>')) { |
|
918 | + $msg = yourls_s('<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $latest); |
|
919 | + yourls_add_notice($msg); |
|
920 | 920 | } |
921 | 921 | } |
922 | 922 | |
@@ -927,11 +927,11 @@ discard block |
||
927 | 927 | * @param string $type content type ('text/html', 'application/json', ...) |
928 | 928 | * @return bool whether header was sent |
929 | 929 | */ |
930 | -function yourls_content_type_header( $type ) { |
|
931 | - yourls_do_action( 'content_type_header', $type ); |
|
932 | - if( !headers_sent() ) { |
|
933 | - $charset = yourls_apply_filter( 'content_type_header_charset', 'utf-8' ); |
|
934 | - header( "Content-Type: $type; charset=$charset" ); |
|
930 | +function yourls_content_type_header($type) { |
|
931 | + yourls_do_action('content_type_header', $type); |
|
932 | + if (!headers_sent()) { |
|
933 | + $charset = yourls_apply_filter('content_type_header_charset', 'utf-8'); |
|
934 | + header("Content-Type: $type; charset=$charset"); |
|
935 | 935 | return true; |
936 | 936 | } |
937 | 937 | return false; |
@@ -950,14 +950,14 @@ discard block |
||
950 | 950 | */ |
951 | 951 | function yourls_get_search_text() { |
952 | 952 | $search = ''; |
953 | - if( isset( $_GET['search_protocol'] ) ) |
|
953 | + if (isset($_GET['search_protocol'])) |
|
954 | 954 | $search .= $_GET['search_protocol']; |
955 | - if( isset( $_GET['search_slashes'] ) ) |
|
955 | + if (isset($_GET['search_slashes'])) |
|
956 | 956 | $search .= $_GET['search_slashes']; |
957 | - if( isset( $_GET['search'] ) ) |
|
957 | + if (isset($_GET['search'])) |
|
958 | 958 | $search .= $_GET['search']; |
959 | 959 | |
960 | - return htmlspecialchars( trim( $search ) ); |
|
960 | + return htmlspecialchars(trim($search)); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -969,13 +969,13 @@ discard block |
||
969 | 969 | * @param bool $echo true to display, false to return the HTML |
970 | 970 | * @return string the HTML for a bookmarklet link |
971 | 971 | */ |
972 | -function yourls_bookmarklet_link( $href, $anchor, $echo = true ) { |
|
973 | - $alert = yourls_esc_attr__( 'Drag to your toolbar!' ); |
|
972 | +function yourls_bookmarklet_link($href, $anchor, $echo = true) { |
|
973 | + $alert = yourls_esc_attr__('Drag to your toolbar!'); |
|
974 | 974 | $link = <<<LINK |
975 | 975 | <a href="$href" class="bookmarklet" onclick="alert('$alert');return false;">$anchor</a> |
976 | 976 | LINK; |
977 | 977 | |
978 | - if( $echo ) |
|
978 | + if ($echo) |
|
979 | 979 | echo $link; |
980 | 980 | return $link; |
981 | 981 | } |