Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/image-op.../classes
File: utils.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace ImageOptimization\Classes;
[2] Fix | Delete
[3] Fix | Delete
use ImageOptimization\Classes\Client\Client;
[4] Fix | Delete
use ImageOptimization\Plugin;
[5] Fix | Delete
[6] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[7] Fix | Delete
exit; // Exit if accessed directly.
[8] Fix | Delete
}
[9] Fix | Delete
[10] Fix | Delete
class Utils {
[11] Fix | Delete
/**
[12] Fix | Delete
* get_elementor
[13] Fix | Delete
* @param $instance
[14] Fix | Delete
*
[15] Fix | Delete
* @return \Elementor\Plugin|false|mixed|null
[16] Fix | Delete
*/
[17] Fix | Delete
public static function get_elementor( $instance = false ) {
[18] Fix | Delete
static $_instance = null;
[19] Fix | Delete
if ( false !== $instance ) {
[20] Fix | Delete
$_instance = $instance;
[21] Fix | Delete
[22] Fix | Delete
return $instance;
[23] Fix | Delete
}
[24] Fix | Delete
if ( null !== $_instance ) {
[25] Fix | Delete
return $_instance;
[26] Fix | Delete
}
[27] Fix | Delete
if ( class_exists( 'Elementor\Plugin' ) ) {
[28] Fix | Delete
return \Elementor\Plugin::instance(); // @codeCoverageIgnore
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
return false;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
public static function get_api_client(): ?Client {
[35] Fix | Delete
return Client::get_instance();
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
public static function get_module( $module_name = '' ) {
[39] Fix | Delete
return Plugin::instance()->modules_manager->get_modules( $module_name );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
public static function get_module_component( $module_name, $component ) {
[43] Fix | Delete
$module = self::get_module( $module_name );
[44] Fix | Delete
if ( $module ) {
[45] Fix | Delete
return $module->get_component( $component );
[46] Fix | Delete
}
[47] Fix | Delete
return null;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* is_elementor_installed
[52] Fix | Delete
* @return bool
[53] Fix | Delete
*/
[54] Fix | Delete
public static function is_elementor_installed(): bool {
[55] Fix | Delete
$plugins = get_plugins();
[56] Fix | Delete
return isset( $plugins['elementor/elementor.php'] );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* is_elementor_installed_and_active
[61] Fix | Delete
* should be used only after `plugins_loaded` action
[62] Fix | Delete
* @return bool
[63] Fix | Delete
*/
[64] Fix | Delete
public static function is_elementor_installed_and_active(): bool {
[65] Fix | Delete
return did_action( 'elementor/loaded' );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
public static function is_media_page(): bool {
[69] Fix | Delete
$current_screen = get_current_screen();
[70] Fix | Delete
[71] Fix | Delete
if ( ! $current_screen ) {
[72] Fix | Delete
return false;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
return 'upload' === $current_screen->id && 'attachment' === $current_screen->post_type;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
public static function is_media_upload_page(): bool {
[79] Fix | Delete
$current_screen = get_current_screen();
[80] Fix | Delete
[81] Fix | Delete
if ( ! $current_screen ) {
[82] Fix | Delete
return false;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
return 'media' === $current_screen->id && 'add' === $current_screen->action;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
public static function is_single_attachment_page(): bool {
[89] Fix | Delete
$current_screen = get_current_screen();
[90] Fix | Delete
[91] Fix | Delete
if ( ! $current_screen ) {
[92] Fix | Delete
return false;
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
return 'attachment' === $current_screen->id && 'post' === $current_screen->base;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
public static function is_plugin_page(): bool {
[99] Fix | Delete
$current_screen = get_current_screen();
[100] Fix | Delete
[101] Fix | Delete
return str_contains( $current_screen->id, 'image-optimization-' );
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
public static function is_plugin_settings_page(): bool {
[105] Fix | Delete
$current_screen = get_current_screen();
[106] Fix | Delete
[107] Fix | Delete
return str_contains( $current_screen->id, 'image-optimization-settings' );
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
public static function is_bulk_optimization_page(): bool {
[111] Fix | Delete
$current_screen = get_current_screen();
[112] Fix | Delete
[113] Fix | Delete
return str_contains( $current_screen->id, 'image-optimization-bulk-optimization' );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
public static function user_is_admin(): bool {
[117] Fix | Delete
return current_user_can( 'manage_options' );
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
public static function is_wp_dashboard_page(): bool {
[121] Fix | Delete
$current_screen = get_current_screen();
[122] Fix | Delete
[123] Fix | Delete
return str_contains( $current_screen->id, 'dashboard' );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
public static function is_wp_updates_page(): bool {
[127] Fix | Delete
$current_screen = get_current_screen();
[128] Fix | Delete
[129] Fix | Delete
return str_contains( $current_screen->id, 'update' );
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function