PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
← All changes | imagify.php +135 -84 1.3.5.1 → trunk View file →
@@ -1,97 +1,148 @@
1 1 <?php
2 -/*
3 -Plugin Name: Imagify
4 -Plugin URI: https://wordpress.org/plugins/imagify/
5 -Description: Dramaticaly reduce image file sizes without loosing quality, make your website load faster, boost your SEO and save money on your bandwith using Imagify, the new most advanced image optimization tool.
6 -Version: 1.3.5.1
7 -Author: WP Media
8 -Author URI: http://wp-media.me
9 -Licence: GPLv2
2 +/**
3 + * Plugin Name: Imagify
4 + * Plugin URI: https://wordpress.org/plugins/imagify/
5 + * Description: Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth using Imagify, the new most advanced image optimization tool.
6 + * Version: 2.3.4
7 + * Requires at least: 5.3
8 + * Requires PHP: 7.4
9 + * Author: Imagify Image Optimizer – Optimize Images & Convert WebP & Avif
10 + * Author URI: https://imagify.io
11 + * Licence: GPLv2
12 + *
13 + * Text Domain: imagify
14 + * Domain Path: languages
15 + *
16 + * Copyright 2024 WP Media
17 + */
10 18
11 -Text Domain: imagify
12 -Domain Path: languages
19 +defined( 'ABSPATH' ) || exit;
13 20
14 -Copyright 2015 WP Media
15 -*/
21 +// Imagify defines.
22 +define( 'IMAGIFY_VERSION', '2.3.4' );
23 +define( 'IMAGIFY_SLUG', 'imagify' );
24 +define( 'IMAGIFY_FILE', __FILE__ );
25 +define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
26 +define( 'IMAGIFY_URL', plugin_dir_url( IMAGIFY_FILE ) );
27 +define( 'IMAGIFY_ASSETS_IMG_URL', IMAGIFY_URL . 'assets/images/' );
28 +define( 'IMAGIFY_MAX_BYTES', 5242880 );
29 +define( 'IMAGIFY_INT_MAX', PHP_INT_MAX - 30 );
30 +if ( ! defined( 'IMAGIFY_SITE_DOMAIN' ) ) {
31 + define( 'IMAGIFY_SITE_DOMAIN', 'https://imagify.io' );
32 +}
33 +if ( ! defined( 'IMAGIFY_APP_DOMAIN' ) ) {
34 + define( 'IMAGIFY_APP_DOMAIN', 'https://app.imagify.io' );
35 +}
36 +define( 'IMAGIFY_APP_API_URL', IMAGIFY_APP_DOMAIN . '/api/' );
16 37
17 -defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
18 38
19 -// Imagify defines
20 -define( 'IMAGIFY_VERSION' , '1.3.5.1' );
21 -define( 'IMAGIFY_SLUG' , 'imagify' );
22 -define( 'IMAGIFY_SETTINGS_SLUG' , IMAGIFY_SLUG . '_settings' );
23 -define( 'IMAGIFY_WEB_MAIN' , 'https://imagify.io' );
24 -define( 'IMAGIFY_APP_MAIN' , 'https://app.imagify.io' );
25 -define( 'IMAGIFY_FILE' , __FILE__ );
26 -define( 'IMAGIFY_PATH' , realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
27 -define( 'IMAGIFY_INC_PATH' , realpath( IMAGIFY_PATH . 'inc/' ) . '/' );
28 -define( 'IMAGIFY_API_PATH' , realpath( IMAGIFY_INC_PATH . 'api/' ) . '/' );
29 -define( 'IMAGIFY_ADMIN_PATH' , realpath( IMAGIFY_INC_PATH . 'admin' ) . '/' );
30 -define( 'IMAGIFY_ADMIN_UI_PATH' , realpath( IMAGIFY_ADMIN_PATH . 'ui' ) . '/' );
31 -define( 'IMAGIFY_COMMON_PATH' , realpath( IMAGIFY_INC_PATH . 'common' ) . '/' );
32 -define( 'IMAGIFY_FUNCTIONS_PATH' , realpath( IMAGIFY_INC_PATH . 'functions' ) . '/' );
33 -define( 'IMAGIFY_CLASSES_PATH' , realpath( IMAGIFY_INC_PATH . 'classes' ) . '/' );
34 -define( 'IMAGIFY_3RD_PARTY_PATH' , realpath( IMAGIFY_INC_PATH . '3rd-party' ) . '/' );
35 -define( 'IMAGIFY_URL' , plugin_dir_url( IMAGIFY_FILE ) );
36 -define( 'IMAGIFY_INC_URL' , IMAGIFY_URL . 'inc/' );
37 -define( 'IMAGIFY_ADMIN_URL' , IMAGIFY_INC_URL . 'admin/' );
38 -define( 'IMAGIFY_ASSETS_URL' , IMAGIFY_URL . 'assets/' );
39 -define( 'IMAGIFY_ASSETS_JS_URL' , IMAGIFY_ASSETS_URL . 'js/' );
40 -define( 'IMAGIFY_ASSETS_CSS_URL' , IMAGIFY_ASSETS_URL . 'css/' );
41 -define( 'IMAGIFY_ASSETS_IMG_URL' , IMAGIFY_ASSETS_URL . 'images/' );
42 -define( 'IMAGIFY_MAX_BYTES' , 5242880 );
39 +// Check for WordPress and PHP version.
40 +if ( imagify_pass_requirements() ) {
41 + require_once IMAGIFY_PATH . 'inc/main.php';
42 +}
43 43
44 -/*
45 - * Tell WP what to do when plugin is loaded
44 +/**
45 + * Check if Imagify is activated on the network.
46 46 *
47 47 * @since 1.0
48 + *
49 + * return bool True if Imagify is activated on the network.
48 50 */
49 -add_action( 'plugins_loaded', '_imagify_init' );
50 -function _imagify_init() {
51 - // Load translations
52 - load_plugin_textdomain( 'imagify', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
51 +function imagify_is_active_for_network() {
52 + static $is;
53 53
54 - // Nothing to do if autosave
55 - if ( defined( 'DOING_AUTOSAVE' ) ) {
56 - return;
57 - }
54 + if ( isset( $is ) ) {
55 + return $is;
56 + }
58 57
59 - require( IMAGIFY_INC_PATH . 'compat.php' );
60 - require( IMAGIFY_FUNCTIONS_PATH . 'options.php' );
61 - require( IMAGIFY_API_PATH . 'imagify.php' );
62 - require( IMAGIFY_FUNCTIONS_PATH . 'formatting.php' );
63 - require( IMAGIFY_FUNCTIONS_PATH . 'files.php' );
64 - require( IMAGIFY_FUNCTIONS_PATH . 'admin.php' );
65 - require( IMAGIFY_FUNCTIONS_PATH . 'api.php' );
66 - require( IMAGIFY_FUNCTIONS_PATH . 'attachments.php' );
67 - require( IMAGIFY_FUNCTIONS_PATH . 'process.php' );
68 - require( IMAGIFY_CLASSES_PATH . 'class-user.php' );
69 - require( IMAGIFY_CLASSES_PATH . 'class-attachment.php' );
70 - require( IMAGIFY_FUNCTIONS_PATH . 'admin-ui.php' );
71 - require( IMAGIFY_FUNCTIONS_PATH . 'admin-stats.php' );
72 - require( IMAGIFY_COMMON_PATH . 'attachments.php' );
73 - require( IMAGIFY_COMMON_PATH . 'admin-bar.php' );
74 - require( IMAGIFY_3RD_PARTY_PATH . '3rd-party.php' );
58 + if ( ! is_multisite() ) {
59 + $is = false;
60 + return $is;
61 + }
75 62
76 - if ( is_admin() ) {
77 - require( IMAGIFY_ADMIN_PATH . 'upgrader.php' );
78 - require( IMAGIFY_ADMIN_PATH . 'ajax.php' );
79 - require( IMAGIFY_ADMIN_PATH . 'options.php' );
80 - require( IMAGIFY_ADMIN_PATH . 'menu.php' );
81 - require( IMAGIFY_ADMIN_PATH . 'plugins.php' );
82 - require( IMAGIFY_ADMIN_PATH . 'upload.php' );
83 - require( IMAGIFY_ADMIN_PATH . 'media.php' );
84 - require( IMAGIFY_ADMIN_PATH . 'enqueue.php' );
85 - require( IMAGIFY_ADMIN_PATH . 'meta-boxes.php' );
86 - require( IMAGIFY_ADMIN_UI_PATH . 'options.php' );
87 - require( IMAGIFY_ADMIN_UI_PATH . 'bulk.php' );
88 - require( IMAGIFY_ADMIN_UI_PATH . 'notices.php' );
89 - }
90 -
91 - /**
92 - * Fires when Imagify is correctly loaded
63 + if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
64 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
65 + }
66 +
67 + $is = is_plugin_active_for_network( plugin_basename( IMAGIFY_FILE ) );
68 +
69 + return $is;
70 +}
71 +
72 +/**
73 + * Check for WordPress and PHP version.
74 + *
75 + * @since 1.9
76 + * @author Grégory Viguier
77 + *
78 + * @return bool True if WP and PHP versions are OK.
79 + */
80 +function imagify_pass_requirements() {
81 + static $check;
82 +
83 + if ( isset( $check ) ) {
84 + return $check;
85 + }
86 +
87 + require_once IMAGIFY_PATH . 'inc/classes/class-imagify-requirements-check.php';
88 +
89 + $requirement_checks = new Imagify_Requirements_Check(
90 + [
91 + 'plugin_name' => 'Imagify',
92 + 'plugin_file' => IMAGIFY_FILE,
93 + 'plugin_version' => IMAGIFY_VERSION,
94 + 'wp_version' => '5.3',
95 + 'php_version' => '7.4',
96 + ]
97 + );
98 +
99 + $check = $requirement_checks->check();
100 +
101 + return $check;
102 +}
103 +
104 +/**
105 + * Set a transient on plugin activation, it will be used later to trigger activation hooks after the plugin is loaded.
106 + * The transient contains the ID of the user that activated the plugin.
107 + *
108 + * @since 1.9
109 + * @see Imagify_Plugin->maybe_activate()
110 + * @author Grégory Viguier
111 + */
112 +function imagify_set_activation() {
113 + if ( ! imagify_pass_requirements() ) {
114 + return;
115 + }
116 +
117 + if ( imagify_is_active_for_network() ) {
118 + set_site_transient( 'imagify_activation', get_current_user_id(), 30 );
119 + } else {
120 + set_transient( 'imagify_activation', get_current_user_id(), 30 );
121 + }
122 +}
123 +register_activation_hook( IMAGIFY_FILE, 'imagify_set_activation' );
124 +
125 +/**
126 + * Trigger a hook on plugin deactivation.
127 + *
128 + * @since 1.9
129 + * @author Grégory Viguier
130 + */
131 +function imagify_deactivation() {
132 + if ( ! imagify_pass_requirements() ) {
133 + return;
134 + }
135 +
136 + // Clean up site transients.
137 + delete_site_transient( 'imagify_check_api_version' );
138 + delete_site_transient( 'imagify_check_licence_1' );
139 +
140 + /**
141 + * Imagify deactivation.
93 142 *
94 - * @since 1.0
95 - */
96 - do_action( 'imagify_loaded' );
97 -}
143 + * @since 1.9
144 + * @author Grégory Viguier
145 + */
146 + do_action( 'imagify_deactivation' );
147 +}
148 +register_deactivation_hook( IMAGIFY_FILE, 'imagify_deactivation' );