PluginProbe
ThumbPress – Compress Images, Manage Thumbnails, Detect Image Issues, WebP/AVIF, Lazy Loading, Hotlinking & More / 6.7.0.2
ThumbPress – Compress Images, Manage Thumbnails, Detect Image Issues, WebP/AVIF, Lazy Loading, Hotlinking & More v6.7.0.2
6.7.0.2 6.7.0.3 6.7.0 6.7.0.1 6.6.0 6.5.2 6.5 6.4.1 6.4 6.3.2 6.3.3 6.3.3.1 6.3.3.2 6.3.1 6.3.0 6.2.2 6.2 6.2.1 6.1.4 6.1.3 6.1.2 6.1 6.1.1 6.0.1 6.0.2 All 148 releases
image-sizes / image-sizes.php

image-sizes.php in ThumbPress – Compress Images, Manage Thumbnails, Detect Image Issues, WebP/AVIF, Lazy Loading, Hotlinking & More 6.7.0.2, at image-sizes.php

219 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Thumbpress
4 *
5 * Plugin Name: ThumbPress
6 * Plugin URI: https://wordpress.org/plugins/image-sizes/
7 * Description: WordPress Image Optimization & Media Management Toolkit
8 * Version: 6.7.0.2
9 * Requires at least: 6.0
10 * Requires PHP: 7.4
11 * Author: ThumbPress
12 * Author URI: https://thumbpress.co
13 * Text Domain: image-sizes
14 * Domain Path: /languages
15 * License: GPL v2 or later
16 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
17 */
18
19 namespace Codexpert\ThumbPress;
20
21 use Codexpert\Plugin\Notice;
22 use Pluggable\Marketing\Survey;
23 use Pluggable\Marketing\Feature;
24 use Pluggable\Marketing\Deactivator;
25
26 defined( 'ABSPATH' ) || exit;
27
28 define( 'THUMBPRESS_VERSION', '6.7.0.2' );
29 define( 'THUMBPRESS_FILE', __FILE__ );
30 define( 'THUMBPRESS_PATH', plugin_dir_path( __FILE__ ) );
31 define( 'THUMBPRESS_URL', plugin_dir_url( __FILE__ ) );
32 define( 'THUMBPRESS_ASSETS_PATH', THUMBPRESS_PATH . 'assets/' );
33 define( 'THUMBPRESS_ASSETS_URL', THUMBPRESS_URL . 'assets/' );
34 define( 'THUMBPRESS_CACHE_ENABLED', true );
35
36 require_once THUMBPRESS_PATH . 'vendor/autoload.php';
37 require_once THUMBPRESS_PATH . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
38
39 ( new Bootstrap\AdminNotice() )->init();
40
41 define( 'THUMBPRESS_PLUGIN_DIR', THUMBPRESS_PATH );
42 define( 'THUMBPRESS_PLUGIN_URL', THUMBPRESS_URL );
43
44 /**
45 * Main ThumbPress plugin class.
46 *
47 * @since 6.0
48 * @package Thumbpress
49 */
50 final class ThumbPress {
51
52 /**
53 * Singleton instance.
54 *
55 * @var ThumbPress|null
56 */
57 public static $_instance;
58
59 /**
60 * Plugin configuration and metadata.
61 *
62 * @var array
63 */
64 public array $plugin;
65
66 /**
67 * Constructor.
68 *
69 * @return void
70 */
71 public function __construct() {
72 $this->define();
73 $this->includes();
74 $this->hook();
75 }
76
77 /**
78 * Define plugin variables.
79 *
80 * @return void
81 */
82 public function define(): void {
83 // get_plugin_data()'s file is only auto-loaded since WP 6.8 (Trac #62244), but define()
84 // runs on every request — load it on demand so WP 6.0–6.7 doesn't fatal (#472).
85 if ( ! function_exists( 'get_plugin_data' ) ) {
86 require_once ABSPATH . 'wp-admin/includes/plugin.php';
87 }
88 $this->plugin = get_plugin_data( THUMBPRESS_FILE, true, false );
89 $this->plugin['basename'] = plugin_basename( THUMBPRESS_FILE );
90 $this->plugin['file'] = THUMBPRESS_FILE;
91 $this->plugin['server'] = apply_filters( 'thumbpress_server', 'https://my.pluggable.io' );
92 $this->plugin['min_php'] = '7.4';
93 $this->plugin['min_wp'] = '5.0';
94 // Opt-in lead collection via pluggable.io / FluentCRM. Data is sent ONLY on explicit user
95 // action — clicking "Agree" on the activation survey notice, or "Submit & Deactivate" on the
96 // deactivation feedback modal. Nothing is transmitted automatically. Disclosed in readme.txt
97 // under "External Services" (what is sent, when, ToS + Privacy Policy links).
98 $this->plugin['hash_deactivator'] = 'f490a1f1-c3a1-4d3a-bc2a-70d4b405aa11';
99 $this->plugin['hash_survey'] = '55b6c7ca-9102-495f-a6bd-581285447c0a';
100 }
101
102 /**
103 * Get plugin metadata parsed once in define() — callers reuse it instead of
104 * calling get_plugin_data() again (#472).
105 *
106 * @param string $key Optional. Metadata key; whole array when empty.
107 * @param mixed $default Optional. Returned when $key is absent.
108 * @return mixed
109 */
110 public function get_plugin( string $key = '', $default = null ) {
111 if ( '' === $key ) {
112 return $this->plugin;
113 }
114 return $this->plugin[ $key ] ?? $default;
115 }
116
117 /**
118 * Include additional dependencies.
119 *
120 * @return void
121 */
122 public function includes(): void {
123 if ( is_admin() ) {
124 new Notice( $this->plugin );
125 new Survey( $this->plugin );
126 new Deactivator( $this->plugin );
127 }
128 }
129
130 /**
131 * Register plugin hooks.
132 *
133 * @return void
134 */
135 public function hook(): void {
136 register_activation_hook( THUMBPRESS_FILE, array( $this, 'install' ) );
137 register_deactivation_hook( THUMBPRESS_FILE, array( $this, 'uninstall' ) );
138
139 add_action( 'admin_init', array( $this, 'redirect' ) );
140 add_action( 'plugins_loaded', array( $this, 'activate' ) );
141 add_action( 'plugins_loaded', array( $this, 'initialize' ) );
142 add_action( 'init', array( $this, 'load_textdomain' ) );
143 }
144
145 /**
146 * Load the plugin's translations for PHP strings (menu labels, admin notices,
147 * REST messages). The React bundle's JS strings are wired separately via
148 * wp_set_script_translations() at enqueue time (see Controllers\Admin\Menu).
149 *
150 * Hooked on `init` so it is valid on WordPress 6.7+, which warns when a
151 * textdomain is loaded earlier.
152 *
153 * @return void
154 */
155 public function load_textdomain(): void {
156 load_plugin_textdomain( 'image-sizes', false, dirname( $this->plugin['basename'] ) . '/languages' );
157 }
158
159 /**
160 * Run on plugin activation.
161 *
162 * @return void
163 */
164 public function install(): void {
165 Bootstrap\Installer::install();
166 update_option( Bootstrap\Activator::REDIRECT_OPTION, true );
167 }
168
169 /**
170 * Redirect after activation.
171 *
172 * @return void
173 */
174 public function redirect(): void {
175 Bootstrap\Activator::maybe_redirect();
176 }
177
178 /**
179 * Run activator on plugins_loaded.
180 *
181 * @return void
182 */
183 public function activate(): void {
184 Bootstrap\Activator::activate();
185 }
186
187 /**
188 * Initialize the plugin.
189 *
190 * @return void
191 */
192 public function initialize(): void {
193 Bootstrap\Initializer::initialize();
194 }
195
196 /**
197 * Run on plugin deactivation.
198 *
199 * @return void
200 */
201 public function uninstall(): void {
202 Bootstrap\Uninstaller::uninstall();
203 }
204
205 /**
206 * Get singleton instance.
207 *
208 * @return ThumbPress
209 */
210 public static function instance(): self {
211 if ( is_null( self::$_instance ) ) {
212 self::$_instance = new self();
213 }
214 return self::$_instance;
215 }
216 }
217
218 ThumbPress::instance();
219