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 | ![]() |
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 +0 -0
- CHANGELOG.txt +31 -0
- CODE_OF_CONDUCT.md +46 -0
- assets/css/demo-importer-rtl.css +1 -0
- assets/css/demo-importer.css +1 -1
- assets/css/demo-importer.scss +84 -24
- assets/images/flash/flash-pro-agency.jpg +0 -0
- assets/images/flash/flash-pro-band.jpg +0 -0
- assets/js/admin/demo-importer.js +23 -21
- assets/js/admin/demo-importer.min.js +1 -1
- assets/js/admin/demo-updates.js +40 -3
- assets/js/admin/demo-updates.min.js +1 -1
- assets/js/jquery-tiptip/jquery.tipTip.min.js +1 -1
- includes/class-demo-importer.php +487 -289
- includes/functions-demo-update.php +21 -0
- includes/includes/admin/class-demo-installer-skin.php +1 -1
- includes/includes/admin/class-demo-upgrader.php +1 -1
- includes/includes/admin/views/html-admin-page-importer.php +9 -10
- includes/includes/admin/views/html-admin-page-installer-preview.php +9 -4
- includes/includes/admin/views/html-admin-page-installer.php +18 -17
- includes/includes/admin/views/html-notice-reset-wizard-success.php +15 -0
- includes/includes/admin/views/html-notice-reset-wizard.php +14 -0
- includes/includes/functions-demo-importer.php +2 -7
- includes/includes/importers/class-wxr-parsers.php +2 -2
- languages/themegrill-demo-importer.pot +309 -167
- phpcs.ruleset.xml +2 -1
- readme.txt +39 -30
- themegrill-demo-importer.php +129 -71
- uninstall.php +13 -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 |
-
|
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 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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: $( '
|
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 |
-
//
|
1210 |
-
$( '.
|
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: '
|
1221 |
-
notice_id: $this_el.parent().data( 'notice_id' )
|
1222 |
});
|
1223 |
|
1224 |
-
|
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,"\\$&"),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,"\\$&"),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(
|
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(
|
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, '
|
49 |
add_action( 'admin_head', array( $this, 'add_menu_classes' ) );
|
50 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
51 |
}
|
52 |
|
53 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
add_action( 'wp_ajax_import-demo', array( $this, 'ajax_import_demo' ) );
|
55 |
-
add_action( '
|
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 |
-
$
|
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 |
-
$
|
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
|
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 =
|
|
|
|
|
|
|
197 |
|
198 |
-
//
|
199 |
-
|
200 |
|
201 |
-
// Register
|
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' ),
|
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' ),
|
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->
|
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 |
-
*
|
252 |
-
* @
|
|
|
253 |
*/
|
254 |
-
public function
|
255 |
-
if (
|
256 |
-
return
|
257 |
}
|
258 |
|
259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
}
|
261 |
|
262 |
/**
|
263 |
-
*
|
264 |
*/
|
265 |
-
|
266 |
-
$
|
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 |
-
|
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 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
}
|
283 |
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
}
|
|
|
312 |
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
333 |
-
$current_template
|
334 |
-
$
|
335 |
|
336 |
/**
|
337 |
* Filters demo data before it is prepared for JavaScript.
|
338 |
*
|
339 |
-
* @param array $prepared_demos
|
340 |
-
* @param null|array $demos
|
341 |
-
* @param string $
|
342 |
*/
|
343 |
-
$prepared_demos = (array) apply_filters( 'themegrill_demo_importer_pre_prepare_demos_for_js', array(), $demos, $
|
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[ $
|
351 |
-
$prepared_demos[ $
|
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 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
'
|
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( '
|
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 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
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★★★★★%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' ) . ' – ' . 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 & Support', 'themegrill-demo-importer' ),
|
324 |
+
'content' =>
|
325 |
+
'<h2>' . __( 'Help & 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’ 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&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:
|
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' =>
|
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 |
-
|
21 |
-
|
22 |
-
|
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 ( $
|
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 |
-
|
24 |
-
|
25 |
-
|
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> – 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( '
|
77 |
-
<li><?php _e( '2. Click <strong>Upload Demo</strong> button on the top of this
|
78 |
-
<li><?php _e( '3. Browse the demo zip file and click <strong>Install Now</strong
|
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 &&
|
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-
|
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&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> – 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 |
|