| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Image optimization service by Optimole |
| 4 |
* Description: Complete handling of your website images. |
| 5 |
* Version: 2.2.8 |
| 6 |
* Author: Optimole |
| 7 |
* Author URI: https://optimole.com |
| 8 |
* License: GPL-2.0+ |
| 9 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 10 |
* Text Domain: optimole-wp |
| 11 |
* Domain Path: /languages |
| 12 |
* WordPress Available: yes |
| 13 |
* Requires License: no |
| 14 |
*/ |
| 15 |
|
| 16 |
if ( ! defined( 'WPINC' ) ) { |
| 17 |
die; |
| 18 |
} |
| 19 |
/** |
| 20 |
* Autoloader function. |
| 21 |
* |
| 22 |
* @param string $class Class to load. |
| 23 |
*/ |
| 24 |
function optml_autoload( $class ) { |
| 25 |
$prefix = 'Optml'; |
| 26 |
if ( strpos( $class, $prefix ) !== 0 ) { |
| 27 |
return; |
| 28 |
} |
| 29 |
foreach ( array( '/inc/', '/inc/traits/', '/inc/image_properties/', '/inc/compatibilities/', '/inc/conflicts/', '/inc/cli/' ) as $folder ) { |
| 30 |
$file = str_replace( $prefix . '_', '', $class ); |
| 31 |
$file = strtolower( $file ); |
| 32 |
$file = dirname( __FILE__ ) . $folder . $file . '.php'; |
| 33 |
if ( file_exists( $file ) ) { |
| 34 |
require $file; |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Deactivates optimole plugin. |
| 41 |
* |
| 42 |
* Used when the user does not have the minimum PHP required version. |
| 43 |
* |
| 44 |
* @since 8.1.4 |
| 45 |
*/ |
| 46 |
function optml_deactivate() { |
| 47 |
if ( is_plugin_active( 'optimole-wp/optimole-wp.php' ) ) { |
| 48 |
deactivate_plugins( 'optimole-wp/optimole-wp.php' ); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Shows a notice for sites running PHP less than 5.4. |
| 54 |
*/ |
| 55 |
function optml_php_notice() { |
| 56 |
?> |
| 57 |
<div class="notice notice-error is-dismissible"> |
| 58 |
<?php echo sprintf( __( '%1$s You\'re using a PHP version lower than 5.4! %2$sOptimole%3$s requires at least %4$sPHP 5.4%5$s to function properly. Plugin has been deactivated. %6$sLearn more here%5$s. %7$s', 'optimole-wp' ), '<p>', '<b>', '</b>', '<b>', '</b>', '<a href="https://themeisle.com/blog/upgrade-wordpress-to-php-7/" target="_blank">', '</a>', '</p>' ); ?> |
| 59 |
</div> |
| 60 |
<?php |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Initiate the Optimole plugin. |
| 65 |
* |
| 66 |
* @return Optml_Main Optimole instance. |
| 67 |
*/ |
| 68 |
function optml() { |
| 69 |
if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) { |
| 70 |
add_action( 'admin_notices', 'optml_php_notice' ); |
| 71 |
add_action( 'admin_init', 'optml_deactivate' ); |
| 72 |
|
| 73 |
return null; |
| 74 |
} |
| 75 |
define( 'OPTML_URL', plugin_dir_url( __FILE__ ) ); |
| 76 |
define( 'OPTML_JS_CDN', 'd5jmkjjpb7yfg.cloudfront.net' ); |
| 77 |
define( 'OPTML_PATH', plugin_dir_path( __FILE__ ) ); |
| 78 |
define( 'OPTML_VERSION', '2.2.8' ); |
| 79 |
define( 'OPTML_NAMESPACE', 'optml' ); |
| 80 |
define( 'OPTML_BASEFILE', __FILE__ ); |
| 81 |
// Fallback for old PHP versions when this constant is not defined. |
| 82 |
if ( ! defined( 'PHP_INT_MIN' ) ) { |
| 83 |
define( 'PHP_INT_MIN', - 999999 ); |
| 84 |
} |
| 85 |
|
| 86 |
if ( ! defined( 'OPTML_DEBUG' ) ) { |
| 87 |
define( 'OPTML_DEBUG', ( defined( 'TEST_GROUND' ) && TEST_GROUND ) ? true : false ); |
| 88 |
} |
| 89 |
|
| 90 |
return Optml_Main::instance(); |
| 91 |
} |
| 92 |
|
| 93 |
spl_autoload_register( 'optml_autoload' ); |
| 94 |
|
| 95 |
optml(); |
| 96 |
|