ThemeGrill Demo Importer - Version 1.6.1

Version Description

  • 12-11-2019 =
  • Tweak - Add admin notice for Upgrade To Pro.
Download this release

Release Info

Developer ThemeGrill
Plugin Icon 128x128 ThemeGrill Demo Importer
Version 1.6.1
Comparing to
See all releases

Code changes from version 1.6.0 to 1.6.1

assets/js/admin/demo-importer.min.js CHANGED
@@ -1 +1 @@
1
- window.wp=window.wp||{},function(d){var a,i;(a=wp.demos=wp.demos||{}).data=_demoImporterSettings,i=a.data.l10n,a.isNew=!!a.data.settings.isNew,_.extend(a,{model:{},view:{},routes:{},router:{},template:wp.template}),a.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}))}}),a.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:d(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView?e.SearchView:a.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new a.view.Demos({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:d(".search-form"),search:function(){var e;1!==a.data.demos.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(d.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+i.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e,t=this;this.window.scrollTop(),t.window.height(),e=t.$el.offset().top+t.$el.outerHeight(!1)-t.window.height(),e=Math.round(.9*e)}}),a.Collection=Backbone.Collection.extend({model:a.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(a.data.demos),d("body").removeClass("no-results")),this.trigger("demos:update"))},search:function(t){var i,e,o,s,r,n;this.reset(a.data.demos,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\amp;")).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,""),n=e.get("author").replace(/(<([^>]+)>)/gi,""),o=_.union([s,e.get("id"),r,n,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(o)})).length?this.trigger("query:empty"):d("body").removeClass("no-results"),this.reset(e)},paginate:function(e){return e=e||0,this},count:!1,query:function(t){var e,i,o,s=this.queries,r=this;if(this.currentQuery.request=t,e=_.find(s,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){r.add(e.demos),r.trigger("query:success"),r.loadingDemos=!1}).fail(function(){r.trigger("query:fail")});0===e.demos.length?r.trigger("query:empty"):d("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.demos),e.total||(this.count=this.length),this.trigger("demos:update"),this.trigger("query:success",this.count)}else e=this.apiCall(t).done(function(e){e.demos&&(r.reset(e.demos),o=e.info.results,s.push({demos:e.demos,request:t,total:o})),r.trigger("demos:update"),r.trigger("query:success",o),e.demos&&0===e.demos.length&&r.trigger("query:empty")}).fail(function(){r.trigger("query:fail")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-demos",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||d("body").addClass("loading-content").removeClass("no-results")}})},loadingDemos:!1}),a.view.Demo=wp.Backbone.View.extend({className:"theme",state:"grid",html:a.template("demo"),events:{click:"preview",keydown:"preview",touchend:"preview",keyup:"addFocus",touchmove:"preventExpand","click .demo-import":"importDemo"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name","data-slug":e.id}),this.activeDemo(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeDemo:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var e=d(":focus").hasClass("theme")?d(":focus"):d(":focus").parents(".theme");d(".theme.focus").removeClass("focus"),e.addClass("focus")},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,o=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;d(e.target).not(".install-demo-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&d(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,a.focusedDemo=this.$el,a.preview=i=new a.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),d("div.wrap").append(i.el),this.listenTo(i,"demo:next",function(){if(t=o.model,_.isUndefined(o.current)||(t=o.current),o.current=o.model.collection.at(o.model.collection.indexOf(t)+1),_.isUndefined(o.current))return o.options.parent.parent.trigger("demo:end"),o.current=t;i.model=o.current,i.render(),this.setNavButtonsState(),d(".next-theme").focus()}).listenTo(i,"demo:previous",function(){t=o.model,0!==o.model.collection.indexOf(o.current)&&(_.isUndefined(o.current)||(t=o.current),o.current=o.model.collection.at(o.model.collection.indexOf(t)-1),_.isUndefined(o.current)||(i.model=o.current,i.render(),this.setNavButtonsState(),d(".previous-theme").focus()))}),this.listenTo(i,"preview:close",function(){o.current=o.model}))},setNavButtonsState:function(){var e=d(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),o=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),o.focus()),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(o.addClass("disabled").prop("disabled",!0),i.focus())},importDemo:function(e){var t=this,i=d(e.target),o=d(e.target).data("plugins");e.preventDefault(),i.hasClass("disabled")||i.hasClass("updating-message")||d.confirm({title:"",content:'<div class="demo-import-confirm-message">'+wp.demos.data.settings.confirmImport+"</div>",boxWidth:"50%",useBootstrap:!1,buttons:{confirm:{text:wp.demos.data.l10n.confirmMsg,keys:["enter"],btnClass:"demo-import-confirm-button",action:function(){t.processImport(i,o,t)}},cancel:{btnClass:"demo-import-cancel-button",action:function(){}}}})},processImport:function(i,e,o){wp.updates.maybeRequestFilesystemCredentials(event),d(document).trigger("wp-plugin-bulk-install",e),d.each(e,function(e,t){t.is_active||wp.updates.queue.push({action:"install-plugin",data:{plugin:t.slug,name:t.name,slug:e,demo:i.data("slug")}})}),d(document).on("wp-demo-import-success",function(e,t){o.model.get("id")===t.slug&&(o.render(),o.model.set({imported:!0}))}),wp.updates.queue.push({action:"import-demo",data:{slug:i.data("slug")}}),wp.updates.queueChecker()}}),a.view.Preview=wp.Backbone.View.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousDemo","click .next-theme":"nextDemo",keyup:"keyEvent","click .demo-import":"importDemo"},html:a.template("demo-preview"),render:function(){var e,t=this,i=this.model.toJSON(),o=d(document.body);o.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(i)),(e=this.$el.data("current-preview-device"))&&t.tooglePreviewDeviceButtons(e),a.router.navigate(a.router.baseUrl(a.router.demoPath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){o.addClass("demo-importer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){t.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),d(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){d("body").removeClass("demo-importer-active full-overlay-active"),a.focusedDemo&&a.focusedDemo.focus()}).removeClass("iframe-ready"),a.router.selectedTab?a.router.navigate(a.router.baseUrl("&browse="+a.router.selectedTab)):a.router.navigate(a.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){var t=d(e.currentTarget);return"true"===t.attr("aria-expanded")?t.attr({"aria-expanded":"false","aria-label":i.expandSidebar}):t.attr({"aria-expanded":"true","aria-label":i.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){var t=d(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+t).data("current-preview-device",t),this.tooglePreviewDeviceButtons(t)},tooglePreviewDeviceButtons:function(e){var t=d(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextDemo()),37===e.keyCode&&this.previousDemo()},nextDemo:function(){return this.trigger("demo:next",this.model.cid),!1},previousDemo:function(){return this.trigger("demo:previous",this.model.cid),!1},importDemo:function(e){var t=this,i=d(e.target),o=d(".plugins-list-table").find("#the-list tr"),s=[];e.preventDefault(),i.hasClass("disabled")||i.hasClass("updating-message")||d.confirm({title:"",content:'<div class="demo-import-confirm-message">'+wp.demos.data.settings.confirmImport+"</div>",boxWidth:"50%",useBootstrap:!1,buttons:{confirm:{text:wp.demos.data.l10n.confirmMsg,keys:["enter"],btnClass:"demo-import-confirm-button",action:function(){t.processImport(i,o,0,0,s,t)}},cancel:{btnClass:"demo-import-cancel-button",action:function(){}}},onContentReady:function(){d("body").addClass("demo-import-message-popup")},onDestroy:function(){d("body").removeClass("demo-import-message-popup")}})},processImport:function(r,e,n,a,l,c){wp.updates.maybeRequestFilesystemCredentials(event),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled"),d(document).trigger("wp-plugin-bulk-install",e),e.each(function(e,t){var i=d(t);i.hasClass("inactive")&&!i.find("notice-error").length&&wp.updates.queue.push({action:"install-plugin",data:{plugin:i.data("plugin"),slug:i.data("slug"),demo:r.data("slug")}})}),d(document).on("wp-plugin-bulk-installing",function(){d(".wp-full-overlay-sidebar-content").animate({scrollTop:d(document).height()})}),d(document).on("wp-plugin-bulk-install-success wp-plugin-bulk-install-error",function(e,t){var i,o,s=d('[data-slug="'+t.slug+'"]');"wp-"+t.install+"-bulk-install-success"===e.type?n++:(o=t.pluginName?t.pluginName:s.find(".plugin-name").text(),a++,l.push(o+": "+t.errorMessage)),wp.updates.adminNotice=wp.template("wp-bulk-installs-admin-notice"),d(".plugins-details .bulk-action-notice").remove(),d(".plugins-details .plugins-info").after(wp.updates.adminNotice({id:"bulk-action-notice",className:"bulk-action-notice notice-alt",successes:n,errors:a,errorMessages:l,type:t.install})),i=d("#bulk-action-notice").on("click","button",function(){d(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!d(this).hasClass("bulk-action-errors-collapsed")),i.find(".bulk-action-errors").toggleClass("hidden")}),wp.updates.queue.length||(0<a?r.removeClass("updating-message").text(r.data("originaltext")):(c.model.set({requiredPlugins:!1}),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled")))}),d(document).on("wp-updates-notice-added",function(){wp.updates.adminNotice=wp.template("wp-updates-admin-notice")}),d(document).on("wp-demo-import-success",function(e,t){c.model.get("id")===t.slug&&c.model.set({imported:!0})}),wp.updates.queue.push({action:"import-demo",data:{slug:r.data("slug")}}),wp.updates.queueChecker()}}),a.view.Demos=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:d("div.theme-overlay"),index:0,count:d(".wrap .demo-count"),liveDemoCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.importedDemo(),this.listenTo(t.collection,"demos:update",function(){t.parent.page=0,t.importedDemo(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){d("body").addClass("no-results")}),this.listenTo(this.parent,"demo:scroll",function(){t.renderDemos(t.parent.page)})},render:function(){this.$el.empty(),0<this.options.collection.size()&&this.renderDemos(this.parent.page),this.liveDemoCount=this.collection.count?this.collection.count:this.collection.length,this.count.text(this.liveDemoCount)},renderDemos:function(e){var t=this;t.instance=t.collection.paginate(e),0!==t.instance.size()?(a.isNew&&1<=e&&d(".add-new-theme").remove(),t.instance.each(function(e){t.demo=new a.view.Demo({model:e,parent:t}),t.demo.render(),t.$el.append(t.demo.el)}),a.isNew&&a.data.settings.suggestURI&&this.$el.append('<div class="theme add-new-theme"><a href="'+a.data.settings.suggestURI+'" target="blank"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+i.suggestNew+"</h2></a></div>"),this.parent.page++):this.parent.trigger("demo:end")},importedDemo:function(){var e;(e=this.collection.findWhere({active:!0}))&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},announceSearchResults:function(e){0===e?wp.a11y.speak(i.noDemosFound):wp.a11y.speak(i.demosFound.replace("%d",e))}}),a.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:i.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"demo:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?a.router.navigate(a.router.baseUrl(a.router.searchPath+e.target.value),t):a.router.navigate(a.router.baseUrl(""))},pushState:function(e){var t=a.router.baseUrl("");e.target.value&&(t=a.router.baseUrl(a.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,a.router.navigate(t)}}),a.Router=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&demo=:slug":"preview","themes.php?page=demo-importer&browse=:sort":"sort","themes.php?page=demo-importer&search=:query":"search","themes.php?page=demo-importer":"sort"},baseUrl:function(e){return"themes.php?page=demo-importer"+e},demoPath:"&demo=",browsePath:"&browse=",searchPath:"&search=",search:function(e){d(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:function o(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}}),a.view.InstallerSearch=a.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",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=""),this.doSearch(e.target.value))},doSearch:function(e){this.terms!==e&&(this.terms=e,d(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),this.collection.doSearch(e.replace(/\+/g," ")),a.router.navigate(a.router.baseUrl(a.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),a.view.Installer=a.view.Appearance.extend({el:"#wpbody-content .wrap",events:{"click .filter-links li > a":"onSort"},render:function(){var e=this;this.search(),this.collection=new a.Collection,this.listenTo(this,"demo:end",function(){e.collection.loadingDemos||(e.collection.loadingDemos=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove()}),this.listenTo(this.collection,"query:fail",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove(),d(".theme-browser").find("div.themes").before('<div class="error"><p>'+i.error+'</p><p><button class="button try-again">'+i.tryAgain+"</button></p></div>"),d(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),d("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new a.view.Demos({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,t){this.collection.query({browse:e,builder:t})},onSort:function(e){var t=d(e.target),i=t.data("sort"),o=t.data("type");e.preventDefault(),i=i||a.router.selectedTab,o=o||a.router.selectedType,t.hasClass(this.activeClass)||(this.sort(i,o),a.router.navigate(a.router.baseUrl(a.router.browsePath+i)))},sort:function(e,t){this.clearSearch(),a.router.selectedTab=e,a.router.selectedType=t,d(".filter-links li > a").removeClass(this.activeClass).removeAttr("aria-current"),d('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),d('[data-type="'+t+'"]').addClass(this.activeClass).attr("aria-current","page"),this.browse(e,t)},activeClass:"current",clearSearch:function(){d("#wp-filter-search-input").val("")}}),a.RunInstaller={init:function(){this.view=new a.view.Installer({section:"all",SearchView:a.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:a.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var i=this,t={};a.router=new a.Router,a.router.on("route:preview",function(e){a.preview&&(a.preview.undelegateEvents(),a.preview.unbind()),i.view.view.demo&&i.view.view.demo.preview?(i.view.view.demo.model=i.view.collection.findWhere({slug:e}),i.view.view.demo.preview()):(t.demo=e,i.view.collection.query(t),i.view.collection.trigger("update"),i.view.collection.once("query:success",function(){d('div[data-slug="'+e+'"]').trigger("click")}))}),a.router.on("route:sort",function(e){var t=a.router.selectedType?a.router.selectedType:d(".filter-links.pagebuilders li").first().find("a").data("type");e&&d('[data-sort="'+e+'"]').length||(e="all",a.router.navigate(a.router.baseUrl("&browse=all"),{replace:!0})),i.view.sort(e,t),a.preview&&a.preview.close()}),a.router.on("route:search",function(){d(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},d(document).ready(function(){a.RunInstaller.init(),d(document.body).on("init_tooltips",function(){d("#tiptip_holder").removeAttr("style"),d("#tiptip_arrow").removeAttr("style"),d(".tips").tipTip({attribute:"data-tip",defaultPosition:"top",fadeIn:50,fadeOut:50,delay:50})}).trigger("init_tooltips"),d(".themegrill-reset-wordpress").on("click",function(){return window.confirm(_demoImporterSettings.settings.confirmReset)}),d(".themegrill-demo-importer-rating-link").on("click",function(){var e=d(this);d.post(a.data.settings.ajaxUrl,{action:"footer-text-rated"}),e.parent().text(e.data("rated"))})})}(jQuery);
1
+ window.wp=window.wp||{},function(d){var a,i;(a=wp.demos=wp.demos||{}).data=_demoImporterSettings,i=a.data.l10n,a.isNew=!!a.data.settings.isNew,_.extend(a,{model:{},view:{},routes:{},router:{},template:wp.template}),a.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}))}}),a.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:d(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView?e.SearchView:a.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new a.view.Demos({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:d(".search-form"),search:function(){var e;1!==a.data.demos.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(d.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+i.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e,t=this;this.window.scrollTop(),t.window.height(),e=t.$el.offset().top+t.$el.outerHeight(!1)-t.window.height(),e=Math.round(.9*e)}}),a.Collection=Backbone.Collection.extend({model:a.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(a.data.demos),d("body").removeClass("no-results")),this.trigger("demos:update"))},search:function(t){var i,e,o,s,r,n;this.reset(a.data.demos,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\amp;")).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,""),n=e.get("author").replace(/(<([^>]+)>)/gi,""),o=_.union([s,e.get("id"),r,n,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(o)})).length?this.trigger("query:empty"):d("body").removeClass("no-results"),this.reset(e)},paginate:function(e){return 0,this},count:!1,query:function(t){var e,i,o,s=this.queries,r=this;if(this.currentQuery.request=t,e=_.find(s,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){r.add(e.demos),r.trigger("query:success"),r.loadingDemos=!1}).fail(function(){r.trigger("query:fail")});0===e.demos.length?r.trigger("query:empty"):d("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.demos),e.total||(this.count=this.length),this.trigger("demos:update"),this.trigger("query:success",this.count)}else e=this.apiCall(t).done(function(e){e.demos&&(r.reset(e.demos),o=e.info.results,s.push({demos:e.demos,request:t,total:o})),r.trigger("demos:update"),r.trigger("query:success",o),e.demos&&0===e.demos.length&&r.trigger("query:empty")}).fail(function(){r.trigger("query:fail")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-demos",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||d("body").addClass("loading-content").removeClass("no-results")}})},loadingDemos:!1}),a.view.Demo=wp.Backbone.View.extend({className:"theme",state:"grid",html:a.template("demo"),events:{click:"preview",keydown:"preview",touchend:"preview",keyup:"addFocus",touchmove:"preventExpand","click .demo-import":"importDemo"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name","data-slug":e.id}),this.activeDemo(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeDemo:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var e=d(":focus").hasClass("theme")?d(":focus"):d(":focus").parents(".theme");d(".theme.focus").removeClass("focus"),e.addClass("focus")},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,o=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;d(e.target).not(".install-demo-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&d(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,a.focusedDemo=this.$el,a.preview=i=new a.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),d("div.wrap").append(i.el),this.listenTo(i,"demo:next",function(){if(t=o.model,_.isUndefined(o.current)||(t=o.current),o.current=o.model.collection.at(o.model.collection.indexOf(t)+1),_.isUndefined(o.current))return o.options.parent.parent.trigger("demo:end"),o.current=t;i.model=o.current,i.render(),this.setNavButtonsState(),d(".next-theme").focus()}).listenTo(i,"demo:previous",function(){t=o.model,0!==o.model.collection.indexOf(o.current)&&(_.isUndefined(o.current)||(t=o.current),o.current=o.model.collection.at(o.model.collection.indexOf(t)-1),_.isUndefined(o.current)||(i.model=o.current,i.render(),this.setNavButtonsState(),d(".previous-theme").focus()))}),this.listenTo(i,"preview:close",function(){o.current=o.model}))},setNavButtonsState:function(){var e=d(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),o=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),o.focus()),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(o.addClass("disabled").prop("disabled",!0),i.focus())},importDemo:function(e){var t=this,i=d(e.target),o=d(e.target).data("plugins");e.preventDefault(),i.hasClass("disabled")||i.hasClass("updating-message")||d.confirm({title:"",content:'<div class="demo-import-confirm-message">'+wp.demos.data.settings.confirmImport+"</div>",boxWidth:"50%",useBootstrap:!1,buttons:{confirm:{text:wp.demos.data.l10n.confirmMsg,keys:["enter"],btnClass:"demo-import-confirm-button",action:function(){t.processImport(i,o,t)}},cancel:{btnClass:"demo-import-cancel-button",action:function(){}}}})},processImport:function(i,e,o){wp.updates.maybeRequestFilesystemCredentials(event),d(document).trigger("wp-plugin-bulk-install",e),d.each(e,function(e,t){t.is_active||wp.updates.queue.push({action:"install-plugin",data:{plugin:t.slug,name:t.name,slug:e,demo:i.data("slug")}})}),d(document).on("wp-demo-import-success",function(e,t){o.model.get("id")===t.slug&&(o.render(),o.model.set({imported:!0}))}),wp.updates.queue.push({action:"import-demo",data:{slug:i.data("slug")}}),wp.updates.queueChecker()}}),a.view.Preview=wp.Backbone.View.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousDemo","click .next-theme":"nextDemo",keyup:"keyEvent","click .demo-import":"importDemo"},html:a.template("demo-preview"),render:function(){var e,t=this,i=this.model.toJSON(),o=d(document.body);o.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(i)),(e=this.$el.data("current-preview-device"))&&t.tooglePreviewDeviceButtons(e),a.router.navigate(a.router.baseUrl(a.router.demoPath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){o.addClass("demo-importer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){t.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),d(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){d("body").removeClass("demo-importer-active full-overlay-active"),a.focusedDemo&&a.focusedDemo.focus()}).removeClass("iframe-ready"),a.router.selectedTab?a.router.navigate(a.router.baseUrl("&browse="+a.router.selectedTab)):a.router.navigate(a.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){var t=d(e.currentTarget);return"true"===t.attr("aria-expanded")?t.attr({"aria-expanded":"false","aria-label":i.expandSidebar}):t.attr({"aria-expanded":"true","aria-label":i.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){var t=d(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+t).data("current-preview-device",t),this.tooglePreviewDeviceButtons(t)},tooglePreviewDeviceButtons:function(e){var t=d(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextDemo()),37===e.keyCode&&this.previousDemo()},nextDemo:function(){return this.trigger("demo:next",this.model.cid),!1},previousDemo:function(){return this.trigger("demo:previous",this.model.cid),!1},importDemo:function(e){var t=this,i=d(e.target),o=d(".plugins-list-table").find("#the-list tr"),s=[];e.preventDefault(),i.hasClass("disabled")||i.hasClass("updating-message")||d.confirm({title:"",content:'<div class="demo-import-confirm-message">'+wp.demos.data.settings.confirmImport+"</div>",boxWidth:"50%",useBootstrap:!1,buttons:{confirm:{text:wp.demos.data.l10n.confirmMsg,keys:["enter"],btnClass:"demo-import-confirm-button",action:function(){t.processImport(i,o,0,0,s,t)}},cancel:{btnClass:"demo-import-cancel-button",action:function(){}}},onContentReady:function(){d("body").addClass("demo-import-message-popup")},onDestroy:function(){d("body").removeClass("demo-import-message-popup")}})},processImport:function(r,e,n,a,l,c){wp.updates.maybeRequestFilesystemCredentials(event),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled"),d(document).trigger("wp-plugin-bulk-install",e),e.each(function(e,t){var i=d(t);i.hasClass("inactive")&&!i.find("notice-error").length&&wp.updates.queue.push({action:"install-plugin",data:{plugin:i.data("plugin"),slug:i.data("slug"),demo:r.data("slug")}})}),d(document).on("wp-plugin-bulk-installing",function(){d(".wp-full-overlay-sidebar-content").animate({scrollTop:d(document).height()})}),d(document).on("wp-plugin-bulk-install-success wp-plugin-bulk-install-error",function(e,t){var i,o,s=d('[data-slug="'+t.slug+'"]');"wp-"+t.install+"-bulk-install-success"===e.type?n++:(o=t.pluginName?t.pluginName:s.find(".plugin-name").text(),a++,l.push(o+": "+t.errorMessage)),wp.updates.adminNotice=wp.template("wp-bulk-installs-admin-notice"),d(".plugins-details .bulk-action-notice").remove(),d(".plugins-details .plugins-info").after(wp.updates.adminNotice({id:"bulk-action-notice",className:"bulk-action-notice notice-alt",successes:n,errors:a,errorMessages:l,type:t.install})),i=d("#bulk-action-notice").on("click","button",function(){d(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!d(this).hasClass("bulk-action-errors-collapsed")),i.find(".bulk-action-errors").toggleClass("hidden")}),wp.updates.queue.length||(0<a?r.removeClass("updating-message").text(r.data("originaltext")):(c.model.set({requiredPlugins:!1}),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled")))}),d(document).on("wp-updates-notice-added",function(){wp.updates.adminNotice=wp.template("wp-updates-admin-notice")}),d(document).on("wp-demo-import-success",function(e,t){c.model.get("id")===t.slug&&c.model.set({imported:!0})}),wp.updates.queue.push({action:"import-demo",data:{slug:r.data("slug")}}),wp.updates.queueChecker()}}),a.view.Demos=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:d("div.theme-overlay"),index:0,count:d(".wrap .demo-count"),liveDemoCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.importedDemo(),this.listenTo(t.collection,"demos:update",function(){t.parent.page=0,t.importedDemo(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){d("body").addClass("no-results")}),this.listenTo(this.parent,"demo:scroll",function(){t.renderDemos(t.parent.page)})},render:function(){this.$el.empty(),0<this.options.collection.size()&&this.renderDemos(this.parent.page),this.liveDemoCount=this.collection.count?this.collection.count:this.collection.length,this.count.text(this.liveDemoCount)},renderDemos:function(e){var t=this;t.instance=t.collection.paginate(e),0!==t.instance.size()?(a.isNew&&1<=e&&d(".add-new-theme").remove(),t.instance.each(function(e){t.demo=new a.view.Demo({model:e,parent:t}),t.demo.render(),t.$el.append(t.demo.el)}),a.isNew&&a.data.settings.suggestURI&&this.$el.append('<div class="theme add-new-theme"><a href="'+a.data.settings.suggestURI+'" target="blank"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+i.suggestNew+"</h2></a></div>"),this.parent.page++):this.parent.trigger("demo:end")},importedDemo:function(){var e;(e=this.collection.findWhere({active:!0}))&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},announceSearchResults:function(e){0===e?wp.a11y.speak(i.noDemosFound):wp.a11y.speak(i.demosFound.replace("%d",e))}}),a.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:i.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"demo:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?a.router.navigate(a.router.baseUrl(a.router.searchPath+e.target.value),t):a.router.navigate(a.router.baseUrl(""))},pushState:function(e){var t=a.router.baseUrl("");e.target.value&&(t=a.router.baseUrl(a.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,a.router.navigate(t)}}),a.Router=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&demo=:slug":"preview","themes.php?page=demo-importer&browse=:sort":"sort","themes.php?page=demo-importer&search=:query":"search","themes.php?page=demo-importer":"sort"},baseUrl:function(e){return"themes.php?page=demo-importer"+e},demoPath:"&demo=",browsePath:"&browse=",searchPath:"&search=",search:function(e){d(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:function o(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}}),a.view.InstallerSearch=a.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",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=""),this.doSearch(e.target.value))},doSearch:function(e){this.terms!==e&&(this.terms=e,d(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),this.collection.doSearch(e.replace(/\+/g," ")),a.router.navigate(a.router.baseUrl(a.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),a.view.Installer=a.view.Appearance.extend({el:"#wpbody-content .wrap",events:{"click .filter-links li > a":"onSort"},render:function(){var e=this;this.search(),this.collection=new a.Collection,this.listenTo(this,"demo:end",function(){e.collection.loadingDemos||(e.collection.loadingDemos=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove()}),this.listenTo(this.collection,"query:fail",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove(),d(".theme-browser").find("div.themes").before('<div class="error"><p>'+i.error+'</p><p><button class="button try-again">'+i.tryAgain+"</button></p></div>"),d(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),d("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new a.view.Demos({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,t){this.collection.query({browse:e,builder:t})},onSort:function(e){var t=d(e.target),i=t.data("sort"),o=t.data("type");e.preventDefault(),i=i||a.router.selectedTab,o=o||a.router.selectedType,t.hasClass(this.activeClass)||(this.sort(i,o),a.router.navigate(a.router.baseUrl(a.router.browsePath+i)))},sort:function(e,t){this.clearSearch(),a.router.selectedTab=e,a.router.selectedType=t,d(".filter-links li > a").removeClass(this.activeClass).removeAttr("aria-current"),d('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),d('[data-type="'+t+'"]').addClass(this.activeClass).attr("aria-current","page"),this.browse(e,t)},activeClass:"current",clearSearch:function(){d("#wp-filter-search-input").val("")}}),a.RunInstaller={init:function(){this.view=new a.view.Installer({section:"all",SearchView:a.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:a.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var i=this,t={};a.router=new a.Router,a.router.on("route:preview",function(e){a.preview&&(a.preview.undelegateEvents(),a.preview.unbind()),i.view.view.demo&&i.view.view.demo.preview?(i.view.view.demo.model=i.view.collection.findWhere({slug:e}),i.view.view.demo.preview()):(t.demo=e,i.view.collection.query(t),i.view.collection.trigger("update"),i.view.collection.once("query:success",function(){d('div[data-slug="'+e+'"]').trigger("click")}))}),a.router.on("route:sort",function(e){var t=a.router.selectedType?a.router.selectedType:d(".filter-links.pagebuilders li").first().find("a").data("type");e&&d('[data-sort="'+e+'"]').length||(e="all",a.router.navigate(a.router.baseUrl("&browse=all"),{replace:!0})),i.view.sort(e,t),a.preview&&a.preview.close()}),a.router.on("route:search",function(){d(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},d(document).ready(function(){a.RunInstaller.init(),d(document.body).on("init_tooltips",function(){d("#tiptip_holder").removeAttr("style"),d("#tiptip_arrow").removeAttr("style"),d(".tips").tipTip({attribute:"data-tip",defaultPosition:"top",fadeIn:50,fadeOut:50,delay:50})}).trigger("init_tooltips"),d(".themegrill-reset-wordpress").on("click",function(){return window.confirm(_demoImporterSettings.settings.confirmReset)}),d(".themegrill-demo-importer-rating-link").on("click",function(){var e=d(this);d.post(a.data.settings.ajaxUrl,{action:"footer-text-rated"}),e.parent().text(e.data("rated"))})})}(jQuery);
includes/admin/assets/css/notice.css ADDED
@@ -0,0 +1,34 @@
1
+ .pro-theme-notice {
2
+ position: relative;
3
+ }
4
+
5
+ .pro-theme-notice p {
6
+ font-size: 16px;
7
+ }
8
+
9
+ .pro-theme-notice code {
10
+ display: inline-block;
11
+ }
12
+
13
+ .pro-theme-notice .links {
14
+ margin: 12px 0;
15
+ }
16
+
17
+ .pro-theme-notice .links a {
18
+ height: auto;
19
+ padding: 3px 15px;
20
+ margin-left: 12px;
21
+ text-transform: uppercase;
22
+ }
23
+
24
+ .pro-theme-notice .links a .dashicons {
25
+ line-height: 1.2;
26
+ }
27
+
28
+ .pro-theme-notice .links a.button-primary {
29
+ margin-left: 0;
30
+ }
31
+
32
+ .pro-theme-notice .notice-dismiss {
33
+ text-decoration: none;
34
+ }
includes/admin/class-pro-theme-notice.php ADDED
@@ -0,0 +1,228 @@
1
+ <?php
2
+ /**
3
+ * Class to display the `Upgrade To Pro` admin notice.
4
+ *
5
+ * @package ThemeGrill_Demo_Importer
6
+ * @since 1.6.1
7
+ */
8
+
9
+ defined( 'ABSPATH' ) || exit;
10
+
11
+ /**
12
+ * Class to display the `Upgrade to Pro` admin notice.
13
+ *
14
+ * Class TG_Pro_Theme_Notice
15
+ */
16
+ class TG_Pro_Theme_Notice {
17
+
18
+ /**
19
+ * Currently active theme in the site.
20
+ *
21
+ * @var \WP_Theme
22
+ */
23
+ protected $active_theme;
24
+
25
+ /**
26
+ * Current user id.
27
+ *
28
+ * @var int Current user id.
29
+ */
30
+ protected $current_user_data;
31
+
32
+ /**
33
+ * Constructor function for `Upgrade To Pro` admin notice.
34
+ *
35
+ * TG_Pro_Theme_Notice constructor.
36
+ */
37
+ public function __construct() {
38
+
39
+ add_action( 'after_setup_theme', array( $this, 'pro_theme_notice' ) );
40
+ add_action( 'switch_theme', array( $this, 'delete_pro_notice_datas' ) );
41
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
42
+
43
+ }
44
+
45
+ /**
46
+ * Function to hold the available themes, which have pro version available.
47
+ *
48
+ * @return array Theme lists.
49
+ */
50
+ public static function get_theme_lists() {
51
+
52
+ $theme_lists = array(
53
+ 'spacious' => 'https://themegrill.com/pricing/?pid=958&vid=1221792&utm_source=spacious-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
54
+ 'colormag' => 'https://themegrill.com/pricing/?pid=1183000&vid=1219398&utm_source=colormag-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
55
+ 'estore' => 'https://themegrill.com/pricing/?pid=1242738&vid=1242847&utm_source=estore-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
56
+ 'ample' => 'https://themegrill.com/pricing/?pid=774550&vid=1219401&utm_source=ample-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
57
+ 'accelerate' => 'https://themegrill.com/pricing/?pid=7394&vid=1221785&utm_source=accelerate-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
58
+ 'colornews' => 'https://themegrill.com/pricing/?pid=1198835&vid=1219395&utm_source=colornews-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
59
+ 'foodhunt' => 'https://themegrill.com/pricing/?pid=1246665&vid=1246668&utm_source=foodhunt-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
60
+ 'fitclub' => 'https://themegrill.com/pricing/?pid=1242755&vid=1242761&utm_source=fitclub-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
61
+ 'radiate' => 'https://themegrill.com/pricing/?pid=179&vid=1221773&utm_source=radiate-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
62
+ 'freedom' => 'https://themegrill.com/pricing/?pid=12287&vid=1221795&utm_source=freedom-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
63
+ 'himalayas' => 'https://themegrill.com/pricing/?pid=1199493&vid=1219392&utm_source=himalayas-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
64
+ 'esteem' => 'https://themegrill.com/pricing/?pid=14083&vid=1221789&utm_source=esteem-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
65
+ 'envince' => 'https://themegrill.com/pricing/?pid=1256403&vid=1256406&utm_source=envince-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
66
+ 'suffice' => 'https://themegrill.com/pricing/?pid=1307844&vid=1307847&utm_source=suffice-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
67
+ 'cenote' => 'https://themegrill.com/pricing/?pid=1383257&vid=1383267&utm_source=cenote-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
68
+ 'zakra' => 'https://zakratheme.com/pricing/?utm_source=zakra-dashboard-message&utm_medium=view-pricing-link&utm_campaign=upgrade',
69
+ );
70
+
71
+ return $theme_lists;
72
+
73
+ }
74
+
75
+ /**
76
+ * Set upgrade time and display the admin notice as required.
77
+ */
78
+ public function pro_theme_notice() {
79
+
80
+ global $current_user;
81
+ $this->current_user_data = $current_user;
82
+ $this->active_theme = wp_get_theme();
83
+
84
+ // In case user is using child theme, we need to show `Upgrade To Pro` notice too.
85
+ if ( is_child_theme() ) {
86
+ $this->active_theme = wp_get_theme()->parent()->get( 'Name' );
87
+ }
88
+
89
+ $option = get_option( 'tg_pro_theme_notice_start_time' );
90
+
91
+ if ( ! $option ) {
92
+ update_option( 'tg_pro_theme_notice_start_time', time() );
93
+ }
94
+
95
+ add_action( 'admin_notices', array( $this, 'pro_theme_notice_markup' ), 0 );
96
+ add_action( 'admin_init', array( $this, 'pro_theme_notice_partial_ignore' ), 0 );
97
+ add_action( 'admin_init', array( $this, 'pro_theme_notice_ignore' ), 0 );
98
+
99
+ }
100
+
101
+ /**
102
+ * Enqueue the required scripts.
103
+ */
104
+ public function enqueue_scripts() {
105
+
106
+ $assets_path = tgdm()->plugin_url() . '/includes/admin/assets/';
107
+
108
+ wp_register_style( 'tg-demo-importer-notice', $assets_path . 'css/notice.css', array(), TGDM_VERSION );
109
+ wp_enqueue_style( 'tg-demo-importer-notice' );
110
+ }
111
+
112
+ /**
113
+ * Display the `Upgrade To Pro` admin notice.
114
+ */
115
+ public function pro_theme_notice_markup() {
116
+
117
+ $theme_lists = self::get_theme_lists();
118
+ $current_theme = strtolower( $this->active_theme );
119
+ $theme_notice_start_time = get_option( 'tg_pro_theme_notice_start_time' );
120
+ $pre_sales_query_link = ( 'zakra' !== $current_theme ) ? "https://themegrill.com/contact/?utm_source={$current_theme}-dashboard-message&utm_medium=button-link&utm_campaign=pre-sales" : "https://zakratheme.com/support/?utm_source={$current_theme}-dashboard-message&utm_medium=button-link&utm_campaign=pre-sales";
121
+ $ignore_notice_permanent = get_user_meta( $this->current_user_data->ID, 'tg_nag_pro_theme_notice_ignore', true );
122
+ $ignore_notice_partially = get_user_meta( $this->current_user_data->ID, 'tg_nag_pro_theme_notice_partial_ignore', true );
123
+
124
+ // Return if the theme is not available in theme lists.
125
+ if ( ! array_key_exists( $current_theme, $theme_lists ) ) {
126
+ return;
127
+ }
128
+
129
+ // Return if `Zakra Pro` plugin is installed.
130
+ if ( is_plugin_active( 'zakra-pro/zakra-pro.php' ) && 'zakra' === $current_theme ) {
131
+ return;
132
+ }
133
+
134
+ /**
135
+ * Return from notice display if:
136
+ *
137
+ * 1. The theme installed is less than 10 days ago.
138
+ * 2. If the user has ignored the message partially for 2 days.
139
+ * 3. Dismiss always if clicked on 'Dismiss' button.
140
+ */
141
+ if ( ( $theme_notice_start_time > strtotime( '-10 day' ) ) || ( $ignore_notice_partially > strtotime( '-2 day' ) ) || ( $ignore_notice_permanent ) ) {
142
+ return;
143
+ }
144
+ ?>
145
+
146
+ <div class="notice updated pro-theme-notice">
147
+ <p>
148
+ <?php
149
+ $pro_link = '<a target="_blank" href=" ' . esc_url( $theme_lists[ $current_theme ] ) . ' ">' . esc_html__( 'upgrade to pro', 'themegrill-demo-importer' ) . '</a>';
150
+
151
+ printf(
152
+ esc_html__(
153
+ /* Translators: %1$s current user display name., %2$s Currently activated theme., %3$s Pro theme link., %4$s Coupon code. */
154
+ 'Howdy, %1$s! You\'ve been using %2$s theme for a while now, and we hope you\'re happy with it. If you need more options and access to the premium features, you can %3$s. Also, you can use the coupon code %4$s to get 15 percent discount while making the purchase. Enjoy!', 'themegrill-demo-importer'
155
+ ),
156
+ '<strong>' . esc_html( $this->current_user_data->display_name ) . '</strong>',
157
+ $this->active_theme,
158
+ $pro_link,
159
+ '<code>upgrade15</code>'
160
+ );
161
+ ?>
162
+ </p>
163
+
164
+ <div class="links">
165
+ <a href="<?php echo esc_url( $theme_lists[ $current_theme ] ); ?>" class="btn button-primary"
166
+ target="_blank">
167
+ <span class="dashicons dashicons-thumbs-up"></span>
168
+ <span><?php esc_html_e( 'Upgrade To Pro', 'themegrill-demo-importer' ); ?></span>
169
+ </a>
170
+
171
+ <a href="?tg_nag_pro_theme_notice_partial_ignore=1" class="btn button-secondary">
172
+ <span class="dashicons dashicons-calendar"></span>
173
+ <span><?php esc_html_e( 'Maybe later', 'themegrill-demo-importer' ); ?></span>
174
+ </a>
175
+
176
+ <a href="<?php echo esc_url( $pre_sales_query_link ); ?>"
177
+ class="btn button-secondary" target="_blank">
178
+ <span class="dashicons dashicons-edit"></span>
179
+ <span><?php esc_html_e( 'Got pre sales queries?', 'themegrill-demo-importer' ); ?></span>
180
+ </a>
181
+ </div>
182
+
183
+ <a class="notice-dismiss" href="?tg_nag_pro_theme_notice_ignore=1"></a>
184
+ </div>
185
+
186
+ <?php
187
+ }
188
+
189
+ /**
190
+ * Set the nag for partially ignored users.
191
+ */
192
+ public function pro_theme_notice_partial_ignore() {
193
+
194
+ $user_id = $this->current_user_data->ID;
195
+
196
+ if ( isset( $_GET['tg_nag_pro_theme_notice_partial_ignore'] ) && '1' == $_GET['tg_nag_pro_theme_notice_partial_ignore'] ) {
197
+ update_user_meta( $user_id, 'tg_nag_pro_theme_notice_partial_ignore', time() );
198
+ }
199
+
200
+ }
201
+
202
+ /**
203
+ * Set the nag for permanently ignored users.
204
+ */
205
+ public function pro_theme_notice_ignore() {
206
+
207
+ $user_id = $this->current_user_data->ID;
208
+
209
+ if ( isset( $_GET['tg_nag_pro_theme_notice_ignore'] ) && '1' == $_GET['tg_nag_pro_theme_notice_ignore'] ) {
210
+ update_user_meta( $user_id, 'tg_nag_pro_theme_notice_ignore', time() );
211
+ }
212
+
213
+ }
214
+
215
+ /**
216
+ * Delete the pro notice datas if theme is switched.
217
+ */
218
+ public function delete_pro_notice_datas() {
219
+
220
+ include_once TGDM_ABSPATH . 'includes/class-demo-importer-deactivator.php';
221
+
222
+ TG_Demo_Importer_Deactivator::pro_upgrade_notice();
223
+
224
+ }
225
+
226
+ }
227
+
228
+ new TG_Pro_Theme_Notice();
includes/class-demo-importer-deactivator.php ADDED
@@ -0,0 +1,58 @@
1
+ <?php
2
+ /**
3
+ * Class to include the plugin deactivation functionality.
4
+ *
5
+ * Class TG_Demo_Importer_Deactivator
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || exit;
9
+
10
+ /**
11
+ * Class to include the plugin deactivation functionality.
12
+ *
13
+ * Class TG_Demo_Importer_Deactivator
14
+ */
15
+ class TG_Demo_Importer_Deactivator {
16
+
17
+ /**
18
+ * Deactivation main hook.
19
+ */
20
+ public static function deactivate() {
21
+
22
+ // Delete the `Upgrade To Pro` data sets.
23
+ self::pro_upgrade_notice();
24
+
25
+ }
26
+
27
+ /**
28
+ * Delete the options set for `Upgrade To Pro` admin notice.
29
+ */
30
+ public static function pro_upgrade_notice() {
31
+
32
+ $get_all_users = get_users();
33
+ $theme_notice_start_time = get_option( 'tg_pro_theme_notice_start_time' );
34
+
35
+ // Delete the time set on `wp_options`.
36
+ if ( $theme_notice_start_time ) {
37
+ delete_option( 'tg_pro_theme_notice_start_time' );
38
+ }
39
+
40
+ // Delete user meta data for theme review notice.
41
+ foreach ( $get_all_users as $user ) {
42
+ $ignored_notice_permanent = get_user_meta( $user->ID, 'tg_nag_pro_theme_notice_ignore', true );
43
+ $ignored_notice_partially = get_user_meta( $user->ID, 'tg_nag_pro_theme_notice_partial_ignore', true );
44
+
45
+ // Delete permanent notice remove data.
46
+ if ( $ignored_notice_permanent ) {
47
+ delete_user_meta( $user->ID, 'tg_nag_pro_theme_notice_ignore' );
48
+ }
49
+
50
+ // Delete partial notice remove data.
51
+ if ( $ignored_notice_partially ) {
52
+ delete_user_meta( $user->ID, 'tg_nag_pro_theme_notice_partial_ignore' );
53
+ }
54
+ }
55
+
56
+ }
57
+
58
+ }
includes/class-themegrill-demo-importer.php CHANGED
@@ -20,7 +20,7 @@ final class ThemeGrill_Demo_Importer {
20
*
21
* @var string
22
*/
23
- public $version = '1.6.0';
24
25
/**
26
* Theme single instance of this class.
@@ -103,6 +103,9 @@ final class ThemeGrill_Demo_Importer {
103
// Register activation hook.
104
register_activation_hook( TGDM_PLUGIN_FILE, array( $this, 'install' ) );
105
106
// Check with Official ThemeGrill theme is installed.
107
if ( in_array( get_option( 'template' ), $this->get_core_supported_themes(), true ) ) {
108
$this->includes();
@@ -121,7 +124,6 @@ final class ThemeGrill_Demo_Importer {
121
*/
122
private function get_core_supported_themes() {
123
$core_themes = array( 'spacious', 'colormag', 'flash', 'estore', 'ample', 'accelerate', 'colornews', 'foodhunt', 'fitclub', 'radiate', 'freedom', 'himalayas', 'esteem', 'envince', 'suffice', 'explore', 'masonic', 'cenote', 'zakra' );
124
-
125
// Check for official core themes pro version.
126
$pro_themes = array_diff( $core_themes, array( 'explore', 'masonic' ) );
127
if ( ! empty( $pro_themes ) ) {
@@ -137,6 +139,7 @@ final class ThemeGrill_Demo_Importer {
137
private function includes() {
138
include_once TGDM_ABSPATH . 'includes/class-demo-importer.php';
139
include_once TGDM_ABSPATH . 'includes/functions-demo-importer.php';
140
141
// Backward compatibility for demo packages config.
142
if ( file_exists( TGDM_DEMO_DIR . 'tg-demo-config.php' ) ) {
@@ -176,6 +179,17 @@ final class ThemeGrill_Demo_Importer {
176
set_transient( '_tg_demo_importer_activation_redirect', 1, 30 );
177
}
178
179
/**
180
* Load Localisation files.
181
*
20
*
21
* @var string
22
*/
23
+ public $version = '1.6.1';
24
25
/**
26
* Theme single instance of this class.
103
// Register activation hook.
104
register_activation_hook( TGDM_PLUGIN_FILE, array( $this, 'install' ) );
105
106
+ // Register deactivation hook.
107
+ register_deactivation_hook( TGDM_PLUGIN_FILE, array( $this, 'deactivate' ) );
108
+
109
// Check with Official ThemeGrill theme is installed.
110
if ( in_array( get_option( 'template' ), $this->get_core_supported_themes(), true ) ) {
111
$this->includes();
124
*/
125
private function get_core_supported_themes() {
126
$core_themes = array( 'spacious', 'colormag', 'flash', 'estore', 'ample', 'accelerate', 'colornews', 'foodhunt', 'fitclub', 'radiate', 'freedom', 'himalayas', 'esteem', 'envince', 'suffice', 'explore', 'masonic', 'cenote', 'zakra' );
127
// Check for official core themes pro version.
128
$pro_themes = array_diff( $core_themes, array( 'explore', 'masonic' ) );
129
if ( ! empty( $pro_themes ) ) {
139
private function includes() {
140
include_once TGDM_ABSPATH . 'includes/class-demo-importer.php';
141
include_once TGDM_ABSPATH . 'includes/functions-demo-importer.php';
142
+ include_once TGDM_ABSPATH . 'includes/admin/class-pro-theme-notice.php';
143
144
// Backward compatibility for demo packages config.
145
if ( file_exists( TGDM_DEMO_DIR . 'tg-demo-config.php' ) ) {
179
set_transient( '_tg_demo_importer_activation_redirect', 1, 30 );
180
}
181
182
+ /**
183
+ * Deactivation hook.
184
+ */
185
+ function deactivate() {
186
+
187
+ include_once dirname( __FILE__ ) . '/class-demo-importer-deactivator.php';
188
+
189
+ TG_Demo_Importer_Deactivator::deactivate();
190
+
191
+ }
192
+
193
/**
194
* Load Localisation files.
195
*
languages/themegrill-demo-importer.pot CHANGED
@@ -2,10 +2,10 @@
2
# This file is distributed under the GPLv3 or later.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: ThemeGrill Demo Importer 1.6.0\n"
6
"Report-Msgid-Bugs-To: "
7
"https://github.com/themegrill/themegrill-demo-importer/issues\n"
8
- "POT-Creation-Date: 2019-09-10 04:33:13+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
@@ -55,9 +55,27 @@ msgstr ""
55
msgid "No valid demos were found."
56
msgstr ""
57
58
#: includes/admin/views/html-admin-page-importer.php:12
59
#: includes/class-demo-importer.php:121
60
- #: includes/class-themegrill-demo-importer.php:223
61
msgid "Demo Importer"
62
msgstr ""
63
@@ -459,31 +477,31 @@ msgstr ""
459
msgid "The WIE file widget content is missing."
460
msgstr ""
461
462
- #: includes/class-themegrill-demo-importer.php:223
463
msgid "View Demo Importer"
464
msgstr ""
465
466
- #: includes/class-themegrill-demo-importer.php:239
467
msgid "View Demo Importer Documentation"
468
msgstr ""
469
470
- #: includes/class-themegrill-demo-importer.php:239
471
msgid "Docs"
472
msgstr ""
473
474
- #: includes/class-themegrill-demo-importer.php:240
475
msgid "Visit Free Customer Support Forum"
476
msgstr ""
477
478
- #: includes/class-themegrill-demo-importer.php:240
479
msgid "Free Support"
480
msgstr ""
481
482
- #: includes/class-themegrill-demo-importer.php:256
483
msgid "This plugin requires %s to be activated to work."
484
msgstr ""
485
486
- #: includes/class-themegrill-demo-importer.php:256
487
msgid "Official ThemeGrill Theme"
488
msgstr ""
489
2
# This file is distributed under the GPLv3 or later.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: ThemeGrill Demo Importer 1.6.1\n"
6
"Report-Msgid-Bugs-To: "
7
"https://github.com/themegrill/themegrill-demo-importer/issues\n"
8
+ "POT-Creation-Date: 2019-10-18 07:08:31+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
55
msgid "No valid demos were found."
56
msgstr ""
57
58
+ #: includes/admin/class-pro-theme-notice.php:149
59
+ msgid "upgrade to pro"
60
+ msgstr ""
61
+
62
+ #: includes/admin/class-pro-theme-notice.php:168
63
+ #. Translators: %1$s current user display name., %2$s Currently activated
64
+ #. theme., %3$s Pro theme link., %4$s Coupon code.
65
+ msgid "Upgrade To Pro"
66
+ msgstr ""
67
+
68
+ #: includes/admin/class-pro-theme-notice.php:173
69
+ msgid "Maybe later"
70
+ msgstr ""
71
+
72
+ #: includes/admin/class-pro-theme-notice.php:179
73
+ msgid "Got pre sales queries?"
74
+ msgstr ""
75
+
76
#: includes/admin/views/html-admin-page-importer.php:12
77
#: includes/class-demo-importer.php:121
78
+ #: includes/class-themegrill-demo-importer.php:237
79
msgid "Demo Importer"
80
msgstr ""
81
477
msgid "The WIE file widget content is missing."
478
msgstr ""
479
480
+ #: includes/class-themegrill-demo-importer.php:237
481
msgid "View Demo Importer"
482
msgstr ""
483
484
+ #: includes/class-themegrill-demo-importer.php:253
485
msgid "View Demo Importer Documentation"
486
msgstr ""
487
488
+ #: includes/class-themegrill-demo-importer.php:253
489
msgid "Docs"
490
msgstr ""
491
492
+ #: includes/class-themegrill-demo-importer.php:254
493
msgid "Visit Free Customer Support Forum"
494
msgstr ""
495
496
+ #: includes/class-themegrill-demo-importer.php:254
497
msgid "Free Support"
498
msgstr ""
499
500
+ #: includes/class-themegrill-demo-importer.php:270
501
msgid "This plugin requires %s to be activated to work."
502
msgstr ""
503
504
+ #: includes/class-themegrill-demo-importer.php:270
505
msgid "Official ThemeGrill Theme"
506
msgstr ""
507
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
Contributors: ThemeGrill, shivapoudel
3
Tags: themegrill, theme demos, demo, importer, one click import
4
Requires at least: 4.7
5
- Tested up to: 5.2.3
6
- Stable tag: 1.6.0
7
License: GPLv3 or later
8
License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
@@ -72,51 +72,10 @@ Yes you can! Join in on our [GitHub repository](https://github.com/themegrill/th
72
3. Finally, Import the Demo with just one click.
73
74
== Changelog ==
75
= 1.6.0 - 10-09-2019 =
76
* Tweak - Support for Zakra Premium version demo import.
77
78
- = 1.5.9 - 22-07-2019 =
79
- * Tweak - Display all available theme demos on main demo import page.
80
-
81
- = 1.5.8 - 20-06-2019 =
82
- * Tweak - Update demo import message.
83
-
84
- = 1.5.7 - 06-03-2019 =
85
- * Fix - Demo preview overlay not importing specific demo.
86
-
87
- = 1.5.6 - 15-02-2019 =
88
- * Fetaure - Install plugins and import demo on a single click.
89
- * Tweak - Remove the more details on demo preview hover.
90
- * Dev - Improve Coding standard with husky compatibility.
91
-
92
- = 1.5.5 - 05-11-2018 =
93
- * Feature - Add support for elementor schemes.
94
-
95
- = 1.5.4 - 02-11-2018 =
96
- * Change Modular to Zakra
97
-
98
- = 1.5.3 - 30-10-2018 =
99
- * Support - Modular theme.
100
-
101
- = 1.5.2 - 25-09-2018 =
102
- * Fix - Custom CSS migration on demo import.
103
- * Fix - Live Preview button when demo is successfully imported in demo preview page.
104
-
105
- = 1.5.1 - 24-08-2018 =
106
- * Support - Cenote Pro theme.
107
-
108
- = 1.5.0 - 21-08-2018 =
109
- * Feature - Fetches the demo config from GitHub repo.
110
- * Feature - Category and pagebuilder routes for views.
111
- * Fetaure - Install and activate plugins on a single click.
112
- * Fix - Slashes to be stripped from imported comments.
113
- * Fix - Importing export files with multiline term meta data.
114
- * Fix - Deprecation notices including `wp_get_http()` and `screen_icon()`.
115
- * Tweak - Demo preview is supported via iframe.
116
- * Tweak - Different device preview is possible for a demo.
117
- * Tweak - Only store single demo package files in upload directory.
118
- * Dev - Improve PHP7 compatibility.
119
- * Deprecated - Upload process for the demo packages.
120
- * Deprecated - Filter hooks `themegrill_demo_importer_config` and `themegrill_demo_importer_packages`.
121
-
122
[See changelog for all versions](https://raw.githubusercontent.com/themegrill/themegrill-demo-importer/master/CHANGELOG.txt).
2
Contributors: ThemeGrill, shivapoudel
3
Tags: themegrill, theme demos, demo, importer, one click import
4
Requires at least: 4.7
5
+ Tested up to: 5.2.4
6
+ Stable tag: 1.6.1
7
License: GPLv3 or later
8
License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
72
3. Finally, Import the Demo with just one click.
73
74
== Changelog ==
75
+ = 1.6.1 - 12-11-2019 =
76
+ * Tweak - Add admin notice for `Upgrade To Pro`.
77
+
78
= 1.6.0 - 10-09-2019 =
79
* Tweak - Support for Zakra Premium version demo import.
80
81
[See changelog for all versions](https://raw.githubusercontent.com/themegrill/themegrill-demo-importer/master/CHANGELOG.txt).
themegrill-demo-importer.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: ThemeGrill Demo Importer
4
* Plugin URI: https://themegrill.com/demo-importer/
5
* Description: Import ThemeGrill official themes demo content, widgets and theme settings with just one click.
6
- * Version: 1.6.0
7
* Author: ThemeGrill
8
* Author URI: https://themegrill.com
9
* License: GPLv3 or later
3
* Plugin Name: ThemeGrill Demo Importer
4
* Plugin URI: https://themegrill.com/demo-importer/
5
* Description: Import ThemeGrill official themes demo content, widgets and theme settings with just one click.
6
+ * Version: 1.6.1
7
* Author: ThemeGrill
8
* Author URI: https://themegrill.com
9
* License: GPLv3 or later