ThemeGrill Demo Importer - Version 1.3.4

Version Description

  • Feature - Support RTL for Importer.
  • Feature - Reset wizard for clean up.
  • Fixed - Undefined queue job update action.
  • Fixed - Use of wp-heading-inline core class.
  • Tweak - Use of defined constant for demo packs.
  • Tweak - Uninstall data with a defined constant.
  • Tweak - Fallback screenshot for flash demo preview.

See changelog for all versions.

Download this release

Release Info

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

Code changes from version 1.3.3 to 1.3.4

.wordpress-org/banner-772x250.jpg ADDED
Binary file
CHANGELOG.txt ADDED
@@ -0,0 +1,31 @@
1
+ == Changelog ==
2
+
3
+ = 1.3.3 =
4
+ * Tweak - Support demo import for suffice theme.
5
+
6
+ = 1.3.2 =
7
+ * Tweak - Load screenshots for pro theme demos.
8
+
9
+ = 1.3.1 =
10
+ * Tweak - Load screenshot from theme instead of plugin for themes with single demo.
11
+
12
+ = 1.3.0 =
13
+ * Tweak - Support data update for nested siteorigin layoutbuilder.
14
+ * Fix - Import button not working on firefox.
15
+
16
+ = 1.2.0 =
17
+ * Tweak - Load scripts perfecly on demo importer appearance page.
18
+ * Tweak - Set transient for redirecting to demo importer page after install or update.
19
+ * Tweak - Introduced filter hook `themegrill_demo_importer_installer` to control demo view.
20
+
21
+ = 1.1.0 =
22
+ * Feature - Backbone views interface for demos and previews
23
+ * Feature - Added download button for the preview not installed
24
+ * Feature - Robust quick search view to change in demo interface
25
+ * Feature - Detailed information in popup to showcase plugins, events, etc
26
+ * Refactor - Replace old way to import demo with new `wp.updates` methods
27
+ * Fix - Menu classes to hide admin menu if no JS using css class `hide-if-no-js`
28
+ * Fix - Remove the old demo pack if found and to update the new demo packs
29
+
30
+ = 1.0.0 =
31
+ * Initial Public Release
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@themegrill.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
assets/css/demo-importer-rtl.css ADDED
@@ -0,0 +1 @@
1
+ .appearance_page_demo-importer .demo-importer h1{margin-bottom:15px}.appearance_page_demo-importer .demo-importer .search-form{display:inline}.appearance_page_demo-importer .demo-importer .wp-filter-search{position:relative;top:-2px;right:20px;margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5}.appearance_page_demo-importer .demo-installer .wp-filter{padding:0 20px}.appearance_page_demo-importer .demo-installer .wp-filter .filter-links li>a:focus{box-shadow:none}.appearance_page_demo-importer .demo-installer .welcome-panel{margin:0;background:#e9eff3;border:10px solid #fff;box-shadow:none}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content{width:45%;float:right}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content .welcome-panel-column{width:100%}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content .welcome-panel-column ul{padding-right:10px}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video{float:left;width:50%}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video .welcome-panel-iframe-video-inner{position:relative;height:0;margin:0 10px 23px;padding-bottom:56.25%;border:5px solid #dadada}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video .welcome-panel-iframe-video-inner iframe{position:absolute;top:0;right:0;width:100%;height:100%}.appearance_page_demo-importer .demo-installer .premium-ribbon{overflow:hidden}.appearance_page_demo-importer .demo-installer .premium-ribbon::after{background-color:#24b37e;border:1px solid #069c64;box-shadow:0 0 4px rgba(255,255,255,.5) inset,0 1px 3px rgba(0,0,0,.3);color:#fff;content:'PRO';font-size:16px;font-weight:700;padding:5px 30px;position:absolute;left:-30px;top:6px;-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}table.plugins-list-table{margin-bottom:1em}table.plugins-list-table tr:nth-child(2n) td{background:#fcfcfc}table.plugins-list-table th{padding:9px;font-weight:600}table.plugins-list-table td{padding:9px;font-size:1.1em}table.plugins-list-table td mark{background:transparent none}table.plugins-list-table td mark.yes{color:#7ad03a}table.plugins-list-table td mark.no{color:#999}table.plugins-list-table td mark.error{color:#a00}table.plugins-list-table .plugin-status{text-align:center}.tips{cursor:help;text-decoration:none}img.tips{padding:5px 0 0}#tiptip_holder{display:none;z-index:8675309;position:absolute;top:0;left:0}#tiptip_holder.tip_top{padding-bottom:5px}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-right:-6px;border-top-color:#333}#tiptip_holder.tip_bottom{padding-top:5px}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-right:-6px;border-bottom-color:#333}#tiptip_holder.tip_right{padding-right:5px}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-right:-5px;border-left-color:#333}#tiptip_holder.tip_left{padding-left:5px}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-right:-7px;border-right-color:#333}#tiptip_content{color:#fff;font-size:.8em;max-width:150px;background:#333;text-align:center;border-radius:3px;padding:.618em 1em;box-shadow:0 1px 3px rgba(0,0,0,.2)}#tiptip_content code{padding:1px;background:#888}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}#tiptip_arrow{right:50%;margin-right:-6px}@media screen and (max-width:500px){.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content,.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video{float:none;width:100%}}
assets/css/demo-importer.css CHANGED
@@ -1 +1 @@
1
- #tiptip_content,table.plugins-list-table .plugin-status{text-align:center}.appearance_page_demo-importer .demo-importer h1{margin-bottom:15px}.appearance_page_demo-importer .demo-importer .wp-filter-search{position:relative;top:-2px;left:20px;margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5}.appearance_page_demo-importer .demo-installer .wp-filter{padding:0 20px}.appearance_page_demo-importer .demo-installer .wp-filter .filter-links li>a:focus{box-shadow:none}.appearance_page_demo-importer .demo-installer .welcome-panel{margin:0}table.plugins-list-table{margin-bottom:1em}table.plugins-list-table tr:nth-child(2n) td{background:#fcfcfc}table.plugins-list-table th{padding:9px;font-weight:600}table.plugins-list-table td{padding:9px;font-size:1.1em}table.plugins-list-table td mark{background:0 0}table.plugins-list-table td mark.yes{color:#7ad03a}table.plugins-list-table td mark.no{color:#999}table.plugins-list-table td mark.error{color:#a00}.tips{cursor:help;text-decoration:none}img.tips{padding:5px 0 0}#tiptip_holder{display:none;position:absolute;top:0;left:0;z-index:9999999}#tiptip_holder.tip_top{padding-bottom:5px}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#333}#tiptip_holder.tip_bottom{padding-top:5px}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#333}#tiptip_holder.tip_right{padding-left:5px}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#333}#tiptip_holder.tip_left{padding-right:5px}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#333}#tiptip_content{color:#fff;font-size:.8em;max-width:150px;background:#333;border-radius:3px;padding:.618em 1em;box-shadow:0 1px 3px rgba(0,0,0,.2)}#tiptip_content code{padding:1px;background:#888}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}.premium-ribbon{overflow:hidden}.premium-ribbon:after{background-color:#24b37e;border:1px solid #069c64;box-shadow:0 0 4px rgba(255,255,255,.5) inset,0 1px 3px rgba(0,0,0,.3);color:#fff;content:"PRO";font-size:16px;font-weight:700;padding:5px 30px;position:absolute;right:-30px;top:6px;transform:rotate(45deg)}
1
+ .appearance_page_demo-importer .demo-importer h1{margin-bottom:15px}.appearance_page_demo-importer .demo-importer .search-form{display:inline}.appearance_page_demo-importer .demo-importer .wp-filter-search{position:relative;top:-2px;left:20px;margin:0;width:280px;font-size:16px;font-weight:300;line-height:1.5}.appearance_page_demo-importer .demo-installer .wp-filter{padding:0 20px}.appearance_page_demo-importer .demo-installer .wp-filter .filter-links li>a:focus{box-shadow:none}.appearance_page_demo-importer .demo-installer .welcome-panel{margin:0;background:#e9eff3;border:10px solid #fff;box-shadow:none}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content{width:45%;float:left}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content .welcome-panel-column{width:100%}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content .welcome-panel-column ul{padding-left:10px}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video{float:right;width:50%}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video .welcome-panel-iframe-video-inner{position:relative;height:0;margin:0 10px 23px;padding-bottom:56.25%;border:5px solid #dadada}.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video .welcome-panel-iframe-video-inner iframe{position:absolute;top:0;left:0;width:100%;height:100%}.appearance_page_demo-importer .demo-installer .premium-ribbon{overflow:hidden}.appearance_page_demo-importer .demo-installer .premium-ribbon::after{background-color:#24b37e;border:1px solid #069c64;box-shadow:0 0 4px rgba(255,255,255,.5) inset,0 1px 3px rgba(0,0,0,.3);color:#fff;content:'PRO';font-size:16px;font-weight:700;padding:5px 30px;position:absolute;right:-30px;top:6px;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}table.plugins-list-table{margin-bottom:1em}table.plugins-list-table tr:nth-child(2n) td{background:#fcfcfc}table.plugins-list-table th{padding:9px;font-weight:600}table.plugins-list-table td{padding:9px;font-size:1.1em}table.plugins-list-table td mark{background:transparent none}table.plugins-list-table td mark.yes{color:#7ad03a}table.plugins-list-table td mark.no{color:#999}table.plugins-list-table td mark.error{color:#a00}table.plugins-list-table .plugin-status{text-align:center}.tips{cursor:help;text-decoration:none}img.tips{padding:5px 0 0}#tiptip_holder{display:none;z-index:8675309;position:absolute;top:0;left:0}#tiptip_holder.tip_top{padding-bottom:5px}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#333}#tiptip_holder.tip_bottom{padding-top:5px}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#333}#tiptip_holder.tip_right{padding-left:5px}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#333}#tiptip_holder.tip_left{padding-right:5px}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#333}#tiptip_content{color:#fff;font-size:.8em;max-width:150px;background:#333;text-align:center;border-radius:3px;padding:.618em 1em;box-shadow:0 1px 3px rgba(0,0,0,.2)}#tiptip_content code{padding:1px;background:#888}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}@media screen and (max-width:500px){.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-content,.appearance_page_demo-importer .demo-installer .welcome-panel .welcome-panel-iframe-video{float:none;width:100%}}
assets/css/demo-importer.scss CHANGED
@@ -3,11 +3,6 @@
3
* General ThemeGrill Demo Importer admin styles.
4
*/
5
6
- /**
7
- * Imports
8
- */
9
- @import 'bourbon';
10
-
11
/**
12
* Styling begins
13
*/
@@ -17,6 +12,10 @@
17
margin-bottom: 15px;
18
}
19
20
.wp-filter-search {
21
position: relative;
22
top: -2px;
@@ -40,6 +39,62 @@
40
41
.welcome-panel {
42
margin: 0;
43
}
44
}
45
}
@@ -98,13 +153,12 @@ img.tips {
98
99
#tiptip_holder {
100
display: none;
101
position: absolute;
102
top: 0;
103
left: 0;
104
- z-index: 9999999;
105
- }
106
107
- #tiptip_holder {
108
&.tip_top {
109
padding-bottom: 5px;
110
@@ -171,21 +225,27 @@ img.tips {
171
height: 0;
172
width: 0;
173
}
174
- .premium-ribbon {
175
- overflow: hidden;
176
-
177
- &:after {
178
- background-color: #24b37e;
179
- border: 1px solid #069c64;
180
- box-shadow: 0 0 4px rgba(255,255,255,0.5) inset, 0 1px 3px rgba(0,0,0,0.3);
181
- color: #fff;
182
- content: "PRO";
183
- font-size: 16px;
184
- font-weight: 700;
185
- padding: 5px 30px;
186
- position: absolute;
187
- right: -30px;
188
- top: 6px;
189
- transform: rotate(45deg);
190
}
191
}
3
* General ThemeGrill Demo Importer admin styles.
4
*/
5
6
/**
7
* Styling begins
8
*/
12
margin-bottom: 15px;
13
}
14
15
+ .search-form {
16
+ display: inline;
17
+ }
18
+
19
.wp-filter-search {
20
position: relative;
21
top: -2px;
39
40
.welcome-panel {
41
margin: 0;
42
+ background: #e9eff3;
43
+ border: 10px solid #fff;
44
+ box-shadow: none;
45
+
46
+ .welcome-panel-content {
47
+ width: 45%;
48
+ float: left;
49
+
50
+ .welcome-panel-column {
51
+ width: 100%;
52
+
53
+ ul {
54
+ padding-left: 10px;
55
+ }
56
+ }
57
+ }
58
+
59
+ .welcome-panel-iframe-video {
60
+ float: right;
61
+ width: 50%;
62
+
63
+ .welcome-panel-iframe-video-inner {
64
+ position: relative;
65
+ height: 0;
66
+ margin: 0 10px 23px;
67
+ padding-bottom: 56.25%; /* 16:9 */
68
+ border: 5px solid #dadada;
69
+
70
+ iframe {
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ height: 100%;
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ .premium-ribbon {
82
+ overflow: hidden;
83
+
84
+ &::after {
85
+ background-color: #24b37e;
86
+ border: 1px solid #069c64;
87
+ box-shadow: 0 0 4px rgba( 255, 255, 255, 0.5 ) inset, 0 1px 3px rgba( 0, 0, 0, 0.3 );
88
+ color: #fff;
89
+ content: 'PRO';
90
+ font-size: 16px;
91
+ font-weight: 700;
92
+ padding: 5px 30px;
93
+ position: absolute;
94
+ right: -30px;
95
+ top: 6px;
96
+ transform: rotate( 45deg );
97
+ }
98
}
99
}
100
}
153
154
#tiptip_holder {
155
display: none;
156
+ z-index: 8675309;
157
position: absolute;
158
top: 0;
159
+ /*rtl:ignore*/
160
left: 0;
161
162
&.tip_top {
163
padding-bottom: 5px;
164
225
height: 0;
226
width: 0;
227
}
228
+
229
+ /*rtl:raw:
230
+ #tiptip_arrow {
231
+ right: 50%;
232
+ margin-right: -6px;
233
+ }
234
+ */
235
+
236
+ /**
237
+ * Optimisation for screens 500px and smaller
238
+ */
239
+ @media screen and (max-width: 500px) {
240
+ .appearance_page_demo-importer {
241
+ .demo-installer {
242
+ .welcome-panel {
243
+ .welcome-panel-content,
244
+ .welcome-panel-iframe-video {
245
+ float: none;
246
+ width: 100%;
247
+ }
248
+ }
249
+ }
250
}
251
}
assets/images/flash/flash-pro-agency.jpg ADDED
Binary file
assets/images/flash/flash-pro-band.jpg ADDED
Binary file
assets/js/admin/demo-importer.js CHANGED
@@ -86,7 +86,7 @@ demos.view.Appearance = wp.Backbone.View.extend({
86
},
87
88
// Defines search element container
89
- searchContainer: $( '#wpbody h1:first' ),
90
91
// Search input and view
92
// for current demo collection
@@ -258,6 +258,7 @@ demos.view.Demo = wp.Backbone.View.extend({
258
259
render: function() {
260
var data = this.model.toJSON();
261
// Render demos using the html template
262
this.$el.html( this.html( data ) ).attr({
263
tabindex: 0,
@@ -265,17 +266,17 @@ demos.view.Demo = wp.Backbone.View.extend({
265
'data-slug': data.id
266
});
267
268
- //add ribbon class
269
- if ( this.model.get( 'actions' ).pro_link ) {
270
- this.$el.html( this.html( data ) ).addClass( 'premium-ribbon' );
271
- }
272
-
273
// Renders active demo styles
274
this.activeDemo();
275
276
if ( this.model.get( 'displayAuthor' ) ) {
277
this.$el.addClass( 'display-author' );
278
}
279
},
280
281
// Adds a class to the currently active demo
@@ -1070,10 +1071,6 @@ demos.view.Installer = demos.view.Appearance.extend({
1070
this.$el.find( '.theme-browser' ).append( this.view.el ).addClass( 'rendered' );
1071
},
1072
1073
- // Overwrite search container class to append search
1074
- // in new location
1075
- searchContainer: $( '.wp-filter .search-form' ),
1076
-
1077
/*
1078
* When users press the "Upload Theme" button, show the upload form in place.
1079
*/
@@ -1206,23 +1203,28 @@ $( document ).ready( function() {
1206
demos.Run.init();
1207
}
1208
1209
- // Dismissible notice.
1210
- $( '.notice.is-dismissible' ).on( 'click', '.notice-dismiss', function( event ) {
1211
var $this_el = $( this );
1212
1213
- event.preventDefault();
1214
-
1215
- if ( $this_el.parent().attr( 'id' ) === 'undefined' ) {
1216
- return;
1217
- }
1218
-
1219
$.post( demos.data.settings.ajaxUrl, {
1220
- action: 'dismiss-notice',
1221
- notice_id: $this_el.parent().data( 'notice_id' )
1222
});
1223
1224
- return false;
1225
} );
1226
});
1227
1228
})( jQuery );
86
},
87
88
// Defines search element container
89
+ searchContainer: $( '.search-form' ),
90
91
// Search input and view
92
// for current demo collection
258
259
render: function() {
260
var data = this.model.toJSON();
261
+
262
// Render demos using the html template
263
this.$el.html( this.html( data ) ).attr({
264
tabindex: 0,
266
'data-slug': data.id
267
});
268
269
// Renders active demo styles
270
this.activeDemo();
271
272
if ( this.model.get( 'displayAuthor' ) ) {
273
this.$el.addClass( 'display-author' );
274
}
275
+
276
+ // Append ribbon class
277
+ if ( this.model.get( 'actions' ).pro_link ) {
278
+ this.$el.html( this.html( data ) ).addClass( 'premium-ribbon' );
279
+ }
280
},
281
282
// Adds a class to the currently active demo
1071
this.$el.find( '.theme-browser' ).append( this.view.el ).addClass( 'rendered' );
1072
},
1073
1074
/*
1075
* When users press the "Upload Theme" button, show the upload form in place.
1076
*/
1203
demos.Run.init();
1204
}
1205
1206
+ // Rating footer.
1207
+ $( '.themegrill-demo-importer-rating-link' ).on( 'click', function() {
1208
var $this_el = $( this );
1209
1210
$.post( demos.data.settings.ajaxUrl, {
1211
+ action: 'footer-text-rated'
1212
});
1213
1214
+ $this_el.parent().text( $this_el.data( 'rated' ) );
1215
} );
1216
+
1217
+ // Confirm WordPress reset wizard.
1218
+ $( '.themegrill-reset-wordpress' ).on( 'click', function() {
1219
+ return window.confirm( demos.data.settings.confirmReset );
1220
+ });
1221
+
1222
+ // Load videos when help button is clicked.
1223
+ $( '#contextual-help-link' ).on( 'click', function() {
1224
+ var frame = $( '#tab-panel-themegrill_demo_importer_guided_tour_tab iframe' );
1225
+
1226
+ frame.attr( 'src', frame.data( 'src' ) );
1227
+ });
1228
});
1229
1230
})( jQuery );
assets/js/admin/demo-importer.min.js CHANGED
@@ -1 +1 @@
1
- window.wp=window.wp||{},function(a){var b,c;b=wp.demos=wp.demos||{},b.data=demoImporterLocalizeScript,c=b.data.l10n,b.isPreview=!!b.data.settings.isPreview,b.isInstall=!!b.data.settings.isInstall,_.extend(b,{model:{},view:{},routes:{},router:{},template:wp.template}),b.Model=Backbone.Model.extend({initialize:function(){var a;_.indexOf(b.data.installedDemos,this.get("slug"))!==-1&&this.set({installed:!0}),this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(a=this.get("sections").description,this.set({description:a}))}}),b.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:a(window),page:0,initialize:function(a){_.bindAll(this,"scroller"),this.SearchView=a.SearchView?a.SearchView:b.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new b.view.Demos({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:a("#wpbody h1:first"),search:function(){var d,e=this;1!==b.data.demos.length&&(d=new this.SearchView({collection:e.collection,parent:this}),d.render(),this.searchContainer.append(a.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+c.search+"</label>")).append(d.el))},scroller:function(){var a,b,c=this;a=this.window.scrollTop()+c.window.height(),b=c.$el.offset().top+c.$el.outerHeight(!1)-c.window.height(),b=Math.round(.9*b),a>b&&this.trigger("demo:scroll")},initTipTip:function(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:50})}}),b.Collection=Backbone.Collection.extend({model:b.Model,terms:"",doSearch:function(c){this.terms!==c&&(this.terms=c,this.terms.length>0&&this.search(this.terms),""===this.terms&&(this.reset(b.data.demos),a("body").removeClass("no-results")),this.trigger("demos:update"))},search:function(c){var d,e,f,g,h,i;this.reset(b.data.demos,{silent:!0}),c=c.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\amp;"),c=c.replace(/ /g,")(?=.*"),d=new RegExp("^(?=.*"+c+").+","i"),e=this.filter(function(a){return g=a.get("name").replace(/(<([^>]+)>)/gi,""),h=a.get("description").replace(/(<([^>]+)>)/gi,""),i=a.get("author").replace(/(<([^>]+)>)/gi,""),f=_.union([g,a.get("id"),h,i,a.get("tags")]),d.test(a.get("author"))&&c.length>2&&a.set("displayAuthor",!0),d.test(f)}),0===e.length?this.trigger("query:empty"):a("body").removeClass("no-results"),this.reset(e)},paginate:function(a){var b=this;return a=a||0,b=_(b.rest(20*a)),b=_(b.first(20))}}),b.view.Demo=wp.Backbone.View.extend({className:"theme",state:"grid",html:b.template(b.isPreview?"demo-preview":"demo"),events:{click:"expand",keydown:"expand",touchend:"expand",keyup:"addFocus",touchmove:"preventExpand","click .demo-import":"importDemo"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)).attr({tabindex:0,"aria-describedby":a.id+"-action "+a.id+"-name","data-slug":a.id}),this.model.get("actions").pro_link&&this.$el.html(this.html(a)).addClass("premium-ribbon"),this.activeDemo(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeDemo:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var b=a(":focus").hasClass("theme")?a(":focus"):a(":focus").parents(".theme");a(".theme.focus").removeClass("focus"),b.addClass("focus")},expand:function(c){var d=this;if(!b.isPreview&&(c=c||window.event,"keydown"!==c.type||13===c.which||32===c.which))return this.touchDrag===!0?this.touchDrag=!1:void(a(c.target).is(".theme-actions a")||a(c.target).is(".theme-actions a, .update-message, .button-link, .notice-dismiss")||(b.focusedDemo=this.$el,this.trigger("demo:expand",d.model.cid)))},preventExpand:function(){this.touchDrag=!0},importDemo:function(b){var c=this,d=a(b.target);b.preventDefault(),d.hasClass("disabled")||window.confirm(wp.demos.data.settings.confirmImport)&&(a(document).on("wp-demo-import-success",function(a,b){c.model.get("id")===b.slug&&c.model.set({imported:!0})}),wp.updates.importDemo({slug:d.data("slug")}))}}),b.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-demo":"deleteDemo","click .left":"previousDemo","click .right":"nextDemo","click .demo-import":"importDemo"},html:b.template("demo-single"),render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeDemo(),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el)},activeDemo:function(){this.$el.toggleClass("active",this.model.get("active"))},containFocus:function(b){_.delay(function(){a(".theme-wrap a.button-primary:visible").focus()},100),b.on("keydown.wp-themes",function(a){var c=b.find(".theme-header button:not(.disabled)").first(),d=b.find(".theme-actions a:visible").last();9===a.which&&(c[0]===a.target&&a.shiftKey?(d.focus(),a.preventDefault()):d[0]!==a.target||a.shiftKey||(c.focus(),a.preventDefault()))})},collapse:function(c){var d,e=this;c=c||window.event,1!==b.data.demos.length&&(a(c.target).is(".theme-backdrop")||a(c.target).is(".close")||27===c.keyCode)&&(a("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){a("body").removeClass("closing-overlay"),e.closeOverlay(),d=document.body.scrollTop,b.router.navigate(b.router.baseUrl("")),document.body.scrollTop=d,b.focusedDemo&&b.focusedDemo.focus()}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled").prop("disabled",!0),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled").prop("disabled",!0)},closeOverlay:function(){a("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("demo:collapse")},importDemo:function(b){var c=this,d=a(b.target);b.preventDefault(),d.hasClass("disabled")||window.confirm(wp.demos.data.settings.confirmImport)&&(a(document).on("wp-demo-import-success",function(a,b){c.model.get("id")===b.slug&&c.model.set({imported:!0})}),a(document).on("wp-updates-queue-job",function(a,b){"import-demo"===b.action&&wp.updates.importDemo(b.data)}),wp.updates.importDemo({slug:d.data("slug")}))},deleteDemo:function(c){var d=this,e=this.model.collection,f=b;c.preventDefault(),window.confirm(wp.demos.data.settings.confirmDelete)&&(wp.updates.maybeRequestFilesystemCredentials(c),a(document).one("wp-demo-delete-success",function(b,c){d.$el.find(".close").trigger("click"),a('[data-slug="'+c.slug+'"').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){a(this).remove(),f.data.demos=_.without(f.data.demos,_.findWhere(f.data.demos,{id:c.slug})),a(".wp-filter-search").val(""),e.doSearch(""),e.remove(d.model),e.trigger("demos:update")})}),wp.updates.deleteDemo({slug:this.model.get("id")}))},nextDemo:function(){var a=this;return a.trigger("demo:next",a.model.cid),!1},previousDemo:function(){var a=this;return a.trigger("demo:previous",a.model.cid),!1},screenshotCheck:function(a){var b,c;b=a.find(".screenshot img"),c=new Image,c.src=b.attr("src"),c.width&&c.width<=300&&a.addClass("small-screenshot")}}),b.view.Demos=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:a("div.theme-overlay"),index:0,count:a(".wrap .demo-count"),liveDemoCount:0,initialize:function(b){var c=this;this.parent=b.parent,c.importedDemo(),this.setView("grid"),this.listenTo(c.collection,"demos:update",function(){c.parent.page=0,c.importedDemo(),c.render(this),c.parent.initTipTip()}),this.listenTo(c.collection,"query:success",function(a){_.isNumber(a)?(c.count.text(a),c.announceSearchResults(a)):(c.count.text(c.collection.length),c.announceSearchResults(c.collection.length))}),this.listenTo(c.collection,"query:empty",function(){a("body").addClass("no-results")}),this.listenTo(this.parent,"demo:scroll",function(){c.renderDemos(c.parent.page)}),this.listenTo(this.parent,"demo:close",function(){c.overlay&&c.overlay.closeOverlay()}),a("body").on("keyup",function(b){c.overlay&&(a("#request-filesystem-credentials-dialog").is(":visible")||(39===b.keyCode&&c.overlay.nextDemo(),37===b.keyCode&&c.overlay.previousDemo(),27===b.keyCode&&c.overlay.collapse(b)))})},render:function(){this.$el.empty(),b.isPreview||1!==b.data.demos.length||(this.singleDemo=new b.view.Details({model:this.collection.models[0]}),this.singleDemo.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleDemo.el)),this.options.collection.size()>0&&this.renderDemos(this.parent.page),this.liveDemoCount=this.collection.count?this.collection.count:this.collection.length,this.count.text(this.liveDemoCount)},renderDemos:function(a){var d=this;return d.instance=d.collection.paginate(a),0===d.instance.size()?void this.parent.trigger("demo:end"):(d.instance.each(function(a){d.demo=new b.view.Demo({model:a,parent:d}),d.demo.render(),d.$el.append(d.demo.el),d.listenTo(d.demo,"demo:expand",d.expand,d)}),!b.isPreview&&b.isInstall&&b.data.settings.canInstall&&this.$el.append('<div class="theme add-new-theme"><a href="'+b.data.settings.installURI+'"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+c.addNew+"</h2></a></div>"),void this.parent.page++)},importedDemo:function(){var a,b=this;a=b.collection.findWhere({active:!0}),a&&(b.collection.remove(a),b.collection.add(a,{at:0}))},setView:function(a){return a},expand:function(c){var d,e,f=this;this.model=f.collection.get(c),b.router.navigate(b.router.baseUrl(b.router.demoPath+this.model.id)),this.setView("detail"),a("body").addClass("modal-open"),this.overlay=new b.view.Details({model:f.model}),this.overlay.render(),this.model.get("hasUpdate")&&(d=a('[data-slug="'+this.model.id+'"]'),e=a(this.overlay.el),d.find(".updating-message").length?(e.find(".notice-warning h3").remove(),e.find(".notice-warning").removeClass("notice-large").addClass("updating-message").find("p").text(wp.updates.l10n.updating)):d.find(".notice-error").length&&e.find(".notice-warning").remove()),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"demo:next",function(){f.next([f.model.cid])}).listenTo(this.overlay,"demo:previous",function(){f.previous([f.model.cid])})},next:function(a){var b,c,d=this;b=d.collection.get(a[0]),c=d.collection.at(d.collection.indexOf(b)+1),void 0!==c&&(this.overlay.closeOverlay(),d.demo.trigger("demo:expand",c.cid))},previous:function(a){var b,c,d=this;b=d.collection.get(a[0]),c=d.collection.at(d.collection.indexOf(b)-1),void 0!==c&&(this.overlay.closeOverlay(),d.demo.trigger("demo:expand",c.cid))},announceSearchResults:function(a){0===a?wp.a11y.speak(c.noDemosFound):wp.a11y.speak(c.demosFound.replace("%d",a))}}),b.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:c.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(a){this.parent=a.parent,this.listenTo(this.parent,"demo:close",function(){this.searching=!1})},search:function(a){"keyup"===a.type&&27===a.which&&(a.target.value=""),this.doSearch(a)},doSearch:_.debounce(function(a){var c={};this.collection.doSearch(a.target.value),this.searching&&13!==a.which?c.replace=!0:this.searching=!0,a.target.value?b.router.navigate(b.router.baseUrl(b.router.searchPath+a.target.value),c):b.router.navigate(b.router.baseUrl(""))},500),pushState:function(a){var c=b.router.baseUrl("");a.target.value&&(c=b.router.baseUrl(b.router.searchPath+a.target.value)),this.searching=!1,b.router.navigate(c)}}),b.Router=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&demo=:slug":"demo","themes.php?page=demo-importer&search=:query":"search","themes.php?page=demo-importer&s=:query":"search","themes.php?page=demo-importer":"demos","":"demos"},baseUrl:function(a){return"themes.php?page=demo-importer"+a},demoPath:"&demo=",searchPath:"&search=",search:function(b){a(".wp-filter-search").val(b)},demos:function(){a(".wp-filter-search").val("")},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),b.Run={init:function(){this.demos=new b.Collection(b.data.demos),this.view=new b.view.Appearance({collection:this.demos}),this.render()},render:function(){this.view.render(),this.view.initTipTip(),this.routes(),Backbone.history.start({root:b.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var c=this;b.router=new b.Router,b.router.on("route:demo",function(a){c.view.view.expand(a)}),b.router.on("route:demos",function(){c.demos.doSearch(""),c.view.trigger("demo:close")}),b.router.on("route:search",function(){a(".wp-filter-search").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},b.view.Installer=b.view.Appearance.extend({el:"#wpbody-content .wrap",render:function(){this.search(),this.uploader(),this.view=new b.view.Demos({collection:this.collection,parent:this}),this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},searchContainer:a(".wp-filter .search-form"),uploader:function(){var b=a(".upload-view-toggle"),c=a(document.body);b.on("click",function(){c.toggleClass("show-upload-view"),b.attr("aria-expanded",c.hasClass("show-upload-view"))})},clearSearch:function(){a("#wp-filter-search-input").val("")}}),b.InstallerRouter=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&browse=uploads&demo=:slug":"demo","themes.php?page=demo-importer&browse=:sort&search=:query":"search","themes.php?page=demo-importer&browse=:sort&s=:query":"search","themes.php?page=demo-importer&browse=welcome":"sort","themes.php?page=demo-importer&browse=:sort":"demos","themes.php?page=demo-importer":"sort"},browse:function(){return b.isPreview?"preview":"uploads"},baseUrl:function(a){return"themes.php?page=demo-importer&browse="+this.browse()+a},demoPath:"&demo=",searchPath:"&search=",search:function(b,c){a(".wp-filter-search").val(c)},demos:function(){a(".wp-filter-search").val("")},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),b.RunInstaller={init:function(){this.demos=new b.Collection(b.data.demos),this.view=new b.view.Installer({collection:this.demos}),this.render()},render:function(){this.view.render(),this.view.initTipTip(),this.routes(),Backbone.history.start({root:b.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var c=this;b.router=new b.InstallerRouter,b.router.on("route:demo",function(a){c.view.view.expand(a)}),b.router.on("route:demos",function(){c.demos.doSearch(""),c.view.trigger("demo:close")}),b.router.on("route:sort",function(b){b&&"welcome"!==b||a(".wp-filter-search").hide()}),b.router.on("route:search",function(){a(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},a(document).ready(function(){b.isInstall?b.RunInstaller.init():b.Run.init(),a(".notice.is-dismissible").on("click",".notice-dismiss",function(c){var d=a(this);if(c.preventDefault(),"undefined"!==d.parent().attr("id"))return a.post(b.data.settings.ajaxUrl,{action:"dismiss-notice",notice_id:d.parent().data("notice_id")}),!1})})}(jQuery);
1
+ window.wp=window.wp||{},function(e){var t,i;(t=wp.demos=wp.demos||{}).data=demoImporterLocalizeScript,i=t.data.l10n,t.isPreview=!!t.data.settings.isPreview,t.isInstall=!!t.data.settings.isInstall,_.extend(t,{model:{},view:{},routes:{},router:{},template:wp.template}),t.Model=Backbone.Model.extend({initialize:function(){var e;-1!==_.indexOf(t.data.installedDemos,this.get("slug"))&&this.set({installed:!0}),this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e}))}}),t.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:e(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView?e.SearchView:t.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new t.view.Demos({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:e(".search-form"),search:function(){var o,s=this;1!==t.data.demos.length&&((o=new this.SearchView({collection:s.collection,parent:this})).render(),this.searchContainer.append(e.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+i.search+"</label>")).append(o.el))},scroller:function(){var e,t,i=this;e=this.window.scrollTop()+i.window.height(),t=i.$el.offset().top+i.$el.outerHeight(!1)-i.window.height(),e>(t=Math.round(.9*t))&&this.trigger("demo:scroll")},initTipTip:function(){e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:50})}}),t.Collection=Backbone.Collection.extend({model:t.Model,terms:"",doSearch:function(i){this.terms!==i&&(this.terms=i,this.terms.length>0&&this.search(this.terms),""===this.terms&&(this.reset(t.data.demos),e("body").removeClass("no-results")),this.trigger("demos:update"))},search:function(i){var o,s,n,r,a,l;this.reset(t.data.demos,{silent:!0}),i=i.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\amp;"),i=i.replace(/ /g,")(?=.*"),o=new RegExp("^(?=.*"+i+").+","i"),0===(s=this.filter(function(e){return r=e.get("name").replace(/(<([^>]+)>)/gi,""),a=e.get("description").replace(/(<([^>]+)>)/gi,""),l=e.get("author").replace(/(<([^>]+)>)/gi,""),n=_.union([r,e.get("id"),a,l,e.get("tags")]),o.test(e.get("author"))&&i.length>2&&e.set("displayAuthor",!0),o.test(n)})).length?this.trigger("query:empty"):e("body").removeClass("no-results"),this.reset(s)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(20*e)),t=_(t.first(20))}}),t.view.Demo=wp.Backbone.View.extend({className:"theme",state:"grid",html:t.template(t.isPreview?"demo-preview":"demo"),events:{click:"expand",keydown:"expand",touchend:"expand",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"),this.model.get("actions").pro_link&&this.$el.html(this.html(e)).addClass("premium-ribbon")},activeDemo:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var t=e(":focus").hasClass("theme")?e(":focus"):e(":focus").parents(".theme");e(".theme.focus").removeClass("focus"),t.addClass("focus")},expand:function(i){var o=this;if(!t.isPreview&&("keydown"!==(i=i||window.event).type||13===i.which||32===i.which))return!0===this.touchDrag?this.touchDrag=!1:void(e(i.target).is(".theme-actions a")||e(i.target).is(".theme-actions a, .update-message, .button-link, .notice-dismiss")||(t.focusedDemo=this.$el,this.trigger("demo:expand",o.model.cid)))},preventExpand:function(){this.touchDrag=!0},importDemo:function(t){var i=this,o=e(t.target);t.preventDefault(),o.hasClass("disabled")||window.confirm(wp.demos.data.settings.confirmImport)&&(e(document).on("wp-demo-import-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({imported:!0})}),wp.updates.importDemo({slug:o.data("slug")}))}}),t.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-demo":"deleteDemo","click .left":"previousDemo","click .right":"nextDemo","click .demo-import":"importDemo"},html:t.template("demo-single"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),this.activeDemo(),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el)},activeDemo:function(){this.$el.toggleClass("active",this.model.get("active"))},containFocus:function(t){_.delay(function(){e(".theme-wrap a.button-primary:visible").focus()},100),t.on("keydown.wp-themes",function(e){var i=t.find(".theme-header button:not(.disabled)").first(),o=t.find(".theme-actions a:visible").last();9===e.which&&(i[0]===e.target&&e.shiftKey?(o.focus(),e.preventDefault()):o[0]!==e.target||e.shiftKey||(i.focus(),e.preventDefault()))})},collapse:function(i){var o,s=this;i=i||window.event,1!==t.data.demos.length&&(e(i.target).is(".theme-backdrop")||e(i.target).is(".close")||27===i.keyCode)&&(e("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){e("body").removeClass("closing-overlay"),s.closeOverlay(),o=document.body.scrollTop,t.router.navigate(t.router.baseUrl("")),document.body.scrollTop=o,t.focusedDemo&&t.focusedDemo.focus()}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled").prop("disabled",!0),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled").prop("disabled",!0)},closeOverlay:function(){e("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("demo:collapse")},importDemo:function(t){var i=this,o=e(t.target);t.preventDefault(),o.hasClass("disabled")||window.confirm(wp.demos.data.settings.confirmImport)&&(e(document).on("wp-demo-import-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({imported:!0})}),e(document).on("wp-updates-queue-job",function(e,t){"import-demo"===t.action&&wp.updates.importDemo(t.data)}),wp.updates.importDemo({slug:o.data("slug")}))},deleteDemo:function(i){var o=this,s=this.model.collection,n=t;i.preventDefault(),window.confirm(wp.demos.data.settings.confirmDelete)&&(wp.updates.maybeRequestFilesystemCredentials(i),e(document).one("wp-demo-delete-success",function(t,i){o.$el.find(".close").trigger("click"),e('[data-slug="'+i.slug+'"').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){e(this).remove(),n.data.demos=_.without(n.data.demos,_.findWhere(n.data.demos,{id:i.slug})),e(".wp-filter-search").val(""),s.doSearch(""),s.remove(o.model),s.trigger("demos:update")})}),wp.updates.deleteDemo({slug:this.model.get("id")}))},nextDemo:function(){var e=this;return e.trigger("demo:next",e.model.cid),!1},previousDemo:function(){var e=this;return e.trigger("demo:previous",e.model.cid),!1},screenshotCheck:function(e){var t,i;t=e.find(".screenshot img"),(i=new Image).src=t.attr("src"),i.width&&i.width<=300&&e.addClass("small-screenshot")}}),t.view.Demos=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:e("div.theme-overlay"),index:0,count:e(".wrap .demo-count"),liveDemoCount:0,initialize:function(t){var i=this;this.parent=t.parent,i.importedDemo(),this.setView("grid"),this.listenTo(i.collection,"demos:update",function(){i.parent.page=0,i.importedDemo(),i.render(this),i.parent.initTipTip()}),this.listenTo(i.collection,"query:success",function(e){_.isNumber(e)?(i.count.text(e),i.announceSearchResults(e)):(i.count.text(i.collection.length),i.announceSearchResults(i.collection.length))}),this.listenTo(i.collection,"query:empty",function(){e("body").addClass("no-results")}),this.listenTo(this.parent,"demo:scroll",function(){i.renderDemos(i.parent.page)}),this.listenTo(this.parent,"demo:close",function(){i.overlay&&i.overlay.closeOverlay()}),e("body").on("keyup",function(t){i.overlay&&(e("#request-filesystem-credentials-dialog").is(":visible")||(39===t.keyCode&&i.overlay.nextDemo(),37===t.keyCode&&i.overlay.previousDemo(),27===t.keyCode&&i.overlay.collapse(t)))})},render:function(){this.$el.empty(),t.isPreview||1!==t.data.demos.length||(this.singleDemo=new t.view.Details({model:this.collection.models[0]}),this.singleDemo.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleDemo.el)),this.options.collection.size()>0&&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 o=this;o.instance=o.collection.paginate(e),0!==o.instance.size()?(o.instance.each(function(e){o.demo=new t.view.Demo({model:e,parent:o}),o.demo.render(),o.$el.append(o.demo.el),o.listenTo(o.demo,"demo:expand",o.expand,o)}),!t.isPreview&&t.isInstall&&t.data.settings.canInstall&&this.$el.append('<div class="theme add-new-theme"><a href="'+t.data.settings.installURI+'"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+i.addNew+"</h2></a></div>"),this.parent.page++):this.parent.trigger("demo:end")},importedDemo:function(){var e,t=this;(e=t.collection.findWhere({active:!0}))&&(t.collection.remove(e),t.collection.add(e,{at:0}))},setView:function(e){return e},expand:function(i){var o,s,n=this;this.model=n.collection.get(i),t.router.navigate(t.router.baseUrl(t.router.demoPath+this.model.id)),this.setView("detail"),e("body").addClass("modal-open"),this.overlay=new t.view.Details({model:n.model}),this.overlay.render(),this.model.get("hasUpdate")&&(o=e('[data-slug="'+this.model.id+'"]'),s=e(this.overlay.el),o.find(".updating-message").length?(s.find(".notice-warning h3").remove(),s.find(".notice-warning").removeClass("notice-large").addClass("updating-message").find("p").text(wp.updates.l10n.updating)):o.find(".notice-error").length&&s.find(".notice-warning").remove()),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"demo:next",function(){n.next([n.model.cid])}).listenTo(this.overlay,"demo:previous",function(){n.previous([n.model.cid])})},next:function(e){var t,i,o=this;t=o.collection.get(e[0]),(i=o.collection.at(o.collection.indexOf(t)+1))!==undefined&&(this.overlay.closeOverlay(),o.demo.trigger("demo:expand",i.cid))},previous:function(e){var t,i,o=this;t=o.collection.get(e[0]),(i=o.collection.at(o.collection.indexOf(t)-1))!==undefined&&(this.overlay.closeOverlay(),o.demo.trigger("demo:expand",i.cid))},announceSearchResults:function(e){0===e?wp.a11y.speak(i.noDemosFound):wp.a11y.speak(i.demosFound.replace("%d",e))}}),t.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:_.debounce(function(e){var i={};this.collection.doSearch(e.target.value),this.searching&&13!==e.which?i.replace=!0:this.searching=!0,e.target.value?t.router.navigate(t.router.baseUrl(t.router.searchPath+e.target.value),i):t.router.navigate(t.router.baseUrl(""))},500),pushState:function(e){var i=t.router.baseUrl("");e.target.value&&(i=t.router.baseUrl(t.router.searchPath+e.target.value)),this.searching=!1,t.router.navigate(i)}}),t.Router=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&demo=:slug":"demo","themes.php?page=demo-importer&search=:query":"search","themes.php?page=demo-importer&s=:query":"search","themes.php?page=demo-importer":"demos","":"demos"},baseUrl:function(e){return"themes.php?page=demo-importer"+e},demoPath:"&demo=",searchPath:"&search=",search:function(t){e(".wp-filter-search").val(t)},demos:function(){e(".wp-filter-search").val("")},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),t.Run={init:function(){this.demos=new t.Collection(t.data.demos),this.view=new t.view.Appearance({collection:this.demos}),this.render()},render:function(){this.view.render(),this.view.initTipTip(),this.routes(),Backbone.history.start({root:t.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var i=this;t.router=new t.Router,t.router.on("route:demo",function(e){i.view.view.expand(e)}),t.router.on("route:demos",function(){i.demos.doSearch(""),i.view.trigger("demo:close")}),t.router.on("route:search",function(){e(".wp-filter-search").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},t.view.Installer=t.view.Appearance.extend({el:"#wpbody-content .wrap",render:function(){this.search(),this.uploader(),this.view=new t.view.Demos({collection:this.collection,parent:this}),this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},uploader:function(){var t=e(".upload-view-toggle"),i=e(document.body);t.on("click",function(){i.toggleClass("show-upload-view"),t.attr("aria-expanded",i.hasClass("show-upload-view"))})},clearSearch:function(){e("#wp-filter-search-input").val("")}}),t.InstallerRouter=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&browse=uploads&demo=:slug":"demo","themes.php?page=demo-importer&browse=:sort&search=:query":"search","themes.php?page=demo-importer&browse=:sort&s=:query":"search","themes.php?page=demo-importer&browse=welcome":"sort","themes.php?page=demo-importer&browse=:sort":"demos","themes.php?page=demo-importer":"sort"},browse:function(){return t.isPreview?"preview":"uploads"},baseUrl:function(e){return"themes.php?page=demo-importer&browse="+this.browse()+e},demoPath:"&demo=",searchPath:"&search=",search:function(t,i){e(".wp-filter-search").val(i)},demos:function(){e(".wp-filter-search").val("")},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),t.RunInstaller={init:function(){this.demos=new t.Collection(t.data.demos),this.view=new t.view.Installer({collection:this.demos}),this.render()},render:function(){this.view.render(),this.view.initTipTip(),this.routes(),Backbone.history.start({root:t.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var i=this;t.router=new t.InstallerRouter,t.router.on("route:demo",function(e){i.view.view.expand(e)}),t.router.on("route:demos",function(){i.demos.doSearch(""),i.view.trigger("demo:close")}),t.router.on("route:sort",function(t){t&&"welcome"!==t||e(".wp-filter-search").hide()}),t.router.on("route:search",function(){e(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},e(document).ready(function(){t.isInstall?t.RunInstaller.init():t.Run.init(),e(".themegrill-demo-importer-rating-link").on("click",function(){var i=e(this);e.post(t.data.settings.ajaxUrl,{action:"footer-text-rated"}),i.parent().text(i.data("rated"))}),e(".themegrill-reset-wordpress").on("click",function(){return window.confirm(t.data.settings.confirmReset)}),e("#contextual-help-link").on("click",function(){var t=e("#tab-panel-themegrill_demo_importer_guided_tour_tab iframe");t.attr("src",t.data("src"))})})}(jQuery);
assets/js/admin/demo-updates.js CHANGED
@@ -17,6 +17,46 @@
17
*/
18
wp.updates.l10n = _.extend( wp.updates.l10n, settings.l10n || {} );
19
20
/**
21
* Sends an Ajax request to the server to import a demo.
22
*
@@ -281,8 +321,6 @@
281
282
job = wp.updates.queue.shift();
283
284
- job = wp.updates.queue.shift();
285
-
286
// Handle a queue job.
287
switch ( job.action ) {
288
case 'import-demo':
@@ -295,7 +333,6 @@
295
296
default:
297
break;
298
-
299
}
300
301
// Handle a queue job.
17
*/
18
wp.updates.l10n = _.extend( wp.updates.l10n, settings.l10n || {} );
19
20
+ /**
21
+ * Adds or updates an admin notice.
22
+ *
23
+ * @since 4.6.0
24
+ * @see https://core.trac.wordpress.org/ticket/41221
25
+ *
26
+ * @param {object} data
27
+ * @param {*=} data.selector Optional. Selector of an element to be replaced with the admin notice.
28
+ * @param {string=} data.id Optional. Unique id that will be used as the notice's id attribute.
29
+ * @param {string=} data.className Optional. Class names that will be used in the admin notice.
30
+ * @param {string=} data.message Optional. The message displayed in the notice.
31
+ * @param {number=} data.successes Optional. The amount of successful operations.
32
+ * @param {number=} data.errors Optional. The amount of failed operations.
33
+ * @param {Array=} data.errorMessages Optional. Error messages of failed operations.
34
+ *
35
+ */
36
+ wp.updates.addAdminNotice = function( data ) {
37
+ var $notice = $( data.selector ),
38
+ $headerEnd = $( '.wp-header-end' ),
39
+ $adminNotice;
40
+
41
+ delete data.selector;
42
+ $adminNotice = wp.updates.adminNotice( data );
43
+
44
+ // Check if this admin notice already exists.
45
+ if ( ! $notice.length ) {
46
+ $notice = $( '#' + data.id );
47
+ }
48
+
49
+ if ( $notice.length ) {
50
+ $notice.replaceWith( $adminNotice );
51
+ } else if ( $headerEnd.length ) {
52
+ $( '.wp-header-end' ).after( $adminNotice );
53
+ } else {
54
+ $( '.wrap' ).find( '> h1' ).after( $adminNotice );
55
+ }
56
+
57
+ $document.trigger( 'wp-updates-notice-added' );
58
+ };
59
+
60
/**
61
* Sends an Ajax request to the server to import a demo.
62
*
321
322
job = wp.updates.queue.shift();
323
324
// Handle a queue job.
325
switch ( job.action ) {
326
case 'import-demo':
333
334
default:
335
break;
336
}
337
338
// Handle a queue job.
assets/js/admin/demo-updates.min.js CHANGED
@@ -1 +1 @@
1
- !function(a,b,c){var d=a(document);b=b||{},b.updates=b.updates||{},b.updates.l10n=_.extend(b.updates.l10n,c.l10n||{}),b.updates.importDemo=function(c){var e=a('.demo-import[data-slug="'+c.slug+'"]');return c=_.extend({success:b.updates.importDemoSuccess,error:b.updates.importDemoError},c),e.addClass("updating-message"),e.parents(".theme").addClass("focus"),e.html()!==b.updates.l10n.importing&&e.data("originaltext",e.html()),e.text(b.updates.l10n.importing).attr("aria-label",b.updates.l10n.demoImportingLabel.replace("%s",e.data("name"))),b.a11y.speak(b.updates.l10n.importingMsg,"polite"),a('.theme-info .theme-description, [data-slug="'+c.slug+'"]').removeClass("demo-import-failed").find(".notice.notice-error").remove(),d.trigger("wp-demo-importing",c),b.updates.ajax("import-demo",c)},b.updates.importDemoSuccess=function(c){var e,f=a(".theme-overlay, [data-slug="+c.slug+"]");d.trigger("wp-demo-import-success",c),e=f.find(".button-primary").removeClass("updating-message").addClass("updated-message disabled").attr("aria-label",b.updates.l10n.demoImportedLabel.replace("%s",c.demoName)).text(b.updates.l10n.imported),b.a11y.speak(b.updates.l10n.importedMsg,"polite"),setTimeout(function(){c.previewUrl&&(e.siblings(".demo-preview").remove(),e.attr("target","_blank").attr("href",c.previewUrl).removeClass("demo-import updated-message disabled").addClass("live-preview").attr("aria-label",b.updates.l10n.livePreviewLabel.replace("%s",c.demoName)).text(b.updates.l10n.livePreview))},1e3)},b.updates.importDemoError=function(c){var e,f,g=b.updates.l10n.importFailed.replace("%s",c.errorMessage),h=b.updates.adminNotice({className:"update-message notice-error notice-alt",message:g});b.updates.isValidResponse(c,"import")&&(d.find("body").hasClass("modal-open")||d.find(".themes").hasClass("single-theme")?(f=a('.demo-import[data-slug="'+c.slug+'"]'),e=a(".theme-info .theme-description").prepend(h)):(e=a('[data-slug="'+c.slug+'"]').removeClass("focus").addClass("demo-import-failed").append(h),f=e.find(".demo-import")),f.removeClass("updating-message").attr("aria-label",b.updates.l10n.demoImportFailedLabel.replace("%s",f.data("name"))).text(b.updates.l10n.importFailedShort),b.a11y.speak(g,"assertive"),d.trigger("wp-demo-import-error",c))},b.updates.deleteDemo=function(c){var e=a(".theme-actions .delete-demo");return c=_.extend({success:b.updates.deleteDemoSuccess,error:b.updates.deleteDemoError},c),e&&e.html()!==b.updates.l10n.deleting&&e.data("originaltext",e.html()).text(b.updates.l10n.deleting),b.a11y.speak(b.updates.l10n.deleting,"polite"),a(".theme-info .update-message").remove(),d.trigger("wp-demo-deleting",c),b.updates.ajax("delete-demo",c)},b.updates.deleteDemoSuccess=function(a){b.a11y.speak(b.updates.l10n.deleted,"polite"),d.trigger("wp-demo-delete-success",a)},b.updates.deleteDemoError=function(c){var e=a(".theme-actions .delete-demo"),f=b.updates.l10n.deleteFailed.replace("%s",c.errorMessage),g=b.updates.adminNotice({className:"update-message notice-error notice-alt",message:f});b.updates.maybeHandleCredentialError(c,"delete-demo")||(a(".theme-info .theme-description").before(g),e.html(e.data("originaltext")),b.a11y.speak(f,"assertive"),d.trigger("wp-demo-delete-error",c))},b.updates.isValidResponse=function(c,d){var e,f=b.updates.l10n.unknownError;if(_.isObject(c)&&!_.isFunction(c.always))return!0;switch(_.isString(c)&&"-1"===c?f=b.updates.l10n.nonceError:_.isString(c)?f=c:"undefined"!=typeof c.readyState&&0===c.readyState?f=b.updates.l10n.connectionError:_.isString(c.statusText)&&(f=c.statusText+" "+b.updates.l10n.statusTextLink),d){case"import":e=b.updates.l10n.importFailed}return e=e.replace("%s",f),b.updates.addAdminNotice({id:"unknown_error",className:"notice-error is-dismissible",message:_.unescape(e)}),a(".button.updating-message").removeClass("updating-message").removeAttr("aria-label").text(b.updates.l10n.updateFailedShort),b.a11y.speak(e,"assertive"),!1},b.updates.queueChecker=function(){var a;if(!b.updates.ajaxLocked&&b.updates.queue.length){switch(a=b.updates.queue.shift(),a=b.updates.queue.shift(),a.action){case"import-demo":b.updates.importDemo(a.data);break;case"delete-demo":b.updates.deleteDemo(a.data)}d.trigger("wp-updates-queue-job",a)}}}(jQuery,window.wp,window._demoUpdatesSettings);
1
+ !function(e,t,a){var s=e(document);(t=t||{}).updates=t.updates||{},t.updates.l10n=_.extend(t.updates.l10n,a.l10n||{}),t.updates.addAdminNotice=function(a){var d,r=e(a.selector),i=e(".wp-header-end");delete a.selector,d=t.updates.adminNotice(a),r.length||(r=e("#"+a.id)),r.length?r.replaceWith(d):i.length?e(".wp-header-end").after(d):e(".wrap").find("> h1").after(d),s.trigger("wp-updates-notice-added")},t.updates.importDemo=function(a){var d=e('.demo-import[data-slug="'+a.slug+'"]');return a=_.extend({success:t.updates.importDemoSuccess,error:t.updates.importDemoError},a),d.addClass("updating-message"),d.parents(".theme").addClass("focus"),d.html()!==t.updates.l10n.importing&&d.data("originaltext",d.html()),d.text(t.updates.l10n.importing).attr("aria-label",t.updates.l10n.demoImportingLabel.replace("%s",d.data("name"))),t.a11y.speak(t.updates.l10n.importingMsg,"polite"),e('.theme-info .theme-description, [data-slug="'+a.slug+'"]').removeClass("demo-import-failed").find(".notice.notice-error").remove(),s.trigger("wp-demo-importing",a),t.updates.ajax("import-demo",a)},t.updates.importDemoSuccess=function(a){var d,r=e(".theme-overlay, [data-slug="+a.slug+"]");s.trigger("wp-demo-import-success",a),d=r.find(".button-primary").removeClass("updating-message").addClass("updated-message disabled").attr("aria-label",t.updates.l10n.demoImportedLabel.replace("%s",a.demoName)).text(t.updates.l10n.imported),t.a11y.speak(t.updates.l10n.importedMsg,"polite"),setTimeout(function(){a.previewUrl&&(d.siblings(".demo-preview").remove(),d.attr("target","_blank").attr("href",a.previewUrl).removeClass("demo-import updated-message disabled").addClass("live-preview").attr("aria-label",t.updates.l10n.livePreviewLabel.replace("%s",a.demoName)).text(t.updates.l10n.livePreview))},1e3)},t.updates.importDemoError=function(a){var d,r=t.updates.l10n.importFailed.replace("%s",a.errorMessage),i=t.updates.adminNotice({className:"update-message notice-error notice-alt",message:r});t.updates.isValidResponse(a,"import")&&(s.find("body").hasClass("modal-open")||s.find(".themes").hasClass("single-theme")?(d=e('.demo-import[data-slug="'+a.slug+'"]'),e(".theme-info .theme-description").prepend(i)):d=e('[data-slug="'+a.slug+'"]').removeClass("focus").addClass("demo-import-failed").append(i).find(".demo-import"),d.removeClass("updating-message").attr("aria-label",t.updates.l10n.demoImportFailedLabel.replace("%s",d.data("name"))).text(t.updates.l10n.importFailedShort),t.a11y.speak(r,"assertive"),s.trigger("wp-demo-import-error",a))},t.updates.deleteDemo=function(a){var d=e(".theme-actions .delete-demo");return a=_.extend({success:t.updates.deleteDemoSuccess,error:t.updates.deleteDemoError},a),d&&d.html()!==t.updates.l10n.deleting&&d.data("originaltext",d.html()).text(t.updates.l10n.deleting),t.a11y.speak(t.updates.l10n.deleting,"polite"),e(".theme-info .update-message").remove(),s.trigger("wp-demo-deleting",a),t.updates.ajax("delete-demo",a)},t.updates.deleteDemoSuccess=function(e){t.a11y.speak(t.updates.l10n.deleted,"polite"),s.trigger("wp-demo-delete-success",e)},t.updates.deleteDemoError=function(a){var d=e(".theme-actions .delete-demo"),r=t.updates.l10n.deleteFailed.replace("%s",a.errorMessage),i=t.updates.adminNotice({className:"update-message notice-error notice-alt",message:r});t.updates.maybeHandleCredentialError(a,"delete-demo")||(e(".theme-info .theme-description").before(i),d.html(d.data("originaltext")),t.a11y.speak(r,"assertive"),s.trigger("wp-demo-delete-error",a))},t.updates.isValidResponse=function(a,s){var d,r=t.updates.l10n.unknownError;if(_.isObject(a)&&!_.isFunction(a.always))return!0;switch(_.isString(a)&&"-1"===a?r=t.updates.l10n.nonceError:_.isString(a)?r=a:"undefined"!=typeof a.readyState&&0===a.readyState?r=t.updates.l10n.connectionError:_.isString(a.statusText)&&(r=a.statusText+" "+t.updates.l10n.statusTextLink),s){case"import":d=t.updates.l10n.importFailed}return d=d.replace("%s",r),t.updates.addAdminNotice({id:"unknown_error",className:"notice-error is-dismissible",message:_.unescape(d)}),e(".button.updating-message").removeClass("updating-message").removeAttr("aria-label").text(t.updates.l10n.updateFailedShort),t.a11y.speak(d,"assertive"),!1},t.updates.queueChecker=function(){var e;if(!t.updates.ajaxLocked&&t.updates.queue.length){switch((e=t.updates.queue.shift()).action){case"import-demo":t.updates.importDemo(e.data);break;case"delete-demo":t.updates.deleteDemo(e.data)}s.trigger("wp-updates-queue-job",e)}}}(jQuery,window.wp,window._demoUpdatesSettings);
assets/js/jquery-tiptip/jquery.tipTip.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){a.fn.tipTip=function(b){var c={activation:"hover",keepAlive:!1,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:!1,enter:function(){},exit:function(){}},d=a.extend(c,b);if(a("#tiptip_holder").length<=0){var e=a('<div id="tiptip_holder" style="max-width:'+d.maxWidth+';"></div>'),f=a('<div id="tiptip_content"></div>'),g=a('<div id="tiptip_arrow"></div>');a("body").append(e.html(f).prepend(g.html('<div id="tiptip_arrow_inner"></div>')))}else var e=a("#tiptip_holder"),f=a("#tiptip_content"),g=a("#tiptip_arrow");return this.each(function(){function b(){d.enter.call(this),f.html(i),e.hide().removeAttr("class").css("margin","0"),g.removeAttr("style");var b=parseInt(h.offset().top),c=parseInt(h.offset().left),k=parseInt(h.outerWidth()),l=parseInt(h.outerHeight()),m=e.outerWidth(),n=e.outerHeight(),o=Math.round((k-m)/2),p=Math.round((l-n)/2),q=Math.round(c+o),r=Math.round(b+l+d.edgeOffset),s="",t="",u=Math.round(m-12)/2;"bottom"==d.defaultPosition?s="_bottom":"top"==d.defaultPosition?s="_top":"left"==d.defaultPosition?s="_left":"right"==d.defaultPosition&&(s="_right");var v=o+c<parseInt(a(window).scrollLeft()),w=m+c>parseInt(a(window).width());v&&o<0||"_right"==s&&!w||"_left"==s&&c<m+d.edgeOffset+5?(s="_right",t=Math.round(n-13)/2,u=-12,q=Math.round(c+k+d.edgeOffset),r=Math.round(b+p)):(w&&o<0||"_left"==s&&!v)&&(s="_left",t=Math.round(n-13)/2,u=Math.round(m),q=Math.round(c-(m+d.edgeOffset+5)),r=Math.round(b+p));var x=b+l+d.edgeOffset+n+8>parseInt(a(window).height()+a(window).scrollTop()),y=b+l-(d.edgeOffset+n+8)<0;x||"_bottom"==s&&x||"_top"==s&&!y?("_top"==s||"_bottom"==s?s="_top":s+="_top",t=n,r=Math.round(b-(n+5+d.edgeOffset))):(y|("_top"==s&&y)||"_bottom"==s&&!x)&&("_top"==s||"_bottom"==s?s="_bottom":s+="_bottom",t=-12,r=Math.round(b+l+d.edgeOffset)),"_right_top"==s||"_left_top"==s?r+=5:"_right_bottom"!=s&&"_left_bottom"!=s||(r-=5),"_left_top"!=s&&"_left_bottom"!=s||(q+=5),g.css({"margin-left":u+"px","margin-top":t+"px"}),e.css({"margin-left":q+"px","margin-top":r+"px"}).attr("class","tip"+s),j&&clearTimeout(j),j=setTimeout(function(){e.stop(!0,!0).fadeIn(d.fadeIn)},d.delay)}function c(){d.exit.call(this),j&&clearTimeout(j),e.fadeOut(d.fadeOut)}var h=a(this);if(d.content)var i=d.content;else var i=h.attr(d.attribute);if(""!=i){d.content||h.removeAttr(d.attribute);var j=!1;"hover"==d.activation?(h.hover(function(){b()},function(){d.keepAlive||c()}),d.keepAlive&&e.hover(function(){},function(){c()})):"focus"==d.activation?h.focus(function(){b()}).blur(function(){c()}):"click"==d.activation&&(h.click(function(){return b(),!1}).hover(function(){},function(){d.keepAlive||c()}),d.keepAlive&&e.hover(function(){},function(){c()}))}})}}(jQuery);
1
+ !function(t){t.fn.tipTip=function(e){var o={activation:"hover",keepAlive:!1,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:!1,enter:function(){},exit:function(){}},i=t.extend(o,e);if(t("#tiptip_holder").length<=0){var n=t('<div id="tiptip_holder" style="max-width:'+i.maxWidth+';"></div>'),r=t('<div id="tiptip_content"></div>'),a=t('<div id="tiptip_arrow"></div>');t("body").append(n.html(r).prepend(a.html('<div id="tiptip_arrow_inner"></div>')))}else var n=t("#tiptip_holder"),r=t("#tiptip_content"),a=t("#tiptip_arrow");return this.each(function(){function e(){i.enter.call(this),r.html(d),n.hide().removeAttr("class").css("margin","0"),a.removeAttr("style");var e=parseInt(f.offset().top),o=parseInt(f.offset().left),p=parseInt(f.outerWidth()),l=parseInt(f.outerHeight()),h=n.outerWidth(),c=n.outerHeight(),s=Math.round((p-h)/2),_=Math.round((l-c)/2),v=Math.round(o+s),m=Math.round(e+l+i.edgeOffset),g="",b="",M=Math.round(h-12)/2;"bottom"==i.defaultPosition?g="_bottom":"top"==i.defaultPosition?g="_top":"left"==i.defaultPosition?g="_left":"right"==i.defaultPosition&&(g="_right");var w=s+o<parseInt(t(window).scrollLeft()),O=h+o>parseInt(t(window).width());w&&s<0||"_right"==g&&!O||"_left"==g&&o<h+i.edgeOffset+5?(g="_right",b=Math.round(c-13)/2,M=-12,v=Math.round(o+p+i.edgeOffset),m=Math.round(e+_)):(O&&s<0||"_left"==g&&!w)&&(g="_left",b=Math.round(c-13)/2,M=Math.round(h),v=Math.round(o-(h+i.edgeOffset+5)),m=Math.round(e+_));var x=e+l+i.edgeOffset+c+8>parseInt(t(window).height()+t(window).scrollTop()),I=e+l-(i.edgeOffset+c+8)<0;x||"_bottom"==g&&x||"_top"==g&&!I?("_top"==g||"_bottom"==g?g="_top":g+="_top",b=c,m=Math.round(e-(c+5+i.edgeOffset))):(I|("_top"==g&&I)||"_bottom"==g&&!x)&&("_top"==g||"_bottom"==g?g="_bottom":g+="_bottom",b=-12,m=Math.round(e+l+i.edgeOffset)),"_right_top"==g||"_left_top"==g?m+=5:"_right_bottom"!=g&&"_left_bottom"!=g||(m-=5),"_left_top"!=g&&"_left_bottom"!=g||(v+=5),a.css({"margin-left":M+"px","margin-top":b+"px"}),n.css({"margin-left":v+"px","margin-top":m+"px"}).attr("class","tip"+g),u&&clearTimeout(u),u=setTimeout(function(){n.stop(!0,!0).fadeIn(i.fadeIn)},i.delay)}function o(){i.exit.call(this),u&&clearTimeout(u),n.fadeOut(i.fadeOut)}var f=t(this);if(i.content)d=i.content;else var d=f.attr(i.attribute);if(""!=d){i.content||f.removeAttr(i.attribute);var u=!1;"hover"==i.activation?(f.hover(function(){e()},function(){i.keepAlive||o()}),i.keepAlive&&n.hover(function(){},function(){o()})):"focus"==i.activation?f.focus(function(){e()}).blur(function(){o()}):"click"==i.activation&&(f.click(function(){return e(),!1}).hover(function(){},function(){i.keepAlive||o()}),i.keepAlive&&n.hover(function(){},function(){o()}))}})}}(jQuery);
includes/class-demo-importer.php CHANGED
@@ -45,14 +45,27 @@ class TG_Demo_Importer {
45
46
// Add Demo Importer menu.
47
if ( apply_filters( 'themegrill_show_demo_importer_page', true ) ) {
48
- add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
49
add_action( 'admin_head', array( $this, 'add_menu_classes' ) );
50
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
51
}
52
53
- // AJAX Events to import demo and dismiss notice.
54
add_action( 'wp_ajax_import-demo', array( $this, 'ajax_import_demo' ) );
55
- add_action( 'wp_ajax_dismiss-notice', array( $this, 'ajax_dismiss_notice' ) );
56
57
// Update custom nav menu items and siteorigin panel data.
58
add_action( 'themegrill_ajax_demo_imported', array( $this, 'update_nav_menu_items' ) );
@@ -93,38 +106,11 @@ class TG_Demo_Importer {
93
94
// If enabled demo pack, load from upload dir.
95
if ( $this->is_enabled_demo_pack( $demo_dir ) ) {
96
- $upload_dir = wp_upload_dir();
97
- $working_dir = $upload_dir['baseurl'] . '/tg-demo-pack/' . $demo_dir;
98
}
99
100
return trailingslashit( $working_dir ) . sanitize_file_name( $filename );
101
}
102
- /**
103
- * Get theme screenshot url to be used in demo importer preview
104
- *
105
- * @param string $demo_id
106
- * @param string $demo_assets_path
107
- * @param string $current_template
108
- * @return string
109
- */
110
- public function get_screenshot_url( $demo_id, $demo_assets_path, $current_template ) {
111
- $dir = plugin_dir_path( __FILE__ );
112
-
113
- //build screenshot url that reside inside the plugin
114
- $screenshot_plugin_url = $demo_assets_path. 'images/' .$current_template. '/' .$demo_id. '.jpg';
115
-
116
- //build screenshot path that reside inside the plugin
117
- $screenshot_plugin_path = ThemeGrill_Demo_Importer::plugin_dir_path() . '/assets/images/' .$current_template. '/' .$demo_id. '.jpg';
118
-
119
- if ( file_exists( $screenshot_plugin_path ) ) {
120
- $screenshot_url = $screenshot_plugin_url;
121
- } else {
122
- $theme_data = wp_get_theme();
123
- $screenshot_url = $theme_data->get_screenshot();
124
- }
125
- return $screenshot_url;
126
-
127
- }
128
129
/**
130
* Get the import file path.
@@ -138,13 +124,35 @@ class TG_Demo_Importer {
138
139
// If enabled demo pack, load from upload dir.
140
if ( $this->is_enabled_demo_pack( $demo_dir ) ) {
141
- $upload_dir = wp_upload_dir();
142
- $working_dir = $upload_dir['basedir'] . '/tg-demo-pack/' . $demo_dir . '/dummy-data';
143
}
144
145
return trailingslashit( $working_dir ) . sanitize_file_name( $filename );
146
}
147
148
/**
149
* Check if demo pack is enabled.
150
* @param array $demo_id
@@ -161,7 +169,7 @@ class TG_Demo_Importer {
161
/**
162
* Add menu item.
163
*/
164
- public function add_admin_menu() {
165
add_theme_page( __( 'Demo Importer', 'themegrill-demo-importer' ), __( 'Demo Importer', 'themegrill-demo-importer' ), 'switch_themes', 'demo-importer', array( $this, 'demo_importer' ) );
166
}
167
@@ -193,15 +201,18 @@ class TG_Demo_Importer {
193
$screen = get_current_screen();
194
$screen_id = $screen ? $screen->id : '';
195
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
196
- $assets_path = ThemeGrill_Demo_Importer::plugin_url() . '/assets/';
197
198
- // Register Styles.
199
- wp_register_style( 'tg-demo-importer', $assets_path . 'css/demo-importer.css', array() );
200
201
- // Register Scripts.
202
wp_register_script( 'jquery-tiptip', $assets_path . 'js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), '1.3', true );
203
- wp_register_script( 'tg-demo-updates', $assets_path . 'js/admin/demo-updates' . $suffix . '.js', array( 'jquery', 'updates' ), '1.1.0', true );
204
- wp_register_script( 'tg-demo-importer', $assets_path . 'js/admin/demo-importer' . $suffix . '.js', array( 'jquery', 'jquery-tiptip', 'wp-backbone', 'wp-a11y', 'tg-demo-updates' ), '1.1.0', true );
205
206
// Demo Importer appearance page.
207
if ( 'appearance_page_demo-importer' === $screen_id ) {
@@ -221,15 +232,16 @@ class TG_Demo_Importer {
221
'livePreviewLabel' => _x( 'Live Preview %s', 'demo', 'themegrill-demo-importer' ),
222
'imported' => __( 'Imported!', 'themegrill-demo-importer' ),
223
'statusTextLink' => '<a href="https://docs.themegrill.com/knowledgebase/demo-import-process-failed/" target="_blank">' . __( 'Try this solution!', 'themegrill-demo-importer' ) . '</a>',
224
- )
225
) );
226
wp_localize_script( 'tg-demo-importer', 'demoImporterLocalizeScript', array(
227
- 'demos' => $this->is_preview() ? $this->prepare_previews_for_js( $this->demo_packages ) : $this->prepare_demos_for_js( $this->demo_config ),
228
'settings' => array(
229
'isPreview' => $this->is_preview(),
230
'isInstall' => $this->demo_installer,
231
'canInstall' => current_user_can( 'upload_files' ),
232
'installURI' => current_user_can( 'upload_files' ) ? self_admin_url( 'themes.php?page=demo-importer&browse=preview' ) : null,
233
'confirmDelete' => __( "Are you sure you want to delete this demo?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete.", 'themegrill-demo-importer' ),
234
'confirmImport' => __( 'Importing demo content will replicate the live demo and overwrites your current customizer, widgets and other settings. It might take few minutes to complete the demo import. Are you sure you want to import this demo?', 'themegrill-demo-importer' ),
235
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
@@ -248,78 +260,236 @@ class TG_Demo_Importer {
248
}
249
250
/**
251
- * Check for preview filter.
252
- * @return bool
253
*/
254
- public function is_preview() {
255
- if ( $this->demo_installer && isset( $_GET['browse'] ) ) {
256
- return 'preview' === $_GET['browse'] ? true : false;
257
}
258
259
- return false;
260
}
261
262
/**
263
- * Prepare previews for JavaScript.
264
*/
265
- private function prepare_previews_for_js( $demos = null ) {
266
- $prepared_demos = array();
267
- $current_template = get_option( 'template' );
268
- $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
269
- $demo_assets_path = ThemeGrill_Demo_Importer::plugin_url() . '/assets/';
270
271
- /**
272
- * Filters demo data before it is prepared for JavaScript.
273
- *
274
- * @param array $prepared_demos An associative array of demo data. Default empty array.
275
- * @param null|array $demos An array of demo config to prepare, if any.
276
- * @param string $demo_imported_id The current demo imported id.
277
- */
278
- $prepared_demos = (array) apply_filters( 'themegrill_demo_importer_pre_prepare_demos_for_js', array(), $demos, $demo_imported_id );
279
280
- if ( ! empty( $prepared_demos ) ) {
281
- return $prepared_demos;
282
}
283
284
- if ( ! empty( $demos ) ) {
285
- foreach ( $demos as $demo_id => $demo_data ) {
286
- $author = isset( $demo_data['author'] ) ? $demo_data['author'] : __( 'ThemeGrill', 'themegrill-demo-importer' );
287
- $download_url = isset( $demo_data['download'] ) ? $demo_data['download'] : "https://github.com/themegrill/themegrill-demo-pack/raw/master/packages/{$current_template}/{$demo_id}.zip";
288
- $pro_link = isset( $demo_data['pro_link'] ) ? $demo_data['pro_link'] : '';
289
290
- // Check if demo is installed.
291
- $installed = false;
292
- if ( in_array( $demo_id, array_keys( $this->demo_config ) ) ) {
293
- $installed = true;
294
- }
295
296
- // Prepare all demos.
297
- $prepared_demos[ $demo_id ] = array(
298
- 'id' => $demo_id,
299
- 'name' => $demo_data['name'],
300
- 'author' => $author,
301
- 'installed' => $installed,
302
- 'screenshot' => $this->get_screenshot_url( $demo_id, $demo_assets_path, $current_template ),
303
- 'description' => isset( $demo_data['description'] ) ? $demo_data['description'] : '',
304
- 'actions' => array(
305
- 'preview_url' => $demo_data['preview'],
306
- 'download_url' => $download_url,
307
- 'pro_link' => $pro_link
308
- ),
309
- );
310
}
311
}
312
313
- /**
314
- * Filters the demos prepared for JavaScript.
315
- *
316
- * Could be useful for changing the order, which is by name by default.
317
- *
318
- * @param array $prepared_demos Array of demos.
319
- */
320
- $prepared_demos = apply_filters( 'themegrill_demo_importer_prepare_demos_for_js', $prepared_demos );
321
- $prepared_demos = array_values( $prepared_demos );
322
- return array_filter( $prepared_demos );
323
}
324
325
/**
@@ -329,32 +499,34 @@ class TG_Demo_Importer {
329
* @return array An associative array of demo data, sorted by name.
330
*/
331
private function prepare_demos_for_js( $demos = null ) {
332
- $prepared_demos = array();
333
- $current_template = get_option( 'template' );
334
- $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
335
336
/**
337
* Filters demo data before it is prepared for JavaScript.
338
*
339
- * @param array $prepared_demos An associative array of demo data. Default empty array.
340
- * @param null|array $demos An array of demo config to prepare, if any.
341
- * @param string $demo_imported_id The current demo imported id.
342
*/
343
- $prepared_demos = (array) apply_filters( 'themegrill_demo_importer_pre_prepare_demos_for_js', array(), $demos, $demo_imported_id );
344
345
if ( ! empty( $prepared_demos ) ) {
346
return $prepared_demos;
347
}
348
349
// Make sure the imported demo is listed first.
350
- if ( isset( $demos[ $demo_imported_id ] ) ) {
351
- $prepared_demos[ $demo_imported_id ] = array();
352
}
353
354
if ( ! empty( $demos ) ) {
355
foreach ( $demos as $demo_id => $demo_data ) {
356
$demo_notices = array();
357
$encoded_slug = urlencode( $demo_id );
358
$demo_package = isset( $demo_data['demo_pack'] ) ? $demo_data['demo_pack'] : false;
359
$plugins_list = isset( $demo_data['plugins_list'] ) ? $demo_data['plugins_list'] : array();
360
@@ -370,26 +542,48 @@ class TG_Demo_Importer {
370
$demo_notices['required_plugins'] = true;
371
}
372
373
// Prepare all demos.
374
- $prepared_demos[ $demo_id ] = array(
375
- 'id' => $demo_id,
376
- 'name' => $demo_data['name'],
377
- 'theme' => $demo_data['theme'],
378
- 'package' => $demo_package,
379
- 'screenshot' => $this->import_file_url( $demo_id, 'screenshot.jpg' ),
380
- 'description' => isset( $demo_data['description'] ) ? $demo_data['description'] : '',
381
- 'author' => isset( $demo_data['author'] ) ? $demo_data['author'] : __( 'ThemeGrill', 'themegrill-demo-importer' ),
382
- 'authorAndUri' => '<a href="http://themegrill.com" target="_blank">ThemeGrill</a>',
383
- 'version' => isset( $demo_data['version'] ) ? $demo_data['version'] : '1.1.0',
384
- 'active' => $demo_id === $demo_imported_id,
385
- 'hasNotice' => $demo_notices,
386
- 'plugins' => $plugins_list,
387
- 'actions' => array(
388
- 'preview' => home_url( '/' ),
389
- 'demo_url' => $demo_data['demo_url'],
390
- 'delete' => current_user_can( 'upload_files' ) ? wp_nonce_url( admin_url( 'themes.php?page=demo-importer&browse=uploads&action=delete&amp;demo_pack=' . urlencode( $demo_id ) ), 'delete-demo_' . $demo_id ) : null,
391
- ),
392
- );
393
}
394
}
395
@@ -409,7 +603,7 @@ class TG_Demo_Importer {
409
* Demo Importer page output.
410
*/
411
public function demo_importer() {
412
- $demos = $this->prepare_demos_for_js( $this->demo_config );
413
414
if ( isset( $_GET['action'] ) && 'upload-demo' === $_GET['action'] ) {
415
$this->upload_demo_pack();
@@ -450,23 +644,6 @@ class TG_Demo_Importer {
450
}
451
}
452
453
- /**
454
- * Ajax handler for dismissing notice.
455
- */
456
- public function ajax_dismiss_notice() {
457
- if ( ! current_user_can( 'manage_options' ) ) {
458
- die( -1 );
459
- }
460
-
461
- $notice_id = sanitize_text_field( stripslashes( $_POST['notice_id'] ) );
462
-
463
- if ( ! empty( $notice_id ) && 'demo-importer' == $notice_id ) {
464
- update_option( 'themegrill_demo_imported_notice_dismiss', 1 );
465
- }
466
-
467
- die();
468
- }
469
-
470
/**
471
* Ajax handler for importing a demo.
472
*/
@@ -508,7 +685,7 @@ class TG_Demo_Importer {
508
$this->import_widget_settings( $slug, $demo_data, $status );
509
510
// Update imported demo ID.
511
- update_option( 'themegrill_demo_imported_id', $slug );
512
513
do_action( 'themegrill_ajax_demo_imported', $slug, $demo_data );
514
}
@@ -519,6 +696,18 @@ class TG_Demo_Importer {
519
wp_send_json_success( $status );
520
}
521
522
/**
523
* Import dummy content from a XML file.
524
* @param string $demo_id
@@ -808,150 +997,159 @@ class TG_Demo_Importer {
808
return $data;
809
}
810
811
- /**
812
- * Recursive function to address n level deep layoutbuilder data update.
813
- * @param array $panels_data
814
- * @param string $data_type
815
- * @param array $data_value
816
- * @return array
817
- */
818
- public function siteorigin_recursive_update( $panels_data, $data_type, $data_value) {
819
- static $instance = 0;
820
- foreach ( $panels_data as $panel_type => $panel_data ) {
821
- // Format the value based on panel type.
822
- switch ( $panel_type ) {
823
- case 'grids':
824
- foreach ( $panel_data as $instance_id => $grid_instance ) {
825
- if ( ! empty( $data_value['data_update']['grids_data'] ) ) {
826
- foreach ( $data_value['data_update']['grids_data'] as $grid_id => $grid_data ) {
827
- if ( ! empty( $grid_data['style'] ) && $instance_id === $grid_id ) {
828
- $level = isset( $grid_data['level'] ) ? $grid_data['level'] : (int)0;
829
- if( $level == $instance ) {
830
- foreach ( $grid_data['style'] as $style_key => $style_value ) {
831
- if ( empty( $style_value ) ) {
832
- continue;
833
- }
834
-
835
- // Format the value based on style key.
836
- switch ( $style_key ) {
837
- case 'background_image_attachment':
838
- $attachment_id = tg_get_attachment_id( $style_value );
839
-
840
- if ( 0 !== $attachment_id ) {
841
- $grid_instance['style'][ $style_key ] = $attachment_id;
842
- }
843
- break;
844
- default:
845
- $grid_instance['style'][ $style_key ] = $style_value;
846
- break;
847
- }
848
- }
849
- }
850
- }
851
- }
852
- }
853
-
854
- // Update panel grids data.
855
- $panels_data['grids'][ $instance_id ] = $grid_instance;
856
- }
857
- break;
858
-
859
- case 'widgets':
860
- foreach ($panel_data as $instance_id => $widget_instance ) {
861
- if( isset( $widget_instance['panels_data']['widgets'] ) ) {
862
- $instance = $instance+1;
863
- $child_panels_data = $widget_instance['panels_data'];
864
- $panels_data['widgets'][$instance_id]['panels_data'] = $this->siteorigin_recursive_update( $child_panels_data, $data_type, $data_value );
865
- $instance = $instance-1;
866
- continue;
867
- }
868
- if ( isset( $widget_instance['nav_menu'] ) && isset( $widget_instance['title'] ) ) {
869
- $nav_menu = wp_get_nav_menu_object( $widget_instance['title'] );
870
-
871
- if ( is_object( $nav_menu ) && $nav_menu->term_id ) {
872
- $widget_instance['nav_menu'] = $nav_menu->term_id;
873
- }
874
- }elseif ( ! empty( $data_value['data_update']['widgets_data'] ) ) {
875
- $instance_class = $widget_instance['panels_info']['class'];
876
- foreach ( $data_value['data_update']['widgets_data'] as $dropdown_type => $dropdown_data ) {
877
- if ( ! in_array( $dropdown_type, array( 'dropdown_pages', 'dropdown_categories' ) ) ) {
878
- continue;
879
- }
880
- switch ( $dropdown_type ) {
881
- case 'dropdown_pages':
882
- foreach ( $dropdown_data as $widget_id => $widget_data ) {
883
- if ( ! empty( $widget_data[ $instance_id ] ) && $widget_id == $instance_class ) {
884
- $level = isset( $widget_data['level'] ) ? $widget_data['level'] : (int)0;
885
- if( $level == $instance ) {
886
- foreach ( $widget_data[ $instance_id ] as $widget_key => $widget_value ) {
887
- $page = get_page_by_title( $widget_value );
888
-
889
- if ( is_object( $page ) && $page->ID ) {
890
- $widget_instance[ $widget_key ] = $page->ID;
891
- }
892
- }
893
- }
894
- }
895
- }
896
- break;
897
- case 'dropdown_categories':
898
- foreach ( $dropdown_data as $taxonomy => $taxonomy_data ) {
899
- if ( ! taxonomy_exists( $taxonomy ) ) {
900
- continue;
901
- }
902
-
903
- foreach ( $taxonomy_data as $widget_id => $widget_data ) {
904
- if ( ! empty( $widget_data[ $instance_id ] ) && $widget_id == $instance_class ) {
905
- $level = isset( $widget_data['level'] ) ? $widget_data['level'] : (int)0;
906
- if( $level == $instance ) {
907
- foreach ( $widget_data[ $instance_id ] as $widget_key => $widget_value ) {
908
- $term = get_term_by( 'name', $widget_value, $taxonomy );
909
-
910
- if ( is_object( $term ) && $term->term_id ) {
911
- $widget_instance[ $widget_key ] = $term->term_id;
912
- }
913
- }
914
- }
915
- }
916
- }
917
- }
918
- break;
919
- }
920
- }
921
- }
922
- $panels_data['widgets'][ $instance_id ] = $widget_instance;
923
- }
924
- break;
925
- }
926
- }
927
- return $panels_data;
928
- }
929
-
930
- /**
931
- * Update siteorigin panel settings data.
932
- * @param string $demo_id
933
- * @param array $demo_data
934
- */
935
- public function update_siteorigin_data( $demo_id, $demo_data ) {
936
- if ( ! empty( $demo_data['siteorigin_panels_data_update'] ) ) {
937
- foreach ( $demo_data['siteorigin_panels_data_update'] as $data_type => $data_value ) {
938
- if ( ! empty( $data_value['post_title'] ) ) {
939
- $page = get_page_by_title( $data_value['post_title'] );
940
-
941
- if ( is_object( $page ) && $page->ID ) {
942
- $panels_data = get_post_meta( $page->ID, 'panels_data', true );
943
-
944
- if ( ! empty( $panels_data ) ) {
945
- $panels_data = $this->siteorigin_recursive_update( $panels_data, $data_type, $data_value );
946
-
947
- }
948
- // Update siteorigin panels data.
949
- update_post_meta( $page->ID, 'panels_data', $panels_data );
950
- }
951
- }
952
- }
953
- }
954
- }
955
}
956
957
new TG_Demo_Importer();
45
46
// Add Demo Importer menu.
47
if ( apply_filters( 'themegrill_show_demo_importer_page', true ) ) {
48
+ add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
49
add_action( 'admin_head', array( $this, 'add_menu_classes' ) );
50
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
51
}
52
53
+ // Help Tabs.
54
+ if ( apply_filters( 'themegrill_demo_importer_enable_admin_help_tab', true ) ) {
55
+ add_action( 'current_screen', array( $this, 'add_help_tabs' ), 50 );
56
+ }
57
+
58
+ // Reset Wizard.
59
+ add_action( 'wp_loaded', array( $this, 'hide_reset_notice' ) );
60
+ add_action( 'admin_init', array( $this, 'reset_wizard_actions' ) );
61
+ add_action( 'admin_notices', array( $this, 'reset_wizard_notice' ) );
62
+
63
+ // Footer rating text.
64
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
65
+
66
+ // AJAX Events to import demo and update rating footer.
67
add_action( 'wp_ajax_import-demo', array( $this, 'ajax_import_demo' ) );
68
+ add_action( 'wp_ajax_footer-text-rated', array( $this, 'ajax_footer_text_rated' ) );
69
70
// Update custom nav menu items and siteorigin panel data.
71
add_action( 'themegrill_ajax_demo_imported', array( $this, 'update_nav_menu_items' ) );
106
107
// If enabled demo pack, load from upload dir.
108
if ( $this->is_enabled_demo_pack( $demo_dir ) ) {
109
+ $working_dir = TGDM_DEMO_URL . $demo_dir;
110
}
111
112
return trailingslashit( $working_dir ) . sanitize_file_name( $filename );
113
}
114
115
/**
116
* Get the import file path.
124
125
// If enabled demo pack, load from upload dir.
126
if ( $this->is_enabled_demo_pack( $demo_dir ) ) {
127
+ $working_dir = TGDM_DEMO_DIR . $demo_dir . '/dummy-data';
128
}
129
130
return trailingslashit( $working_dir ) . sanitize_file_name( $filename );
131
}
132
133
+ /**
134
+ * Get the demo preview screenshot URL.
135
+ *
136
+ * @param string $demo_dir
137
+ * @param string $current_template
138
+ * @return string the demo preview screenshot URL.
139
+ */
140
+ public function get_screenshot_url( $demo_dir, $current_template ) {
141
+ $screenshot_theme_path = get_template_directory() . "/images/demo/{$demo_dir}.jpg";
142
+ $screenshot_plugin_path = TGDM()->plugin_path() . "/assets/images/{$current_template}/{$demo_dir}.jpg";
143
+
144
+ if ( file_exists( $screenshot_theme_path ) ) {
145
+ $screenshot_url = get_template_directory_uri() . "/images/demo/{$demo_dir}.jpg";
146
+ } elseif ( file_exists( $screenshot_plugin_path ) ) {
147
+ $screenshot_url = TGDM()->plugin_url() . "/assets/images/{$current_template}/{$demo_dir}.jpg";
148
+ } else {
149
+ $theme_data = wp_get_theme();
150
+ $screenshot_url = $theme_data->get_screenshot();
151
+ }
152
+
153
+ return $screenshot_url;
154
+ }
155
+
156
/**
157
* Check if demo pack is enabled.
158
* @param array $demo_id
169
/**
170
* Add menu item.
171
*/
172
+ public function admin_menu() {
173
add_theme_page( __( 'Demo Importer', 'themegrill-demo-importer' ), __( 'Demo Importer', 'themegrill-demo-importer' ), 'switch_themes', 'demo-importer', array( $this, 'demo_importer' ) );
174
}
175
201
$screen = get_current_screen();
202
$screen_id = $screen ? $screen->id : '';
203
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
204
+ $assets_path = TGDM()->plugin_url() . '/assets/';
205
+
206
+ // Register admin styles.
207
+ wp_register_style( 'tg-demo-importer', $assets_path . 'css/demo-importer.css', array(), TGDM_VERSION );
208
209
+ // Add RTL support for admin styles.
210
+ wp_style_add_data( 'tg-demo-importer', 'rtl', 'replace' );
211
212
+ // Register admin scripts.
213
wp_register_script( 'jquery-tiptip', $assets_path . 'js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), '1.3', true );
214
+ wp_register_script( 'tg-demo-updates', $assets_path . 'js/admin/demo-updates' . $suffix . '.js', array( 'jquery', 'updates' ), TGDM_VERSION, true );
215
+ wp_register_script( 'tg-demo-importer', $assets_path . 'js/admin/demo-importer' . $suffix . '.js', array( 'jquery', 'jquery-tiptip', 'wp-backbone', 'wp-a11y', 'tg-demo-updates' ), TGDM_VERSION, true );
216
217
// Demo Importer appearance page.
218
if ( 'appearance_page_demo-importer' === $screen_id ) {
232
'livePreviewLabel' => _x( 'Live Preview %s', 'demo', 'themegrill-demo-importer' ),
233
'imported' => __( 'Imported!', 'themegrill-demo-importer' ),
234
'statusTextLink' => '<a href="https://docs.themegrill.com/knowledgebase/demo-import-process-failed/" target="_blank">' . __( 'Try this solution!', 'themegrill-demo-importer' ) . '</a>',
235
+ ),
236
) );
237
wp_localize_script( 'tg-demo-importer', 'demoImporterLocalizeScript', array(
238
+ 'demos' => $this->prepare_demos_for_js( $this->is_preview() ? $this->demo_packages : $this->demo_config ),
239
'settings' => array(
240
'isPreview' => $this->is_preview(),
241
'isInstall' => $this->demo_installer,
242
'canInstall' => current_user_can( 'upload_files' ),
243
'installURI' => current_user_can( 'upload_files' ) ? self_admin_url( 'themes.php?page=demo-importer&browse=preview' ) : null,
244
+ 'confirmReset' => __( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the reset wizard now?', 'themegrill-demo-importer' ),
245
'confirmDelete' => __( "Are you sure you want to delete this demo?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete.", 'themegrill-demo-importer' ),
246
'confirmImport' => __( 'Importing demo content will replicate the live demo and overwrites your current customizer, widgets and other settings. It might take few minutes to complete the demo import. Are you sure you want to import this demo?', 'themegrill-demo-importer' ),
247
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
260
}
261
262
/**
263
+ * Change the admin footer text.
264
+ * @param string $footer_text
265
+ * @return string
266
*/
267
+ public function admin_footer_text( $footer_text ) {
268
+ if ( ! current_user_can( 'manage_options' ) ) {
269
+ return $footer_text;
270
}
271
272
+ $current_screen = get_current_screen();
273
+
274
+ // Check to make sure we're on a ThemeGrill Demo Importer admin page.
275
+ if ( isset( $current_screen->id ) && apply_filters( 'themegrill_demo_importer_display_admin_footer_text', in_array( $current_screen->id, array( 'appearance_page_demo-importer' ) ) ) ) {
276
+ // Change the footer text.
277
+ if ( ! get_option( 'themegrill_demo_importer_admin_footer_text_rated' ) ) {
278
+ $footer_text = sprintf( __( 'If you like <strong>ThemeGrill Demo Importer</strong> please leave us a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s rating. A huge thanks in advance!', 'themegrill-demo-importer' ), '<a href="https://wordpress.org/support/plugin/themegrill-demo-importer/reviews?rate=5#new-post" target="_blank" class="themegrill-demo-importer-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'themegrill-demo-importer' ) . '">', '</a>' );
279
+ } else {
280
+ $footer_text = __( 'Thank you for importing with ThemeGrill Demo Importer.', 'themegrill-demo-importer' );
281
+ }
282
+ }
283
+
284
+ return $footer_text;
285
}
286
287
/**
288
+ * Add Contextual help tabs.
289
*/
290
+ public function add_help_tabs() {
291
+ $screen = get_current_screen();
292
293
+ if ( ! $screen || ! in_array( $screen->id, array( 'appearance_page_demo-importer' ) ) ) {
294
+ return;
295
+ }
296
297
+ $video_map = array(
298
+ 'demo-importer' => array(
299
+ 'title' => __( 'Importing Demo', 'themegrill-demo-importer' ),
300
+ 'url' => '//fast.wistia.net/embed/iframe/ctdquor9uh.jsonp?',
301
+ ),
302
+ );
303
+
304
+ $page = empty( $_GET['page'] ) ? '' : sanitize_title( $_GET['page'] );
305
+ $video_key = $page ? $page : $screen->id;
306
+
307
+ if ( ! $this->demo_installer && isset( $video_map[ $video_key ] ) ) {
308
+ $screen->add_help_tab( array(
309
+ 'id' => 'themegrill_demo_importer_guided_tour_tab',
310
+ 'title' => __( 'Guided Tour', 'themegrill-demo-importer' ),
311
+ 'content' =>
312
+ '<h2>' . __( 'Guided Tour', 'themegrill-demo-importer' ) . ' &ndash; ' . esc_html( $video_map[ $video_key ]['title'] ) . '</h2>' .
313
+ '<div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;">
314
+ <div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;">
315
+ <iframe src="' . esc_url( $video_map[ $video_key ]['url'] ) . 'seo=false&videoFoam=true" title="Wistia video player" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="100%" height="100%"></iframe>
316
+ </div></div>
317
+ <script src="//fast.wistia.net/assets/external/E-v1.js" async></script>',
318
+ ) );
319
}
320
321
+ $screen->add_help_tab( array(
322
+ 'id' => 'themegrill_demo_importer_support_tab',
323
+ 'title' => __( 'Help &amp; Support', 'themegrill-demo-importer' ),
324
+ 'content' =>
325
+ '<h2>' . __( 'Help &amp; Support', 'themegrill-demo-importer' ) . '</h2>' .
326
+ '<p>' . sprintf(
327
+ __( 'Should you need help understanding, using, or extending ThemeGrill Demo Importer, <a href="%s">please read our documentation</a>. You will find all kinds of resources including snippets, tutorials and much more.' , 'themegrill-demo-importer' ),
328
+ 'https://themegrill.com/docs/themegrill-demo-importer/'
329
+ ) . '</p>' .
330
+ '<p>' . sprintf(
331
+ __( 'For further assistance with ThemeGrill Demo Importer core you can use the <a href="%1$s">community forum</a>. If you need help with premium themes sold by ThemeGrill, please <a href="%2$s">use our free support forum</a>.', 'themegrill-demo-importer' ),
332
+ 'https://wordpress.org/support/plugin/themegrill-demo-importer',
333
+ 'https://themegrill.com/support-forum/'
334
+ ) . '</p>' .
335
+ '<p><a href="' . 'https://wordpress.org/support/plugin/themegrill-demo-importer' . '" class="button button-primary">' . __( 'Community forum', 'themegrill-demo-importer' ) . '</a> <a href="' . 'https://themegrill.com/support-forum/' . '" class="button">' . __( 'ThemeGrill Support', 'themegrill-demo-importer' ) . '</a></p>',
336
+ ) );
337
+
338
+ $screen->add_help_tab( array(
339
+ 'id' => 'themegrill_demo_importer_bugs_tab',
340
+ 'title' => __( 'Found a bug?', 'themegrill-demo-importer' ),
341
+ 'content' =>
342
+ '<h2>' . __( 'Found a bug?', 'themegrill-demo-importer' ) . '</h2>' .
343
+ '<p>' . sprintf( __( 'If you find a bug within ThemeGrill Demo Importer you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible.', 'themegrill-demo-importer' ), 'https://github.com/themegrill/themegrill-demo-importer/issues?state=open', 'https://github.com/themegrill/themegrill-demo-importer/blob/master/.github/CONTRIBUTING.md' ) . '</p>' .
344
+ '<p><a href="' . 'https://github.com/themegrill/themegrill-demo-importer/issues?state=open' . '" class="button button-primary">' . __( 'Report a bug', 'themegrill-demo-importer' ) . '</a></p>',
345
+
346
+ ) );
347
+
348
+ $screen->add_help_tab( array(
349
+ 'id' => 'themegrill_demo_importer_reset_tab',
350
+ 'title' => __( 'Reset wizard', 'themegrill-demo-importer' ),
351
+ 'content' =>
352
+ '<h2>' . __( 'Reset wizard', 'themegrill-demo-importer' ) . '</h2>' .
353
+ '<p>' . __( 'If you need to reset the WordPress back to default again, please click on the button below.', 'themegrill-demo-importer' ) . '</p>' .
354
+ '<p><a href="' . esc_url( add_query_arg( 'do_reset_wordpress', 'true', admin_url( 'themes.php?page=demo-importer' ) ) ) . '" class="button button-primary themegrill-reset-wordpress">' . __( 'Reset wizard', 'themegrill-demo-importer' ) . '</a></p>',
355
+ ) );
356
+
357
+ $screen->set_help_sidebar(
358
+ '<p><strong>' . __( 'For more information:', 'themegrill-demo-importer' ) . '</strong></p>' .
359
+ '<p><a href="' . 'https://themegrill.com/demo-importer/' . '" target="_blank">' . __( 'About Demo Importer', 'themegrill-demo-importer' ) . '</a></p>' .
360
+ '<p><a href="' . 'https://wordpress.org/plugins/themegrill-demo-importer/' . '" target="_blank">' . __( 'WordPress.org project', 'themegrill-demo-importer' ) . '</a></p>' .
361
+ '<p><a href="' . 'https://github.com/themegrill/themegrill-demo-importer' . '" target="_blank">' . __( 'Github project', 'themegrill-demo-importer' ) . '</a></p>' .
362
+ '<p><a href="' . 'https://themegrill.com/wordpress-themes/' . '" target="_blank">' . __( 'Official themes', 'themegrill-demo-importer' ) . '</a></p>' .
363
+ '<p><a href="' . 'https://themegrill.com/plugins/' . '" target="_blank">' . __( 'Official plugins', 'themegrill-demo-importer' ) . '</a></p>'
364
+ );
365
+ }
366
367
+ /**
368
+ * Reset wizard notice.
369
+ */
370
+ public function reset_wizard_notice() {
371
+ $screen = get_current_screen();
372
+ $demo_activated_id = get_option( 'themegrill_demo_importer_activated_id' );
373
+ $demo_notice_dismiss = get_option( 'themegrill_demo_importer_reset_notice' );
374
375
+ if ( ! $screen || ! in_array( $screen->id, array( 'appearance_page_demo-importer' ) ) ) {
376
+ return;
377
+ }
378
+
379
+ // Output reset wizard notice.
380
+ if ( ! $demo_notice_dismiss && in_array( $demo_activated_id, array_keys( $this->demo_config ) ) ) {
381
+ include_once( dirname( __FILE__ ) . '/includes/admin/views/html-notice-reset-wizard.php' );
382
+ } elseif ( isset( $_GET['reset'] ) && 'true' === $_GET['reset'] ) {
383
+ include_once( dirname( __FILE__ ) . '/includes/admin/views/html-notice-reset-wizard-success.php' );
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Hide a notice if the GET variable is set.
389
+ */
390
+ public function hide_reset_notice() {
391
+ if ( isset( $_GET['themegrill-demo-importer-hide-notice'] ) && isset( $_GET['_themegrill_demo_importer_notice_nonce'] ) ) {
392
+ if ( ! wp_verify_nonce( $_GET['_themegrill_demo_importer_notice_nonce'], 'themegrill_demo_importer_hide_notice_nonce' ) ) {
393
+ wp_die( __( 'Action failed. Please refresh the page and retry.', 'themegrill-demo-importer' ) );
394
+ }
395
+
396
+ if ( ! current_user_can( 'manage_options' ) ) {
397
+ wp_die( __( 'Cheatin&#8217; huh?', 'themegrill-demo-importer' ) );
398
+ }
399
+
400
+ $hide_notice = sanitize_text_field( $_GET['themegrill-demo-importer-hide-notice'] );
401
+
402
+ if ( ! empty( $hide_notice ) && 'reset_notice' == $hide_notice ) {
403
+ update_option( 'themegrill_demo_importer_reset_notice', 1 );
404
}
405
}
406
+ }
407
408
+ /**
409
+ * Reset actions when a reset button is clicked.
410
+ */
411
+ public function reset_wizard_actions() {
412
+ global $wpdb, $current_user;
413
+
414
+ if ( ! empty( $_GET['do_reset_wordpress'] ) ) {
415
+ require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
416
+
417
+ $template = get_option( 'template' );
418
+ $blogname = get_option( 'blogname' );
419
+ $admin_email = get_option( 'admin_email' );
420
+ $blog_public = get_option( 'blog_public' );
421
+ $footer_rated = get_option( 'themegrill_demo_importer_admin_footer_text_rated' );
422
+
423
+ if ( $current_user->user_login != 'admin' ) {
424
+ $user = get_user_by( 'login', 'admin' );
425
+ }
426
+
427
+ if ( empty( $user->user_level ) || $user->user_level < 10 ) {
428
+ $user = $current_user;
429
+ }
430
+
431
+ // Drop tables.
432
+ $drop_tables = $wpdb->get_col( sprintf( "SHOW TABLES LIKE '%s%%'", str_replace( '_', '\_', $wpdb->prefix ) ) );
433
+ foreach ( $drop_tables as $table ) {
434
+ $wpdb->query( "DROP TABLE IF EXISTS $table" );
435
+ }
436
+
437
+ // Installs the site.
438
+ $result = wp_install( $blogname, $user->user_login, $user->user_email, $blog_public );
439
+
440
+ // Updates the user password with a old one.
441
+ $wpdb->update( $wpdb->users, array( 'user_pass' => $user->user_pass, 'user_activation_key' => '' ), array( 'ID' => $result['user_id'] ) );
442
+
443
+ // Set up the Password change nag.
444
+ $default_password_nag = get_user_option( 'default_password_nag', $result['user_id'] );
445
+ if ( $default_password_nag ) {
446
+ update_user_option( $result['user_id'], 'default_password_nag', false, true );
447
+ }
448
+
449
+ // Update footer text.
450
+ if ( $footer_rated ) {
451
+ update_option( 'themegrill_demo_importer_admin_footer_text_rated', $footer_rated );
452
+ }
453
+
454
+ // Switch current theme.
455
+ $current_theme = wp_get_theme( $template );
456
+ if ( $current_theme->exists() ) {
457
+ switch_theme( $template );
458
+ }
459
+
460
+ // Activate required plugins.
461
+ $activate_required_plugins = (array) apply_filters( 'themegrill_demo_importer_' . $template . '_required_plugins', array( TGDM_PLUGIN_BASENAME ) );
462
+ if ( ! empty( $activate_required_plugins ) ) {
463
+ foreach ( $activate_required_plugins as $plugin ) {
464
+ $plugin = plugin_basename( $plugin );
465
+ if ( ! is_wp_error( validate_plugin( $plugin ) ) ) {
466
+ activate_plugin( $plugin );
467
+ }
468
+ }
469
+ } else {
470
+ activate_plugin( TGDM_PLUGIN_BASENAME );
471
+ }
472
+
473
+ // Update the cookies.
474
+ wp_clear_auth_cookie();
475
+ wp_set_auth_cookie( $result['user_id'] );
476
+
477
+ // Redirect to demo importer page to display reset success notice.
478
+ wp_safe_redirect( admin_url( 'themes.php?page=demo-importer&reset=true' ) );
479
+ exit();
480
+ }
481
+ }
482
+
483
+ /**
484
+ * Check for preview filter.
485
+ * @return bool
486
+ */
487
+ public function is_preview() {
488
+ if ( $this->demo_installer && isset( $_GET['browse'] ) ) {
489
+ return 'preview' === $_GET['browse'] ? true : false;
490
+ }
491
+
492
+ return false;
493
}
494
495
/**
499
* @return array An associative array of demo data, sorted by name.
500
*/
501
private function prepare_demos_for_js( $demos = null ) {
502
+ $prepared_demos = array();
503
+ $current_template = get_option( 'template' );
504
+ $demo_activated_id = get_option( 'themegrill_demo_importer_activated_id' );
505
506
/**
507
* Filters demo data before it is prepared for JavaScript.
508
*
509
+ * @param array $prepared_demos An associative array of demo data. Default empty array.
510
+ * @param null|array $demos An array of demo config to prepare, if any.
511
+ * @param string $demo_activated_id The current demo activated id.
512
*/
513
+ $prepared_demos = (array) apply_filters( 'themegrill_demo_importer_pre_prepare_demos_for_js', array(), $demos, $demo_activated_id );
514
515
if ( ! empty( $prepared_demos ) ) {
516
return $prepared_demos;
517
}
518
519
// Make sure the imported demo is listed first.
520
+ if ( ! $this->is_preview() && isset( $demos[ $demo_activated_id ] ) ) {
521
+ $prepared_demos[ $demo_activated_id ] = array();
522
}
523
524
if ( ! empty( $demos ) ) {
525
foreach ( $demos as $demo_id => $demo_data ) {
526
$demo_notices = array();
527
$encoded_slug = urlencode( $demo_id );
528
+ $premium_link = isset( $demo_data['pro_link'] ) ? $demo_data['pro_link'] : '';
529
+ $download_url = isset( $demo_data['download'] ) ? $demo_data['download'] : "https://github.com/themegrill/themegrill-demo-pack/raw/master/packages/{$current_template}/{$demo_id}.zip";
530
$demo_package = isset( $demo_data['demo_pack'] ) ? $demo_data['demo_pack'] : false;
531
$plugins_list = isset( $demo_data['plugins_list'] ) ? $demo_data['plugins_list'] : array();
532
542
$demo_notices['required_plugins'] = true;
543
}
544
545
+ // Check if demo is installed.
546
+ $installed = false;
547
+ if ( in_array( $demo_id, array_keys( $this->demo_config ) ) ) {
548
+ $installed = true;
549
+ }
550
+
551
// Prepare all demos.
552
+ if ( $this->is_preview() ) {
553
+ $prepared_demos[ $demo_id ] = array(
554
+ 'id' => $demo_id,
555
+ 'name' => $demo_data['name'],
556
+ 'installed' => $installed,
557
+ 'screenshot' => $this->get_screenshot_url( $demo_id, $current_template ),
558
+ 'description' => isset( $demo_data['description'] ) ? $demo_data['description'] : '',
559
+ 'author' => isset( $demo_data['author'] ) ? $demo_data['author'] : __( 'ThemeGrill', 'themegrill-demo-importer' ),
560
+ 'actions' => array(
561
+ 'pro_link' => $premium_link,
562
+ 'preview_url' => $demo_data['preview'],
563
+ 'download_url' => $download_url,
564
+ ),
565
+ );
566
+ } else {
567
+ $prepared_demos[ $demo_id ] = array(
568
+ 'id' => $demo_id,
569
+ 'name' => $demo_data['name'],
570
+ 'theme' => $demo_data['theme'],
571
+ 'package' => $demo_package,
572
+ 'screenshot' => $this->import_file_url( $demo_id, 'screenshot.jpg' ),
573
+ 'description' => isset( $demo_data['description'] ) ? $demo_data['description'] : '',
574
+ 'author' => isset( $demo_data['author'] ) ? $demo_data['author'] : __( 'ThemeGrill', 'themegrill-demo-importer' ),
575
+ 'authorAndUri' => '<a href="https://themegrill.com" target="_blank">ThemeGrill</a>',
576
+ 'version' => isset( $demo_data['version'] ) ? $demo_data['version'] : '1.1.0',
577
+ 'active' => $demo_id === $demo_activated_id,
578
+ 'hasNotice' => $demo_notices,
579
+ 'plugins' => $plugins_list,
580
+ 'actions' => array(
581
+ 'preview' => home_url( '/' ),
582
+ 'demo_url' => $demo_data['demo_url'],
583
+ 'delete' => current_user_can( 'upload_files' ) ? wp_nonce_url( admin_url( 'themes.php?page=demo-importer&browse=uploads&action=delete&amp;demo_pack=' . urlencode( $demo_id ) ), 'delete-demo_' . $demo_id ) : null,
584
+ ),
585
+ );
586
+ }
587
}
588
}
589
603
* Demo Importer page output.
604
*/
605
public function demo_importer() {
606
+ $demos = $this->prepare_demos_for_js( $this->is_preview() ? $this->demo_packages : $this->demo_config );
607
608
if ( isset( $_GET['action'] ) && 'upload-demo' === $_GET['action'] ) {
609
$this->upload_demo_pack();
644
}
645
}
646
647
/**
648
* Ajax handler for importing a demo.
649
*/
685
$this->import_widget_settings( $slug, $demo_data, $status );
686
687
// Update imported demo ID.
688
+ update_option( 'themegrill_demo_importer_activated_id', $slug );
689
690
do_action( 'themegrill_ajax_demo_imported', $slug, $demo_data );
691
}
696
wp_send_json_success( $status );
697
}
698
699
+ /**
700
+ * Triggered when clicking the rating footer.
701
+ */
702
+ public function ajax_footer_text_rated() {
703
+ if ( ! current_user_can( 'manage_options' ) ) {
704
+ die( -1 );
705
+ }
706
+
707
+ update_option( 'themegrill_demo_importer_admin_footer_text_rated', 1 );
708
+ die();
709
+ }
710
+
711
/**
712
* Import dummy content from a XML file.
713
* @param string $demo_id
997
return $data;
998
}
999
1000
+ /**
1001
+ * Recursive function to address n level deep layoutbuilder data update.
1002
+ * @param array $panels_data
1003
+ * @param string $data_type
1004
+ * @param array $data_value
1005
+ * @return array
1006
+ */
1007
+ public function siteorigin_recursive_update( $panels_data, $data_type, $data_value ) {
1008
+ static $instance = 0;
1009
+
1010
+ foreach ( $panels_data as $panel_type => $panel_data ) {
1011
+ // Format the value based on panel type.
1012
+ switch ( $panel_type ) {
1013
+ case 'grids':
1014
+ foreach ( $panel_data as $instance_id => $grid_instance ) {
1015
+ if ( ! empty( $data_value['data_update']['grids_data'] ) ) {
1016
+ foreach ( $data_value['data_update']['grids_data'] as $grid_id => $grid_data ) {
1017
+ if ( ! empty( $grid_data['style'] ) && $instance_id === $grid_id ) {
1018
+ $level = isset( $grid_data['level'] ) ? $grid_data['level'] : (int) 0;
1019
+ if ( $level == $instance ) {
1020
+ foreach ( $grid_data['style'] as $style_key => $style_value ) {
1021
+ if ( empty( $style_value ) ) {
1022
+ continue;
1023
+ }
1024
+
1025
+ // Format the value based on style key.
1026
+ switch ( $style_key ) {
1027
+ case 'background_image_attachment':
1028
+ $attachment_id = tg_get_attachment_id( $style_value );
1029
+
1030
+ if ( 0 !== $attachment_id ) {
1031
+ $grid_instance['style'][ $style_key ] = $attachment_id;
1032
+ }
1033
+ break;
1034
+ default:
1035
+ $grid_instance['style'][ $style_key ] = $style_value;
1036
+ break;
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+ // Update panel grids data.
1045
+ $panels_data['grids'][ $instance_id ] = $grid_instance;
1046
+ }
1047
+ break;
1048
+
1049
+ case 'widgets':
1050
+ foreach ( $panel_data as $instance_id => $widget_instance ) {
1051
+ if ( isset( $widget_instance['panels_data']['widgets'] ) ) {
1052
+ $instance = $instance + 1;
1053
+ $child_panels_data = $widget_instance['panels_data'];
1054
+ $panels_data['widgets'][ $instance_id ]['panels_data'] = $this->siteorigin_recursive_update( $child_panels_data, $data_type, $data_value );
1055
+ $instance = $instance - 1;
1056
+ continue;
1057
+ }
1058
+
1059
+ if ( isset( $widget_instance['nav_menu'] ) && isset( $widget_instance['title'] ) ) {
1060
+ $nav_menu = wp_get_nav_menu_object( $widget_instance['title'] );
1061
+
1062
+ if ( is_object( $nav_menu ) && $nav_menu->term_id ) {
1063
+ $widget_instance['nav_menu'] = $nav_menu->term_id;
1064
+ }
1065
+ } elseif ( ! empty( $data_value['data_update']['widgets_data'] ) ) {
1066
+ $instance_class = $widget_instance['panels_info']['class'];
1067
+
1068
+ foreach ( $data_value['data_update']['widgets_data'] as $dropdown_type => $dropdown_data ) {
1069
+ if ( ! in_array( $dropdown_type, array( 'dropdown_pages', 'dropdown_categories' ) ) ) {
1070
+ continue;
1071
+ }
1072
+
1073
+ // Format the value based on data type.
1074
+ switch ( $dropdown_type ) {
1075
+ case 'dropdown_pages':
1076
+ foreach ( $dropdown_data as $widget_id => $widget_data ) {
1077
+ if ( ! empty( $widget_data[ $instance_id ] ) && $widget_id == $instance_class ) {
1078
+ $level = isset( $widget_data['level'] ) ? $widget_data['level'] : (int) 0;
1079
+
1080
+ if ( $level == $instance ) {
1081
+ foreach ( $widget_data[ $instance_id ] as $widget_key => $widget_value ) {
1082
+ $page = get_page_by_title( $widget_value );
1083
+
1084
+ if ( is_object( $page ) && $page->ID ) {
1085
+ $widget_instance[ $widget_key ] = $page->ID;
1086
+ }
1087
+ }
1088
+ }
1089
+ }
1090
+ }
1091
+ break;
1092
+ case 'dropdown_categories':
1093
+ foreach ( $dropdown_data as $taxonomy => $taxonomy_data ) {
1094
+ if ( ! taxonomy_exists( $taxonomy ) ) {
1095
+ continue;
1096
+ }
1097
+
1098
+ foreach ( $taxonomy_data as $widget_id => $widget_data ) {
1099
+ if ( ! empty( $widget_data[ $instance_id ] ) && $widget_id == $instance_class ) {
1100
+ $level = isset( $widget_data['level'] ) ? $widget_data['level'] : (int) 0;
1101
+
1102
+ if ( $level == $instance ) {
1103
+ foreach ( $widget_data[ $instance_id ] as $widget_key => $widget_value ) {
1104
+ $term = get_term_by( 'name', $widget_value, $taxonomy );
1105
+
1106
+ if ( is_object( $term ) && $term->term_id ) {
1107
+ $widget_instance[ $widget_key ] = $term->term_id;
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+ }
1113
+ }
1114
+ break;
1115
+ }
1116
+ }
1117
+ }
1118
+
1119
+ $panels_data['widgets'][ $instance_id ] = $widget_instance;
1120
+ }
1121
+ break;
1122
+ }
1123
+ }
1124
+
1125
+ return $panels_data;
1126
+ }
1127
+
1128
+ /**
1129
+ * Update siteorigin panel settings data.
1130
+ * @param string $demo_id
1131
+ * @param array $demo_data
1132
+ */
1133
+ public function update_siteorigin_data( $demo_id, $demo_data ) {
1134
+ if ( ! empty( $demo_data['siteorigin_panels_data_update'] ) ) {
1135
+ foreach ( $demo_data['siteorigin_panels_data_update'] as $data_type => $data_value ) {
1136
+ if ( ! empty( $data_value['post_title'] ) ) {
1137
+ $page = get_page_by_title( $data_value['post_title'] );
1138
+
1139
+ if ( is_object( $page ) && $page->ID ) {
1140
+ $panels_data = get_post_meta( $page->ID, 'panels_data', true );
1141
+
1142
+ if ( ! empty( $panels_data ) ) {
1143
+ $panels_data = $this->siteorigin_recursive_update( $panels_data, $data_type, $data_value );
1144
+ }
1145
+
1146
+ // Update siteorigin panels data.
1147
+ update_post_meta( $page->ID, 'panels_data', $panels_data );
1148
+ }
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
}
1154
1155
new TG_Demo_Importer();
includes/functions-demo-update.php CHANGED
@@ -67,3 +67,24 @@ function tg_update_demo_importer_config( $demo_config ) {
67
return $demo_config;
68
}
69
add_filter( 'themegrill_demo_importer_config', 'tg_update_demo_importer_config', 99 );
67
return $demo_config;
68
}
69
add_filter( 'themegrill_demo_importer_config', 'tg_update_demo_importer_config', 99 );
70
+
71
+ /**
72
+ * Update demo importer options.
73
+ * @since 1.3.4
74
+ */
75
+ function tg_update_demo_importer_options() {
76
+ $migrate_options = array(
77
+ 'themegrill_demo_imported_id' => 'themegrill_demo_importer_activated_id',
78
+ 'themegrill_demo_imported_notice_dismiss' => 'themegrill_demo_importer_reset_notice',
79
+ );
80
+
81
+ foreach ( $migrate_options as $old_option => $new_option ) {
82
+ $value = get_option( $old_option );
83
+
84
+ if ( $value ) {
85
+ update_option( $new_option, $value );
86
+ delete_option( $old_option );
87
+ }
88
+ }
89
+ }
90
+ add_action( 'admin_init', 'tg_update_demo_importer_options' );
includes/includes/admin/class-demo-installer-skin.php CHANGED
@@ -1,6 +1,6 @@
1
<?php
2
/**
3
- * Upgrader API: Plugin_Upgrader_Skin class
4
*
5
* Demo Installer Skin for the WordPress Demo Importer.
6
*
1
<?php
2
/**
3
+ * Upgrader API: TG_Demo_Installer_Skin class
4
*
5
* Demo Installer Skin for the WordPress Demo Importer.
6
*
includes/includes/admin/class-demo-upgrader.php CHANGED
@@ -80,7 +80,7 @@ class TG_Demo_Upgrader extends WP_Upgrader {
80
81
$this->run( array(
82
'package' => $package,
83
- 'destination' => $upload_dir['basedir'] . '/tg-demo-pack',
84
'clear_destination' => true, // Do overwrite files.
85
'protect_destination' => true,
86
'clear_working' => true,
80
81
$this->run( array(
82
'package' => $package,
83
+ 'destination' => TGDM_DEMO_DIR,
84
'clear_destination' => true, // Do overwrite files.
85
'protect_destination' => true,
86
'clear_working' => true,
includes/includes/admin/views/html-admin-page-importer.php CHANGED
@@ -7,21 +7,20 @@ if ( ! defined( 'ABSPATH' ) ) {
7
exit;
8
}
9
10
- $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
11
-
12
?>
13
<div class="wrap demo-importer">
14
- <h1><?php esc_html_e( 'Demo Importer', 'themegrill-demo-importer' ); ?>
15
<span class="title-count demo-count"><?php echo count( $this->demo_config ); ?></span>
16
- <?php if ( apply_filters( 'themegrill_demo_importer_new_demos', false ) ) : ?>
17
- <a href="<?php echo esc_url( 'https://themegrill.com/upcoming-new-demos' ); ?>" class="page-title-action" target="_blank"><?php esc_html_e( 'New Demos', 'themegrill-demo-importer' ); ?></a>
18
- <?php endif; ?>
19
</h1>
20
- <?php if ( ! get_option( 'themegrill_demo_imported_notice_dismiss' ) && in_array( $demo_imported_id, array_keys( $this->demo_config ) ) ) : ?>
21
- <div id="message" class="notice notice-info is-dismissible" data-notice_id="demo-importer">
22
- <p><?php printf( __( '<strong>Notice</strong> &#8211; If you want to completely remove a demo installation after importing it, you can use a plugin like %1$sWordPress Reset%2$s.', 'themegrill-demo-importer' ), '<a target="_blank" href="' . esc_url( 'https://wordpress.org/plugins/wordpress-reset/' ) . '">', '</a>' ); ?></p>
23
- </div>
24
<?php endif; ?>
25
<div class="error hide-if-js">
26
<p><?php _e( 'The Demo Importer screen requires JavaScript.', 'themegrill-demo-importer' ); ?></p>
27
</div>
7
exit;
8
}
9
10
?>
11
<div class="wrap demo-importer">
12
+ <h1 class="wp-heading-inline"><?php esc_html_e( 'Demo Importer', 'themegrill-demo-importer' ); ?>
13
<span class="title-count demo-count"><?php echo count( $this->demo_config ); ?></span>
14
</h1>
15
+
16
+ <?php if ( apply_filters( 'themegrill_demo_importer_new_demos', false ) ) : ?>
17
+ <a href="<?php echo esc_url( 'https://themegrill.com/upcoming-new-demos' ); ?>" class="page-title-action" target="_blank"><?php esc_html_e( 'New Demos', 'themegrill-demo-importer' ); ?></a>
18
<?php endif; ?>
19
+
20
+ <form class="search-form"></form>
21
+
22
+ <hr class="wp-header-end">
23
+
24
<div class="error hide-if-js">
25
<p><?php _e( 'The Demo Importer screen requires JavaScript.', 'themegrill-demo-importer' ); ?></p>
26
</div>
includes/includes/admin/views/html-admin-page-installer-preview.php CHANGED
@@ -7,12 +7,10 @@ if ( ! defined( 'ABSPATH' ) ) {
7
exit;
8
}
9
10
- $previews = $this->prepare_previews_for_js( $this->demo_packages );
11
-
12
?>
13
<div class="theme-browser rendered">
14
<div class="themes wp-clearfix">
15
- <?php foreach ( $previews as $demo ) : ?>
16
<div class="theme<?php echo ( $demo['actions']['pro_link'] ) ? " premium-ribbon": ''; ?>" tabindex="0">
17
<a target="_blank" href="<?php echo esc_url( $demo['actions']['preview_url'] ); ?>">
18
<?php if ( $demo['screenshot'] ) : ?>
@@ -31,13 +29,20 @@ $previews = $this->prepare_previews_for_js( $this->demo_packages );
31
<h3 class="theme-name"><?php echo esc_html( $demo['name'] ); ?></h3>
32
33
<div class="theme-actions">
34
- <?php if ( ! $demo['installed'] ) : ?>
35
<?php
36
/* translators: %s: Demo name */
37
$aria_label = sprintf( _x( 'Download %s', 'demo', 'themegrill-demo-importer' ), esc_attr( $demo['name'] ) );
38
?>
39
<a class="button button-primary demo-download" data-name="<?php echo esc_attr( $demo['name'] ); ?>" href="<?php echo esc_url( $demo['actions']['download_url'] ); ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Download', 'themegrill-demo-importer' ); ?></a>
40
<?php endif; ?>
41
<a class="button button-secondary demo-preview" target="_blank" href="<?php echo esc_url( $demo['actions']['preview_url'] ); ?>"><?php _e( 'Preview', 'themegrill-demo-importer' ); ?></a>
42
</div>
43
7
exit;
8
}
9
10
?>
11
<div class="theme-browser rendered">
12
<div class="themes wp-clearfix">
13
+ <?php foreach ( $demos as $demo ) : ?>
14
<div class="theme<?php echo ( $demo['actions']['pro_link'] ) ? " premium-ribbon": ''; ?>" tabindex="0">
15
<a target="_blank" href="<?php echo esc_url( $demo['actions']['preview_url'] ); ?>">
16
<?php if ( $demo['screenshot'] ) : ?>
29
<h3 class="theme-name"><?php echo esc_html( $demo['name'] ); ?></h3>
30
31
<div class="theme-actions">
32
+ <?php if ( ! $demo['installed'] && ! $demo['actions']['pro_link'] ) : ?>
33
<?php
34
/* translators: %s: Demo name */
35
$aria_label = sprintf( _x( 'Download %s', 'demo', 'themegrill-demo-importer' ), esc_attr( $demo['name'] ) );
36
?>
37
<a class="button button-primary demo-download" data-name="<?php echo esc_attr( $demo['name'] ); ?>" href="<?php echo esc_url( $demo['actions']['download_url'] ); ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Download', 'themegrill-demo-importer' ); ?></a>
38
<?php endif; ?>
39
+ <?php if ( $demo['actions']['pro_link'] ) : ?>
40
+ <?php
41
+ /* translators: %s: Demo name */
42
+ $aria_label = sprintf( _x( 'View %s Pro', 'demo', 'themegrill-demo-importer' ), esc_attr( $demo['name'] ) );
43
+ ?>
44
+ <a class="button button-primary demo-premium" target="_blank" data-name="<?php echo esc_attr( $demo['name'] ); ?>" href="<?php echo esc_url( $demo['actions']['pro_link'] ); ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'View Pro', 'themegrill-demo-importer' ); ?></a>
45
+ <?php endif; ?>
46
<a class="button button-secondary demo-preview" target="_blank" href="<?php echo esc_url( $demo['actions']['preview_url'] ); ?>"><?php _e( 'Preview', 'themegrill-demo-importer' ); ?></a>
47
</div>
48
includes/includes/admin/views/html-admin-page-installer.php CHANGED
@@ -10,7 +10,6 @@ if ( ! defined( 'ABSPATH' ) ) {
10
global $current_filter;
11
12
$current_filter = empty( $_GET['browse'] ) ? 'welcome' : sanitize_title( $_GET['browse'] );
13
- $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
14
$demo_filter_links = apply_filters( 'themegrill_demo_importer_filter_links_array', array(
15
'welcome' => __( 'Welcome', 'themegrill-demo-importer' ),
16
'uploads' => __( 'Installed Demos', 'themegrill-demo-importer' ),
@@ -19,17 +18,14 @@ $demo_filter_links = apply_filters( 'themegrill_demo_importer_filter_links_array
19
20
?>
21
<div class="wrap demo-installer">
22
- <h1><?php
23
- esc_html_e( 'Demo Importer', 'themegrill-demo-importer' );
24
- if ( current_user_can( 'upload_files' ) ) {
25
- echo ' <button type="button" class="upload-view-toggle page-title-action hide-if-no-js tg-demo-upload" aria-expanded="false">' . __( 'Upload Demo', 'themegrill-demo-importer' ) . '</button>';
26
- }
27
- ?></h1>
28
- <?php if ( ! get_option( 'themegrill_demo_imported_notice_dismiss' ) && in_array( $demo_imported_id, array_keys( $this->demo_config ) ) ) : ?>
29
- <div id="message" class="notice notice-info is-dismissible" data-notice_id="demo-importer">
30
- <p><?php printf( __( '<strong>Notice</strong> &#8211; If you want to completely remove a demo installation after importing it, you can use a plugin like %1$sWordPress Reset%2$s.', 'themegrill-demo-importer' ), '<a target="_blank" href="' . esc_url( 'https://wordpress.org/plugins/wordpress-reset/' ) . '">', '</a>' ); ?></p>
31
- </div>
32
<?php endif; ?>
33
<div class="error hide-if-js">
34
<p><?php _e( 'The Demo Importer screen requires JavaScript.', 'themegrill-demo-importer' ); ?></p>
35
</div>
@@ -73,15 +69,20 @@ $demo_filter_links = apply_filters( 'themegrill_demo_importer_filter_links_array
73
<div class="welcome-panel-column-container">
74
<div class="welcome-panel-column">
75
<ul>
76
- <li><?php printf( __( '1. Visit <a href="%s" target="_blank"><strong>this page</strong></a> and download demo zip file.','themegrill-demo-importer' ),esc_url( 'http://themegrill.com/theme-demo-file-downloads/' ) ); ?></li>
77
- <li><?php _e( '2. Click <strong>Upload Demo</strong> button on the top of this Page.','themegrill-demo-importer' ); ?></li>
78
- <li><?php _e( '3. Browse the demo zip file and click <strong>Install Now</strong>.','themegrill-demo-importer' ); ?></li>
79
<li><?php _e( '4. Go to <strong>Installed Demos</strong> tab.','themegrill-demo-importer' ); ?></li>
80
- <li><?php _e( '5. Click <strong>Import</strong> button and wait for few minutes. Done!','themegrill-demo-importer' ); ?></li>
81
</ul>
82
</div>
83
</div>
84
</div>
85
</div>
86
<?php else : ?>
87
<h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Available demos list', 'themegrill-demo-importer' ); ?></h2>
@@ -275,7 +276,7 @@ $demo_filter_links = apply_filters( 'themegrill_demo_importer_filter_links_array
275
<h3 class="theme-name">{{ data.name }}</h3>
276
277
<div class="theme-actions">
278
- <# if ( ! data.installed && ( ! data.actions.pro_link ) ) { #>
279
<?php
280
/* translators: %s: Demo name */
281
$aria_label = sprintf( _x( 'Download %s', 'demo', 'themegrill-demo-importer' ), '{{ data.name }}' );
@@ -287,7 +288,7 @@ $demo_filter_links = apply_filters( 'themegrill_demo_importer_filter_links_array
287
/* translators: %s: Demo name */
288
$aria_label = sprintf( _x( 'View %s Pro', 'demo', 'themegrill-demo-importer' ), '{{ data.name }}' );
289
?>
290
- <a class="button button-primary demo-pro-link" data-name="{{ data.name }}" href="{{ data.actions.pro_link }}" aria-label="<?php echo esc_attr( $aria_label ); ?>" target="_blank"><?php _e( 'View Pro', 'themegrill-demo-importer' ); ?></a>
291
<# } #>
292
<a class="button button-secondary demo-preview" target="_blank" href="{{{ data.actions.preview_url }}}"><?php _e( 'Preview', 'themegrill-demo-importer' ); ?></a>
293
</div>
10
global $current_filter;
11
12
$current_filter = empty( $_GET['browse'] ) ? 'welcome' : sanitize_title( $_GET['browse'] );
13
$demo_filter_links = apply_filters( 'themegrill_demo_importer_filter_links_array', array(
14
'welcome' => __( 'Welcome', 'themegrill-demo-importer' ),
15
'uploads' => __( 'Installed Demos', 'themegrill-demo-importer' ),
18
19
?>
20
<div class="wrap demo-installer">
21
+ <h1 class="wp-heading-inline"><?php esc_html_e( 'Demo Importer', 'themegrill-demo-importer' ); ?></h1>
22
+
23
+ <?php if ( current_user_can( 'upload_files' ) ) : ?>
24
+ <button type="button" class="upload-view-toggle page-title-action hide-if-no-js tg-demo-upload" aria-expanded="false"><?php _e( 'Upload Demo', 'themegrill-demo-importer' ); ?></button>
25
<?php endif; ?>
26
+
27
+ <hr class="wp-header-end">
28
+
29
<div class="error hide-if-js">
30
<p><?php _e( 'The Demo Importer screen requires JavaScript.', 'themegrill-demo-importer' ); ?></p>
31
</div>
69
<div class="welcome-panel-column-container">
70
<div class="welcome-panel-column">
71
<ul>
72
+ <li><?php printf( __( '1. Visit <a href="%s" target="_blank"><strong>this page</strong></a> and download the theme demo zip file.','themegrill-demo-importer' ), esc_url( self_admin_url( 'themes.php?page=demo-importer&browse=preview' ) ) ); ?></li>
73
+ <li><?php _e( '2. Click on the <strong>Upload Demo</strong> button on the top of this page.','themegrill-demo-importer' ); ?></li>
74
+ <li><?php _e( '3. Browse the downloaded demo zip file and click on <strong>Install Now</strong> button.','themegrill-demo-importer' ); ?></li>
75
<li><?php _e( '4. Go to <strong>Installed Demos</strong> tab.','themegrill-demo-importer' ); ?></li>
76
+ <li><?php _e( '5. Click on the <strong>Import</strong> button and wait for few minutes. Done!','themegrill-demo-importer' ); ?></li>
77
</ul>
78
</div>
79
</div>
80
</div>
81
+ <div class="welcome-panel-iframe-video">
82
+ <div class="welcome-panel-iframe-video-inner">
83
+ <iframe width="560" height="315" src="<?php echo esc_url( 'https://www.youtube.com/embed/rhiybsv3vUU?rel=0&amp;showinfo=0' ); ?>" allowtransparency="true" frameborder="0" scrolling="no" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen></iframe>
84
+ </div>
85
+ </div>
86
</div>
87
<?php else : ?>
88
<h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Available demos list', 'themegrill-demo-importer' ); ?></h2>
276
<h3 class="theme-name">{{ data.name }}</h3>
277
278
<div class="theme-actions">
279
+ <# if ( ! data.installed && ! data.actions.pro_link ) { #>
280
<?php
281
/* translators: %s: Demo name */
282
$aria_label = sprintf( _x( 'Download %s', 'demo', 'themegrill-demo-importer' ), '{{ data.name }}' );
288
/* translators: %s: Demo name */
289
$aria_label = sprintf( _x( 'View %s Pro', 'demo', 'themegrill-demo-importer' ), '{{ data.name }}' );
290
?>
291
+ <a class="button button-primary demo-premium" target="_blank" data-name="{{ data.name }}" href="{{ data.actions.pro_link }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'View Pro', 'themegrill-demo-importer' ); ?></a>
292
<# } #>
293
<a class="button button-secondary demo-preview" target="_blank" href="{{{ data.actions.preview_url }}}"><?php _e( 'Preview', 'themegrill-demo-importer' ); ?></a>
294
</div>
includes/includes/admin/views/html-notice-reset-wizard-success.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Reset Wizard Success
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ $user = get_user_by( 'id', 1 );
11
+
12
+ ?>
13
+ <div id="message" class="notice notice-info is-dismissible">
14
+ <p><?php printf( __( 'WordPress has been reset back to defaults. The user <strong>"%1$s"</strong> was recreated with its previous password.', 'themegrill-demo-importer' ), $user->user_login ); ?></p>
15
+ </div>
includes/includes/admin/views/html-notice-reset-wizard.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+ /**
3
+ * Admin View: Notice - Reset Wizard
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ ?>
11
+ <div id="message" class="updated themegrill-demo-importer-message">
12
+ <p><?php _e( '<strong>Reset Wizard</strong> &#8211; If you need to reset the WordPress back to default again :)', 'themegrill-demo-importer' ); ?></p>
13
+ <p class="submit"><a href="<?php echo esc_url( add_query_arg( 'do_reset_wordpress', 'true', admin_url( 'themes.php?page=demo-importer' ) ) ); ?>" class="button button-primary themegrill-reset-wordpress"><?php _e( 'Run the Reset Wizard', 'themegrill-demo-importer' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'themegrill-demo-importer-hide-notice', 'reset_notice' ), 'themegrill_demo_importer_hide_notice_nonce', '_themegrill_demo_importer_notice_nonce' ) ); ?>"><?php _e( 'Hide this notice', 'themegrill-demo-importer' ); ?></a></p>
14
+ </div>
includes/includes/functions-demo-importer.php CHANGED
@@ -145,7 +145,6 @@ add_action( 'wp_ajax_delete-demo', 'tg_ajax_delete_demo_pack', 1 );
145
/**
146
* Remove a demo.
147
*
148
- *
149
* @global WP_Filesystem_Base $wp_filesystem Subclass
150
*
151
* @param string $demo_pack Demo pack to delete completely.
@@ -155,10 +154,6 @@ add_action( 'wp_ajax_delete-demo', 'tg_ajax_delete_demo_pack', 1 );
155
function tg_delete_demo_pack( $demo_pack, $redirect = '' ) {
156
global $wp_filesystem;
157
158
- $upload_dir = wp_upload_dir();
159
- $demo_packs = $upload_dir['basedir'] . '/tg-demo-pack/';
160
- $demo_imported_id = get_option( 'themegrill_demo_imported_id' );
161
-
162
if ( empty( $demo_pack ) ) {
163
return false;
164
}
@@ -204,9 +199,9 @@ function tg_delete_demo_pack( $demo_pack, $redirect = '' ) {
204
}
205
206
// Get the base demo folder.
207
- $demos_dir = $wp_filesystem->find_folder( $demo_packs );
208
if ( empty( $demos_dir ) ) {
209
- return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate ThemeGrill demo pack directory.', 'themegrill-demo-importer' ) );
210
}
211
212
$demos_dir = trailingslashit( $demos_dir );
145
/**
146
* Remove a demo.
147
*
148
* @global WP_Filesystem_Base $wp_filesystem Subclass
149
*
150
* @param string $demo_pack Demo pack to delete completely.
154
function tg_delete_demo_pack( $demo_pack, $redirect = '' ) {
155
global $wp_filesystem;
156
157
if ( empty( $demo_pack ) ) {
158
return false;
159
}
199
}
200
201
// Get the base demo folder.
202
+ $demos_dir = $wp_filesystem->find_folder( TGDM_DEMO_DIR );
203
if ( empty( $demos_dir ) ) {
204
+ return new WP_Error( 'fs_no_demos_dir', __( 'Unable to locate ThemeGrill demo pack directory.', 'themegrill-demo-importer' ) );
205
}
206
207
$demos_dir = trailingslashit( $demos_dir );
includes/includes/importers/class-wxr-parsers.php CHANGED
@@ -95,9 +95,9 @@ class TG_WXR_Parser_SimpleXML {
95
96
$namespaces = $xml->getDocNamespaces();
97
if ( ! isset( $namespaces['wp'] ) )
98
- $namespaces['wp'] = 'http://wordpress.org/export/1.1/';
99
if ( ! isset( $namespaces['excerpt'] ) )
100
- $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
101
102
// grab authors
103
foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) {
95
96
$namespaces = $xml->getDocNamespaces();
97
if ( ! isset( $namespaces['wp'] ) )
98
+ $namespaces['wp'] = 'https://wordpress.org/export/1.1/';
99
if ( ! isset( $namespaces['excerpt'] ) )
100
+ $namespaces['excerpt'] = 'https://wordpress.org/export/1.1/excerpt/';
101
102
// grab authors
103
foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) {
languages/themegrill-demo-importer.pot CHANGED
@@ -2,130 +2,244 @@
2
# This file is distributed under the GPLv3 or later.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: ThemeGrill Demo Importer 1.2.0\n"
6
"Report-Msgid-Bugs-To: themegrill@gmail.com\n"
7
- "POT-Creation-Date: 2017-01-23 04:13:43+00:00\n"
8
"MIME-Version: 1.0\n"
9
"Content-Type: text/plain; charset=utf-8\n"
10
"Content-Transfer-Encoding: 8bit\n"
11
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
14
- "X-Generator: grunt-wp-i18n 0.5.4\n"
15
16
- #: includes/class-demo-importer.php:139
17
- #: includes/includes/admin/views/html-admin-page-importer.php:14
18
- #: includes/includes/admin/views/html-admin-page-installer.php:23
19
- #: themegrill-demo-importer.php:170
20
msgid "Demo Importer"
21
msgstr ""
22
23
- #: includes/class-demo-importer.php:186
24
msgid "Importing..."
25
msgstr ""
26
27
- #: includes/class-demo-importer.php:188
28
msgid "Importing... please wait."
29
msgstr ""
30
31
- #: includes/class-demo-importer.php:189
32
msgid "Import completed successfully."
33
msgstr ""
34
35
- #: includes/class-demo-importer.php:190
36
msgid "Import Failed!"
37
msgstr ""
38
39
- #: includes/class-demo-importer.php:191
40
msgid "Import failed: %s"
41
msgstr ""
42
43
- #: includes/class-demo-importer.php:194
44
- #: includes/includes/admin/views/html-admin-page-importer.php:58
45
- #: includes/includes/admin/views/html-admin-page-importer.php:110
46
- #: includes/includes/admin/views/html-admin-page-importer.php:222
47
- #: includes/includes/admin/views/html-admin-page-importer.php:231
48
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:40
49
- #: includes/includes/admin/views/html-admin-page-installer.php:124
50
- #: includes/includes/admin/views/html-admin-page-installer.php:236
51
- #: includes/includes/admin/views/html-admin-page-installer.php:245
52
msgid "Live Preview"
53
msgstr ""
54
55
- #: includes/class-demo-importer.php:196
56
msgid "Imported!"
57
msgstr ""
58
59
- #: includes/class-demo-importer.php:197
60
msgid "Try this solution!"
61
msgstr ""
62
63
- #: includes/class-demo-importer.php:207
64
msgid ""
65
"Are you sure you want to delete this demo?\n"
66
"\n"
67
"Click 'Cancel' to go back, 'OK' to confirm the delete."
68
msgstr ""
69
70
- #: includes/class-demo-importer.php:208
71
msgid ""
72
"Importing demo content will replicate the live demo and overwrites your "
73
"current customizer, widgets and other settings. It might take few minutes "
74
"to complete the demo import. Are you sure you want to import this demo?"
75
msgstr ""
76
77
- #: includes/class-demo-importer.php:213
78
msgid "Add New Demo"
79
msgstr ""
80
81
- #: includes/class-demo-importer.php:214
82
msgid "Search Demos"
83
msgstr ""
84
85
- #: includes/class-demo-importer.php:215
86
msgid "Search demos..."
87
msgstr ""
88
89
- #: includes/class-demo-importer.php:216
90
msgid "Number of Demos found: %d"
91
msgstr ""
92
93
- #: includes/class-demo-importer.php:217
94
- #: includes/includes/admin/views/html-admin-page-importer.php:81
95
- #: includes/includes/admin/views/html-admin-page-installer.php:94
96
msgid "No demos found. Try a different search."
97
msgstr ""
98
99
#. Author of the plugin/theme
100
msgid "ThemeGrill"
101
msgstr ""
102
103
- #: includes/class-demo-importer.php:401
104
msgid "Sorry, you are not allowed to install demo on this site."
105
msgstr ""
106
107
- #: includes/class-demo-importer.php:408
108
msgid "Installing Demo from uploaded file: %s"
109
msgstr ""
110
111
- #: includes/class-demo-importer.php:452
112
#: includes/includes/functions-demo-importer.php:97
113
msgid "No demo specified."
114
msgstr ""
115
116
- #: includes/class-demo-importer.php:468
117
msgid "Sorry, you are not allowed to import."
118
msgstr ""
119
120
- #: includes/class-demo-importer.php:533
121
msgid "The XML file dummy content is missing."
122
msgstr ""
123
124
- #: includes/class-demo-importer.php:596
125
msgid "The DAT file customizer data is missing."
126
msgstr ""
127
128
- #: includes/class-demo-importer.php:620
129
msgid "The WIE file widget content is missing."
130
msgstr ""
131
@@ -182,236 +296,257 @@ msgstr ""
182
msgid "New Demos"
183
msgstr ""
184
185
- #: includes/includes/admin/views/html-admin-page-importer.php:22
186
#: includes/includes/admin/views/html-admin-page-installer.php:30
187
- msgid ""
188
- "<strong>Notice</strong> &#8211; If you want to completely remove a demo "
189
- "installation after importing it, you can use a plugin like %1$sWordPress "
190
- "Reset%2$s."
191
- msgstr ""
192
-
193
- #: includes/includes/admin/views/html-admin-page-importer.php:26
194
- #: includes/includes/admin/views/html-admin-page-installer.php:34
195
msgid "The Demo Importer screen requires JavaScript."
196
msgstr ""
197
198
- #: includes/includes/admin/views/html-admin-page-importer.php:41
199
- #: includes/includes/admin/views/html-admin-page-importer.php:93
200
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:23
201
- #: includes/includes/admin/views/html-admin-page-installer.php:107
202
msgid "Demo Details"
203
msgstr ""
204
205
- #: includes/includes/admin/views/html-admin-page-importer.php:44
206
- #: includes/includes/admin/views/html-admin-page-importer.php:96
207
- #: includes/includes/admin/views/html-admin-page-importer.php:156
208
- #: includes/includes/admin/views/html-admin-page-installer-preview.php:29
209
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:26
210
- #: includes/includes/admin/views/html-admin-page-installer.php:110
211
- #: includes/includes/admin/views/html-admin-page-installer.php:170
212
- #: includes/includes/admin/views/html-admin-page-installer.php:273
213
#. translators: %s: Demo author name
214
msgid "By %s"
215
msgstr ""
216
217
- #: includes/includes/admin/views/html-admin-page-importer.php:50
218
- #: includes/includes/admin/views/html-admin-page-importer.php:102
219
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:32
220
- #: includes/includes/admin/views/html-admin-page-installer.php:116
221
#. translators: %s: Demo name
222
msgid "<span>Imported:</span> %s"
223
msgstr ""
224
225
- #: includes/includes/admin/views/html-admin-page-importer.php:62
226
- #: includes/includes/admin/views/html-admin-page-importer.php:114
227
- #: includes/includes/admin/views/html-admin-page-importer.php:161
228
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:44
229
- #: includes/includes/admin/views/html-admin-page-installer.php:128
230
- #: includes/includes/admin/views/html-admin-page-installer.php:175
231
msgid "Required %s theme must be activated to import this demo."
232
msgstr ""
233
234
- #: includes/includes/admin/views/html-admin-page-importer.php:62
235
- #: includes/includes/admin/views/html-admin-page-importer.php:64
236
- #: includes/includes/admin/views/html-admin-page-importer.php:71
237
- #: includes/includes/admin/views/html-admin-page-importer.php:114
238
- #: includes/includes/admin/views/html-admin-page-importer.php:116
239
- #: includes/includes/admin/views/html-admin-page-importer.php:123
240
- #: includes/includes/admin/views/html-admin-page-importer.php:233
241
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:44
242
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:46
243
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:53
244
- #: includes/includes/admin/views/html-admin-page-installer.php:128
245
- #: includes/includes/admin/views/html-admin-page-installer.php:130
246
- #: includes/includes/admin/views/html-admin-page-installer.php:137
247
- #: includes/includes/admin/views/html-admin-page-installer.php:247
248
msgid "Import"
249
msgstr ""
250
251
- #: includes/includes/admin/views/html-admin-page-importer.php:73
252
- #: includes/includes/admin/views/html-admin-page-importer.php:125
253
- #: includes/includes/admin/views/html-admin-page-importer.php:236
254
- #: includes/includes/admin/views/html-admin-page-installer-preview.php:41
255
#: includes/includes/admin/views/html-admin-page-installer-uploads.php:55
256
- #: includes/includes/admin/views/html-admin-page-installer.php:139
257
- #: includes/includes/admin/views/html-admin-page-installer.php:250
258
- #: includes/includes/admin/views/html-admin-page-installer.php:285
259
msgid "Preview"
260
msgstr ""
261
262
- #: includes/includes/admin/views/html-admin-page-importer.php:138
263
- #: includes/includes/admin/views/html-admin-page-installer.php:152
264
msgid "Show previous demo"
265
msgstr ""
266
267
- #: includes/includes/admin/views/html-admin-page-importer.php:139
268
- #: includes/includes/admin/views/html-admin-page-installer.php:153
269
msgid "Show next demo"
270
msgstr ""
271
272
- #: includes/includes/admin/views/html-admin-page-importer.php:140
273
- #: includes/includes/admin/views/html-admin-page-installer.php:154
274
msgid "Close details dialog"
275
msgstr ""
276
277
- #: includes/includes/admin/views/html-admin-page-importer.php:153
278
- #: includes/includes/admin/views/html-admin-page-installer.php:167
279
msgid "Imported Demo"
280
msgstr ""
281
282
- #: includes/includes/admin/views/html-admin-page-importer.php:155
283
- #: includes/includes/admin/views/html-admin-page-installer.php:169
284
msgid "Version: %s"
285
msgstr ""
286
287
- #: includes/includes/admin/views/html-admin-page-importer.php:163
288
- #: includes/includes/admin/views/html-admin-page-installer.php:177
289
msgid "Required Plugin must be activated to import this demo."
290
msgstr ""
291
292
- #: includes/includes/admin/views/html-admin-page-importer.php:169
293
- #: includes/includes/admin/views/html-admin-page-installer.php:183
294
msgid "Plugins Information"
295
msgstr ""
296
297
- #: includes/includes/admin/views/html-admin-page-importer.php:174
298
- #: includes/includes/admin/views/html-admin-page-installer.php:188
299
msgid "Plugin Name"
300
msgstr ""
301
302
- #: includes/includes/admin/views/html-admin-page-importer.php:175
303
- #: includes/includes/admin/views/html-admin-page-installer.php:189
304
msgid "Type"
305
msgstr ""
306
307
- #: includes/includes/admin/views/html-admin-page-importer.php:176
308
- #: includes/includes/admin/views/html-admin-page-installer.php:190
309
msgid "Status"
310
msgstr ""
311
312
- #: includes/includes/admin/views/html-admin-page-importer.php:192
313
- #: includes/includes/admin/views/html-admin-page-installer.php:206
314
msgid "Required"
315
msgstr ""
316
317
- #: includes/includes/admin/views/html-admin-page-importer.php:194
318
- #: includes/includes/admin/views/html-admin-page-installer.php:208
319
msgid "Recommended"
320
msgstr ""
321
322
- #: includes/includes/admin/views/html-admin-page-importer.php:208
323
- #: includes/includes/admin/views/html-admin-page-installer.php:222
324
msgid "No plugins are needed to import this demo."
325
msgstr ""
326
327
- #: includes/includes/admin/views/html-admin-page-importer.php:215
328
- #: includes/includes/admin/views/html-admin-page-installer.php:229
329
msgid "Tags:"
330
msgstr ""
331
332
- #: includes/includes/admin/views/html-admin-page-importer.php:240
333
- #: includes/includes/admin/views/html-admin-page-installer.php:254
334
msgid "Delete"
335
msgstr ""
336
337
- #: includes/includes/admin/views/html-admin-page-installer-preview.php:25
338
- #: includes/includes/admin/views/html-admin-page-installer.php:269
339
msgid "Demo Preview"
340
msgstr ""
341
342
- #: includes/includes/admin/views/html-admin-page-installer-preview.php:39
343
- #: includes/includes/admin/views/html-admin-page-installer.php:283
344
msgid "Download"
345
msgstr ""
346
347
- #: includes/includes/admin/views/html-admin-page-installer.php:15
348
msgid "Welcome"
349
msgstr ""
350
351
- #: includes/includes/admin/views/html-admin-page-installer.php:16
352
msgid "Installed Demos"
353
msgstr ""
354
355
- #: includes/includes/admin/views/html-admin-page-installer.php:17
356
msgid "Theme Demos"
357
msgstr ""
358
359
- #: includes/includes/admin/views/html-admin-page-installer.php:25
360
msgid "Upload Demo"
361
msgstr ""
362
363
- #: includes/includes/admin/views/html-admin-page-installer.php:38
364
msgid ""
365
"If you have a demo pack in a .zip format, you may install it by uploading "
366
"it here."
367
msgstr ""
368
369
- #: includes/includes/admin/views/html-admin-page-installer.php:41
370
msgid "Demo zip file"
371
msgstr ""
372
373
- #: includes/includes/admin/views/html-admin-page-installer.php:43
374
msgid "Install Now"
375
msgstr ""
376
377
- #: includes/includes/admin/views/html-admin-page-installer.php:47
378
msgid "Filter demos list"
379
msgstr ""
380
381
- #: includes/includes/admin/views/html-admin-page-installer.php:71
382
msgid "Welcome to ThemeGrill Demo Importer!"
383
msgstr ""
384
385
- #: includes/includes/admin/views/html-admin-page-installer.php:72
386
msgid "Get Started"
387
msgstr ""
388
389
- #: includes/includes/admin/views/html-admin-page-installer.php:76
390
msgid ""
391
"1. Visit <a href=\"%s\" target=\"_blank\"><strong>this page</strong></a> "
392
- "and download demo zip file."
393
msgstr ""
394
395
- #: includes/includes/admin/views/html-admin-page-installer.php:77
396
- msgid "2. Click <strong>Upload Demo</strong> button on the top of this Page."
397
msgstr ""