| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 3 |
|
| 4 |
if ( defined( 'RML_FILE' ) ) : |
| 5 |
|
| 6 |
/** |
| 7 |
* Prevent WP Real Media Library to use its outdated version of SweetAlert where we need ours, and to mess with our CSS styles. |
| 8 |
*/ |
| 9 |
add_action( 'current_screen', 'imagify_wprml_init' ); |
| 10 |
/** |
| 11 |
* Dequeue all WP Real Media Library's styles and scripts where we use ours. |
| 12 |
* |
| 13 |
* @since 1.6.13 |
| 14 |
* @author Grégory Viguier |
| 15 |
*/ |
| 16 |
function imagify_wprml_init() { |
| 17 |
static $done = false; |
| 18 |
|
| 19 |
if ( $done ) { |
| 20 |
return; |
| 21 |
} |
| 22 |
$done = true; |
| 23 |
|
| 24 |
if ( ! class_exists( '\\MatthiasWeb\\RealMediaLibrary\\general\\Backend' ) ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
$notices = Imagify_Notices::get_instance(); |
| 29 |
|
| 30 |
if ( $notices->has_notices() && ( $notices->display_welcome_steps() || $notices->display_wrong_api_key() ) ) { |
| 31 |
// We display a notice that uses SweetAlert. |
| 32 |
imagify_wprml_dequeue(); |
| 33 |
return; |
| 34 |
} |
| 35 |
|
| 36 |
if ( imagify_is_screen( 'bulk' ) || imagify_is_screen( 'imagify-settings' ) ) { |
| 37 |
// We display a page that uses SweetAlert. |
| 38 |
imagify_wprml_dequeue(); |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
if ( function_exists( 'imagify_get_ngg_bulk_screen_id' ) && imagify_is_screen( imagify_get_ngg_bulk_screen_id() ) ) { |
| 43 |
// We display the NGG Bulk Optimization page. |
| 44 |
imagify_wprml_dequeue(); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Prevent WP Real Media Library to enqueue its styles and scripts. |
| 50 |
* |
| 51 |
* @since 1.6.13 |
| 52 |
* @author Grégory Viguier |
| 53 |
*/ |
| 54 |
function imagify_wprml_dequeue() { |
| 55 |
$instance = \MatthiasWeb\RealMediaLibrary\general\Backend::getInstance(); |
| 56 |
|
| 57 |
remove_action( 'admin_enqueue_scripts', [ $instance, 'admin_enqueue_scripts' ], 0 ); |
| 58 |
remove_action( 'admin_footer', [ $instance, 'admin_footer' ] ); |
| 59 |
|
| 60 |
if ( class_exists( '\\MatthiasWeb\\RealMediaLibrary\\general\\FolderShortcode' ) ) { |
| 61 |
$instance = \MatthiasWeb\RealMediaLibrary\general\FolderShortcode::getInstance(); |
| 62 |
|
| 63 |
remove_action( 'admin_head', [ $instance, 'admin_head' ] ); |
| 64 |
remove_action( 'admin_enqueue_scripts', [ $instance, 'admin_enqueue_scripts' ] ); |
| 65 |
} |
| 66 |
|
| 67 |
if ( class_exists( '\\MatthiasWeb\\RealMediaLibrary\\comp\\PageBuilders' ) ) { |
| 68 |
$instance = \MatthiasWeb\RealMediaLibrary\comp\PageBuilders::getInstance(); |
| 69 |
|
| 70 |
remove_action( 'init', [ $instance, 'init' ] ); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
endif; |
| 75 |
|