# squeeze/1.3/squeeze.php

Squeeze – Image Optimization &amp; Compression, WEBP Conversion, version 1.3. 93 lines.

- Page: https://pluginprobe.com/plugins/squeeze/1.3/code/squeeze.php
- Raw: https://pluginprobe.com/plugins/squeeze/1.3/raw/squeeze.php
- Modified: 2024-01-10T14:47:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/squeeze/1.3/code/squeeze.php#L10-L20`.

```php
<?php
/**
 * Plugin Name: Squeeze
 * Description: Compress images by squoosh.app
 * Author URI:  https://bogdan.kyiv.ua
 * Author:      Bogdan Bendziukov
 * Version:     1.3
 *
 * Text Domain: squeeze
 * Domain Path: /languages
 *
 * License:     GNU GPL v3
 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
 *
 * Network:     false
 * 
 */

// Exit if accessed directly.
if (!defined('ABSPATH')) {
	exit;
}

define('SQUEEZE_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('SQUEEZE_PLUGIN_URL', plugin_dir_url(__FILE__));

add_action('plugins_loaded', 'squeeze_load_textdomain');
/**
 * Load plugin textdomain
 */
function squeeze_load_textdomain() {
	load_plugin_textdomain('squeeze', false, dirname(plugin_basename(__FILE__)) . '/languages/');
}

include_once(SQUEEZE_PLUGIN_DIR . 'src/settings.php');
include_once(SQUEEZE_PLUGIN_DIR . 'src/handlers.php');


add_action('admin_print_footer_scripts', 'squeeze_block_assets');
/**
 * Enqueue assets
 */
function squeeze_block_assets() {
	global $pagenow;

	$options = get_option( 'squeeze_options' );
	$default_options = squeeze_get_default_value( null, true); // get all default values
	$js_options = array();

	foreach ($default_options as $key => $value) {
		if (isset($options[$key])) {
			if (is_numeric($options[$key])) {
				$js_options[$key] = intval($options[$key]);
			} elseif ($options[$key] === "on") {
				$js_options[$key] = true;
			}
		} else {
			$js_options[$key] = $value;
		}
	}

	// Enqueue script for backend.

	wp_enqueue_script(
		'squeeze-script',
		// Handle.
		plugins_url('/assets/js/script.bundle.js', __FILE__),
		array('jquery', 'wp-mediaelement'),
		// Dependencies, defined above.
		null,
		true // Enqueue the script in the footer.
	);


	// WP Localized globals. Use dynamic PHP stuff in JavaScript via `squeeze` object.
	wp_localize_script(
		'squeeze-script',
		'squeeze',
		// Array containing dynamic data for a JS Global.
		[
			'pluginUrl' => SQUEEZE_PLUGIN_URL,
			'ajaxUrl' => admin_url('admin-ajax.php'),
			'nonce' => wp_create_nonce('squeeze-nonce'),
			'options' => json_encode($js_options),
		]
	);

	wp_set_script_translations('squeeze-script', 'squeeze', plugin_dir_path(__DIR__) . 'languages');

}



```
