PluginProbe
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / 1.4.1
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF v1.4.1
2.0.7 2.0.6 2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 All 26 releases
robin-image-optimizer / admin / boot.php

boot.php in Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF 1.4.1, at admin/boot.php

285 lines 9.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin boot
4 *
5 * @author Webcraftic <wordpress.webraftic@gmail.com>
6 * @copyright Webcraftic 25.05.2017
7 * @version 1.0
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Проверяем таблицу в базе данны�
17
18 *
19 * Если таблица не существует или её структура устарела, то обновляем.
20 * Проверка проводится при каждой инициализации плагина т.к. структура может измениться
21 * после очередного обновления плагина.
22 *
23 * @return bool
24 */
25 add_action( 'admin_init', function () {
26 RIO_Process_Queue::try_create_plugin_tables();
27 } );
28
29 /**
30 * Удаляет карточку компонента в плагине Clearfy.
31 *
32 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
33 * @since 1.3.0
34 */
35 add_filter( 'wbcr/clearfy/components/items_list', function ( $components ) {
36 if ( wrio_is_clearfy_license_activate() ) {
37 return $components;
38 }
39 if ( ! empty( $components ) ) {
40 foreach ( $components as $key => $component ) {
41 if ( "robin_image_optimizer" == $component['name'] ) {
42 unset( $components[ $key ] );
43 }
44 }
45 }
46
47 return $components;
48 } );
49
50 /**
51 * Добавляет карточку компонента на страницу компонентов
52 * в плагине Clearfy.
53 *
54 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
55 * @since 1.3.0
56 */
57 add_action( 'wbcr/clearfy/components/custom_plugins_card', function () {
58 if ( ! wrio_is_clearfy_license_activate() ) {
59 $view = WRIO_Views::get_instance( WRIO_PLUGIN_DIR );
60 $view->print_template( 'clearfy-component-card' );
61 }
62 } );
63
64 /**
65 * We asset migration scripts to all admin panel pages
66 *
67 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
68 * @since 1.3.0
69 */
70 add_action( 'admin_enqueue_scripts', function () {
71 if ( ! current_user_can( 'update_plugins' ) || ! wbcr_rio_has_meta_to_migrate() ) {
72 return;
73 }
74
75 wp_enqueue_script( 'wrio-meta-migrations', WRIO_PLUGIN_URL . '/admin/assets/js/meta-migrations.js', [
76 'jquery',
77 'wbcr-factory-clearfy-216-global'
78 ], WRIO_Plugin::app()->getPluginVersion() );
79 } );
80
81 /**
82 * Plugin was heavy migrated into new architecture. Specifically, post meta was moved to separate table and
83 * therefore it is required to migrate all of them to new table.
84 *
85 * This action prints a notice, which contains clickable link with JS onclick event, which invokes AJAX request
86 * to migrate these post metas to new table.
87 *
88 * Once all post meta migrated, notice would not be shown anymore.
89 *
90 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
91 * @since 1.3.0
92 *
93 * @param $notices
94 *
95 * @return array
96 * @see wbcr_rio_migrate_postmeta_to_process_queue() for further information about AJAX processing function.
97 * @see wbcr_rio_has_meta_to_migrate() used to check whether to show notice or not.
98 *
99 * @see RIO_Process_Queue for further information about new table.
100 */
101 add_action( "wbcr/factory/admin_notices", function ( $notices ) {
102
103 if ( ! current_user_can( 'update_plugins' ) || ! wbcr_rio_has_meta_to_migrate() ) {
104 return $notices;
105 }
106
107 $notices[] = [
108 'id' => WRIO_Plugin::app()->getPrefix() . 'meta_to_migration',
109 'type' => 'warning',
110 'dismissible' => false,
111 'dismiss_expires' => 0,
112 'text' => "<p><b>" . WRIO_Plugin::app()->getPluginTitle() . ":</b> " . wrio_get_meta_migration_notice_text() . '</p>'
113 ];
114
115 return $notices;
116 } );
117
118 /**
119 * Plugin was heavy migrated into new architecture. Specifically, post meta was moved to separate table and
120 * therefore it is required to migrate all of them to new table.
121 *
122 * This action prints a notice, which contains clickable link with JS onclick event, which invokes AJAX request
123 * to migrate these post metas to new table.
124 *
125 * Once all post meta migrated, notice would not be shown anymore.
126 *
127 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
128 * @since 1.3.0
129 *
130 * @param Wbcr_Factory424_Plugin $plugin
131 * @param Wbcr_FactoryPages424_ImpressiveThemplate $obj
132 *
133 * @see wbcr_rio_migrate_postmeta_to_process_queue() for further information about AJAX processing function.
134 * @see wbcr_rio_has_meta_to_migrate() used to check whether to show notice or not.
135 *
136 * @see RIO_Process_Queue for further information about new table.
137 */
138 add_action( 'wbcr/factory/pages/impressive/print_all_notices', function ( $plugin, $obj ) {
139 if ( ( $plugin->getPluginName() != WRIO_Plugin::app()->getPluginName() ) || ! wbcr_rio_has_meta_to_migrate() ) {
140 return;
141 }
142
143 $obj->printWarningNotice( wrio_get_meta_migration_notice_text() );
144 }, 10, 2 );
145
146 /***
147 * Flush configuration after saving the settings
148 *
149 * @param WHM_Plugin $plugin
150 * @param Wbcr_FactoryPages424_ImpressiveThemplate $obj
151 *
152 * @return bool
153 */
154 /*add_action('wbcr_factory_424_imppage_after_form_save', function ($plugin, $obj) {
155 $is_rio = WRIO_Plugin::app()->getPluginName() == $plugin->getPluginName();
156
157 if( $is_rio ) {
158 WRIO_Cron::check();
159 }
160 }, 10, 2);*/
161
162 /**
163 * Виджет отзывов
164 *
165 * @param string $page_url
166 * @param string $plugin_name
167 *
168 * @return string
169 */
170 function wio_rating_widget_url( $page_url, $plugin_name ) {
171 if ( $plugin_name == WRIO_Plugin::app()->getPluginName() ) {
172 return 'https://wordpress.org/support/plugin/robin-image-optimizer/reviews/#new-post';
173 }
174
175 return $page_url;
176 }
177
178 add_filter( 'wbcr_factory_pages_424_imppage_rating_widget_url', 'wio_rating_widget_url', 10, 2 );
179
180 /**
181 * Widget with the offer to buy Clearfy Business
182 *
183 * @param array $widgets
184 * @param string $position
185 * @param Wbcr_Factory424_Plugin $plugin
186 */
187 add_filter( 'wbcr/factory/pages/impressive/widgets', function ( $widgets, $position, $plugin ) {
188 if ( $plugin->getPluginName() == WRIO_Plugin::app()->getPluginName() ) {
189 require_once WRIO_PLUGIN_DIR . '/admin/includes/sidebar-widgets.php';
190
191 if ( wrio_is_license_activate() ) {
192 unset( $widgets['donate_widget'] );
193
194 if ( $position == 'right' ) {
195 unset( $widgets['business_suggetion'] );
196 unset( $widgets['rating_widget'] );
197 unset( $widgets['info_widget'] );
198 }
199
200 /*if ( $position == 'bottom' ) {
201 $widgets['support'] = wrio_get_sidebar_support_widget();
202 }*/
203
204 return $widgets;
205 } else {
206 if ( $position == 'right' ) {
207 unset( $widgets['info_widget'] );
208 unset( $widgets['rating_widget'] );
209 //$widgets['support'] = wrio_get_sidebar_support_widget();
210 }
211 }
212
213 //if ( $position == 'bottom' ) {
214 //$widgets['donate_widget'] = wrio_get_sidebar_premium_widget();
215 //}
216 }
217
218 return $widgets;
219 }, 20, 3 );
220
221 /**
222 * Заменяет заголовок в рекламном виджете
223 *
224 * @param array $features
225 * @param string $plugin_name
226 * @param string $page_id
227 */
228 add_filter( 'wbcr/clearfy/pages/suggetion_title', function ( $features, $plugin_name, $page_id ) {
229 if ( ! empty( $plugin_name ) && ( $plugin_name == WRIO_Plugin::app()->getPluginName() ) ) {
230 return __( "ROBIN IMAGE OPTIMIZER PRO", 'robin-image-optimizer' );
231 }
232
233 return $features;
234 }, 20, 3 );
235
236 /**
237 * Заменяем премиум возможности в рекламном виджете
238 *
239 * @param array $features
240 * @param string $plugin_name
241 * @param string $page_id
242 */
243 add_filter( 'wbcr/clearfy/pages/suggetion_features', function ( $features, $plugin_name, $page_id ) {
244 if ( ! empty( $plugin_name ) && ( $plugin_name == WRIO_Plugin::app()->getPluginName() ) ) {
245 $upgrade_feature = [];
246 $upgrade_feature[] = __( 'Automatic convertation in Webp', 'robin-image-optimizer' );
247 $upgrade_feature[] = __( 'You can optimize custom folders', 'robin-image-optimizer' );
248 $upgrade_feature[] = __( 'Support Nextgen gallery', 'robin-image-optimizer' );
249 $upgrade_feature[] = __( 'Multisite support', 'robin-image-optimizer' );
250 $upgrade_feature[] = __( 'Fast optimization servers', 'robin-image-optimizer' );
251 $upgrade_feature[] = __( 'No ads', 'robin-image-optimizer' );
252 $upgrade_feature[] = __( 'Best support', 'robin-image-optimizer' );
253
254 return $upgrade_feature;
255 }
256
257 return $features;
258 }, 20, 3 );
259
260 /**
261 * Заменяем премиум возможности в рекламном виджете
262 *
263 * @param array $messages
264 * @param string $type
265 * @param string $plugin_name
266 */
267 add_filter( 'wbcr/factory/premium/notice_text', function ( $text, $type, $plugin_name ) {
268 if ( WRIO_Plugin::app()->getPluginName() != $plugin_name ) {
269 return $text;
270 }
271
272 $license_page_url = WRIO_Plugin::app()->getPluginPageUrl( 'rio_license' );
273
274 if ( 'need_activate_license' == $type ) {
275 return sprintf( __( '<a href="%s">License activation</a> required. A license is required to get premium plugin updates, as well as to get additional services.', 'robin-image-optimizer' ), $license_page_url );
276 } else if ( 'need_renew_license' == $type ) {
277 return sprintf( __( 'Your <a href="%s">license</a> has expired. You can no longer get premium plugin updates, premium support and your access to Webcraftic services has been suspended.', 'robin-image-optimizer' ), $license_page_url );
278 }
279
280 return $text;
281 }, 10, 3 );
282
283
284
285