Merge pull request #776 from mailpoet/js_conflict

Load MailPoet assets only on Widgets admin page [MAILPOET-740]
This commit is contained in:
mrcasual
2017-01-09 15:38:52 -05:00
committed by GitHub
3 changed files with 17 additions and 26 deletions

View File

@ -1,10 +1,8 @@
define('i18n', define('i18n',
[ [
'mailpoet', 'mailpoet'
'underscore',
], function( ], function(
MailPoet, MailPoet
_
) { ) {
'use strict'; 'use strict';

View File

@ -1,12 +1,11 @@
define([ define([
'backbone', 'backbone',
'backbone.marionette', 'backbone.marionette',
'backbone.supermodel',
'jquery', 'jquery',
'underscore', 'underscore',
'handlebars', 'handlebars',
'handlebars_helpers' 'handlebars_helpers'
], function(Backbone, Marionette, SuperModel, jQuery, _, Handlebars) { ], function(Backbone, Marionette, jQuery, _, Handlebars) {
var app = new Marionette.Application(), AppView; var app = new Marionette.Application(), AppView;

View File

@ -21,7 +21,7 @@ class Widget {
$this->setupDependencies(); $this->setupDependencies();
$this->setupIframe(); $this->setupIframe();
} else { } else {
$this->setupAdminDependencies(); add_action('widgets_admin_page', array($this, 'setupAdminWidgetPageDependencies'));
} }
} }
@ -110,12 +110,7 @@ class Widget {
)); ));
} }
function setupAdminDependencies() { function setupAdminWidgetPageDependencies() {
if(
empty($_GET['page'])
or
isset($_GET['page']) && strpos($_GET['page'], 'mailpoet') === false
) {
wp_enqueue_script('mailpoet_vendor', wp_enqueue_script('mailpoet_vendor',
Env::$assets_url.'/js/vendor.js', Env::$assets_url.'/js/vendor.js',
array(), array(),
@ -130,7 +125,6 @@ class Widget {
true true
); );
} }
}
// TODO: extract this method into an Initializer // TODO: extract this method into an Initializer
// - the "ajax" part might probably be useless // - the "ajax" part might probably be useless