-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimage-converter-webp.php
75 lines (66 loc) · 1.57 KB
/
image-converter-webp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Plugin Name: Image Converter for WebP
* Plugin URI: https://github.com/badasswp/image-converter-webp
* Description: Convert your WordPress JPG/PNG images to WebP formats during runtime.
* Version: 1.3.0
* Author: badasswp
* Author URI: https://github.com/badasswp
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: image-converter-webp
* Domain Path: /languages
*
* @package ImageConverterWebP
*/
if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'ICFW_AUTOLOAD', __DIR__ . '/vendor/autoload.php' );
/**
* Bail out, if Composer is NOT installed.
* Log error message.
*
* @return bool
*/
function icfw_can_autoload(): bool {
if ( ! file_exists( ICFW_AUTOLOAD ) ) {
error_log(
sprintf(
esc_html__( 'Fatal Error: Composer not setup in %', 'image-converter-webp' ),
__DIR__
)
);
return false;
}
// Require autoload.
require_once ICFW_AUTOLOAD;
return true;
}
/**
* Generate autoload notice if Composer is
* NOT installed.
*
* @return void
*/
function icfw_autoload_notice(): void {
printf(
/* translators: plugin autoload file path. */
esc_html__( 'Fatal Error: %s file does not exist, please check if Composer is installed!', 'image-converter-webp' ),
esc_html( ICFW_AUTOLOAD )
);
}
/**
* Run plugin.
*
* @return void
*/
function icfw_run(): void {
if ( icfw_can_autoload() ) {
require_once __DIR__ . '/inc/Helpers/functions.php';
( \ImageConverterWebP\Plugin::get_instance() )->run();
} else {
add_action( 'admin_notices', 'icfw_autoload_notice' );
}
}
icfw_run();