PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 3.3.0
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v3.3.0
4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
quickwebp / includes / class-quickwebp-activator.php

class-quickwebp-activator.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 3.3.0, at includes/class-quickwebp-activator.php

92 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Fired during plugin activation
5 *
6 * @link http://webdeclic.com
7 * @since 1.0.0
8 *
9 * @package Quickwebp
10 * @subpackage Quickwebp/includes
11 */
12
13 /**
14 * Fired during plugin activation.
15 *
16 * This class defines all code necessary to run during the plugin's activation.
17 *
18 * @since 1.0.0
19 * @package Quickwebp
20 * @subpackage Quickwebp/includes
21 * @author Webdeclic <contact@webdeclic.com>
22 */
23 class Quickwebp_Activator {
24
25 /**
26 * Short Description. (use period)
27 *
28 * Long Description.
29 *
30 * @since 1.0.0
31 */
32 public static function activate() {
33
34 self::update_library();
35 self::maybe_add_rewrite_rules();
36
37 }
38
39 /**
40 * Update library
41 */
42 public static function update_library() {
43
44 $library_to_use = get_option( 'quickwebp_settings_library', quickwebp_settings_default('quickwebp_settings_library') );
45
46 switch ($library_to_use) {
47
48 case 'gd':
49 if ( !extension_loaded('gd') ) {
50 update_option( 'quickwebp_settings_library', 'imagick' );
51 }
52 break;
53
54 case 'imagick':
55 if ( !extension_loaded('imagick') ) {
56 update_option( 'quickwebp_settings_library', 'gd' );
57 }
58 break;
59 }
60 }
61
62 /**
63 * Add rewrite rules
64 */
65 public static function maybe_add_rewrite_rules() {
66
67 $web_mode = get_option( 'quickwebp_settings_conversion_display_webp_mode', quickwebp_settings_default('quickwebp_settings_conversion_display_webp_mode') );
68 if ( 'rewrite' !== $web_mode ) {
69 return;
70 }
71
72 global $is_apache, $is_iis7, $is_nginx;
73
74 include_once QUICKWEBP_PLUGIN_PATH . 'admin/rewrite-rules/class-apache.php';
75 include_once QUICKWEBP_PLUGIN_PATH . 'admin/rewrite-rules/class-nginx.php';
76 include_once QUICKWEBP_PLUGIN_PATH . 'admin/rewrite-rules/class-iis.php';
77
78 if ( $is_apache ) {
79 $rules = new Apache();
80 } elseif ( $is_iis7 ) {
81 $rules = new IIS();
82 } elseif ( $is_nginx ) {
83 $rules = new Nginx();
84 } else {
85 return;
86 }
87
88 $rules->add();
89 }
90
91 }
92