Unload WP editor loaded by another plugin

[MAILPOET-2105]
This commit is contained in:
Jan Jakeš
2019-05-27 14:10:39 +02:00
committed by M. Shull
parent c6f5eb943c
commit c1e686831c

View File

@ -51,6 +51,13 @@ class ConflictResolver {
'resolveScriptsConflict',
]
);
WPFunctions::get()->addAction(
'mailpoet_conflict_resolver_scripts',
[
$this,
'resolveEditorConflict',
]
);
}
function resolveRouterUrlQueryParametersConflict() {
@ -117,4 +124,30 @@ class ConflictResolver {
WPFunctions::get()->addAction('admin_print_scripts', $dequeue_scripts, $execute_first);
WPFunctions::get()->addAction('admin_print_footer_scripts', $dequeue_scripts, $execute_first);
}
function resolveEditorConflict() {
// mark editor as already enqueued to prevent loading its assets
// when wp_enqueue_editor() used by some other plugin
global $wp_actions;
$wp_actions['wp_enqueue_editor'] = 1;
// prevent editor loading when used wp_editor() used by some other plugin
WPFunctions::get()->addFilter('wp_editor_settings', function () {
ob_start();
return [
'tinymce' => false,
'quicktags' => false,
];
});
WPFunctions::get()->addFilter('the_editor', function () {
return '';
});
WPFunctions::get()->addFilter('the_editor_content', function () {
ob_end_clean();
return '';
});
}
}