PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.9.11
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.9.11
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
imagify / imagify.php

imagify.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.9.11, at imagify.php

181 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
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: 1.9.11
7 * Requires at least: 4.0.0
8 * Requires PHP: 5.4
9 * Author: WP Media
10 * Author URI: https://wp-media.me/
11 * Licence: GPLv2
12 *
13 * Text Domain: imagify
14 * Domain Path: languages
15 *
16 * Copyright 2019 WP Media
17 *
18 * @package WP-Media\Imagify\WordPress-Plugin
19 */
20
21 defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
22
23 // Imagify defines.
24 define( 'IMAGIFY_VERSION', '1.9.11' );
25 define( 'IMAGIFY_SLUG', 'imagify' );
26 define( 'IMAGIFY_FILE', __FILE__ );
27 define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
28 define( 'IMAGIFY_URL', plugin_dir_url( IMAGIFY_FILE ) );
29 define( 'IMAGIFY_ASSETS_IMG_URL', IMAGIFY_URL . 'assets/images/' );
30 define( 'IMAGIFY_MAX_BYTES', 5242880 );
31 define( 'IMAGIFY_INT_MAX', PHP_INT_MAX - 30 );
32
33 add_action( 'plugins_loaded', '_imagify_init' );
34 /**
35 * Plugin init.
36 *
37 * @since 1.0
38 */
39 function _imagify_init() {
40 // Nothing to do during autosave.
41 if ( defined( 'DOING_AUTOSAVE' ) ) {
42 return;
43 }
44
45 // Check for WordPress and PHP version.
46 if ( ! imagify_pass_requirements() ) {
47 return;
48 }
49
50 // Init the plugin.
51 require_once IMAGIFY_PATH . 'inc/classes/class-imagify-plugin.php';
52
53 $plugin = new Imagify_Plugin(
54 array(
55 'plugin_path' => IMAGIFY_PATH,
56 )
57 );
58
59 $plugin->init();
60 }
61
62 /**
63 * Check if Imagify is activated on the network.
64 *
65 * @since 1.0
66 *
67 * return bool True if Imagify is activated on the network.
68 */
69 function imagify_is_active_for_network() {
70 static $is;
71
72 if ( isset( $is ) ) {
73 return $is;
74 }
75
76 if ( ! is_multisite() ) {
77 $is = false;
78 return $is;
79 }
80
81 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
82 require_once ABSPATH . 'wp-admin/includes/plugin.php';
83 }
84
85 $is = is_plugin_active_for_network( plugin_basename( IMAGIFY_FILE ) );
86
87 return $is;
88 }
89
90 /**
91 * Check for WordPress and PHP version.
92 *
93 * @since 1.9
94 * @author Grégory Viguier
95 *
96 * @return bool True if WP and PHP versions are OK.
97 */
98 function imagify_pass_requirements() {
99 static $check;
100
101 if ( isset( $check ) ) {
102 return $check;
103 }
104
105 require_once IMAGIFY_PATH . 'inc/classes/class-imagify-requirements-check.php';
106
107 $requirement_checks = new Imagify_Requirements_Check(
108 array(
109 'plugin_name' => 'Imagify',
110 'plugin_file' => IMAGIFY_FILE,
111 'plugin_version' => IMAGIFY_VERSION,
112 'wp_version' => '4.0',
113 'php_version' => '5.4',
114 )
115 );
116
117 $check = $requirement_checks->check();
118
119 return $check;
120 }
121
122 /**
123 * Load plugin translations.
124 *
125 * @since 1.9
126 * @author Grégory Viguier
127 */
128 function imagify_load_translations() {
129 static $done = false;
130
131 if ( $done ) {
132 return;
133 }
134
135 $done = true;
136
137 load_plugin_textdomain( 'imagify', false, dirname( plugin_basename( IMAGIFY_FILE ) ) . '/languages/' );
138 }
139
140 register_activation_hook( IMAGIFY_FILE, 'imagify_set_activation' );
141 /**
142 * Set a transient on plugin activation, it will be used later to trigger activation hooks after the plugin is loaded.
143 * The transient contains the ID of the user that activated the plugin.
144 *
145 * @since 1.9
146 * @see Imagify_Plugin->maybe_activate()
147 * @author Grégory Viguier
148 */
149 function imagify_set_activation() {
150 if ( ! imagify_pass_requirements() ) {
151 return;
152 }
153
154 if ( imagify_is_active_for_network() ) {
155 set_site_transient( 'imagify_activation', get_current_user_id(), 30 );
156 } else {
157 set_transient( 'imagify_activation', get_current_user_id(), 30 );
158 }
159 }
160
161 register_deactivation_hook( IMAGIFY_FILE, 'imagify_deactivation' );
162 /**
163 * Trigger a hook on plugin deactivation.
164 *
165 * @since 1.9
166 * @author Grégory Viguier
167 */
168 function imagify_deactivation() {
169 if ( ! imagify_pass_requirements() ) {
170 return;
171 }
172
173 /**
174 * Imagify deactivation.
175 *
176 * @since 1.9
177 * @author Grégory Viguier
178 */
179 do_action( 'imagify_deactivation' );
180 }
181