ThemeGrill Demo Importer - Version 1.5.6

Version Description

  • 15-02-2019 =
  • Fetaure - Install plugins and import demo on a single click.
  • Tweak - Remove the more details on demo preview hover.
  • Dev - Improve Coding standard with husky compatibility.
Download this release

Release Info

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

Code changes from version 1.5.5 to 1.5.6

.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ *.min.js
2
+
3
+ /assets/js/jquery-tiptip/**
.eslintrc ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "root": true,
3
+ "env": {
4
+ "browser": true,
5
+ "node": true
6
+ },
7
+ "globals": {
8
+ "wp": true
9
+ },
10
+ "rules": {
11
+ "camelcase": 0,
12
+ "indent": 0,
13
+ "max-len": [ 2, { "code": 250 } ],
14
+ "no-console": 1
15
+ }
16
+ }
.stylelintrc DELETED
@@ -1,58 +0,0 @@
1
- {
2
- "rules": {
3
- "indentation": "tab",
4
- "color-hex-case": "lower",
5
- "color-no-invalid-hex": true,
6
-
7
- "function-calc-no-unspaced-operator": true,
8
- "function-comma-space-after": "always-single-line",
9
- "function-comma-space-before": "never",
10
- "function-name-case": "lower",
11
- "function-url-quotes": "always",
12
- "function-whitespace-after": "always",
13
-
14
- "number-leading-zero": "always",
15
- "number-no-trailing-zeros": true,
16
- "length-zero-no-unit": true,
17
-
18
- "string-no-newline": true,
19
- "string-quotes": "single",
20
-
21
- "unit-case": "lower",
22
- "unit-no-unknown": true,
23
- "unit-whitelist": ["px", "%", "deg", "ms", "em", "vh", "vw", "rem", "s", "ex", "pt", "cm"],
24
-
25
- "value-list-comma-space-after": "always-single-line",
26
- "value-list-comma-space-before": "never",
27
-
28
- "shorthand-property-no-redundant-values": true,
29
-
30
- "property-case": "lower",
31
-
32
- "declaration-block-no-duplicate-properties": [true, { "severity": "warning" } ],
33
- "declaration-block-trailing-semicolon": "always",
34
- "declaration-block-single-line-max-declarations": 0,
35
- "declaration-block-semicolon-space-before": "never",
36
- "declaration-block-semicolon-space-after": "always-single-line",
37
- "declaration-block-semicolon-newline-before": "never-multi-line",
38
- "declaration-block-semicolon-newline-after": "always-multi-line",
39
-
40
- "block-closing-brace-newline-after": "always",
41
- "block-closing-brace-newline-before": "always-multi-line",
42
- "block-no-empty": true,
43
- "block-opening-brace-newline-after": "always-multi-line",
44
- "block-opening-brace-space-before": "always",
45
-
46
- "selector-attribute-brackets-space-inside": "never",
47
- "selector-attribute-operator-space-after": "never",
48
- "selector-attribute-operator-space-before": "never",
49
- "selector-combinator-space-after": "always",
50
- "selector-combinator-space-before": "always",
51
- "selector-pseudo-class-case": "lower",
52
- "selector-pseudo-class-parentheses-space-inside": "always",
53
- "selector-pseudo-element-case": "lower",
54
- "selector-pseudo-element-colon-notation": "double",
55
- "selector-pseudo-element-no-unknown": true,
56
- "selector-type-case": "lower"
57
- }
58
- }
.stylelintrc.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "extends": "stylelint-config-wordpress",
3
+ "rules": {
4
+ "at-rule-empty-line-before": null,
5
+ "at-rule-no-unknown": null,
6
+ "comment-empty-line-before": null,
7
+ "declaration-block-no-duplicate-properties": null,
8
+ "declaration-colon-newline-after": null,
9
+ "declaration-property-unit-whitelist": null,
10
+ "font-weight-notation": null,
11
+ "font-family-name-quotes": null,
12
+ "font-family-no-missing-generic-family-keyword": null,
13
+ "max-line-length": null,
14
+ "no-descending-specificity": null,
15
+ "no-duplicate-selectors": null,
16
+ "rule-empty-line-before": null,
17
+ "selector-class-pattern": null,
18
+ "string-quotes": "single",
19
+ "value-keyword-case": null,
20
+ "value-list-comma-newline-after": null
21
+ }
22
+ }
.wordpress-org/banner-1544x500.png DELETED
Binary file
.wordpress-org/banner-772x250.png DELETED
Binary file
.wordpress-org/icon-128x128.png DELETED
Binary file
.wordpress-org/icon-256x256.png DELETED
Binary file
.wordpress-org/screenshot-1.png DELETED
Binary file
.wordpress-org/screenshot-2.png DELETED
Binary file
.wordpress-org/screenshot-3.png DELETED
Binary file
CHANGELOG.txt DELETED
@@ -1,89 +0,0 @@
1
- == Changelog ==
2
-
3
- = 1.5.5 - 05-11-2018 =
4
- * Feature - Add support for elementor schemes.
5
-
6
- = 1.5.4 - 02-11-2018 =
7
- * Change Modular to Zakra
8
-
9
- = 1.5.3 - 30-10-2018 =
10
- * Support - Modular theme.
11
-
12
- = 1.5.2 - 25-09-2018 =
13
- * Fix - Custom CSS migration on demo import.
14
- * Fix - Live Preview button when demo is successfully imported in demo preview page.
15
-
16
- = 1.5.1 - 24-08-2018 =
17
- * Support - Cenote Pro theme.
18
-
19
- = 1.5.0 - 21-08-2018 =
20
- * Feature - Fetches the demo config from GitHub repo.
21
- * Feature - Category and pagebuilder routes for views.
22
- * Fetaure - Install and activate plugins on a single click.
23
- * Fix - Slashes to be stripped from imported comments.
24
- * Fix - Importing export files with multiline term meta data.
25
- * Fix - Deprecation notices including `wp_get_http()` and `screen_icon()`.
26
- * Tweak - Demo preview is supported via iframe.
27
- * Tweak - Different device preview is possible for a demo.
28
- * Tweak - Only store single demo package files in upload directory.
29
- * Dev - Improve PHP7 compatibility.
30
- * Deprecated - Upload process for the demo packages.
31
- * Deprecated - Filter hooks `themegrill_demo_importer_config` and `themegrill_demo_importer_packages`.
32
-
33
- = 1.4.3 - 23-04-2018 =
34
- * Support - Cenote theme.
35
-
36
- = 1.4.2 - 25-12-2017 =
37
- * Fix - Disable WooCommerce setup wizard for demo import.
38
- * Fix - Styling issue caused by missing `theme-id-container` container.
39
-
40
- = 1.4.1 - 08-12-2017 =
41
- * Feature - Compatiable with Elementor page builder.
42
- * Fix - Styling issue caused by missing `theme-id-container` container.
43
-
44
- = 1.4.0 - 20-07-2017 =
45
- * Feature - Plugin installer and activator mechinism.
46
- * Fix - Call to undefined function `preg_filter()`.
47
- * Dev - Improved file structure.
48
- * Dev - Introduced `tg_demo_installer_enabled()`.
49
- * Dev - Introduced `tg_demo_installer_preview()`.
50
- * Dev - Introduced `tg_demo_preview_screenshot_url()`.
51
-
52
- = 1.3.4 - 03-07-2017 =
53
- * Feature - Support RTL for Importer.
54
- * Feature - Reset wizard for clean up.
55
- * Fixed - Undefined queue job update action.
56
- * Fixed - Use of `wp-heading-inline` core class.
57
- * Tweak - Use of defined constant for demo packs.
58
- * Tweak - Uninstall data with a defined constant.
59
- * Tweak - Fallback screenshot for flash demo preview.
60
-
61
- = 1.3.3 =
62
- * Tweak - Support demo import for suffice theme.
63
-
64
- = 1.3.2 =
65
- * Tweak - Load screenshots for pro theme demos.
66
-
67
- = 1.3.1 =
68
- * Tweak - Load screenshot from theme instead of plugin for themes with single demo.
69
-
70
- = 1.3.0 =
71
- * Tweak - Support data update for nested siteorigin layoutbuilder.
72
- * Fix - Import button not working on firefox.
73
-
74
- = 1.2.0 =
75
- * Tweak - Load scripts perfecly on demo importer appearance page.
76
- * Tweak - Set transient for redirecting to demo importer page after install or update.
77
- * Tweak - Introduced filter hook `themegrill_demo_importer_installer` to control demo view.
78
-
79
- = 1.1.0 =
80
- * Feature - Backbone views interface for demos and previews
81
- * Feature - Added download button for the preview not installed
82
- * Feature - Robust quick search view to change in demo interface
83
- * Feature - Detailed information in popup to showcase plugins, events, etc
84
- * Refactor - Replace old way to import demo with new `wp.updates` methods
85
- * Fix - Menu classes to hide admin menu if no JS using css class `hide-if-no-js`
86
- * Fix - Remove the old demo pack if found and to update the new demo packs
87
-
88
- = 1.0.0 =
89
- * Initial Public Release
CODE_OF_CONDUCT.md DELETED
@@ -1,46 +0,0 @@
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 email 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/js/admin/demo-importer.js CHANGED
@@ -556,11 +556,12 @@ demos.view.Demo = wp.Backbone.View.extend({
556
},
557
558
importDemo: function( event ) {
559
- var _this = this,
560
- $target = $( event.target );
561
event.preventDefault();
562
563
- if ( $target.hasClass( 'disabled' ) ) {
564
return;
565
}
566
@@ -568,17 +569,52 @@ demos.view.Demo = wp.Backbone.View.extend({
568
return;
569
}
570
571
wp.updates.maybeRequestFilesystemCredentials( event );
572
573
$( document ).on( 'wp-demo-import-success', function( event, response ) {
574
if ( _this.model.get( 'id' ) === response.slug ) {
575
_this.model.set( { 'imported': true } );
576
}
577
} );
578
579
- wp.updates.importDemo( {
580
- slug: $target.data( 'slug' )
581
} );
582
}
583
});
584
@@ -596,8 +632,7 @@ demos.view.Preview = wp.Backbone.View.extend({
596
'click .previous-theme': 'previousDemo',
597
'click .next-theme': 'nextDemo',
598
'keyup': 'keyEvent',
599
- 'click .demo-import': 'importDemo',
600
- 'click .plugins-install': 'installPlugins'
601
},
602
603
// The HTML template for the demo preview
@@ -722,37 +757,8 @@ demos.view.Preview = wp.Backbone.View.extend({
722
723
importDemo: function( event ) {
724
var _this = this,
725
- $target = $( event.target );
726
- event.preventDefault();
727
-
728
- if ( $target.hasClass( 'disabled' ) || $target.hasClass( 'updating-message' ) ) {
729
- return;
730
- }
731
-
732
- if ( ! window.confirm( wp.demos.data.settings.confirmImport ) ) {
733
- return;
734
- }
735
-
736
- wp.updates.maybeRequestFilesystemCredentials( event );
737
-
738
- // Disable the next and previous demo.
739
- $( '.theme-install-overlay' ).find( '.next-theme, .previous-theme' ).addClass( 'disabled' );
740
-
741
- $( document ).on( 'wp-demo-import-success', function( event, response ) {
742
- if ( _this.model.get( 'id' ) === response.slug ) {
743
- _this.model.set( { 'imported': true } );
744
- }
745
- } );
746
-
747
- wp.updates.importDemo( {
748
- slug: $target.data( 'slug' )
749
- } );
750
- },
751
-
752
- installPlugins: function( event ) {
753
- var _this = this,
754
pluginsList = $( '.plugins-list-table' ).find( '#the-list tr' ),
755
- $target = $( '.plugins-install' ),
756
success = 0,
757
error = 0,
758
errorMessages = [];
@@ -763,10 +769,12 @@ demos.view.Preview = wp.Backbone.View.extend({
763
return;
764
}
765
766
// Bail if there were required plugins.
767
if ( pluginsList.length ) {
768
- $( '.wp-full-overlay-sidebar-content' ).animate( { scrollTop: $( document ).height() } );
769
-
770
if ( $target.html() !== wp.updates.l10n.installing ) {
771
$target.data( 'originaltext', $target.html() );
772
}
@@ -803,6 +811,11 @@ demos.view.Preview = wp.Backbone.View.extend({
803
} );
804
} );
805
806
// Display bulk notification for install of plugin.
807
$( document ).on( 'wp-plugin-bulk-install-success wp-plugin-bulk-install-error', function( event, response ) {
808
var $itemRow = $( '[data-slug="' + response.slug + '"]' ),
@@ -847,7 +860,6 @@ demos.view.Preview = wp.Backbone.View.extend({
847
.text( $target.data( 'originaltext' ) );
848
} else {
849
_this.model.set( { requiredPlugins: false } );
850
- _this.render();
851
852
// Disable the next and previous demo.
853
$( '.theme-install-overlay' ).find( '.next-theme, .previous-theme' ).addClass( 'disabled' );
@@ -860,6 +872,21 @@ demos.view.Preview = wp.Backbone.View.extend({
860
wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
861
} );
862
863
// Check the queue, now that the event handlers have been added.
864
wp.updates.queueChecker();
865
}
556
},
557
558
importDemo: function( event ) {
559
+ var _this = this,
560
+ $target = $( event.target ),
561
+ pluginsList = $( event.target ).data( 'plugins' );
562
event.preventDefault();
563
564
+ if ( $target.hasClass( 'disabled' ) || $target.hasClass( 'updating-message' ) ) {
565
return;
566
}
567
569
return;
570
}
571
572
+ // Bail if there were required plugins.
573
+ if ( ! $.isEmptyObject( pluginsList ) ) {
574
+ if ( $target.html() !== wp.updates.l10n.installing ) {
575
+ $target.data( 'originaltext', $target.html() );
576
+ }
577
+
578
+ $target
579
+ .addClass( 'updating-message' )
580
+ .text( wp.updates.l10n.installing );
581
+ wp.a11y.speak( wp.updates.l10n.installingMsg, 'polite' );
582
+ }
583
+
584
wp.updates.maybeRequestFilesystemCredentials( event );
585
586
+ $( document ).trigger( 'wp-plugin-bulk-install', pluginsList );
587
+
588
+ // Find all the plugins which are required.
589
+ $.each( pluginsList, function( plugin_slug, plugin_data ) {
590
+ if ( ! plugin_data.is_active ) {
591
+ // Add it to the queue.
592
+ wp.updates.queue.push( {
593
+ action: 'install-plugin',
594
+ data: {
595
+ plugin: plugin_data.slug,
596
+ slug: plugin_slug
597
+ }
598
+ } );
599
+ }
600
+ } );
601
+
602
$( document ).on( 'wp-demo-import-success', function( event, response ) {
603
if ( _this.model.get( 'id' ) === response.slug ) {
604
_this.model.set( { 'imported': true } );
605
}
606
} );
607
608
+ // Add it to the queue.
609
+ wp.updates.queue.push( {
610
+ action: 'import-demo',
611
+ data: {
612
+ slug: $target.data( 'slug' )
613
+ }
614
} );
615
+
616
+ // Check the queue, now that the event handlers have been added.
617
+ wp.updates.queueChecker();
618
}
619
});
620
632
'click .previous-theme': 'previousDemo',
633
'click .next-theme': 'nextDemo',
634
'keyup': 'keyEvent',
635
+ 'click .demo-import': 'importDemo'
636
},
637
638
// The HTML template for the demo preview
757
758
importDemo: function( event ) {
759
var _this = this,
760
pluginsList = $( '.plugins-list-table' ).find( '#the-list tr' ),
761
+ $target = $( '.demo-import' ),
762
success = 0,
763
error = 0,
764
errorMessages = [];
769
return;
770
}
771
772
+ if ( ! window.confirm( wp.demos.data.settings.confirmImport ) ) {
773
+ return;
774
+ }
775
+
776
// Bail if there were required plugins.
777
if ( pluginsList.length ) {
778
if ( $target.html() !== wp.updates.l10n.installing ) {
779
$target.data( 'originaltext', $target.html() );
780
}
811
} );
812
} );
813
814
+ // Scroll to bulk plugin install area.
815
+ $( document ).on( 'wp-plugin-bulk-installing', function() {
816
+ $( '.wp-full-overlay-sidebar-content' ).animate( { scrollTop: $( document ).height() } );
817
+ } );
818
+
819
// Display bulk notification for install of plugin.
820
$( document ).on( 'wp-plugin-bulk-install-success wp-plugin-bulk-install-error', function( event, response ) {
821
var $itemRow = $( '[data-slug="' + response.slug + '"]' ),
860
.text( $target.data( 'originaltext' ) );
861
} else {
862
_this.model.set( { requiredPlugins: false } );
863
864
// Disable the next and previous demo.
865
$( '.theme-install-overlay' ).find( '.next-theme, .previous-theme' ).addClass( 'disabled' );
872
wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
873
} );
874
875
+ $( document ).on( 'wp-demo-import-success', function( event, response ) {
876
+ if ( _this.model.get( 'id' ) === response.slug ) {
877
+ // _this.render();
878
+ _this.model.set( { 'imported': true } );
879
+ }
880
+ } );
881
+
882
+ // Add it to the queue.
883
+ wp.updates.queue.push( {
884
+ action: 'import-demo',
885
+ data: {
886
+ slug: $target.data( 'slug' )
887
+ }
888
+ } );
889
+
890
// Check the queue, now that the event handlers have been added.
891
wp.updates.queueChecker();
892
}
assets/js/admin/demo-importer.min.js CHANGED
@@ -1 +1 @@
1
- window.wp=window.wp||{},function(d){var a,i;(a=wp.demos=wp.demos||{}).data=_demoImporterSettings,i=a.data.l10n,a.isNew=!!a.data.settings.isNew,_.extend(a,{model:{},view:{},routes:{},router:{},template:wp.template}),a.Model=Backbone.Model.extend({initialize:function(){var e;this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e}))}}),a.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:d(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView?e.SearchView:a.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new a.view.Demos({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:d(".search-form"),search:function(){var e;1!==a.data.demos.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(d.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+i.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e,t=this;this.window.scrollTop(),t.window.height(),e=t.$el.offset().top+t.$el.outerHeight(!1)-t.window.height(),e=Math.round(.9*e)}}),a.Collection=Backbone.Collection.extend({model:a.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(a.data.demos),d("body").removeClass("no-results")),this.trigger("demos:update"))},search:function(t){var i,e,s,r,o,n;this.reset(a.data.demos,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\amp;")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return r=e.get("name").replace(/(<([^>]+)>)/gi,""),o=e.get("description").replace(/(<([^>]+)>)/gi,""),n=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([r,e.get("id"),o,n,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):d("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(20*e)),t=_(t.first(20))},count:!1,query:function(t){var e,i,s,r=this.queries,o=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){o.add(e.demos),o.trigger("query:success"),o.loadingDemos=!1}).fail(function(){o.trigger("query:fail")});0===e.demos.length?o.trigger("query:empty"):d("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.demos),e.total||(this.count=this.length),this.trigger("demos:update"),this.trigger("query:success",this.count)}else e=this.apiCall(t).done(function(e){e.demos&&(o.reset(e.demos),s=e.info.results,r.push({demos:e.demos,request:t,total:s})),o.trigger("demos:update"),o.trigger("query:success",s),e.demos&&0===e.demos.length&&o.trigger("query:empty")}).fail(function(){o.trigger("query:fail")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-demos",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||d("body").addClass("loading-content").removeClass("no-results")}})},loadingDemos:!1}),a.view.Demo=wp.Backbone.View.extend({className:"theme",state:"grid",html:a.template("demo"),events:{click:"preview",keydown:"preview",touchend:"preview",keyup:"addFocus",touchmove:"preventExpand","click .demo-import":"importDemo"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name","data-slug":e.id}),this.activeDemo(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeDemo:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var e=d(":focus").hasClass("theme")?d(":focus"):d(":focus").parents(".theme");d(".theme.focus").removeClass("focus"),e.addClass("focus")},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,s=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;d(e.target).not(".install-demo-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&d(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,a.focusedDemo=this.$el,a.preview=i=new a.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),d("div.wrap").append(i.el),this.listenTo(i,"demo:next",function(){if(t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("demo:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),d(".next-theme").focus()}).listenTo(i,"demo:previous",function(){t=s.model,0!==s.model.collection.indexOf(s.current)&&(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current)||(i.model=s.current,i.render(),this.setNavButtonsState(),d(".previous-theme").focus()))}),this.listenTo(i,"preview:close",function(){s.current=s.model}))},setNavButtonsState:function(){var e=d(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),s=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),s.focus()),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(s.addClass("disabled").prop("disabled",!0),i.focus())},importDemo:function(e){var i=this,t=d(e.target);e.preventDefault(),t.hasClass("disabled")||window.confirm(wp.demos.data.settings.confirmImport)&&(wp.updates.maybeRequestFilesystemCredentials(e),d(document).on("wp-demo-import-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({imported:!0})}),wp.updates.importDemo({slug:t.data("slug")}))}}),a.view.Preview=wp.Backbone.View.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousDemo","click .next-theme":"nextDemo",keyup:"keyEvent","click .demo-import":"importDemo","click .plugins-install":"installPlugins"},html:a.template("demo-preview"),render:function(){var e,t=this,i=this.model.toJSON(),s=d(document.body);s.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(i)),(e=this.$el.data("current-preview-device"))&&t.tooglePreviewDeviceButtons(e),a.router.navigate(a.router.baseUrl(a.router.demoPath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){s.addClass("demo-importer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){t.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),d(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){d("body").removeClass("demo-importer-active full-overlay-active"),a.focusedDemo&&a.focusedDemo.focus()}).removeClass("iframe-ready"),a.router.selectedTab?a.router.navigate(a.router.baseUrl("&browse="+a.router.selectedTab)):a.router.navigate(a.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){var t=d(e.currentTarget);return"true"===t.attr("aria-expanded")?t.attr({"aria-expanded":"false","aria-label":i.expandSidebar}):t.attr({"aria-expanded":"true","aria-label":i.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){var t=d(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+t).data("current-preview-device",t),this.tooglePreviewDeviceButtons(t)},tooglePreviewDeviceButtons:function(e){var t=d(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextDemo()),37===e.keyCode&&this.previousDemo()},nextDemo:function(){return this.trigger("demo:next",this.model.cid),!1},previousDemo:function(){return this.trigger("demo:previous",this.model.cid),!1},importDemo:function(e){var i=this,t=d(e.target);e.preventDefault(),t.hasClass("disabled")||t.hasClass("updating-message")||window.confirm(wp.demos.data.settings.confirmImport)&&(wp.updates.maybeRequestFilesystemCredentials(e),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled"),d(document).on("wp-demo-import-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({imported:!0})}),wp.updates.importDemo({slug:t.data("slug")}))},installPlugins:function(e){var o=this,t=d(".plugins-list-table").find("#the-list tr"),n=d(".plugins-install"),a=0,l=0,c=[];e.preventDefault(),n.hasClass("disabled")||n.hasClass("updating-message")||(t.length&&(d(".wp-full-overlay-sidebar-content").animate({scrollTop:d(document).height()}),n.html()!==wp.updates.l10n.installing&&n.data("originaltext",n.html()),n.addClass("updating-message").text(wp.updates.l10n.installing),wp.a11y.speak(wp.updates.l10n.installingMsg,"polite"),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled")),wp.updates.maybeRequestFilesystemCredentials(e),d(document).trigger("wp-plugin-bulk-install",t),t.each(function(e,t){var i=d(t);i.hasClass("inactive")&&!i.find("notice-error").length&&wp.updates.queue.push({action:"install-plugin",data:{plugin:i.data("plugin"),slug:i.data("slug")}})}),d(document).on("wp-plugin-bulk-install-success wp-plugin-bulk-install-error",function(e,t){var i,s,r=d('[data-slug="'+t.slug+'"]');"wp-"+t.install+"-bulk-install-success"===e.type?a++:(s=t.pluginName?t.pluginName:r.find(".plugin-name").text(),l++,c.push(s+": "+t.errorMessage)),wp.updates.adminNotice=wp.template("wp-bulk-installs-admin-notice"),d(".plugins-details .bulk-action-notice").remove(),d(".plugins-details .plugins-info").after(wp.updates.adminNotice({id:"bulk-action-notice",className:"bulk-action-notice notice-alt",successes:a,errors:l,errorMessages:c,type:t.install})),i=d("#bulk-action-notice").on("click","button",function(){d(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!d(this).hasClass("bulk-action-errors-collapsed")),i.find(".bulk-action-errors").toggleClass("hidden")}),wp.updates.queue.length||(0<l?n.removeClass("updating-message").text(n.data("originaltext")):(o.model.set({requiredPlugins:!1}),o.render(),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled")))}),d(document).on("wp-updates-notice-added",function(){wp.updates.adminNotice=wp.template("wp-updates-admin-notice")}),wp.updates.queueChecker())}}),a.view.Demos=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:d("div.theme-overlay"),index:0,count:d(".wrap .demo-count"),liveDemoCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.importedDemo(),this.listenTo(t.collection,"demos:update",function(){t.parent.page=0,t.importedDemo(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){d("body").addClass("no-results")}),this.listenTo(this.parent,"demo:scroll",function(){t.renderDemos(t.parent.page)})},render:function(){this.$el.empty(),0<this.options.collection.size()&&this.renderDemos(this.parent.page),this.liveDemoCount=this.collection.count?this.collection.count:this.collection.length,this.count.text(this.liveDemoCount)},renderDemos:function(e){var t=this;t.instance=t.collection.paginate(e),0!==t.instance.size()?(a.isNew&&1<=e&&d(".add-new-theme").remove(),t.instance.each(function(e){t.demo=new a.view.Demo({model:e,parent:t}),t.demo.render(),t.$el.append(t.demo.el)}),a.isNew&&a.data.settings.suggestURI&&this.$el.append('<div class="theme add-new-theme"><a href="'+a.data.settings.suggestURI+'" target="blank"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+i.suggestNew+"</h2></a></div>"),this.parent.page++):this.parent.trigger("demo:end")},importedDemo:function(){var e;(e=this.collection.findWhere({active:!0}))&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},announceSearchResults:function(e){0===e?wp.a11y.speak(i.noDemosFound):wp.a11y.speak(i.demosFound.replace("%d",e))}}),a.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:i.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"demo:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?a.router.navigate(a.router.baseUrl(a.router.searchPath+e.target.value),t):a.router.navigate(a.router.baseUrl(""))},pushState:function(e){var t=a.router.baseUrl("");e.target.value&&(t=a.router.baseUrl(a.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,a.router.navigate(t)}}),a.Router=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&demo=:slug":"preview","themes.php?page=demo-importer&browse=:sort":"sort","themes.php?page=demo-importer&search=:query":"search","themes.php?page=demo-importer":"sort"},baseUrl:function(e){return"themes.php?page=demo-importer"+e},demoPath:"&demo=",browsePath:"&browse=",searchPath:"&search=",search:function(e){d(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:function s(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}}),a.view.InstallerSearch=a.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e.target.value))},doSearch:function(e){this.terms!==e&&(this.terms=e,d(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),this.collection.doSearch(e.replace(/\+/g," ")),a.router.navigate(a.router.baseUrl(a.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),a.view.Installer=a.view.Appearance.extend({el:"#wpbody-content .wrap",events:{"click .filter-links li > a":"onSort"},render:function(){var e=this;this.search(),this.collection=new a.Collection,this.listenTo(this,"demo:end",function(){e.collection.loadingDemos||(e.collection.loadingDemos=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove()}),this.listenTo(this.collection,"query:fail",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove(),d(".theme-browser").find("div.themes").before('<div class="error"><p>'+i.error+'</p><p><button class="button try-again">'+i.tryAgain+"</button></p></div>"),d(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),d("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new a.view.Demos({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e,t){this.collection.query({browse:e,builder:t})},onSort:function(e){var t=d(e.target),i=t.data("sort"),s=t.data("type");e.preventDefault(),i=i||a.router.selectedTab,s=s||a.router.selectedType,t.hasClass(this.activeClass)||(this.sort(i,s),a.router.navigate(a.router.baseUrl(a.router.browsePath+i)))},sort:function(e,t){this.clearSearch(),a.router.selectedTab=e,a.router.selectedType=t,d(".filter-links li > a").removeClass(this.activeClass).removeAttr("aria-current"),d('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),d('[data-type="'+t+'"]').addClass(this.activeClass).attr("aria-current","page"),this.browse(e,t)},activeClass:"current",clearSearch:function(){d("#wp-filter-search-input").val("")}}),a.RunInstaller={init:function(){this.view=new a.view.Installer({section:"all",SearchView:a.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:a.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var i=this,t={};a.router=new a.Router,a.router.on("route:preview",function(e){a.preview&&(a.preview.undelegateEvents(),a.preview.unbind()),i.view.view.demo&&i.view.view.demo.preview?(i.view.view.demo.model=i.view.collection.findWhere({slug:e}),i.view.view.demo.preview()):(t.demo=e,i.view.collection.query(t),i.view.collection.trigger("update"),i.view.collection.once("query:success",function(){d('div[data-slug="'+e+'"]').trigger("click")}))}),a.router.on("route:sort",function(e){var t=a.router.selectedType?a.router.selectedType:d(".filter-links.pagebuilders li").first().find("a").data("type");e&&d('[data-sort="'+e+'"]').length||(e="all",a.router.navigate(a.router.baseUrl("&browse=all"),{replace:!0})),i.view.sort(e,t),a.preview&&a.preview.close()}),a.router.on("route:search",function(){d(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},d(document).ready(function(){a.RunInstaller.init(),d(document.body).on("init_tooltips",function(){d("#tiptip_holder").removeAttr("style"),d("#tiptip_arrow").removeAttr("style"),d(".tips").tipTip({attribute:"data-tip",defaultPosition:"top",fadeIn:50,fadeOut:50,delay:50})}).trigger("init_tooltips"),d(".themegrill-reset-wordpress").on("click",function(){return window.confirm(_demoImporterSettings.settings.confirmReset)}),d(".themegrill-demo-importer-rating-link").on("click",function(){var e=d(this);d.post(a.data.settings.ajaxUrl,{action:"footer-text-rated"}),e.parent().text(e.data("rated"))})})}(jQuery);
1
+ window.wp=window.wp||{},function(d){var a,i;(a=wp.demos=wp.demos||{}).data=_demoImporterSettings,i=a.data.l10n,a.isNew=!!a.data.settings.isNew,_.extend(a,{model:{},view:{},routes:{},router:{},template:wp.template}),a.Model=Backbone.Model.extend({initialize:function(){var e;this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e}))}}),a.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:d(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView?e.SearchView:a.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new a.view.Demos({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:d(".search-form"),search:function(){var e;1!==a.data.demos.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(d.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+i.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e,t=this;this.window.scrollTop(),t.window.height(),e=t.$el.offset().top+t.$el.outerHeight(!1)-t.window.height(),e=Math.round(.9*e)}}),a.Collection=Backbone.Collection.extend({model:a.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(a.data.demos),d("body").removeClass("no-results")),this.trigger("demos:update"))},search:function(t){var i,e,s,r,o,n;this.reset(a.data.demos,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\amp;")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return r=e.get("name").replace(/(<([^>]+)>)/gi,""),o=e.get("description").replace(/(<([^>]+)>)/gi,""),n=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([r,e.get("id"),o,n,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):d("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(20*e)),t=_(t.first(20))},count:!1,query:function(t){var e,i,s,r=this.queries,o=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){o.add(e.demos),o.trigger("query:success"),o.loadingDemos=!1}).fail(function(){o.trigger("query:fail")});0===e.demos.length?o.trigger("query:empty"):d("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.demos),e.total||(this.count=this.length),this.trigger("demos:update"),this.trigger("query:success",this.count)}else e=this.apiCall(t).done(function(e){e.demos&&(o.reset(e.demos),s=e.info.results,r.push({demos:e.demos,request:t,total:s})),o.trigger("demos:update"),o.trigger("query:success",s),e.demos&&0===e.demos.length&&o.trigger("query:empty")}).fail(function(){o.trigger("query:fail")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-demos",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||d("body").addClass("loading-content").removeClass("no-results")}})},loadingDemos:!1}),a.view.Demo=wp.Backbone.View.extend({className:"theme",state:"grid",html:a.template("demo"),events:{click:"preview",keydown:"preview",touchend:"preview",keyup:"addFocus",touchmove:"preventExpand","click .demo-import":"importDemo"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name","data-slug":e.id}),this.activeDemo(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeDemo:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var e=d(":focus").hasClass("theme")?d(":focus"):d(":focus").parents(".theme");d(".theme.focus").removeClass("focus"),e.addClass("focus")},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,s=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;d(e.target).not(".install-demo-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&d(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,a.focusedDemo=this.$el,a.preview=i=new a.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),d("div.wrap").append(i.el),this.listenTo(i,"demo:next",function(){if(t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("demo:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),d(".next-theme").focus()}).listenTo(i,"demo:previous",function(){t=s.model,0!==s.model.collection.indexOf(s.current)&&(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current)||(i.model=s.current,i.render(),this.setNavButtonsState(),d(".previous-theme").focus()))}),this.listenTo(i,"preview:close",function(){s.current=s.model}))},setNavButtonsState:function(){var e=d(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),s=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),s.focus()),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(s.addClass("disabled").prop("disabled",!0),i.focus())},importDemo:function(e){var i=this,t=d(e.target),s=d(e.target).data("plugins");e.preventDefault(),t.hasClass("disabled")||t.hasClass("updating-message")||window.confirm(wp.demos.data.settings.confirmImport)&&(d.isEmptyObject(s)||(t.html()!==wp.updates.l10n.installing&&t.data("originaltext",t.html()),t.addClass("updating-message").text(wp.updates.l10n.installing),wp.a11y.speak(wp.updates.l10n.installingMsg,"polite")),wp.updates.maybeRequestFilesystemCredentials(e),d(document).trigger("wp-plugin-bulk-install",s),d.each(s,function(e,t){t.is_active||wp.updates.queue.push({action:"install-plugin",data:{plugin:t.slug,slug:e}})}),d(document).on("wp-demo-import-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({imported:!0})}),wp.updates.queue.push({action:"import-demo",data:{slug:t.data("slug")}}),wp.updates.queueChecker())}}),a.view.Preview=wp.Backbone.View.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousDemo","click .next-theme":"nextDemo",keyup:"keyEvent","click .demo-import":"importDemo"},html:a.template("demo-preview"),render:function(){var e,t=this,i=this.model.toJSON(),s=d(document.body);s.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(i)),(e=this.$el.data("current-preview-device"))&&t.tooglePreviewDeviceButtons(e),a.router.navigate(a.router.baseUrl(a.router.demoPath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){s.addClass("demo-importer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){t.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),d(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){d("body").removeClass("demo-importer-active full-overlay-active"),a.focusedDemo&&a.focusedDemo.focus()}).removeClass("iframe-ready"),a.router.selectedTab?a.router.navigate(a.router.baseUrl("&browse="+a.router.selectedTab)):a.router.navigate(a.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){var t=d(e.currentTarget);return"true"===t.attr("aria-expanded")?t.attr({"aria-expanded":"false","aria-label":i.expandSidebar}):t.attr({"aria-expanded":"true","aria-label":i.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){var t=d(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+t).data("current-preview-device",t),this.tooglePreviewDeviceButtons(t)},tooglePreviewDeviceButtons:function(e){var t=d(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextDemo()),37===e.keyCode&&this.previousDemo()},nextDemo:function(){return this.trigger("demo:next",this.model.cid),!1},previousDemo:function(){return this.trigger("demo:previous",this.model.cid),!1},importDemo:function(e){var o=this,t=d(".plugins-list-table").find("#the-list tr"),n=d(".demo-import"),a=0,l=0,c=[];e.preventDefault(),n.hasClass("disabled")||n.hasClass("updating-message")||window.confirm(wp.demos.data.settings.confirmImport)&&(t.length&&(n.html()!==wp.updates.l10n.installing&&n.data("originaltext",n.html()),n.addClass("updating-message").text(wp.updates.l10n.installing),wp.a11y.speak(wp.updates.l10n.installingMsg,"polite"),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled")),wp.updates.maybeRequestFilesystemCredentials(e),d(document).trigger("wp-plugin-bulk-install",t),t.each(function(e,t){var i=d(t);i.hasClass("inactive")&&!i.find("notice-error").length&&wp.updates.queue.push({action:"install-plugin",data:{plugin:i.data("plugin"),slug:i.data("slug")}})}),d(document).on("wp-plugin-bulk-installing",function(){d(".wp-full-overlay-sidebar-content").animate({scrollTop:d(document).height()})}),d(document).on("wp-plugin-bulk-install-success wp-plugin-bulk-install-error",function(e,t){var i,s,r=d('[data-slug="'+t.slug+'"]');"wp-"+t.install+"-bulk-install-success"===e.type?a++:(s=t.pluginName?t.pluginName:r.find(".plugin-name").text(),l++,c.push(s+": "+t.errorMessage)),wp.updates.adminNotice=wp.template("wp-bulk-installs-admin-notice"),d(".plugins-details .bulk-action-notice").remove(),d(".plugins-details .plugins-info").after(wp.updates.adminNotice({id:"bulk-action-notice",className:"bulk-action-notice notice-alt",successes:a,errors:l,errorMessages:c,type:t.install})),i=d("#bulk-action-notice").on("click","button",function(){d(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!d(this).hasClass("bulk-action-errors-collapsed")),i.find(".bulk-action-errors").toggleClass("hidden")}),wp.updates.queue.length||(0<l?n.removeClass("updating-message").text(n.data("originaltext")):(o.model.set({requiredPlugins:!1}),d(".theme-install-overlay").find(".next-theme, .previous-theme").addClass("disabled")))}),d(document).on("wp-updates-notice-added",function(){wp.updates.adminNotice=wp.template("wp-updates-admin-notice")}),d(document).on("wp-demo-import-success",function(e,t){o.model.get("id")===t.slug&&o.model.set({imported:!0})}),wp.updates.queue.push({action:"import-demo",data:{slug:n.data("slug")}}),wp.updates.queueChecker())}}),a.view.Demos=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:d("div.theme-overlay"),index:0,count:d(".wrap .demo-count"),liveDemoCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.importedDemo(),this.listenTo(t.collection,"demos:update",function(){t.parent.page=0,t.importedDemo(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){d("body").addClass("no-results")}),this.listenTo(this.parent,"demo:scroll",function(){t.renderDemos(t.parent.page)})},render:function(){this.$el.empty(),0<this.options.collection.size()&&this.renderDemos(this.parent.page),this.liveDemoCount=this.collection.count?this.collection.count:this.collection.length,this.count.text(this.liveDemoCount)},renderDemos:function(e){var t=this;t.instance=t.collection.paginate(e),0!==t.instance.size()?(a.isNew&&1<=e&&d(".add-new-theme").remove(),t.instance.each(function(e){t.demo=new a.view.Demo({model:e,parent:t}),t.demo.render(),t.$el.append(t.demo.el)}),a.isNew&&a.data.settings.suggestURI&&this.$el.append('<div class="theme add-new-theme"><a href="'+a.data.settings.suggestURI+'" target="blank"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+i.suggestNew+"</h2></a></div>"),this.parent.page++):this.parent.trigger("demo:end")},importedDemo:function(){var e;(e=this.collection.findWhere({active:!0}))&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},announceSearchResults:function(e){0===e?wp.a11y.speak(i.noDemosFound):wp.a11y.speak(i.demosFound.replace("%d",e))}}),a.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:i.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"demo:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?a.router.navigate(a.router.baseUrl(a.router.searchPath+e.target.value),t):a.router.navigate(a.router.baseUrl(""))},pushState:function(e){var t=a.router.baseUrl("");e.target.value&&(t=a.router.baseUrl(a.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,a.router.navigate(t)}}),a.Router=Backbone.Router.extend({routes:{"themes.php?page=demo-importer&demo=:slug":"preview","themes.php?page=demo-importer&browse=:sort":"sort","themes.php?page=demo-importer&search=:query":"search","themes.php?page=demo-importer":"sort"},baseUrl:function(e){return"themes.php?page=demo-importer"+e},demoPath:"&demo=",browsePath:"&browse=",searchPath:"&search=",search:function(e){d(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:function s(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}}),a.view.InstallerSearch=a.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e.target.value))},doSearch:function(e){this.terms!==e&&(this.terms=e,d(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),this.collection.doSearch(e.replace(/\+/g," ")),a.router.navigate(a.router.baseUrl(a.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),a.view.Installer=a.view.Appearance.extend({el:"#wpbody-content .wrap",events:{"click .filter-links li > a":"onSort"},render:function(){var e=this;this.search(),this.collection=new a.Collection,this.listenTo(this,"demo:end",function(){e.collection.loadingDemos||(e.collection.loadingDemos=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove()}),this.listenTo(this.collection,"query:fail",function(){d("body").removeClass("loading-content"),d(".theme-browser").find("div.error").remove(),d(".theme-browser").find("div.themes").before('<div class="error"><p>'+i.error+'</p><p><button class="button try-again">'+i.tryAgain+"</button></p></div>"),d(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),d("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new a.view.Demos({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e,t){this.collection.query({browse:e,builder:t})},onSort:function(e){var t=d(e.target),i=t.data("sort"),s=t.data("type");e.preventDefault(),i=i||a.router.selectedTab,s=s||a.router.selectedType,t.hasClass(this.activeClass)||(this.sort(i,s),a.router.navigate(a.router.baseUrl(a.router.browsePath+i)))},sort:function(e,t){this.clearSearch(),a.router.selectedTab=e,a.router.selectedType=t,d(".filter-links li > a").removeClass(this.activeClass).removeAttr("aria-current"),d('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),d('[data-type="'+t+'"]').addClass(this.activeClass).attr("aria-current","page"),this.browse(e,t)},activeClass:"current",clearSearch:function(){d("#wp-filter-search-input").val("")}}),a.RunInstaller={init:function(){this.view=new a.view.Installer({section:"all",SearchView:a.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:a.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var i=this,t={};a.router=new a.Router,a.router.on("route:preview",function(e){a.preview&&(a.preview.undelegateEvents(),a.preview.unbind()),i.view.view.demo&&i.view.view.demo.preview?(i.view.view.demo.model=i.view.collection.findWhere({slug:e}),i.view.view.demo.preview()):(t.demo=e,i.view.collection.query(t),i.view.collection.trigger("update"),i.view.collection.once("query:success",function(){d('div[data-slug="'+e+'"]').trigger("click")}))}),a.router.on("route:sort",function(e){var t=a.router.selectedType?a.router.selectedType:d(".filter-links.pagebuilders li").first().find("a").data("type");e&&d('[data-sort="'+e+'"]').length||(e="all",a.router.navigate(a.router.baseUrl("&browse=all"),{replace:!0})),i.view.sort(e,t),a.preview&&a.preview.close()}),a.router.on("route:search",function(){d(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},d(document).ready(function(){a.RunInstaller.init(),d(document.body).on("init_tooltips",function(){d("#tiptip_holder").removeAttr("style"),d("#tiptip_arrow").removeAttr("style"),d(".tips").tipTip({attribute:"data-tip",defaultPosition:"top",fadeIn:50,fadeOut:50,delay:50})}).trigger("init_tooltips"),d(".themegrill-reset-wordpress").on("click",function(){return window.confirm(_demoImporterSettings.settings.confirmReset)}),d(".themegrill-demo-importer-rating-link").on("click",function(){var e=d(this);d.post(a.data.settings.ajaxUrl,{action:"footer-text-rated"}),e.parent().text(e.data("rated"))})})}(jQuery);
composer.lock DELETED
@@ -1,425 +0,0 @@
1
- {
2
- "_readme": [
3
- "This file locks the dependencies of your project to a known state",
4
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
- "This file is @generated automatically"
6
- ],
7
- "content-hash": "7d1f46a9688ef0db39b8afa16e609252",
8
- "packages": [
9
- {
10
- "name": "composer/installers",
11
- "version": "v1.5.0",
12
- "source": {
13
- "type": "git",
14
- "url": "https://github.com/composer/installers.git",
15
- "reference": "049797d727261bf27f2690430d935067710049c2"
16
- },
17
- "dist": {
18
- "type": "zip",
19
- "url": "https://api.github.com/repos/composer/installers/zipball/049797d727261bf27f2690430d935067710049c2",
20
- "reference": "049797d727261bf27f2690430d935067710049c2",
21
- "shasum": ""
22
- },
23
- "require": {
24
- "composer-plugin-api": "^1.0"
25
- },
26
- "replace": {
27
- "roundcube/plugin-installer": "*",
28
- "shama/baton": "*"
29
- },
30
- "require-dev": {
31
- "composer/composer": "1.0.*@dev",
32
- "phpunit/phpunit": "^4.8.36"
33
- },
34
- "type": "composer-plugin",
35
- "extra": {
36
- "class": "Composer\\Installers\\Plugin",
37
- "branch-alias": {
38
- "dev-master": "1.0-dev"
39
- }
40
- },
41
- "autoload": {
42
- "psr-4": {
43
- "Composer\\Installers\\": "src/Composer/Installers"
44
- }
45
- },
46
- "notification-url": "https://packagist.org/downloads/",
47
- "license": [
48
- "MIT"
49
- ],
50
- "authors": [
51
- {
52
- "name": "Kyle Robinson Young",
53
- "email": "kyle@dontkry.com",
54
- "homepage": "https://github.com/shama"
55
- }
56
- ],
57
- "description": "A multi-framework Composer library installer",
58
- "homepage": "https://composer.github.io/installers/",
59
- "keywords": [
60
- "Craft",
61
- "Dolibarr",
62
- "Eliasis",
63
- "Hurad",
64
- "ImageCMS",
65
- "Kanboard",
66
- "Lan Management System",
67
- "MODX Evo",
68
- "Mautic",
69
- "Maya",
70
- "OXID",
71
- "Plentymarkets",
72
- "Porto",
73
- "RadPHP",
74
- "SMF",
75
- "Thelia",
76
- "WolfCMS",
77
- "agl",
78
- "aimeos",
79
- "annotatecms",
80
- "attogram",
81
- "bitrix",
82
- "cakephp",
83
- "chef",
84
- "cockpit",
85
- "codeigniter",
86
- "concrete5",
87
- "croogo",
88
- "dokuwiki",
89
- "drupal",
90
- "eZ Platform",
91
- "elgg",
92
- "expressionengine",
93
- "fuelphp",
94
- "grav",
95
- "installer",
96
- "itop",
97
- "joomla",
98
- "kohana",
99
- "laravel",
100
- "lavalite",
101
- "lithium",
102
- "magento",
103
- "majima",
104
- "mako",
105
- "mediawiki",
106
- "modulework",
107
- "modx",
108
- "moodle",
109
- "osclass",
110
- "phpbb",
111
- "piwik",
112
- "ppi",
113
- "puppet",
114
- "pxcms",
115
- "reindex",
116
- "roundcube",
117
- "shopware",
118
- "silverstripe",
119
- "sydes",
120
- "symfony",
121
- "typo3",
122
- "wordpress",
123
- "yawik",
124
- "zend",
125
- "zikula"
126
- ],
127
- "time": "2017-12-29T09:13:20+00:00"
128
- }
129
- ],
130
- "packages-dev": [
131
- {
132
- "name": "dealerdirect/phpcodesniffer-composer-installer",
133
- "version": "v0.4.4",
134
- "source": {
135
- "type": "git",
136
- "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
137
- "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08"
138
- },
139
- "dist": {
140
- "type": "zip",
141
- "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/2e41850d5f7797cbb1af7b030d245b3b24e63a08",
142
- "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08",
143
- "shasum": ""
144
- },
145
- "require": {
146
- "composer-plugin-api": "^1.0",
147
- "php": "^5.3|^7",
148
- "squizlabs/php_codesniffer": "*"
149
- },
150
- "require-dev": {
151
- "composer/composer": "*",
152
- "wimg/php-compatibility": "^8.0"
153
- },
154
- "suggest": {
155
- "dealerdirect/qa-tools": "All the PHP QA tools you'll need"
156
- },
157
- "type": "composer-plugin",
158
- "extra": {
159
- "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
160
- },
161
- "autoload": {
162
- "psr-4": {
163
- "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
164
- }
165
- },
166
- "notification-url": "https://packagist.org/downloads/",
167
- "license": [
168
- "MIT"
169
- ],
170
- "authors": [
171
- {
172
- "name": "Franck Nijhof",
173
- "email": "f.nijhof@dealerdirect.nl",
174
- "homepage": "http://workingatdealerdirect.eu",
175
- "role": "Developer"
176
- }
177
- ],
178
- "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
179
- "homepage": "http://workingatdealerdirect.eu",
180
- "keywords": [
181
- "PHPCodeSniffer",
182
- "PHP_CodeSniffer",
183
- "code quality",
184
- "codesniffer",
185
- "composer",
186
- "installer",
187
- "phpcs",
188
- "plugin",
189
- "qa",
190
- "quality",
191
- "standard",
192
- "standards",
193
- "style guide",
194
- "stylecheck",
195
- "tests"
196
- ],
197
- "time": "2017-12-06T16:27:17+00:00"
198
- },
199
- {
200
- "name": "squizlabs/php_codesniffer",
201
- "version": "3.3.1",
202
- "source": {
203
- "type": "git",
204
- "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
205
- "reference": "628a481780561150481a9ec74709092b9759b3ec"
206
- },
207
- "dist": {
208
- "type": "zip",
209
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/628a481780561150481a9ec74709092b9759b3ec",
210
- "reference": "628a481780561150481a9ec74709092b9759b3ec",
211
- "shasum": ""
212
- },
213
- "require": {
214
- "ext-simplexml": "*",
215
- "ext-tokenizer": "*",
216
- "ext-xmlwriter": "*",
217
- "php": ">=5.4.0"
218
- },
219
- "require-dev": {
220
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
221
- },
222
- "bin": [
223
- "bin/phpcs",
224
- "bin/phpcbf"
225
- ],
226
- "type": "library",
227
- "extra": {
228
- "branch-alias": {
229
- "dev-master": "3.x-dev"
230
- }
231
- },
232
- "notification-url": "https://packagist.org/downloads/",
233
- "license": [
234
- "BSD-3-Clause"
235
- ],
236
- "authors": [
237
- {
238
- "name": "Greg Sherwood",
239
- "role": "lead"
240
- }
241
- ],
242
- "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
243
- "homepage": "http://www.squizlabs.com/php-codesniffer",
244
- "keywords": [
245
- "phpcs",
246
- "standards"
247
- ],
248
- "time": "2018-07-26T23:47:18+00:00"
249
- },
250
- {
251
- "name": "wimg/php-compatibility",
252
- "version": "8.2.0",
253
- "source": {
254
- "type": "git",
255
- "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
256
- "reference": "eaf613c1a8265bcfd7b0ab690783f2aef519f78a"
257
- },
258
- "dist": {
259
- "type": "zip",
260
- "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/eaf613c1a8265bcfd7b0ab690783f2aef519f78a",
261
- "reference": "eaf613c1a8265bcfd7b0ab690783f2aef519f78a",
262
- "shasum": ""
263
- },
264
- "require": {
265
- "php": ">=5.3",
266
- "squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
267
- },
268
- "conflict": {
269
- "squizlabs/php_codesniffer": "2.6.2"
270
- },
271
- "require-dev": {
272
- "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
273
- },
274
- "suggest": {
275
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
276
- "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
277
- },
278
- "type": "phpcodesniffer-standard",
279
- "autoload": {
280
- "psr-4": {
281
- "PHPCompatibility\\": "PHPCompatibility/"
282
- }
283
- },
284
- "notification-url": "https://packagist.org/downloads/",
285
- "license": [
286
- "LGPL-3.0-or-later"
287
- ],
288
- "authors": [
289
- {
290
- "name": "Wim Godden",
291
- "role": "lead"
292
- }
293
- ],
294
- "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
295
- "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
296
- "keywords": [
297
- "compatibility",
298
- "phpcs",
299
- "standards"
300
- ],
301
- "time": "2018-07-17T13:42:26+00:00"
302
- },
303
- {
304
- "name": "wp-coding-standards/wpcs",
305
- "version": "0.14.1",
306
- "source": {
307
- "type": "git",
308
- "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
309
- "reference": "cf6b310caad735816caef7573295f8a534374706"
310
- },
311
- "dist": {
312
- "type": "zip",
313
- "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706",
314
- "reference": "cf6b310caad735816caef7573295f8a534374706",
315
- "shasum": ""
316
- },
317
- "require": {
318
- "php": ">=5.3",
319
- "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
320
- },
321
- "suggest": {
322
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
323
- },
324
- "type": "phpcodesniffer-standard",
325
- "notification-url": "https://packagist.org/downloads/",
326
- "license": [
327
- "MIT"
328
- ],
329
- "authors": [
330
- {
331
- "name": "Contributors",
332
- "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
333
- }
334
- ],
335
- "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
336
- "keywords": [
337
- "phpcs",
338
- "standards",
339
- "wordpress"
340
- ],
341
- "time": "2018-02-16T01:57:48+00:00"
342
- },
343
- {
344
- "name": "wpeverest/wpeverest-git-hooks",
345
- "version": "1.0.2",
346
- "source": {
347
- "type": "git",
348
- "url": "https://github.com/wpeverest/wpeverest-git-hooks.git",
349
- "reference": "81b1a2ff501252a23cbd59155bdc21918cef0dd2"
350
- },
351
- "dist": {
352
- "type": "zip",
353
- "url": "https://api.github.com/repos/wpeverest/wpeverest-git-hooks/zipball/81b1a2ff501252a23cbd59155bdc21918cef0dd2",
354
- "reference": "81b1a2ff501252a23cbd59155bdc21918cef0dd2",
355
- "shasum": ""
356
- },
357
- "type": "scripts",
358
- "autoload": {
359
- "psr-4": {
360
- "WPEverest\\GitHooks\\": "src/"
361
- }
362
- },
363
- "notification-url": "https://packagist.org/downloads/",
364
- "license": [
365
- "MIT"
366
- ],
367
- "authors": [
368
- {
369
- "name": "Shiva Poudel",
370
- "email": "dev.shivapoudel@gmail.com"
371
- }
372
- ],
373
- "description": "WPEverest Git Hooks",
374
- "time": "2017-12-18T16:25:25+00:00"
375
- },
376
- {
377
- "name": "wpeverest/wpeverest-sniffs",
378
- "version": "0.0.1",
379
- "source": {
380
- "type": "git",
381
- "url": "https://github.com/wpeverest/wpeverest-sniffs.git",
382
- "reference": "2e61559f889ba4d3b01e4ded277161fb78e74c3f"
383
- },
384
- "dist": {
385
- "type": "zip",
386
- "url": "https://api.github.com/repos/wpeverest/wpeverest-sniffs/zipball/2e61559f889ba4d3b01e4ded277161fb78e74c3f",
387
- "reference": "2e61559f889ba4d3b01e4ded277161fb78e74c3f",
388
- "shasum": ""
389
- },
390
- "require": {
391
- "php": ">=7.0",
392
- "squizlabs/php_codesniffer": "^3.0.2"
393
- },
394
- "suggest": {
395
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
396
- },
397
- "type": "phpcodesniffer-standard",
398
- "notification-url": "https://packagist.org/downloads/",
399
- "license": [
400
- "MIT"
401
- ],
402
- "authors": [
403
- {
404
- "name": "Shiva Poudel",
405
- "email": "dev.shivapoudel@gmail.com"
406
- }
407
- ],
408
- "description": "WPEverest sniffs",
409
- "keywords": [
410
- "WPEverest",
411
- "phpcs",
412
- "standards",
413
- "wordpress"
414
- ],
415
- "time": "2017-12-25T05:34:53+00:00"
416
- }
417
- ],
418
- "aliases": [],
419
- "minimum-stability": "stable",
420
- "stability-flags": [],
421
- "prefer-stable": false,
422
- "prefer-lowest": false,
423
- "platform": [],
424
- "platform-dev": []
425
- }
includes/admin/class-demo-pack-upgrader.php CHANGED
@@ -9,7 +9,7 @@
9
*
10
* @since 1.5.0
11
* @see WP_Upgrader
12
- * @package ThemeGrill_Demo_Importer/Class
13
*/
14
class TG_Demo_Pack_Upgrader extends WP_Upgrader {
15
@@ -35,13 +35,13 @@ class TG_Demo_Pack_Upgrader extends WP_Upgrader {
35
$this->strings['no_package'] = __( 'Install package not available.', 'themegrill-demo-importer' );
36
/* translators: %s: package URL */
37
$this->strings['downloading_package'] = __( 'Downloading install package from <span class="code">%s</span>&#8230;', 'themegrill-demo-importer' );
38
- $this->strings['unpack_package'] = __( 'Unpacking the package&#8230;', 'themegrill-demo-importer' );
39
- $this->strings['remove_old'] = __( 'Removing the old version of the demo&#8230;', 'themegrill-demo-importer' );
40
- $this->strings['remove_old_failed'] = __( 'Could not remove the old demo.', 'themegrill-demo-importer' );
41
- $this->strings['installing_package'] = __( 'Installing the demo&#8230;', 'themegrill-demo-importer' );
42
- $this->strings['no_files'] = __( 'The demo contains no files.', 'themegrill-demo-importer' );
43
- $this->strings['process_failed'] = __( 'Demo install failed.', 'themegrill-demo-importer' );
44
- $this->strings['process_success'] = __( 'Demo installed successfully.', 'themegrill-demo-importer' );
45
}
46
47
/**
@@ -59,7 +59,7 @@ class TG_Demo_Pack_Upgrader extends WP_Upgrader {
59
*/
60
public function install( $package, $args = array() ) {
61
62
- $defaults = array(
63
'clear_update_cache' => true,
64
);
65
$parsed_args = wp_parse_args( $args, $defaults );
@@ -69,16 +69,18 @@ class TG_Demo_Pack_Upgrader extends WP_Upgrader {
69
70
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
71
72
- $this->run( array(
73
- 'package' => $package,
74
- 'destination' => TGDM_DEMO_DIR,
75
- 'clear_destination' => true, // Do overwrite files.
76
- 'clear_working' => true,
77
- 'hook_extra' => array(
78
- 'type' => 'demo',
79
- 'action' => 'install',
80
- ),
81
- ) );
82
83
remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
84
@@ -110,8 +112,9 @@ class TG_Demo_Pack_Upgrader extends WP_Upgrader {
110
111
// Check the folder contains a valid demo.
112
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
113
- if ( ! is_dir( $working_directory ) ) // Sanity check, if the above fails, let's not prevent installation.
114
return $source;
115
116
// Check the folder contains at least 1 valid demo.
117
if ( ! file_exists( $working_directory . 'screenshot.jpg' ) ) {
9
*
10
* @since 1.5.0
11
* @see WP_Upgrader
12
+ * @package ThemeGrill_Demo_Importer\Class
13
*/
14
class TG_Demo_Pack_Upgrader extends WP_Upgrader {
15
35
$this->strings['no_package'] = __( 'Install package not available.', 'themegrill-demo-importer' );
36
/* translators: %s: package URL */
37
$this->strings['downloading_package'] = __( 'Downloading install package from <span class="code">%s</span>&#8230;', 'themegrill-demo-importer' );
38
+ $this->strings['unpack_package'] = __( 'Unpacking the package&#8230;', 'themegrill-demo-importer' );
39
+ $this->strings['remove_old'] = __( 'Removing the old version of the demo&#8230;', 'themegrill-demo-importer' );
40
+ $this->strings['remove_old_failed'] = __( 'Could not remove the old demo.', 'themegrill-demo-importer' );
41
+ $this->strings['installing_package'] = __( 'Installing the demo&#8230;', 'themegrill-demo-importer' );
42
+ $this->strings['no_files'] = __( 'The demo contains no files.', 'themegrill-demo-importer' );
43
+ $this->strings['process_failed'] = __( 'Demo install failed.', 'themegrill-demo-importer' );
44
+ $this->strings['process_success'] = __( 'Demo installed successfully.', 'themegrill-demo-importer' );
45
}
46
47
/**
59
*/
60
public function install( $package, $args = array() ) {
61
62
+ $defaults = array(
63
'clear_update_cache' => true,
64
);
65
$parsed_args = wp_parse_args( $args, $defaults );
69
70
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
71
72
+ $this->run(
73
+ array(
74
+ 'package' => $package,
75
+ 'destination' => TGDM_DEMO_DIR,
76
+ 'clear_destination' => true, // Do overwrite files.
77
+ 'clear_working' => true,
78
+ 'hook_extra' => array(
79
+ 'type' => 'demo',
80
+ 'action' => 'install',
81
+ ),
82
+ )
83
+ );
84
85
remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
86
112
113
// Check the folder contains a valid demo.
114
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
115
+ if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
116
return $source;
117
+ }
118
119
// Check the folder contains at least 1 valid demo.
120
if ( ! file_exists( $working_directory . 'screenshot.jpg' ) ) {
includes/admin/views/html-admin-page-importer.php CHANGED
@@ -18,10 +18,10 @@ defined( 'ABSPATH' ) || exit;
18
<hr class="wp-header-end">
19
20
<div class="error hide-if-js">
21
- <p><?php _e( 'The Demo Importer screen requires JavaScript.', 'themegrill-demo-importer' ); ?></p>
22
</div>
23
24
- <h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Filter demos list', 'themegrill-demo-importer' ); ?></h2>
25
26
<div class="wp-filter hide-if-no-js">
27
<div class="filter-section">
@@ -43,7 +43,7 @@ defined( 'ABSPATH' ) || exit;
43
<?php foreach ( $this->demo_packages->pagebuilders as $slug => $label ) : ?>
44
<?php if ( 'default' !== $slug ) : ?>
45
<li><a href="#" data-type="<?php echo esc_attr( $slug ); ?>" class="pagebuilder-tab"><?php echo esc_html( $label ); ?></a></li>
46
- <?php else: ?>
47
<li><a href="#" data-type="<?php echo esc_attr( $slug ); ?>" class="pagebuilder-tab tips" data-tip="<?php esc_attr_e( 'Without Page Builder', 'themegrill-demo-importer' ); ?>"><?php echo esc_html( $label ); ?></a></li>
48
<?php endif; ?>
49
<?php endforeach; ?>
@@ -53,11 +53,11 @@ defined( 'ABSPATH' ) || exit;
53
<form class="search-form"></form>
54
</div>
55
</div>
56
- <h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Themes list', 'themegrill-demo-importer' ); ?></h2>
57
<div class="theme-browser content-filterable"></div>
58
<div class="theme-install-overlay wp-full-overlay expanded"></div>
59
60
- <p class="no-themes"><?php _e( 'No demos found. Try a different search.', 'themegrill-demo-importer' ); ?></p>
61
<span class="spinner"></span>
62
</div>
63
@@ -71,14 +71,13 @@ defined( 'ABSPATH' ) || exit;
71
<# } #>
72
73
<# if ( data.isPro ) { #>
74
- <span class="premium-demo-banner"><?php _e( 'Pro', 'themegrill-demo-importer' ); ?></span>
75
<# } #>
76
77
- <span class="more-details"><?php _ex( 'Details &amp; Preview', 'demo', 'themegrill-demo-importer' ); ?></span>
78
<div class="theme-author">
79
<?php
80
/* translators: %s: Demo author name */
81
- printf( __( 'By %s', 'themegrill-demo-importer' ), '{{{ data.author }}}' );
82
?>
83
</div>
84
@@ -87,7 +86,7 @@ defined( 'ABSPATH' ) || exit;
87
<h2 class="theme-name" id="{{ data.id }}-name">
88
<?php
89
/* translators: %s: Demo name */
90
- printf( __( '<span>Imported:</span> %s', 'themegrill-demo-importer' ), '{{{ data.name }}}' );
91
?>
92
</h2>
93
<# } else { #>
@@ -96,46 +95,42 @@ defined( 'ABSPATH' ) || exit;
96
97
<div class="theme-actions">
98
<# if ( data.active ) { #>
99
- <a class="button button-primary live-preview" target="_blank" href="<?php echo home_url( '/' ); ?>"><?php _e( 'Live Preview', 'themegrill-demo-importer' ); ?></a>
100
<# } else { #>
101
<# if ( data.isPro ) { #>
102
- <a class="button button-primary purchase-now" href="{{ data.homepage }}" target="_blank"><?php _e( 'Buy Now', 'themegrill-demo-importer' ); ?></a>
103
- <# } else if ( data.requiredTheme || data.requiredPlugins ) { #>
104
- <button class="button button-primary preview install-demo-preview"><?php _e( 'Import', 'themegrill-demo-importer' ); ?></button>
105
<# } else { #>
106
<?php
107
/* translators: %s: Demo name */
108
- $aria_label = sprintf( _x( 'Import %s', 'demo', 'themegrill-demo-importer' ), '{{ data.name }}' );
109
?>
110
- <a class="button button-primary hide-if-no-js demo-import" href="#" data-name="{{ data.name }}" data-slug="{{ data.id }}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Import', 'themegrill-demo-importer' ); ?></a>
111
<# } #>
112
- <button class="button preview install-demo-preview"><?php _e( 'Preview', 'themegrill-demo-importer' ); ?></button>
113
<# } #>
114
</div>
115
</div>
116
117
<# if ( data.imported ) { #>
118
- <div class="notice notice-success notice-alt"><p><?php _ex( 'Imported', 'demo', 'themegrill-demo-importer' ); ?></p></div>
119
<# } #>
120
</script>
121
122
<script id="tmpl-demo-preview" type="text/template">
123
<div class="wp-full-overlay-sidebar">
124
<div class="wp-full-overlay-header">
125
- <button class="close-full-overlay"><span class="screen-reader-text"><?php _e( 'Close', 'themegrill-demo-importer' ); ?></span></button>
126
- <button class="previous-theme"><span class="screen-reader-text"><?php _ex( 'Previous', 'Button label for a demo', 'themegrill-demo-importer' ); ?></span></button>
127
- <button class="next-theme"><span class="screen-reader-text"><?php _ex( 'Next', 'Button label for a demo', 'themegrill-demo-importer' ); ?></span></button>
128
<# if ( data.isPro ) { #>
129
- <a class="button button-primary purchase-now" href="{{ data.homepage }}" target="_blank"><?php _e( 'Buy Now', 'themegrill-demo-importer' ); ?></a>
130
<# } else if ( data.requiredTheme ) { #>
131
- <button class="button button-primary hide-if-no-js disabled"><?php _e( 'Import Demo', 'themegrill-demo-importer' ); ?></button>
132
- <# } else if ( data.requiredPlugins ) { #>
133
- <button class="button button-secondary hide-if-no-js plugins-install"><?php _e( 'Install Plugins', 'themegrill-demo-importer' ); ?></button>
134
<# } else { #>
135
<# if ( data.active ) { #>
136
- <a class="button button-primary live-preview" target="_blank" href="<?php echo home_url( '/' ); ?>"><?php _e( 'Live Preview', 'themegrill-demo-importer' ); ?></a>
137
<# } else { #>
138
- <a class="button button-primary hide-if-no-js demo-import" href="#" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Import Demo', 'themegrill-demo-importer' ); ?></a>
139
<# } #>
140
<# } #>
141
</div>
@@ -144,38 +139,39 @@ defined( 'ABSPATH' ) || exit;
144
<h3 class="theme-name">
145
{{ data.name }}
146
<# if ( data.isPro ) { #>
147
- <span class="premium-demo-tag"><?php _e( 'Pro', 'themegrill-demo-importer' ); ?></span>
148
<# } #>
149
</h3>
150
151
<span class="theme-by">
152
<?php
153
/* translators: %s: Demo author name */
154
- printf( __( 'By %s', 'themegrill-demo-importer' ), '{{ data.author }}' );
155
?>
156
</span>
157
158
<img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" />
159
160
<div class="theme-details">
161
- <# if ( ! data.isPro ) { #>
162
- <# if ( data.requiredTheme ) { #>
163
- <div class="demo-message notice notice-error notice-alt"><p><?php printf( esc_html__( '%s theme is not active.', 'themegrill-demo-importer' ), '<strong>{{{ data.theme }}}</strong>' ); ?></p></div>
164
- <# } else if ( data.requiredPlugins ) { #>
165
- <div class="demo-message notice notice-info notice-alt"><p><?php esc_html_e( 'Required Plugins must be activated.', 'themegrill-demo-importer' ); ?></p></div>
166
- <# } #>
167
<# } #>
168
<div class="theme-version">
169
<?php
170
/* translators: %s: Demo version */
171
- printf( __( 'Version: %s', 'themegrill-demo-importer' ), '{{ data.version }}', 'themegrill-demo-importer' );
172
?>
173
</div>
174
<div class="theme-description">{{{ data.description }}}</div>
175
</div>
176
177
<div class="plugins-details">
178
- <h4 class="plugins-info"><?php _e( 'Plugins Information', 'themegrill-demo-importer' ); ?></h4>
179
180
<table class="plugins-list-table widefat striped">
181
<thead>
@@ -214,22 +210,20 @@ defined( 'ABSPATH' ) || exit;
214
<div class="wp-full-overlay-footer">
215
<div class="demo-import-actions">
216
<# if ( data.isPro ) { #>
217
- <a class="button button-hero button-primary purchase-now" href="{{ data.homepage }}" target="_blank"><?php _e( 'Buy Now', 'themegrill-demo-importer' ); ?></a>
218
<# } else if ( data.requiredTheme ) { #>
219
- <button class="button button-hero button-primary hide-if-no-js disabled"><?php _e( 'Import Demo', 'themegrill-demo-importer' ); ?></button>
220
- <# } else if ( data.requiredPlugins ) { #>
221
- <button class="button button-hero button-secondary hide-if-no-js plugins-install"><?php _e( 'Install Plugins', 'themegrill-demo-importer' ); ?></button>
222
<# } else { #>
223
<# if ( data.active ) { #>
224
- <a class="button button-primary live-preview button-hero hide-if-no-js" target="_blank" href="<?php echo home_url( '/' ); ?>"><?php _e( 'Live Preview', 'themegrill-demo-importer' ); ?></a>
225
<# } else { #>
226
- <a class="button button-hero button-primary hide-if-no-js demo-import" href="#" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Import Demo', 'themegrill-demo-importer' ); ?></a>
227
<# } #>
228
<# } #>
229
</div>
230
<button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar', 'themegrill-demo-importer' ); ?>">
231
<span class="collapse-sidebar-arrow"></span>
232
- <span class="collapse-sidebar-label"><?php _e( 'Collapse', 'themegrill-demo-importer' ); ?></span>
233
</button>
234
<div class="devices-wrapper">
235
<div class="devices">
18
<hr class="wp-header-end">
19
20
<div class="error hide-if-js">
21
+ <p><?php esc_html_e( 'The Demo Importer screen requires JavaScript.', 'themegrill-demo-importer' ); ?></p>
22
</div>
23
24
+ <h2 class="screen-reader-text hide-if-no-js"><?php esc_html_e( 'Filter demos list', 'themegrill-demo-importer' ); ?></h2>
25
26
<div class="wp-filter hide-if-no-js">
27
<div class="filter-section">
43
<?php foreach ( $this->demo_packages->pagebuilders as $slug => $label ) : ?>
44
<?php if ( 'default' !== $slug ) : ?>
45
<li><a href="#" data-type="<?php echo esc_attr( $slug ); ?>" class="pagebuilder-tab"><?php echo esc_html( $label ); ?></a></li>
46
+ <?php else : ?>
47
<li><a href="#" data-type="<?php echo esc_attr( $slug ); ?>" class="pagebuilder-tab tips" data-tip="<?php esc_attr_e( 'Without Page Builder', 'themegrill-demo-importer' ); ?>"><?php echo esc_html( $label ); ?></a></li>
48
<?php endif; ?>
49
<?php endforeach; ?>
53
<form class="search-form"></form>
54
</div>
55
</div>
56
+ <h2 class="screen-reader-text hide-if-no-js"><?php esc_html_e( 'Themes list', 'themegrill-demo-importer' ); ?></h2>
57
<div class="theme-browser content-filterable"></div>
58
<div class="theme-install-overlay wp-full-overlay expanded"></div>
59
60
+ <p class="no-themes"><?php esc_html_e( 'No demos found. Try a different search.', 'themegrill-demo-importer' ); ?></p>
61
<span class="spinner"></span>
62
</div>
63
71
<# } #>
72
73
<# if ( data.isPro ) { #>
74
+ <span class="premium-demo-banner"><?php esc_html_e( 'Pro', 'themegrill-demo-importer' ); ?></span>
75
<# } #>
76
77
<div class="theme-author">
78
<?php
79
/* translators: %s: Demo author name */
80
+ printf( esc_html__( 'By %s', 'themegrill-demo-importer' ), '{{{ data.author }}}' );
81
?>
82
</div>
83
86
<h2 class="theme-name" id="{{ data.id }}-name">
87
<?php
88
/* translators: %s: Demo name */
89
+ printf( __( '<span>Imported:</span> %s', 'themegrill-demo-importer' ), '{{{ data.name }}}' ); // @codingStandardsIgnoreLine
90
?>
91
</h2>
92
<# } else { #>
95
96
<div class="theme-actions">
97
<# if ( data.active ) { #>
98
+ <a class="button button-primary live-preview" target="_blank" href="<?php echo esc_url_raw( home_url( '/' ) ); ?>"><?php esc_html_e( 'Live Preview', 'themegrill-demo-importer' ); ?></a>
99
<# } else { #>
100
<# if ( data.isPro ) { #>
101
+ <a class="button button-primary purchase-now" href="{{ data.homepage }}" target="_blank"><?php esc_html_e( 'Buy Now', 'themegrill-demo-importer' ); ?></a>
102
<# } else { #>
103
<?php
104
/* translators: %s: Demo name */
105
+ $aria_label = sprintf( esc_html_x( 'Import %s', 'demo', 'themegrill-demo-importer' ), '{{ data.name }}' );
106
?>
107
+ <a class="button button-primary hide-if-no-js demo-import" href="#" data-name="{{ data.name }}" data-slug="{{ data.id }}" aria-label="<?php echo esc_attr( $aria_label ); ?>" data-plugins="{{ JSON.stringify( data.plugins ) }}"><?php esc_html_e( 'Import', 'themegrill-demo-importer' ); ?></a>
108
<# } #>
109
+ <button class="button preview install-demo-preview"><?php esc_html_e( 'Preview', 'themegrill-demo-importer' ); ?></button>
110
<# } #>
111
</div>
112
</div>
113
114
<# if ( data.imported ) { #>
115
+ <div class="notice notice-success notice-alt"><p><?php echo esc_html_x( 'Imported', 'demo', 'themegrill-demo-importer' ); ?></p></div>
116
<# } #>
117
</script>
118
119
<script id="tmpl-demo-preview" type="text/template">
120
<div class="wp-full-overlay-sidebar">
121
<div class="wp-full-overlay-header">
122
+ <button class="close-full-overlay"><span class="screen-reader-text"><?php esc_html_e( 'Close', 'themegrill-demo-importer' ); ?></span></button>
123
+ <button class="previous-theme"><span class="screen-reader-text"><?php echo esc_html_x( 'Previous', 'Button label for a demo', 'themegrill-demo-importer' ); ?></span></button>
124
+ <button class="next-theme"><span class="screen-reader-text"><?php echo esc_html_x( 'Next', 'Button label for a demo', 'themegrill-demo-importer' ); ?></span></button>
125
<# if ( data.isPro ) { #>
126
+ <a class="button button-primary purchase-now" href="{{ data.homepage }}" target="_blank"><?php esc_html_e( 'Buy Now', 'themegrill-demo-importer' ); ?></a>
127
<# } else if ( data.requiredTheme ) { #>
128
+ <button class="button button-primary hide-if-no-js disabled"><?php esc_html_e( 'Import Demo', 'themegrill-demo-importer' ); ?></button>
129
<# } else { #>
130
<# if ( data.active ) { #>
131
+ <a class="button button-primary live-preview" target="_blank" href="<?php echo esc_url_raw( home_url( '/' ) ); ?>"><?php esc_html_e( 'Live Preview', 'themegrill-demo-importer' ); ?></a>
132
<# } else { #>
133
+ <a class="button button-primary hide-if-no-js demo-import" href="#" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php esc_html_e( 'Import Demo', 'themegrill-demo-importer' ); ?></a>
134
<# } #>
135
<# } #>
136
</div>
139
<h3 class="theme-name">
140
{{ data.name }}
141
<# if ( data.isPro ) { #>
142
+ <span class="premium-demo-tag"><?php esc_html_e( 'Pro', 'themegrill-demo-importer' ); ?></span>
143
<# } #>
144
</h3>
145
146
<span class="theme-by">
147
<?php
148
/* translators: %s: Demo author name */
149
+ printf( esc_html__( 'By %s', 'themegrill-demo-importer' ), '{{ data.author }}' );
150
?>
151
</span>
152
153
<img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" />
154
155
<div class="theme-details">
156
+ <# if ( ! data.isPro && data.requiredTheme ) { #>
157
+ <div class="demo-message notice notice-error notice-alt"><p>
158
+ <?php
159
+ /* translators: %s: Theme Name */
160
+ printf( esc_html__( '%s theme is not active.', 'themegrill-demo-importer' ), '<strong>{{{ data.theme }}}</strong>' );
161
+ ?>
162
+ </p></div>
163
<# } #>
164
<div class="theme-version">
165
<?php
166
/* translators: %s: Demo version */
167
+ printf( esc_html__( 'Version: %s', 'themegrill-demo-importer' ), '{{ data.version }}', 'themegrill-demo-importer' );
168
?>
169
</div>
170
<div class="theme-description">{{{ data.description }}}</div>
171
</div>
172
173
<div class="plugins-details">
174
+ <h4 class="plugins-info"><?php esc_html_e( 'Plugins Information', 'themegrill-demo-importer' ); ?></h4>
175
176
<table class="plugins-list-table widefat striped">
177
<thead>
210
<div class="wp-full-overlay-footer">
211
<div class="demo-import-actions">
212
<# if ( data.isPro ) { #>
213
+ <a class="button button-hero button-primary purchase-now" href="{{ data.homepage }}" target="_blank"><?php esc_html_e( 'Buy Now', 'themegrill-demo-importer' ); ?></a>
214
<# } else if ( data.requiredTheme ) { #>
215
+ <button class="button button-hero button-primary hide-if-no-js disabled"><?php esc_html_e( 'Import Demo', 'themegrill-demo-importer' ); ?></button>
216
<# } else { #>
217
<# if ( data.active ) { #>
218
+ <a class="button button-primary live-preview button-hero hide-if-no-js" target="_blank" href="<?php echo esc_url_raw( home_url( '/' ) ); ?>"><?php esc_html_e( 'Live Preview', 'themegrill-demo-importer' ); ?></a>
219
<# } else { #>
220
+ <a class="button button-hero button-primary hide-if-no-js demo-import" href="#" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php esc_html_e( 'Import Demo', 'themegrill-demo-importer' ); ?></a>
221
<# } #>
222
<# } #>
223
</div>
224
<button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar', 'themegrill-demo-importer' ); ?>">
225
<span class="collapse-sidebar-arrow"></span>
226
+ <span class="collapse-sidebar-label"><?php esc_html_e( 'Collapse', 'themegrill-demo-importer' ); ?></span>
227
</button>
228
<div class="devices-wrapper">
229
<div class="devices">
includes/class-demo-importer.php CHANGED
@@ -2,7 +2,7 @@
2
/**
3
* ThemeGrill Demo Importer.
4
*
5
- * @package ThemeGrill_Demo_Importer/Classes
6
* @version 1.0.0
7
*/
8
@@ -166,47 +166,55 @@ class TG_Demo_Importer {
166
if ( 'appearance_page_demo-importer' === $screen_id ) {
167
wp_enqueue_style( 'tg-demo-importer' );
168
wp_enqueue_script( 'tg-demo-importer' );
169
- wp_localize_script( 'tg-demo-updates', '_demoUpdatesSettings', array(
170
- 'l10n' => array(
171
- 'importing' => __( 'Importing...', 'themegrill-demo-importer' ),
172
- 'demoImportingLabel' => _x( 'Importing %s...', 'demo', 'themegrill-demo-importer' ), // no ellipsis
173
- 'importingMsg' => __( 'Importing... please wait.', 'themegrill-demo-importer' ),
174
- 'importedMsg' => __( 'Import completed successfully.', 'themegrill-demo-importer' ),
175
- 'importFailedShort' => __( 'Import Failed!', 'themegrill-demo-importer' ),
176
- 'importFailed' => __( 'Import failed: %s', 'themegrill-demo-importer' ),
177
- 'demoImportedLabel' => _x( '%s imported!', 'demo', 'themegrill-demo-importer' ),
178
- 'demoImportFailedLabel' => _x( '%s import failed', 'demo', 'themegrill-demo-importer' ),
179
- 'livePreview' => __( 'Live Preview', 'themegrill-demo-importer' ),
180
- 'livePreviewLabel' => _x( 'Live Preview %s', 'demo', 'themegrill-demo-importer' ),
181
- 'imported' => __( 'Imported!', 'themegrill-demo-importer' ),
182
- 'statusTextLink' => '<a href="https://docs.themegrill.com/knowledgebase/demo-import-process-failed/" target="_blank">' . __( 'Try this solution!', 'themegrill-demo-importer' ) . '</a>',
183
- ),
184
- ) );
185
- wp_localize_script( 'tg-demo-importer', '_demoImporterSettings', array(
186
- 'demos' => $this->ajax_query_demos( true ),
187
- 'settings' => array(
188
- 'isNew' => false,
189
- 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
190
- 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ),
191
- 'suggestURI' => apply_filters( 'themegrill_demo_importer_suggest_new', 'https://themegrill.com/contact/' ),
192
- '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' ),
193
- 'confirmImport' => __( "Importing demo data will ensure that your site will look similar as theme demo. It makes you easy to modify the content instead of creating them from scratch. Also consider before importing theme demo: \n\n1. You need to import demo on fresh WordPress install to exactly replicate the theme demo. \n\n2. None of the posts, pages, attachments or any other data already existing in your site will be deleted or modified. \n\n3. Copyright images will get replaced with other placeholder images. \n\n4. It will take some time to import the theme demo.", 'themegrill-demo-importer' ),
194
- ),
195
- 'l10n' => array(
196
- 'search' => __( 'Search Demos', 'themegrill-demo-importer' ),
197
- 'searchPlaceholder' => __( 'Search demos...', 'themegrill-demo-importer' ), // placeholder (no ellipsis)
198
- /* translators: %s: support forums URL */
199
- 'error' => sprintf( __( 'An unexpected error occurred. Something may be wrong with ThemeGrill demo server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.', 'themegrill-demo-importer' ), 'https://wordpress.org/support/plugin/themegrill-demo-importer' ),
200
- 'tryAgain' => __( 'Try Again', 'themegrill-demo-importer' ),
201
- 'suggestNew' => __( 'Please suggest us!', 'themegrill-demo-importer' ),
202
- 'demosFound' => __( 'Number of Demos found: %d', 'themegrill-demo-importer' ),
203
- 'noDemosFound' => __( 'No demos found. Try a different search.', 'themegrill-demo-importer' ),
204
- 'collapseSidebar' => __( 'Collapse Sidebar', 'themegrill-demo-importer' ),
205
- 'expandSidebar' => __( 'Expand Sidebar', 'themegrill-demo-importer' ),
206
- /* translators: accessibility text */
207
- 'selectFeatureFilter' => __( 'Select one or more Demo features to filter by', 'themegrill-demo-importer' ),
208
- ),
209
- ) );
210
}
211
}
212
@@ -251,13 +259,14 @@ class TG_Demo_Importer {
251
return;
252
}
253
254
- $screen->add_help_tab( array(
255
- 'id' => 'themegrill_demo_importer_support_tab',
256
- 'title' => __( 'Help &amp; Support', 'themegrill-demo-importer' ),
257
- 'content' =>
258
- '<h2>' . __( 'Help &amp; Support', 'themegrill-demo-importer' ) . '</h2>' .
259
'<p>' . sprintf(
260
- __( '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' ),
261
'https://themegrill.com/docs/themegrill-demo-importer/'
262
) . '</p>' .
263
'<p>' . sprintf(
@@ -265,27 +274,32 @@ class TG_Demo_Importer {
265
'https://wordpress.org/support/plugin/themegrill-demo-importer',
266
'https://themegrill.com/support-forum/'
267
) . '</p>' .
268
- '<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>',
269
- ) );
270
-
271
- $screen->add_help_tab( array(
272
- 'id' => 'themegrill_demo_importer_bugs_tab',
273
- 'title' => __( 'Found a bug?', 'themegrill-demo-importer' ),
274
- 'content' =>
275
- '<h2>' . __( 'Found a bug?', 'themegrill-demo-importer' ) . '</h2>' .
276
- '<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>' .
277
- '<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>',
278
-
279
- ) );
280
-
281
- $screen->add_help_tab( array(
282
- 'id' => 'themegrill_demo_importer_reset_tab',
283
- 'title' => __( 'Reset wizard', 'themegrill-demo-importer' ),
284
- 'content' =>
285
- '<h2>' . __( 'Reset wizard', 'themegrill-demo-importer' ) . '</h2>' .
286
- '<p>' . __( 'If you need to reset the WordPress back to default again, please click on the button below.', 'themegrill-demo-importer' ) . '</p>' .
287
- '<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>',
288
- ) );
289
290
$screen->set_help_sidebar(
291
'<p><strong>' . __( 'For more information:', 'themegrill-demo-importer' ) . '</strong></p>' .
@@ -371,7 +385,14 @@ class TG_Demo_Importer {
371
$result = wp_install( $blogname, $user->user_login, $user->user_email, $blog_public );
372
373
// Updates the user password with a old one.
374
- $wpdb->update( $wpdb->users, array( 'user_pass' => $user->user_pass, 'user_activation_key' => '' ), array( 'ID' => $result['user_id'] ) );
375
376
// Set up the Password change nag.
377
$default_password_nag = get_user_option( 'default_password_nag', $result['user_id'] );
@@ -440,9 +461,12 @@ class TG_Demo_Importer {
440
}
441
442
if ( ! $return ) {
443
- $request = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array(
444
- 'browse' => 'all',
445
- ) );
446
} else {
447
$request = array(
448
'browse' => 'all',
@@ -511,14 +535,16 @@ class TG_Demo_Importer {
511
return $prepared_demos;
512
}
513
514
- wp_send_json_success( array(
515
- 'info' => array(
516
- 'page' => 1,
517
- 'pages' => 1,
518
- 'results' => count( $prepared_demos ),
519
- ),
520
- 'demos' => array_filter( $prepared_demos ),
521
- ) );
522
}
523
524
/**
@@ -532,11 +558,13 @@ class TG_Demo_Importer {
532
check_ajax_referer( 'updates' );
533
534
if ( empty( $_POST['slug'] ) ) {
535
- wp_send_json_error( array(
536
- 'slug' => '',
537
- 'errorCode' => 'no_demo_specified',
538
- 'errorMessage' => __( 'No demo specified.', 'themegrill-demo-importer' ),
539
- ) );
540
}
541
542
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
@@ -554,8 +582,8 @@ class TG_Demo_Importer {
554
wp_send_json_error( $status );
555
}
556
557
- include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
558
- include_once( dirname( __FILE__ ) . '/admin/class-demo-pack-upgrader.php' );
559
560
$skin = new WP_Ajax_Upgrader_Skin();
561
$upgrader = new TG_Demo_Pack_Upgrader( $skin );
@@ -607,7 +635,6 @@ class TG_Demo_Importer {
607
608
// Update imported demo ID.
609
update_option( 'themegrill_demo_importer_activated_id', $slug );
610
-
611
do_action( 'themegrill_ajax_demo_imported', $slug, $demo_data );
612
}
613
@@ -655,7 +682,7 @@ class TG_Demo_Importer {
655
656
// Import XML file demo content.
657
if ( is_file( $import_file ) ) {
658
- $wp_import = new TG_WXR_Importer();
659
$wp_import->fetch_attachments = true;
660
661
ob_start();
@@ -693,7 +720,7 @@ class TG_Demo_Importer {
693
if ( in_array( $option_value, array( 'posts', 'page' ) ) ) {
694
update_option( 'show_on_front', $option_value );
695
}
696
- break;
697
case 'page_on_front':
698
case 'page_for_posts':
699
$page = get_page_by_title( $option_value );
@@ -702,10 +729,10 @@ class TG_Demo_Importer {
702
update_option( $option_key, $page->ID );
703
update_option( 'show_on_front', 'page' );
704
}
705
- break;
706
default:
707
update_option( $option_key, sanitize_text_field( $option_value ) );
708
- break;
709
}
710
}
711
}
@@ -854,7 +881,7 @@ class TG_Demo_Importer {
854
}
855
}
856
}
857
- break;
858
case 'dropdown_categories':
859
foreach ( $dropdown_data as $taxonomy => $taxonomy_data ) {
860
if ( ! taxonomy_exists( $taxonomy ) ) {
@@ -873,7 +900,7 @@ class TG_Demo_Importer {
873
}
874
}
875
}
876
- break;
877
}
878
}
879
}
@@ -907,7 +934,7 @@ class TG_Demo_Importer {
907
}
908
}
909
}
910
- break;
911
case 'categories':
912
foreach ( $data_value as $taxonomy => $taxonomy_data ) {
913
if ( ! taxonomy_exists( $taxonomy ) ) {
@@ -924,7 +951,7 @@ class TG_Demo_Importer {
924
}
925
}
926
}
927
- break;
928
case 'nav_menu_locations':
929
$nav_menus = wp_get_nav_menus();
930
@@ -939,7 +966,7 @@ class TG_Demo_Importer {
939
}
940
}
941
}
942
- break;
943
}
944
}
945
}
@@ -960,7 +987,7 @@ class TG_Demo_Importer {
960
961
// Recursively update elementor data.
962
foreach ( $elementor_data as $element_id => $element_data ) {
963
- if ( ! empty( $element_data['elements' ] ) ) {
964
foreach ( $element_data['elements'] as $el_key => $el_data ) {
965
if ( ! empty( $el_data['elements'] ) ) {
966
foreach ( $el_data['elements'] as $el_child_key => $child_el_data ) {
@@ -1002,7 +1029,7 @@ class TG_Demo_Importer {
1002
}
1003
1004
// Update the elementor data.
1005
- $elementor_data[ $element_id ][ 'elements' ][ $el_key ]['elements'][ $el_child_key ]['settings']['categories_selected'] = $categories_selected;
1006
}
1007
}
1008
}
@@ -1075,10 +1102,10 @@ class TG_Demo_Importer {
1075
if ( 0 !== $attachment_id ) {
1076
$grid_instance['style'][ $style_key ] = $attachment_id;
1077
}
1078
- break;
1079
default:
1080
$grid_instance['style'][ $style_key ] = $style_value;
1081
- break;
1082
}
1083
}
1084
}
@@ -1088,13 +1115,13 @@ class TG_Demo_Importer {
1088
1089
// Update panel grids data.
1090
$panels_data['grids'][ $instance_id ] = $grid_instance;
1091
- }
1092
- break;
1093
1094
case 'widgets':
1095
foreach ( $panel_data as $instance_id => $widget_instance ) {
1096
if ( isset( $widget_instance['panels_data']['widgets'] ) ) {
1097
- $instance = $instance + 1;
1098
$child_panels_data = $widget_instance['panels_data'];
1099
$panels_data['widgets'][ $instance_id ]['panels_data'] = $this->siteorigin_recursive_update( $child_panels_data, $data_type, $data_value );
1100
$instance = $instance - 1;
@@ -1133,7 +1160,7 @@ class TG_Demo_Importer {
1133
}
1134
}
1135
}
1136
- break;
1137
case 'dropdown_categories':
1138
foreach ( $dropdown_data as $taxonomy => $taxonomy_data ) {
1139
if ( ! taxonomy_exists( $taxonomy ) ) {
@@ -1156,14 +1183,14 @@ class TG_Demo_Importer {
1156
}
1157
}
1158
}
1159
- break;
1160
}
1161
}
1162
}
1163
1164
$panels_data['widgets'][ $instance_id ] = $widget_instance;
1165
}
1166
- break;
1167
}
1168
}
1169
2
/**
3
* ThemeGrill Demo Importer.
4
*
5
+ * @package ThemeGrill_Demo_Importer\Classes
6
* @version 1.0.0
7
*/
8
166
if ( 'appearance_page_demo-importer' === $screen_id ) {
167
wp_enqueue_style( 'tg-demo-importer' );
168
wp_enqueue_script( 'tg-demo-importer' );
169
+ wp_localize_script(
170
+ 'tg-demo-updates',
171
+ '_demoUpdatesSettings',
172
+ array(
173
+ 'l10n' => array(
174
+ 'importing' => __( 'Importing...', 'themegrill-demo-importer' ),
175
+ 'demoImportingLabel' => _x( 'Importing %s...', 'demo', 'themegrill-demo-importer' ), // no ellipsis
176
+ 'importingMsg' => __( 'Importing... please wait.', 'themegrill-demo-importer' ),
177
+ 'importedMsg' => __( 'Import completed successfully.', 'themegrill-demo-importer' ),
178
+ 'importFailedShort' => __( 'Import Failed!', 'themegrill-demo-importer' ),
179
+ 'importFailed' => __( 'Import failed: %s', 'themegrill-demo-importer' ),
180
+ 'demoImportedLabel' => _x( '%s imported!', 'demo', 'themegrill-demo-importer' ),
181
+ 'demoImportFailedLabel' => _x( '%s import failed', 'demo', 'themegrill-demo-importer' ),
182
+ 'livePreview' => __( 'Live Preview', 'themegrill-demo-importer' ),
183
+ 'livePreviewLabel' => _x( 'Live Preview %s', 'demo', 'themegrill-demo-importer' ),
184
+ 'imported' => __( 'Imported!', 'themegrill-demo-importer' ),
185
+ 'statusTextLink' => '<a href="https://docs.themegrill.com/knowledgebase/demo-import-process-failed/" target="_blank">' . __( 'Try this solution!', 'themegrill-demo-importer' ) . '</a>',
186
+ ),
187
+ )
188
+ );
189
+ wp_localize_script(
190
+ 'tg-demo-importer',
191
+ '_demoImporterSettings',
192
+ array(
193
+ 'demos' => $this->ajax_query_demos( true ),
194
+ 'settings' => array(
195
+ 'isNew' => false,
196
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
197
+ 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ),
198
+ 'suggestURI' => apply_filters( 'themegrill_demo_importer_suggest_new', 'https://themegrill.com/contact/' ),
199
+ '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' ),
200
+ 'confirmImport' => __( "Importing demo data will ensure that your site will look similar as theme demo. It makes you easy to modify the content instead of creating them from scratch. Also consider before importing theme demo: \n\n1. It will install the required plugin as well as activate them for installing theme demo. \n\n2. You need to import demo on fresh WordPress install to exactly replicate the theme demo. \n\n3. None of the posts, pages, attachments or any other data already existing in your site will be deleted or modified. \n\n4. Copyright images will get replaced with other placeholder images. \n\n5. It will take some time to import the theme demo.", 'themegrill-demo-importer' ),
201
+ ),
202
+ 'l10n' => array(
203
+ 'search' => __( 'Search Demos', 'themegrill-demo-importer' ),
204
+ 'searchPlaceholder' => __( 'Search demos...', 'themegrill-demo-importer' ), // placeholder (no ellipsis)
205
+ /* translators: %s: support forums URL */
206
+ 'error' => sprintf( __( 'An unexpected error occurred. Something may be wrong with ThemeGrill demo server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.', 'themegrill-demo-importer' ), 'https://wordpress.org/support/plugin/themegrill-demo-importer' ),
207
+ 'tryAgain' => __( 'Try Again', 'themegrill-demo-importer' ),
208
+ 'suggestNew' => __( 'Please suggest us!', 'themegrill-demo-importer' ),
209
+ 'demosFound' => __( 'Number of Demos found: %d', 'themegrill-demo-importer' ),
210
+ 'noDemosFound' => __( 'No demos found. Try a different search.', 'themegrill-demo-importer' ),
211
+ 'collapseSidebar' => __( 'Collapse Sidebar', 'themegrill-demo-importer' ),
212
+ 'expandSidebar' => __( 'Expand Sidebar', 'themegrill-demo-importer' ),
213
+ /* translators: accessibility text */
214
+ 'selectFeatureFilter' => __( 'Select one or more Demo features to filter by', 'themegrill-demo-importer' ),
215
+ ),
216
+ )
217
+ );
218
}
219
}
220
259
return;
260
}
261
262
+ $screen->add_help_tab(
263
+ array(
264
+ 'id' => 'themegrill_demo_importer_support_tab',
265
+ 'title' => __( 'Help &amp; Support', 'themegrill-demo-importer' ),
266
+ 'content' =>
267
+ '<h2>' . __( 'Help &amp; Support', 'themegrill-demo-importer' ) . '</h2>' .
268
'<p>' . sprintf(
269
+ __( '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' ),
270
'https://themegrill.com/docs/themegrill-demo-importer/'
271
) . '</p>' .
272
'<p>' . sprintf(
274
'https://wordpress.org/support/plugin/themegrill-demo-importer',
275
'https://themegrill.com/support-forum/'
276
) . '</p>' .
277
+ '<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>',
278
+ )
279
+ );
280
+
281
+ $screen->add_help_tab(
282
+ array(
283
+ 'id' => 'themegrill_demo_importer_bugs_tab',
284
+ 'title' => __( 'Found a bug?', 'themegrill-demo-importer' ),
285
+ 'content' =>
286
+ '<h2>' . __( 'Found a bug?', 'themegrill-demo-importer' ) . '</h2>' .
287
+ '<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>' .
288
+ '<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>',
289
+
290
+ )
291
+ );
292
+
293
+ $screen->add_help_tab(
294
+ array(
295
+ 'id' => 'themegrill_demo_importer_reset_tab',
296
+ 'title' => __( 'Reset wizard', 'themegrill-demo-importer' ),
297
+ 'content' =>
298
+ '<h2>' . __( 'Reset wizard', 'themegrill-demo-importer' ) . '</h2>' .
299
+ '<p>' . __( 'If you need to reset the WordPress back to default again, please click on the button below.', 'themegrill-demo-importer' ) . '</p>' .
300
+ '<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>',
301
+ )
302
+ );
303
304
$screen->set_help_sidebar(
305
'<p><strong>' . __( 'For more information:', 'themegrill-demo-importer' ) . '</strong></p>' .
385
$result = wp_install( $blogname, $user->user_login, $user->user_email, $blog_public );
386
387
// Updates the user password with a old one.
388
+ $wpdb->update(
389
+ $wpdb->users,
390
+ array(
391
+ 'user_pass' => $user->user_pass,
392
+ 'user_activation_key' => '',
393
+ ),
394
+ array( 'ID' => $result['user_id'] )
395
+ );
396
397
// Set up the Password change nag.
398
$default_password_nag = get_user_option( 'default_password_nag', $result['user_id'] );
461
}
462
463
if ( ! $return ) {
464
+ $request = wp_parse_args(
465
+ wp_unslash( $_REQUEST['request'] ),
466
+ array(
467
+ 'browse' => 'all',
468
+ )
469
+ );
470
} else {
471
$request = array(
472
'browse' => 'all',
535
return $prepared_demos;
536
}
537
538
+ wp_send_json_success(
539
+ array(
540
+ 'info' => array(
541
+ 'page' => 1,
542
+ 'pages' => 1,
543
+ 'results' => count( $prepared_demos ),
544
+ ),
545
+ 'demos' => array_filter( $prepared_demos ),
546
+ )
547
+ );
548
}
549
550
/**
558
check_ajax_referer( 'updates' );
559
560
if ( empty( $_POST['slug'] ) ) {
561
+ wp_send_json_error(
562
+ array(
563
+ 'slug' => '',
564
+ 'errorCode' => 'no_demo_specified',
565
+ 'errorMessage' => __( 'No demo specified.', 'themegrill-demo-importer' ),
566
+ )
567
+ );
568
}
569
570
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
582
wp_send_json_error( $status );
583
}
584
585
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
586
+ include_once dirname( __FILE__ ) . '/admin/class-demo-pack-upgrader.php';
587
588
$skin = new WP_Ajax_Upgrader_Skin();
589
$upgrader = new TG_Demo_Pack_Upgrader( $skin );
635
636
// Update imported demo ID.
637
update_option( 'themegrill_demo_importer_activated_id', $slug );
638
do_action( 'themegrill_ajax_demo_imported', $slug, $demo_data );
639
}
640
682
683
// Import XML file demo content.
684
if ( is_file( $import_file ) ) {
685
+ $wp_import = new TG_WXR_Importer();
686
$wp_import->fetch_attachments = true;
687
688
ob_start();
720
if ( in_array( $option_value, array( 'posts', 'page' ) ) ) {
721
update_option( 'show_on_front', $option_value );
722
}
723
+ break;
724
case 'page_on_front':
725
case 'page_for_posts':
726
$page = get_page_by_title( $option_value );
729
update_option( $option_key, $page->ID );
730
update_option( 'show_on_front', 'page' );
731
}
732
+ break;
733
default:
734
update_option( $option_key, sanitize_text_field( $option_value ) );
735
+ break;
736
}
737
}
738
}
881
}
882
}
883
}
884
+ break;
885
case 'dropdown_categories':
886
foreach ( $dropdown_data as $taxonomy => $taxonomy_data ) {
887
if ( ! taxonomy_exists( $taxonomy ) ) {
900
}
901
}
902
}
903
+ break;
904
}
905
}
906
}
934
}
935
}
936
}
937
+ break;
938
case 'categories':
939
foreach ( $data_value as $taxonomy => $taxonomy_data ) {
940
if ( ! taxonomy_exists( $taxonomy ) ) {
951
}
952
}
953
}
954
+ break;
955
case 'nav_menu_locations':
956
$nav_menus = wp_get_nav_menus();
957
966
}
967
}
968
}
969
+ break;
970
}
971
}
972
}
987
988
// Recursively update elementor data.
989
foreach ( $elementor_data as $element_id => $element_data ) {
990
+ if ( ! empty( $element_data['elements'] ) ) {
991
foreach ( $element_data['elements'] as $el_key => $el_data ) {
992
if ( ! empty( $el_data['elements'] ) ) {
993
foreach ( $el_data['elements'] as $el_child_key => $child_el_data ) {
1029
}
1030
1031
// Update the elementor data.
1032
+ $elementor_data[ $element_id ]['elements'][ $el_key ]['elements'][ $el_child_key ]['settings']['categories_selected'] = $categories_selected;
1033
}
1034
}
1035
}
1102
if ( 0 !== $attachment_id ) {
1103
$grid_instance['style'][ $style_key ] = $attachment_id;
1104
}
1105
+ break;
1106
default:
1107
$grid_instance['style'][ $style_key ] = $style_value;
1108
+ break;
1109
}
1110
}
1111
}
1115
1116
// Update panel grids data.
1117
$panels_data['grids'][ $instance_id ] = $grid_instance;
1118
+ }
1119
+ break;
1120
1121
case 'widgets':
1122
foreach ( $panel_data as $instance_id => $widget_instance ) {
1123
if ( isset( $widget_instance['panels_data']['widgets'] ) ) {
1124
+ $instance = $instance + 1;
1125
$child_panels_data = $widget_instance['panels_data'];
1126
$panels_data['widgets'][ $instance_id ]['panels_data'] = $this->siteorigin_recursive_update( $child_panels_data, $data_type, $data_value );
1127
$instance = $instance - 1;
1160
}
1161
}
1162
}
1163
+ break;
1164
case 'dropdown_categories':
1165
foreach ( $dropdown_data as $taxonomy => $taxonomy_data ) {
1166
if ( ! taxonomy_exists( $taxonomy ) ) {
1183
}
1184
}
1185
}
1186
+ break;
1187
}
1188
}
1189
}
1190
1191
$panels_data['widgets'][ $instance_id ] = $widget_instance;
1192
}
1193
+ break;
1194
}
1195
}
1196
includes/class-themegrill-demo-importer.php CHANGED
@@ -20,7 +20,7 @@ final class ThemeGrill_Demo_Importer {
20
*
21
* @var string
22
*/
23
- public $version = '1.5.5';
24
25
/**
26
* Theme single instance of this class.
20
*
21
* @var string
22
*/
23
+ public $version = '1.5.6';
24
25
/**
26
* Theme single instance of this class.
includes/functions-demo-importer.php CHANGED
@@ -2,14 +2,14 @@
2
/**
3
* Demo Importer Functions.
4
*
5
- * @package ThemeGrill_Demo_Importer/Functions
6
* @version 1.0.0
7
*/
8
9
defined( 'ABSPATH' ) || exit;
10
11
// Include core functions (available in both admin and frontend).
12
- include_once TGDM_ABSPATH . 'includes/functions-demo-update.php';
13
14
/**
15
* Ajax handler for installing a required plugin.
@@ -24,11 +24,13 @@ function tg_ajax_install_required_plugin() {
24
check_ajax_referer( 'updates' );
25
26
if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) {
27
- wp_send_json_error( array(
28
- 'slug' => '',
29
- 'errorCode' => 'no_plugin_specified',
30
- 'errorMessage' => __( 'No plugin specified.', 'themegrill-demo-importer' ),
31
- ) );
32
}
33
34
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
@@ -43,8 +45,8 @@ function tg_ajax_install_required_plugin() {
43
wp_send_json_error( $status );
44
}
45
46
- include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
47
- include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
48
49
// Looks like a plugin is installed, but not active.
50
if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
@@ -65,12 +67,15 @@ function tg_ajax_install_required_plugin() {
65
}
66
}
67
68
- $api = plugins_api( 'plugin_information', array(
69
- 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
70
- 'fields' => array(
71
- 'sections' => false,
72
- ),
73
- ) );
74
75
if ( is_wp_error( $api ) ) {
76
$status['errorMessage'] = $api->get_error_message();
@@ -243,24 +248,27 @@ if ( class_exists( 'WooCommerce' ) ) {
243
function tg_set_wc_pages( $demo_id ) {
244
global $wpdb;
245
246
- $wc_pages = apply_filters( 'themegrill_wc_' . $demo_id . '_pages', array(
247
- 'shop' => array(
248
- 'name' => 'shop',
249
- 'title' => 'Shop',
250
- ),
251
- 'cart' => array(
252
- 'name' => 'cart',
253
- 'title' => 'Cart',
254
- ),
255
- 'checkout' => array(
256
- 'name' => 'checkout',
257
- 'title' => 'Checkout',
258
- ),
259
- 'myaccount' => array(
260
- 'name' => 'my-account',
261
- 'title' => 'My Account',
262
- ),
263
- ) );
264
265
// Set WC pages properly.
266
foreach ( $wc_pages as $key => $wc_page ) {
@@ -270,7 +278,7 @@ function tg_set_wc_pages( $demo_id ) {
270
271
if ( ! is_null( $page_ids ) ) {
272
$page_id = 0;
273
- $delete_ids = array();
274
275
// Retrieve page with greater id and delete others.
276
if ( sizeof( $page_ids ) > 1 ) {
@@ -297,7 +305,12 @@ function tg_set_wc_pages( $demo_id ) {
297
// Update WC page.
298
if ( $page_id > 0 ) {
299
update_option( 'woocommerce_' . $key . '_page_id', $page_id );
300
- wp_update_post( array( 'ID' => $page_id, 'post_name' => sanitize_title( $wc_page['name'] ) ) );
301
}
302
}
303
}
2
/**
3
* Demo Importer Functions.
4
*
5
+ * @package ThemeGrill_Demo_Importer\Functions
6
* @version 1.0.0
7
*/
8
9
defined( 'ABSPATH' ) || exit;
10
11
// Include core functions (available in both admin and frontend).
12
+ require_once TGDM_ABSPATH . 'includes/functions-demo-update.php';
13
14
/**
15
* Ajax handler for installing a required plugin.
24
check_ajax_referer( 'updates' );
25
26
if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) {
27
+ wp_send_json_error(
28
+ array(
29
+ 'slug' => '',
30
+ 'errorCode' => 'no_plugin_specified',
31
+ 'errorMessage' => __( 'No plugin specified.', 'themegrill-demo-importer' ),
32
+ )
33
+ );
34
}
35
36
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
45
wp_send_json_error( $status );
46
}
47
48
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
49
+ include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
50
51
// Looks like a plugin is installed, but not active.
52
if ( file_exists( WP_PLUGIN_DIR . '/' . $slug ) ) {
67
}
68
}
69
70
+ $api = plugins_api(
71
+ 'plugin_information',
72
+ array(
73
+ 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
74
+ 'fields' => array(
75
+ 'sections' => false,
76
+ ),
77
+ )
78
+ );
79
80
if ( is_wp_error( $api ) ) {
81
$status['errorMessage'] = $api->get_error_message();
248
function tg_set_wc_pages( $demo_id ) {
249
global $wpdb;
250
251
+ $wc_pages = apply_filters(
252
+ 'themegrill_wc_' . $demo_id . '_pages',
253
+ array(
254
+ 'shop' => array(
255
+ 'name' => 'shop',
256
+ 'title' => 'Shop',
257
+ ),
258
+ 'cart' => array(
259
+ 'name' => 'cart',
260
+ 'title' => 'Cart',
261
+ ),
262
+ 'checkout' => array(
263
+ 'name' => 'checkout',
264
+ 'title' => 'Checkout',
265
+ ),
266
+ 'myaccount' => array(
267
+ 'name' => 'my-account',
268
+ 'title' => 'My Account',
269
+ ),
270
+ )
271
+ );
272
273
// Set WC pages properly.
274
foreach ( $wc_pages as $key => $wc_page ) {
278
279
if ( ! is_null( $page_ids ) ) {
280
$page_id = 0;
281
+ $delete_ids = array();
282
283
// Retrieve page with greater id and delete others.
284
if ( sizeof( $page_ids ) > 1 ) {
305
// Update WC page.
306
if ( $page_id > 0 ) {
307
update_option( 'woocommerce_' . $key . '_page_id', $page_id );
308
+ wp_update_post(
309
+ array(
310
+ 'ID' => $page_id,
311
+ 'post_name' => sanitize_title( $wc_page['name'] ),
312
+ )
313
+ );
314
}
315
}
316
}
includes/functions-demo-update.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* Backward compatibility for demo importer configs and options.
6
*
7
- * @package ThemeGrill_Demo_Importer/Functions
8
* @version 1.1.0
9
*/
10
4
*
5
* Backward compatibility for demo importer configs and options.
6
*
7
+ * @package ThemeGrill_Demo_Importer\Functions
8
* @version 1.1.0
9
*/
10
includes/importers/class-customizer-importer.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* Code adapted from the "Customizer Export/Import" plugin.
6
*
7
- * @package ThemeGrill_Demo_Importer/Classes
8
* @version 1.0.0
9
*/
10
@@ -60,11 +60,15 @@ class TG_Customizer_Importer {
60
include_once dirname( __FILE__ ) . '/customize/class-oc-customize-demo-importer-setting.php';
61
62
foreach ( $data['options'] as $option_key => $option_value ) {
63
- $option = new OC_Customize_Demo_Importer_Setting( $wp_customize, $option_key, array(
64
- 'default' => '',
65
- 'type' => 'option',
66
- 'capability' => 'edit_theme_options',
67
- ) );
68
69
$option->import( $option_value );
70
}
@@ -141,7 +145,7 @@ class TG_Customizer_Importer {
141
if ( ! empty( $file ) ) {
142
// Set variables for storage, fix file filename for query strings.
143
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
144
- $file_array = array();
145
$file_array['name'] = basename( $matches[0] );
146
147
// Download file to temp location.
4
*
5
* Code adapted from the "Customizer Export/Import" plugin.
6
*
7
+ * @package ThemeGrill_Demo_Importer\Classes
8
* @version 1.0.0
9
*/
10
60
include_once dirname( __FILE__ ) . '/customize/class-oc-customize-demo-importer-setting.php';
61
62
foreach ( $data['options'] as $option_key => $option_value ) {
63
+ $option = new OC_Customize_Demo_Importer_Setting(
64
+ $wp_customize,
65
+ $option_key,
66
+ array(
67
+ 'default' => '',
68
+ 'type' => 'option',
69
+ 'capability' => 'edit_theme_options',
70
+ )
71
+ );
72
73
$option->import( $option_value );
74
}
145
if ( ! empty( $file ) ) {
146
// Set variables for storage, fix file filename for query strings.
147
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
148
+ $file_array = array();
149
$file_array['name'] = basename( $matches[0] );
150
151
// Download file to temp location.
includes/importers/class-widget-importer.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* Code adapted from the "Widget Importer & Exporter" plugin.
6
*
7
- * @package ThemeGrill_Demo_Importer/Classes
8
* @version 1.0.0
9
*/
10
@@ -31,7 +31,7 @@ class TG_Widget_Importer {
31
32
// Have valid data? If no data or could not decode.
33
if ( empty( $data ) || ! is_object( $data ) ) {
34
- return new WP_Error( 'themegrill_widget_import_data_error', __( 'Widget import data could not be read. Please try a different file.', 'themegrill-demo-importer' ) );
35
}
36
37
// Hook before import.
@@ -147,7 +147,7 @@ class TG_Widget_Importer {
147
// If key is 0, make it 1.
148
// When 0, an issue can occur where adding a widget causes data from other widget to load, and the widget doesn't stick (reload wipes it).
149
if ( '0' === strval( $new_instance_id_number ) ) {
150
- $new_instance_id_number = 1;
151
$single_widget_instances[ $new_instance_id_number ] = $single_widget_instances[0];
152
unset( $single_widget_instances[0] );
153
}
@@ -163,8 +163,8 @@ class TG_Widget_Importer {
163
update_option( 'widget_' . $id_base, $single_widget_instances );
164
165
// Assign widget instance to sidebar.
166
- $sidebars_widgets = get_option( 'sidebars_widgets' ); // Which sidebars have which widgets, get fresh every time.
167
- $new_instance_id = $id_base . '-' . $new_instance_id_number; // Use ID number from new widget instance.
168
$sidebars_widgets[ $use_sidebar_id ][] = $new_instance_id; // Add new instance to sidebar.
169
update_option( 'sidebars_widgets', $sidebars_widgets ); // Save the amended data.
170
4
*
5
* Code adapted from the "Widget Importer & Exporter" plugin.
6
*
7
+ * @package ThemeGrill_Demo_Importer\Classes
8
* @version 1.0.0
9
*/
10
31
32
// Have valid data? If no data or could not decode.
33
if ( empty( $data ) || ! is_object( $data ) ) {
34
+ return new WP_Error( 'themegrill_widget_import_data_error', __( 'Widget import data could not be read. Please try a different file.', 'themegrill-demo-importer' ) );
35
}
36
37
// Hook before import.
147
// If key is 0, make it 1.
148
// When 0, an issue can occur where adding a widget causes data from other widget to load, and the widget doesn't stick (reload wipes it).
149
if ( '0' === strval( $new_instance_id_number ) ) {
150
+ $new_instance_id_number = 1;
151
$single_widget_instances[ $new_instance_id_number ] = $single_widget_instances[0];
152
unset( $single_widget_instances[0] );
153
}
163
update_option( 'widget_' . $id_base, $single_widget_instances );
164
165
// Assign widget instance to sidebar.
166
+ $sidebars_widgets = get_option( 'sidebars_widgets' ); // Which sidebars have which widgets, get fresh every time.
167
+ $new_instance_id = $id_base . '-' . $new_instance_id_number; // Use ID number from new widget instance.
168
$sidebars_widgets[ $use_sidebar_id ][] = $new_instance_id; // Add new instance to sidebar.
169
update_option( 'sidebars_widgets', $sidebars_widgets ); // Save the amended data.
170
includes/importers/customize/class-oc-customize-demo-importer-setting.php CHANGED
@@ -2,18 +2,20 @@
2
/**
3
* Customize API: OC_Customize_Demo_Importer_Setting class
4
*
5
- * @package ThemeGrill_Demo_Importer/Classes
6
* @version 1.0.0
7
*/
8
9
/**
10
* Customizer Demo Importer Setting class.
11
* @see WP_Customize_Setting
12
*/
13
final class OC_Customize_Demo_Importer_Setting extends WP_Customize_Setting {
14
15
/**
16
* Import an option value for this setting.
17
* @param mixed $value The value to update.
18
*/
19
public function import( $value ) {
2
/**
3
* Customize API: OC_Customize_Demo_Importer_Setting class
4
*
5
+ * @package ThemeGrill_Demo_Importer\Classes
6
* @version 1.0.0
7
*/
8
9
/**
10
* Customizer Demo Importer Setting class.
11
+ *
12
* @see WP_Customize_Setting
13
*/
14
final class OC_Customize_Demo_Importer_Setting extends WP_Customize_Setting {
15
16
/**
17
* Import an option value for this setting.
18
+ *
19
* @param mixed $value The value to update.
20
*/
21
public function import( $value ) {
includes/importers/wordpress-importer/class-wxr-importer.php CHANGED
@@ -5,7 +5,7 @@
5
* Code adapted from the "WordPress Importer" plugin.
6