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

185 lines 4.1 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.10
7 * Requires at least: 5.3
8 * Requires PHP: 7.0
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.10' );
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 if ( ! defined( 'IMAGIFY_APP_DOMAIN' ) ) {
33 define( 'IMAGIFY_APP_DOMAIN', 'https://app.imagify.io' );
34 }
35 define( 'IMAGIFY_APP_API_URL', IMAGIFY_APP_DOMAIN . '/api/' );
36
37 add_action( 'plugins_loaded', '_imagify_init' );
38 /**
39 * Plugin init.
40 *
41 * @since 1.0
42 */
43 function _imagify_init() {
44 // Nothing to do during autosave.
45 if ( defined( 'DOING_AUTOSAVE' ) ) {
46 return;
47 }
48
49 // Check for WordPress and PHP version.
50 if ( ! imagify_pass_requirements() ) {
51 return;
52 }
53
54 // Init the plugin.
55 require_once IMAGIFY_PATH . 'inc/classes/class-imagify-plugin.php';
56
57 $plugin = new Imagify_Plugin(
58 array(
59 'plugin_path' => IMAGIFY_PATH,
60 )
61 );
62
63 $plugin->init();
64 }
65
66 /**
67 * Check if Imagify is activated on the network.
68 *
69 * @since 1.0
70 *
71 * return bool True if Imagify is activated on the network.
72 */
73 function imagify_is_active_for_network() {
74 static $is;
75
76 if ( isset( $is ) ) {
77 return $is;
78 }
79
80 if ( ! is_multisite() ) {
81 $is = false;
82 return $is;
83 }
84
85 if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
86 require_once ABSPATH . 'wp-admin/includes/plugin.php';
87 }
88
89 $is = is_plugin_active_for_network( plugin_basename( IMAGIFY_FILE ) );
90
91 return $is;
92 }
93
94 /**
95 * Check for WordPress and PHP version.
96 *
97 * @since 1.9
98 * @author Grégory Viguier
99 *
100 * @return bool True if WP and PHP versions are OK.
101 */
102 function imagify_pass_requirements() {
103 static $check;
104
105 if ( isset( $check ) ) {
106 return $check;
107 }
108
109 require_once IMAGIFY_PATH . 'inc/classes/class-imagify-requirements-check.php';
110
111 $requirement_checks = new Imagify_Requirements_Check(
112 array(
113 'plugin_name' => 'Imagify',
114 'plugin_file' => IMAGIFY_FILE,
115 'plugin_version' => IMAGIFY_VERSION,
116 'wp_version' => '5.3',
117 'php_version' => '7.0',
118 )
119 );
120
121 $check = $requirement_checks->check();
122
123 return $check;
124 }
125
126 /**
127 * Load plugin translations.
128 *
129 * @since 1.9
130 * @author Grégory Viguier
131 */
132 function imagify_load_translations() {
133 static $done = false;
134
135 if ( $done ) {
136 return;
137 }
138
139 $done = true;
140
141 load_plugin_textdomain( 'imagify', false, dirname( plugin_basename( IMAGIFY_FILE ) ) . '/languages/' );
142 }
143
144 register_activation_hook( IMAGIFY_FILE, 'imagify_set_activation' );
145 /**
146 * Set a transient on plugin activation, it will be used later to trigger activation hooks after the plugin is loaded.
147 * The transient contains the ID of the user that activated the plugin.
148 *
149 * @since 1.9
150 * @see Imagify_Plugin->maybe_activate()
151 * @author Grégory Viguier
152 */
153 function imagify_set_activation() {
154 if ( ! imagify_pass_requirements() ) {
155 return;
156 }
157
158 if ( imagify_is_active_for_network() ) {
159 set_site_transient( 'imagify_activation', get_current_user_id(), 30 );
160 } else {
161 set_transient( 'imagify_activation', get_current_user_id(), 30 );
162 }
163 }
164
165 register_deactivation_hook( IMAGIFY_FILE, 'imagify_deactivation' );
166 /**
167 * Trigger a hook on plugin deactivation.
168 *
169 * @since 1.9
170 * @author Grégory Viguier
171 */
172 function imagify_deactivation() {
173 if ( ! imagify_pass_requirements() ) {
174 return;
175 }
176
177 /**
178 * Imagify deactivation.
179 *
180 * @since 1.9
181 * @author Grégory Viguier
182 */
183 do_action( 'imagify_deactivation' );
184 }
185