PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.9.5
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.9.5
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.5, at imagify.php

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