codemirror
4 years ago
jquery-tiptip
5 years ago
select2
5 years ago
how-to.js
8 years ago
how-to.min.js
6 years ago
jquery.colorbox.js
8 years ago
jquery.colorbox.min.js
6 years ago
metabox.js
4 years ago
metabox.min.js
4 years ago
multisite-updater.js
2 years ago
multisite-updater.min.js
6 years ago
welcome-modal.js
3 years ago
welcome-modal.min.js
3 years ago
wp-pages.js
3 years ago
wp-pages.min.js
3 years ago
yit-cpt-unlimited.js
6 years ago
yit-cpt-unlimited.min.js
6 years ago
yit-plugin-panel.js
1 year ago
yit-plugin-panel.min.js
1 year ago
yit-wp-pointer.js
5 years ago
yit-wp-pointer.min.js
5 years ago
yith-bh-onboarding.js
3 years ago
yith-bh-onboarding.min.js
3 years ago
yith-colorpicker.min.js
5 years ago
yith-dashboard.js
7 years ago
yith-dashboard.min.js
6 years ago
yith-date-format.js
5 years ago
yith-date-format.min.js
5 years ago
yith-enhanced-select-wc-2.6.js
5 years ago
yith-enhanced-select-wc-2.6.min.js
5 years ago
yith-enhanced-select.js
2 years ago
yith-enhanced-select.min.js
2 years ago
yith-fields.js
2 years ago
yith-fields.min.js
2 years ago
yith-promo.js
7 years ago
yith-promo.min.js
6 years ago
yith-system-info.js
2 years ago
yith-system-info.min.js
2 years ago
yith-ui.js
1 year ago
yith-ui.min.js
1 year ago
yith-update-plugins.js
7 years ago
yith-update-plugins.min.js
6 years ago
multisite-updater.js
221 lines
| 1 | /** |
| 2 | * This file belongs to the YIT Framework. |
| 3 | * |
| 4 | * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0) |
| 5 | * that is bundled with this package in the file LICENSE.txt. |
| 6 | * It is also available through the world-wide-web at this URL: |
| 7 | * http://www.gnu.org/licenses/gpl-3.0.txt |
| 8 | */ |
| 9 | (function ( $ ) { |
| 10 | |
| 11 | var plugins_menu_item = $( '#menu-plugins' ), |
| 12 | update = plugins_menu_item.find( '.update-plugins' ), |
| 13 | count = update.find( ".plugin-count" ).text(), |
| 14 | registered = plugins.registered, |
| 15 | activated = plugins.activated; |
| 16 | |
| 17 | if ( count == 0 || count == '' ) { |
| 18 | var update_row = '<span class="update-plugins"><span class="plugin-count"></span></span>'; |
| 19 | count = 0; |
| 20 | plugins_menu_item.find( '.wp-menu-name' ).append( update_row ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Add the plugin update rows for old plugins |
| 25 | */ |
| 26 | update_plugins_row( registered, activated, count, plugins ); |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * Add the update plugin rows for old plugin |
| 31 | * |
| 32 | * @param registered Registred plugins |
| 33 | * @param activated Activated plugins |
| 34 | * @param count Number of old plugins |
| 35 | * @param localize Localize strings array |
| 36 | * |
| 37 | * @return void |
| 38 | */ |
| 39 | function update_plugins_row( registered, activated, count, localize ) { |
| 40 | for ( var init in registered ) { |
| 41 | var plugin = registered[ init ]; |
| 42 | for ( var headers in plugin ) { |
| 43 | |
| 44 | if ( headers == 'slug' || version_compare( plugin[ headers ].Version, plugin[ headers ].Latest, '=' ) ) { |
| 45 | continue; |
| 46 | } |
| 47 | |
| 48 | count = parseInt( count ) + 1; |
| 49 | $( ".plugin-count" ).empty().html( count ); |
| 50 | |
| 51 | var regex = new RegExp( ' ', 'g' ), |
| 52 | info = plugin[ headers ], |
| 53 | name = '' + info.Name, |
| 54 | id = name.replace( regex, '-' ).trim(), |
| 55 | row = '*[data-slug="' + id.toLowerCase() + '"]'; |
| 56 | |
| 57 | $( row ).addClass( "update" ); |
| 58 | |
| 59 | var html = '<tr class="plugin-update-tr">' + |
| 60 | '<td colspan="3" class="plugin-update colspanchange">' + |
| 61 | '<div class="update-message notice inline notice-warning notice-alt">' + localize.strings.new_version.replace( '%plugin_name%', name ) + |
| 62 | '<a class="thickbox open-plugin-details-modal" href="' + localize.details_url[ init ] + '">' + localize.strings.latest.replace( '%latest%', plugin[ headers ].Latest ) + '</a>'; |
| 63 | |
| 64 | if ( typeof activated[ init ] == "undefined" ) { |
| 65 | |
| 66 | html = html + |
| 67 | ' <em>' + localize.strings.unavailable + '</em>' + |
| 68 | localize.strings.activate.replace( '%activate_link%', localize.licence_activation_url ).replace( '%plugin_name%', name ); |
| 69 | } else { |
| 70 | html = html + |
| 71 | '. <a href="' + localize.update_url[ init ] + '">' + localize.strings.update_now + '</a>'; |
| 72 | } |
| 73 | |
| 74 | if( version_compare( plugin[ headers ].Version, plugin[ headers ].Latest, '>' ) ){ |
| 75 | html = html + localize.strings.version_issue.replace( '%plugin_name%', name ) |
| 76 | } |
| 77 | |
| 78 | html = html + |
| 79 | '</div>' + |
| 80 | '</td>' + |
| 81 | '</tr>'; |
| 82 | |
| 83 | $( html ).insertAfter( row ); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * |
| 90 | * @param v1 Version 1 |
| 91 | * @param v2 Version 2 |
| 92 | * @param operator Compare type |
| 93 | * @returns bool |
| 94 | * |
| 95 | * @see php.js library http://phpjs.org/ |
| 96 | */ |
| 97 | function version_compare( v1, v2, operator ) { |
| 98 | // discuss at: http://phpjs.org/functions/version_compare/ |
| 99 | // original by: Philippe Jausions (http://pear.php.net/user/jausions) |
| 100 | // original by: Aidan Lister (http://aidanlister.com/) |
| 101 | // reimplemented by: Kankrelune (http://www.webfaktory.info/) |
| 102 | // improved by: Brett Zamir (http://brett-zamir.me) |
| 103 | // improved by: Scott Baker |
| 104 | // improved by: Theriault |
| 105 | // example 1: version_compare('8.2.5rc', '8.2.5a'); |
| 106 | // returns 1: 1 |
| 107 | // example 2: version_compare('8.2.50', '8.2.52', '<'); |
| 108 | // returns 2: true |
| 109 | // example 3: version_compare('5.3.0-dev', '5.3.0'); |
| 110 | // returns 3: -1 |
| 111 | // example 4: version_compare('4.1.0.52','4.01.0.51'); |
| 112 | // returns 4: 1 |
| 113 | |
| 114 | this.php_js = this.php_js || {}; |
| 115 | this.php_js.ENV = this.php_js.ENV || {}; |
| 116 | // END REDUNDANT |
| 117 | // Important: compare must be initialized at 0. |
| 118 | var i = 0, |
| 119 | x = 0, |
| 120 | compare = 0, |
| 121 | // vm maps textual PHP versions to negatives so they're less than 0. |
| 122 | // PHP currently defines these as CASE-SENSITIVE. It is important to |
| 123 | // leave these as negatives so that they can come before numerical versions |
| 124 | // and as if no letters were there to begin with. |
| 125 | // (1alpha is < 1 and < 1.1 but > 1dev1) |
| 126 | // If a non-numerical value can't be mapped to this table, it receives |
| 127 | // -7 as its value. |
| 128 | vm = { |
| 129 | 'dev' : -6, |
| 130 | 'alpha': -5, |
| 131 | 'a' : -5, |
| 132 | 'beta' : -4, |
| 133 | 'b' : -4, |
| 134 | 'RC' : -3, |
| 135 | 'rc' : -3, |
| 136 | '#' : -2, |
| 137 | 'p' : 1, |
| 138 | 'pl' : 1 |
| 139 | }, |
| 140 | // This function will be called to prepare each version argument. |
| 141 | // It replaces every _, -, and + with a dot. |
| 142 | // It surrounds any nonsequence of numbers/dots with dots. |
| 143 | // It replaces sequences of dots with a single dot. |
| 144 | // version_compare('4..0', '4.0') == 0 |
| 145 | // Important: A string of 0 length needs to be converted into a value |
| 146 | // even less than an unexisting value in vm (-7), hence [-8]. |
| 147 | // It's also important to not strip spaces because of this. |
| 148 | // version_compare('', ' ') == 1 |
| 149 | prepVersion = function ( v ) { |
| 150 | v = ('' + v) |
| 151 | .replace( /[_\-+]/g, '.' ); |
| 152 | v = v.replace( /([^.\d]+)/g, '.$1.' ) |
| 153 | .replace( /\.{2,}/g, '.' ); |
| 154 | return (!v.length ? [ -8 ] : v.split( '.' )); |
| 155 | }; |
| 156 | // This converts a version component to a number. |
| 157 | // Empty component becomes 0. |
| 158 | // Non-numerical component becomes a negative number. |
| 159 | // Numerical component becomes itself as an integer. |
| 160 | numVersion = function ( v ) { |
| 161 | return !v ? 0 : (isNaN( v ) ? vm[ v ] || -7 : parseInt( v, 10 )); |
| 162 | }; |
| 163 | v1 = prepVersion( v1 ); |
| 164 | v2 = prepVersion( v2 ); |
| 165 | x = Math.max( v1.length, v2.length ); |
| 166 | for ( i = 0; i < x; i++ ) { |
| 167 | if ( v1[ i ] == v2[ i ] ) { |
| 168 | continue; |
| 169 | } |
| 170 | v1[ i ] = numVersion( v1[ i ] ); |
| 171 | v2[ i ] = numVersion( v2[ i ] ); |
| 172 | if ( v1[ i ] < v2[ i ] ) { |
| 173 | compare = -1; |
| 174 | break; |
| 175 | } else if ( v1[ i ] > v2[ i ] ) { |
| 176 | compare = 1; |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | if ( !operator ) { |
| 181 | return compare; |
| 182 | } |
| 183 | |
| 184 | // Important: operator is CASE-SENSITIVE. |
| 185 | // "No operator" seems to be treated as "<." |
| 186 | // Any other values seem to make the function return null. |
| 187 | switch ( operator ) { |
| 188 | case '>': |
| 189 | case 'gt': |
| 190 | return (compare > 0); |
| 191 | case '>=': |
| 192 | case 'ge': |
| 193 | return (compare >= 0); |
| 194 | case '<=': |
| 195 | case 'le': |
| 196 | return (compare <= 0); |
| 197 | case '==': |
| 198 | case '=': |
| 199 | case 'eq': |
| 200 | return (compare === 0); |
| 201 | case '<>': |
| 202 | case '!=': |
| 203 | case 'ne': |
| 204 | return (compare !== 0); |
| 205 | case '': |
| 206 | case '<': |
| 207 | case 'lt': |
| 208 | return (compare < 0); |
| 209 | default: |
| 210 | return null; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | // fix ThickBox issue (width-height) when opening a changelog |
| 215 | $( 'body' ).on( 'click', '.yit-changelog-button', function () { |
| 216 | $( '#TB_window' ).remove(); |
| 217 | } ); |
| 218 | |
| 219 | |
| 220 | })( jQuery ); |
| 221 |