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