<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12632] sites/trunk: Theme Directory: Refactor the API calls to properly query the user with favorites.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/12632">12632</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/12632","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-06-08 02:34:42 +0000 (Thu, 08 Jun 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Theme Directory: Refactor the API calls to properly query the user with favorites.
This reverts <a href="http://meta.trac.wordpress.org/changeset/12630">[12630]</a> which was a quick-fix for the issue, but it was actually caused by <a href="http://meta.trac.wordpress.org/changeset/12600">[12600]</a>.
This refactors the API query code to avoid using jsonp requests for ease of debugging, and slims down the request to what it actually needs to query for.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkapiwordpressorgpublic_htmlthemesthemedirectory10indexphp">sites/trunk/api.wordpress.org/public_html/themes/theme-directory/1.0/index.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsthemedirectoryclassthemesapiphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesjsthemejs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesjsthememinjs">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.min.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkapiwordpressorgpublic_htmlthemesthemedirectory10indexphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/api.wordpress.org/public_html/themes/theme-directory/1.0/index.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/api.wordpress.org/public_html/themes/theme-directory/1.0/index.php 2023-06-08 00:34:57 UTC (rev 12631)
+++ sites/trunk/api.wordpress.org/public_html/themes/theme-directory/1.0/index.php 2023-06-08 02:34:42 UTC (rev 12632)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,8 +17,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function api_send_json( $data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Allow cross-domain calls from *.wordpress.org
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $_SERVER['HTTP_ORIGIN'] ) && preg_match( '!^https?://[^.]+\.wordpress\.org/!i', $_SERVER['HTTP_ORIGIN'] ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $_SERVER['HTTP_ORIGIN'] ) && preg_match( '!^https?://([^.]+\.)?wordpress\.org/?$!i', $_SERVER['HTTP_ORIGIN'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> header( 'Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ header( 'Access-Control-Allow-Credentials: true' ); // Allow cookies to be used.
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $_GET['callback'] ) ) {
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsthemedirectoryclassthemesapiphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php 2023-06-08 00:34:57 UTC (rev 12631)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php 2023-06-08 02:34:42 UTC (rev 12632)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,12 +122,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Favorites requests require a user to fetch favorites for.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $this->request->browse ) && 'favorites' === $this->request->browse && ! isset( $this->request->user ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_user_logged_in() ) {
- $this->request->user = wp_get_current_user()->user_nicename;
- } else {
- $this->request->user = '';
- $this->bad_input = true;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request->user = '';
+ $this->bad_input = true;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $array_of_string_fields = [
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesjsthemejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js 2023-06-08 00:34:57 UTC (rev 12631)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js 2023-06-08 02:34:42 UTC (rev 12632)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,47 +345,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var url = themes.data.settings.apiEndpoint,
</span><span class="cx" style="display: block; padding: 0 10px"> data, options;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- data = _.extend({
- per_page: themes.data.settings.postsPerPage,
- locale: themes.data.settings.locale,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ data = _.extend( {
+ action: 'query_themes',
+ // Fields which are not set as true in theme-directory/class-themes-api.php for the API endpoint used.
</ins><span class="cx" style="display: block; padding: 0 10px"> fields: {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- description: true,
- sections: false,
- tested: true,
- requires: true,
- downloaded: false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ active_installs: true,
</ins><span class="cx" style="display: block; padding: 0 10px"> downloadlink: true,
</span><span class="cx" style="display: block; padding: 0 10px"> last_updated: true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- homepage: true,
- theme_url: true,
- parent: true,
- tags: true,
- rating: true,
</del><span class="cx" style="display: block; padding: 0 10px"> ratings: true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- num_ratings: true,
- extended_author: true,
</del><span class="cx" style="display: block; padding: 0 10px"> photon_screenshots: true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- active_installs: true,
- requires_php: true,
- is_commercial: true,
- is_community: true,
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ tags: true,
+ theme_url: true,
+ },
+ per_page: themes.data.settings.postsPerPage,
+ locale: themes.data.settings.locale
</ins><span class="cx" style="display: block; padding: 0 10px"> }, request);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Requests against api.WordPress.org need to be nested.
- if ( 'api.wordpress.org' === ( new URL(url) ).hostname ) {
- data = {
- action: 'query_themes',
- // Request data
- request: data
- };
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> options = {
</span><span class="cx" style="display: block; padding: 0 10px"> type: 'GET',
</span><span class="cx" style="display: block; padding: 0 10px"> url: url,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jsonp: 'callback',
- dataType: 'jsonp',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ dataType: 'json',
</ins><span class="cx" style="display: block; padding: 0 10px"> data: data,
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> beforeSend: function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -506,7 +485,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'click .theme-actions .button-secondary': 'preview',
</span><span class="cx" style="display: block; padding: 0 10px"> 'keydown .theme-actions .button-secondary': 'preview',
</span><span class="cx" style="display: block; padding: 0 10px"> 'touchend .theme-actions .button-secondary': 'preview',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'click .favorite': 'favourite_toggle',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'click .favorite': 'favorite_toggle',
</ins><span class="cx" style="display: block; padding: 0 10px"> // This is provided by a Third Party
</span><span class="cx" style="display: block; padding: 0 10px"> 'click #theme-patterns-grid-js .wporg-screenshot-card': 'preview',
</span><span class="cx" style="display: block; padding: 0 10px"> 'click .wporg-horizontal-slider-js .wporg-screenshot-card': 'thumbnailPreview',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -572,7 +551,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> this.renderStyleVariations();
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- favourite_toggle: function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ favorite_toggle: function() {
</ins><span class="cx" style="display: block; padding: 0 10px"> var $heart = this.$el.find( '.favorite' ),
</span><span class="cx" style="display: block; padding: 0 10px"> favorited = ! $heart.hasClass( 'favorited' ),
</span><span class="cx" style="display: block; padding: 0 10px"> slug = this.model.get('slug'),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -594,8 +573,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var options = {
</span><span class="cx" style="display: block; padding: 0 10px"> type: 'GET',
</span><span class="cx" style="display: block; padding: 0 10px"> url: themes.data.settings.favorites.api,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- jsonp: 'callback',
- dataType: 'jsonp',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ dataType: 'json',
+ xhrFields: {
+ withCredentials: true
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> data: {
</span><span class="cx" style="display: block; padding: 0 10px"> action: favorited ? 'add-favorite' : 'remove-favorite',
</span><span class="cx" style="display: block; padding: 0 10px"> theme: this.model.get('slug'),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1696,7 +1677,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'favorites' === section ) {
</span><span class="cx" style="display: block; padding: 0 10px"> this.collection.query( {
</span><span class="cx" style="display: block; padding: 0 10px"> browse: section,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- user: themes.data.settings.favorites.user
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ user: themes.data.settings.currentUser?.login
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> this.collection.query( { browse: section } );
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgthemesjsthememinjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.min.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.min.js 2023-06-08 00:34:57 UTC (rev 12631)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.min.js 2023-06-08 02:34:42 UTC (rev 12632)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1 +1 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-window.wp=window.wp||{},function(n){var s,o=wp.themes=wp.themes||{};o.data=_wpThemeSettings,s=o.data.l10n,_.extend(o,{model:{},view:{},routes:{},router:{},template:wp.template}),o.utils={title:function(e,t){var i=o.data.settings.title.default,t=("author"===t?i=o.data.settings.title.author:"tags"===t||"browse"===t?i=o.data.settings.title.tax:"search"===t?i=o.data.settings.title.search:"theme"===t?i=o.data.settings.title.theme:"404"===t||"notfound"===t?i=o.data.settings.title.notfound:("home"===t||"home"===e&&void 0===t)&&(i=o.data.settings.title.home),n("<div/>").html(i.replace("%s",n("<div/>").text(e).html())).text());document.title!==t&&t.length&&(document.title=t)}},o.Model=Backbone.Model.extend({initialize:function(){var e;
this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e})),this.set({can_configure_categorization_options:o.data.settings.currentUser?.is_admin||this.get("author")?.user_nicename===o.data.settings.currentUser?.slug})}}),o.view.Appearance=wp.Backbone.View.extend({el:"#themes .theme-browser",window:n(window),page:0,loadMore:n(".js-load-more-themes"),initialize:function(e){this.SearchView=e.SearchView||o.view.Search,this.loadMoreThemes=this.loadMoreThemes.bind(this),this.loadMore.bind("click",this.loadMoreThemes)},render:function(){this.view=new o.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.find(".themes").remove(),this.$el.append(this.view.el).addClass("rendered")},searchContainer:"",search:function(){var e=new this.SearchView({collection:this.c
ollection,parent:this});e.render(),this.searchContainer.append(n.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+s.search+"</label>")).append(e.el)},loadMoreThemes:function(){this.trigger("theme:loadMore")}}),o.Collection=Backbone.Collection.extend({model:o.Model,terms:"",queries:[],currentQuery:{page:1,request:{}},count:!1,loadingThemes:!1,doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&this.reset(o.data.themes),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(o.data.themes,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return s=e.get("name").replace(/(<([^>]+)>)/gi,""),r=e
.get("description").replace(/(<([^>]+)>)/gi,""),a=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([s,e.get("id"),r,a,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):n("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(o.data.settings.postsPerPage*e)),t=_(t.first(o.data.settings.postsPerPage))},query:function(t){var e,i,s,r=this.queries,a=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){a.add(e.themes),a.trigger("themes:rerender"),a.trigger("query:success",e.info.results),a.loadingThemes=!1}).fail(function(){a.trigger("query:fa
il")});0===e.themes.length?a.trigger("query:empty"):n("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.themes),e.total||(this.count=this.length),this.trigger("themes:update"),this.trigger("query:success",this.count)}else this.apiCall(t).done(function(e){e.themes&&(a.reset(e.themes),s=e.info.results,r.push({themes:e.themes,request:t,total:s})),a.trigger("themes:update"),a.trigger("query:success",s),e.themes&&0===e.themes.length&&a.trigger("query:empty")}).fail(function(){a.trigger("query:fail")})},apiCall:function(e,t){var i,s=o.data.settings.apiEndpoint,e=_.extend({per_page:o.data.settings.postsPerPage,locale:o.data.settings.locale,fields:{description:!0,sections:!1,tested:!0,requires:!0,downloaded:!1,downloadlink:!0,last_updated:!0,homepage:!0,theme_url:!0,parent:!0,tags:!0,rating:!0,ratings:!0,num_ratings:!0,extended
_author:!0,photon_screenshots:!0,active_installs:!0,requires_php:!0,is_commercial:!0,is_community:!0}},e);return"api.wordpress.org"===new URL(s).hostname&&(e={action:"query_themes",request:e}),i={type:"GET",url:s,jsonp:"callback",dataType:"jsonp",data:e,beforeSend:function(){t||n("body").addClass("loading-content").removeClass("no-results")}},n.Deferred(function(t){n.ajax(i).done(function(e){t.resolveWith(this,[e])}).fail(function(){t.rejectWith(this,arguments)})}).promise()}}),o.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:wp.themes.template("theme"),events:{click:"expand",keydown:"expand",touchend:"expand",keyup:"addFocus",touchmove:"preventExpand"},touchDrag:!1,render:function(){var e=this.model.toJSON();e.permalink=o.data.settings.path+o.router.baseUrl(e.slug),e.path=o.data.settings.path
,this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name"})},addFocus:function(){var e=n(":focus").hasClass("theme")?n(":focus"):n(":focus").parents(".theme");n(".theme.focus").removeClass("focus"),e.addClass("focus")},expand:function(e){if(!(!0===(e=e||window.event).metaKey|e.ctrlKey&&"click"===e.type||"keydown"===e.type&&13!==e.which&&32!==e.which))return!0===this.touchDrag?this.touchDrag=!1:void(n(e.target).is(".theme-actions a")||(o.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid),e.preventDefault()))},preventExpand:function(){this.touchDrag=!0}}),o.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .left":"previousTheme","click .right":"nextTheme",&quo
t;click .screenshot":"preview","click .theme-actions .button-secondary":"preview","keydown .theme-actions .button-secondary":"preview","touchend .theme-actions .button-secondary":"preview","click .favorite":"favourite_toggle","click #theme-patterns-grid-js .wporg-screenshot-card":"preview","click .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview","keydown .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview"},html:o.template("theme-single"),render:function(){var e=this.model.toJSON(),t=new Date;t.setUTCFullYear(e.last_updated.substring(0,4),e.last_updated.substring(5,7)-1,e.last_updated.substring(8,10)),e.last_updated=t.toLocaleDateString(s.locale,{day:"numeric",month:"long",year:"numeric"}),e.is_outdated=t.setYear(t.getYear()+1902).valueOf()<(new Date
).valueOf(),e.tags=_.map(e.tags,function(e,t){e=s.tags[t]||e;return'<a href="'+o.data.settings.path+o.router.baseUrl("tags/"+t)+'">'+e+"</a>"}).join(", "),e.path=o.data.settings.path,e.active_installs<10?e.active_installs=s.active_installs_less_than_10:1e6<=e.active_installs?e.active_installs=s.active_installs_1_million:e.active_installs=e.active_installs.toLocaleString()+"+",e.show_favorites=!!o.data.settings.currentUser?.login,e.is_favorited=-1!==o.data.settings.favorites.themes.indexOf(e.slug),e.current_user=o.data.settings.currentUser?.login,this.$el.html(this.html(e)),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el),this.renderDownloadsGraph(),this.renderPatterns(),this.renderStyleVariations()},favourite_toggle:function(){var e=this.$el.find(".favorite"),t=!e.hasClass("favorited"),i=this.model.get("slug"),i=(e.toggleClass("favorited"),t?o.data.
settings.favorites.themes.push(i):-1<(e=o.data.settings.favorites.themes.indexOf(i))&&delete o.data.settings.favorites.themes[e],{type:"GET",url:o.data.settings.favorites.api,jsonp:"callback",dataType:"jsonp",data:{action:t?"add-favorite":"remove-favorite",theme:this.model.get("slug"),_wpnonce:o.data.settings.favorites.nonce}});n.ajax(i).done(function(e){void 0!==e.error&&"not_logged_in"===e.error&&(o.data.settings.favorites.themes=[],o.data.settings.currentUser=!1)})},preview:function(e){var t,i,s=this,r=this.model.attributes.preview_url,a=document.activeElement;if(!0===this.touchDrag)return this.touchDrag=!1;n(e.target).hasClass("button-primary")||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&n(":focus").hasClass("button")||((e=e||window.event).preventDefault(),o.focuse
dTheme=this.$el,(e=n(e.target).closest("a")[0])&&e.classList.contains("wporg-screenshot-card")&&(this.model.attributes.preview_url=e.href.replace("&preview","")),(i=new o.view.Preview({model:this.model})).render(),this.setNavButtonsState(),o.data.settings.isMobile?i.$el.addClass("wp-full-overlay collapsed"):i.$el.addClass("wp-full-overlay expanded"),n(".theme-install-overlay").append(i.el),this.listenTo(i,"theme:next",function(){if(this.trigger("theme:next"),t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("theme:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),n(".next-theme").focus()}).listenTo(i,"theme:previous",function(){this.trigger("theme:previous"),t=s.model,0===s.model.collec
tion.indexOf(s.current)||(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current))||(i.model=s.current,i.render(),this.setNavButtonsState(),n(".previous-theme").focus())}),this.listenTo(i,"preview:close",function(){s.model.attributes.preview_url=r,s.current=s.model,a&&a.focus()}))},thumbnailPreview:function(e){var t,i,s,r,a;"keydown"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),"a"!==(e=n(e.target)).prop("tagName").toLowerCase()&&(e=n(e.parent("a")[0])),t=n(".screenshot"),i="wporg-screenshot-card__active",s="wporg-thumbnail-screenshot-preview-js",r="style-variation",(a=n(".wporg-horizontal-slider-js .wporg-screenshot-card")).attr("aria-selected",!1),e.attr("aria-selected",!0),0===a.index(e)?(t.find("picture").show(),t.removeClas
s(r),n("."+s).remove()):(a=n('<div class="'+s+'" role="tabpanel"></div>').attr("data-link",e.attr("href")).attr("data-preview-link",e.attr("href")+"&v="+this.model.attributes.version+"-betaV2").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",e.find("img").attr("alt"))).attr("data-height",t.height()+"px").attr("data-aspect-ratio",.75).attr("data-query-string","?vpw=1200&vph=900").attr("id",e.attr("aria-controls")),t.find("picture").hide(),t.addClass(r),n("."+s).remove(),t.append(a),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(s)),n("."+i).removeClass(i),e.addClass(i),this.model.attributes.preview_url=e.attr("href"))},setNavButtonsState:function(){var e
=n(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current;0===this.model.collection.indexOf(t)&&e.find(".previous-theme").addClass("disabled"),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&e.find(".next-theme").addClass("disabled")},containFocus:function(t){var e=window.event;void 0!==e&&1!==n(e.target).closest(".theme").length||_.delay(function(){n(".theme-wrap a.button-primary:visible").focus()},500),t.on("keydown.wp-themes",function(e){9===e.which&&n(e.target).is("button.close")&&e.shiftKey&&(t.find(".theme-tags a:last-child").focus(),e.preventDefault())})},collapse:function(e){var t,i,s,r=this,a={};1!==o.data.themes.length&&(e=e||window.event,n(e.target).is(".close")||27===e.keyCode)&&(n("body").addClass("closing-overlay"),r.unmountR
eactAssets(),this.$el.fadeOut(1,function(){n("body").removeClass("closing-overlay"),r.closeOverlay(),t=document.body.scrollTop,(s=o.Collection.prototype.currentQuery.request.author)?(o.router.navigate(o.router.baseUrl("author/"+s)),o.utils.title(s,"author")):(s=o.Collection.prototype.currentQuery.request.search)?(o.router.navigate(o.router.baseUrl(o.router.searchPath+s)),o.utils.title(s,"search")):(i=o.view.Installer.prototype.filtersChecked())?(o.router.navigate(o.router.baseUrl("tags/"+i.join("+"))),o.utils.title(_.each(i,function(e,t){i[t]=n('label[for="filter-id-'+e+'"]').text()})[0],"tags")):(s=n(".filter-links .current"))&&(s.length||(s=n('.filter-links [data-sort="'+o.data.settings.browseDefault+'"]'),a={trigger:!0}),o.data.settings.browseDefault===s.data("sort")?(o.router.navigate(o.router.baseUrl("/"),a),o.utils.title("home")):(
o.router.navigate(o.router.baseUrl(o.router.browsePath+s.data("sort")),a),o.utils.title(s.text(),"browse"))),document.body.scrollTop=t,o.focusedTheme&&o.focusedTheme.focus()}))},renderDownloadsGraph:function(){var t=this;n.getJSON("https://api.wordpress.org/stats/themes/1.0/downloads.php?slug="+t.model.get("id")+"&limit=260&callback=?",function(e){google.charts.setOnLoadCallback(function(){var i=new google.visualization.DataTable,s=0;i.addColumn("string",_wpThemeSettings.l10n.date),i.addColumn("number",_wpThemeSettings.l10n.downloads),n.each(e,function(e,t){i.addRow(),i.setValue(s,0,new Date(e).toLocaleDateString()),i.setValue(s,1,Number(t)),s++}),new google.visualization.ColumnChart(document.getElementById("theme-download-stats-"+t.model.get("id"))).draw(i,{colors:["#253578"],legend:{position:"none"},titlePosition:"in",axisTitlesPosition:"in&q
uot;,chartArea:{height:280,left:35,width:"98%"},hAxis:{textStyle:{color:"black",fontSize:9}},vAxis:{format:"###,###",textPosition:"out",viewWindowMode:"explicit",viewWindow:{min:0}},bar:{groupWidth:100<i.getNumberOfRows()?"100%":null},height:350})})})},renderPatterns:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-patterns/v1/patterns"},s=this.model;function r(i,e){n.each(e,function(e,t){t=n('<div class="wporg-screenshot-preview-js"></div>').attr("data-link",t.link).attr("data-preview-link",t.preview_link+"&v="+s.get("version")+"-betaV4.0.4").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",t.title));i.append(t)}),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(
)}n.ajax(e).done(function(e){var t=n("#theme-patterns-grid-js"),i=n("#theme-patterns-button-js"),s=JSON.parse(e);s.length&&(n("#theme-patterns-js").show(),e=s.slice(0,9),r(t,e),9<s.length)&&(i.show(),i.on("click",function(e){e.preventDefault();e=s.slice(9);r(t,e),t.find(".wporg-screenshot-card")[9].focus(),i.hide()}))})},renderStyleVariations:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-styles/v1/variations"},s=this.model;n.ajax(e).done(function(e){var i,t=n(".wporg-horizontal-slider-js"),e=JSON.parse(e);e.length&&(i=[],n.each(e,function(e,t){i.push({title:t.title,link:t.link,previewLink:t.preview_link+"&v="+s.get("version")+"-betaV1.1.2",caption:_wpThemeSettings.l10n.style_variation_caption_template.replace("%s",t.title)})}),e=i,t.attr("data-items"
,JSON.stringify(e)),t.attr("data-title",_wpThemeSettings.l10n.style_variations_title),window.__wporg_horizontal_slider_render)&&window.__wporg_horizontal_slider_render()})},unmountReactAssets:function(){ReactDOM&&ReactDOM.unmountComponentAtNode&&(n(".wporg-horizontal-slider-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-thumbnail-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled"),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled")},closeOverlay:function(){n("body").removeClass("modal-open"),this.remove(),this.unbind(),
this.trigger("theme:collapse")},nextTheme:function(){return this.trigger("theme:next",this.model.cid),!1},previousTheme:function(){return this.trigger("theme:previous",this.model.cid),!1},screenshotCheck:function(e){(new Image).src=e.find(".screenshot img").attr("src")}}),o.view.Preview=o.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .previous-theme":"previousTheme","click .next-theme":"nextTheme","click .wp-full-overlay-footer .devices button":"devicePreview",keyup:"keyEvent"},html:o.template("theme-preview"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),this
.$el.fadeIn(200,function(){n("body").addClass("theme-installer-active full-overlay-active"),n(".close-full-overlay").focus()}),o.activeDevicePreview&&this.setDevicePreview(o.activeDevicePreview)},close:function(){return this.$el.fadeOut(200,function(){n("body").removeClass("theme-installer-active full-overlay-active"),o.focusedTheme&&o.focusedTheme.focus()}),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),!1},collapse:function(){return this.$el.toggleClass("collapsed"),o.data.settings.isMobile?this.$el.removeClass("expanded"):this.$el.toggleClass("expanded"),!1},devicePreview:function(e){return this.setDevicePreview(e.target.dataset.device)},setDevicePreview:function(e){var t=this.$el.find(".wp-full-overlay-footer");return t.find(".active").removeClass(&
quot;active"),t.find("."+e).addClass("active"),this.$el.find(".wp-full-overlay-main iframe").removeClass(o.activeDevicePreview).addClass(e),o.activeDevicePreview=e,!1},keyEvent:function(){return 27===event.keyCode&&(this.undelegateEvents(),this.close()),39===event.keyCode&&_.once(this.nextTheme()),37===event.keyCode&&this.previousTheme(),!1}}),o.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:n("div.theme-overlay"),index:0,count:n(".wp-filter .theme-count"),initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?t.count.text(e.toLocaleString()):t.count.text(t.collection.length.toLocaleString())}),this.listenTo(t.collection,"query:empty",function(){n("body")
.addClass("no-results")}),this.listenTo(this.parent,"theme:loadMore",function(){t.renderThemes(t.parent.page)}),this.listenTo(t.collection,"themes:rerender",function(){t.renderThemes(t.parent.page)}),this.listenTo(this.parent,"theme:close",function(){t.overlay&&t.overlay.closeOverlay()}),n("body").on("keyup",function(e){t.overlay&&(39===e.keyCode&&t.overlay.nextTheme(),37===e.keyCode&&t.overlay.previousTheme(),27===e.keyCode)&&t.overlay.collapse(e)})},render:function(){this.$el.empty(),1===o.data.themes.length&&(this.singleTheme=new o.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),0<this.options.collection.size()&&this.renderThemes(this.parent.page),this.count.text(this.collection.count||this.collection.length)},renderThemes:function(e){var t=this;t.instance=
t.collection.paginate(e),0===t.instance.size()?this.parent.trigger("theme:end"):(1<=e&&n(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new o.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,"theme:expand",t.expand,t)}),this.parent.page++)},setView:function(e){return e},expand:function(e){var t=this;this.model=t.collection.get(e),_.isUndefined(this.model)||(o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.id)),o.utils.title(this.model.attributes.name,"theme"),this.setView("detail"),n("body").addClass("modal-open"),this.overlay=new o.view.Details({model:t.model}),this.overlay.render(),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){t.next([t.model.cid]),n(".theme-header").find(".right").focus()}).listenTo(this.overlay,"theme:previous",function(){t.previ
ous([t.model.cid]),n(".theme-header").find(".left").focus()}))},next:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)},previous:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)-1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)}}),o.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:s.searchPlaceholder,type:"search"},events:{keyup:"search",search:"search"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"
;===e.type&&27===e.which&&(e.target.value=""),_.debounce(_.bind(this.doSearch,this),300)(e.target.value))},doSearch:_.debounce(function(e){var t={};o.view.Installer.prototype.clearFilters(jQuery.Event("click")),"author:"===(t.search=e).substring(0,7)&&(t.search="",t.author=e.slice(7)),"tag:"===e.substring(0,4)&&(t.search="",t.tag=[e.slice(4)]),n(".filter-links li > a.current").removeClass("current"),n("body").removeClass("show-filters filters-applied"),e?(o.utils.title(e,"search"),o.router.navigate(o.router.baseUrl(o.router.searchPath+e),{replace:!0})):(delete t.search,t.browse=o.data.settings.browseDefault,o.utils.title("home"),o.router.navigate(o.router.baseUrl("/"),{replace:!0})),this.collection.query(t)},300)}),o.view.Installer=o.view.Appearance.extend({el:"#themes",events:{"click .filter-links li >
a":"onSort","click .theme-filter":"onFilter","click .drawer-toggle":"moreFilters","click .filter-drawer .apply-filters":"applyFilters",'click .filter-group [type="checkbox"]':"addFilter","click .filter-drawer .clear-filters":"clearFilters","click .filtered-by":"backToFilters"},activeClass:"current",searchContainer:n(".wp-filter .search-form"),initialize:function(){o.view.Appearance.prototype.initialize.apply(this,arguments),this.sortValues=n(".filter-links li > a").map(function(){return n(this).data("sort")}).get()},render:function(){var i=this;this.search(),this.collection=new o.Collection,this.listenTo(this,"theme:end",function(){i.collection.loadingThemes||n("body").hasClass("modal-open")||i.collection.length<o.data.settings.postsPerPage||(i.collection.loadingThemes=!0,i.
collection.currentQuery.page++,_.extend(i.collection.currentQuery.request,{page:i.collection.currentQuery.page}),i.collection.query(i.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(e){var t;n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),1<i.page&&(t=1+(i.page-1)*o.data.settings.postsPerPage,this.$el.find(".theme:nth-child("+t+")").focus()),(e=_.isNumber(e)?e:i.collection.count)<=i.collection.length?i.loadMore.hide():i.loadMore.show()}),this.listenTo(this.collection,"query:fail",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),n(".theme-browser").find("div.themes").before('<div class="error"><p>'+s.error+"</p></div>")}),this.view&&this.view.remove()
,this.view=new o.view.Themes({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e){"favorites"===e?this.collection.query({browse:e,user:o.data.settings.favorites.user}):this.collection.query({browse:e})},onSort:function(e){var t=n(e.target),i=t.data("sort");e.preventDefault(),!i&&t.data("tag")?o.router.trigger("route:tag",t.data("tag")):(n("body").removeClass("filters-applied show-filters"),t.hasClass(this.activeClass)||(this.sort(i),o.data.settings.browseDefault===i?o.router.navigate(o.router.baseUrl("/")):o.router.navigate(o.router.baseUrl(o.router.browsePath+i))))},sort:function(e){var t=this,i=!1;-1!==_.indexOf(this.sortValues,e)&&(i=n('.filter-links [data-sort="'+e+'"]')),t.clearSearch(),_.each(n(&qu
ot;.filter-group").find(":checkbox").filter(":checked"),function(e){return n(e).prop("checked",!1),t.filtersChecked()}),n(".filter-links li > a, .theme-filter").removeClass(this.activeClass),i&&i.length?(i.addClass(this.activeClass),o.data.settings.browseDefault===e?o.utils.title("home"):o.utils.title(i.text(),"browse"),this.browse(e)):o.utils.title("404","notfound")},onFilter:function(e){var e=n(e.target),t=e.data("filter");e.hasClass(this.activeClass)||(n(".filter-links li > a, .theme-section").removeClass(this.activeClass),e.addClass(this.activeClass),t&&(t=_.union([t,this.filtersChecked()]),this.collection.query({tag:[t]})))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=[],s=this.filtersChecked(),r={tag:s},a=n(".filtered-by .tags");e&&e.preventDefault(),s&&(n("body").addClass("filte
rs-applied"),n(".filter-links li > a.current").removeClass("current"),a.empty(),_.each(s,function(e){t=n('label[for="filter-id-'+e+'"]').text(),i.push(t),a.append('<span class="tag">'+t+"</span>"),n('.filter-links li > a[data-tag="'+e+'"]').addClass("current")}),o.router.navigate(o.router.baseUrl("tags/"+s.join("+"))),o.utils.title(i[0],"tags"),this.collection.query(r))},filtersChecked:function(){var e=n(".filter-group").find(":checkbox").filter(":checked"),t=n(".filter-drawer"),i=[];return _.each(e,function(e){i.push(n(e).prop("value"))}),0===i.length?(t.find(".apply-filters").prop("disabled",!0).find("span").text(""),t.find(".clear-filters").hide(),n("body").removeClass("filters-applied"),!1):(t.find(".apply-filters").prop("dis
abled",!1).find("span").text(i.length),t.find(".clear-filters").css("display","inline-block"),i)},moreFilters:function(e){return e.preventDefault(),n("body").hasClass("filters-applied")?this.backToFilters():n("body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),void n("body").toggleClass("show-filters"))},clearFilters:function(e){var t=n(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return n(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),n("body").removeClass("filters-applied")},clearSearch:function(){n("#wp-filter-search-input").val("")}}),o.Router=Backbone.Router.extend({routes:{"browse/:sort(/page/:page)(/)":"sort","tags
/:tag(/page/:page)(/)":"tag","search/:query(/page/:page)(/)":"search","author/:author(/page/:page)(/)":"author",":slug(/)":"preview","":"sort"},baseUrl:function(e){return"/"===e?e="/#":0!==e.length&&(e+="/"),e},themePath:"",browsePath:"browse/",searchPath:"search/",search:function(e){n(".wp-filter-search").val(e)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),o.History=Backbone.History.extend({getFragment:function(){return Backbone.History.prototype.getFragment.apply(this,arguments).replace(/\?.*/,"")}}),o.Run={init:function(){this.view=new o.view.Installer({section:o.data.settings.browseDefault,SearchView:o.view.Search}),Backbone.history=new o.History,this.render()},render:function(){this.view.render(),this.routes(),Backbone.hist
ory.start({root:o.data.settings.path,pushState:!0,hashChange:!1})},routes:function(){var i=this,s={};o.router=new o.Router,o.router.on("route:preview",function(e){i.view.collection.queries.push(o.data.query),s.theme=e,i.view.collection.query(s),i.view.view.expand(e)}),o.router.on("route:sort",function(e,t){t&&o.router.navigate("browse/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),e=e||o.data.settings.browseDefault,i.view.sort(e),i.view.trigger("theme:close")}),o.router.on("route:search",function(e,t){t&&o.router.navigate("search/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),n(".wp-filter-search").focus().trigger("keyup"),i.view.trigger("theme:close")}),o.router.on("route:tag",function(e,t){t&&o.router.navigate("tags/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query
),_.each(e.split("+"),function(e){e=e.toLowerCase().replace(/[^a-z-]/g,""),n("#filter-id-"+e).prop("checked",!0)}),n("body").removeClass("show-filters").addClass("show-filters"),i.view.applyFilters(),i.view.trigger("theme:close")}),o.router.on("route:author",function(e,t){t&&o.router.navigate("author/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),s.author=e,i.view.collection.query(s),o.utils.title(e,"author"),i.view.trigger("theme:close")})}},n(function(){o.Run.init()})}(jQuery),google.charts.load("current",{packages:["corechart"]}),function(l){function c(e){document.querySelector(".spinner")?.classList.remove("spinner"),e=e.status+": "+e.statusText,alert(e)}document.addEventListener("submit",r=>{var a=r.target.closest("form");if(a&&["commerci
al","community"].includes(a.id)){r.preventDefault();const n=a.querySelector('button[type="submit"]'),o=a.querySelector(".success-msg");r=a.closest(".theme-about")?.dataset.slug;o?.classList.remove("saved");let e="",i=(rest_name="commercial"===a.id?(e="external_support_url","supportURL"):(e="external_repository_url","repositoryURL"),a.querySelector('input[name="'+e+'"]')),s=a.querySelector(".button-small")?.classList.add("spinner"),t=l.restUrl+"themes/v1/theme/"+r+"/"+a.id+"/?_wpnonce="+l.restNonce;originalValue=i.dataset.originalValue??"",n.disabled=!0,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[rest_name]:i.value})}).then(e=>(e.ok||c(e),e)).then(e=>e.json()).then(e=>{let t;t=void 0!==e[rest_name]?(o?.classList.add(&qu
ot;saved"),e[rest_name]):originalValue,i.value=t;e=document.querySelector(".categorization-widget .widget-head a");e&&(e.attributes.href.value=t),n.disabled=!1,s?.classList.remove("spinner")}).catch(e=>{c(e),i.value=originalValue,n.disabled=!1})}})}((window.wp,_wpThemeSettings.rest));
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+window.wp=window.wp||{},function(n){var s,o=wp.themes=wp.themes||{};o.data=_wpThemeSettings,s=o.data.l10n,_.extend(o,{model:{},view:{},routes:{},router:{},template:wp.template}),o.utils={title:function(e,t){var i=o.data.settings.title.default,t=("author"===t?i=o.data.settings.title.author:"tags"===t||"browse"===t?i=o.data.settings.title.tax:"search"===t?i=o.data.settings.title.search:"theme"===t?i=o.data.settings.title.theme:"404"===t||"notfound"===t?i=o.data.settings.title.notfound:("home"===t||"home"===e&&void 0===t)&&(i=o.data.settings.title.home),n("<div/>").html(i.replace("%s",n("<div/>").text(e).html())).text());document.title!==t&&t.length&&(document.title=t)}},o.Model=Backbone.Model.extend({initialize:function(){var e;
this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e})),this.set({can_configure_categorization_options:o.data.settings.currentUser?.is_admin||this.get("author")?.user_nicename===o.data.settings.currentUser?.slug})}}),o.view.Appearance=wp.Backbone.View.extend({el:"#themes .theme-browser",window:n(window),page:0,loadMore:n(".js-load-more-themes"),initialize:function(e){this.SearchView=e.SearchView||o.view.Search,this.loadMoreThemes=this.loadMoreThemes.bind(this),this.loadMore.bind("click",this.loadMoreThemes)},render:function(){this.view=new o.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.find(".themes").remove(),this.$el.append(this.view.el).addClass("rendered")},searchContainer:"",search:function(){var e=new this.SearchView({collection:this.c
ollection,parent:this});e.render(),this.searchContainer.append(n.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+s.search+"</label>")).append(e.el)},loadMoreThemes:function(){this.trigger("theme:loadMore")}}),o.Collection=Backbone.Collection.extend({model:o.Model,terms:"",queries:[],currentQuery:{page:1,request:{}},count:!1,loadingThemes:!1,doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&this.reset(o.data.themes),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(o.data.themes,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return s=e.get("name").replace(/(<([^>]+)>)/gi,""),r=e
.get("description").replace(/(<([^>]+)>)/gi,""),a=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([s,e.get("id"),r,a,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):n("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(o.data.settings.postsPerPage*e)),t=_(t.first(o.data.settings.postsPerPage))},query:function(t){var e,i,s,r=this.queries,a=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){a.add(e.themes),a.trigger("themes:rerender"),a.trigger("query:success",e.info.results),a.loadingThemes=!1}).fail(function(){a.trigger("query:fa
il")});0===e.themes.length?a.trigger("query:empty"):n("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.themes),e.total||(this.count=this.length),this.trigger("themes:update"),this.trigger("query:success",this.count)}else this.apiCall(t).done(function(e){e.themes&&(a.reset(e.themes),s=e.info.results,r.push({themes:e.themes,request:t,total:s})),a.trigger("themes:update"),a.trigger("query:success",s),e.themes&&0===e.themes.length&&a.trigger("query:empty")}).fail(function(){a.trigger("query:fail")})},apiCall:function(e,t){var i={type:"GET",url:o.data.settings.apiEndpoint,dataType:"json",data:_.extend({action:"query_themes",fields:{active_installs:!0,downloadlink:!0,last_updated:!0,ratings:!0,photon_screenshots:!0,tags:!0,theme_url:!0},per_page:o.data.settings.postsPerPage,locale:o.data.setting
s.locale},e),beforeSend:function(){t||n("body").addClass("loading-content").removeClass("no-results")}};return n.Deferred(function(t){n.ajax(i).done(function(e){t.resolveWith(this,[e])}).fail(function(){t.rejectWith(this,arguments)})}).promise()}}),o.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:wp.themes.template("theme"),events:{click:"expand",keydown:"expand",touchend:"expand",keyup:"addFocus",touchmove:"preventExpand"},touchDrag:!1,render:function(){var e=this.model.toJSON();e.permalink=o.data.settings.path+o.router.baseUrl(e.slug),e.path=o.data.settings.path,this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name"})},addFocus:function(){var e=n(":focus").hasClass("theme")?n(":focus"):n(":focus").parents(".theme");n(".theme.fo
cus").removeClass("focus"),e.addClass("focus")},expand:function(e){if(!(!0===(e=e||window.event).metaKey|e.ctrlKey&&"click"===e.type||"keydown"===e.type&&13!==e.which&&32!==e.which))return!0===this.touchDrag?this.touchDrag=!1:void(n(e.target).is(".theme-actions a")||(o.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid),e.preventDefault()))},preventExpand:function(){this.touchDrag=!0}}),o.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .left":"previousTheme","click .right":"nextTheme","click .screenshot":"preview","click .theme-actions .button-secondary":"preview","keydown .theme-actions .button-secondary":"preview","touchend .theme-actions .button-secondary":"preview","click .favorite":
"favorite_toggle","click #theme-patterns-grid-js .wporg-screenshot-card":"preview","click .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview","keydown .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview"},html:o.template("theme-single"),render:function(){var e=this.model.toJSON(),t=new Date;t.setUTCFullYear(e.last_updated.substring(0,4),e.last_updated.substring(5,7)-1,e.last_updated.substring(8,10)),e.last_updated=t.toLocaleDateString(s.locale,{day:"numeric",month:"long",year:"numeric"}),e.is_outdated=t.setYear(t.getYear()+1902).valueOf()<(new Date).valueOf(),e.tags=_.map(e.tags,function(e,t){e=s.tags[t]||e;return'<a href="'+o.data.settings.path+o.router.baseUrl("tags/"+t)+'">'+e+"</a>"}).join(", "),e.path=o.data.settings.path,e.active_installs<10?e.active_installs=s.active_install
s_less_than_10:1e6<=e.active_installs?e.active_installs=s.active_installs_1_million:e.active_installs=e.active_installs.toLocaleString()+"+",e.show_favorites=!!o.data.settings.currentUser?.login,e.is_favorited=-1!==o.data.settings.favorites.themes.indexOf(e.slug),e.current_user=o.data.settings.currentUser?.login,this.$el.html(this.html(e)),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el),this.renderDownloadsGraph(),this.renderPatterns(),this.renderStyleVariations()},favorite_toggle:function(){var e=this.$el.find(".favorite"),t=!e.hasClass("favorited"),i=this.model.get("slug"),i=(e.toggleClass("favorited"),t?o.data.settings.favorites.themes.push(i):-1<(e=o.data.settings.favorites.themes.indexOf(i))&&delete o.data.settings.favorites.themes[e],{type:"GET",url:o.data.settings.favorites.api,dataType:"json",xhrFields:{withCredentials:!0},data:{action:t?"add-favorite":&
quot;remove-favorite",theme:this.model.get("slug"),_wpnonce:o.data.settings.favorites.nonce}});n.ajax(i).done(function(e){void 0!==e.error&&"not_logged_in"===e.error&&(o.data.settings.favorites.themes=[],o.data.settings.currentUser=!1)})},preview:function(e){var t,i,s=this,r=this.model.attributes.preview_url,a=document.activeElement;if(!0===this.touchDrag)return this.touchDrag=!1;n(e.target).hasClass("button-primary")||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&n(":focus").hasClass("button")||((e=e||window.event).preventDefault(),o.focusedTheme=this.$el,(e=n(e.target).closest("a")[0])&&e.classList.contains("wporg-screenshot-card")&&(this.model.attributes.preview_url=e.href.replace("&preview","")),(i=new o.view.Preview({model:this.model})).render(),this.setNavButton
sState(),o.data.settings.isMobile?i.$el.addClass("wp-full-overlay collapsed"):i.$el.addClass("wp-full-overlay expanded"),n(".theme-install-overlay").append(i.el),this.listenTo(i,"theme:next",function(){if(this.trigger("theme:next"),t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("theme:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),n(".next-theme").focus()}).listenTo(i,"theme:previous",function(){this.trigger("theme:previous"),t=s.model,0!==s.model.collection.indexOf(s.current)&&(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current)||(i.model=s.current,i.render(),this.setNavButtonsState(),n(".previous-theme").focus()))}),this.listenTo(i,"previ
ew:close",function(){s.model.attributes.preview_url=r,s.current=s.model,a&&a.focus()}))},thumbnailPreview:function(e){var t,i,s,r,a;"keydown"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),"a"!==(e=n(e.target)).prop("tagName").toLowerCase()&&(e=n(e.parent("a")[0])),t=n(".screenshot"),i="wporg-screenshot-card__active",s="wporg-thumbnail-screenshot-preview-js",r="style-variation",(a=n(".wporg-horizontal-slider-js .wporg-screenshot-card")).attr("aria-selected",!1),e.attr("aria-selected",!0),0===a.index(e)?(t.find("picture").show(),t.removeClass(r),n("."+s).remove()):(a=n('<div class="'+s+'" role="tabpanel"></div>').attr("data-link",e.attr("href")).attr("data-preview-link",e.attr("href")+"&v="+this.model.attributes.version+&quo
t;-betaV2").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",e.find("img").attr("alt"))).attr("data-height",t.height()+"px").attr("data-aspect-ratio",.75).attr("data-query-string","?vpw=1200&vph=900").attr("id",e.attr("aria-controls")),t.find("picture").hide(),t.addClass(r),n("."+s).remove(),t.append(a),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(s)),n("."+i).removeClass(i),e.addClass(i),this.model.attributes.preview_url=e.attr("href"))},setNavButtonsState:function(){var e=n(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current;0===this.model.collection.indexOf(t)&&e.find(".previous-theme").addClass("disabled"),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&a
mp;&e.find(".next-theme").addClass("disabled")},containFocus:function(t){var e=window.event;void 0!==e&&1!==n(e.target).closest(".theme").length||_.delay(function(){n(".theme-wrap a.button-primary:visible").focus()},500),t.on("keydown.wp-themes",function(e){9===e.which&&n(e.target).is("button.close")&&e.shiftKey&&(t.find(".theme-tags a:last-child").focus(),e.preventDefault())})},collapse:function(e){var t,i,s,r=this,a={};1!==o.data.themes.length&&(e=e||window.event,!n(e.target).is(".close")&&27!==e.keyCode||(n("body").addClass("closing-overlay"),r.unmountReactAssets(),this.$el.fadeOut(1,function(){n("body").removeClass("closing-overlay"),r.closeOverlay(),t=document.body.scrollTop,(s=o.Collection.prototype.currentQuery.request.author)?(o.router.navigate(o.router.baseUrl("author/"+s)),o.utils.title(s,"
;author")):(s=o.Collection.prototype.currentQuery.request.search)?(o.router.navigate(o.router.baseUrl(o.router.searchPath+s)),o.utils.title(s,"search")):(i=o.view.Installer.prototype.filtersChecked())?(o.router.navigate(o.router.baseUrl("tags/"+i.join("+"))),o.utils.title(_.each(i,function(e,t){i[t]=n('label[for="filter-id-'+e+'"]').text()})[0],"tags")):(s=n(".filter-links .current"))&&(s.length||(s=n('.filter-links [data-sort="'+o.data.settings.browseDefault+'"]'),a={trigger:!0}),o.data.settings.browseDefault===s.data("sort")?(o.router.navigate(o.router.baseUrl("/"),a),o.utils.title("home")):(o.router.navigate(o.router.baseUrl(o.router.browsePath+s.data("sort")),a),o.utils.title(s.text(),"browse"))),document.body.scrollTop=t,o.focusedTheme&&o.focusedTheme.focus()})))},renderDownloadsGraph:function(){var t=this;n.getJSON("https://api.wordp
ress.org/stats/themes/1.0/downloads.php?slug="+t.model.get("id")+"&limit=260&callback=?",function(e){google.charts.setOnLoadCallback(function(){var i=new google.visualization.DataTable,s=0;i.addColumn("string",_wpThemeSettings.l10n.date),i.addColumn("number",_wpThemeSettings.l10n.downloads),n.each(e,function(e,t){i.addRow(),i.setValue(s,0,new Date(e).toLocaleDateString()),i.setValue(s,1,Number(t)),s++}),new google.visualization.ColumnChart(document.getElementById("theme-download-stats-"+t.model.get("id"))).draw(i,{colors:["#253578"],legend:{position:"none"},titlePosition:"in",axisTitlesPosition:"in",chartArea:{height:280,left:35,width:"98%"},hAxis:{textStyle:{color:"black",fontSize:9}},vAxis:{format:"###,###",textPosition:"out",viewWindowMode:"explicit",viewWindow:{min:0}},bar:{groupWidth:100<i.getNumberOfRows()?"1
00%":null},height:350})})})},renderPatterns:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-patterns/v1/patterns"},s=this.model;function r(i,e){n.each(e,function(e,t){t=n('<div class="wporg-screenshot-preview-js"></div>').attr("data-link",t.link).attr("data-preview-link",t.preview_link+"&v="+s.get("version")+"-betaV4.0.4").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",t.title));i.append(t)}),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render()}n.ajax(e).done(function(e){var t=n("#theme-patterns-grid-js"),i=n("#theme-patterns-button-js"),s=JSON.parse(e);s.length&&(n("#theme-patterns-js").show(),e=s.slice(0,9),r(t,e),9<s.length&&(i.show(),i.on("click",function(e)
{e.preventDefault();e=s.slice(9);r(t,e),t.find(".wporg-screenshot-card")[9].focus(),i.hide()})))})},renderStyleVariations:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-styles/v1/variations"},s=this.model;n.ajax(e).done(function(e){var i,t=n(".wporg-horizontal-slider-js"),e=JSON.parse(e);e.length&&(i=[],n.each(e,function(e,t){i.push({title:t.title,link:t.link,previewLink:t.preview_link+"&v="+s.get("version")+"-betaV1.1.2",caption:_wpThemeSettings.l10n.style_variation_caption_template.replace("%s",t.title)})}),e=i,t.attr("data-items",JSON.stringify(e)),t.attr("data-title",_wpThemeSettings.l10n.style_variations_title),window.__wporg_horizontal_slider_render&&window.__wporg_horizontal_slider_render())})},unmountReactAssets:function(){ReactDOM&&ReactDOM.unmountComponentAtNode&&(n
(".wporg-horizontal-slider-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-thumbnail-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled"),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled")},closeOverlay:function(){n("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("theme:collapse")},nextTheme:function(){return this.trigger("theme:next",this.model.cid),!1},previousTheme:function(){return this.trigger("theme:previous",this.model.cid),!1},screenshotCheck:function(e){(new Image).src=e.find(".screen
shot img").attr("src")}}),o.view.Preview=o.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .previous-theme":"previousTheme","click .next-theme":"nextTheme","click .wp-full-overlay-footer .devices button":"devicePreview",keyup:"keyEvent"},html:o.template("theme-preview"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),this.$el.fadeIn(200,function(){n("body").addClass("theme-installer-active full-overlay-active"),n(".close-full-overlay").focus()}),o.activeDevicePreview&&this.setDevicePreview(o.activeDevicePreview)},close:function(){return this.$el.fadeOut(200,fun
ction(){n("body").removeClass("theme-installer-active full-overlay-active"),o.focusedTheme&&o.focusedTheme.focus()}),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),!1},collapse:function(){return this.$el.toggleClass("collapsed"),o.data.settings.isMobile?this.$el.removeClass("expanded"):this.$el.toggleClass("expanded"),!1},devicePreview:function(e){return this.setDevicePreview(e.target.dataset.device)},setDevicePreview:function(e){var t=this.$el.find(".wp-full-overlay-footer");return t.find(".active").removeClass("active"),t.find("."+e).addClass("active"),this.$el.find(".wp-full-overlay-main iframe").removeClass(o.activeDevicePreview).addClass(e),o.activeDevicePreview=e,!1},keyEvent:function(){return 27===event.keyCode&&(this.undelegateEvents()
,this.close()),39===event.keyCode&&_.once(this.nextTheme()),37===event.keyCode&&this.previousTheme(),!1}}),o.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:n("div.theme-overlay"),index:0,count:n(".wp-filter .theme-count"),initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?t.count.text(e.toLocaleString()):t.count.text(t.collection.length.toLocaleString())}),this.listenTo(t.collection,"query:empty",function(){n("body").addClass("no-results")}),this.listenTo(this.parent,"theme:loadMore",function(){t.renderThemes(t.parent.page)}),this.listenTo(t.collection,"themes:rerender",function(){t.renderThemes(t.parent.page)}),this.listenTo(this.parent,"theme:close",fu
nction(){t.overlay&&t.overlay.closeOverlay()}),n("body").on("keyup",function(e){t.overlay&&(39===e.keyCode&&t.overlay.nextTheme(),37===e.keyCode&&t.overlay.previousTheme(),27===e.keyCode&&t.overlay.collapse(e))})},render:function(){this.$el.empty(),1===o.data.themes.length&&(this.singleTheme=new o.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),0<this.options.collection.size()&&this.renderThemes(this.parent.page),this.count.text(this.collection.count||this.collection.length)},renderThemes:function(e){var t=this;t.instance=t.collection.paginate(e),0===t.instance.size()?this.parent.trigger("theme:end"):(1<=e&&n(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new o.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,&
quot;theme:expand",t.expand,t)}),this.parent.page++)},setView:function(e){return e},expand:function(e){var t=this;this.model=t.collection.get(e),_.isUndefined(this.model)||(o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.id)),o.utils.title(this.model.attributes.name,"theme"),this.setView("detail"),n("body").addClass("modal-open"),this.overlay=new o.view.Details({model:t.model}),this.overlay.render(),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){t.next([t.model.cid]),n(".theme-header").find(".right").focus()}).listenTo(this.overlay,"theme:previous",function(){t.previous([t.model.cid]),n(".theme-header").find(".left").focus()}))},next:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)},previous:function(e){e=this.co
llection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)-1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)}}),o.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:s.searchPlaceholder,type:"search"},events:{keyup:"search",search:"search"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),_.debounce(_.bind(this.doSearch,this),300)(e.target.value))},doSearch:_.debounce(function(e){var t={};o.view.Installer.prototype.clearFilters(jQuery.Event("click")),"author:"===(t.search=e).
substring(0,7)&&(t.search="",t.author=e.slice(7)),"tag:"===e.substring(0,4)&&(t.search="",t.tag=[e.slice(4)]),n(".filter-links li > a.current").removeClass("current"),n("body").removeClass("show-filters filters-applied"),e?(o.utils.title(e,"search"),o.router.navigate(o.router.baseUrl(o.router.searchPath+e),{replace:!0})):(delete t.search,t.browse=o.data.settings.browseDefault,o.utils.title("home"),o.router.navigate(o.router.baseUrl("/"),{replace:!0})),this.collection.query(t)},300)}),o.view.Installer=o.view.Appearance.extend({el:"#themes",events:{"click .filter-links li > a":"onSort","click .theme-filter":"onFilter","click .drawer-toggle":"moreFilters","click .filter-drawer .apply-filters":"applyFilters",'click .filter-group [type="checkbox"]':"addFilter"
,"click .filter-drawer .clear-filters":"clearFilters","click .filtered-by":"backToFilters"},activeClass:"current",searchContainer:n(".wp-filter .search-form"),initialize:function(){o.view.Appearance.prototype.initialize.apply(this,arguments),this.sortValues=n(".filter-links li > a").map(function(){return n(this).data("sort")}).get()},render:function(){var i=this;this.search(),this.collection=new o.Collection,this.listenTo(this,"theme:end",function(){i.collection.loadingThemes||n("body").hasClass("modal-open")||i.collection.length<o.data.settings.postsPerPage||(i.collection.loadingThemes=!0,i.collection.currentQuery.page++,_.extend(i.collection.currentQuery.request,{page:i.collection.currentQuery.page}),i.collection.query(i.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(e){var t;n("body").removeClass("
loading-content"),n(".theme-browser").find("div.error").remove(),1<i.page&&(t=1+(i.page-1)*o.data.settings.postsPerPage,this.$el.find(".theme:nth-child("+t+")").focus()),(e=_.isNumber(e)?e:i.collection.count)<=i.collection.length?i.loadMore.hide():i.loadMore.show()}),this.listenTo(this.collection,"query:fail",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),n(".theme-browser").find("div.themes").before('<div class="error"><p>'+s.error+"</p></div>")}),this.view&&this.view.remove(),this.view=new o.view.Themes({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e){"favorites"=
==e?this.collection.query({browse:e,user:o.data.settings.currentUser?.login}):this.collection.query({browse:e})},onSort:function(e){var t=n(e.target),i=t.data("sort");e.preventDefault(),!i&&t.data("tag")?o.router.trigger("route:tag",t.data("tag")):(n("body").removeClass("filters-applied show-filters"),t.hasClass(this.activeClass)||(this.sort(i),o.data.settings.browseDefault===i?o.router.navigate(o.router.baseUrl("/")):o.router.navigate(o.router.baseUrl(o.router.browsePath+i))))},sort:function(e){var t=this,i=!1;-1!==_.indexOf(this.sortValues,e)&&(i=n('.filter-links [data-sort="'+e+'"]')),t.clearSearch(),_.each(n(".filter-group").find(":checkbox").filter(":checked"),function(e){return n(e).prop("checked",!1),t.filtersChecked()}),n(".filter-links li > a, .theme-filter").removeClass(this.activeClass),i&&i.length?(i.addClass(this.ac
tiveClass),o.data.settings.browseDefault===e?o.utils.title("home"):o.utils.title(i.text(),"browse"),this.browse(e)):o.utils.title("404","notfound")},onFilter:function(e){var e=n(e.target),t=e.data("filter");e.hasClass(this.activeClass)||(n(".filter-links li > a, .theme-section").removeClass(this.activeClass),e.addClass(this.activeClass),t&&(t=_.union([t,this.filtersChecked()]),this.collection.query({tag:[t]})))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=[],s=this.filtersChecked(),r={tag:s},a=n(".filtered-by .tags");e&&e.preventDefault(),s&&(n("body").addClass("filters-applied"),n(".filter-links li > a.current").removeClass("current"),a.empty(),_.each(s,function(e){t=n('label[for="filter-id-'+e+'"]').text(),i.push(t),a.append('<span class="tag">'+t+"</span>"),n('.filter-
links li > a[data-tag="'+e+'"]').addClass("current")}),o.router.navigate(o.router.baseUrl("tags/"+s.join("+"))),o.utils.title(i[0],"tags"),this.collection.query(r))},filtersChecked:function(){var e=n(".filter-group").find(":checkbox").filter(":checked"),t=n(".filter-drawer"),i=[];return _.each(e,function(e){i.push(n(e).prop("value"))}),0===i.length?(t.find(".apply-filters").prop("disabled",!0).find("span").text(""),t.find(".clear-filters").hide(),n("body").removeClass("filters-applied"),!1):(t.find(".apply-filters").prop("disabled",!1).find("span").text(i.length),t.find(".clear-filters").css("display","inline-block"),i)},moreFilters:function(e){return e.preventDefault(),n("body").hasClass("filters-applied")?this.backToFilters():n(&quo
t;body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),void n("body").toggleClass("show-filters"))},clearFilters:function(e){var t=n(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return n(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),n("body").removeClass("filters-applied")},clearSearch:function(){n("#wp-filter-search-input").val("")}}),o.Router=Backbone.Router.extend({routes:{"browse/:sort(/page/:page)(/)":"sort","tags/:tag(/page/:page)(/)":"tag","search/:query(/page/:page)(/)":"search","author/:author(/page/:page)(/)":"author",":slug(/)":"preview","":"sort"},baseUrl:function(e){return"/"
===e?e="/#":0!==e.length&&(e+="/"),e},themePath:"",browsePath:"browse/",searchPath:"search/",search:function(e){n(".wp-filter-search").val(e)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),o.History=Backbone.History.extend({getFragment:function(){return Backbone.History.prototype.getFragment.apply(this,arguments).replace(/\?.*/,"")}}),o.Run={init:function(){this.view=new o.view.Installer({section:o.data.settings.browseDefault,SearchView:o.view.Search}),Backbone.history=new o.History,this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:o.data.settings.path,pushState:!0,hashChange:!1})},routes:function(){var i=this,s={};o.router=new o.Router,o.router.on("route:preview",function(e){i.view.collection.queries.push(o.data.query),s.theme=e,i.view.collection.query(s),i.view.view.expand(e)})
,o.router.on("route:sort",function(e,t){t&&o.router.navigate("browse/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),e=e||o.data.settings.browseDefault,i.view.sort(e),i.view.trigger("theme:close")}),o.router.on("route:search",function(e,t){t&&o.router.navigate("search/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),n(".wp-filter-search").focus().trigger("keyup"),i.view.trigger("theme:close")}),o.router.on("route:tag",function(e,t){t&&o.router.navigate("tags/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),_.each(e.split("+"),function(e){e=e.toLowerCase().replace(/[^a-z-]/g,""),n("#filter-id-"+e).prop("checked",!0)}),n("body").removeClass("show-filters").addClass("show-filters"),i.view.applyFilters(),i.view.t
rigger("theme:close")}),o.router.on("route:author",function(e,t){t&&o.router.navigate("author/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),s.author=e,i.view.collection.query(s),o.utils.title(e,"author"),i.view.trigger("theme:close")})}},n(function(){o.Run.init()})}(jQuery),google.charts.load("current",{packages:["corechart"]}),function(l){function c(e){document.querySelector(".spinner")?.classList.remove("spinner"),e=e.status+": "+e.statusText,alert(e)}document.addEventListener("submit",i=>{const a=i.target.closest("form");if(a&&["commercial","community"].includes(a.id)){i.preventDefault();const n=a.querySelector('button[type="submit"]'),o=a.querySelector(".success-msg");i=a.closest(".theme-about")?.dataset.slug;o?.classList.remove("saved");let e="&qu
ot;,s=(rest_name="commercial"===a.id?(e="external_support_url","supportURL"):(e="external_repository_url","repositoryURL"),a.querySelector('input[name="'+e+'"]')),r=a.querySelector(".button-small")?.classList.add("spinner"),t=l.restUrl+"themes/v1/theme/"+i+"/"+a.id+"/?_wpnonce="+l.restNonce;originalValue=s.dataset.originalValue??"",n.disabled=!0,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[rest_name]:s.value})}).then(e=>(e.ok||c(e),e)).then(e=>e.json()).then(e=>{let t;t=void 0!==e[rest_name]?(o?.classList.add("saved"),e[rest_name]):originalValue,s.value=t;const i=document.querySelector(".categorization-widget .widget-head a");i&&(i.attributes.href.value=t),n.disabled=!1,r?.classList.remove("spinner")}).catch(e=>{c(e),s.value=originalValue,n.di
sabled=!1})}})}((window.wp,_wpThemeSettings.rest));
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>