PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.6.8
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.6.8
2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 2.6.4 2.6.3 2.5.23 All 138 releases
metasync / media-optimization / media-optimization-loader.php

media-optimization-loader.php in Search Atlas SEO – OTTO AI SEO Automation for WordPress 2.6.8, at media-optimization/media-optimization-loader.php

120 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MetaSync - Media Optimization Module Loader
4 *
5 * @package Search Atlas SEO
6 * @copyright Copyright (C) 2021-2025, Search Atlas Group - support@searchatlas.com
7 * @since 2.6.0
8 */
9
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13
14 define('METASYNC_MEDIA_OPT_PATH', plugin_dir_path(__FILE__));
15 define('METASYNC_MEDIA_OPT_URL', plugin_dir_url(__FILE__));
16
17 // Load classes
18 require_once METASYNC_MEDIA_OPT_PATH . 'class-media-settings.php';
19 require_once METASYNC_MEDIA_OPT_PATH . 'class-image-converter.php';
20 require_once METASYNC_MEDIA_OPT_PATH . 'class-smart-lazy-loader.php';
21 require_once METASYNC_MEDIA_OPT_PATH . 'class-dimension-injector.php';
22 require_once METASYNC_MEDIA_OPT_PATH . 'class-media-batch-optimizer.php';
23
24 /**
25 * Initialize media optimization features based on settings.
26 * Only activates when the plugin is active and settings are enabled.
27 */
28 function metasync_media_optimization_init() {
29 $settings = Metasync_Media_Settings::get_settings();
30
31 // Frontend features - only load when enabled
32 if (!empty($settings['enable_conversion'])) {
33 new Metasync_Image_Converter($settings);
34 }
35
36 if (!empty($settings['enable_lazy_loading'])) {
37 new Metasync_Smart_Lazy_Loader($settings);
38 }
39
40 if (!empty($settings['enable_dimension_injection'])) {
41 new Metasync_Dimension_Injector();
42 }
43 }
44 add_action('init', 'metasync_media_optimization_init');
45
46 /**
47 * Enqueue media optimization admin assets on the correct page only.
48 *
49 * @param string $hook_suffix The current admin page hook suffix.
50 */
51 function metasync_media_optimization_enqueue_assets($hook_suffix) {
52 // Only load on the media optimization admin page.
53 // The hook suffix varies based on the parent menu slug (which may be white-labeled).
54 if (strpos($hook_suffix, 'media-optimization') === false) {
55 return;
56 }
57
58 $version = defined('METASYNC_VERSION') ? METASYNC_VERSION : '1.0.0';
59 $assets_url = METASYNC_MEDIA_OPT_URL . 'assets/';
60
61 // ── CSS ──
62 wp_enqueue_style(
63 'metasync-media-optimization',
64 $assets_url . 'css/media-optimization.css',
65 array(),
66 $version
67 );
68
69 // ── Settings JS ──
70 wp_enqueue_script(
71 'metasync-media-opt-settings',
72 $assets_url . 'js/media-optimization-settings.js',
73 array(),
74 $version,
75 true
76 );
77
78 wp_localize_script('metasync-media-opt-settings', 'metasyncMediaOpt', array(
79 'resetConfirm' => __('Are you sure you want to reset all media optimization settings to their defaults? This cannot be undone.', 'metasync'),
80 ));
81
82 // ── Image Library JS ──
83 wp_enqueue_script(
84 'metasync-media-opt-library',
85 $assets_url . 'js/media-optimization-library.js',
86 array(),
87 $version,
88 true
89 );
90
91 $batch_progress = Metasync_Media_Batch_Optimizer::get_progress();
92
93 wp_localize_script('metasync-media-opt-library', 'metasyncMediaLib', array(
94 'ajaxUrl' => admin_url('admin-ajax.php'),
95 'nonce' => wp_create_nonce('metasync_media_opt_nonce'),
96 'batchRunning' => ($batch_progress['status'] === 'running'),
97 'i18n' => array(
98 'optimizing' => __('Optimizing...', 'metasync'),
99 'optimize' => __('Optimize', 'metasync'),
100 'revert' => __('Revert', 'metasync'),
101 'revertConfirm' => __('Revert this image to its original format?', 'metasync'),
102 'optimizeFailed' => __('Optimization failed.', 'metasync'),
103 'revertFailed' => __('Revert failed.', 'metasync'),
104 'startBatch' => __('Start optimizing all unoptimized images?', 'metasync'),
105 'batchFailed' => __('Failed to start batch optimization.', 'metasync'),
106 'batchComplete' => __('Batch optimization complete!', 'metasync'),
107 'imagesProcessed' => __('images processed', 'metasync'),
108 'failed' => __('failed', 'metasync'),
109 'optimizingOf' => __('Optimizing', 'metasync'),
110 'of' => __('of', 'metasync'),
111 'images' => __('images...', 'metasync'),
112 'unoptimized' => __('Unoptimized', 'metasync'),
113 'selectImages' => __('Please select at least one image.', 'metasync'),
114 'bulkFailed' => __('Bulk optimization failed.', 'metasync'),
115 'apply' => __('Apply', 'metasync'),
116 ),
117 ));
118 }
119 add_action('admin_enqueue_scripts', 'metasync_media_optimization_enqueue_assets');
120