script-loader.php 111 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942
  1. <?php
  2. /**
  3. * WordPress scripts and styles default loader.
  4. *
  5. * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
  6. * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
  7. * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
  8. * define('COMPRESS_SCRIPTS', false); disables compression of scripts,
  9. * define('COMPRESS_CSS', false); disables compression of CSS,
  10. * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
  11. *
  12. * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
  13. * to temporarily override the above settings. Also a compression test is run once and the result is saved
  14. * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
  15. *
  16. * @package WordPress
  17. */
  18. /** WordPress Dependency Class */
  19. require( ABSPATH . WPINC . '/class-wp-dependency.php' );
  20. /** WordPress Dependencies Class */
  21. require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
  22. /** WordPress Scripts Class */
  23. require( ABSPATH . WPINC . '/class.wp-scripts.php' );
  24. /** WordPress Scripts Functions */
  25. require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
  26. /** WordPress Styles Class */
  27. require( ABSPATH . WPINC . '/class.wp-styles.php' );
  28. /** WordPress Styles Functions */
  29. require( ABSPATH . WPINC . '/functions.wp-styles.php' );
  30. /**
  31. * Registers TinyMCE scripts.
  32. *
  33. * @since 5.0.0
  34. *
  35. * @param WP_Scripts $scripts WP_Scripts object.
  36. */
  37. function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) {
  38. global $tinymce_version, $concatenate_scripts, $compress_scripts;
  39. $suffix = wp_scripts_get_suffix();
  40. $dev_suffix = wp_scripts_get_suffix( 'dev' );
  41. script_concat_settings();
  42. $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
  43. && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;
  44. // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or
  45. // tinymce.min.js (when SCRIPT_DEBUG is true).
  46. if ( $compressed ) {
  47. $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
  48. } else {
  49. $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
  50. $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
  51. }
  52. $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
  53. }
  54. /**
  55. * Registers all the WordPress vendor scripts that are in the standardized
  56. * `js/dist/vendor/` location.
  57. *
  58. * For the order of `$scripts->add` see `wp_default_scripts`.
  59. *
  60. * @since 5.0.0
  61. *
  62. * @param WP_Scripts $scripts WP_Scripts object.
  63. */
  64. function wp_default_packages_vendor( &$scripts ) {
  65. global $wp_locale;
  66. $suffix = wp_scripts_get_suffix();
  67. $vendor_scripts = array(
  68. 'react' => array( 'wp-polyfill' ),
  69. 'react-dom' => array( 'react' ),
  70. 'moment',
  71. 'lodash',
  72. 'wp-polyfill-fetch',
  73. 'wp-polyfill-formdata',
  74. 'wp-polyfill-node-contains',
  75. 'wp-polyfill-element-closest',
  76. 'wp-polyfill',
  77. );
  78. $vendor_scripts_versions = array(
  79. 'react' => '16.9.0',
  80. 'react-dom' => '16.9.0',
  81. 'moment' => '2.22.2',
  82. 'lodash' => '4.17.15',
  83. 'wp-polyfill-fetch' => '3.0.0',
  84. 'wp-polyfill-formdata' => '3.0.12',
  85. 'wp-polyfill-node-contains' => '3.26.0-0',
  86. 'wp-polyfill-element-closest' => '2.0.2',
  87. 'wp-polyfill' => '7.4.4',
  88. );
  89. foreach ( $vendor_scripts as $handle => $dependencies ) {
  90. if ( is_string( $dependencies ) ) {
  91. $handle = $dependencies;
  92. $dependencies = array();
  93. }
  94. $path = "/wp-includes/js/dist/vendor/$handle$suffix.js";
  95. $version = $vendor_scripts_versions[ $handle ];
  96. $scripts->add( $handle, $path, $dependencies, $version, 1 );
  97. }
  98. $scripts->add( 'wp-polyfill', null, array( 'wp-polyfill' ) );
  99. did_action( 'init' ) && $scripts->add_inline_script(
  100. 'wp-polyfill',
  101. wp_get_script_polyfill(
  102. $scripts,
  103. array(
  104. '\'fetch\' in window' => 'wp-polyfill-fetch',
  105. 'document.contains' => 'wp-polyfill-node-contains',
  106. 'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
  107. 'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
  108. )
  109. )
  110. );
  111. did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );
  112. did_action( 'init' ) && $scripts->add_inline_script(
  113. 'moment',
  114. sprintf(
  115. "moment.locale( '%s', %s );",
  116. get_user_locale(),
  117. wp_json_encode(
  118. array(
  119. 'months' => array_values( $wp_locale->month ),
  120. 'monthsShort' => array_values( $wp_locale->month_abbrev ),
  121. 'weekdays' => array_values( $wp_locale->weekday ),
  122. 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
  123. 'week' => array(
  124. 'dow' => (int) get_option( 'start_of_week', 0 ),
  125. ),
  126. 'longDateFormat' => array(
  127. 'LT' => get_option( 'time_format', __( 'g:i a', 'default' ) ),
  128. 'LTS' => null,
  129. 'L' => null,
  130. 'LL' => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
  131. 'LLL' => __( 'F j, Y g:i a', 'default' ),
  132. 'LLLL' => null,
  133. ),
  134. )
  135. )
  136. ),
  137. 'after'
  138. );
  139. }
  140. /**
  141. * Returns contents of an inline script used in appending polyfill scripts for
  142. * browsers which fail the provided tests. The provided array is a mapping from
  143. * a condition to verify feature support to its polyfill script handle.
  144. *
  145. * @since 5.0.0
  146. *
  147. * @param WP_Scripts $scripts WP_Scripts object.
  148. * @param array $tests Features to detect.
  149. * @return string Conditional polyfill inline script.
  150. */
  151. function wp_get_script_polyfill( &$scripts, $tests ) {
  152. $polyfill = '';
  153. foreach ( $tests as $test => $handle ) {
  154. if ( ! array_key_exists( $handle, $scripts->registered ) ) {
  155. continue;
  156. }
  157. $src = $scripts->registered[ $handle ]->src;
  158. $ver = $scripts->registered[ $handle ]->ver;
  159. if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $scripts->content_url && 0 === strpos( $src, $scripts->content_url ) ) ) {
  160. $src = $scripts->base_url . $src;
  161. }
  162. if ( ! empty( $ver ) ) {
  163. $src = add_query_arg( 'ver', $ver, $src );
  164. }
  165. /** This filter is documented in wp-includes/class.wp-scripts.php */
  166. $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
  167. if ( ! $src ) {
  168. continue;
  169. }
  170. $polyfill .= (
  171. // Test presence of feature...
  172. '( ' . $test . ' ) || ' .
  173. // ...appending polyfill on any failures. Cautious viewers may balk
  174. // at the `document.write`. Its caveat of synchronous mid-stream
  175. // blocking write is exactly the behavior we need though.
  176. 'document.write( \'<script src="' .
  177. $src .
  178. '"></scr\' + \'ipt>\' );'
  179. );
  180. }
  181. return $polyfill;
  182. }
  183. /**
  184. * Registers all the WordPress packages scripts that are in the standardized
  185. * `js/dist/` location.
  186. *
  187. * For the order of `$scripts->add` see `wp_default_scripts`.
  188. *
  189. * @since 5.0.0
  190. *
  191. * @param WP_Scripts $scripts WP_Scripts object.
  192. */
  193. function wp_default_packages_scripts( &$scripts ) {
  194. $suffix = wp_scripts_get_suffix();
  195. $packages_versions = array(
  196. 'a11y' => '2.5.1',
  197. 'annotations' => '1.7.2',
  198. 'api-fetch' => '3.6.4',
  199. 'autop' => '2.5.1',
  200. 'blob' => '2.5.1',
  201. 'block-editor' => '3.2.4',
  202. 'block-library' => '2.9.5',
  203. 'block-serialization-default-parser' => '3.4.1',
  204. 'blocks' => '6.7.2',
  205. 'components' => '8.3.2',
  206. 'compose' => '3.7.2',
  207. 'core-data' => '2.7.4',
  208. 'data-controls' => '1.3.4',
  209. 'data' => '4.9.2',
  210. 'date' => '3.5.0',
  211. 'deprecated' => '2.6.1',
  212. 'dom-ready' => '2.5.1',
  213. 'dom' => '2.5.2',
  214. 'edit-post' => '3.8.5',
  215. 'editor' => '9.7.5',
  216. 'element' => '2.8.2',
  217. 'escape-html' => '1.5.1',
  218. 'format-library' => '1.9.4',
  219. 'hooks' => '2.6.0',
  220. 'html-entities' => '2.5.0',
  221. 'i18n' => '3.6.1',
  222. 'is-shallow-equal' => '1.6.1',
  223. 'keycodes' => '2.6.2',
  224. 'list-reusable-blocks' => '1.8.4',
  225. 'media-utils' => '1.2.4',
  226. 'notices' => '1.8.2',
  227. 'nux' => '3.7.2',
  228. 'plugins' => '2.7.2',
  229. 'priority-queue' => '1.3.1',
  230. 'redux-routine' => '3.6.2',
  231. 'rich-text' => '3.7.2',
  232. 'shortcode' => '2.4.1',
  233. 'server-side-render' => '1.3.4',
  234. 'token-list' => '1.6.1',
  235. 'url' => '2.8.2',
  236. 'viewport' => '2.8.2',
  237. 'wordcount' => '2.6.2',
  238. );
  239. $packages_dependencies = array(
  240. 'a11y' => array(
  241. 'wp-dom-ready',
  242. 'wp-polyfill',
  243. ),
  244. 'annotations' => array(
  245. 'lodash',
  246. 'wp-data',
  247. 'wp-hooks',
  248. 'wp-i18n',
  249. 'wp-polyfill',
  250. 'wp-rich-text',
  251. ),
  252. 'api-fetch' => array(
  253. 'wp-i18n',
  254. 'wp-polyfill',
  255. 'wp-url',
  256. ),
  257. 'autop' => array(
  258. 'wp-polyfill',
  259. ),
  260. 'blob' => array(
  261. 'wp-polyfill',
  262. ),
  263. 'block-editor' => array(
  264. 'lodash',
  265. 'wp-a11y',
  266. 'wp-blob',
  267. 'wp-blocks',
  268. 'wp-components',
  269. 'wp-compose',
  270. 'wp-data',
  271. 'wp-deprecated',
  272. 'wp-dom',
  273. 'wp-element',
  274. 'wp-hooks',
  275. 'wp-html-entities',
  276. 'wp-i18n',
  277. 'wp-is-shallow-equal',
  278. 'wp-keycodes',
  279. 'wp-polyfill',
  280. 'wp-rich-text',
  281. 'wp-token-list',
  282. 'wp-url',
  283. 'wp-viewport',
  284. 'wp-wordcount',
  285. ),
  286. 'block-library' => array(
  287. 'editor',
  288. 'lodash',
  289. 'moment',
  290. 'wp-a11y',
  291. 'wp-api-fetch',
  292. 'wp-autop',
  293. 'wp-blob',
  294. 'wp-block-editor',
  295. 'wp-blocks',
  296. 'wp-components',
  297. 'wp-compose',
  298. 'wp-core-data',
  299. 'wp-data',
  300. 'wp-date',
  301. 'wp-deprecated',
  302. 'wp-editor',
  303. 'wp-element',
  304. 'wp-i18n',
  305. 'wp-is-shallow-equal',
  306. 'wp-keycodes',
  307. 'wp-polyfill',
  308. 'wp-rich-text',
  309. 'wp-server-side-render',
  310. 'wp-url',
  311. 'wp-viewport',
  312. ),
  313. 'block-serialization-default-parser' => array(
  314. 'wp-polyfill',
  315. ),
  316. 'blocks' => array(
  317. 'lodash',
  318. 'wp-autop',
  319. 'wp-blob',
  320. 'wp-block-serialization-default-parser',
  321. 'wp-compose',
  322. 'wp-data',
  323. 'wp-dom',
  324. 'wp-element',
  325. 'wp-hooks',
  326. 'wp-html-entities',
  327. 'wp-i18n',
  328. 'wp-is-shallow-equal',
  329. 'wp-polyfill',
  330. 'wp-shortcode',
  331. ),
  332. 'components' => array(
  333. 'lodash',
  334. 'moment',
  335. 'wp-a11y',
  336. 'wp-compose',
  337. 'wp-deprecated',
  338. 'wp-dom',
  339. 'wp-element',
  340. 'wp-hooks',
  341. 'wp-i18n',
  342. 'wp-is-shallow-equal',
  343. 'wp-keycodes',
  344. 'wp-polyfill',
  345. 'wp-rich-text',
  346. ),
  347. 'compose' => array(
  348. 'lodash',
  349. 'wp-element',
  350. 'wp-is-shallow-equal',
  351. 'wp-polyfill',
  352. ),
  353. 'core-data' => array(
  354. 'lodash',
  355. 'wp-api-fetch',
  356. 'wp-data',
  357. 'wp-deprecated',
  358. 'wp-is-shallow-equal',
  359. 'wp-polyfill',
  360. 'wp-url',
  361. ),
  362. 'data' => array(
  363. 'lodash',
  364. 'wp-compose',
  365. 'wp-deprecated',
  366. 'wp-element',
  367. 'wp-is-shallow-equal',
  368. 'wp-polyfill',
  369. 'wp-priority-queue',
  370. 'wp-redux-routine',
  371. ),
  372. 'data-controls' => array(
  373. 'wp-api-fetch',
  374. 'wp-data',
  375. 'wp-polyfill',
  376. ),
  377. 'date' => array(
  378. 'moment',
  379. 'wp-polyfill',
  380. ),
  381. 'deprecated' => array(
  382. 'wp-hooks',
  383. 'wp-polyfill',
  384. ),
  385. 'dom' => array(
  386. 'lodash',
  387. 'wp-polyfill',
  388. ),
  389. 'dom-ready' => array(
  390. 'wp-polyfill',
  391. ),
  392. 'edit-post' => array(
  393. 'lodash',
  394. 'postbox',
  395. 'media-models',
  396. 'media-views',
  397. 'wp-a11y',
  398. 'wp-api-fetch',
  399. 'wp-block-editor',
  400. 'wp-block-library',
  401. 'wp-blocks',
  402. 'wp-components',
  403. 'wp-compose',
  404. 'wp-core-data',
  405. 'wp-data',
  406. 'wp-dom-ready',
  407. 'wp-editor',
  408. 'wp-element',
  409. 'wp-hooks',
  410. 'wp-i18n',
  411. 'wp-keycodes',
  412. 'wp-media-utils',
  413. 'wp-notices',
  414. 'wp-nux',
  415. 'wp-plugins',
  416. 'wp-polyfill',
  417. 'wp-url',
  418. 'wp-viewport',
  419. ),
  420. 'editor' => array(
  421. 'lodash',
  422. 'wp-api-fetch',
  423. 'wp-autop',
  424. 'wp-block-editor',
  425. 'wp-blocks',
  426. 'wp-components',
  427. 'wp-compose',
  428. 'wp-core-data',
  429. 'wp-data',
  430. 'wp-data-controls',
  431. 'wp-date',
  432. 'wp-deprecated',
  433. 'wp-element',
  434. 'wp-hooks',
  435. 'wp-html-entities',
  436. 'wp-i18n',
  437. 'wp-is-shallow-equal',
  438. 'wp-keycodes',
  439. 'wp-media-utils',
  440. 'wp-notices',
  441. 'wp-nux',
  442. 'wp-polyfill',
  443. 'wp-rich-text',
  444. 'wp-server-side-render',
  445. 'wp-url',
  446. 'wp-viewport',
  447. 'wp-wordcount',
  448. ),
  449. 'element' => array(
  450. 'lodash',
  451. 'react',
  452. 'react-dom',
  453. 'wp-escape-html',
  454. 'wp-polyfill',
  455. ),
  456. 'escape-html' => array(
  457. 'wp-polyfill',
  458. ),
  459. 'format-library' => array(
  460. 'lodash',
  461. 'wp-block-editor',
  462. 'wp-components',
  463. 'wp-dom',
  464. 'wp-element',
  465. 'wp-html-entities',
  466. 'wp-i18n',
  467. 'wp-keycodes',
  468. 'wp-polyfill',
  469. 'wp-rich-text',
  470. 'wp-url',
  471. ),
  472. 'hooks' => array(
  473. 'wp-polyfill',
  474. ),
  475. 'html-entities' => array(
  476. 'wp-polyfill',
  477. ),
  478. 'i18n' => array(
  479. 'wp-polyfill',
  480. ),
  481. 'is-shallow-equal' => array(
  482. 'wp-polyfill',
  483. ),
  484. 'keycodes' => array(
  485. 'lodash',
  486. 'wp-i18n',
  487. 'wp-polyfill',
  488. ),
  489. 'list-reusable-blocks' => array(
  490. 'lodash',
  491. 'wp-api-fetch',
  492. 'wp-components',
  493. 'wp-compose',
  494. 'wp-element',
  495. 'wp-i18n',
  496. 'wp-polyfill',
  497. ),
  498. 'media-utils' => array(
  499. 'lodash',
  500. 'wp-api-fetch',
  501. 'wp-blob',
  502. 'wp-element',
  503. 'wp-i18n',
  504. 'wp-polyfill',
  505. ),
  506. 'notices' => array(
  507. 'lodash',
  508. 'wp-a11y',
  509. 'wp-data',
  510. 'wp-polyfill',
  511. ),
  512. 'nux' => array(
  513. 'lodash',
  514. 'wp-components',
  515. 'wp-compose',
  516. 'wp-data',
  517. 'wp-element',
  518. 'wp-i18n',
  519. 'wp-polyfill',
  520. ),
  521. 'plugins' => array(
  522. 'lodash',
  523. 'wp-compose',
  524. 'wp-element',
  525. 'wp-hooks',
  526. 'wp-polyfill',
  527. ),
  528. 'priority-queue' => array(
  529. 'wp-polyfill',
  530. ),
  531. 'redux-routine' => array(
  532. 'lodash',
  533. 'wp-polyfill',
  534. ),
  535. 'rich-text' => array(
  536. 'lodash',
  537. 'wp-compose',
  538. 'wp-data',
  539. 'wp-element',
  540. 'wp-escape-html',
  541. 'wp-hooks',
  542. 'wp-is-shallow-equal',
  543. 'wp-keycodes',
  544. 'wp-polyfill',
  545. ),
  546. 'server-side-render' => array(
  547. 'lodash',
  548. 'wp-api-fetch',
  549. 'wp-components',
  550. 'wp-data',
  551. 'wp-deprecated',
  552. 'wp-element',
  553. 'wp-i18n',
  554. 'wp-polyfill',
  555. 'wp-url',
  556. ),
  557. 'shortcode' => array(
  558. 'lodash',
  559. 'wp-polyfill',
  560. ),
  561. 'token-list' => array(
  562. 'lodash',
  563. 'wp-polyfill',
  564. ),
  565. 'url' => array(
  566. 'wp-polyfill',
  567. ),
  568. 'viewport' => array(
  569. 'lodash',
  570. 'wp-compose',
  571. 'wp-data',
  572. 'wp-polyfill',
  573. ),
  574. 'wordcount' => array(
  575. 'lodash',
  576. 'wp-polyfill',
  577. ),
  578. );
  579. $package_translations = array(
  580. 'api-fetch',
  581. 'blocks',
  582. 'block-editor',
  583. 'block-library',
  584. 'components',
  585. 'edit-post',
  586. 'editor',
  587. 'format-library',
  588. 'keycodes',
  589. 'list-reusable-blocks',
  590. 'nux',
  591. );
  592. foreach ( $packages_dependencies as $package => $dependencies ) {
  593. $handle = 'wp-' . $package;
  594. $path = "/wp-includes/js/dist/$package$suffix.js";
  595. $version = $packages_versions[ $package ];
  596. $scripts->add( $handle, $path, $dependencies, $version, 1 );
  597. if ( in_array( $package, $package_translations, true ) ) {
  598. $scripts->set_translations( $handle );
  599. }
  600. }
  601. }
  602. /**
  603. * Adds inline scripts required for the WordPress JavaScript packages.
  604. *
  605. * @since 5.0.0
  606. *
  607. * @param WP_Scripts $scripts WP_Scripts object.
  608. */
  609. function wp_default_packages_inline_scripts( &$scripts ) {
  610. global $wp_locale;
  611. if ( isset( $scripts->registered['wp-api-fetch'] ) ) {
  612. $scripts->registered['wp-api-fetch']->deps[] = 'wp-hooks';
  613. }
  614. $scripts->add_inline_script(
  615. 'wp-api-fetch',
  616. sprintf(
  617. 'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
  618. esc_url_raw( get_rest_url() )
  619. ),
  620. 'after'
  621. );
  622. $scripts->add_inline_script(
  623. 'wp-api-fetch',
  624. implode(
  625. "\n",
  626. array(
  627. sprintf(
  628. 'wp.apiFetch.nonceMiddleware = wp.apiFetch.createNonceMiddleware( "%s" );',
  629. ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
  630. ),
  631. 'wp.apiFetch.use( wp.apiFetch.nonceMiddleware );',
  632. 'wp.apiFetch.use( wp.apiFetch.mediaUploadMiddleware );',
  633. sprintf(
  634. 'wp.apiFetch.nonceEndpoint = "%s";',
  635. admin_url( 'admin-ajax.php?action=rest-nonce' )
  636. ),
  637. )
  638. ),
  639. 'after'
  640. );
  641. $scripts->add_inline_script(
  642. 'wp-data',
  643. implode(
  644. "\n",
  645. array(
  646. '( function() {',
  647. ' var userId = ' . get_current_user_ID() . ';',
  648. ' var storageKey = "WP_DATA_USER_" + userId;',
  649. ' wp.data',
  650. ' .use( wp.data.plugins.persistence, { storageKey: storageKey } );',
  651. ' wp.data.plugins.persistence.__unstableMigrate( { storageKey: storageKey } );',
  652. '} )();',
  653. )
  654. )
  655. );
  656. $scripts->add_inline_script(
  657. 'wp-date',
  658. sprintf(
  659. 'wp.date.setSettings( %s );',
  660. wp_json_encode(
  661. array(
  662. 'l10n' => array(
  663. 'locale' => get_user_locale(),
  664. 'months' => array_values( $wp_locale->month ),
  665. 'monthsShort' => array_values( $wp_locale->month_abbrev ),
  666. 'weekdays' => array_values( $wp_locale->weekday ),
  667. 'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
  668. 'meridiem' => (object) $wp_locale->meridiem,
  669. 'relative' => array(
  670. /* translators: %s: Duration. */
  671. 'future' => __( '%s from now' ),
  672. /* translators: %s: Duration. */
  673. 'past' => __( '%s ago' ),
  674. ),
  675. ),
  676. 'formats' => array(
  677. /* translators: Time format, see https://secure.php.net/date */
  678. 'time' => get_option( 'time_format', __( 'g:i a' ) ),
  679. /* translators: Date format, see https://secure.php.net/date */
  680. 'date' => get_option( 'date_format', __( 'F j, Y' ) ),
  681. /* translators: Date/Time format, see https://secure.php.net/date */
  682. 'datetime' => __( 'F j, Y g:i a' ),
  683. /* translators: Abbreviated date/time format, see https://secure.php.net/date */
  684. 'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
  685. ),
  686. 'timezone' => array(
  687. 'offset' => get_option( 'gmt_offset', 0 ),
  688. 'string' => get_option( 'timezone_string', 'UTC' ),
  689. ),
  690. )
  691. )
  692. ),
  693. 'after'
  694. );
  695. // Loading the old editor and its config to ensure the classic block works as expected.
  696. $scripts->add_inline_script(
  697. 'editor',
  698. 'window.wp.oldEditor = window.wp.editor;',
  699. 'after'
  700. );
  701. }
  702. /**
  703. * Adds inline scripts required for the TinyMCE in the block editor.
  704. *
  705. * These TinyMCE init settings are used to extend and override the default settings
  706. * from `_WP_Editors::default_settings()` for the Classic block.
  707. *
  708. * @since 5.0.0
  709. *
  710. * @global WP_Scripts $wp_scripts
  711. */
  712. function wp_tinymce_inline_scripts() {
  713. global $wp_scripts;
  714. /** This filter is documented in wp-includes/class-wp-editor.php */
  715. $editor_settings = apply_filters( 'wp_editor_settings', array( 'tinymce' => true ), 'classic-block' );
  716. $tinymce_plugins = array(
  717. 'charmap',
  718. 'colorpicker',
  719. 'hr',
  720. 'lists',
  721. 'media',
  722. 'paste',
  723. 'tabfocus',
  724. 'textcolor',
  725. 'fullscreen',
  726. 'wordpress',
  727. 'wpautoresize',
  728. 'wpeditimage',
  729. 'wpemoji',
  730. 'wpgallery',
  731. 'wplink',
  732. 'wpdialogs',
  733. 'wptextpattern',
  734. 'wpview',
  735. );
  736. /* This filter is documented in wp-includes/class-wp-editor.php */
  737. $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' );
  738. $tinymce_plugins = array_unique( $tinymce_plugins );
  739. $disable_captions = false;
  740. // Runs after `tiny_mce_plugins` but before `mce_buttons`.
  741. /** This filter is documented in wp-admin/includes/media.php */
  742. if ( apply_filters( 'disable_captions', '' ) ) {
  743. $disable_captions = true;
  744. }
  745. $toolbar1 = array(
  746. 'formatselect',
  747. 'bold',
  748. 'italic',
  749. 'bullist',
  750. 'numlist',
  751. 'blockquote',
  752. 'alignleft',
  753. 'aligncenter',
  754. 'alignright',
  755. 'link',
  756. 'unlink',
  757. 'wp_more',
  758. 'spellchecker',
  759. 'wp_add_media',
  760. 'wp_adv',
  761. );
  762. /* This filter is documented in wp-includes/class-wp-editor.php */
  763. $toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' );
  764. $toolbar2 = array(
  765. 'strikethrough',
  766. 'hr',
  767. 'forecolor',
  768. 'pastetext',
  769. 'removeformat',
  770. 'charmap',
  771. 'outdent',
  772. 'indent',
  773. 'undo',
  774. 'redo',
  775. 'wp_help',
  776. );
  777. /* This filter is documented in wp-includes/class-wp-editor.php */
  778. $toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' );
  779. /* This filter is documented in wp-includes/class-wp-editor.php */
  780. $toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' );
  781. /* This filter is documented in wp-includes/class-wp-editor.php */
  782. $toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' );
  783. /* This filter is documented in wp-includes/class-wp-editor.php */
  784. $external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' );
  785. $tinymce_settings = array(
  786. 'plugins' => implode( ',', $tinymce_plugins ),
  787. 'toolbar1' => implode( ',', $toolbar1 ),
  788. 'toolbar2' => implode( ',', $toolbar2 ),
  789. 'toolbar3' => implode( ',', $toolbar3 ),
  790. 'toolbar4' => implode( ',', $toolbar4 ),
  791. 'external_plugins' => wp_json_encode( $external_plugins ),
  792. 'classic_block_editor' => true,
  793. );
  794. if ( $disable_captions ) {
  795. $tinymce_settings['wpeditimage_disable_captions'] = true;
  796. }
  797. if ( ! empty( $editor_settings['tinymce'] ) && is_array( $editor_settings['tinymce'] ) ) {
  798. array_merge( $tinymce_settings, $editor_settings['tinymce'] );
  799. }
  800. /* This filter is documented in wp-includes/class-wp-editor.php */
  801. $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' );
  802. // Do "by hand" translation from PHP array to js object.
  803. // Prevents breakage in some custom settings.
  804. $init_obj = '';
  805. foreach ( $tinymce_settings as $key => $value ) {
  806. if ( is_bool( $value ) ) {
  807. $val = $value ? 'true' : 'false';
  808. $init_obj .= $key . ':' . $val . ',';
  809. continue;
  810. } elseif ( ! empty( $value ) && is_string( $value ) && (
  811. ( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) ||
  812. ( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) ||
  813. preg_match( '/^\(?function ?\(/', $value ) ) ) {
  814. $init_obj .= $key . ':' . $value . ',';
  815. continue;
  816. }
  817. $init_obj .= $key . ':"' . $value . '",';
  818. }
  819. $init_obj = '{' . trim( $init_obj, ' ,' ) . '}';
  820. $script = 'window.wpEditorL10n = {
  821. tinymce: {
  822. baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ',
  823. suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ',
  824. settings: ' . $init_obj . ',
  825. }
  826. }';
  827. $wp_scripts->add_inline_script( 'wp-block-library', $script, 'before' );
  828. }
  829. /**
  830. * Registers all the WordPress packages scripts.
  831. *
  832. * @since 5.0.0
  833. *
  834. * @param WP_Scripts $scripts WP_Scripts object.
  835. */
  836. function wp_default_packages( &$scripts ) {
  837. wp_default_packages_vendor( $scripts );
  838. wp_register_tinymce_scripts( $scripts );
  839. wp_default_packages_scripts( $scripts );
  840. if ( did_action( 'init' ) ) {
  841. wp_default_packages_inline_scripts( $scripts );
  842. }
  843. }
  844. /**
  845. * Returns the suffix that can be used for the scripts.
  846. *
  847. * There are two suffix types, the normal one and the dev suffix.
  848. *
  849. * @since 5.0.0
  850. *
  851. * @param string $type The type of suffix to retrieve.
  852. * @return string The script suffix.
  853. */
  854. function wp_scripts_get_suffix( $type = '' ) {
  855. static $suffixes;
  856. if ( $suffixes === null ) {
  857. include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
  858. $develop_src = false !== strpos( $wp_version, '-src' );
  859. if ( ! defined( 'SCRIPT_DEBUG' ) ) {
  860. define( 'SCRIPT_DEBUG', $develop_src );
  861. }
  862. $suffix = SCRIPT_DEBUG ? '' : '.min';
  863. $dev_suffix = $develop_src ? '' : '.min';
  864. $suffixes = array(
  865. 'suffix' => $suffix,
  866. 'dev_suffix' => $dev_suffix,
  867. );
  868. }
  869. if ( $type === 'dev' ) {
  870. return $suffixes['dev_suffix'];
  871. }
  872. return $suffixes['suffix'];
  873. }
  874. /**
  875. * Register all WordPress scripts.
  876. *
  877. * Localizes some of them.
  878. * args order: `$scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );`
  879. * when last arg === 1 queues the script for the footer
  880. *
  881. * @since 2.6.0
  882. *
  883. * @param WP_Scripts $scripts WP_Scripts object.
  884. */
  885. function wp_default_scripts( &$scripts ) {
  886. $suffix = wp_scripts_get_suffix();
  887. $dev_suffix = wp_scripts_get_suffix( 'dev' );
  888. $guessurl = site_url();
  889. if ( ! $guessurl ) {
  890. $guessed_url = true;
  891. $guessurl = wp_guess_url();
  892. }
  893. $scripts->base_url = $guessurl;
  894. $scripts->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
  895. $scripts->default_version = get_bloginfo( 'version' );
  896. $scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' );
  897. $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" );
  898. did_action( 'init' ) && $scripts->localize(
  899. 'utils',
  900. 'userSettings',
  901. array(
  902. 'url' => (string) SITECOOKIEPATH,
  903. 'uid' => (string) get_current_user_id(),
  904. 'time' => (string) time(),
  905. 'secure' => (string) ( 'https' === parse_url( site_url(), PHP_URL_SCHEME ) ),
  906. )
  907. );
  908. $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverIntent', 'utils' ), false, 1 );
  909. did_action( 'init' ) && $scripts->localize(
  910. 'common',
  911. 'commonL10n',
  912. array(
  913. 'warnDelete' => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
  914. 'dismiss' => __( 'Dismiss this notice.' ),
  915. 'collapseMenu' => __( 'Collapse Main menu' ),
  916. 'expandMenu' => __( 'Expand Main menu' ),
  917. )
  918. );
  919. $scripts->add( 'wp-sanitize', "/wp-includes/js/wp-sanitize$suffix.js", array(), false, 1 );
  920. $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", array(), '1.6.1', 1 );
  921. $scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", array(), false, 1 );
  922. did_action( 'init' ) && $scripts->localize(
  923. 'quicktags',
  924. 'quicktagsL10n',
  925. array(
  926. 'closeAllOpenTags' => __( 'Close all open tags' ),
  927. 'closeTags' => __( 'close tags' ),
  928. 'enterURL' => __( 'Enter the URL' ),
  929. 'enterImageURL' => __( 'Enter the URL of the image' ),
  930. 'enterImageDescription' => __( 'Enter a description of the image' ),
  931. 'textdirection' => __( 'text direction' ),
  932. 'toggleTextdirection' => __( 'Toggle Editor Text Direction' ),
  933. 'dfw' => __( 'Distraction-free writing mode' ),
  934. 'strong' => __( 'Bold' ),
  935. 'strongClose' => __( 'Close bold tag' ),
  936. 'em' => __( 'Italic' ),
  937. 'emClose' => __( 'Close italic tag' ),
  938. 'link' => __( 'Insert link' ),
  939. 'blockquote' => __( 'Blockquote' ),
  940. 'blockquoteClose' => __( 'Close blockquote tag' ),
  941. 'del' => __( 'Deleted text (strikethrough)' ),
  942. 'delClose' => __( 'Close deleted text tag' ),
  943. 'ins' => __( 'Inserted text' ),
  944. 'insClose' => __( 'Close inserted text tag' ),
  945. 'image' => __( 'Insert image' ),
  946. 'ul' => __( 'Bulleted list' ),
  947. 'ulClose' => __( 'Close bulleted list tag' ),
  948. 'ol' => __( 'Numbered list' ),
  949. 'olClose' => __( 'Close numbered list tag' ),
  950. 'li' => __( 'List item' ),
  951. 'liClose' => __( 'Close list item tag' ),
  952. 'code' => __( 'Code' ),
  953. 'codeClose' => __( 'Close code tag' ),
  954. 'more' => __( 'Insert Read More tag' ),
  955. )
  956. );
  957. $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array( 'prototype' ), '3517m' );
  958. $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 );
  959. $scripts->add( 'clipboard', "/wp-includes/js/clipboard$suffix.js", array(), false, 1 );
  960. // Back-compat for old DFW. To-do: remove at the end of 2016.
  961. $scripts->add( 'wp-fullscreen-stub', "/wp-admin/js/wp-fullscreen-stub$suffix.js", array(), false, 1 );
  962. $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array( 'jquery' ), false, 1 );
  963. did_action( 'init' ) && $scripts->localize(
  964. 'wp-ajax-response',
  965. 'wpAjax',
  966. array(
  967. 'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
  968. 'broken' => __( 'Something went wrong.' ),
  969. )
  970. );
  971. $scripts->add( 'wp-api-request', "/wp-includes/js/api-request$suffix.js", array( 'jquery' ), false, 1 );
  972. // `wpApiSettings` is also used by `wp-api`, which depends on this script.
  973. did_action( 'init' ) && $scripts->localize(
  974. 'wp-api-request',
  975. 'wpApiSettings',
  976. array(
  977. 'root' => esc_url_raw( get_rest_url() ),
  978. 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ),
  979. 'versionString' => 'wp/v2/',
  980. )
  981. );
  982. $scripts->add( 'wp-pointer', "/wp-includes/js/wp-pointer$suffix.js", array( 'jquery-ui-widget', 'jquery-ui-position' ), '20111129a', 1 );
  983. did_action( 'init' ) && $scripts->localize(
  984. 'wp-pointer',
  985. 'wpPointerL10n',
  986. array(
  987. 'dismiss' => __( 'Dismiss' ),
  988. )
  989. );
  990. $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array( 'heartbeat' ), false, 1 );
  991. $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array( 'jquery', 'wp-hooks' ), false, 1 );
  992. did_action( 'init' ) && $scripts->localize(
  993. 'heartbeat',
  994. 'heartbeatSettings',
  995. /**
  996. * Filters the Heartbeat settings.
  997. *
  998. * @since 3.6.0
  999. *
  1000. * @param array $settings Heartbeat settings array.
  1001. */
  1002. apply_filters( 'heartbeat_settings', array() )
  1003. );
  1004. $scripts->add( 'wp-auth-check', "/wp-includes/js/wp-auth-check$suffix.js", array( 'heartbeat' ), false, 1 );
  1005. did_action( 'init' ) && $scripts->localize(
  1006. 'wp-auth-check',
  1007. 'authcheckL10n',
  1008. array(
  1009. 'beforeunload' => __( 'Your session has expired. You can log in again from this page or go to the login page.' ),
  1010. /**
  1011. * Filters the authentication check interval.
  1012. *
  1013. * @since 3.6.0
  1014. *
  1015. * @param int $interval The interval in which to check a user's authentication.
  1016. * Default 3 minutes in seconds, or 180.
  1017. */
  1018. 'interval' => apply_filters( 'wp_auth_check_interval', 3 * MINUTE_IN_SECONDS ),
  1019. )
  1020. );
  1021. $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array( 'wp-ajax-response', 'jquery-color' ), false, 1 );
  1022. // WordPress no longer uses or bundles Prototype or script.aculo.us. These are now pulled from an external source.
  1023. $scripts->add( 'prototype', 'https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js', array(), '1.7.1' );
  1024. $scripts->add( 'scriptaculous-root', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js', array( 'prototype' ), '1.9.0' );
  1025. $scripts->add( 'scriptaculous-builder', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js', array( 'scriptaculous-root' ), '1.9.0' );
  1026. $scripts->add( 'scriptaculous-dragdrop', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js', array( 'scriptaculous-builder', 'scriptaculous-effects' ), '1.9.0' );
  1027. $scripts->add( 'scriptaculous-effects', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js', array( 'scriptaculous-root' ), '1.9.0' );
  1028. $scripts->add( 'scriptaculous-slider', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js', array( 'scriptaculous-effects' ), '1.9.0' );
  1029. $scripts->add( 'scriptaculous-sound', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js', array( 'scriptaculous-root' ), '1.9.0' );
  1030. $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' );
  1031. $scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );
  1032. // not used in core, replaced by Jcrop.js
  1033. $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) );
  1034. // jQuery
  1035. $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4-wp' );
  1036. $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.4-wp' );
  1037. $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.4.1' );
  1038. // full jQuery UI
  1039. $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  1040. $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  1041. $scripts->add( 'jquery-effects-blind', "/wp-includes/js/jquery/ui/effect-blind$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1042. $scripts->add( 'jquery-effects-bounce', "/wp-includes/js/jquery/ui/effect-bounce$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1043. $scripts->add( 'jquery-effects-clip', "/wp-includes/js/jquery/ui/effect-clip$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1044. $scripts->add( 'jquery-effects-drop', "/wp-includes/js/jquery/ui/effect-drop$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1045. $scripts->add( 'jquery-effects-explode', "/wp-includes/js/jquery/ui/effect-explode$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1046. $scripts->add( 'jquery-effects-fade', "/wp-includes/js/jquery/ui/effect-fade$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1047. $scripts->add( 'jquery-effects-fold', "/wp-includes/js/jquery/ui/effect-fold$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1048. $scripts->add( 'jquery-effects-highlight', "/wp-includes/js/jquery/ui/effect-highlight$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1049. $scripts->add( 'jquery-effects-puff', "/wp-includes/js/jquery/ui/effect-puff$dev_suffix.js", array( 'jquery-effects-core', 'jquery-effects-scale' ), '1.11.4', 1 );
  1050. $scripts->add( 'jquery-effects-pulsate', "/wp-includes/js/jquery/ui/effect-pulsate$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1051. $scripts->add( 'jquery-effects-scale', "/wp-includes/js/jquery/ui/effect-scale$dev_suffix.js", array( 'jquery-effects-core', 'jquery-effects-size' ), '1.11.4', 1 );
  1052. $scripts->add( 'jquery-effects-shake', "/wp-includes/js/jquery/ui/effect-shake$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1053. $scripts->add( 'jquery-effects-size', "/wp-includes/js/jquery/ui/effect-size$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1054. $scripts->add( 'jquery-effects-slide', "/wp-includes/js/jquery/ui/effect-slide$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1055. $scripts->add( 'jquery-effects-transfer', "/wp-includes/js/jquery/ui/effect-transfer$dev_suffix.js", array( 'jquery-effects-core' ), '1.11.4', 1 );
  1056. $scripts->add( 'jquery-ui-accordion', "/wp-includes/js/jquery/ui/accordion$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
  1057. $scripts->add( 'jquery-ui-autocomplete', "/wp-includes/js/jquery/ui/autocomplete$dev_suffix.js", array( 'jquery-ui-menu', 'wp-a11y' ), '1.11.4', 1 );
  1058. $scripts->add( 'jquery-ui-button', "/wp-includes/js/jquery/ui/button$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
  1059. $scripts->add( 'jquery-ui-datepicker', "/wp-includes/js/jquery/ui/datepicker$dev_suffix.js", array( 'jquery-ui-core' ), '1.11.4', 1 );
  1060. $scripts->add( 'jquery-ui-dialog', "/wp-includes/js/jquery/ui/dialog$dev_suffix.js", array( 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position' ), '1.11.4', 1 );
  1061. $scripts->add( 'jquery-ui-draggable', "/wp-includes/js/jquery/ui/draggable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  1062. $scripts->add( 'jquery-ui-droppable', "/wp-includes/js/jquery/ui/droppable$dev_suffix.js", array( 'jquery-ui-draggable' ), '1.11.4', 1 );
  1063. $scripts->add( 'jquery-ui-menu', "/wp-includes/js/jquery/ui/menu$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 );
  1064. $scripts->add( 'jquery-ui-mouse', "/wp-includes/js/jquery/ui/mouse$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
  1065. $scripts->add( 'jquery-ui-position', "/wp-includes/js/jquery/ui/position$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  1066. $scripts->add( 'jquery-ui-progressbar', "/wp-includes/js/jquery/ui/progressbar$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
  1067. $scripts->add( 'jquery-ui-resizable', "/wp-includes/js/jquery/ui/resizable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  1068. $scripts->add( 'jquery-ui-selectable', "/wp-includes/js/jquery/ui/selectable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  1069. $scripts->add( 'jquery-ui-selectmenu', "/wp-includes/js/jquery/ui/selectmenu$dev_suffix.js", array( 'jquery-ui-menu' ), '1.11.4', 1 );
  1070. $scripts->add( 'jquery-ui-slider', "/wp-includes/js/jquery/ui/slider$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  1071. $scripts->add( 'jquery-ui-sortable', "/wp-includes/js/jquery/ui/sortable$dev_suffix.js", array( 'jquery-ui-mouse' ), '1.11.4', 1 );
  1072. $scripts->add( 'jquery-ui-spinner', "/wp-includes/js/jquery/ui/spinner$dev_suffix.js", array( 'jquery-ui-button' ), '1.11.4', 1 );
  1073. $scripts->add( 'jquery-ui-tabs', "/wp-includes/js/jquery/ui/tabs$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.11.4', 1 );
  1074. $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 );
  1075. $scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 );
  1076. // Strings for 'jquery-ui-autocomplete' live region messages
  1077. did_action( 'init' ) && $scripts->localize(
  1078. 'jquery-ui-autocomplete',
  1079. 'uiAutocompleteL10n',
  1080. array(
  1081. 'noResults' => __( 'No results found.' ),
  1082. /* translators: Number of results found when using jQuery UI Autocomplete. */
  1083. 'oneResult' => __( '1 result found. Use up and down arrow keys to navigate.' ),
  1084. /* translators: %d: Number of results found when using jQuery UI Autocomplete. */
  1085. 'manyResults' => __( '%d results found. Use up and down arrow keys to navigate.' ),
  1086. 'itemSelected' => __( 'Item selected.' ),
  1087. )
  1088. );
  1089. // deprecated, not used in core, most functionality is included in jQuery 1.3
  1090. $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.2.1', 1 );
  1091. // jQuery plugins
  1092. $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 );
  1093. $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 );
  1094. $scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 );
  1095. $scripts->add( 'jquery-serialize-object', '/wp-includes/js/jquery/jquery.serialize-object.js', array( 'jquery' ), '0.2', 1 );
  1096. $scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array( 'jquery' ), '0.0.2m', 1 );
  1097. $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array( 'jquery', 'jquery-hotkeys' ), false, 1 );
  1098. $scripts->add( 'jquery-touch-punch', '/wp-includes/js/jquery/jquery.ui.touch-punch.js', array( 'jquery-ui-widget', 'jquery-ui-mouse' ), '0.2.2', 1 );
  1099. // Not used any more, registered for backward compatibility.
  1100. $scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array( 'jquery' ), '1.1-20110113', 1 );
  1101. // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
  1102. // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
  1103. $scripts->add( 'imagesloaded', '/wp-includes/js/imagesloaded.min.js', array(), '3.2.0', 1 );
  1104. $scripts->add( 'masonry', '/wp-includes/js/masonry.min.js', array( 'imagesloaded' ), '3.3.2', 1 );
  1105. $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2b', 1 );
  1106. $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array( 'jquery' ), '3.1-20121105', 1 );
  1107. did_action( 'init' ) && $scripts->localize(
  1108. 'thickbox',
  1109. 'thickboxL10n',
  1110. array(
  1111. 'next' => __( 'Next &gt;' ),
  1112. 'prev' => __( '&lt; Prev' ),
  1113. 'image' => __( 'Image' ),
  1114. 'of' => __( 'of' ),
  1115. 'close' => __( 'Close' ),
  1116. 'noiframes' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ),
  1117. 'loadingAnimation' => includes_url( 'js/thickbox/loadingAnimation.gif' ),
  1118. )
  1119. );
  1120. $scripts->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.js', array( 'jquery' ), '0.9.12' );
  1121. $scripts->add( 'swfobject', '/wp-includes/js/swfobject.js', array(), '2.2-20120417' );
  1122. // Error messages for Plupload.
  1123. $uploader_l10n = array(
  1124. 'queue_limit_exceeded' => __( 'You have attempted to queue too many files.' ),
  1125. /* translators: %s: File name. */
  1126. 'file_exceeds_size_limit' => __( '%s exceeds the maximum upload size for this site.' ),
  1127. 'zero_byte_file' => __( 'This file is empty. Please try another.' ),
  1128. 'invalid_filetype' => __( 'Sorry, this file type is not permitted for security reasons.' ),
  1129. 'not_an_image' => __( 'This file is not an image. Please try another.' ),
  1130. 'image_memory_exceeded' => __( 'Memory exceeded. Please try another smaller file.' ),
  1131. 'image_dimensions_exceeded' => __( 'This is larger than the maximum size. Please try another.' ),
  1132. 'default_error' => __( 'An error occurred in the upload. Please try again later.' ),
  1133. 'missing_upload_url' => __( 'There was a configuration error. Please contact the server administrator.' ),
  1134. 'upload_limit_exceeded' => __( 'You may only upload 1 file.' ),
  1135. 'http_error' => __( 'Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.' ),
  1136. 'http_error_image' => __( 'Post-processing of the image failed. If this is a photo or a large image, please scale it down to 2500 pixels and upload it again.' ),
  1137. 'upload_failed' => __( 'Upload failed.' ),
  1138. /* translators: 1: Opening link tag, 2: Closing link tag. */
  1139. 'big_upload_failed' => __( 'Please try uploading this file with the %1$sbrowser uploader%2$s.' ),
  1140. /* translators: %s: File name. */
  1141. 'big_upload_queued' => __( '%s exceeds the maximum upload size for the multi-file uploader when used in your browser.' ),
  1142. 'io_error' => __( 'IO error.' ),
  1143. 'security_error' => __( 'Security error.' ),
  1144. 'file_cancelled' => __( 'File canceled.' ),
  1145. 'upload_stopped' => __( 'Upload stopped.' ),
  1146. 'dismiss' => __( 'Dismiss' ),
  1147. 'crunching' => __( 'Crunching&hellip;' ),
  1148. 'deleted' => __( 'moved to the trash.' ),
  1149. /* translators: %s: File name. */
  1150. 'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.' ),
  1151. );
  1152. $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
  1153. $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' );
  1154. // Back compat handles:
  1155. foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
  1156. $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
  1157. }
  1158. $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
  1159. did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
  1160. $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
  1161. did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );
  1162. // keep 'swfupload' for back-compat.
  1163. $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' );
  1164. $scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' );
  1165. $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' );
  1166. did_action( 'init' ) && $scripts->localize( 'swfupload-handlers', 'swfuploadL10n', $uploader_l10n );
  1167. $scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
  1168. $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
  1169. did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
  1170. $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 );
  1171. $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 );
  1172. $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 );
  1173. did_action( 'init' ) && $scripts->localize(
  1174. 'wp-util',
  1175. '_wpUtilSettings',
  1176. array(
  1177. 'ajax' => array(
  1178. 'url' => admin_url( 'admin-ajax.php', 'relative' ),
  1179. ),
  1180. )
  1181. );
  1182. $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 );
  1183. $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverIntent' ), false, 1 );
  1184. $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 );
  1185. $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.13-9993131', 1 );
  1186. $scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.13-9993131', 1 );
  1187. $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1 );
  1188. did_action( 'init' ) && $scripts->add_inline_script(
  1189. 'mediaelement-core',
  1190. sprintf(
  1191. 'var mejsL10n = %s;',
  1192. wp_json_encode(
  1193. array(
  1194. 'language' => strtolower( strtok( determine_locale(), '_-' ) ),
  1195. 'strings' => array(
  1196. 'mejs.install-flash' => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ),
  1197. 'mejs.fullscreen-off' => __( 'Turn off Fullscreen' ),
  1198. 'mejs.fullscreen-on' => __( 'Go Fullscreen' ),
  1199. 'mejs.download-video' => __( 'Download Video' ),
  1200. 'mejs.fullscreen' => __( 'Fullscreen' ),
  1201. 'mejs.time-jump-forward' => array( __( 'Jump forward 1 second' ), __( 'Jump forward %1 seconds' ) ),
  1202. 'mejs.loop' => __( 'Toggle Loop' ),
  1203. 'mejs.play' => __( 'Play' ),
  1204. 'mejs.pause' => __( 'Pause' ),
  1205. 'mejs.close' => __( 'Close' ),
  1206. 'mejs.time-slider' => __( 'Time Slider' ),
  1207. 'mejs.time-help-text' => __( 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.' ),
  1208. 'mejs.time-skip-back' => array( __( 'Skip back 1 second' ), __( 'Skip back %1 seconds' ) ),
  1209. 'mejs.captions-subtitles' => __( 'Captions/Subtitles' ),
  1210. 'mejs.captions-chapters' => __( 'Chapters' ),
  1211. 'mejs.none' => __( 'None' ),
  1212. 'mejs.mute-toggle' => __( 'Mute Toggle' ),
  1213. 'mejs.volume-help-text' => __( 'Use Up/Down Arrow keys to increase or decrease volume.' ),
  1214. 'mejs.unmute' => __( 'Unmute' ),
  1215. 'mejs.mute' => __( 'Mute' ),
  1216. 'mejs.volume-slider' => __( 'Volume Slider' ),
  1217. 'mejs.video-player' => __( 'Video Player' ),
  1218. 'mejs.audio-player' => __( 'Audio Player' ),
  1219. 'mejs.ad-skip' => __( 'Skip ad' ),
  1220. 'mejs.ad-skip-info' => array( __( 'Skip in 1 second' ), __( 'Skip in %1 seconds' ) ),
  1221. 'mejs.source-chooser' => __( 'Source Chooser' ),
  1222. 'mejs.stop' => __( 'Stop' ),
  1223. 'mejs.speed-rate' => __( 'Speed Rate' ),
  1224. 'mejs.live-broadcast' => __( 'Live Broadcast' ),
  1225. 'mejs.afrikaans' => __( 'Afrikaans' ),
  1226. 'mejs.albanian' => __( 'Albanian' ),
  1227. 'mejs.arabic' => __( 'Arabic' ),
  1228. 'mejs.belarusian' => __( 'Belarusian' ),
  1229. 'mejs.bulgarian' => __( 'Bulgarian' ),
  1230. 'mejs.catalan' => __( 'Catalan' ),
  1231. 'mejs.chinese' => __( 'Chinese' ),
  1232. 'mejs.chinese-simplified' => __( 'Chinese (Simplified)' ),
  1233. 'mejs.chinese-traditional' => __( 'Chinese (Traditional)' ),
  1234. 'mejs.croatian' => __( 'Croatian' ),
  1235. 'mejs.czech' => __( 'Czech' ),
  1236. 'mejs.danish' => __( 'Danish' ),
  1237. 'mejs.dutch' => __( 'Dutch' ),
  1238. 'mejs.english' => __( 'English' ),
  1239. 'mejs.estonian' => __( 'Estonian' ),
  1240. 'mejs.filipino' => __( 'Filipino' ),
  1241. 'mejs.finnish' => __( 'Finnish' ),
  1242. 'mejs.french' => __( 'French' ),
  1243. 'mejs.galician' => __( 'Galician' ),
  1244. 'mejs.german' => __( 'German' ),
  1245. 'mejs.greek' => __( 'Greek' ),
  1246. 'mejs.haitian-creole' => __( 'Haitian Creole' ),
  1247. 'mejs.hebrew' => __( 'Hebrew' ),
  1248. 'mejs.hindi' => __( 'Hindi' ),
  1249. 'mejs.hungarian' => __( 'Hungarian' ),
  1250. 'mejs.icelandic' => __( 'Icelandic' ),
  1251. 'mejs.indonesian' => __( 'Indonesian' ),
  1252. 'mejs.irish' => __( 'Irish' ),
  1253. 'mejs.italian' => __( 'Italian' ),
  1254. 'mejs.japanese' => __( 'Japanese' ),
  1255. 'mejs.korean' => __( 'Korean' ),
  1256. 'mejs.latvian' => __( 'Latvian' ),
  1257. 'mejs.lithuanian' => __( 'Lithuanian' ),
  1258. 'mejs.macedonian' => __( 'Macedonian' ),
  1259. 'mejs.malay' => __( 'Malay' ),
  1260. 'mejs.maltese' => __( 'Maltese' ),
  1261. 'mejs.norwegian' => __( 'Norwegian' ),
  1262. 'mejs.persian' => __( 'Persian' ),
  1263. 'mejs.polish' => __( 'Polish' ),
  1264. 'mejs.portuguese' => __( 'Portuguese' ),
  1265. 'mejs.romanian' => __( 'Romanian' ),
  1266. 'mejs.russian' => __( 'Russian' ),
  1267. 'mejs.serbian' => __( 'Serbian' ),
  1268. 'mejs.slovak' => __( 'Slovak' ),
  1269. 'mejs.slovenian' => __( 'Slovenian' ),
  1270. 'mejs.spanish' => __( 'Spanish' ),
  1271. 'mejs.swahili' => __( 'Swahili' ),
  1272. 'mejs.swedish' => __( 'Swedish' ),
  1273. 'mejs.tagalog' => __( 'Tagalog' ),
  1274. 'mejs.thai' => __( 'Thai' ),
  1275. 'mejs.turkish' => __( 'Turkish' ),
  1276. 'mejs.ukrainian' => __( 'Ukrainian' ),
  1277. 'mejs.vietnamese' => __( 'Vietnamese' ),
  1278. 'mejs.welsh' => __( 'Welsh' ),
  1279. 'mejs.yiddish' => __( 'Yiddish' ),
  1280. ),
  1281. )
  1282. )
  1283. ),
  1284. 'before'
  1285. );
  1286. $scripts->add( 'mediaelement-vimeo', '/wp-includes/js/mediaelement/renderers/vimeo.min.js', array( 'mediaelement' ), '4.2.13-9993131', 1 );
  1287. $scripts->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.js", array( 'mediaelement' ), false, 1 );
  1288. $mejs_settings = array(
  1289. 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ),
  1290. 'classPrefix' => 'mejs-',
  1291. 'stretching' => 'responsive',
  1292. );
  1293. did_action( 'init' ) && $scripts->localize(
  1294. 'mediaelement',
  1295. '_wpmejsSettings',
  1296. /**
  1297. * Filters the MediaElement configuration settings.
  1298. *
  1299. * @since 4.4.0
  1300. *
  1301. * @param array $mejs_settings MediaElement settings array.
  1302. */
  1303. apply_filters( 'mejs_settings', $mejs_settings )
  1304. );
  1305. $scripts->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.js', array(), '5.29.1-alpha-ee20357' );
  1306. $scripts->add( 'csslint', '/wp-includes/js/codemirror/csslint.js', array(), '1.0.5' );
  1307. $scripts->add( 'esprima', '/wp-includes/js/codemirror/esprima.js', array(), '4.0.0' );
  1308. $scripts->add( 'jshint', '/wp-includes/js/codemirror/fakejshint.js', array( 'esprima' ), '2.9.5' );
  1309. $scripts->add( 'jsonlint', '/wp-includes/js/codemirror/jsonlint.js', array(), '1.6.2' );
  1310. $scripts->add( 'htmlhint', '/wp-includes/js/codemirror/htmlhint.js', array(), '0.9.14-xwp' );
  1311. $scripts->add( 'htmlhint-kses', '/wp-includes/js/codemirror/htmlhint-kses.js', array( 'htmlhint' ) );
  1312. $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) );
  1313. $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) );
  1314. did_action( 'init' ) && $scripts->add_inline_script(
  1315. 'wp-theme-plugin-editor',
  1316. sprintf(
  1317. 'wp.themePluginEditor.l10n = %s;',
  1318. wp_json_encode(
  1319. array(
  1320. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
  1321. 'saveError' => __( 'Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.' ),
  1322. 'lintError' => array(
  1323. /* translators: %d: Error count. */
  1324. 'singular' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 1 ),
  1325. /* translators: %d: Error count. */
  1326. 'plural' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
  1327. ),
  1328. )
  1329. )
  1330. )
  1331. );
  1332. $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
  1333. $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' );
  1334. did_action( 'init' ) && $scripts->localize(
  1335. 'zxcvbn-async',
  1336. '_zxcvbnSettings',
  1337. array(
  1338. 'src' => empty( $guessed_url ) ? includes_url( '/js/zxcvbn.min.js' ) : $scripts->base_url . '/wp-includes/js/zxcvbn.min.js',
  1339. )
  1340. );
  1341. $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
  1342. did_action( 'init' ) && $scripts->localize(
  1343. 'password-strength-meter',
  1344. 'pwsL10n',
  1345. array(
  1346. 'unknown' => _x( 'Password strength unknown', 'password strength' ),
  1347. 'short' => _x( 'Very weak', 'password strength' ),
  1348. 'bad' => _x( 'Weak', 'password strength' ),
  1349. 'good' => _x( 'Medium', 'password strength' ),
  1350. 'strong' => _x( 'Strong', 'password strength' ),
  1351. 'mismatch' => _x( 'Mismatch', 'password mismatch' ),
  1352. )
  1353. );
  1354. $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 );
  1355. did_action( 'init' ) && $scripts->localize(
  1356. 'user-profile',
  1357. 'userProfileL10n',
  1358. array(
  1359. 'warn' => __( 'Your new password has not been saved.' ),
  1360. 'warnWeak' => __( 'Confirm use of weak password' ),
  1361. 'show' => __( 'Show' ),
  1362. 'hide' => __( 'Hide' ),
  1363. 'cancel' => __( 'Cancel' ),
  1364. 'ariaShow' => esc_attr__( 'Show password' ),
  1365. 'ariaHide' => esc_attr__( 'Hide password' ),
  1366. )
  1367. );
  1368. $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
  1369. $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
  1370. $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
  1371. $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
  1372. did_action( 'init' ) && $scripts->localize(
  1373. 'wplink',
  1374. 'wpLinkL10n',
  1375. array(
  1376. 'title' => __( 'Insert/edit link' ),
  1377. 'update' => __( 'Update' ),
  1378. 'save' => __( 'Add Link' ),
  1379. 'noTitle' => __( '(no title)' ),
  1380. 'noMatchesFound' => __( 'No results found.' ),
  1381. 'linkSelected' => __( 'Link selected.' ),
  1382. 'linkInserted' => __( 'Link inserted.' ),
  1383. )
  1384. );
  1385. $scripts->add( 'wpdialogs', "/wp-includes/js/wpdialog$suffix.js", array( 'jquery-ui-dialog' ), false, 1 );
  1386. $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array(), false, 1 );
  1387. $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 );
  1388. $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.8.1', 1 );
  1389. $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
  1390. $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
  1391. $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 );
  1392. $scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 );
  1393. $scripts->add( 'customize-views', '/wp-includes/js/customize-views.js', array( 'jquery', 'underscore', 'imgareaselect', 'customize-models', 'media-editor', 'media-views' ), false, 1 );
  1394. $scripts->add( 'customize-controls', "/wp-admin/js/customize-controls$suffix.js", array( 'customize-base', 'wp-a11y', 'wp-util', 'jquery-ui-core' ), false, 1 );
  1395. did_action( 'init' ) && $scripts->localize(
  1396. 'customize-controls',
  1397. '_wpCustomizeControlsL10n',
  1398. array(
  1399. 'activate' => __( 'Activate &amp; Publish' ),
  1400. 'save' => __( 'Save &amp; Publish' ), // @todo Remove as not required.
  1401. 'publish' => __( 'Publish' ),
  1402. 'published' => __( 'Published' ),
  1403. 'saveDraft' => __( 'Save Draft' ),
  1404. 'draftSaved' => __( 'Draft Saved' ),
  1405. 'updating' => __( 'Updating' ),
  1406. 'schedule' => _x( 'Schedule', 'customizer changeset action/button label' ),
  1407. 'scheduled' => _x( 'Scheduled', 'customizer changeset status' ),
  1408. 'invalid' => __( 'Invalid' ),
  1409. 'saveBeforeShare' => __( 'Please save your changes in order to share the preview.' ),
  1410. 'futureDateError' => __( 'You must supply a future date to schedule.' ),
  1411. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
  1412. 'saved' => __( 'Saved' ),
  1413. 'cancel' => __( 'Cancel' ),
  1414. 'close' => __( 'Close' ),
  1415. 'action' => __( 'Action' ),
  1416. 'discardChanges' => __( 'Discard changes' ),
  1417. 'cheatin' => __( 'Something went wrong.' ),
  1418. 'notAllowedHeading' => __( 'You need a higher level of permission.' ),
  1419. 'notAllowed' => __( 'Sorry, you are not allowed to customize this site.' ),
  1420. 'previewIframeTitle' => __( 'Site Preview' ),
  1421. 'loginIframeTitle' => __( 'Session expired' ),
  1422. 'collapseSidebar' => _x( 'Hide Controls', 'label for hide controls button without length constraints' ),
  1423. 'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ),
  1424. 'untitledBlogName' => __( '(Untitled)' ),
  1425. 'unknownRequestFail' => __( 'Looks like something&#8217;s gone wrong. Wait a couple seconds, and then try again.' ),
  1426. 'themeDownloading' => __( 'Downloading your new theme&hellip;' ),
  1427. 'themePreviewWait' => __( 'Setting up your live preview. This may take a bit.' ),
  1428. 'revertingChanges' => __( 'Reverting unpublished changes&hellip;' ),
  1429. 'trashConfirm' => __( 'Are you sure you want to discard your unpublished changes?' ),
  1430. /* translators: %s: Display name of the user who has taken over the changeset in customizer. */
  1431. 'takenOverMessage' => __( '%s has taken over and is currently customizing.' ),
  1432. /* translators: %s: URL to the Customizer to load the autosaved version. */
  1433. 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ),
  1434. 'videoHeaderNotice' => __( 'This theme doesn&#8217;t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),
  1435. // Used for overriding the file types allowed in plupload.
  1436. 'allowedFiles' => __( 'Allowed Files' ),
  1437. 'customCssError' => array(
  1438. /* translators: %d: Error count. */
  1439. 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ),
  1440. /* translators: %d: Error count. */
  1441. 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
  1442. ),
  1443. 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ),
  1444. 'saveBlockedError' => array(
  1445. /* translators: %s: Number of invalid settings. */
  1446. 'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ),
  1447. /* translators: %s: Number of invalid settings. */
  1448. 'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
  1449. ),
  1450. 'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ),
  1451. 'themePreviewUnavailable' => __( 'Sorry, you can&#8217;t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ),
  1452. 'themeInstallUnavailable' => sprintf(
  1453. /* translators: %s: URL to Add Themes admin screen. */
  1454. __( 'You won&#8217;t be able to install new themes from here yet since your install requires SFTP credentials. For now, please <a href="%s">add themes in the admin</a>.' ),
  1455. esc_url( admin_url( 'theme-install.php' ) )
  1456. ),
  1457. 'publishSettings' => __( 'Publish Settings' ),
  1458. 'invalidDate' => __( 'Invalid date.' ),
  1459. 'invalidValue' => __( 'Invalid value.' ),
  1460. )
  1461. );
  1462. $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );
  1463. $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 );
  1464. $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
  1465. $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu', 'wp-sanitize' ), false, 1 );
  1466. $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
  1467. $scripts->add( 'wp-custom-header', "/wp-includes/js/wp-custom-header$suffix.js", array( 'wp-a11y' ), false, 1 );
  1468. $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );
  1469. $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
  1470. $scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'wp-backbone' ), false, 1 );
  1471. did_action( 'init' ) && $scripts->localize(
  1472. 'media-models',
  1473. '_wpMediaModelsL10n',
  1474. array(
  1475. 'settings' => array(
  1476. 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
  1477. 'post' => array( 'id' => 0 ),
  1478. ),
  1479. )
  1480. );
  1481. $scripts->add( 'wp-embed', "/wp-includes/js/wp-embed$suffix.js" );
  1482. // To enqueue media-views or media-editor, call wp_enqueue_media().
  1483. // Both rely on numerous settings, styles, and templates to operate correctly.
  1484. $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'wp-api-request', 'wp-a11y', 'wp-i18n' ), false, 1 );
  1485. $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
  1486. $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
  1487. $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
  1488. $scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 );
  1489. if ( is_admin() ) {
  1490. $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );
  1491. did_action( 'init' ) && $scripts->localize(
  1492. 'admin-tags',
  1493. 'tagsl10n',
  1494. array(
  1495. 'noPerm' => __( 'Sorry, you are not allowed to do that.' ),
  1496. 'broken' => __( 'Something went wrong.' ),
  1497. )
  1498. );
  1499. $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array( 'wp-lists', 'quicktags', 'jquery-query' ), false, 1 );
  1500. did_action( 'init' ) && $scripts->localize(
  1501. 'admin-comments',
  1502. 'adminCommentsL10n',
  1503. array(
  1504. 'hotkeys_highlight_first' => isset( $_GET['hotkeys_highlight_first'] ),
  1505. 'hotkeys_highlight_last' => isset( $_GET['hotkeys_highlight_last'] ),
  1506. 'replyApprove' => __( 'Approve and Reply' ),
  1507. 'reply' => __( 'Reply' ),
  1508. 'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ),
  1509. 'warnCommentChanges' => __( "Are you sure you want to do this?\nThe comment changes you made will be lost." ),
  1510. 'docTitleComments' => __( 'Comments' ),
  1511. /* translators: %s: Comments count. */
  1512. 'docTitleCommentsCount' => __( 'Comments (%s)' ),
  1513. )
  1514. );
  1515. $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array( 'jquery' ), false, 1 );
  1516. $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable' ), false, 1 );
  1517. did_action( 'init' ) && $scripts->localize(
  1518. 'postbox',
  1519. 'postBoxL10n',
  1520. array(
  1521. 'postBoxEmptyString' => __( 'Drag boxes here' ),
  1522. )
  1523. );
  1524. $scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'tags-suggest' ), false, 1 );
  1525. $scripts->add( 'tags-suggest', "/wp-admin/js/tags-suggest$suffix.js", array( 'jquery-ui-autocomplete', 'wp-a11y' ), false, 1 );
  1526. did_action( 'init' ) && $scripts->localize(
  1527. 'tags-suggest',
  1528. 'tagsSuggestL10n',
  1529. array(
  1530. 'tagDelimiter' => _x( ',', 'tag delimiter' ),
  1531. 'removeTerm' => __( 'Remove term:' ),
  1532. 'termSelected' => __( 'Term selected.' ),
  1533. 'termAdded' => __( 'Term added.' ),
  1534. 'termRemoved' => __( 'Term removed.' ),
  1535. )
  1536. );
  1537. $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize' ), false, 1 );
  1538. did_action( 'init' ) && $scripts->localize(
  1539. 'post',
  1540. 'postL10n',
  1541. array(
  1542. 'ok' => __( 'OK' ),
  1543. 'cancel' => __( 'Cancel' ),
  1544. 'publishOn' => __( 'Publish on:' ),
  1545. 'publishOnFuture' => __( 'Schedule for:' ),
  1546. 'publishOnPast' => __( 'Published on:' ),
  1547. /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
  1548. 'dateFormat' => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
  1549. 'showcomm' => __( 'Show more comments' ),
  1550. 'endcomm' => __( 'No more comments found.' ),
  1551. 'publish' => __( 'Publish' ),
  1552. 'schedule' => _x( 'Schedule', 'post action/button label' ),
  1553. 'update' => __( 'Update' ),
  1554. 'savePending' => __( 'Save as Pending' ),
  1555. 'saveDraft' => __( 'Save Draft' ),
  1556. 'private' => __( 'Private' ),
  1557. 'public' => __( 'Public' ),
  1558. 'publicSticky' => __( 'Public, Sticky' ),
  1559. 'password' => __( 'Password Protected' ),
  1560. 'privatelyPublished' => __( 'Privately Published' ),
  1561. 'published' => __( 'Published' ),
  1562. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
  1563. 'savingText' => __( 'Saving Draft&#8230;' ),
  1564. 'permalinkSaved' => __( 'Permalink saved' ),
  1565. )
  1566. );
  1567. $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
  1568. $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
  1569. $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
  1570. $scripts->add_data( 'comment', 'group', 1 );
  1571. did_action( 'init' ) && $scripts->localize(
  1572. 'comment',
  1573. 'commentL10n',
  1574. array(
  1575. 'submittedOn' => __( 'Submitted on:' ),
  1576. /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
  1577. 'dateFormat' => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
  1578. )
  1579. );
  1580. $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
  1581. $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
  1582. did_action( 'init' ) && $scripts->add_inline_script(
  1583. 'admin-widgets',
  1584. sprintf(
  1585. 'wpWidgets.l10n = %s;',
  1586. wp_json_encode(
  1587. array(
  1588. 'save' => __( 'Save' ),
  1589. 'saved' => __( 'Saved' ),
  1590. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
  1591. )
  1592. )
  1593. )
  1594. );
  1595. $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views', 'wp-api-request' ) );
  1596. $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' );
  1597. $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
  1598. $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) );
  1599. $scripts->add( 'media-gallery-widget', "/wp-admin/js/widgets/media-gallery-widget$suffix.js", array( 'media-widgets' ) );
  1600. $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo', 'wp-api-request' ) );
  1601. $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util', 'wp-a11y' ) );
  1602. $scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) );
  1603. $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 );
  1604. $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
  1605. did_action( 'init' ) && $scripts->localize(
  1606. 'inline-edit-post',
  1607. 'inlineEditL10n',
  1608. array(
  1609. 'error' => __( 'Error while saving the changes.' ),
  1610. 'ntdeltitle' => __( 'Remove From Bulk Edit' ),
  1611. 'notitle' => __( '(no title)' ),
  1612. 'comma' => trim( _x( ',', 'tag delimiter' ) ),
  1613. 'saved' => __( 'Changes saved.' ),
  1614. )
  1615. );
  1616. $scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 );
  1617. did_action( 'init' ) && $scripts->localize(
  1618. 'inline-edit-tax',
  1619. 'inlineEditL10n',
  1620. array(
  1621. 'error' => __( 'Error while saving the changes.' ),
  1622. 'saved' => __( 'Changes saved.' ),
  1623. )
  1624. );
  1625. $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
  1626. did_action( 'init' ) && $scripts->localize(
  1627. 'plugin-install',
  1628. 'plugininstallL10n',
  1629. array(
  1630. 'plugin_information' => __( 'Plugin:' ),
  1631. 'plugin_modal_label' => __( 'Plugin details' ),
  1632. 'ays' => __( 'Are you sure you want to install this plugin?' ),
  1633. )
  1634. );
  1635. $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y', 'wp-i18n' ), false, 1 );
  1636. $scripts->set_translations( 'site-health' );
  1637. $scripts->add( 'privacy-tools', "/wp-admin/js/privacy-tools$suffix.js", array( 'jquery' ), false, 1 );
  1638. did_action( 'init' ) && $scripts->localize(
  1639. 'privacy-tools',
  1640. 'privacyToolsL10n',
  1641. array(
  1642. 'noDataFound' => __( 'No personal data was found for this user.' ),
  1643. 'foundAndRemoved' => __( 'All of the personal data found for this user was erased.' ),
  1644. 'noneRemoved' => __( 'Personal data was found for this user but was not erased.' ),
  1645. 'someNotRemoved' => __( 'Personal data was found for this user but some of the personal data found was not erased.' ),
  1646. 'removalError' => __( 'An error occurred while attempting to find and erase personal data.' ),
  1647. 'emailSent' => __( 'The personal data export link for this user was sent.' ),
  1648. 'noExportFile' => __( 'No personal data export file was generated.' ),
  1649. 'exportError' => __( 'An error occurred while attempting to export personal data.' ),
  1650. )
  1651. );
  1652. $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y', 'wp-sanitize' ), false, 1 );
  1653. did_action( 'init' ) && $scripts->localize(
  1654. 'updates',
  1655. '_wpUpdatesSettings',
  1656. array(
  1657. 'ajax_nonce' => wp_create_nonce( 'updates' ),
  1658. 'l10n' => array(
  1659. /* translators: %s: Search query. */
  1660. 'searchResults' => __( 'Search results for &#8220;%s&#8221;' ),
  1661. 'searchResultsLabel' => __( 'Search Results' ),
  1662. 'noPlugins' => __( 'You do not appear to have any plugins available at this time.' ),
  1663. 'noItemsSelected' => __( 'Please select at least one item to perform this action on.' ),
  1664. 'updating' => __( 'Updating...' ), // No ellipsis.
  1665. 'pluginUpdated' => _x( 'Updated!', 'plugin' ),
  1666. 'themeUpdated' => _x( 'Updated!', 'theme' ),
  1667. 'update' => __( 'Update' ),
  1668. 'updateNow' => __( 'Update Now' ),
  1669. /* translators: %s: Plugin name and version. */
  1670. 'pluginUpdateNowLabel' => _x( 'Update %s now', 'plugin' ),
  1671. 'updateFailedShort' => __( 'Update Failed!' ),
  1672. /* translators: %s: Error string for a failed update. */
  1673. 'updateFailed' => __( 'Update Failed: %s' ),
  1674. /* translators: %s: Plugin name and version. */
  1675. 'pluginUpdatingLabel' => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
  1676. /* translators: %s: Plugin name and version. */
  1677. 'pluginUpdatedLabel' => _x( '%s updated!', 'plugin' ),
  1678. /* translators: %s: Plugin name and version. */
  1679. 'pluginUpdateFailedLabel' => _x( '%s update failed', 'plugin' ),
  1680. /* translators: Accessibility text. */
  1681. 'updatingMsg' => __( 'Updating... please wait.' ), // No ellipsis.
  1682. /* translators: Accessibility text. */
  1683. 'updatedMsg' => __( 'Update completed successfully.' ),
  1684. /* translators: Accessibility text. */
  1685. 'updateCancel' => __( 'Update canceled.' ),
  1686. 'beforeunload' => __( 'Updates may not complete if you navigate away from this page.' ),
  1687. 'installNow' => __( 'Install Now' ),
  1688. /* translators: %s: Plugin name. */
  1689. 'pluginInstallNowLabel' => _x( 'Install %s now', 'plugin' ),
  1690. 'installing' => __( 'Installing...' ),
  1691. 'pluginInstalled' => _x( 'Installed!', 'plugin' ),
  1692. 'themeInstalled' => _x( 'Installed!', 'theme' ),
  1693. 'installFailedShort' => __( 'Installation Failed!' ),
  1694. /* translators: %s: Error string for a failed installation. */
  1695. 'installFailed' => __( 'Installation failed: %s' ),
  1696. /* translators: %s: Plugin name and version. */
  1697. 'pluginInstallingLabel' => _x( 'Installing %s...', 'plugin' ), // no ellipsis
  1698. /* translators: %s: Theme name and version. */
  1699. 'themeInstallingLabel' => _x( 'Installing %s...', 'theme' ), // no ellipsis
  1700. /* translators: %s: Plugin name and version. */
  1701. 'pluginInstalledLabel' => _x( '%s installed!', 'plugin' ),
  1702. /* translators: %s: Theme name and version. */
  1703. 'themeInstalledLabel' => _x( '%s installed!', 'theme' ),
  1704. /* translators: %s: Plugin name and version. */
  1705. 'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ),
  1706. /* translators: %s: Theme name and version. */
  1707. 'themeInstallFailedLabel' => _x( '%s installation failed', 'theme' ),
  1708. 'installingMsg' => __( 'Installing... please wait.' ),
  1709. 'installedMsg' => __( 'Installation completed successfully.' ),
  1710. /* translators: %s: Activation URL. */
  1711. 'importerInstalledMsg' => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ),
  1712. /* translators: %s: Theme name. */
  1713. 'aysDelete' => __( 'Are you sure you want to delete %s?' ),
  1714. /* translators: %s: Plugin name. */
  1715. 'aysDeleteUninstall' => __( 'Are you sure you want to delete %s and its data?' ),
  1716. 'aysBulkDelete' => __( 'Are you sure you want to delete the selected plugins and their data?' ),
  1717. 'aysBulkDeleteThemes' => __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ),
  1718. 'deleting' => __( 'Deleting...' ),
  1719. /* translators: %s: Error string for a failed deletion. */
  1720. 'deleteFailed' => __( 'Deletion failed: %s' ),
  1721. 'pluginDeleted' => _x( 'Deleted!', 'plugin' ),
  1722. 'themeDeleted' => _x( 'Deleted!', 'theme' ),
  1723. 'livePreview' => __( 'Live Preview' ),
  1724. 'activatePlugin' => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
  1725. 'activateTheme' => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
  1726. /* translators: %s: Plugin name. */
  1727. 'activatePluginLabel' => is_network_admin() ? _x( 'Network Activate %s', 'plugin' ) : _x( 'Activate %s', 'plugin' ),
  1728. /* translators: %s: Theme name. */
  1729. 'activateThemeLabel' => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ),
  1730. 'activateImporter' => __( 'Run Importer' ),
  1731. /* translators: %s: Importer name. */
  1732. 'activateImporterLabel' => __( 'Run %s' ),
  1733. 'unknownError' => __( 'Something went wrong.' ),
  1734. 'connectionError' => __( 'Connection lost or the server is busy. Please try again later.' ),
  1735. 'nonceError' => __( 'An error has occurred. Please reload the page and try again.' ),
  1736. /* translators: %s: Number of plugins. */
  1737. 'pluginsFound' => __( 'Number of plugins found: %d' ),
  1738. 'noPluginsFound' => __( 'No plugins found. Try a different search.' ),
  1739. ),
  1740. )
  1741. );
  1742. $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array( 'jquery' ), '1.2' );
  1743. $scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), '1.0.7', 1 );
  1744. $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 );
  1745. did_action( 'init' ) && $scripts->localize(
  1746. 'wp-color-picker',
  1747. 'wpColorPickerL10n',
  1748. array(
  1749. 'clear' => __( 'Clear' ),
  1750. 'clearAriaLabel' => __( 'Clear color' ),
  1751. 'defaultString' => __( 'Default' ),
  1752. 'defaultAriaLabel' => __( 'Select default color' ),
  1753. 'pick' => __( 'Select Color' ),
  1754. 'defaultLabel' => __( 'Color value' ),
  1755. )
  1756. );
  1757. $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
  1758. $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
  1759. $scripts->add( 'media-grid', "/wp-includes/js/media-grid$suffix.js", array( 'media-editor' ), false, 1 );
  1760. $scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery' ), false, 1 );
  1761. did_action( 'init' ) && $scripts->localize(
  1762. 'media',
  1763. 'attachMediaBoxL10n',
  1764. array(
  1765. 'error' => __( 'An error has occurred. Please reload the page and try again.' ),
  1766. )
  1767. );
  1768. $scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'json2', 'imgareaselect' ), false, 1 );
  1769. did_action( 'init' ) && $scripts->localize(
  1770. 'image-edit',
  1771. 'imageEditL10n',
  1772. array(
  1773. 'error' => __( 'Could not load the preview image. Please reload the page and try again.' ),
  1774. )
  1775. );
  1776. $scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
  1777. did_action( 'init' ) && $scripts->localize(
  1778. 'set-post-thumbnail',
  1779. 'setPostThumbnailL10n',
  1780. array(
  1781. 'setThumbnail' => __( 'Use as featured image' ),
  1782. 'saving' => __( 'Saving...' ), // no ellipsis
  1783. 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
  1784. 'done' => __( 'Done' ),
  1785. )
  1786. );
  1787. /*
  1788. * Navigation Menus: Adding underscore as a dependency to utilize _.debounce
  1789. * see https://core.trac.wordpress.org/ticket/42321
  1790. */
  1791. $scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) );
  1792. did_action( 'init' ) && $scripts->localize(
  1793. 'nav-menu',
  1794. 'navMenuL10n',
  1795. array(
  1796. 'noResultsFound' => __( 'No results found.' ),
  1797. 'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
  1798. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
  1799. 'untitled' => _x( '(no label)', 'missing menu item navigation label' ),
  1800. )
  1801. );
  1802. $scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 );
  1803. $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 );
  1804. $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array( 'jquery' ), false, 1 );
  1805. $scripts->add( 'svg-painter', '/wp-admin/js/svg-painter.js', array( 'jquery' ), false, 1 );
  1806. }
  1807. }
  1808. /**
  1809. * Assign default styles to $styles object.
  1810. *
  1811. * Nothing is returned, because the $styles parameter is passed by reference.
  1812. * Meaning that whatever object is passed will be updated without having to
  1813. * reassign the variable that was passed back to the same value. This saves
  1814. * memory.
  1815. *
  1816. * Adding default styles is not the only task, it also assigns the base_url
  1817. * property, the default version, and text direction for the object.
  1818. *
  1819. * @since 2.6.0
  1820. *
  1821. * @param WP_Styles $styles
  1822. */
  1823. function wp_default_styles( &$styles ) {
  1824. include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
  1825. if ( ! defined( 'SCRIPT_DEBUG' ) ) {
  1826. define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
  1827. }
  1828. $guessurl = site_url();
  1829. if ( ! $guessurl ) {
  1830. $guessurl = wp_guess_url();
  1831. }
  1832. $styles->base_url = $guessurl;
  1833. $styles->content_url = defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL : '';
  1834. $styles->default_version = get_bloginfo( 'version' );
  1835. $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
  1836. $styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' );
  1837. // Open Sans is no longer used by core, but may be relied upon by themes and plugins.
  1838. $open_sans_font_url = '';
  1839. /*
  1840. * translators: If there are characters in your language that are not supported
  1841. * by Open Sans, translate this to 'off'. Do not translate into your own language.
  1842. */
  1843. if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
  1844. $subsets = 'latin,latin-ext';
  1845. /*
  1846. * translators: To add an additional Open Sans character subset specific to your language,
  1847. * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
  1848. */
  1849. $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
  1850. if ( 'cyrillic' === $subset ) {
  1851. $subsets .= ',cyrillic,cyrillic-ext';
  1852. } elseif ( 'greek' === $subset ) {
  1853. $subsets .= ',greek,greek-ext';
  1854. } elseif ( 'vietnamese' === $subset ) {
  1855. $subsets .= ',vietnamese';
  1856. }
  1857. // Hotlink Open Sans, for now
  1858. $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback";
  1859. }
  1860. // Register a stylesheet for the selected admin color scheme.
  1861. $styles->add( 'colors', true, array( 'wp-admin', 'buttons' ) );
  1862. $suffix = SCRIPT_DEBUG ? '' : '.min';
  1863. // Admin CSS
  1864. $styles->add( 'common', "/wp-admin/css/common$suffix.css" );
  1865. $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" );
  1866. $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" );
  1867. $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" );
  1868. $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" );
  1869. $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" );
  1870. $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" );
  1871. $styles->add( 'media', "/wp-admin/css/media$suffix.css" );
  1872. $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" );
  1873. $styles->add( 'about', "/wp-admin/css/about$suffix.css" );
  1874. $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" );
  1875. $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array( 'wp-pointer' ) );
  1876. $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" );
  1877. $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" );
  1878. $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) );
  1879. $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" );
  1880. $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) );
  1881. $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
  1882. $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'dashicons', 'buttons', 'forms', 'l10n' ) );
  1883. $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" );
  1884. $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) );
  1885. $styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
  1886. $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) );
  1887. $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
  1888. $styles->add_data( 'ie', 'conditional', 'lte IE 7' );
  1889. // Common dependencies
  1890. $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" );
  1891. $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" );
  1892. // Includes CSS
  1893. $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) );
  1894. $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) );
  1895. $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) );
  1896. $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
  1897. $styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
  1898. $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
  1899. $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
  1900. $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );
  1901. // External libraries and friends
  1902. $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
  1903. $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) );
  1904. $styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.13-9993131' );
  1905. $styles->add( 'wp-mediaelement', "/wp-includes/js/mediaelement/wp-mediaelement$suffix.css", array( 'mediaelement' ) );
  1906. $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) );
  1907. $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' );
  1908. // Deprecated CSS
  1909. $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" );
  1910. $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' );
  1911. $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' );
  1912. $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
  1913. $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6
  1914. // Packages styles
  1915. $fonts_url = '';
  1916. /*
  1917. * translators: Use this to specify the proper Google Font name and variants
  1918. * to load that is supported by your language. Do not translate.
  1919. * Set to 'off' to disable loading.
  1920. */
  1921. $font_family = _x( 'Noto Serif:400,400i,700,700i', 'Google Font Name and Variants' );
  1922. if ( 'off' !== $font_family ) {
  1923. $fonts_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $font_family );
  1924. }
  1925. $styles->add( 'wp-editor-font', $fonts_url );
  1926. $styles->add( 'wp-block-library-theme', "/wp-includes/css/dist/block-library/theme$suffix.css" );
  1927. $styles->add(
  1928. 'wp-edit-blocks',
  1929. "/wp-includes/css/dist/block-library/editor$suffix.css",
  1930. array(
  1931. 'wp-components',
  1932. 'wp-editor',
  1933. 'wp-block-library',
  1934. // Always include visual styles so the editor never appears broken.
  1935. 'wp-block-library-theme',
  1936. )
  1937. );
  1938. $package_styles = array(
  1939. 'block-editor' => array(
  1940. 'wp-components',
  1941. 'wp-editor-font',
  1942. ),
  1943. 'block-library' => array(),
  1944. 'components' => array(),
  1945. 'edit-post' => array(
  1946. 'wp-components',
  1947. 'wp-block-editor',
  1948. 'wp-editor',
  1949. 'wp-edit-blocks',
  1950. 'wp-block-library',
  1951. 'wp-nux',
  1952. ),
  1953. 'editor' => array(
  1954. 'wp-components',
  1955. 'wp-block-editor',
  1956. 'wp-nux',
  1957. ),
  1958. 'format-library' => array(),
  1959. 'list-reusable-blocks' => array( 'wp-components' ),
  1960. 'nux' => array( 'wp-components' ),
  1961. );
  1962. foreach ( $package_styles as $package => $dependencies ) {
  1963. $handle = 'wp-' . $package;
  1964. $path = "/wp-includes/css/dist/$package/style$suffix.css";
  1965. $styles->add( $handle, $path, $dependencies );
  1966. }
  1967. // RTL CSS
  1968. $rtl_styles = array(
  1969. // Admin CSS
  1970. 'common',
  1971. 'forms',
  1972. 'admin-menu',
  1973. 'dashboard',
  1974. 'list-tables',
  1975. 'edit',
  1976. 'revisions',
  1977. 'media',
  1978. 'themes',
  1979. 'about',
  1980. 'nav-menus',
  1981. 'widgets',
  1982. 'site-icon',
  1983. 'l10n',
  1984. 'install',
  1985. 'wp-color-picker',
  1986. 'customize-controls',
  1987. 'customize-widgets',
  1988. 'customize-nav-menus',
  1989. 'customize-preview',
  1990. 'ie',
  1991. 'login',
  1992. 'site-health',
  1993. // Includes CSS
  1994. 'buttons',
  1995. 'admin-bar',
  1996. 'wp-auth-check',
  1997. 'editor-buttons',
  1998. 'media-views',
  1999. 'wp-pointer',
  2000. 'wp-jquery-ui-dialog',
  2001. // Package styles
  2002. 'wp-block-library-theme',
  2003. 'wp-edit-blocks',
  2004. 'wp-block-editor',
  2005. 'wp-block-library',
  2006. 'wp-components',
  2007. 'wp-edit-post',
  2008. 'wp-editor',
  2009. 'wp-format-library',
  2010. 'wp-list-reusable-blocks',
  2011. 'wp-nux',
  2012. // Deprecated CSS
  2013. 'deprecated-media',
  2014. 'farbtastic',
  2015. );
  2016. foreach ( $rtl_styles as $rtl_style ) {
  2017. $styles->add_data( $rtl_style, 'rtl', 'replace' );
  2018. if ( $suffix ) {
  2019. $styles->add_data( $rtl_style, 'suffix', $suffix );
  2020. }
  2021. }
  2022. }
  2023. /**
  2024. * Reorder JavaScript scripts array to place prototype before jQuery.
  2025. *
  2026. * @since 2.3.1
  2027. *
  2028. * @param array $js_array JavaScript scripts array
  2029. * @return array Reordered array, if needed.
  2030. */
  2031. function wp_prototype_before_jquery( $js_array ) {
  2032. $prototype = array_search( 'prototype', $js_array, true );
  2033. if ( false === $prototype ) {
  2034. return $js_array;
  2035. }
  2036. $jquery = array_search( 'jquery', $js_array, true );
  2037. if ( false === $jquery ) {
  2038. return $js_array;
  2039. }
  2040. if ( $prototype < $jquery ) {
  2041. return $js_array;
  2042. }
  2043. unset( $js_array[ $prototype ] );
  2044. array_splice( $js_array, $jquery, 0, 'prototype' );
  2045. return $js_array;
  2046. }
  2047. /**
  2048. * Load localized data on print rather than initialization.
  2049. *
  2050. * These localizations require information that may not be loaded even by init.
  2051. *
  2052. * @since 2.5.0
  2053. */
  2054. function wp_just_in_time_script_localization() {
  2055. wp_localize_script(
  2056. 'autosave',
  2057. 'autosaveL10n',
  2058. array(
  2059. 'autosaveInterval' => AUTOSAVE_INTERVAL,
  2060. 'blog_id' => get_current_blog_id(),
  2061. )
  2062. );
  2063. wp_localize_script(
  2064. 'mce-view',
  2065. 'mceViewL10n',
  2066. array(
  2067. 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
  2068. )
  2069. );
  2070. wp_localize_script(
  2071. 'word-count',
  2072. 'wordCountL10n',
  2073. array(
  2074. /*
  2075. * translators: If your word count is based on single characters (e.g. East Asian characters),
  2076. * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
  2077. * Do not translate into your own language.
  2078. */
  2079. 'type' => _x( 'words', 'Word count type. Do not translate!' ),
  2080. 'shortcodes' => ! empty( $GLOBALS['shortcode_tags'] ) ? array_keys( $GLOBALS['shortcode_tags'] ) : array(),
  2081. )
  2082. );
  2083. }
  2084. /**
  2085. * Localizes the jQuery UI datepicker.
  2086. *
  2087. * @since 4.6.0
  2088. *
  2089. * @link https://api.jqueryui.com/datepicker/#options
  2090. *
  2091. * @global WP_Locale $wp_locale WordPress date and time locale object.
  2092. */
  2093. function wp_localize_jquery_ui_datepicker() {
  2094. global $wp_locale;
  2095. if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
  2096. return;
  2097. }
  2098. // Convert the PHP date format into jQuery UI's format.
  2099. $datepicker_date_format = str_replace(
  2100. array(
  2101. 'd',
  2102. 'j',
  2103. 'l',
  2104. 'z', // Day.
  2105. 'F',
  2106. 'M',
  2107. 'n',
  2108. 'm', // Month.
  2109. 'Y',
  2110. 'y', // Year.
  2111. ),
  2112. array(
  2113. 'dd',
  2114. 'd',
  2115. 'DD',
  2116. 'o',
  2117. 'MM',
  2118. 'M',
  2119. 'm',
  2120. 'mm',
  2121. 'yy',
  2122. 'y',
  2123. ),
  2124. get_option( 'date_format' )
  2125. );
  2126. $datepicker_defaults = wp_json_encode(
  2127. array(
  2128. 'closeText' => __( 'Close' ),
  2129. 'currentText' => __( 'Today' ),
  2130. 'monthNames' => array_values( $wp_locale->month ),
  2131. 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
  2132. 'nextText' => __( 'Next' ),
  2133. 'prevText' => __( 'Previous' ),
  2134. 'dayNames' => array_values( $wp_locale->weekday ),
  2135. 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ),
  2136. 'dayNamesMin' => array_values( $wp_locale->weekday_initial ),
  2137. 'dateFormat' => $datepicker_date_format,
  2138. 'firstDay' => absint( get_option( 'start_of_week' ) ),
  2139. 'isRTL' => $wp_locale->is_rtl(),
  2140. )
  2141. );
  2142. wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
  2143. }
  2144. /**
  2145. * Localizes community events data that needs to be passed to dashboard.js.
  2146. *
  2147. * @since 4.8.0
  2148. */
  2149. function wp_localize_community_events() {
  2150. if ( ! wp_script_is( 'dashboard' ) ) {
  2151. return;
  2152. }
  2153. require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
  2154. $user_id = get_current_user_id();
  2155. $saved_location = get_user_option( 'community-events-location', $user_id );
  2156. $saved_ip_address = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
  2157. $current_ip_address = WP_Community_Events::get_unsafe_client_ip();
  2158. /*
  2159. * If the user's location is based on their IP address, then update their
  2160. * location when their IP address changes. This allows them to see events
  2161. * in their current city when travelling. Otherwise, they would always be
  2162. * shown events in the city where they were when they first loaded the
  2163. * Dashboard, which could have been months or years ago.
  2164. */
  2165. if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
  2166. $saved_location['ip'] = $current_ip_address;
  2167. update_user_option( $user_id, 'community-events-location', $saved_location, true );
  2168. }
  2169. $events_client = new WP_Community_Events( $user_id, $saved_location );
  2170. wp_localize_script(
  2171. 'dashboard',
  2172. 'communityEventsData',
  2173. array(
  2174. 'nonce' => wp_create_nonce( 'community_events' ),
  2175. 'cache' => $events_client->get_cached_events(),
  2176. 'l10n' => array(
  2177. 'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),
  2178. 'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
  2179. 'attend_event_near_generic' => __( 'Attend an upcoming event near you.' ),
  2180. /*
  2181. * These specific examples were chosen to highlight the fact that a
  2182. * state is not needed, even for cities whose name is not unique.
  2183. * It would be too cumbersome to include that in the instructions
  2184. * to the user, so it's left as an implication.
  2185. */
  2186. /*
  2187. * translators: %s is the name of the city we couldn't locate.
  2188. * Replace the examples with cities related to your locale. Test that
  2189. * they match the expected location and have upcoming events before
  2190. * including them. If no cities related to your locale have events,
  2191. * then use cities related to your locale that would be recognizable
  2192. * to most users. Use only the city name itself, without any region
  2193. * or country. Use the endonym (native locale name) instead of the
  2194. * English name if possible.
  2195. */
  2196. 'could_not_locate_city' => __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
  2197. // This one is only used with wp.a11y.speak(), so it can/should be more brief.
  2198. /* translators: %s: The name of a city. */
  2199. 'city_updated' => __( 'City updated. Listing events near %s.' ),
  2200. ),
  2201. )
  2202. );
  2203. }
  2204. /**
  2205. * Administration Screen CSS for changing the styles.
  2206. *
  2207. * If installing the 'wp-admin/' directory will be replaced with './'.
  2208. *
  2209. * The $_wp_admin_css_colors global manages the Administration Screens CSS
  2210. * stylesheet that is loaded. The option that is set is 'admin_color' and is the
  2211. * color and key for the array. The value for the color key is an object with
  2212. * a 'url' parameter that has the URL path to the CSS file.
  2213. *
  2214. * The query from $src parameter will be appended to the URL that is given from
  2215. * the $_wp_admin_css_colors array value URL.
  2216. *
  2217. * @since 2.6.0
  2218. * @global array $_wp_admin_css_colors
  2219. *
  2220. * @param string $src Source URL.
  2221. * @param string $handle Either 'colors' or 'colors-rtl'.
  2222. * @return string|false URL path to CSS stylesheet for Administration Screens.
  2223. */
  2224. function wp_style_loader_src( $src, $handle ) {
  2225. global $_wp_admin_css_colors;
  2226. if ( wp_installing() ) {
  2227. return preg_replace( '#^wp-admin/#', './', $src );
  2228. }
  2229. if ( 'colors' === $handle ) {
  2230. $color = get_user_option( 'admin_color' );
  2231. if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) {
  2232. $color = 'fresh';
  2233. }
  2234. $color = $_wp_admin_css_colors[ $color ];
  2235. $url = $color->url;
  2236. if ( ! $url ) {
  2237. return false;
  2238. }
  2239. $parsed = parse_url( $src );
  2240. if ( isset( $parsed['query'] ) && $parsed['query'] ) {
  2241. wp_parse_str( $parsed['query'], $qv );
  2242. $url = add_query_arg( $qv, $url );
  2243. }
  2244. return $url;
  2245. }
  2246. return $src;
  2247. }
  2248. /**
  2249. * Prints the script queue in the HTML head on admin pages.
  2250. *
  2251. * Postpones the scripts that were queued for the footer.
  2252. * print_footer_scripts() is called in the footer to print these scripts.
  2253. *
  2254. * @since 2.8.0
  2255. *
  2256. * @see wp_print_scripts()
  2257. *
  2258. * @global bool $concatenate_scripts
  2259. *
  2260. * @return array
  2261. */
  2262. function print_head_scripts() {
  2263. global $concatenate_scripts;
  2264. if ( ! did_action( 'wp_print_scripts' ) ) {
  2265. /** This action is documented in wp-includes/functions.wp-scripts.php */
  2266. do_action( 'wp_print_scripts' );
  2267. }
  2268. $wp_scripts = wp_scripts();
  2269. script_concat_settings();
  2270. $wp_scripts->do_concat = $concatenate_scripts;
  2271. $wp_scripts->do_head_items();
  2272. /**
  2273. * Filters whether to print the head scripts.
  2274. *
  2275. * @since 2.8.0
  2276. *
  2277. * @param bool $print Whether to print the head scripts. Default true.
  2278. */
  2279. if ( apply_filters( 'print_head_scripts', true ) ) {
  2280. _print_scripts();
  2281. }
  2282. $wp_scripts->reset();
  2283. return $wp_scripts->done;
  2284. }
  2285. /**
  2286. * Prints the scripts that were queued for the footer or too late for the HTML head.
  2287. *
  2288. * @since 2.8.0
  2289. *
  2290. * @global WP_Scripts $wp_scripts
  2291. * @global bool $concatenate_scripts
  2292. *
  2293. * @return array
  2294. */
  2295. function print_footer_scripts() {
  2296. global $wp_scripts, $concatenate_scripts;
  2297. if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
  2298. return array(); // No need to run if not instantiated.
  2299. }
  2300. script_concat_settings();
  2301. $wp_scripts->do_concat = $concatenate_scripts;
  2302. $wp_scripts->do_footer_items();
  2303. /**
  2304. * Filters whether to print the footer scripts.
  2305. *
  2306. * @since 2.8.0
  2307. *
  2308. * @param bool $print Whether to print the footer scripts. Default true.
  2309. */
  2310. if ( apply_filters( 'print_footer_scripts', true ) ) {
  2311. _print_scripts();
  2312. }
  2313. $wp_scripts->reset();
  2314. return $wp_scripts->done;
  2315. }
  2316. /**
  2317. * Print scripts (internal use only)
  2318. *
  2319. * @ignore
  2320. *
  2321. * @global WP_Scripts $wp_scripts
  2322. * @global bool $compress_scripts
  2323. */
  2324. function _print_scripts() {
  2325. global $wp_scripts, $compress_scripts;
  2326. $zip = $compress_scripts ? 1 : 0;
  2327. if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
  2328. $zip = 'gzip';
  2329. }
  2330. $concat = trim( $wp_scripts->concat, ', ' );
  2331. $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'";
  2332. if ( $concat ) {
  2333. if ( ! empty( $wp_scripts->print_code ) ) {
  2334. echo "\n<script{$type_attr}>\n";
  2335. echo "/* <![CDATA[ */\n"; // not needed in HTML 5
  2336. echo $wp_scripts->print_code;
  2337. echo "/* ]]> */\n";
  2338. echo "</script>\n";
  2339. }
  2340. $concat = str_split( $concat, 128 );
  2341. $concatenated = '';
  2342. foreach ( $concat as $key => $chunk ) {
  2343. $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
  2344. }
  2345. $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
  2346. echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
  2347. }
  2348. if ( ! empty( $wp_scripts->print_html ) ) {
  2349. echo $wp_scripts->print_html;
  2350. }
  2351. }
  2352. /**
  2353. * Prints the script queue in the HTML head on the front end.
  2354. *
  2355. * Postpones the scripts that were queued for the footer.
  2356. * wp_print_footer_scripts() is called in the footer to print these scripts.
  2357. *
  2358. * @since 2.8.0
  2359. *
  2360. * @global WP_Scripts $wp_scripts
  2361. *
  2362. * @return array
  2363. */
  2364. function wp_print_head_scripts() {
  2365. if ( ! did_action( 'wp_print_scripts' ) ) {
  2366. /** This action is documented in wp-includes/functions.wp-scripts.php */
  2367. do_action( 'wp_print_scripts' );
  2368. }
  2369. global $wp_scripts;
  2370. if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
  2371. return array(); // no need to run if nothing is queued
  2372. }
  2373. return print_head_scripts();
  2374. }
  2375. /**
  2376. * Private, for use in *_footer_scripts hooks
  2377. *
  2378. * @since 3.3.0
  2379. */
  2380. function _wp_footer_scripts() {
  2381. print_late_styles();
  2382. print_footer_scripts();
  2383. }
  2384. /**
  2385. * Hooks to print the scripts and styles in the footer.
  2386. *
  2387. * @since 2.8.0
  2388. */
  2389. function wp_print_footer_scripts() {
  2390. /**
  2391. * Fires when footer scripts are printed.
  2392. *
  2393. * @since 2.8.0
  2394. */
  2395. do_action( 'wp_print_footer_scripts' );
  2396. }
  2397. /**
  2398. * Wrapper for do_action('wp_enqueue_scripts')
  2399. *
  2400. * Allows plugins to queue scripts for the front end using wp_enqueue_script().
  2401. * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
  2402. *
  2403. * @since 2.8.0
  2404. */
  2405. function wp_enqueue_scripts() {
  2406. /**
  2407. * Fires when scripts and styles are enqueued.
  2408. *
  2409. * @since 2.8.0
  2410. */
  2411. do_action( 'wp_enqueue_scripts' );
  2412. }
  2413. /**
  2414. * Prints the styles queue in the HTML head on admin pages.
  2415. *
  2416. * @since 2.8.0
  2417. *
  2418. * @global bool $concatenate_scripts
  2419. *
  2420. * @return array
  2421. */
  2422. function print_admin_styles() {
  2423. global $concatenate_scripts;
  2424. $wp_styles = wp_styles();
  2425. script_concat_settings();
  2426. $wp_styles->do_concat = $concatenate_scripts;
  2427. $wp_styles->do_items( false );
  2428. /**
  2429. * Filters whether to print the admin styles.
  2430. *
  2431. * @since 2.8.0
  2432. *
  2433. * @param bool $print Whether to print the admin styles. Default true.
  2434. */
  2435. if ( apply_filters( 'print_admin_styles', true ) ) {
  2436. _print_styles();
  2437. }
  2438. $wp_styles->reset();
  2439. return $wp_styles->done;
  2440. }
  2441. /**
  2442. * Prints the styles that were queued too late for the HTML head.
  2443. *
  2444. * @since 3.3.0
  2445. *
  2446. * @global WP_Styles $wp_styles
  2447. * @global bool $concatenate_scripts
  2448. *
  2449. * @return array|void
  2450. */
  2451. function print_late_styles() {
  2452. global $wp_styles, $concatenate_scripts;
  2453. if ( ! ( $wp_styles instanceof WP_Styles ) ) {
  2454. return;
  2455. }
  2456. script_concat_settings();
  2457. $wp_styles->do_concat = $concatenate_scripts;
  2458. $wp_styles->do_footer_items();
  2459. /**
  2460. * Filters whether to print the styles queued too late for the HTML head.
  2461. *
  2462. * @since 3.3.0
  2463. *
  2464. * @param bool $print Whether to print the 'late' styles. Default true.
  2465. */
  2466. if ( apply_filters( 'print_late_styles', true ) ) {
  2467. _print_styles();
  2468. }
  2469. $wp_styles->reset();
  2470. return $wp_styles->done;
  2471. }
  2472. /**
  2473. * Print styles (internal use only)
  2474. *
  2475. * @ignore
  2476. * @since 3.3.0
  2477. *
  2478. * @global bool $compress_css
  2479. */
  2480. function _print_styles() {
  2481. global $compress_css;
  2482. $wp_styles = wp_styles();
  2483. $zip = $compress_css ? 1 : 0;
  2484. if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
  2485. $zip = 'gzip';
  2486. }
  2487. $concat = trim( $wp_styles->concat, ', ' );
  2488. $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
  2489. if ( $concat ) {
  2490. $dir = $wp_styles->text_direction;
  2491. $ver = $wp_styles->default_version;
  2492. $concat = str_split( $concat, 128 );
  2493. $concatenated = '';
  2494. foreach ( $concat as $key => $chunk ) {
  2495. $concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
  2496. }
  2497. $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
  2498. echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
  2499. if ( ! empty( $wp_styles->print_code ) ) {
  2500. echo "<style{$type_attr}>\n";
  2501. echo $wp_styles->print_code;
  2502. echo "\n</style>\n";
  2503. }
  2504. }
  2505. if ( ! empty( $wp_styles->print_html ) ) {
  2506. echo $wp_styles->print_html;
  2507. }
  2508. }
  2509. /**
  2510. * Determine the concatenation and compression settings for scripts and styles.
  2511. *
  2512. * @since 2.8.0
  2513. *
  2514. * @global bool $concatenate_scripts
  2515. * @global bool $compress_scripts
  2516. * @global bool $compress_css
  2517. */
  2518. function script_concat_settings() {
  2519. global $concatenate_scripts, $compress_scripts, $compress_css;
  2520. $compressed_output = ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) );
  2521. if ( ! isset( $concatenate_scripts ) ) {
  2522. $concatenate_scripts = defined( 'CONCATENATE_SCRIPTS' ) ? CONCATENATE_SCRIPTS : true;
  2523. if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
  2524. $concatenate_scripts = false;
  2525. }
  2526. }
  2527. if ( ! isset( $compress_scripts ) ) {
  2528. $compress_scripts = defined( 'COMPRESS_SCRIPTS' ) ? COMPRESS_SCRIPTS : true;
  2529. if ( $compress_scripts && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) {
  2530. $compress_scripts = false;
  2531. }
  2532. }
  2533. if ( ! isset( $compress_css ) ) {
  2534. $compress_css = defined( 'COMPRESS_CSS' ) ? COMPRESS_CSS : true;
  2535. if ( $compress_css && ( ! get_site_option( 'can_compress_scripts' ) || $compressed_output ) ) {
  2536. $compress_css = false;
  2537. }
  2538. }
  2539. }
  2540. /**
  2541. * Handles the enqueueing of block scripts and styles that are common to both
  2542. * the editor and the front-end.
  2543. *
  2544. * @since 5.0.0
  2545. *
  2546. * @global WP_Screen $current_screen WordPress current screen object.
  2547. */
  2548. function wp_common_block_scripts_and_styles() {
  2549. global $current_screen;
  2550. if ( is_admin() && ( $current_screen instanceof WP_Screen ) && ! $current_screen->is_block_editor() ) {
  2551. return;
  2552. }
  2553. wp_enqueue_style( 'wp-block-library' );
  2554. if ( current_theme_supports( 'wp-block-styles' ) ) {
  2555. wp_enqueue_style( 'wp-block-library-theme' );
  2556. }
  2557. /**
  2558. * Fires after enqueuing block assets for both editor and front-end.
  2559. *
  2560. * Call `add_action` on any hook before 'wp_enqueue_scripts'.
  2561. *
  2562. * In the function call you supply, simply use `wp_enqueue_script` and
  2563. * `wp_enqueue_style` to add your functionality to the Gutenberg editor.
  2564. *
  2565. * @since 5.0.0
  2566. */
  2567. do_action( 'enqueue_block_assets' );
  2568. }
  2569. /**
  2570. * Enqueues registered block scripts and styles, depending on current rendered
  2571. * context (only enqueuing editor scripts while in context of the editor).
  2572. *
  2573. * @since 5.0.0
  2574. *
  2575. * @global WP_Screen $current_screen WordPress current screen object.
  2576. */
  2577. function wp_enqueue_registered_block_scripts_and_styles() {
  2578. global $current_screen;
  2579. $is_editor = ( ( $current_screen instanceof WP_Screen ) && $current_screen->is_block_editor() );
  2580. $block_registry = WP_Block_Type_Registry::get_instance();
  2581. foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
  2582. // Front-end styles.
  2583. if ( ! empty( $block_type->style ) ) {
  2584. wp_enqueue_style( $block_type->style );
  2585. }
  2586. // Front-end script.
  2587. if ( ! empty( $block_type->script ) ) {
  2588. wp_enqueue_script( $block_type->script );
  2589. }
  2590. // Editor styles.
  2591. if ( $is_editor && ! empty( $block_type->editor_style ) ) {
  2592. wp_enqueue_style( $block_type->editor_style );
  2593. }
  2594. // Editor script.
  2595. if ( $is_editor && ! empty( $block_type->editor_script ) ) {
  2596. wp_enqueue_script( $block_type->editor_script );
  2597. }
  2598. }
  2599. }
  2600. /**
  2601. * Function responsible for enqueuing the styles required for block styles functionality on the editor and on the frontend.
  2602. *
  2603. * @since 5.3.0
  2604. */
  2605. function enqueue_block_styles_assets() {
  2606. $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
  2607. foreach ( $block_styles as $styles ) {
  2608. foreach ( $styles as $style_properties ) {
  2609. if ( isset( $style_properties['style_handle'] ) ) {
  2610. wp_enqueue_style( $style_properties['style_handle'] );
  2611. }
  2612. if ( isset( $style_properties['inline_style'] ) ) {
  2613. wp_add_inline_style( 'wp-block-library', $style_properties['inline_style'] );
  2614. }
  2615. }
  2616. }
  2617. }
  2618. /**
  2619. * Function responsible for enqueuing the assets required for block styles functionality on the editor.
  2620. *
  2621. * @since 5.3.0
  2622. */
  2623. function enqueue_editor_block_styles_assets() {
  2624. $block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();
  2625. $register_script_lines = array( '( function() {' );
  2626. foreach ( $block_styles as $block_name => $styles ) {
  2627. foreach ( $styles as $style_properties ) {
  2628. $register_script_lines[] = sprintf(
  2629. ' wp.blocks.registerBlockStyle( \'%s\', %s );',
  2630. $block_name,
  2631. wp_json_encode(
  2632. array(
  2633. 'name' => $style_properties['name'],
  2634. 'label' => $style_properties['label'],
  2635. )
  2636. )
  2637. );
  2638. }
  2639. }
  2640. $register_script_lines[] = '} )();';
  2641. $inline_script = implode( "\n", $register_script_lines );
  2642. wp_register_script( 'wp-block-styles', false, array( 'wp-blocks' ), true, true );
  2643. wp_add_inline_script( 'wp-block-styles', $inline_script );
  2644. wp_enqueue_script( 'wp-block-styles' );
  2645. }