| Server IP : 213.136.93.164 / Your IP : 216.73.216.20 Web Server : Apache System : Linux m14200.contabo.net 5.14.0-611.54.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 6 18:03:03 EDT 2026 x86_64 User : ki692510 ( 1047) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/ki692510/www/wp-content/plugins/image-optimization/classes/ |
Upload File : |
<?php
namespace ImageOptimization\Classes;
use ImageOptimization\Classes\Client\Client;
use ImageOptimization\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Utils {
/**
* get_elementor
* @param $instance
*
* @return \Elementor\Plugin|false|mixed|null
*/
public static function get_elementor( $instance = false ) {
static $_instance = null;
if ( false !== $instance ) {
$_instance = $instance;
return $instance;
}
if ( null !== $_instance ) {
return $_instance;
}
if ( class_exists( 'Elementor\Plugin' ) ) {
return \Elementor\Plugin::instance(); // @codeCoverageIgnore
}
return false;
}
public static function get_api_client(): ?Client {
return Client::get_instance();
}
public static function get_module( $module_name = '' ) {
return Plugin::instance()->modules_manager->get_modules( $module_name );
}
public static function get_module_component( $module_name, $component ) {
$module = self::get_module( $module_name );
if ( $module ) {
return $module->get_component( $component );
}
return null;
}
/**
* is_elementor_installed
* @return bool
*/
public static function is_elementor_installed(): bool {
$plugins = get_plugins();
return isset( $plugins['elementor/elementor.php'] );
}
/**
* is_elementor_installed_and_active
* should be used only after `plugins_loaded` action
* @return bool
*/
public static function is_elementor_installed_and_active(): bool {
return did_action( 'elementor/loaded' );
}
public static function is_media_page(): bool {
$current_screen = get_current_screen();
if ( ! $current_screen ) {
return false;
}
return 'upload' === $current_screen->id && 'attachment' === $current_screen->post_type;
}
public static function is_single_attachment_page(): bool {
$current_screen = get_current_screen();
if ( ! $current_screen ) {
return false;
}
return 'attachment' === $current_screen->id && 'post' === $current_screen->base;
}
public static function is_plugin_page(): bool {
$current_screen = get_current_screen();
return str_contains( $current_screen->id, 'image-optimization-' );
}
public static function is_plugin_settings_page(): bool {
$current_screen = get_current_screen();
return str_contains( $current_screen->id, 'image-optimization-settings' );
}
public static function is_bulk_optimization_page(): bool {
$current_screen = get_current_screen();
return str_contains( $current_screen->id, 'image-optimization-bulk-optimization' );
}
public static function user_is_admin(): bool {
return current_user_can( 'manage_options' );
}
}