Template Kit – Import - Version 1.0.1

Version Description

  • 2020-02-13 =
  • Support for Elementor 2.9.0
  • Support for Elementor Global Theme Styles
  • Support for Elementor Pro Theme Builder templates
Download this release

Release Info

Developer envato
Plugin Icon 128x128 Template Kit – Import
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

assets/css/main.min.css CHANGED
@@ -43,6 +43,8 @@
43
  .envato-template-kit-import__template-screenshot-wrapper{height:300px;overflow:hidden}
44
  .envato-template-kit-import__template-screenshot{max-width:100%;height:auto}
45
  .envato-template-kit-import__template-title{text-align:center;padding:20px 0 0;font-size:16px}
 
 
46
  .envato-template-kit-import__template-import-options{text-align:center;padding:20px 0}
47
  .envato-template-kit-import__template-import-option--imported,.envato-template-kit-import__template-import-option--unmet-requirements{display:none}
48
  .envato-template-kit-import__template--imported{position:relative;overflow:hidden}
@@ -73,44 +75,44 @@
73
  .envato-template-kit-import__button-ignore-requirements:hover,.envato-template-kit-import__button-ignore-requirements:focus{background:#dc5f5c;border-color:#d64742;color:#fff}
74
  .envato-template-kit-import__button-ignore-requirements:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #d9534f;box-shadow:0 0 0 1px #fff,0 0 0 3px #d9534f}
75
  .envato-template-kit-import__button-ignore-requirements:active{background:#d43f3a;border-color:#d43f3a;color:#fff}
76
- .envato-template-kit-import__plugins{background:#fff;border:1px solid #ccd6df;margin:40px auto 40px;padding:20px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}
77
- .envato-template-kit-import__plugin-list-wrapper{-webkit-box-flex:0;-webkit-flex:0 0 690px;-ms-flex:0 0 690px;flex:0 0 690px}
78
- .envato-template-kit-import__plugin-list{padding-top:10px;padding-left:10px}
79
- .envato-template-kit-import__plugin{border-bottom:1px solid #ccd6df;padding:10px 0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;width:100%}
80
- .envato-template-kit-import__plugin-title{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}
81
- .envato-template-kit-import__plugin-status{-webkit-box-flex:0;-webkit-flex:0 0 200px;-ms-flex:0 0 200px;flex:0 0 200px}
82
- .envato-template-kit-import__plugin-status--deactivated{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
83
- .envato-template-kit-import__plugin-status--deactivated:hover,.envato-template-kit-import__plugin-status--deactivated:focus{background:#0090c9;border-color:#007aab;color:#fff}
84
- .envato-template-kit-import__plugin-status--deactivated:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
85
- .envato-template-kit-import__plugin-status--deactivated:active{background:#0073a1;border-color:#0073a1;color:#fff}
86
- .envato-template-kit-import__plugin-status--deactivated [data-plugin-status="deactivated"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
87
- .envato-template-kit-import__plugin-status--update{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
88
- .envato-template-kit-import__plugin-status--update:hover,.envato-template-kit-import__plugin-status--update:focus{background:#0090c9;border-color:#007aab;color:#fff}
89
- .envato-template-kit-import__plugin-status--update:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
90
- .envato-template-kit-import__plugin-status--update:active{background:#0073a1;border-color:#0073a1;color:#fff}
91
- .envato-template-kit-import__plugin-status--update [data-plugin-status="update"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
92
- .envato-template-kit-import__plugin-status--install{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
93
- .envato-template-kit-import__plugin-status--install:hover,.envato-template-kit-import__plugin-status--install:focus{background:#0090c9;border-color:#007aab;color:#fff}
94
- .envato-template-kit-import__plugin-status--install:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
95
- .envato-template-kit-import__plugin-status--install:active{background:#0073a1;border-color:#0073a1;color:#fff}
96
- .envato-template-kit-import__plugin-status--install [data-plugin-status="install"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
97
- .envato-template-kit-import__plugin-status--activated{background:#d0d0d0;border-color:#d0d0d0;color:#030303;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #c3c3c3;box-shadow:inset 0 -2px 0 #c3c3c3}
98
- .envato-template-kit-import__plugin-status--activated:hover,.envato-template-kit-import__plugin-status--activated:focus{background:#d8d8d8;border-color:#c8c8c8;color:#030303}
99
- .envato-template-kit-import__plugin-status--activated:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #d0d0d0;box-shadow:0 0 0 1px #fff,0 0 0 3px #d0d0d0}
100
- .envato-template-kit-import__plugin-status--activated:active{background:#c3c3c3;border-color:#c3c3c3;color:#030303}
101
- .envato-template-kit-import__plugin-status--activated [data-plugin-status="activated"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
102
- .envato-template-kit-import__plugin-status--activated [data-plugin-status="activated"] .dashicons-yes{color:#5cb85c}
103
- .envato-template-kit-import__plugin-status--error{background:#818a91;border-color:#818a91;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #747d85;box-shadow:inset 0 -2px 0 #747d85}
104
- .envato-template-kit-import__plugin-status--error:hover,.envato-template-kit-import__plugin-status--error:focus{background:#899298;border-color:#79828a;color:#fff}
105
- .envato-template-kit-import__plugin-status--error:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #818a91;box-shadow:0 0 0 1px #fff,0 0 0 3px #818a91}
106
- .envato-template-kit-import__plugin-status--error:active{background:#747d85;border-color:#747d85;color:#fff}
107
- .envato-template-kit-import__plugin-status--error [data-plugin-status="error"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
108
- .envato-template-kit-import__plugin-status-text{display:none;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between}
109
- .envato-template-kit-import__plugin-list-next{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;padding:60px}
110
- .envato-template-kit-import__plugin-list-next-button{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:16px 20px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
111
- .envato-template-kit-import__plugin-list-next-button:hover,.envato-template-kit-import__plugin-list-next-button:focus{background:#0090c9;border-color:#007aab;color:#fff}
112
- .envato-template-kit-import__plugin-list-next-button:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
113
- .envato-template-kit-import__plugin-list-next-button:active{background:#0073a1;border-color:#0073a1;color:#fff}
114
  @-webkit-keyframes templateImportSpin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}
115
  }@keyframes templateImportSpin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}
116
  }
43
  .envato-template-kit-import__template-screenshot-wrapper{height:300px;overflow:hidden}
44
  .envato-template-kit-import__template-screenshot{max-width:100%;height:auto}
45
  .envato-template-kit-import__template-title{text-align:center;padding:20px 0 0;font-size:16px}
46
+ .envato-template-kit-import__template-information{border-radius:3px;padding:10px;border:1px solid #efefef;margin:14px 20px 0}
47
+ .envato-template-kit-import__template-information p{margin:0;padding:0}
48
  .envato-template-kit-import__template-import-options{text-align:center;padding:20px 0}
49
  .envato-template-kit-import__template-import-option--imported,.envato-template-kit-import__template-import-option--unmet-requirements{display:none}
50
  .envato-template-kit-import__template--imported{position:relative;overflow:hidden}
75
  .envato-template-kit-import__button-ignore-requirements:hover,.envato-template-kit-import__button-ignore-requirements:focus{background:#dc5f5c;border-color:#d64742;color:#fff}
76
  .envato-template-kit-import__button-ignore-requirements:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #d9534f;box-shadow:0 0 0 1px #fff,0 0 0 3px #d9534f}
77
  .envato-template-kit-import__button-ignore-requirements:active{background:#d43f3a;border-color:#d43f3a;color:#fff}
78
+ .envato-template-kit-import__requirements{background:#fff;border:1px solid #ccd6df;margin:40px auto 40px;padding:20px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}
79
+ .envato-template-kit-import__requirement-list-wrapper{-webkit-box-flex:0;-webkit-flex:0 0 690px;-ms-flex:0 0 690px;flex:0 0 690px}
80
+ .envato-template-kit-import__requirement-list{padding-top:10px;padding-left:10px}
81
+ .envato-template-kit-import__requirement{border-bottom:1px solid #ccd6df;padding:10px 0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;width:100%}
82
+ .envato-template-kit-import__requirement-title{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}
83
+ .envato-template-kit-import__requirement-status{-webkit-box-flex:0;-webkit-flex:0 0 200px;-ms-flex:0 0 200px;flex:0 0 200px}
84
+ .envato-template-kit-import__requirement-status--deactivated{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
85
+ .envato-template-kit-import__requirement-status--deactivated:hover,.envato-template-kit-import__requirement-status--deactivated:focus{background:#0090c9;border-color:#007aab;color:#fff}
86
+ .envato-template-kit-import__requirement-status--deactivated:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
87
+ .envato-template-kit-import__requirement-status--deactivated:active{background:#0073a1;border-color:#0073a1;color:#fff}
88
+ .envato-template-kit-import__requirement-status--deactivated [data-theme-status="deactivated"],.envato-template-kit-import__requirement-status--deactivated [data-plugin-status="deactivated"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
89
+ .envato-template-kit-import__requirement-status--update{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
90
+ .envato-template-kit-import__requirement-status--update:hover,.envato-template-kit-import__requirement-status--update:focus{background:#0090c9;border-color:#007aab;color:#fff}
91
+ .envato-template-kit-import__requirement-status--update:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
92
+ .envato-template-kit-import__requirement-status--update:active{background:#0073a1;border-color:#0073a1;color:#fff}
93
+ .envato-template-kit-import__requirement-status--update [data-theme-status="update"],.envato-template-kit-import__requirement-status--update [data-plugin-status="update"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
94
+ .envato-template-kit-import__requirement-status--install{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
95
+ .envato-template-kit-import__requirement-status--install:hover,.envato-template-kit-import__requirement-status--install:focus{background:#0090c9;border-color:#007aab;color:#fff}
96
+ .envato-template-kit-import__requirement-status--install:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
97
+ .envato-template-kit-import__requirement-status--install:active{background:#0073a1;border-color:#0073a1;color:#fff}
98
+ .envato-template-kit-import__requirement-status--install [data-theme-status="install"],.envato-template-kit-import__requirement-status--install [data-plugin-status="install"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
99
+ .envato-template-kit-import__requirement-status--activated{background:#d0d0d0;border-color:#d0d0d0;color:#030303;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #c3c3c3;box-shadow:inset 0 -2px 0 #c3c3c3}
100
+ .envato-template-kit-import__requirement-status--activated:hover,.envato-template-kit-import__requirement-status--activated:focus{background:#d8d8d8;border-color:#c8c8c8;color:#030303}
101
+ .envato-template-kit-import__requirement-status--activated:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #d0d0d0;box-shadow:0 0 0 1px #fff,0 0 0 3px #d0d0d0}
102
+ .envato-template-kit-import__requirement-status--activated:active{background:#c3c3c3;border-color:#c3c3c3;color:#030303}
103
+ .envato-template-kit-import__requirement-status--activated [data-theme-status="activated"],.envato-template-kit-import__requirement-status--activated [data-plugin-status="activated"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
104
+ .envato-template-kit-import__requirement-status--activated [data-theme-status="activated"] .dashicons-yes,.envato-template-kit-import__requirement-status--activated [data-plugin-status="activated"] .dashicons-yes{color:#5cb85c}
105
+ .envato-template-kit-import__requirement-status--error{background:#818a91;border-color:#818a91;color:#fff;border-radius:3px;font-size:13px;padding:5px 15px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #747d85;box-shadow:inset 0 -2px 0 #747d85}
106
+ .envato-template-kit-import__requirement-status--error:hover,.envato-template-kit-import__requirement-status--error:focus{background:#899298;border-color:#79828a;color:#fff}
107
+ .envato-template-kit-import__requirement-status--error:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #818a91;box-shadow:0 0 0 1px #fff,0 0 0 3px #818a91}
108
+ .envato-template-kit-import__requirement-status--error:active{background:#747d85;border-color:#747d85;color:#fff}
109
+ .envato-template-kit-import__requirement-status--error [data-theme-status="error"],.envato-template-kit-import__requirement-status--error [data-plugin-status="error"]{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}
110
+ .envato-template-kit-import__requirement-status-text{display:none;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between}
111
+ .envato-template-kit-import__requirement-list-next{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;padding:60px}
112
+ .envato-template-kit-import__requirement-list-next-button{background:#0085ba;border-color:#0085ba;color:#fff;border-radius:3px;font-size:13px;padding:16px 20px;border:0;cursor:pointer;text-decoration:none;-webkit-box-shadow:inset 0 -2px 0 #0073a1;box-shadow:inset 0 -2px 0 #0073a1}
113
+ .envato-template-kit-import__requirement-list-next-button:hover,.envato-template-kit-import__requirement-list-next-button:focus{background:#0090c9;border-color:#007aab;color:#fff}
114
+ .envato-template-kit-import__requirement-list-next-button:focus{-webkit-box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba;box-shadow:0 0 0 1px #fff,0 0 0 3px #0085ba}
115
+ .envato-template-kit-import__requirement-list-next-button:active{background:#0073a1;border-color:#0073a1;color:#fff}
116
  @-webkit-keyframes templateImportSpin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}
117
  }@keyframes templateImportSpin{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}
118
  }
assets/js/importer.min.js CHANGED
@@ -1 +1 @@
1
- !function(r){window.TemplateKitImport=function(){function t(t){t.preventDefault();var e=r(this).data();if(e&&e.templateKitId&&e.nonce){var a=parseInt(e.templateIndex,10),i=r('.js-single-template[data-template-index="'+a+'"]');i.addClass("envato-template-kit-import__template--importing"),r.ajax({url:ajaxurl,method:"post",dataType:"json",data:{action:"envato_template_kit_import_process",template_kit_id:parseInt(e.templateKitId,10),template_index:a,nonce:e.nonce},success:function(t){i.addClass("envato-template-kit-import__template--imported"),i.find(".js-edit-template").attr("href",t.data.edit_url)},error:function(){alert("failed to import")},complete:function(){i.removeClass("envato-template-kit-import__template--importing")}})}return!1}function e(t){if(t.preventDefault(),confirm("Are you sure?")){var e=r(this).data();return e&&e.templateKitId&&e.nonce&&r.ajax({url:ajaxurl,type:"post",dataType:"json",data:{action:"envato_template_kit_delete_process",template_kit_id:parseInt(e.templateKitId,10),_ajax_nonce:e.nonce},success:function(t){r(".js-template-kit-id-"+e.templateKitId).remove(),r(".envato-template-kit-import__wrapper").not(".envato-template-kit-import__template-kit")&&location.reload(!0)},error:function(t){alert("Failed to remove template kit!")}}),!1}}function a(t){t.preventDefault();var e=r(this).data();switch(e.pluginStatus){case"deactivated":case"update":case"install":window.location.href=e.pluginUrl;break;case"activated":break;case"error":alert("Unknown error");break;default:alert("Unknown plugin action")}return!1}function i(t){t.preventDefault();var e=r(this).data("templateIndex");return r('.js-single-template[data-template-index="'+e+'"]').removeClass("envato-template-kit-import__template--unmet-requirements"),!1}function n(t){return!((r(".envato-template-kit-import__plugin-status--install")[0]||r(".envato-template-kit-import__plugin-status--deactivated")[0])&&!confirm("Some required plugins are not installed or actived. Proceed anyway?"))||(t.preventDefault(),!1)}return{initPluginPage:function(){r(".js-template-kit-plugin").click(a),r(".js-template-kit-plugin-next").click(n)},initImportPage:function(){r(".js-template-kit-delete").click(e)},initTemplatePage:function(){r(".js-template-kit-import").click(t),r(".js-template-kit-ignore-requirements").click(i)}}}}(jQuery);
1
+ !function(l){window.TemplateKitImport=function(){function t(t){t.preventDefault();var e=l(this).data();if(e&&e.templateKitId&&e.nonce){var a=parseInt(e.templateIndex,10),n=l('.js-single-template[data-template-index="'+a+'"]');n.addClass("envato-template-kit-import__template--importing"),l.ajax({url:ajaxurl,method:"post",dataType:"json",data:{action:"envato_template_kit_import_process",template_kit_id:parseInt(e.templateKitId,10),template_index:a,nonce:e.nonce},success:function(t){n.addClass("envato-template-kit-import__template--imported"),n.find(".js-edit-template").attr("href",t.data.edit_url)},error:function(){alert("failed to import")},complete:function(){n.removeClass("envato-template-kit-import__template--importing")}})}return!1}function e(t){if(t.preventDefault(),confirm("Are you sure?")){var e=l(this).data();return e&&e.templateKitId&&e.nonce&&l.ajax({url:ajaxurl,type:"post",dataType:"json",data:{action:"envato_template_kit_delete_process",template_kit_id:parseInt(e.templateKitId,10),_ajax_nonce:e.nonce},success:function(t){l(".js-template-kit-id-"+e.templateKitId).remove(),l(".envato-template-kit-import__wrapper").not(".envato-template-kit-import__template-kit")&&location.reload(!0)},error:function(t){alert("Failed to remove template kit!")}}),!1}}function a(t){t.preventDefault();var e=l(this).data();switch(e.pluginStatus){case"deactivated":case"update":case"install":window.location.href=e.pluginUrl;break;case"activated":break;case"error":alert("Unknown error");break;default:alert("Unknown plugin action")}return!1}function n(t){t.preventDefault();var e=l(this).data();switch(e.themeStatus){case"deactivated":case"update":case"install":window.location.href=e.themeUrl;break;case"activated":break;case"error":alert("Unknown error");break;default:alert("Unknown theme action")}return!1}function i(t){t.preventDefault();var e=l(this).data("templateIndex");return l('.js-single-template[data-template-index="'+e+'"]').removeClass("envato-template-kit-import__template--unmet-requirements"),!1}function r(t){return!((l(".envato-template-kit-import__plugin-status--install")[0]||l(".envato-template-kit-import__plugin-status--deactivated")[0])&&!confirm("Some required plugins are not installed or actived. Proceed anyway?"))||(t.preventDefault(),!1)}return{initPluginPage:function(){l(".js-template-kit-plugin").click(a),l(".js-template-kit-theme").click(n),l(".js-template-kit-plugin-next").click(r)},initImportPage:function(){l(".js-template-kit-delete").click(e)},initTemplatePage:function(){l(".js-template-kit-import").click(t),l(".js-template-kit-ignore-requirements").click(i)}}}}(jQuery);
inc/class-builder-elementor.php CHANGED
@@ -47,11 +47,31 @@ class Builder_Elementor extends Builder {
47
  return new \WP_Error( 'Failed to load kit' );
48
  }
49
 
 
 
 
 
 
 
50
  $template_data = $this->get_template_data( $template_index );
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  // Found the template to import from the manifest file.
53
  $template_kit_folder_name = $this->get_template_kit_temporary_folder();
54
- $template_json_file = $template_kit_folder_name . $template_data['source'];
55
  $source = \Elementor\Plugin::$instance->templates_manager->get_source( 'local' );
56
  $result = $source->import_template( basename( $template_json_file ), $template_json_file );
57
 
@@ -71,10 +91,8 @@ class Builder_Elementor extends Builder {
71
  }
72
 
73
  return new \WP_Error( 'Unknown import error' );
74
-
75
  }
76
 
77
-
78
  /**
79
  * What text to display on input buttons
80
  *
@@ -84,6 +102,83 @@ class Builder_Elementor extends Builder {
84
  return esc_html__( 'Import into Elementor Library', 'template-kit-import' );
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  /**
88
  * Get the URL to the list of imported templates.
89
  *
@@ -154,4 +249,42 @@ class Builder_Elementor extends Builder {
154
  }
155
  return $unmet_requirements;
156
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
47
  return new \WP_Error( 'Failed to load kit' );
48
  }
49
 
50
+ // We pipe off here to handle a special case for Global Styles.
51
+ $global_result = $this->ensure_elementor_global_styles_are_imported_and_active( $template_index );
52
+ if ( true !== $global_result ) {
53
+ return $global_result;
54
+ }
55
+
56
  $template_data = $this->get_template_data( $template_index );
57
 
58
+ return $this->import_json_file_to_elementor_library( $template_data['source'], $template_index );
59
+
60
+ }
61
+
62
+ /**
63
+ * Reach out to Elementor to import a local JSON file into the library.
64
+ * Returns the ID of the locally imported post.
65
+ *
66
+ * @param $json_file_path
67
+ * @param $template_index
68
+ *
69
+ * @return int|\WP_Error
70
+ */
71
+ private function import_json_file_to_elementor_library( $json_file_path, $template_index ) {
72
  // Found the template to import from the manifest file.
73
  $template_kit_folder_name = $this->get_template_kit_temporary_folder();
74
+ $template_json_file = $template_kit_folder_name . $json_file_path;
75
  $source = \Elementor\Plugin::$instance->templates_manager->get_source( 'local' );
76
  $result = $source->import_template( basename( $template_json_file ), $template_json_file );
77
 
91
  }
92
 
93
  return new \WP_Error( 'Unknown import error' );
 
94
  }
95
 
 
96
  /**
97
  * What text to display on input buttons
98
  *
102
  return esc_html__( 'Import into Elementor Library', 'template-kit-import' );
103
  }
104
 
105
+
106
+ /**
107
+ * Ensure our global styles (if they exist) are installed and active on the site.
108
+ * But only installed + active once!
109
+ *
110
+ * @param $template_index_user_requested_to_import
111
+ *
112
+ * @return bool|\WP_Error
113
+ */
114
+ public function ensure_elementor_global_styles_are_imported_and_active( $template_index_user_requested_to_import ) {
115
+ $templates = $this->get_available_templates();
116
+ foreach ( $templates as $template_index => $template ) {
117
+ // Global styles are tagged with a metadata of 'global-styles` in the JSON
118
+ if ( ! empty( $template['metadata'] ) && ! empty( $template['metadata']['template_type'] ) && 'global-styles' === $template['metadata']['template_type'] ) {
119
+ // We have found some global styles!
120
+ // First we check if we've previously imported these global styles, looking at the 'envato_tk_source_index' and 'envato_tk_source_kit' post meta.
121
+ $existing_global_styles_query = array(
122
+ 'meta_query' => array(
123
+ array(
124
+ 'key' => 'envato_tk_source_kit',
125
+ 'value' => $this->kit_id,
126
+ ),
127
+ array(
128
+ 'key' => 'envato_tk_source_index',
129
+ 'value' => $template_index,
130
+ ),
131
+ ),
132
+ 'post_type' => 'elementor_library',
133
+ 'post_status' => 'publish',
134
+ 'posts_per_page' => -1,
135
+ );
136
+ $existing_global_styles = get_posts( $existing_global_styles_query );
137
+ if ( ! $existing_global_styles ) {
138
+ // We haven't imported these global styles before! Lets do it...
139
+
140
+ $imported_global_styles_id = $this->import_json_file_to_elementor_library( $template['source'], $template_index );
141
+
142
+ if ( is_wp_error( $imported_global_styles_id ) ) {
143
+ // Failed to import global styles:
144
+ return $imported_global_styles_id;
145
+ } else {
146
+ // We set some metadata around the global styles so Elementor can interpret them correctly:
147
+ // From: wp-content/plugins/elementor/core/documents-manager.php:366
148
+ update_post_meta( $imported_global_styles_id, '_elementor_edit_mode', 'builder' );
149
+ update_post_meta( $imported_global_styles_id, '_elementor_template_type', 'kit' );
150
+
151
+ wp_update_post(
152
+ array(
153
+ 'ID' => $imported_global_styles_id,
154
+ 'post_title' => 'Global Styles For Kit: ' . $this->get_name(),
155
+ )
156
+ );
157
+ }
158
+ } else {
159
+ // We have imported this kit before, lets make sure it's still the default.
160
+ // From: wp-content/plugins/elementor/core/kits/manager.php:17
161
+ $imported_global_styles = current( $existing_global_styles );
162
+ $imported_global_styles_id = $imported_global_styles->ID;
163
+ }
164
+
165
+ if ( $imported_global_styles_id ) {
166
+ // And now actually set this kit as active:
167
+ // From: wp-content/plugins/elementor/core/kits/manager.php:17
168
+ update_option( 'elementor_active_kit', $imported_global_styles_id );
169
+
170
+ // Special case here if the user has clicked on "Import Global Styles" on its own
171
+ // we return early because we don't want the parent caller to run the import a second time around.
172
+ if ( $template_index_user_requested_to_import === $template_index ) {
173
+ return $imported_global_styles_id;
174
+ }
175
+ }
176
+ }
177
+ }
178
+
179
+ return true;
180
+ }
181
+
182
  /**
183
  * Get the URL to the list of imported templates.
184
  *
249
  }
250
  return $unmet_requirements;
251
  }
252
+
253
+
254
+ /**
255
+ * Gets any required theme for this Template Kit
256
+ *
257
+ * @return array
258
+ */
259
+ public function get_required_theme() {
260
+ $required_theme = array(
261
+ 'slug' => 'hello-elementor',
262
+ 'name' => 'Hello Elementor',
263
+ );
264
+ $themes = wp_get_themes();
265
+ $current_theme = wp_get_theme();
266
+ $is_hello_installed = false;
267
+ $is_hello_active = false;
268
+ foreach ( $themes as $theme ) {
269
+ if ( $required_theme['slug'] === $theme->get_template() ) {
270
+ $is_hello_installed = true;
271
+ }
272
+ }
273
+ // get_template() checks for parent theme, so we handle a hello child theme using this just fine:
274
+ if ( $required_theme['slug'] === $current_theme->get_template() ) {
275
+ $is_hello_active = true;
276
+ }
277
+ $theme_action_url = admin_url( 'themes.php' );
278
+ $theme_status = $is_hello_active ? 'activated' : ( $is_hello_installed ? 'deactivated' : 'install' );
279
+ if ( 'install' === $theme_status ) {
280
+ // We want the user to install this theme
281
+ $theme_action_url = wp_nonce_url( 'update.php?action=install-theme&theme=' . $required_theme['slug'], 'install-theme_' . $required_theme['slug'] );
282
+ } elseif ( 'deactivated' === $theme_status ) {
283
+ // We want the user to activate this theme
284
+ $theme_action_url = wp_nonce_url( 'themes.php?action=activate&stylesheet=' . $required_theme['slug'], 'switch-theme_' . $required_theme['slug'] );
285
+ }
286
+ $required_theme['status'] = $theme_status;
287
+ $required_theme['url'] = $theme_action_url;
288
+ return $required_theme;
289
+ }
290
  }
inc/class-builder.php CHANGED
@@ -84,6 +84,15 @@ abstract class Builder extends Base {
84
  return Required_Plugin::get_instance()->check_for_required_plugins( ! empty( $manifest_data['required_plugins'] ) ? $manifest_data['required_plugins'] : array() );
85
  }
86
 
 
 
 
 
 
 
 
 
 
87
  /**
88
  * Gets the list of available templates in this kit from metadata
89
  *
84
  return Required_Plugin::get_instance()->check_for_required_plugins( ! empty( $manifest_data['required_plugins'] ) ? $manifest_data['required_plugins'] : array() );
85
  }
86
 
87
+ /**
88
+ * Gets any required theme for this Template Kit
89
+ *
90
+ * @return array
91
+ */
92
+ public function get_required_theme() {
93
+ return array();
94
+ }
95
+
96
  /**
97
  * Gets the list of available templates in this kit from metadata
98
  *
inc/class-plugin.php CHANGED
@@ -54,6 +54,19 @@ class Plugin extends Base {
54
  array( Importer::get_instance(), 'admin_menu_open' )
55
  );
56
  add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_page_assets' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  /**
54
  array( Importer::get_instance(), 'admin_menu_open' )
55
  );
56
  add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_page_assets' ) );
57
+
58
+ if ( defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV ) {
59
+ $page = add_menu_page(
60
+ __( 'Import', 'template-kit-import' ),
61
+ 'Import',
62
+ 'edit_posts',
63
+ ENVATO_TEMPLATE_KIT_IMPORT_SLUG,
64
+ array( Importer::get_instance(), 'admin_menu_open' ),
65
+ '',
66
+ 30
67
+ );
68
+ add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_page_assets' ) );
69
+ }
70
  }
71
 
72
  /**
languages/template-kit-import.pot CHANGED
@@ -34,11 +34,11 @@ msgstr ""
34
  msgid "Something went wrong."
35
  msgstr ""
36
 
37
- #: inc/class-builder-elementor.php:84
38
  msgid "Import into Elementor Library"
39
  msgstr ""
40
 
41
- #: inc/class-builder.php:198
42
  msgid "Import Template"
43
  msgstr ""
44
 
@@ -54,15 +54,23 @@ msgstr ""
54
  msgid "Template Kit Import"
55
  msgstr ""
56
 
57
- #: views/importer/importer.php:33, views/importer/importer.php:46
 
 
 
 
58
  msgid "1. Upload"
59
  msgstr ""
60
 
61
- #: views/importer/importer.php:37, views/importer/importer.php:50
62
- msgid "2. Install Plugins"
 
 
 
 
63
  msgstr ""
64
 
65
- #: views/importer/importer.php:41, views/importer/importer.php:54
66
  msgid "3. Select Templates"
67
  msgstr ""
68
 
@@ -70,7 +78,7 @@ msgstr ""
70
  msgid "Upload Template Kit Zip File"
71
  msgstr ""
72
 
73
- #: views/importer/step1-upload.php:16, views/importer/step1.php:56, views/importer/step2.php:60
74
  msgid "Next"
75
  msgstr ""
76
 
@@ -92,32 +100,48 @@ msgstr ""
92
  msgid "Delete Template Kit"
93
  msgstr ""
94
 
95
- #: views/importer/step1.php:63
96
  msgid "Upload Another Template Kit"
97
  msgstr ""
98
 
99
  #. translators: %s Template kit name
100
- #: views/importer/step2.php:23
101
- msgid "The %s requires the following plugins to work best, select the plugins you would like to install:"
102
  msgstr ""
103
 
104
  #: views/importer/step2.php:39
105
- msgid "Activate Plugin"
106
  msgstr ""
107
 
108
  #: views/importer/step2.php:42
109
- msgid "Update Plugin"
110
  msgstr ""
111
 
112
  #: views/importer/step2.php:45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  msgid "Install Plugin"
114
  msgstr ""
115
 
116
- #: views/importer/step2.php:48
117
- msgid "Plugin Installed"
118
  msgstr ""
119
 
120
- #: views/importer/step2.php:52
121
  msgid "Plugin Error"
122
  msgstr ""
123
 
@@ -130,14 +154,14 @@ msgstr ""
130
  msgid "Imported"
131
  msgstr ""
132
 
133
- #: views/importer/step3.php:66
134
  msgid "Edit"
135
  msgstr ""
136
 
137
- #: views/importer/step3.php:67
138
  msgid "Import Again"
139
  msgstr ""
140
 
141
- #: views/importer/step3.php:78
142
  msgid "Ignore Requirements"
143
  msgstr ""
34
  msgid "Something went wrong."
35
  msgstr ""
36
 
37
+ #: inc/class-builder-elementor.php:102
38
  msgid "Import into Elementor Library"
39
  msgstr ""
40
 
41
+ #: inc/class-builder.php:207
42
  msgid "Import Template"
43
  msgstr ""
44
 
54
  msgid "Template Kit Import"
55
  msgstr ""
56
 
57
+ #: inc/class-plugin.php:60
58
+ msgid "Import"
59
+ msgstr ""
60
+
61
+ #: views/importer/importer.php:40, views/importer/importer.php:58
62
  msgid "1. Upload"
63
  msgstr ""
64
 
65
+ #: views/importer/importer.php:44, views/importer/importer.php:62, views/importer/step1.php:57
66
+ msgid "REVIEW"
67
+ msgstr ""
68
+
69
+ #: views/importer/importer.php:49, views/importer/importer.php:67
70
+ msgid "2. Install Requirements"
71
  msgstr ""
72
 
73
+ #: views/importer/importer.php:53, views/importer/importer.php:71
74
  msgid "3. Select Templates"
75
  msgstr ""
76
 
78
  msgid "Upload Template Kit Zip File"
79
  msgstr ""
80
 
81
+ #: views/importer/step1-upload.php:16, views/importer/step1.php:64, views/importer/step2.php:87
82
  msgid "Next"
83
  msgstr ""
84
 
100
  msgid "Delete Template Kit"
101
  msgstr ""
102
 
103
+ #: views/importer/step1.php:71
104
  msgid "Upload Another Template Kit"
105
  msgstr ""
106
 
107
  #. translators: %s Template kit name
108
+ #: views/importer/step2.php:24
109
+ msgid "The %s requires the following themes & plugins to work best, select the items you would like to install:"
110
  msgstr ""
111
 
112
  #: views/importer/step2.php:39
113
+ msgid "Activate Theme"
114
  msgstr ""
115
 
116
  #: views/importer/step2.php:42
117
+ msgid "Install Theme"
118
  msgstr ""
119
 
120
  #: views/importer/step2.php:45
121
+ msgid "Theme Installed & Active"
122
+ msgstr ""
123
+
124
+ #: views/importer/step2.php:49
125
+ msgid "Theme Error"
126
+ msgstr ""
127
+
128
+ #: views/importer/step2.php:66
129
+ msgid "Activate Plugin"
130
+ msgstr ""
131
+
132
+ #: views/importer/step2.php:69
133
+ msgid "Update Plugin"
134
+ msgstr ""
135
+
136
+ #: views/importer/step2.php:72
137
  msgid "Install Plugin"
138
  msgstr ""
139
 
140
+ #: views/importer/step2.php:75
141
+ msgid "Plugin Installed & Active"
142
  msgstr ""
143
 
144
+ #: views/importer/step2.php:79
145
  msgid "Plugin Error"
146
  msgstr ""
147
 
154
  msgid "Imported"
155
  msgstr ""
156
 
157
+ #: views/importer/step3.php:73
158
  msgid "Edit"
159
  msgstr ""
160
 
161
+ #: views/importer/step3.php:74
162
  msgid "Import Again"
163
  msgstr ""
164
 
165
+ #: views/importer/step3.php:85
166
  msgid "Ignore Requirements"
167
  msgstr ""
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: elementor, template, templates
4
  Requires at least: 5.3
5
  Tested up to: 5.3.2
6
  Requires PHP: 5.6
7
- Stable tag: 1.0.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -36,6 +36,11 @@ Create your own "Template Kit" for others with the "[Template Kit Export](https:
36
 
37
  == Changelog ==
38
 
 
 
 
 
 
39
  = 1.0.0 - 2020-01-16 =
40
  * Official release for public use.
41
 
4
  Requires at least: 5.3
5
  Tested up to: 5.3.2
6
  Requires PHP: 5.6
7
+ Stable tag: 1.0.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
36
 
37
  == Changelog ==
38
 
39
+ = 1.0.1 - 2020-02-13 =
40
+ * Support for Elementor 2.9.0
41
+ * Support for Elementor Global Theme Styles
42
+ * Support for Elementor Pro Theme Builder templates
43
+
44
  = 1.0.0 - 2020-01-16 =
45
  * Official release for public use.
46
 
src/scss/admin/_plugins.scss CHANGED
@@ -1,5 +1,5 @@
1
  .envato-template-kit-import{
2
- &__plugins {
3
  background: #FFFFFF;
4
  border: 1px solid $gray-mouse;
5
  margin: 40px auto 40px;
@@ -8,16 +8,16 @@
8
  flex-wrap: wrap;
9
  }
10
 
11
- &__plugin-list-wrapper {
12
  flex: 0 0 690px;
13
  }
14
 
15
- &__plugin-list {
16
  padding-top: 10px;
17
  padding-left: 10px;
18
  }
19
 
20
- &__plugin {
21
  border-bottom: 1px solid $gray-mouse;
22
  padding: 10px 0;
23
  display: flex;
@@ -25,32 +25,36 @@
25
  width: 100%;
26
  }
27
 
28
- &__plugin-title {
29
  flex: 1;
30
  }
31
 
32
- &__plugin-status {
33
  flex: 0 0 200px;
34
  &--deactivated {
35
  @include button($wp-primary, #fff, $buttonSmall);
 
36
  [data-plugin-status="deactivated"] {
37
  display: flex;
38
  }
39
  }
40
  &--update {
41
  @include button($wp-primary, #fff, $buttonSmall);
 
42
  [data-plugin-status="update"] {
43
  display: flex;
44
  }
45
  }
46
  &--install {
47
  @include button($wp-primary, #fff, $buttonSmall);
 
48
  [data-plugin-status="install"] {
49
  display: flex;
50
  }
51
  }
52
  &--activated {
53
  @include button(#D0D0D0, #030303, $buttonSmall);
 
54
  [data-plugin-status="activated"] {
55
  display: flex;
56
  .dashicons-yes {
@@ -60,19 +64,20 @@
60
  }
61
  &--error {
62
  @include button($gray, #fff, $buttonSmall);
 
63
  [data-plugin-status="error"] {
64
  display: flex;
65
  }
66
  }
67
  }
68
 
69
- &__plugin-status-text {
70
  display: none;
71
  align-items: center;
72
  justify-content: space-between;
73
  }
74
 
75
- &__plugin-list-next {
76
  flex: 1;
77
  display: flex;
78
  justify-content: flex-end;
@@ -80,7 +85,7 @@
80
  padding: 60px;
81
  }
82
 
83
- &__plugin-list-next-button {
84
  @include button($wp-primary);
85
  }
86
 
1
  .envato-template-kit-import{
2
+ &__requirements {
3
  background: #FFFFFF;
4
  border: 1px solid $gray-mouse;
5
  margin: 40px auto 40px;
8
  flex-wrap: wrap;
9
  }
10
 
11
+ &__requirement-list-wrapper {
12
  flex: 0 0 690px;
13
  }
14
 
15
+ &__requirement-list {
16
  padding-top: 10px;
17
  padding-left: 10px;
18
  }
19
 
20
+ &__requirement {
21
  border-bottom: 1px solid $gray-mouse;
22
  padding: 10px 0;
23
  display: flex;
25
  width: 100%;
26
  }
27
 
28
+ &__requirement-title {
29
  flex: 1;
30
  }
31
 
32
+ &__requirement-status {
33
  flex: 0 0 200px;
34
  &--deactivated {
35
  @include button($wp-primary, #fff, $buttonSmall);
36
+ [data-theme-status="deactivated"],
37
  [data-plugin-status="deactivated"] {
38
  display: flex;
39
  }
40
  }
41
  &--update {
42
  @include button($wp-primary, #fff, $buttonSmall);
43
+ [data-theme-status="update"],
44
  [data-plugin-status="update"] {
45
  display: flex;
46
  }
47
  }
48
  &--install {
49
  @include button($wp-primary, #fff, $buttonSmall);
50
+ [data-theme-status="install"],
51
  [data-plugin-status="install"] {
52
  display: flex;
53
  }
54
  }
55
  &--activated {
56
  @include button(#D0D0D0, #030303, $buttonSmall);
57
+ [data-theme-status="activated"],
58
  [data-plugin-status="activated"] {
59
  display: flex;
60
  .dashicons-yes {
64
  }
65
  &--error {
66
  @include button($gray, #fff, $buttonSmall);
67
+ [data-theme-status="error"],
68
  [data-plugin-status="error"] {
69
  display: flex;
70
  }
71
  }
72
  }
73
 
74
+ &__requirement-status-text {
75
  display: none;
76
  align-items: center;
77
  justify-content: space-between;
78
  }
79
 
80
+ &__requirement-list-next {
81
  flex: 1;
82
  display: flex;
83
  justify-content: flex-end;
85
  padding: 60px;
86
  }
87
 
88
+ &__requirement-list-next-button {
89
  @include button($wp-primary);
90
  }
91
 
src/scss/admin/_templates.scss CHANGED
@@ -45,6 +45,18 @@
45
  font-size: 16px;
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  &__template-import-options {
49
  text-align: center;
50
  padding: 20px 0;
45
  font-size: 16px;
46
  }
47
 
48
+ &__template-information {
49
+ border-radius: 3px;
50
+ padding: 10px;
51
+ border: 1px solid #efefef;
52
+ margin: 14px 20px 0;
53
+
54
+ p {
55
+ margin: 0;
56
+ padding: 0;
57
+ }
58
+ }
59
+
60
  &__template-import-options {
61
  text-align: center;
62
  padding: 20px 0;
template-kit-import.php CHANGED
@@ -4,7 +4,7 @@
4
  * Description: Import Template Kits to WordPress
5
  * Author: Envato
6
  * Author URI: https://envato.com
7
- * Version: 1.0.0
8
  * License: GPLv3 or later
9
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
  *
@@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
28
  }
29
 
30
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_SLUG', 'template-kit-import' );
31
- define( 'ENVATO_TEMPLATE_KIT_IMPORT_VER', '1.0.0' );
32
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_FILE', __FILE__ );
33
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_DIR', plugin_dir_path( ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
34
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_URI', plugins_url( '/', ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
4
  * Description: Import Template Kits to WordPress
5
  * Author: Envato
6
  * Author URI: https://envato.com
7
+ * Version: 1.0.1
8
  * License: GPLv3 or later
9
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
  *
28
  }
29
 
30
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_SLUG', 'template-kit-import' );
31
+ define( 'ENVATO_TEMPLATE_KIT_IMPORT_VER', '1.0.1' );
32
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_FILE', __FILE__ );
33
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_DIR', plugin_dir_path( ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
34
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_URI', plugins_url( '/', ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
views/importer/importer.php CHANGED
@@ -9,21 +9,28 @@ if ( ! defined( 'ABSPATH' ) ) {
9
  $current_active_step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 1;
10
  $template_kit_id = isset( $_GET['template_kit_id'] ) ? (int) $_GET['template_kit_id'] : 0;
11
 
12
- $step1_url = Importer::get_instance()->get_url();
13
- $step2_url = add_query_arg(
14
  array(
15
  'step' => 2,
16
  'template_kit_id' => $template_kit_id,
17
  ),
18
  Importer::get_instance()->get_url()
19
  );
20
- $step3_url = add_query_arg(
21
  array(
22
  'step' => 3,
23
  'template_kit_id' => $template_kit_id,
24
  ),
25
  Importer::get_instance()->get_url()
26
  );
 
 
 
 
 
 
 
27
  ?>
28
 
29
  <div class="envato-template-kit-import__tabset">
@@ -32,9 +39,14 @@ $step3_url = add_query_arg(
32
  <a href="<?php echo esc_url( $step1_url ); ?>" class="envato-template-kit-import__tab<?php echo 1 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
33
  <?php esc_html_e( '1. Upload', 'template-kit-import' ); ?>
34
  </a>
 
 
 
 
 
35
  <!-- Tab 2 -->
36
  <a href="<?php echo esc_url( $step2_url ); ?>" class="envato-template-kit-import__tab<?php echo 2 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
37
- <?php esc_html_e( '2. Install Plugins', 'template-kit-import' ); ?>
38
  </a>
39
  <!-- Tab 3 -->
40
  <a href="<?php echo esc_url( $step3_url ); ?>" class="envato-template-kit-import__tab<?php echo 3 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
@@ -45,9 +57,14 @@ $step3_url = add_query_arg(
45
  <a href="<?php echo esc_url( $step1_url ); ?>" class="envato-template-kit-import__tab<?php echo 1 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
46
  <?php esc_html_e( '1. Upload', 'template-kit-import' ); ?>
47
  </a>
 
 
 
 
 
48
  <!-- Tab 2 -->
49
  <span class="envato-template-kit-import__tab">
50
- <?php esc_html_e( '2. Install Plugins', 'template-kit-import' ); ?>
51
  </span>
52
  <!-- Tab 3 -->
53
  <span class="envato-template-kit-import__tab">
@@ -57,7 +74,7 @@ $step3_url = add_query_arg(
57
  </div>
58
  <section class="envato-template-kit-import__tab-panel">
59
  <?php
60
- if ( 1 === $current_active_step || 2 === $current_active_step || 3 === $current_active_step ) {
61
  require __DIR__ . '/step' . $current_active_step . '.php';
62
  }
63
  ?>
9
  $current_active_step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 1;
10
  $template_kit_id = isset( $_GET['template_kit_id'] ) ? (int) $_GET['template_kit_id'] : 0;
11
 
12
+ $step1_url = Importer::get_instance()->get_url();
13
+ $step2_url = add_query_arg(
14
  array(
15
  'step' => 2,
16
  'template_kit_id' => $template_kit_id,
17
  ),
18
  Importer::get_instance()->get_url()
19
  );
20
+ $step3_url = add_query_arg(
21
  array(
22
  'step' => 3,
23
  'template_kit_id' => $template_kit_id,
24
  ),
25
  Importer::get_instance()->get_url()
26
  );
27
+ $review_url = add_query_arg(
28
+ array(
29
+ 'step' => 8,
30
+ 'template_kit_id' => $template_kit_id,
31
+ ),
32
+ Importer::get_instance()->get_url()
33
+ );
34
  ?>
35
 
36
  <div class="envato-template-kit-import__tabset">
39
  <a href="<?php echo esc_url( $step1_url ); ?>" class="envato-template-kit-import__tab<?php echo 1 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
40
  <?php esc_html_e( '1. Upload', 'template-kit-import' ); ?>
41
  </a>
42
+ <?php if ( defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV ) { ?>
43
+ <a href="<?php echo esc_url( $review_url ); ?>" class="envato-template-kit-import__tab<?php echo 8 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
44
+ <?php esc_html_e( 'REVIEW', 'template-kit-import' ); ?>
45
+ </a>
46
+ <?php } ?>
47
  <!-- Tab 2 -->
48
  <a href="<?php echo esc_url( $step2_url ); ?>" class="envato-template-kit-import__tab<?php echo 2 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
49
+ <?php esc_html_e( '2. Install Requirements', 'template-kit-import' ); ?>
50
  </a>
51
  <!-- Tab 3 -->
52
  <a href="<?php echo esc_url( $step3_url ); ?>" class="envato-template-kit-import__tab<?php echo 3 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
57
  <a href="<?php echo esc_url( $step1_url ); ?>" class="envato-template-kit-import__tab<?php echo 1 === $current_active_step ? ' envato-template-kit-import__tab--current' : ''; ?>">
58
  <?php esc_html_e( '1. Upload', 'template-kit-import' ); ?>
59
  </a>
60
+ <?php if ( defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV ) { ?>
61
+ <span class="envato-template-kit-import__tab">
62
+ <?php esc_html_e( 'REVIEW', 'template-kit-import' ); ?>
63
+ </span>
64
+ <?php } ?>
65
  <!-- Tab 2 -->
66
  <span class="envato-template-kit-import__tab">
67
+ <?php esc_html_e( '2. Install Requirements', 'template-kit-import' ); ?>
68
  </span>
69
  <!-- Tab 3 -->
70
  <span class="envato-template-kit-import__tab">
74
  </div>
75
  <section class="envato-template-kit-import__tab-panel">
76
  <?php
77
+ if ( 1 === $current_active_step || 2 === $current_active_step || 3 === $current_active_step || 8 === $current_active_step ) {
78
  require __DIR__ . '/step' . $current_active_step . '.php';
79
  }
80
  ?>
views/importer/step1.php CHANGED
@@ -52,6 +52,14 @@ if ( ! $existing_kits || isset( $_GET['upload'] ) ) {
52
  <p><button class="envato-template-kit-import__btn-delete js-template-kit-delete" data-nonce="<?php echo wp_create_nonce( 'delete_template_kit_' . $template_kit_id ); ?>" data-template-kit-id="<?php echo (int) $template_kit_id; ?>"><?php echo esc_html_e( 'Delete Template Kit', 'template-kit-import' ); ?></button></p>
53
  </div>
54
  <div class="envato-template-kit-import__next">
 
 
 
 
 
 
 
 
55
  <a class="envato-template-kit-import__upload-btn-next-link"
56
  href="<?php echo esc_url( Importer::get_instance()->get_url() ); ?>&step=2&template_kit_id=<?php echo (int) $template_kit_id; ?>"><?php esc_html_e( 'Next', 'template-kit-import' ); ?></a>
57
  </div>
52
  <p><button class="envato-template-kit-import__btn-delete js-template-kit-delete" data-nonce="<?php echo wp_create_nonce( 'delete_template_kit_' . $template_kit_id ); ?>" data-template-kit-id="<?php echo (int) $template_kit_id; ?>"><?php echo esc_html_e( 'Delete Template Kit', 'template-kit-import' ); ?></button></p>
53
  </div>
54
  <div class="envato-template-kit-import__next">
55
+ <?php if ( defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV ) { ?>
56
+ <a class="envato-template-kit-import__upload-btn-next-link"
57
+ href="<?php echo esc_url( Importer::get_instance()->get_url() ); ?>&step=8&template_kit_id=<?php echo (int) $template_kit_id; ?>"><?php esc_html_e( 'REVIEW', 'template-kit-import' ); ?></a>
58
+ <br />
59
+ <br />
60
+ <br />
61
+ <br />
62
+ <?php } ?>
63
  <a class="envato-template-kit-import__upload-btn-next-link"
64
  href="<?php echo esc_url( Importer::get_instance()->get_url() ); ?>&step=2&template_kit_id=<?php echo (int) $template_kit_id; ?>"><?php esc_html_e( 'Next', 'template-kit-import' ); ?></a>
65
  </div>
views/importer/step2.php CHANGED
@@ -12,43 +12,70 @@ if ( ! $template_kit ) {
12
  wp_die( 'Invalid Template Kit ID' );
13
  }
14
 
 
15
  $required_plugins = $template_kit->get_required_plugins();
16
  ?>
17
 
18
- <div class="envato-template-kit-import__plugins">
19
- <div class="envato-template-kit-import__plugin-list-wrapper">
20
  <p>
21
  <?php
22
  /* Translators: %s Template kit name */
23
- printf( esc_html__( 'The %s requires the following plugins to work best, select the plugins you would like to install:', 'template-kit-import' ), '<strong>' . esc_html( $template_kit->get_name() ) . ' - Template Kit</strong>' );
24
  ?>
25
  </p>
26
- <div class="envato-template-kit-import__plugin-list">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  <?php foreach ( $required_plugins as $required_plugin ) { ?>
28
- <div class="envato-template-kit-import__plugin">
29
- <span class="envato-template-kit-import__plugin-title">
30
  <?php echo esc_html( $required_plugin['name'] ); ?>
31
  </span>
32
  <span
33
- class="envato-template-kit-import__plugin-status envato-template-kit-import__plugin-status--btn-small envato-template-kit-import__plugin-status--<?php echo esc_attr( $required_plugin['status'] ); ?> js-template-kit-plugin"
34
  data-plugin-status="<?php echo esc_attr( $required_plugin['status'] ); ?>"
35
  data-plugin-file="<?php echo esc_attr( $required_plugin['file'] ); ?>"
36
  data-plugin-slug="<?php echo esc_attr( $required_plugin['slug'] ); ?>"
37
  data-plugin-url="<?php echo esc_attr( $required_plugin['url'] ); ?>">
38
- <span class="envato-template-kit-import__plugin-status-text" data-plugin-status="deactivated">
39
  <?php esc_html_e( 'Activate Plugin', 'template-kit-import' ); ?>
40
  </span>
41
- <span class="envato-template-kit-import__plugin-status-text" data-plugin-status="update">
42
  <?php esc_html_e( 'Update Plugin', 'template-kit-import' ); ?>
43
  </span>
44
- <span class="envato-template-kit-import__plugin-status-text" data-plugin-status="install">
45
  <?php esc_html_e( 'Install Plugin', 'template-kit-import' ); ?>
46
  </span>
47
- <span class="envato-template-kit-import__plugin-status-text" data-plugin-status="activated">
48
- <?php esc_html_e( 'Plugin Installed', 'template-kit-import' ); ?>
49
  <span class="dashicons dashicons-yes"></span>
50
  </span>
51
- <span class="envato-template-kit-import__plugin-status-text" data-plugin-status="error">
52
  <?php esc_html_e( 'Plugin Error', 'template-kit-import' ); ?>
53
  </span>
54
  </span>
@@ -56,8 +83,8 @@ $required_plugins = $template_kit->get_required_plugins();
56
  <?php } ?>
57
  </div>
58
  </div>
59
- <div class="envato-template-kit-import__plugin-list-next">
60
- <a class="envato-template-kit-import__plugin-list-next-button js-template-kit-plugin-next" href="<?php echo esc_url( Importer::get_instance()->get_url() ); ?>&step=3&template_kit_id=<?php echo (int) $template_kit_id; ?>"><?php esc_html_e( 'Next', 'template-kit-import' ); ?></a>
61
  </div>
62
  </div>
63
 
12
  wp_die( 'Invalid Template Kit ID' );
13
  }
14
 
15
+ $required_theme = $template_kit->get_required_theme();
16
  $required_plugins = $template_kit->get_required_plugins();
17
  ?>
18
 
19
+ <div class="envato-template-kit-import__requirements">
20
+ <div class="envato-template-kit-import__requirement-list-wrapper">
21
  <p>
22
  <?php
23
  /* Translators: %s Template kit name */
24
+ printf( esc_html__( 'The %s requires the following themes & plugins to work best, select the items you would like to install:', 'template-kit-import' ), '<strong>' . esc_html( $template_kit->get_name() ) . ' - Template Kit</strong>' );
25
  ?>
26
  </p>
27
+ <div class="envato-template-kit-import__requirement-list">
28
+ <?php if ( $required_theme ) { ?>
29
+ <div class="envato-template-kit-import__requirement">
30
+ <span class="envato-template-kit-import__requirement-title">
31
+ <?php echo esc_html( $required_theme['name'] ); ?>
32
+ </span>
33
+ <span
34
+ class="envato-template-kit-import__requirement-status envato-template-kit-import__requirement-status--btn-small envato-template-kit-import__requirement-status--<?php echo esc_attr( $required_theme['status'] ); ?> js-template-kit-theme"
35
+ data-theme-status="<?php echo esc_attr( $required_theme['status'] ); ?>"
36
+ data-theme-slug="<?php echo esc_attr( $required_theme['slug'] ); ?>"
37
+ data-theme-url="<?php echo esc_attr( $required_theme['url'] ); ?>">
38
+ <span class="envato-template-kit-import__requirement-status-text" data-theme-status="deactivated">
39
+ <?php esc_html_e( 'Activate Theme', 'template-kit-import' ); ?>
40
+ </span>
41
+ <span class="envato-template-kit-import__requirement-status-text" data-theme-status="install">
42
+ <?php esc_html_e( 'Install Theme', 'template-kit-import' ); ?>
43
+ </span>
44
+ <span class="envato-template-kit-import__requirement-status-text" data-theme-status="activated">
45
+ <?php esc_html_e( 'Theme Installed & Active', 'template-kit-import' ); ?>
46
+ <span class="dashicons dashicons-yes"></span>
47
+ </span>
48
+ <span class="envato-template-kit-import__requirement-status-text" data-theme-status="error">
49
+ <?php esc_html_e( 'Theme Error', 'template-kit-import' ); ?>
50
+ </span>
51
+ </span>
52
+ </div>
53
+ <?php } ?>
54
  <?php foreach ( $required_plugins as $required_plugin ) { ?>
55
+ <div class="envato-template-kit-import__requirement">
56
+ <span class="envato-template-kit-import__requirement-title">
57
  <?php echo esc_html( $required_plugin['name'] ); ?>
58
  </span>
59
  <span
60
+ class="envato-template-kit-import__requirement-status envato-template-kit-import__requirement-status--btn-small envato-template-kit-import__requirement-status--<?php echo esc_attr( $required_plugin['status'] ); ?> js-template-kit-plugin"
61
  data-plugin-status="<?php echo esc_attr( $required_plugin['status'] ); ?>"
62
  data-plugin-file="<?php echo esc_attr( $required_plugin['file'] ); ?>"
63
  data-plugin-slug="<?php echo esc_attr( $required_plugin['slug'] ); ?>"
64
  data-plugin-url="<?php echo esc_attr( $required_plugin['url'] ); ?>">
65
+ <span class="envato-template-kit-import__requirement-status-text" data-plugin-status="deactivated">
66
  <?php esc_html_e( 'Activate Plugin', 'template-kit-import' ); ?>
67
  </span>
68
+ <span class="envato-template-kit-import__requirement-status-text" data-plugin-status="update">
69
  <?php esc_html_e( 'Update Plugin', 'template-kit-import' ); ?>
70
  </span>
71
+ <span class="envato-template-kit-import__requirement-status-text" data-plugin-status="install">
72
  <?php esc_html_e( 'Install Plugin', 'template-kit-import' ); ?>
73
  </span>
74
+ <span class="envato-template-kit-import__requirement-status-text" data-plugin-status="activated">
75
+ <?php esc_html_e( 'Plugin Installed & Active', 'template-kit-import' ); ?>
76
  <span class="dashicons dashicons-yes"></span>
77
  </span>
78
+ <span class="envato-template-kit-import__requirement-status-text" data-plugin-status="error">
79
  <?php esc_html_e( 'Plugin Error', 'template-kit-import' ); ?>
80
  </span>
81
  </span>
83
  <?php } ?>
84
  </div>
85
  </div>
86
+ <div class="envato-template-kit-import__requirement-list-next">
87
+ <a class="envato-template-kit-import__requirement-list-next-button js-template-kit-plugin-next" href="<?php echo esc_url( Importer::get_instance()->get_url() ); ?>&step=3&template_kit_id=<?php echo (int) $template_kit_id; ?>"><?php esc_html_e( 'Next', 'template-kit-import' ); ?></a>
88
  </div>
89
  </div>
90
 
views/importer/step3.php CHANGED
@@ -61,6 +61,13 @@ $templates = $template_kit->get_available_templates();
61
  <div class="envato-template-kit-import__template-title">
62
  <?php echo esc_html( $template['name'] ); ?>
63
  </div>
 
 
 
 
 
 
 
64
  <div class="envato-template-kit-import__template-import-options">
65
  <div class="envato-template-kit-import__template-import-option--imported">
66
  <a href="<?php echo esc_url( $template_kit->get_imported_template_edit_url( $template['imports'] ? $template['imports'][0]['imported_template_id'] : 0 ) ); ?>" target="_blank" class="envato-template-kit-import__button-edit js-edit-template"><?php esc_html_e( 'Edit', 'template-kit-import' ); ?></a>
61
  <div class="envato-template-kit-import__template-title">
62
  <?php echo esc_html( $template['name'] ); ?>
63
  </div>
64
+ <?php if ( ! empty( $template['metadata'] ) && ! empty( $template['metadata']['additional_template_information'] ) ) { ?>
65
+ <div class="envato-template-kit-import__template-information">
66
+ <?php foreach ( $template['metadata']['additional_template_information'] as $additional_information ) { ?>
67
+ <p><?php echo wp_kses_post( $additional_information ); ?></p>
68
+ <?php } ?>
69
+ </div>
70
+ <?php } ?>
71
  <div class="envato-template-kit-import__template-import-options">
72
  <div class="envato-template-kit-import__template-import-option--imported">
73
  <a href="<?php echo esc_url( $template_kit->get_imported_template_edit_url( $template['imports'] ? $template['imports'][0]['imported_template_id'] : 0 ) ); ?>" target="_blank" class="envato-template-kit-import__button-edit js-edit-template"><?php esc_html_e( 'Edit', 'template-kit-import' ); ?></a>
views/importer/step8.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Envato_Template_Kit_Import;
4
+
5
+ if ( ! defined( 'ABSPATH' ) || ! isset( $template_kit_id ) ) {
6
+ exit; // Exit if accessed directly.
7
+ }
8
+
9
+ $template_kit = envato_template_kit_import_get_builder( $template_kit_id );
10
+
11
+ if ( ! $template_kit ) {
12
+ wp_die( 'Invalid Template Kit ID' );
13
+ }
14
+
15
+ $manifest = $template_kit->get_manifest_data();
16
+ $required_plugins = $template_kit->get_required_plugins();
17
+ $templates = $template_kit->get_available_templates();
18
+
19
+ ?>
20
+ <div>
21
+ <h2>Kit Details:</h2>
22
+ <ul>
23
+ <li>Kit Name: <strong><?php echo esc_html( $manifest['title'] ); ?></strong></li>
24
+ <li>Builder: <strong><?php echo esc_html( $manifest['page_builder'] ); ?></strong></li>
25
+ <li>Author Kit Version: <strong><?php echo esc_html( $manifest['kit_version'] ); ?></strong></li>
26
+ <li>Export Plugin Version: <strong><?php echo esc_html( $manifest['manifest_version'] ); ?></strong></li>
27
+ <li>Templates: <strong><?php echo count( $manifest['templates'] ); ?></strong></li>
28
+ <li>Plugins: <strong><?php echo count( $manifest['required_plugins'] ); ?></strong></li>
29
+ <li>Images: <strong><?php echo count( $manifest['images'] ); ?></strong></li>
30
+ </ul>
31
+ </div>
32
+ <div>
33
+ <h2>Required Plugins:</h2>
34
+ <ul>
35
+ <?php
36
+ foreach ( $required_plugins as $required_plugin ) {
37
+ ?>
38
+ <li>
39
+ <?php echo '<strong>' . esc_html( $required_plugin['name'] . ' - ' . $required_plugin['slug'] ) . '</strong>' . esc_html__( ' - Version ' . $required_plugin['version'] . ' (' . ( ! empty( $required_plugin['author'] ) ? $required_plugin['author'] . ' / ' : '' ) . $required_plugin['file'] . ')' ); ?>
40
+ </li>
41
+ <?php } ?>
42
+ </ul>
43
+ </div>
44
+ <div>
45
+ <h2>JSON Audit:</h2>
46
+ <?php
47
+ $template_errors = array();
48
+
49
+ foreach ( $templates as $template ) {
50
+
51
+ $template_kit_folder_name = $template_kit->get_template_kit_temporary_folder();
52
+ $template_json_file = $template_kit_folder_name . $template['source'];
53
+
54
+ $elementor_meta = json_decode( file_get_contents( $template_json_file ), true );
55
+ if ( $elementor_meta ) {
56
+ $iterator = new \RecursiveIteratorIterator( new \RecursiveArrayIterator( $elementor_meta ) );
57
+ $element_type = 'widget';
58
+ foreach ( $iterator as $key => $val ) {
59
+ if ( 'elType' === $key ) {
60
+ $element_type = $val;
61
+ }
62
+ if ( 'custom_css' === $key && strlen( $val ) > 0 ) {
63
+ // Look for any Custom CSS coming in from Elementor Pro:
64
+ $template_errors[] = 'Please remove Custom CSS from the ' . $element_type . ' in template: ' . $template['name'];
65
+ } elseif ( '_element_id' === $key && strlen( $val ) > 0 ) {
66
+ // Error if the user has set a custom element ID on any element
67
+ $template_errors[] = 'Please remove Custom ID value "' . $val . '" from the ' . $element_type . ' in template: ' . $template['name'];
68
+ } elseif ( '_css_classes' === $key && strlen( $val ) > 0 ) {
69
+ // Error if hte user has set a custom classname on any element
70
+ $template_errors[] = 'Please remove Custom Class value "' . $val . '" from the ' . $element_type . ' in template: ' . $template['name'];
71
+ } elseif ( preg_match_all( '#(https?://[\w\d\-./]+)+#', $val, $matches ) ) {
72
+ // a basic white list of allowed external urls here:
73
+ foreach ( $matches[1] as $match ) {
74
+ if ( ! strpos( $match, 'youtube.com' )
75
+ && ! strpos( $match, 'wp-content/uploads/' )
76
+ && ! strpos( $match, 'vimeo.com' )
77
+ ) {
78
+ $template_errors[] = 'Please remove external URL "' . $match . '" from the ' . $element_type . ' in template: ' . $template['name'];
79
+ }
80
+ }
81
+ }
82
+ // Hunt for mailto links:
83
+ if ( preg_match_all( '#mailto:\w+#', $val, $matches ) ) {
84
+ foreach ( $matches[0] as $match ) {
85
+ $template_errors[] = 'Please remove the Email link "' . $match . '" from the ' . $element_type . ' in template: ' . $template['name'];
86
+ }
87
+ }
88
+ // Hunt for inline styles:
89
+ if ( preg_match_all( '#style=[\'"]([^\'"]+)[\'"]#imsU', $val, $matches ) ) {
90
+ foreach ( $matches[1] as $match ) {
91
+ $template_errors[] = 'Please remove any inline style="' . esc_html( $match ) . '" from ' . $template['name'];
92
+ }
93
+ }
94
+ // Hunt for inline class names
95
+ if ( preg_match_all( '#class=[\'"]([^\'"]+)[\'"]#imsU', $val, $matches ) ) {
96
+ $allowed_built_in_classes = array(
97
+ 'size-',
98
+ 'wp-image',
99
+ 'align',
100
+ );
101
+ foreach ( $matches[1] as $match ) {
102
+ if ( str_replace( $allowed_built_in_classes, '', $match ) === $match ) {
103
+ $template_errors[] = 'Please remove any inline class="' . esc_html( $match ) . '" from ' . $template['name'];
104
+ }
105
+ }
106
+ }
107
+ // Hunt for onclick event handlers:
108
+ if ( preg_match_all( '#(on\w+)=[\'"]([^\'"]+)[\'"]#imsU', $val, $matches ) ) {
109
+ foreach ( $matches[1] as $onclick ) {
110
+ $template_errors[] = 'No ' . esc_html( $onclick ) . ' allowed in: ' . $template['name'];
111
+ }
112
+ }
113
+ if ( preg_match_all( '#<script[^>]*>(.*)<#imsU', $val, $matches ) ) {
114
+ foreach ( $matches[1] as $match ) {
115
+ $template_errors[] = 'No script tags allowed in: ' . $template['name'];
116
+ }
117
+ }
118
+ if ( preg_match_all( '/<(link|meta|div|span|table)[^>]*>/', $val, $matches ) ) {
119
+ foreach ( $matches[0] as $match ) {
120
+ if ( strlen( $match ) > 1 ) {
121
+ $template_errors[] = 'Please remove any custom HTML tags: ' . esc_html( $match ) . ': ' . $template['name'];
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+ ?>
130
+ <ul>
131
+ <?php
132
+ foreach ( $template_errors as $template_error ) {
133
+ ?>
134
+ <li>
135
+ <?php echo '<strong>ERROR:</strong> ' . esc_html( $template_error ); ?>
136
+ </li>
137
+ <?php } ?>
138
+ </ul>
139
+ </div>
140
+ <div>
141
+ <h2>Large Images:</h2>
142
+ <?php
143
+ $bad_images = array();
144
+ foreach ( $manifest['images'] as $image ) {
145
+ if ( ! empty( $image['dimensions'] ) ) {
146
+ if ( $image['dimensions'][0] > 3000 ) {
147
+ $bad_images[] = 'Image ' . $image['filename'] . ' is ' . $image['dimensions'][0] . 'px wide, it probably doesn\'t need to be this big.';
148
+ }
149
+ if ( $image['dimensions'][1] > 3000 ) {
150
+ $bad_images[] = 'Image ' . $image['filename'] . ' is ' . $image['dimensions'][1] . 'px tall, it probably doesn\'t need to be this big.';
151
+ }
152
+ } else {
153
+ $bad_images[] = 'Image ' . $image['filename'] . ' has no dimensions, author needs to re-export kit in latest Export plugin.';
154
+ }
155
+ if ( ! empty( $image['filesize'] ) ) {
156
+ if ( $image['filesize'] > 900000 ) {
157
+ $bad_images[] = 'Image ' . $image['filename'] . ' is ' . number_format( $image['filesize'] / 1048576, 2 ) . 'MB, it probably doesn\'t need to be this big.';
158
+ }
159
+ } else {
160
+ $bad_images[] = 'Image ' . $image['filename'] . ' has no file size, author needs to re-export kit in latest Export plugin.';
161
+ }
162
+ }
163
+ if ( ! $bad_images ) {
164
+ echo 'None found, yay!';
165
+ } else {
166
+ ?>
167
+ <ul>
168
+ <?php foreach ( $bad_images as $bad_image ) { ?>
169
+ <li><?php echo esc_html( $bad_image ); ?></li>
170
+ <?php } ?>
171
+ </ul>
172
+ <?php
173
+ }
174
+ ?>
175
+ </div>
176
+ <div>
177
+ <h2>Templates:</h2>
178
+ <table class="widefat striped">
179
+ <thead>
180
+ <tr>
181
+ <th>Template Name</th>
182
+ <th>Screenshot</th>
183
+ <th>Author Demo URL</th>
184
+ <th>Review</th>
185
+ </tr>
186
+ </thead>
187
+ <tbody>
188
+ <?php
189
+ foreach ( $templates as $template ) {
190
+ ?>
191
+ <tr>
192
+ <td>
193
+ <?php echo esc_html( $template['name'] ); ?>
194
+ </td>
195
+ <td>
196
+ <div style="max-height: 200px; overflow: hidden;">
197
+ <a href="<?php echo esc_url( $template['screenshot_url'] ); ?>" target="_blank" rel="nofollow noreferrer">
198
+ <img width="200" src="<?php echo esc_url( $template['screenshot_url'] ); ?>" alt="<?php echo esc_attr( $template['name'] ); ?>" />
199
+ </a>
200
+ </div>
201
+ </td>
202
+ <td>
203
+ <a href="<?php echo esc_url( $template['preview_url'] ); ?>" target="_blank" rel="nofollow noreferrer"><?php echo esc_html( $template['preview_url'] ); ?></a>
204
+ </td>
205
+ <td>
206
+ <ul>
207
+ <li>Pro Required: <strong><?php echo ! empty( $template['elementor_pro_required'] ) ? 'YES' : 'No'; ?></strong></li>
208
+ <li>Elementor Type: <strong><?php echo esc_html( $template['type'] ); ?></strong></li>
209
+ <?php if ( ! empty( $template['metadata'] ) && is_array( $template['metadata'] ) ) { ?>
210
+ <li>Author Type: <strong><?php echo esc_html( $template['metadata']['template_type'] ); ?></strong></li>
211
+ <?php if ( ! empty( $template['metadata']['additional_template_information'] ) ) { ?>
212
+ <?php foreach ( $template['metadata']['additional_template_information'] as $message ) { ?>
213
+ <li>Message: <strong><?php echo esc_html( $message ); ?></strong></li>
214
+ <?php } ?>
215
+ <?php } ?>
216
+ <?php if ( ! empty( $template['metadata']['elementor_pro_conditions'] ) ) { ?>
217
+ <?php foreach ( $template['metadata']['elementor_pro_conditions'] as $message ) { ?>
218
+ <li>Pro Display Condition: <strong><?php echo esc_html( $message ); ?></strong></li>
219
+ <?php } ?>
220
+ <?php } ?>
221
+ <?php } ?>
222
+ </ul>
223
+ </td>
224
+ </tr>
225
+ <?php } ?>
226
+ </tbody>
227
+ </table>
228
+ </div>
229
+ <div>
230
+ <h2>Images:</h2>
231
+ <table class="widefat striped">
232
+ <thead>
233
+ <tr>
234
+ <th>File Name &amp; Sizes</th>
235
+ <th>Author Preview URL</th>
236
+ <th>Used On Templates</th>
237
+ <th>Image Source</th>
238
+ <th>Person or Place</th>
239
+ <th>Image URLs</th>
240
+ </tr>
241
+ </thead>
242
+ <tbody>
243
+ <?php
244
+ foreach ( $manifest['images'] as $image ) {
245
+ ?>
246
+ <tr>
247
+ <td>
248
+ <?php echo esc_html( $image['filename'] ); ?>
249
+ <br/>
250
+ <br/>
251
+ (<?php echo esc_html( $image['dimensions'][0] . 'x' . $image['dimensions'][1] . 'px @ ' . number_format( $image['filesize'] / 1048576, 2 ) . ' MB' ); ?>)
252
+ </td>
253
+ <td>
254
+ <div style="max-height: 200px; max-width: 300px; overflow: hidden; text-align: center">
255
+ <a href="<?php echo esc_url( $image['thumbnail_url'] ); ?>" target="_blank" rel="nofollow noreferrer">
256
+ <?php echo esc_html( $image['thumbnail_url'] ); ?> <br/>
257
+ <img width="200" src="<?php echo esc_url( $image['thumbnail_url'] ); ?>" alt="<?php echo esc_attr( $image['filename'] ); ?>" />
258
+ </a>
259
+ </div>
260
+ </td>
261
+ <td>
262
+ <ul>
263
+ <?php
264
+ if ( ! empty( $image['templates'] ) && is_array( $image['templates'] ) ) {
265
+ foreach ( $image['templates'] as $image_template ) {
266
+ ?>
267
+ <li>
268
+ <?php echo esc_html( $image_template['name'] ); ?>
269
+ </li>
270
+ <?php
271
+ }
272
+ }
273
+ ?>
274
+ </ul>
275
+ </td>
276
+ <td>
277
+ <?php echo esc_html( $image['image_source'] ); ?>
278
+ </td>
279
+ <td>
280
+ <?php echo esc_html( $image['person_or_place'] ); ?>
281
+ </td>
282
+ <td>
283
+ <?php echo esc_html( $image['image_urls'] ); ?>
284
+ </td>
285
+ </tr>
286
+ <?php } ?>
287
+ </tbody>
288
+ </table>
289
+ </div>
views/wrapper.php CHANGED
@@ -19,7 +19,13 @@ if ( ! defined( 'ABSPATH' ) ) {
19
 
20
  <div class="envato-template-kit-import__wrapper">
21
  <div class="envato-template-kit-import__header">
22
- <h1>Template Kit - Import</h1>
 
 
 
 
 
 
23
  <p>Use this plugin to Import a Template Kit.</p>
24
  <div class="envato-template-kit-import__header-logo">
25
  <svg width="27" height="31" viewBox="0 0 27 31" fill="none" xmlns="http://www.w3.org/2000/svg">
19
 
20
  <div class="envato-template-kit-import__wrapper">
21
  <div class="envato-template-kit-import__header">
22
+ <h1>Template Kit - Import
23
+ <?php
24
+ if ( defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV ) {
25
+ echo ' (Reviewer Mode)';
26
+ }
27
+ ?>
28
+ </h1>
29
  <p>Use this plugin to Import a Template Kit.</p>
30
  <div class="envato-template-kit-import__header-logo">
31
  <svg width="27" height="31" viewBox="0 0 27 31" fill="none" xmlns="http://www.w3.org/2000/svg">