| @@ -108,15 +108,8 @@ | ||
| 108 | 108 | * The class responsible for orchestrating the actions and filters of the |
| 109 | 109 | * core plugin. |
| 110 | 110 | */ |
| 111 | 111 | require_once QUICKWEBP_PLUGIN_PATH . 'includes/class-quickwebp-loader.php'; |
| 112 | - | |
| 113 | - /** | |
| 114 | - * This file is loaded only on local environement for test or debug. | |
| 115 | - */ | |
| 116 | - if( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1' ){ | |
| 117 | - require_once QUICKWEBP_PLUGIN_PATH. 'includes/dev-toolkits.php'; | |
| 118 | - } | |
| 119 | 112 | |
| 120 | 113 | /** |
| 121 | 114 | * The global functions for this plugin |
| 122 | 115 | */ |
| @@ -141,10 +134,29 @@ | ||
| 141 | 134 | /** |
| 142 | 135 | * The core functionality for wp media extending |
| 143 | 136 | */ |
| 144 | 137 | require_once QUICKWEBP_PLUGIN_PATH . 'admin/class-wp-media-extends.php'; |
| 145 | - | |
| 146 | 138 | |
| 139 | + /** | |
| 140 | + * The class responsible of cron job. | |
| 141 | + */ | |
| 142 | + require_once QUICKWEBP_PLUGIN_PATH . 'admin/class-cron-job.php'; | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * The class responsible for handling the surecart. | |
| 146 | + */ | |
| 147 | + require_once QUICKWEBP_PLUGIN_PATH . 'admin/class-surecart.php'; | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * The class responsible for handling the migration. | |
| 151 | + */ | |
| 152 | + require_once QUICKWEBP_PLUGIN_PATH . 'admin/class-migration.php'; | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * The handle the front-end display functionality of the plugin. | |
| 156 | + */ | |
| 157 | + require_once QUICKWEBP_PLUGIN_PATH . 'public/class-display-webp.php'; | |
| 158 | + | |
| 147 | 159 | $this->loader = new Quickwebp_Loader(); |
| 148 | 160 | |
| 149 | 161 | } |
| 150 | 162 | |
| @@ -160,9 +172,9 @@ | ||
| 160 | 172 | private function set_locale() { |
| 161 | 173 | |
| 162 | 174 | $plugin_i18n = new Quickwebp_i18n(); |
| 163 | 175 | |
| 164 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); | |
| 176 | + $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' ); | |
| 165 | 177 | |
| 166 | 178 | } |
| 167 | 179 | |
| 168 | 180 | /** |
| @@ -176,16 +188,47 @@ | ||
| 176 | 188 | |
| 177 | 189 | $quickwebp_settings = new Quickwebp_Settings( $this->get_plugin_name(), $this->get_version() ); |
| 178 | 190 | $this->loader->add_action( 'admin_enqueue_scripts', $quickwebp_settings, 'enqueue_scripts_styles' ); |
| 179 | 191 | $this->loader->add_action( 'admin_menu', $quickwebp_settings, 'add_settings_menu' ); |
| 180 | - | |
| 192 | + $this->loader->add_action( 'admin_init', $quickwebp_settings, 'dismiss_avif_notice' ); | |
| 193 | + $this->loader->add_action( 'admin_notices', $quickwebp_settings, 'render_avif_notice' ); | |
| 194 | + $this->loader->add_filter( 'plugin_action_links', $quickwebp_settings, 'add_settings_link', 10, 2 ); | |
| 195 | + $this->loader->add_filter( 'sanitize_option_quickwebp_settings_conversion_display_webp_mode', $quickwebp_settings, 'add_rewrite_rules', 5 ); | |
| 196 | + $this->loader->add_filter( 'sanitize_option_quickwebp_settings_conversion_display_webp_mode', $quickwebp_settings, 'sanitize_display_mode_for_consistency', 10, 3 ); | |
| 197 | + | |
| 181 | 198 | $quickwebp_image_optimizer = new Quickwebp_Image_Optimizer( $this->get_plugin_name(), $this->get_version() ); |
| 182 | - $this->loader->add_filter( 'wp_handle_upload_prefilter', $quickwebp_image_optimizer, 'image_optimizition' ); | |
| 199 | + $this->loader->add_filter( 'wp_handle_upload_prefilter', $quickwebp_image_optimizer, 'image_optimization' ); | |
| 200 | + $this->loader->add_filter( 'wp_generate_attachment_metadata', $quickwebp_image_optimizer, 'add_already_optimized_meta', 10, 3 ); | |
| 201 | + $this->loader->add_filter( 'wp_generate_attachment_metadata', $quickwebp_image_optimizer, 'save_original_image', 10, 3 ); | |
| 183 | 202 | $this->loader->add_filter( 'wp_generate_attachment_metadata', $quickwebp_image_optimizer, 'add_data_to_attachment', 10, 3 ); |
| 203 | + $this->loader->add_filter( 'big_image_size_threshold', $quickwebp_image_optimizer, 'change_wp_max_size', PHP_INT_MAX, 2 ); | |
| 204 | + $this->loader->add_filter( 'wp_editor_set_quality', $quickwebp_image_optimizer, 'change_wp_quality', PHP_INT_MAX ); | |
| 205 | + $this->loader->add_action( 'wp_ajax_image_optimization_ajax', $quickwebp_image_optimizer, 'image_optimization_ajax' ); | |
| 206 | + $this->loader->add_action( 'wp_ajax_single_optimization_ajax', $quickwebp_image_optimizer, 'single_optimization_ajax' ); | |
| 207 | + $this->loader->add_action( 'wp_ajax_undo_single_optimization_ajax', $quickwebp_image_optimizer, 'undo_single_optimization_ajax' ); | |
| 208 | + $this->loader->add_action( 'delete_attachment', $quickwebp_image_optimizer, 'before_delete_attachment' ); | |
| 209 | + $this->loader->add_action( 'wp_ajax_get_image_data_for_preview', $quickwebp_image_optimizer, 'get_image_data_for_preview_ajax' ); | |
| 184 | 210 | |
| 185 | 211 | $quickwebp_wp_media_extends = new Quickwebp_Wp_Media_Extends( $this->get_plugin_name(), $this->get_version() ); |
| 186 | - $this->loader->add_action( 'wp_enqueue_media', $quickwebp_wp_media_extends, 'enqueue_scripts' ); | |
| 212 | + $this->loader->add_action( 'admin_enqueue_scripts', $quickwebp_wp_media_extends, 'enqueue_scripts' ); | |
| 213 | + $this->loader->add_filter( 'attachment_fields_to_edit', $quickwebp_wp_media_extends, 'add_attachment_fields_to_edit', PHP_INT_MAX, 2 ); | |
| 214 | + $this->loader->add_filter( 'manage_media_columns', $quickwebp_wp_media_extends, 'add_media_columns'); | |
| 215 | + $this->loader->add_action( 'manage_media_custom_column', $quickwebp_wp_media_extends, 'add_media_custom_column', 10, 2 ); | |
| 216 | + $this->loader->add_action( 'attachment_submitbox_misc_actions', $quickwebp_wp_media_extends, 'add_attachment_submitbox_misc_actions', PHP_INT_MAX ); | |
| 187 | 217 | |
| 218 | + $quickwebp_cron_job = new Quickwebp_Cron_Job( $this->get_plugin_name(), $this->get_version() ); | |
| 219 | + $this->loader->add_filter( 'cron_schedules', $quickwebp_cron_job, 'crons_registrations' ); | |
| 220 | + $this->loader->add_action( 'quickwebp_bulk_optimization_hook', $quickwebp_cron_job, 'excute_bulk_optimization' ); | |
| 221 | + $this->loader->add_action( 'wp_ajax_start_bulk_optimization', $quickwebp_cron_job, 'start_bulk_optimization' ); | |
| 222 | + $this->loader->add_action( 'wp_ajax_stop_bulk_optimization', $quickwebp_cron_job, 'stop_bulk_optimization' ); | |
| 223 | + $this->loader->add_action( 'wp_ajax_check_bulk_optimization_progress', $quickwebp_cron_job, 'check_bulk_optimization_progress' ); | |
| 224 | + | |
| 225 | + $quickwebp_surecart = new Quickwebp_Surecart(); | |
| 226 | + $this->loader->add_action( 'init', $quickwebp_surecart, 'init_surecart' ); | |
| 227 | + $this->loader->add_action( 'admin_enqueue_scripts', $quickwebp_surecart, 'enqueue_scripts_styles' ); | |
| 228 | + | |
| 229 | + $quickwebp_migration = new Quickwebp_Migration(); | |
| 230 | + $this->loader->add_action( 'admin_init', $quickwebp_migration, 'init_migration' ); | |
| 188 | 231 | } |
| 189 | 232 | |
| 190 | 233 | /** |
| 191 | 234 | * Register all of the hooks related to the public-facing functionality |
| @@ -195,8 +238,10 @@ | ||
| 195 | 238 | * @access private |
| 196 | 239 | */ |
| 197 | 240 | private function define_public_hooks() { |
| 198 | 241 | |
| 242 | + $quickwebp_display_webp = new Quickwebp_Display_Webp( $this->get_plugin_name(), $this->get_version() ); | |
| 243 | + $this->loader->add_action( 'template_redirect', $quickwebp_display_webp, 'start_content_process', -1000 ); | |
| 199 | 244 | } |
| 200 | 245 | |
| 201 | 246 | /** |
| 202 | 247 | * Run the loader to execute all of the hooks with WordPress. |