PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | pages/page-mainwp-updates.php +2629 -2269 5.0 → 6.2.1 View file →
@@ -6,2438 +6,2798 @@
6 6 */
7 7
8 8 namespace MainWP\Dashboard;
9 9
10 +// Exit if accessed directly.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit;
13 +}
14 +
10 15 /**
11 16 * Class MainWP_Updates
12 17 *
13 18 * @package MainWP\Dashboard
14 19 */
15 -class MainWP_Updates {
20 +class MainWP_Updates { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16 21
17 - /**
18 - * User can ignore updates.
19 - *
20 - * @var bool $user_can_ignore_updates User can ignore updates.
21 - */
22 - public static $user_can_ignore_updates = null;
22 + /**
23 + * User can ignore updates.
24 + *
25 + * @var bool $user_can_ignore_updates User can ignore updates.
26 + */
27 + public static $user_can_ignore_updates = null;
23 28
24 - /**
25 - * User can update translations.
26 - *
27 - * @var bool $user_can_update_trans User can update translations.
28 - */
29 - public static $user_can_update_trans = null;
29 + /**
30 + * User can update translations.
31 + *
32 + * @var bool $user_can_update_trans User can update translations.
33 + */
34 + public static $user_can_update_trans = null;
30 35
31 - /**
32 - * User can update WordPress core files.
33 - *
34 - * @var bool $user_can_update_wp User can update WordPress core files.
35 - */
36 - public static $user_can_update_wp = null;
36 + /**
37 + * User can update WordPress core files.
38 + *
39 + * @var bool $user_can_update_wp User can update WordPress core files.
40 + */
41 + public static $user_can_update_wp = null;
37 42
38 - /**
39 - * User can update themes.
40 - *
41 - * @var bool $user_can_update_themes User can update themes.
42 - */
43 - public static $user_can_update_themes = null;
43 + /**
44 + * User can update themes.
45 + *
46 + * @var bool $user_can_update_themes User can update themes.
47 + */
48 + public static $user_can_update_themes = null;
44 49
45 - /**
46 - * User can update plugins.
47 - *
48 - * @var bool $user_can_update_plugins User can update plugins.
49 - */
50 - public static $user_can_update_plugins = null;
50 + /**
51 + * User can update plugins.
52 + *
53 + * @var bool $user_can_update_plugins User can update plugins.
54 + */
55 + public static $user_can_update_plugins = null;
51 56
52 - /**
53 - * Placeholder for continue selector.
54 - *
55 - * @var string $continue_selector Placeholder for continue selector.
56 - */
57 - public static $continue_selector = '';
57 + /**
58 + * Placeholder for continue selector.
59 + *
60 + * @var string $continue_selector Placeholder for continue selector.
61 + */
62 + public static $continue_selector = '';
58 63
59 - /**
60 - * Placeholder for continue update.
61 - *
62 - * @var string $continue_update Placeholder for continue update.
63 - */
64 - public static $continue_update = '';
64 + /**
65 + * Placeholder for continue update.
66 + *
67 + * @var string $continue_update Placeholder for continue update.
68 + */
69 + public static $continue_update = '';
65 70
66 - /**
67 - * Placeholder for continue update slug.
68 - *
69 - * @var string $continue_update_slug Placeholder for continue update slug.
70 - */
71 - public static $continue_update_slug = '';
71 + /**
72 + * Placeholder for continue update slug.
73 + *
74 + * @var string $continue_update_slug Placeholder for continue update slug.
75 + */
76 + public static $continue_update_slug = '';
72 77
73 - /**
74 - * Public static varable to hold Subpages information.
75 - *
76 - * @var array $subPages
77 - */
78 - public static $subPages;
78 + /**
79 + * Cached ignored updates counts.
80 + *
81 + * @var array $ignored_updates_counts Cached ignored updates counts.
82 + */
83 + public static $ignored_updates_counts = array();
79 84
80 - /**
81 - * Current page.
82 - *
83 - * @static
84 - * @var string $page Current page.
85 - */
86 - public static $page;
85 + /**
86 + * Public static varable to hold Subpages information.
87 + *
88 + * @var array $subPages
89 + */
90 + public static $subPages;
87 91
88 - /**
89 - * Gets Class Name.
90 - *
91 - * @return object
92 - */
93 - public static function get_class_name() {
94 - return __CLASS__;
95 - }
92 + /**
93 + * Current page.
94 + *
95 + * @static
96 + * @var string $page Current page.
97 + */
98 + public static $page;
96 99
97 - /**
98 - * Instantiates MainWP Updates Page.
99 - *
100 - * @uses \MainWP\Dashboard\MainWP_Post::get_class_name()
101 - */
102 - public static function init() {
103 - /**
104 - * This hook allows you to render the Post page header via the 'mainwp-pageheader-updates' action.
105 - *
106 - * This hook is normally used in the same context of 'mainwp-getsubpages-updates'
107 - *
108 - * @see \MainWP_Updates::render_header
109 - */
110 - add_action( 'mainwp-pageheader-updates', array( MainWP_Post::get_class_name(), 'render_header' ) );
100 + /**
101 + * Gets Class Name.
102 + *
103 + * @return object
104 + */
105 + public static function get_class_name() {
106 + return __CLASS__;
107 + }
111 108
112 - /**
113 - * This hook allows you to render the Updates page footer via the 'mainwp-pagefooter-updates' action.
114 - *
115 - * This hook is normally used in the same context of 'mainwp-getsubpages-updates'
116 - *
117 - * @see \MainWP_Updates::render_footer
118 - */
119 - add_action( 'mainwp-pagefooter-updates', array( MainWP_Post::get_class_name(), 'render_footer' ) );
109 + /**
110 + * Instantiates MainWP Updates Page.
111 + *
112 + * @uses \MainWP\Dashboard\MainWP_Post::get_class_name()
113 + */
114 + public static function init() {
115 + /**
116 + * This hook allows you to render the Post page header via the 'mainwp-pageheader-updates' action.
117 + *
118 + * This hook is normally used in the same context of 'mainwp-getsubpages-updates'
119 + *
120 + * @see \MainWP_Updates::render_header
121 + */
122 + add_action( 'mainwp-pageheader-updates', array( MainWP_Post::get_class_name(), 'render_header' ) );
120 123
121 - add_action( 'mainwp_help_sidebar_content', array( self::get_class_name(), 'mainwp_help_content' ) );
122 - }
124 + /**
125 + * This hook allows you to render the Updates page footer via the 'mainwp-pagefooter-updates' action.
126 + *
127 + * This hook is normally used in the same context of 'mainwp-getsubpages-updates'
128 + *
129 + * @see \MainWP_Updates::render_footer
130 + */
131 + add_action( 'mainwp-pagefooter-updates', array( MainWP_Post::get_class_name(), 'render_footer' ) );
123 132
124 - /**
125 - * Renders init updates menu.
126 - *
127 - * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
128 - */
129 - public static function init_menu() {
130 - self::init_left_menu( self::$subPages );
131 - add_action( 'load-' . self::$page, array( self::get_class_name(), 'on_load_page' ) );
132 - }
133 + add_action( 'mainwp_help_sidebar_content', array( static::get_class_name(), 'mainwp_help_content' ) );
134 + add_action( 'admin_init', array( static::get_class_name(), 'admin_init' ) );
135 + }
133 136
134 - /**
135 - * Initiates Updates menu.
136 - *
137 - * @param array $subPages Sub pages array.
138 - *
139 - * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
140 - * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
141 - * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
142 - */
143 - public static function init_left_menu( $subPages = array() ) {
144 - self::$page = add_submenu_page(
145 - 'mainwp_tab',
146 - __( 'Updates', 'mainwp' ),
147 - '<span id="mainwp-Updates">' . esc_html__( 'Updates', 'mainwp' ) . '</span>',
148 - 'read',
149 - 'UpdatesManage',
150 - array(
151 - self::get_class_name(),
152 - 'render',
153 - )
154 - );
137 + /**
138 + * Init method.
139 + */
140 + public static function admin_init() {
141 + static::handle_post_staging_sites_view();
142 + }
155 143
156 - $updates_count = MainWP_Common_Handler::instance()->sites_available_updates_count();
144 + /**
145 + * Renders init updates menu.
146 + *
147 + * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
148 + */
149 + public static function init_menu() {
150 + static::init_left_menu( static::$subPages );
151 + add_action( 'load-' . static::$page, array( static::get_class_name(), 'on_load_page' ) );
152 + }
157 153
158 - $label_color_plugins = '';
159 - $label_color_themes = '';
160 - $label_color_wp = '';
161 - $label_color_translations = '';
162 - $label_color_total = '';
154 + /**
155 + * Initiates Updates menu.
156 + *
157 + * @param array $subPages Sub pages array.
158 + *
159 + * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
160 + * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
161 + * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
162 + */
163 + public static function init_left_menu( $subPages = array() ) {
164 + static::$page = add_submenu_page(
165 + 'mainwp_tab',
166 + __( 'Updates', 'mainwp' ),
167 + '<span id="mainwp-Updates">' . esc_html__( 'Updates', 'mainwp' ) . '</span>',
168 + 'read',
169 + 'UpdatesManage',
170 + array(
171 + static::get_class_name(),
172 + 'render',
173 + )
174 + );
163 175
164 - if ( isset( $updates_count['plugins'] ) && 0 < $updates_count['plugins'] ) {
165 - $label_color_plugins = ' blue ';
166 - }
176 + $updates_count = MainWP_Common_Handler::instance()->sites_available_updates_count();
167 177
168 - if ( isset( $updates_count['wp'] ) && 0 < $updates_count['wp'] ) {
169 - $label_color_wp = ' blue ';
170 - }
178 + $label_color_plugins = '';
179 + $label_color_themes = '';
180 + $label_color_wp = '';
181 + $label_color_translations = '';
182 + $label_color_total = '';
171 183
172 - if ( isset( $updates_count['themes'] ) && 0 < $updates_count['themes'] ) {
173 - $label_color_themes = ' blue ';
174 - }
184 + if ( isset( $updates_count['plugins'] ) && 0 < $updates_count['plugins'] ) {
185 + $label_color_plugins = 'green';
186 + }
175 187
176 - if ( isset( $updates_count['translations'] ) && 0 < $updates_count['translations'] ) {
177 - $label_color_translations = ' blue ';
178 - }
188 + if ( isset( $updates_count['wp'] ) && 0 < $updates_count['wp'] ) {
189 + $label_color_wp = 'green';
190 + }
179 191
180 - if ( isset( $updates_count['total'] ) && 0 < $updates_count['total'] ) {
181 - $label_color_total = ' blue ';
182 - }
192 + if ( isset( $updates_count['themes'] ) && 0 < $updates_count['themes'] ) {
193 + $label_color_themes = 'green';
194 + }
183 195
184 - MainWP_Menu::add_left_menu(
185 - array(
186 - 'title' => esc_html__( 'Updates', 'mainwp' ) . ' <span class="ui ' . $label_color_total . ' mini label">' . intval( $updates_count['total'] ) . '</span>',
187 - 'parent_key' => 'managesites',
188 - 'slug' => 'UpdatesManage',
189 - 'href' => 'admin.php?page=UpdatesManage',
190 - 'icon' => '<i class="sync icon"></i>',
191 - 'desc' => 'Manage updates on your child sites',
192 - 'leftsub_order' => 4,
193 - ),
194 - 1
195 - );
196 + if ( isset( $updates_count['translations'] ) && 0 < $updates_count['translations'] ) {
197 + $label_color_translations = 'green';
198 + }
196 199
197 - $show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
200 + if ( isset( $updates_count['total'] ) && 0 < $updates_count['total'] ) {
201 + $label_color_total = 'green';
202 + }
198 203
199 - if ( $show_language_updates ) {
204 + MainWP_Menu::add_left_menu(
205 + array(
206 + 'title' => esc_html__( 'Updates', 'mainwp' ) . ' <span class="ui ' . $label_color_total . ' mini label">' . intval( $updates_count['total'] ) . '</span>',
207 + 'parent_key' => 'managesites',
208 + 'slug' => 'UpdatesManage',
209 + 'href' => 'admin.php?page=UpdatesManage',
210 + 'icon' => '<i class="sync icon"></i>',
211 + 'desc' => 'Manage updates on your child sites',
212 + 'leftsub_order' => 4,
213 + ),
214 + 1
215 + );
200 216
201 - $init_sub_subleftmenu = array(
202 - array(
203 - 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' label">' . intval( $updates_count['plugins'] ) . '</span>',
204 - 'parent_key' => 'UpdatesManage',
205 - 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates',
206 - 'slug' => 'UpdatesManage',
207 - 'right' => '',
208 - ),
209 - array(
210 - 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' label">' . intval( $updates_count['themes'] ) . '</span>',
211 - 'parent_key' => 'UpdatesManage',
212 - 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates',
213 - 'slug' => 'UpdatesManage',
214 - 'right' => '',
215 - ),
216 - array(
217 - 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' label">' . intval( $updates_count['wp'] ) . '</span>',
218 - 'parent_key' => 'UpdatesManage',
219 - 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates',
220 - 'slug' => 'UpdatesManage&tab=wordpress-updates',
221 - 'right' => '',
222 - ),
223 - array(
224 - 'title' => esc_html__( 'Translation', 'mainwp' ) . ' <span class="ui ' . $label_color_translations . ' label">' . intval( $updates_count['translations'] ) . '</span>',
225 - 'parent_key' => 'UpdatesManage',
226 - 'href' => 'admin.php?page=UpdatesManage&tab=translations-updates',
227 - 'slug' => 'UpdatesManage&tab=translations-updates',
228 - 'right' => '',
229 - ),
217 + $init_sub_subleftmenu = array(
218 + array(
219 + 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' tiny label">' . intval( $updates_count['plugins'] ) . '</span>',
220 + 'parent_key' => 'UpdatesManage',
221 + 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates',
222 + 'slug' => 'UpdatesManage',
223 + 'right' => '',
224 + ),
225 + array(
226 + 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' tiny label">' . intval( $updates_count['themes'] ) . '</span>',
227 + 'parent_key' => 'UpdatesManage',
228 + 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates',
229 + 'slug' => 'UpdatesManage',
230 + 'right' => '',
231 + ),
232 + array(
233 + 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' tiny label">' . intval( $updates_count['wp'] ) . '</span>',
234 + 'parent_key' => 'UpdatesManage',
235 + 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates',
236 + 'slug' => 'UpdatesManage&tab=wordpress-updates',
237 + 'right' => '',
238 + 'active_params' => array( 'tab' => 'updates-ignore' ),
239 + ),
240 + array(
241 + 'title' => esc_html__( 'Updates Ignore', 'mainwp' ),
242 + 'parent_key' => 'UpdatesManage',
243 + 'slug' => 'UpdatesManage&tab=updates-ignore',
244 + 'href' => '', // fix warning.
245 + 'menu_hidden' => true,
246 + ),
247 + );
230 248
231 - );
232 - } else {
233 - $init_sub_subleftmenu = array(
234 - array(
235 - 'title' => esc_html__( 'Plugins', 'mainwp' ) . ' <span class="ui ' . $label_color_plugins . ' label">' . intval( $updates_count['plugins'] ) . '</span>',
236 - 'parent_key' => 'UpdatesManage',
237 - 'href' => 'admin.php?page=UpdatesManage&tab=plugins-updates',
238 - 'slug' => 'UpdatesManage',
239 - 'right' => '',
240 - ),
241 - array(
242 - 'title' => esc_html__( 'Themes', 'mainwp' ) . ' <span class="ui ' . $label_color_themes . ' label">' . intval( $updates_count['themes'] ) . '</span>',
243 - 'parent_key' => 'UpdatesManage',
244 - 'href' => 'admin.php?page=UpdatesManage&tab=themes-updates',
245 - 'slug' => 'UpdatesManage',
246 - 'right' => '',
247 - ),
248 - array(
249 - 'title' => esc_html__( 'WordPress', 'mainwp' ) . ' <span class="ui ' . $label_color_wp . ' label">' . intval( $updates_count['wp'] ) . '1</span>',
250 - 'parent_key' => 'UpdatesManage',
251 - 'href' => 'admin.php?page=UpdatesManage&tab=wordpress-updates',
252 - 'slug' => 'UpdatesManage&tab=wordpress-updates',
253 - 'right' => '',
254 - ),
255 - );
256 - }
249 + $show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
250 + if ( $show_language_updates ) {
251 + $init_sub_subleftmenu[] = array(
252 + 'title' => esc_html__( 'Translation', 'mainwp' ) . ' <span class="ui ' . $label_color_translations . ' tiny label">' . intval( $updates_count['translations'] ) . '</span>',
253 + 'parent_key' => 'UpdatesManage',
254 + 'href' => 'admin.php?page=UpdatesManage&tab=translations-updates',
255 + 'slug' => 'UpdatesManage&tab=translations-updates',
256 + 'right' => '',
257 + );
258 + }
257 259
258 - $init_sub_subleftmenu = apply_filters( 'mainwp_sub_leftmenu_updates', $init_sub_subleftmenu );
260 + $init_sub_subleftmenu = apply_filters( 'mainwp_sub_leftmenu_updates', $init_sub_subleftmenu );
259 261
260 - MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'UpdatesManage', 'UpdatesManage' );
262 + MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'UpdatesManage', 'UpdatesManage' );
261 263
262 - foreach ( $init_sub_subleftmenu as $item ) {
263 - if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
264 - continue;
265 - }
266 - MainWP_Menu::add_left_menu( $item, 2 );
267 - }
268 - }
264 + foreach ( $init_sub_subleftmenu as $item ) {
265 + if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
266 + continue;
267 + }
268 + MainWP_Menu::add_left_menu( $item, 2 );
269 + }
270 + }
269 271
270 - /**
271 - * Method on_load_page()
272 - *
273 - * Run on page load.
274 - */
275 - public static function on_load_page() {
276 - add_filter( 'mainwp_header_actions_right', array( self::get_class_name(), 'screen_options' ), 10, 2 );
277 - }
272 + /**
273 + * Method on_load_page()
274 + *
275 + * Run on page load.
276 + */
277 + public static function on_load_page() {
278 + add_filter( 'mainwp_header_actions_right', array( static::get_class_name(), 'screen_options' ), 10, 2 );
279 + }
278 280
279 - /**
280 - * Method screen_options()
281 - *
282 - * Create Page Settings button.
283 - *
284 - * @param mixed $input Page Settings button HTML.
285 - *
286 - * @return mixed Page Settings button.
287 - */
288 - public static function screen_options( $input ) {
289 - return $input .
290 - '<a class="ui button basic icon" onclick="mainwp_manage_updates_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '">
291 - <i class="cog icon"></i>
292 - </a>';
293 - }
281 + /**
282 + * Method screen_options()
283 + *
284 + * Create Page Settings button.
285 + *
286 + * @param mixed $input Page Settings button HTML.
287 + *
288 + * @return mixed Page Settings button.
289 + */
290 + public static function screen_options( $input ) {
291 + return $input .
292 + '<a class="ui button basic icon" onclick="mainwp_manage_updates_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '">
293 + <i class="cog icon"></i>
294 + </a>';
295 + }
294 296
295 - /**
296 - * Sets the MainWP Update page page title and pass it off to method MainWP_UI::render_top_header().
297 - *
298 - * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
299 - */
300 - public static function render_header() {
297 + /**
298 + * Sets the MainWP Update page page title and pass it off to method MainWP_UI::render_top_header().
299 + *
300 + * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
301 + */
302 + public static function render_header( $current_tab = '' ) {
301 303
302 - $params = array(
303 - 'title' => esc_html__( 'Available Updates', 'mainwp' ),
304 - );
304 + $title = esc_html__( 'Available Updates', 'mainwp' );
305 305
306 - MainWP_UI::render_top_header( $params );
307 - }
306 + if ( 'abandoned-plugins' === $current_tab ) {
307 + $title = esc_html__( 'Abandoned Plugins', 'mainwp' );
308 + } elseif ( 'abandoned-themes' === $current_tab ) {
309 + $title = esc_html__( 'Abandoned Themes', 'mainwp' );
310 + }
308 311
309 - /**
310 - * Closes the page container.
311 - */
312 - public static function render_footer() {
313 - echo '</div>';
314 - }
312 + $params = array(
313 + 'title' => $title,
314 + );
315 315
316 - /**
317 - * Generates individual site overview page link.
318 - *
319 - * @param object $website The site object.
320 - * @param bool $echo_out Either echo or not.
321 - *
322 - * @return string Dashboard link.
323 - */
324 - public static function render_site_link_dashboard( $website, $echo_out = true ) {
325 - $lnk = '<a href="' . esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ) . '" data-inverted="" data-tooltip="' . esc_html__( 'Visit this dashboard.', 'mainwp' ) . '">' . stripslashes( $website->name ) . '</a>';
326 - if ( $echo_out ) {
327 - echo $lnk; // phpcs:ignore WordPress.Security.EscapeOutput
328 - } else {
329 - return $lnk;
330 - }
331 - }
316 + MainWP_UI::render_top_header( $params );
317 + }
332 318
333 - /**
334 - * Checks if the current user has permission to uignore updates.
335 - *
336 - * @return bool Whether user can ignore updates or not.
337 - */
338 - public static function user_can_ignore_updates() {
339 - if ( null === self::$user_can_ignore_updates ) {
340 - self::$user_can_ignore_updates = mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' );
341 - }
342 - return self::$user_can_ignore_updates;
343 - }
319 + /**
320 + * Closes the page container.
321 + */
322 + public static function render_footer() {
323 + echo '</div>';
324 + }
344 325
345 - /**
346 - * Checks if the current user has permission to update translations.
347 - *
348 - * @return bool Whether user can update translations or not.
349 - */
350 - public static function user_can_update_trans() {
351 - if ( null === self::$user_can_update_trans ) {
352 - self::$user_can_update_trans = mainwp_current_user_have_right( 'dashboard', 'update_translations' );
353 - }
354 - return self::$user_can_update_trans;
355 - }
326 + /**
327 + * Generates individual site overview page link.
328 + *
329 + * @param object $website The site object.
330 + * @param bool $echo_out Either echo or not.
331 + *
332 + * @return string Dashboard link.
333 + */
334 + public static function render_site_link_dashboard( $website, $echo_out = true ) {
335 + $lnk = '<a href="' . esc_url( admin_url( 'admin.php?page=managesites&dashboard=' . $website->id ) ) . '" data-inverted="" data-tooltip="' . esc_html__( 'Visit this dashboard.', 'mainwp' ) . '">' . stripslashes( $website->name ) . '</a>';
336 + if ( $echo_out ) {
337 + echo $lnk; // phpcs:ignore WordPress.Security.EscapeOutput
338 + } else {
339 + return $lnk;
340 + }
341 + }
356 342
357 - /**
358 - * Checks if the current user has permission to update WordPress core files.
359 - *
360 - * @return bool Whether user can update WordPress or not.
361 - */
362 - public static function user_can_update_wp() {
363 - if ( null === self::$user_can_update_wp ) {
364 - self::$user_can_update_wp = mainwp_current_user_have_right( 'dashboard', 'update_wordpress' );
365 - }
366 - return self::$user_can_update_wp;
367 - }
343 + /**
344 + * Checks if the current user has permission to uignore updates.
345 + *
346 + * @return bool Whether user can ignore updates or not.
347 + */
348 + public static function user_can_ignore_updates() {
349 + if ( null === static::$user_can_ignore_updates ) {
350 + static::$user_can_ignore_updates = \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' );
351 + }
352 + return static::$user_can_ignore_updates;
353 + }
368 354
369 - /**
370 - * Checks if the current user has permission to update themes.
371 - *
372 - * @return bool Whether user can update themes or not.
373 - */
374 - public static function user_can_update_themes() {
375 - if ( null === self::$user_can_update_themes ) {
376 - self::$user_can_update_themes = mainwp_current_user_have_right( 'dashboard', 'update_themes' );
377 - }
378 - return self::$user_can_update_themes;
379 - }
355 + /**
356 + * Checks if the current user has permission to update translations.
357 + *
358 + * @return bool Whether user can update translations or not.
359 + */
360 + public static function user_can_update_trans() {
361 + if ( null === static::$user_can_update_trans ) {
362 + static::$user_can_update_trans = \mainwp_current_user_can( 'dashboard', 'update_translations' );
363 + }
364 + return static::$user_can_update_trans;
365 + }
380 366
381 - /**
382 - * Checks if the current user has permission to update plugins.
383 - *
384 - * @return bool Whether user can update plugins or not.
385 - */
386 - public static function user_can_update_plugins() {
387 - if ( null === self::$user_can_update_plugins ) {
388 - self::$user_can_update_plugins = mainwp_current_user_have_right( 'dashboard', 'update_plugins' );
389 - }
390 - return self::$user_can_update_plugins;
391 - }
367 + /**
368 + * Checks if the current user has permission to update WordPress core files.
369 + *
370 + * @return bool Whether user can update WordPress or not.
371 + */
372 + public static function user_can_update_wp() {
373 + if ( null === static::$user_can_update_wp ) {
374 + static::$user_can_update_wp = \mainwp_current_user_can( 'dashboard', 'update_wordpress' );
375 + }
376 + return static::$user_can_update_wp;
377 + }
392 378
393 - /**
394 - * Renders updates page.
395 - *
396 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
397 - * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_current_user()
398 - * @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_group_id()
399 - * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
400 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
401 - * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
402 - * @uses \MainWP\Dashboard\MainWP_Utility::array_sort()
403 - */
404 - public static function render() { // phpcs:ignore Generic.Metrics.CyclomaticComplexity -- current complexity is the only way to achieve desired results, pull request solutions appreciated.
405 - $websites = self::get_sites_for_current_user();
406 - $userExtension = MainWP_DB_Common::instance()->get_user_extension();
407 - $site_view = (int) $userExtension->site_view;
379 + /**
380 + * Checks if the current user has permission to update themes.
381 + *
382 + * @return bool Whether user can update themes or not.
383 + */
384 + public static function user_can_update_themes() {
385 + if ( null === static::$user_can_update_themes ) {
386 + static::$user_can_update_themes = \mainwp_current_user_can( 'dashboard', 'update_themes' );
387 + }
388 + return static::$user_can_update_themes;
389 + }
408 390
409 - $site_offset_for_groups = array();
410 - $all_groups = array();
411 - $sites_in_groups = array();
412 - $all_groups_sites = array();
391 + /**
392 + * Checks if the current user has permission to update plugins.
393 + *
394 + * @return bool Whether user can update plugins or not.
395 + */
396 + public static function user_can_update_plugins() {
397 + if ( null === static::$user_can_update_plugins ) {
398 + static::$user_can_update_plugins = \mainwp_current_user_can( 'dashboard', 'update_plugins' );
399 + }
400 + return static::$user_can_update_plugins;
401 + }
413 402
414 - if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
415 - $groups = MainWP_DB_Common::instance()->get_groups_for_current_user();
416 - foreach ( $groups as $group ) {
417 - $all_groups[ $group->id ] = $group->name;
418 - }
419 - foreach ( $all_groups as $group_id => $group_name ) {
420 - $all_groups_sites[ $group_id ] = array();
421 - $group_sites = MainWP_DB::instance()->get_websites_by_group_id( $group_id );
422 - foreach ( $group_sites as $site ) {
423 - if ( ! isset( $sites_in_groups[ $site->id ] ) ) {
424 - $sites_in_groups[ $site->id ] = 1;
425 - }
426 - $all_groups_sites[ $group_id ][] = $site->id;
427 - }
428 - unset( $group_sites );
429 - }
403 + /**
404 + * Renders updates page.
405 + *
406 + * @param string $abandoned_tab Render abandoned plugins|themes tab, abandoned_plugins|abandoned_themes.
407 + *
408 + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
409 + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_current_user()
410 + * @uses \MainWP\Dashboard\MainWP_DB::get_websites_by_group_id()
411 + * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
412 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
413 + * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
414 + * @uses \MainWP\Dashboard\MainWP_Utility::array_sort()
415 + */
416 + public static function render( $abandoned_tab = '' ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity -- NOSONAR - current complexity is the only way to achieve desired results, pull request solutions appreciated.
430 417
431 - $sites_not_in_groups = array();
432 - $pos = 0;
433 - MainWP_DB::data_seek( $websites, 0 );
434 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
435 - $site_offset_for_groups[ $website->id ] = $pos;
436 - ++$pos;
437 - if ( ! isset( $sites_in_groups[ $website->id ] ) ) {
438 - $sites_not_in_groups[] = $website->id;
439 - }
440 - }
418 + static::handle_limit_sites();
441 419
442 - if ( 0 < count( $sites_not_in_groups ) ) {
443 - $all_groups_sites[0] = $sites_not_in_groups;
444 - $all_groups[0] = esc_html__( 'Others', 'mainwp' );
445 - }
446 - }
420 + $websites = static::get_sites_for_current_user();
421 + $userExtension = MainWP_DB_Common::instance()->get_user_extension();
422 + $site_view = (int) $userExtension->site_view;
447 423
448 - $decodedDismissedPlugins = json_decode( $userExtension->dismissed_plugins, true );
449 - $decodedDismissedThemes = json_decode( $userExtension->dismissed_themes, true );
424 + $site_offset_for_groups = array();
425 + $all_groups = array();
426 + $sites_in_groups = array();
427 + $all_groups_sites = array();
450 428
451 - $total_wp_upgrades = 0;
452 - $total_plugin_upgrades = 0;
453 - $total_translation_upgrades = 0;
454 - $total_theme_upgrades = 0;
455 - $total_sync_errors = 0;
456 - $total_plugins_outdate = 0;
457 - $total_themes_outdate = 0;
429 + if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
430 + $groups = MainWP_DB_Common::instance()->get_groups_for_current_user();
431 + foreach ( $groups as $group ) {
432 + $all_groups[ $group->id ] = $group->name;
433 + }
434 + foreach ( $all_groups as $group_id => $group_name ) {
435 + $all_groups_sites[ $group_id ] = array();
436 + $group_sites = MainWP_DB::instance()->get_websites_by_group_id( $group_id );
437 + foreach ( $group_sites as $site ) {
438 + if ( ! isset( $sites_in_groups[ $site->id ] ) ) {
439 + $sites_in_groups[ $site->id ] = 1;
440 + }
441 + $all_groups_sites[ $group_id ][] = $site->id;
442 + }
443 + unset( $group_sites );
444 + }
458 445
459 - $allTranslations = array();
460 - $translationsInfo = array();
461 - $allPlugins = array();
462 - $pluginsInfo = array();
463 - $allThemes = array();
464 - $themesInfo = array();
446 + $sites_not_in_groups = array();
447 + $pos = 0;
448 + MainWP_DB::data_seek( $websites, 0 );
449 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
450 + $site_offset_for_groups[ $website->id ] = $pos;
451 + ++$pos;
452 + if ( ! isset( $sites_in_groups[ $website->id ] ) ) {
453 + $sites_not_in_groups[] = $website->id;
454 + }
455 + }
465 456
466 - $allPluginsOutdate = array();
467 - $allThemesOutdate = array();
457 + if ( ! empty( $sites_not_in_groups ) ) {
458 + $all_groups_sites[0] = $sites_not_in_groups;
459 + $all_groups[0] = esc_html__( 'Others', 'mainwp' );
460 + }
461 + }
468 462
469 - MainWP_DB::data_seek( $websites, 0 );
463 + $decodedDismissedPlugins = ! empty( $userExtension->dismissed_plugins ) ? json_decode( $userExtension->dismissed_plugins, true ) : array();
464 + $decodedDismissedThemes = ! empty( $userExtension->dismissed_themes ) ? json_decode( $userExtension->dismissed_themes, true ) : array();
465 + $decodedDismissedCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
470 466
471 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
467 + $total_wp_upgrades = 0;
468 + $total_plugin_upgrades = 0;
469 + $total_translation_upgrades = 0;
470 + $total_theme_upgrades = 0;
471 + $total_sync_errors = 0;
472 + $total_plugins_outdate = 0;
473 + $total_themes_outdate = 0;
472 474
473 - $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' );
474 - $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array();
475 + $allTranslations = array();
476 + $translationsInfo = array();
477 + $allPlugins = array();
478 + $pluginsInfo = array();
479 + $allThemes = array();
480 + $themesInfo = array();
475 481
476 - if ( $website->is_ignoreCoreUpdates ) {
477 - $wp_upgrades = array();
478 - }
482 + $allPluginsOutdate = array();
483 + $allThemesOutdate = array();
479 484
480 - if ( is_array( $wp_upgrades ) && 0 < count( $wp_upgrades ) ) {
481 - ++$total_wp_upgrades;
482 - }
485 + MainWP_DB::data_seek( $websites, 0 );
483 486
484 - $translation_upgrades = json_decode( $website->translation_upgrades, true );
487 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
485 488
486 - $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
487 - if ( $website->is_ignorePluginUpdates ) {
488 - $plugin_upgrades = array();
489 - }
489 + $wp_upgrades = ! empty( $website->wp_upgrades ) ? json_decode( $website->wp_upgrades, true ) : array();
490 + $ignored_core_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array();
490 491
491 - $theme_upgrades = json_decode( $website->theme_upgrades, true );
492 - if ( $website->is_ignoreThemeUpdates ) {
493 - $theme_upgrades = array();
494 - }
492 + if ( $website->is_ignoreCoreUpdates || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $decodedDismissedCores, 'core' ) ) {
493 + $wp_upgrades = array();
494 + }
495 495
496 - $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
497 - $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
496 + if ( is_array( $wp_upgrades ) && ! empty( $wp_upgrades ) ) {
497 + ++$total_wp_upgrades;
498 + }
498 499
499 - if ( is_array( $decodedPremiumUpgrades ) ) {
500 - foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
501 - $premiumUpgrade['premium'] = true;
500 + $translation_upgrades = json_decode( $website->translation_upgrades, true );
502 501
503 - if ( 'plugin' === $premiumUpgrade['type'] ) {
504 - if ( ! is_array( $plugin_upgrades ) ) {
505 - $plugin_upgrades = array();
506 - }
507 - if ( ! $website->is_ignorePluginUpdates ) {
508 - $premiumUpgrade = array_filter( $premiumUpgrade );
509 - if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
510 - $plugin_upgrades[ $crrSlug ] = array();
511 - }
512 - $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
513 - }
514 - } elseif ( 'theme' === $premiumUpgrade['type'] ) {
515 - if ( ! is_array( $theme_upgrades ) ) {
516 - $theme_upgrades = array();
517 - }
518 - if ( ! $website->is_ignoreThemeUpdates ) {
519 - $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
520 - }
521 - }
522 - }
523 - }
502 + if ( ! empty( $website->ignored_trans_updates ) ) {
503 + $translation_upgrades = array();
504 + }
524 505
525 - if ( is_array( $translation_upgrades ) ) {
526 - $total_translation_upgrades += count( $translation_upgrades );
527 - }
506 + $plugin_upgrades = json_decode( $website->plugin_upgrades, true );
507 + if ( $website->is_ignorePluginUpdates ) {
508 + $plugin_upgrades = array();
509 + }
528 510
529 - if ( is_array( $plugin_upgrades ) && ! $website->is_ignorePluginUpdates ) {
530 - $_ignored_plugins = json_decode( $website->ignored_plugins, true );
531 - if ( is_array( $_ignored_plugins ) ) {
532 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $_ignored_plugins );
533 - }
511 + $theme_upgrades = json_decode( $website->theme_upgrades, true );
512 + if ( $website->is_ignoreThemeUpdates ) {
513 + $theme_upgrades = array();
514 + }
534 515
535 - $_ignored_plugins = json_decode( $userExtension->ignored_plugins, true );
536 - if ( is_array( $_ignored_plugins ) ) {
537 - $plugin_upgrades = array_diff_key( $plugin_upgrades, $_ignored_plugins );
538 - }
516 + $decodedPremiumUpgrades = MainWP_DB::instance()->get_website_option( $website, 'premium_upgrades' );
517 + $decodedPremiumUpgrades = ! empty( $decodedPremiumUpgrades ) ? json_decode( $decodedPremiumUpgrades, true ) : array();
539 518
540 - $total_plugin_upgrades += count( $plugin_upgrades );
541 - }
519 + if ( is_array( $decodedPremiumUpgrades ) ) {
520 + foreach ( $decodedPremiumUpgrades as $crrSlug => $premiumUpgrade ) {
521 + $premiumUpgrade['premium'] = true;
542 522
543 - if ( is_array( $theme_upgrades ) ) {
544 - $_ignored_themes = json_decode( $website->ignored_themes, true );
545 - if ( is_array( $_ignored_themes ) ) {
546 - $theme_upgrades = array_diff_key( $theme_upgrades, $_ignored_themes );
547 - }
523 + if ( 'plugin' === $premiumUpgrade['type'] ) {
524 + if ( ! is_array( $plugin_upgrades ) ) {
525 + $plugin_upgrades = array();
526 + }
527 + if ( ! $website->is_ignorePluginUpdates ) {
528 + $premiumUpgrade = array_filter( $premiumUpgrade );
529 + if ( ! isset( $plugin_upgrades[ $crrSlug ] ) ) {
530 + continue; // to fix missing update name.
531 + }
532 + $plugin_upgrades[ $crrSlug ] = array_merge( $plugin_upgrades[ $crrSlug ], $premiumUpgrade );
533 + }
534 + } elseif ( 'theme' === $premiumUpgrade['type'] ) {
535 + if ( ! is_array( $theme_upgrades ) ) {
536 + $theme_upgrades = array();
537 + }
538 + if ( ! $website->is_ignoreThemeUpdates ) {
539 + $theme_upgrades[ $crrSlug ] = $premiumUpgrade;
540 + }
541 + }
542 + }
543 + }
548 544
549 - $_ignored_themes = json_decode( $userExtension->ignored_themes, true );
550 - if ( is_array( $_ignored_themes ) ) {
551 - $theme_upgrades = array_diff_key( $theme_upgrades, $_ignored_themes );
552 - }
545 + if ( is_array( $translation_upgrades ) ) {
546 + $total_translation_upgrades += count( $translation_upgrades );
547 + }
553 548
554 - $total_theme_upgrades += count( $theme_upgrades );
555 - }
549 + if ( is_array( $plugin_upgrades ) && ! $website->is_ignorePluginUpdates ) {
550 + $_ignored_plugins = json_decode( $website->ignored_plugins, true );
551 + if ( is_array( $_ignored_plugins ) ) {
552 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $_ignored_plugins );
553 + }
556 554
557 - $themesIgnoredAbandoned_perSites = array();
558 - $ignoredAbandoned_themes = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
559 - $ignoredAbandoned_themes = ! empty( $ignoredAbandoned_themes ) ? json_decode( $ignoredAbandoned_themes, true ) : array();
555 + $_ignored_plugins = json_decode( $userExtension->ignored_plugins, true );
556 + if ( is_array( $_ignored_plugins ) ) {
557 + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $_ignored_plugins );
558 + }
559 + $total_plugin_upgrades += count( $plugin_upgrades );
560 + }
560 561
561 - if ( is_array( $ignoredAbandoned_themes ) ) {
562 - $ignoredAbandoned_themes = array_filter( $ignoredAbandoned_themes );
563 - $themesIgnoredAbandoned_perSites = array_merge( $themesIgnoredAbandoned_perSites, $ignoredAbandoned_themes );
564 - }
562 + if ( is_array( $theme_upgrades ) ) {
563 + $_ignored_themes = json_decode( $website->ignored_themes, true );
564 + if ( is_array( $_ignored_themes ) ) {
565 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $_ignored_themes );
566 + }
565 567
566 - $ignoredAbandoned_plugins = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
567 - $ignoredAbandoned_plugins = ! empty( $ignoredAbandoned_plugins ) ? json_decode( $ignoredAbandoned_plugins, true ) : array();
568 + $_ignored_themes = json_decode( $userExtension->ignored_themes, true );
569 + if ( is_array( $_ignored_themes ) ) {
570 + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $_ignored_themes );
571 + }
568 572
569 - $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
570 - $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
573 + $total_theme_upgrades += count( $theme_upgrades );
574 + }
571 575
572 - $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
573 - $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
576 + $themesIgnoredAbandoned_perSites = array();
577 + $ignoredAbandoned_themes = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_dismissed' );
578 + $ignoredAbandoned_themes = ! empty( $ignoredAbandoned_themes ) ? json_decode( $ignoredAbandoned_themes, true ) : array();
574 579
575 - if ( is_array( $plugins_outdate ) ) {
576 - if ( is_array( $ignoredAbandoned_plugins ) ) {
577 - $plugins_outdate = array_diff_key( $plugins_outdate, $ignoredAbandoned_plugins );
578 - }
580 + if ( is_array( $ignoredAbandoned_themes ) ) {
581 + $ignoredAbandoned_themes = array_filter( $ignoredAbandoned_themes );
582 + $themesIgnoredAbandoned_perSites = array_merge( $themesIgnoredAbandoned_perSites, $ignoredAbandoned_themes );
583 + }
579 584
580 - if ( is_array( $decodedDismissedPlugins ) ) {
581 - $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
582 - }
585 + $ignoredAbandoned_plugins = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_dismissed' );
586 + $ignoredAbandoned_plugins = ! empty( $ignoredAbandoned_plugins ) ? json_decode( $ignoredAbandoned_plugins, true ) : array();
583 587
584 - $total_plugins_outdate += count( $plugins_outdate );
585 - }
588 + $plugins_outdate = MainWP_DB::instance()->get_website_option( $website, 'plugins_outdate_info' );
589 + $plugins_outdate = ! empty( $plugins_outdate ) ? json_decode( $plugins_outdate, true ) : array();
586 590
587 - if ( is_array( $themes_outdate ) ) {
588 - if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
589 - $themes_outdate = array_diff_key( $themes_outdate, $themesIgnoredAbandoned_perSites );
590 - }
591 + $themes_outdate = MainWP_DB::instance()->get_website_option( $website, 'themes_outdate_info' );
592 + $themes_outdate = ! empty( $themes_outdate ) ? json_decode( $themes_outdate, true ) : array();
591 593
592 - if ( is_array( $decodedDismissedThemes ) ) {
593 - $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
594 - }
594 + if ( is_array( $plugins_outdate ) ) {
595 + if ( is_array( $ignoredAbandoned_plugins ) ) {
596 + $plugins_outdate = array_diff_key( $plugins_outdate, $ignoredAbandoned_plugins );
597 + }
595 598
596 - $total_themes_outdate += count( $themes_outdate );
597 - }
599 + if ( is_array( $decodedDismissedPlugins ) ) {
600 + $plugins_outdate = array_diff_key( $plugins_outdate, $decodedDismissedPlugins );
601 + }
598 602
599 - if ( MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ) {
600 - if ( is_array( $translation_upgrades ) ) {
601 - foreach ( $translation_upgrades as $translation_upgrade ) {
602 - $slug = esc_html( $translation_upgrade['slug'] );
603 - if ( ! isset( $allTranslations[ $slug ] ) ) {
604 - $allTranslations[ $slug ] = array(
605 - 'name' => isset( $translation_upgrade['name'] ) ? esc_html( $translation_upgrade['name'] ) : $slug,
606 - 'cnt' => 1,
607 - );
608 - } else {
609 - ++$allTranslations[ $slug ]['cnt'];
610 - }
603 + $total_plugins_outdate += count( $plugins_outdate );
604 + }
611 605
612 - $translationsInfo[ $slug ] = array(
613 - 'name' => isset( $translation_upgrade['name'] ) ? esc_html( $translation_upgrade['name'] ) : $slug,
614 - 'slug' => $slug,
615 - 'version' => esc_html( $translation_upgrade['version'] ),
616 - );
617 - }
618 - }
606 + if ( is_array( $themes_outdate ) ) {
607 + if ( is_array( $themesIgnoredAbandoned_perSites ) ) {
608 + $themes_outdate = array_diff_key( $themes_outdate, $themesIgnoredAbandoned_perSites );
609 + }
619 610
620 - if ( is_array( $plugin_upgrades ) ) {
621 - foreach ( $plugin_upgrades as $slug => $plugin_upgrade ) {
622 - if ( ! isset( $allPlugins[ $slug ] ) ) {
623 - $allPlugins[ $slug ] = array(
624 - 'name' => esc_html( $plugin_upgrade['Name'] ),
625 - 'cnt' => 1,
626 - );
627 - } else {
628 - ++$allPlugins[ $slug ]['cnt'];
629 - }
611 + if ( is_array( $decodedDismissedThemes ) ) {
612 + $themes_outdate = array_diff_key( $themes_outdate, $decodedDismissedThemes );
613 + }
630 614
631 - $pluginsInfo[ $slug ] = array(
632 - 'name' => esc_html( $plugin_upgrade['Name'] ),
633 - 'slug' => isset( $plugin_upgrade['update']['slug'] ) ? esc_html( $plugin_upgrade['update']['slug'] ) : '',
634 - 'premium' => ( isset( $plugin_upgrade['premium'] ) ? esc_html( $plugin_upgrade['premium'] ) : 0 ),
635 - 'PluginURI' => esc_html( $plugin_upgrade['PluginURI'] ),
636 - );
637 - }
638 - }
615 + $total_themes_outdate += count( $themes_outdate );
616 + }
639 617
640 - if ( is_array( $theme_upgrades ) ) {
641 - foreach ( $theme_upgrades as $slug => $theme_upgrade ) {
642 - if ( ! isset( $allThemes[ $slug ] ) ) {
643 - $allThemes[ $slug ] = array(
644 - 'name' => esc_html( $theme_upgrade['Name'] ),
645 - 'cnt' => 1,
646 - );
647 - } else {
648 - ++$allThemes[ $slug ]['cnt'];
649 - }
618 + // to fix displaying per sites/tags.
619 + if ( is_array( $plugins_outdate ) ) {
620 + foreach ( $plugins_outdate as $slug => $plugin_outdate ) {
621 + $slug = esc_html( $slug );
622 + if ( ! isset( $allPluginsOutdate[ $slug ] ) ) {
623 + $allPluginsOutdate[ $slug ] = array(
624 + 'name' => esc_html( $plugin_outdate['Name'] ),
625 + 'cnt' => 1,
626 + 'uri' => esc_html( $plugin_outdate['PluginURI'] ),
627 + );
628 + } else {
629 + ++$allPluginsOutdate[ $slug ]['cnt'];
630 + }
631 + }
632 + }
650 633
651 - $themesInfo[ $slug ] = array(
652 - 'name' => esc_html( $theme_upgrade['Name'] ),
653 - 'premium' => ( isset( $theme_upgrade['premium'] ) ? esc_html( $theme_upgrade['premium'] ) : 0 ),
654 - );
655 - }
656 - }
634 + if ( is_array( $themes_outdate ) ) {
635 + foreach ( $themes_outdate as $slug => $theme_outdate ) {
636 + $slug = esc_html( $slug );
637 + if ( ! isset( $allThemesOutdate[ $slug ] ) ) {
638 + $allThemesOutdate[ $slug ] = array(
639 + 'name' => esc_html( $theme_outdate['Name'] ),
640 + 'cnt' => 1,
641 + );
642 + } else {
643 + ++$allThemesOutdate[ $slug ]['cnt'];
644 + }
645 + }
646 + }
657 647
658 - if ( is_array( $plugins_outdate ) ) {
659 - foreach ( $plugins_outdate as $slug => $plugin_outdate ) {
660 - $slug = esc_html( $slug );
661 - if ( ! isset( $allPluginsOutdate[ $slug ] ) ) {
662 - $allPluginsOutdate[ $slug ] = array(
663 - 'name' => esc_html( $plugin_outdate['Name'] ),
664 - 'cnt' => 1,
665 - 'uri' => esc_html( $plugin_outdate['PluginURI'] ),
666 - );
667 - } else {
668 - ++$allPluginsOutdate[ $slug ]['cnt'];
669 - }
670 - }
671 - }
648 + if ( MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ) {
649 + if ( is_array( $translation_upgrades ) ) {
650 + foreach ( $translation_upgrades as $translation_upgrade ) {
651 + $slug = esc_html( $translation_upgrade['slug'] );
652 + if ( ! isset( $allTranslations[ $slug ] ) ) {
653 + $allTranslations[ $slug ] = array(
654 + 'name' => isset( $translation_upgrade['name'] ) ? esc_html( $translation_upgrade['name'] ) : $slug,
655 + 'cnt' => 1,
656 + );
657 + } else {
658 + ++$allTranslations[ $slug ]['cnt'];
659 + }
672 660
673 - if ( is_array( $themes_outdate ) ) {
674 - foreach ( $themes_outdate as $slug => $theme_outdate ) {
675 - $slug = esc_html( $slug );
676 - if ( ! isset( $allThemesOutdate[ $slug ] ) ) {
677 - $allThemesOutdate[ $slug ] = array(
678 - 'name' => esc_html( $theme_outdate['Name'] ),
679 - 'cnt' => 1,
680 - );
681 - } else {
682 - ++$allThemesOutdate[ $slug ]['cnt'];
683 - }
684 - }
685 - }
686 - }
661 + $translationsInfo[ $slug ] = array(
662 + 'name' => isset( $translation_upgrade['name'] ) ? esc_html( $translation_upgrade['name'] ) : $slug,
663 + 'slug' => $slug,
664 + 'version' => esc_html( $translation_upgrade['version'] ),
665 + );
666 + }
667 + }
687 668
688 - if ( '' !== $website->sync_errors ) {
689 - ++$total_sync_errors;
690 - }
691 - }
669 + if ( is_array( $plugin_upgrades ) ) {
670 + foreach ( $plugin_upgrades as $slug => $plugin_upgrade ) {
671 + if ( ! isset( $allPlugins[ $slug ] ) ) {
672 + $allPlugins[ $slug ] = array(
673 + 'name' => esc_html( $plugin_upgrade['Name'] ),
674 + 'cnt' => 1,
675 + );
676 + } else {
677 + ++$allPlugins[ $slug ]['cnt'];
678 + }
692 679
693 - /**
694 - * Filter: mainwp_updates_translation_sort_by
695 - *
696 - * Filters the default sorting option for Translation updates.
697 - *
698 - * @since 4.1
699 - */
700 - $allTranslationsSortBy = apply_filters( 'mainwp_updates_translation_sort_by', 'name' );
680 + $pluginsInfo[ $slug ] = array(
681 + 'name' => esc_html( $plugin_upgrade['Name'] ),
682 + 'slug' => isset( $plugin_upgrade['update']['slug'] ) ? esc_html( $plugin_upgrade['update']['slug'] ) : '',
683 + 'premium' => ( isset( $plugin_upgrade['premium'] ) ? esc_html( $plugin_upgrade['premium'] ) : 0 ),
684 + 'PluginURI' => esc_html( $plugin_upgrade['PluginURI'] ),
685 + 'version' => esc_html( $plugin_upgrade['Version'] ),
686 + );
687 + }
688 + }
701 689
702 - /**
703 - * Filter: mainwp_updates_plugins_sort_by
704 - *
705 - * Filters the default sorting option for Plugin updates.
706 - *
707 - * @since 4.1
708 - */
709 - $allPluginsSortBy = apply_filters( 'mainwp_updates_plugins_sort_by', 'name' );
690 + if ( is_array( $theme_upgrades ) ) {
691 + foreach ( $theme_upgrades as $slug => $theme_upgrade ) {
692 + if ( ! isset( $allThemes[ $slug ] ) ) {
693 + $allThemes[ $slug ] = array(
694 + 'name' => esc_html( $theme_upgrade['Name'] ),
695 + 'cnt' => 1,
696 + );
697 + } else {
698 + ++$allThemes[ $slug ]['cnt'];
699 + }
710 700
711 - /**
712 - * Filter: mainwp_updates_themes_sort_by
713 - *
714 - * Filters the default sorting option for Theme updates.
715 - *
716 - * @since 4.1
717 - */
718 - $allThemesSortBy = apply_filters( 'mainwp_updates_themes_sort_by', 'name' );
701 + $up_th_name = isset( $theme_upgrade['Name'] ) ? esc_html( $theme_upgrade['Name'] ) : '';
719 702
720 - /**
721 - * Filter: mainwp_updates_abandoned_plugins_sort_by
722 - *
723 - * Filters the default sorting option for Abandoned plugins.
724 - *
725 - * @since 4.1
726 - */
727 - $allPluginsOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_plugins_sort_by', 'name' );
703 + if ( empty( $up_th_name ) ) {
704 + $up_th_name = isset( $theme_upgrade['name'] ) ? esc_html( $theme_upgrade['name'] ) : 'N/A';
705 + }
728 706
729 - /**
730 - * Filter: mainwp_updates_abandoned_themes_sort_by
731 - *
732 - * Filters the default sorting option for Abandoned themes.
733 - *
734 - * @since 4.1
735 - */
736 - $allThemesOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_themes_sort_by', 'name' );
707 + $themesInfo[ $slug ] = array(
708 + 'name' => $up_th_name,
709 + 'premium' => ( isset( $theme_upgrade['premium'] ) ? esc_html( $theme_upgrade['premium'] ) : 0 ),
710 + );
711 + }
712 + }
713 + }
737 714
738 - MainWP_Utility::array_sort( $allTranslations, $allTranslationsSortBy );
739 - MainWP_Utility::array_sort( $allPlugins, $allPluginsSortBy );
740 - MainWP_Utility::array_sort( $allThemes, $allThemesSortBy );
741 - MainWP_Utility::array_sort( $allPluginsOutdate, $allPluginsOutdateSortBy );
742 - MainWP_Utility::array_sort( $allThemesOutdate, $allThemesOutdateSortBy );
715 + if ( '' !== $website->sync_errors ) {
716 + ++$total_sync_errors;
717 + }
718 + }
743 719
744 - $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
720 + /**
721 + * Filter: mainwp_updates_translation_sort_by
722 + *
723 + * Filters the default sorting option for Translation updates.
724 + *
725 + * @since 4.1
726 + */
727 + $allTranslationsSortBy = apply_filters( 'mainwp_updates_translation_sort_by', 'name' );
745 728
746 - /**
747 - * Limits number of updates to process.
748 - *
749 - * Limits the number of updates that will be processed in a single run on Update Everything action.
750 - *
751 - * @since 4.0
752 - */
753 - $limit_updates_all = apply_filters( 'mainwp_limit_updates_all', 0 );
754 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
755 - if ( 0 < $limit_updates_all ) {
756 - if ( isset( $_GET['continue_update'] ) && '' !== $_GET['continue_update'] ) {
757 - self::$continue_update = sanitize_text_field( wp_unslash( $_GET['continue_update'] ) );
758 - if ( 'plugins_upgrade_all' === self::$continue_update || 'themes_upgrade_all' === self::$continue_update || 'translations_upgrade_all' === self::$continue_update ) {
759 - if ( isset( $_GET['slug'] ) && '' !== $_GET['slug'] ) {
760 - self::$continue_update_slug = wp_unslash( $_GET['slug'] );
761 - }
762 - }
763 - }
764 - }
729 + /**
730 + * Filter: mainwp_updates_plugins_sort_by
731 + *
732 + * Filters the default sorting option for Plugin updates.
733 + *
734 + * @since 4.1
735 + */
736 + $allPluginsSortBy = apply_filters( 'mainwp_updates_plugins_sort_by', 'name' );
765 737
766 - $current_tab = '';
738 + /**
739 + * Filter: mainwp_updates_themes_sort_by
740 + *
741 + * Filters the default sorting option for Theme updates.
742 + *
743 + * @since 4.1
744 + */
745 + $allThemesSortBy = apply_filters( 'mainwp_updates_themes_sort_by', 'name' );
767 746
768 - if ( isset( $_GET['tab'] ) ) {
769 - $current_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) );
770 - if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates', 'translations-updates', 'abandoned-plugins', 'abandoned-themes', true ) ) ) {
771 - $current_tab = 'plugins-updates';
772 - }
773 - } else {
774 - $current_tab = 'plugins-updates';
775 - }
776 - // phpcs:enable
777 - self::render_header( 'UpdatesManage' );
747 + /**
748 + * Filter: mainwp_updates_abandoned_plugins_sort_by
749 + *
750 + * Filters the default sorting option for Abandoned plugins.
751 + *
752 + * @since 4.1
753 + */
754 + $allPluginsOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_plugins_sort_by', 'name' );
778 755
779 - self::render_header_tabs( $mainwp_show_language_updates, $current_tab, $total_wp_upgrades, $total_plugin_upgrades, $total_theme_upgrades, $total_translation_upgrades, $total_plugins_outdate, $total_themes_outdate, $site_view );
756 + /**
757 + * Filter: mainwp_updates_abandoned_themes_sort_by
758 + *
759 + * Filters the default sorting option for Abandoned themes.
760 + *
761 + * @since 4.1
762 + */
763 + $allThemesOutdateSortBy = apply_filters( 'mainwp_updates_abandoned_themes_sort_by', 'name' );
780 764
781 - ?>
782 - <div class="ui segment" id="mainwp-manage-updates">
783 - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-message' ) ) { ?>
784 - <div class="ui info message">
785 - <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i>
786 - <div><?php printf( esc_html__( 'Manage available updates for all your child sites. From here, you can update update %1$splugins%2$s, %3$sthemes%4$s, and %5$sWordPress core%6$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/update-plugins/" target="_blank">', '</a>', '<a href="https://kb.mainwp.com/docs/update-themes/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/update-wordpress-core/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div>
787 - <div><?php printf( esc_html__( 'Also, from here, you can ignore updates for %1$sWordPress core%2$s, %3$splugins%4$s, and %5$sthemes%6$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/ignore-wordpress-core-update/" target="_blank">', '</a>', '<a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://kb.mainwp.com/docs/ignore-theme-updates/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div>
788 - </div>
789 - <?php } ?>
790 - <?php
765 + MainWP_Utility::array_sort( $allTranslations, $allTranslationsSortBy );
766 + MainWP_Utility::array_sort( $allPlugins, $allPluginsSortBy );
767 + MainWP_Utility::array_sort( $allThemes, $allThemesSortBy );
768 + MainWP_Utility::array_sort( $allPluginsOutdate, $allPluginsOutdateSortBy );
769 + MainWP_Utility::array_sort( $allThemesOutdate, $allThemesOutdateSortBy );
791 770
792 - $hooks_tabs = apply_filters( 'mainwp_pages_updates_render_tabs', false, $current_tab );
771 + $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
793 772
794 - if ( false === $hooks_tabs ) {
795 - if ( 'wordpress-updates' === $current_tab ) {
796 - self::render_wp_update_tab( $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view );
797 - } elseif ( 'plugins-updates' === $current_tab ) {
798 - self::render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view );
799 - } elseif ( 'themes-updates' === $current_tab ) {
800 - self::render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view );
801 - } elseif ( 'translations-updates' === $current_tab ) {
802 - self::render_trans_update_tab( $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups, $site_view );
803 - } elseif ( 'abandoned-plugins' === $current_tab ) {
804 - self::render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view );
805 - } elseif ( 'abandoned-themes' === $current_tab ) {
806 - self::render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view );
807 - }
808 - ?>
809 - </div>
810 - <?php
811 - self::render_js_updates( $site_view );
812 - }
773 + /**
774 + * Limits number of updates to process.
775 + *
776 + * Limits the number of updates that will be processed in a single run on Update Everything action.
777 + *
778 + * @since 4.0
779 + */
780 + $limit_updates_all = apply_filters( 'mainwp_limit_updates_all', 0 );
781 + // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
782 + if ( 0 < $limit_updates_all && isset( $_GET['continue_update'] ) && '' !== $_GET['continue_update'] ) {
783 + static::$continue_update = sanitize_text_field( wp_unslash( $_GET['continue_update'] ) );
784 + if ( ( 'plugins_upgrade_all' === static::$continue_update || 'themes_upgrade_all' === static::$continue_update || 'translations_upgrade_all' === static::$continue_update ) && isset( $_GET['slug'] ) && '' !== $_GET['slug'] ) {
785 + static::$continue_update_slug = wp_unslash( $_GET['slug'] );
786 + }
787 + }
813 788
814 - self::render_updates_modal();
789 + $current_tab = '';
815 790
816 - self::render_plugin_details_modal();
817 - MainWP_UI::render_modal_upload_icon();
818 - self::render_screen_options_modal();
819 - self::render_footer();
820 - ?>
821 - <script type="text/javascript">
822 - mainwp_manage_updates_screen_options = function () {
823 - jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'show' );
824 - jQuery( '#manage-updates-screen-options-form' ).submit( function() {
825 - jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'hide' );
826 - } );
827 - return false;
828 - };
829 - </script>
830 - <?php
831 - }
791 + if ( isset( $_GET['tab'] ) ) {
792 + $current_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) );
793 + if ( ! in_array( $current_tab, array( 'wordpress-updates', 'updates-ignore', 'plugins-updates', 'themes-updates', 'translations-updates', true ) ) ) {
794 + $current_tab = 'plugins-updates';
795 + }
796 + } elseif ( 'abandoned_plugins' === $abandoned_tab ) {
797 + $current_tab = 'abandoned-plugins';
798 + } elseif ( 'abandoned_themes' === $abandoned_tab ) {
799 + $current_tab = 'abandoned-themes';
800 + }
832 801
833 - /**
834 - * Render WP updates tab.
835 - *
836 - * @param object $websites Object containing child sites info.
837 - * @param int $total_wp_upgrades Number of available WP upates.
838 - * @param array $all_groups_sites Array containing all groups and sites.
839 - * @param array $all_groups Array containing all groups.
840 - * @param int $site_offset_for_groups Offset value.
841 - * @param string $site_view Current view.
842 - *
843 - * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
844 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_wpcore_updates()
845 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_wpcore_updates()
846 - */
847 - public static function render_wp_update_tab( $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ) {
848 - ?>
849 - <div class="ui active tab" data-tab="wordpress-updates">
850 - <?php
851 - /**
852 - * Action: mainwp_updates_before_wp_updates
853 - *
854 - * Fires at the top of the WP updates tab.
855 - *
856 - * @param object $websites Object containing child sites info.
857 - * @param int $total_wp_upgrades Number of available WP upates.
858 - * @param array $all_groups_sites Array containing all groups and sites.
859 - * @param array $all_groups Array containing all groups.
860 - * @param int $site_offset_for_groups Offset value.
861 - *
862 - * @since 4.1
863 - */
864 - do_action( 'mainwp_updates_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
865 - if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
866 - /**
867 - * Action: mainwp_updates_pergroup_before_wp_updates
868 - *
869 - * Fires at the top of the WP updates tab, per Group view.
870 - *
871 - * @param object $websites Object containing child sites info.
872 - * @param int $total_wp_upgrades Number of available WP upates.
873 - * @param array $all_groups_sites Array containing all groups and sites.
874 - * @param array $all_groups Array containing all groups.
875 - * @param int $site_offset_for_groups Offset value.
876 - *
877 - * @since 4.1
878 - */
879 - do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
880 - MainWP_Updates_Per_Group::render_wpcore_updates( $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
881 - /**
882 - * Action: mainwp_updates_pergroup_after_wp_updates
883 - *
884 - * Fires at the bottom of the WP updates tab, per Group view.
885 - *
886 - * @param object $websites Object containing child sites info.
887 - * @param int $total_wp_upgrades Number of available WP upates.
888 - * @param array $all_groups_sites Array containing all groups and sites.
889 - * @param array $all_groups Array containing all groups.
890 - * @param int $site_offset_for_groups Offset value.
891 - *
892 - * @since 4.1
893 - */
894 - do_action( 'mainwp_updates_pergroup_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
895 - } else {
896 - /**
897 - * Action: mainwp_updates_persite_before_wp_updates
898 - *
899 - * Fires at the top of the WP updates tab, per Site view.
900 - *
901 - * @param object $websites Object containing child sites info.
902 - * @param int $total_wp_upgrades Number of available WP upates.
903 - * @param array $all_groups_sites Array containing all groups and sites.
904 - * @param array $all_groups Array containing all groups.
905 - * @param int $site_offset_for_groups Offset value.
906 - *
907 - * @since 4.1
908 - */
909 - do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
910 - MainWP_DB::data_seek( $websites, 0 );
911 - MainWP_Updates_Per_Site::render_wpcore_updates( $websites, $total_wp_upgrades );
912 - /**
913 - * Action: mainwp_updates_persite_after_wp_updates
914 - *
915 - * Fires at the bottom of the WP updates tab, per Site view.
916 - *
917 - * @param object $websites Object containing child sites info.
918 - * @param int $total_wp_upgrades Number of available WP upates.
919 - * @param array $all_groups_sites Array containing all groups and sites.
920 - * @param array $all_groups Array containing all groups.
921 - * @param int $site_offset_for_groups Offset value.
922 - *
923 - * @since 4.1
924 - */
925 - do_action( 'mainwp_updates_persite_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
926 - }
927 - /**
928 - * Action: mainwp_updates_after_wp_updates
929 - *
930 - * Fires at the top of the WP updates tab.
931 - *
932 - * @param object $websites Object containing child sites info.
933 - * @param int $total_wp_upgrades Number of available WP upates.
934 - * @param array $all_groups_sites Array containing all groups and sites.
935 - * @param array $all_groups Array containing all groups.
936 - * @param int $site_offset_for_groups Offset value.
937 - *
938 - * @since 4.1
939 - */
940 - do_action( 'mainwp_updates_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
941 - ?>
942 - </div>
943 - <?php
944 - }
802 + if ( empty( $current_tab ) ) {
803 + $current_tab = 'plugins-updates';
804 + }
945 805
946 - /**
947 - * Renders WP updates tab.
948 - *
949 - * @param object $websites Object containing child sites info.
950 - * @param int $total_plugin_upgrades Number of available plugin updates.
951 - * @param object $userExtension User extension.
952 - * @param array $all_groups_sites Array of all groups and sites.
953 - * @param array $all_groups Array of all groups.
954 - * @param array $allPlugins Array of all plugins.
955 - * @param array $pluginsInfo Array of all plugins info.
956 - * @param int $site_offset_for_groups Offset value.
957 - * @param string $site_view Current view.
958 - *
959 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_plugins_updates()
960 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_plugins_updates()
961 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_plugins_updates()
962 - */
963 - public static function render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view ) {
964 - $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
965 - if ( ! is_array( $trustedPlugins ) ) {
966 - $trustedPlugins = array();
967 - }
968 - ?>
969 - <div class="ui active tab" data-tab="plugins-updates">
970 - <?php
971 - /**
972 - * Action: mainwp_updates_before_plugin_updates
973 - *
974 - * Fires at the top of the Plugin updates tab.
975 - *
976 - * @param object $websites Object containing child sites info.
977 - * @param int $total_plugin_upgrades Number of available plugin updates.
978 - * @param object $userExtension User extension.
979 - * @param array $all_groups_sites Array of all groups and sites.
980 - * @param array $all_groups Array of all groups.
981 - * @param array $allPlugins Array of all plugins.
982 - * @param array $pluginsInfo Array of all plugins info.
983 - * @param int $site_offset_for_groups Offset value.
984 - *
985 - * @since 4.1
986 - */
987 - do_action( 'mainwp_updates_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
988 - if ( MAINWP_VIEW_PER_SITE === $site_view ) {
989 - /**
990 - * Action: mainwp_updates_persite_before_plugin_updates
991 - *
992 - * Fires at the top of the Plugin updates tab, per Site view.
993 - *
994 - * @param object $websites Object containing child sites info.
995 - * @param int $total_plugin_upgrades Number of available plugin updates.
996 - * @param object $userExtension User extension.
997 - * @param array $all_groups_sites Array of all groups and sites.
998 - * @param array $all_groups Array of all groups.
999 - * @param array $allPlugins Array of all plugins.
1000 - * @param array $pluginsInfo Array of all plugins info.
1001 - * @param int $site_offset_for_groups Offset value.
1002 - *
1003 - * @since 4.1
1004 - */
1005 - do_action( 'mainwp_updates_persite_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1006 - MainWP_Updates_Per_Site::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $trustedPlugins );
1007 - /**
1008 - * Action: mainwp_updates_persite_after_plugin_updates
1009 - *
1010 - * Fires at the bottom of the Plugin updates tab, per Site view.
1011 - *
1012 - * @param object $websites Object containing child sites info.
1013 - * @param int $total_plugin_upgrades Number of available plugin updates.
1014 - * @param object $userExtension User extension.
1015 - * @param array $all_groups_sites Array of all groups and sites.
1016 - * @param array $all_groups Array of all groups.
1017 - * @param array $allPlugins Array of all plugins.
1018 - * @param array $pluginsInfo Array of all plugins info.
1019 - * @param int $site_offset_for_groups Offset value.
1020 - *
1021 - * @since 4.1
1022 - */
1023 - do_action( 'mainwp_updates_persite_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1024 - } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1025 - /**
1026 - * Action: mainwp_updates_pergroup_before_plugin_updates
1027 - *
1028 - * Fires at the top of the Plugin updates tab, per Group view.
1029 - *
1030 - * @param object $websites Object containing child sites info.
1031 - * @param int $total_plugin_upgrades Number of available plugin updates.
1032 - * @param object $userExtension User extension.
1033 - * @param array $all_groups_sites Array of all groups and sites.
1034 - * @param array $all_groups Array of all groups.
1035 - * @param array $allPlugins Array of all plugins.
1036 - * @param array $pluginsInfo Array of all plugins info.
1037 - * @param int $site_offset_for_groups Offset value.
1038 - *
1039 - * @since 4.1
1040 - */
1041 - do_action( 'mainwp_updates_pergroup_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1042 - MainWP_Updates_Per_Group::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins );
1043 - /**
1044 - * Action: mainwp_updates_pergroup_after_plugin_updates
1045 - *
1046 - * Fires at the bottom of the Plugin updates tab, per Group view.
1047 - *
1048 - * @param object $websites Object containing child sites info.
1049 - * @param int $total_plugin_upgrades Number of available plugin updates.
1050 - * @param object $userExtension User extension.
1051 - * @param array $all_groups_sites Array of all groups and sites.
1052 - * @param array $all_groups Array of all groups.
1053 - * @param array $allPlugins Array of all plugins.
1054 - * @param array $pluginsInfo Array of all plugins info.
1055 - * @param int $site_offset_for_groups Offset value.
1056 - *
1057 - * @since 4.1
1058 - */
1059 - do_action( 'mainwp_updates_pergroup_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1060 - } else {
1061 - /**
1062 - * Action: mainwp_updates_perplugin_before_plugin_updates
1063 - *
1064 - * Fires at the top of the Plugin updates tab, per Plugin view.
1065 - *
1066 - * @param object $websites Object containing child sites info.
1067 - * @param int $total_plugin_upgrades Number of available plugin updates.
1068 - * @param object $userExtension User extension.
1069 - * @param array $all_groups_sites Array of all groups and sites.
1070 - * @param array $all_groups Array of all groups.
1071 - * @param array $allPlugins Array of all plugins.
1072 - * @param array $pluginsInfo Array of all plugins info.
1073 - * @param int $site_offset_for_groups Offset value.
1074 - *
1075 - * @since 4.1
1076 - */
1077 - do_action( 'mainwp_updates_perplugin_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1078 - MainWP_Updates_Per_Item::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins );
1079 - /**
1080 - * Action: mainwp_updates_perplugin_after_plugin_updates
1081 - *
1082 - * Fires at the bottom of the Plugin updates tab, per Plugin view.
1083 - *
1084 - * @param object $websites Object containing child sites info.
1085 - * @param int $total_plugin_upgrades Number of available plugin updates.
1086 - * @param object $userExtension User extension.
1087 - * @param array $all_groups_sites Array of all groups and sites.
1088 - * @param array $all_groups Array of all groups.
1089 - * @param array $allPlugins Array of all plugins.
1090 - * @param array $pluginsInfo Array of all plugins info.
1091 - * @param int $site_offset_for_groups Offset value.
1092 - *
1093 - * @since 4.1
1094 - */
1095 - do_action( 'mainwp_updates_perplugin_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1096 - }
1097 - /**
1098 - * Action: mainwp_updates_after_plugin_updates
1099 - *
1100 - * Fires at the bottom of the Plugin updates tab.
1101 - *
1102 - * @param object $websites Object containing child sites info.
1103 - * @param int $total_plugin_upgrades Number of available plugin updates.
1104 - * @param object $userExtension User extension.
1105 - * @param array $all_groups_sites Array of all groups and sites.
1106 - * @param array $all_groups Array of all groups.
1107 - * @param array $allPlugins Array of all plugins.
1108 - * @param array $pluginsInfo Array of all plugins info.
1109 - * @param int $site_offset_for_groups Offset value.
1110 - *
1111 - * @since 4.1
1112 - */
1113 - do_action( 'mainwp_updates_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1114 - ?>
1115 - </div>
1116 - <?php
1117 - }
806 + // phpcs:enable
807 + static::render_header( $current_tab );
1118 808
1119 - /**
1120 - * Renders theme update tab.
1121 - *
1122 - * @param object $websites Object containing child sites info.
1123 - * @param int $total_theme_upgrades Number of available theme updates.
1124 - * @param object $userExtension User extension.
1125 - * @param array $all_groups_sites Array of all groups and sites.
1126 - * @param array $all_groups Array of all groups.
1127 - * @param array $allThemes Array of all themes.
1128 - * @param array $themesInfo Array of all themes info.
1129 - * @param int $site_offset_for_groups Offset value.
1130 - * @param string $site_view Current view.
1131 - *
1132 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_themes_updates()
1133 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_themes_updates()
1134 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_themes_updates()
1135 - */
1136 - public static function render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view ) {
1137 - $trustedThemes = json_decode( $userExtension->trusted_themes, true );
1138 - if ( ! is_array( $trustedThemes ) ) {
1139 - $trustedThemes = array();
1140 - }
1141 - ?>
1142 - <div class="ui active tab" data-tab="themes-updates">
1143 - <?php
1144 - /**
1145 - * Action: mainwp_updates_before_theme_updates
1146 - *
1147 - * Fires at the top of the Theme updates tab.
1148 - *
1149 - * @param object $websites Object containing child sites info.
1150 - * @param int $total_theme_upgrades Number of available theme updates.
1151 - * @param object $userExtension User extension.
1152 - * @param array $all_groups_sites Array of all groups and sites.
1153 - * @param array $all_groups Array of all groups.
1154 - * @param array $allThemes Array of all themes.
1155 - * @param array $themesInfo Array of all themes info.
1156 - * @param int $site_offset_for_groups Offset value.
1157 - *
1158 - * @since 4.1
1159 - */
1160 - do_action( 'mainwp_updates_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1161 - if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1162 - /**
1163 - * Action: mainwp_updates_persite_before_theme_updates
1164 - *
1165 - * Fires at the top of the Theme updates tab, per Site view.
1166 - *
1167 - * @param object $websites Object containing child sites info.
1168 - * @param int $total_theme_upgrades Number of available theme updates.
1169 - * @param object $userExtension User extension.
1170 - * @param array $all_groups_sites Array of all groups and sites.
1171 - * @param array $all_groups Array of all groups.
1172 - * @param array $allThemes Array of all themes.
1173 - * @param array $themesInfo Array of all themes info.
1174 - * @param int $site_offset_for_groups Offset value.
1175 - *
1176 - * @since 4.1
1177 - */
1178 - do_action( 'mainwp_updates_persite_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1179 - MainWP_Updates_Per_Site::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $trustedThemes );
1180 - /**
1181 - * Action: mainwp_updates_persite_after_theme_updates
1182 - *
1183 - * Fires at the bottom of the Theme updates tab, per Site view.
1184 - *
1185 - * @param object $websites Object containing child sites info.
1186 - * @param int $total_theme_upgrades Number of available theme updates.
1187 - * @param object $userExtension User extension.
1188 - * @param array $all_groups_sites Array of all groups and sites.
1189 - * @param array $all_groups Array of all groups.
1190 - * @param array $allThemes Array of all themes.
1191 - * @param array $themesInfo Array of all themes info.
1192 - * @param int $site_offset_for_groups Offset value.
1193 - *
1194 - * @since 4.1
1195 - */
1196 - do_action( 'mainwp_updates_persite_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1197 - } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1198 - /**
1199 - * Action: mainwp_updates_pergroup_before_theme_updates
1200 - *
1201 - * Fires at the top of the Theme updates tab, per Group view.
1202 - *
1203 - * @param object $websites Object containing child sites info.
1204 - * @param int $total_theme_upgrades Number of available theme updates.
1205 - * @param object $userExtension User extension.
1206 - * @param array $all_groups_sites Array of all groups and sites.
1207 - * @param array $all_groups Array of all groups.
1208 - * @param array $allThemes Array of all themes.
1209 - * @param array $themesInfo Array of all themes info.
1210 - * @param int $site_offset_for_groups Offset value.
1211 - *
1212 - * @since 4.1
1213 - */
1214 - do_action( 'mainwp_updates_pergroup_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1215 - MainWP_Updates_Per_Group::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedThemes );
1216 - /**
1217 - * Action: mainwp_updates_pergroup_after_theme_updates
1218 - *
1219 - * Fires at the bottom of the Theme updates tab, per Group view.
1220 - *
1221 - * @param object $websites Object containing child sites info.
1222 - * @param int $total_theme_upgrades Number of available theme updates.
1223 - * @param object $userExtension User extension.
1224 - * @param array $all_groups_sites Array of all groups and sites.
1225 - * @param array $all_groups Array of all groups.
1226 - * @param array $allThemes Array of all themes.
1227 - * @param array $themesInfo Array of all themes info.
1228 - * @param int $site_offset_for_groups Offset value.
1229 - *
1230 - * @since 4.1
1231 - */
1232 - do_action( 'mainwp_updates_pergroup_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1233 - } else {
1234 - /**
1235 - * Action: mainwp_updates_pertheme_before_theme_updates
1236 - *
1237 - * Fires at the top of the Theme updates tab, per Theme view.
1238 - *
1239 - * @param object $websites Object containing child sites info.
1240 - * @param int $total_theme_upgrades Number of available theme updates.
1241 - * @param object $userExtension User extension.
1242 - * @param array $all_groups_sites Array of all groups and sites.
1243 - * @param array $all_groups Array of all groups.
1244 - * @param array $allThemes Array of all themes.
1245 - * @param array $themesInfo Array of all themes info.
1246 - * @param int $site_offset_for_groups Offset value.
1247 - *
1248 - * @since 4.1
1249 - */
1250 - do_action( 'mainwp_updates_pertheme_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1251 - MainWP_Updates_Per_Item::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $allThemes, $themesInfo, $trustedThemes );
1252 - /**
1253 - * Action: mainwp_updates_pertheme_after_theme_updates
1254 - *
1255 - * Fires at the bottom of the Theme updates tab, per Theme view.
1256 - *
1257 - * @param object $websites Object containing child sites info.
1258 - * @param int $total_theme_upgrades Number of available theme updates.
1259 - * @param object $userExtension User extension.
1260 - * @param array $all_groups_sites Array of all groups and sites.
1261 - * @param array $all_groups Array of all groups.
1262 - * @param array $allThemes Array of all themes.
1263 - * @param array $themesInfo Array of all themes info.
1264 - * @param int $site_offset_for_groups Offset value.
1265 - *
1266 - * @since 4.1
1267 - */
1268 - do_action( 'mainwp_updates_pertheme_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1269 - }
1270 - /**
1271 - * Action: mainwp_updates_after_theme_updates
1272 - *
1273 - * Fires at the bottom of the Theme updates tab.
1274 - *
1275 - * @param object $websites Object containing child sites info.
1276 - * @param int $total_theme_upgrades Number of available theme updates.
1277 - * @param object $userExtension User extension.
1278 - * @param array $all_groups_sites Array of all groups and sites.
1279 - * @param array $all_groups Array of all groups.
1280 - * @param array $allThemes Array of all themes.
1281 - * @param array $themesInfo Array of all themes info.
1282 - * @param int $site_offset_for_groups Offset value.
1283 - *
1284 - * @since 4.1
1285 - */
1286 - do_action( 'mainwp_updates_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1287 - ?>
1288 - </div>
1289 - <?php
1290 - }
809 + static::render_header_tabs( $mainwp_show_language_updates, $current_tab, $total_wp_upgrades, $total_plugin_upgrades, $total_theme_upgrades, $total_translation_upgrades, $total_plugins_outdate, $total_themes_outdate, $site_view );
1291 810
1292 - /**
1293 - * Renders translations update tab.
1294 - *
1295 - * @param object $websites Object containing child sites info.
1296 - * @param int $total_translation_upgrades Number of available translation updates.
1297 - * @param object $userExtension User extension.
1298 - * @param array $all_groups_sites Array of all groups and sites.
1299 - * @param array $all_groups Array of all groups.
1300 - * @param array $allTranslations Array of all translations.
1301 - * @param array $translationsInfo Array of all translations info.
1302 - * @param bool $mainwp_show_language_updates Either or not show language updates.
1303 - * @param int $site_offset_for_groups Offset value.
1304 - * @param string $site_view Current Site view.
1305 - *
1306 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_trans_update()
1307 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_trans_update()
1308 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_trans_update()
1309 - */
1310 - public static function render_trans_update_tab( $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups, $site_view ) {
1311 - if ( 1 === (int) $mainwp_show_language_updates ) {
1312 - ?>
1313 - <div class="ui active tab" data-tab="translations-updates">
1314 - <?php
1315 - /**
1316 - * Action: mainwp_updates_before_translation_updates
1317 - *
1318 - * Fires at the top of the Translation updates tab.
1319 - *
1320 - * @param object $websites Object containing child sites info.
1321 - * @param int $total_translation_upgrades Number of available translation updates.
1322 - * @param object $userExtension User extension.
1323 - * @param array $all_groups_sites Array of all groups and sites.
1324 - * @param array $all_groups Array of all groups.
1325 - * @param array $allTranslations Array of all translations.
1326 - * @param array $translationsInfo Array of all translations info.
1327 - * @param int $site_offset_for_groups Offset value.
1328 - *
1329 - * @since 4.1
1330 - */
1331 - do_action( 'mainwp_updates_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1332 - if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1333 - /**
1334 - * Action: mainwp_updates_persite_before_translation_updates
1335 - *
1336 - * Fires at the top of the Translation updates tab, per Site view.
1337 - *
1338 - * @param object $websites Object containing child sites info.
1339 - * @param int $total_translation_upgrades Number of available translation updates.
1340 - * @param object $userExtension User extension.
1341 - * @param array $all_groups_sites Array of all groups and sites.
1342 - * @param array $all_groups Array of all groups.
1343 - * @param array $allTranslations Array of all translations.
1344 - * @param array $translationsInfo Array of all translations info.
1345 - * @param int $site_offset_for_groups Offset value.
1346 - *
1347 - * @since 4.1
1348 - */
1349 - do_action( 'mainwp_updates_persite_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1350 - MainWP_Updates_Per_Site::render_trans_update( $websites, $total_translation_upgrades );
1351 - /**
1352 - * Action: mainwp_updates_persite_after_translation_updates
1353 - *
1354 - * Fires at the bottom of the Translation updates tab, per Site view.
1355 - *
1356 - * @param object $websites Object containing child sites info.
1357 - * @param int $total_translation_upgrades Number of available translation updates.
1358 - * @param object $userExtension User extension.
1359 - * @param array $all_groups_sites Array of all groups and sites.
1360 - * @param array $all_groups Array of all groups.
1361 - * @param array $allTranslations Array of all translations.
1362 - * @param array $translationsInfo Array of all translations info.
1363 - * @param int $site_offset_for_groups Offset value.
1364 - *
1365 - * @since 4.1
1366 - */
1367 - do_action( 'mainwp_updates_persite_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1368 - } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1369 - /**
1370 - * Action: mainwp_updates_pergroup_before_translation_updates
1371 - *
1372 - * Fires at the top of the Translation updates tab, per Group view.
1373 - *
1374 - * @param object $websites Object containing child sites info.
1375 - * @param int $total_translation_upgrades Number of available translation updates.
1376 - * @param object $userExtension User extension.
1377 - * @param array $all_groups_sites Array of all groups and sites.
1378 - * @param array $all_groups Array of all groups.
1379 - * @param array $allTranslations Array of all translations.
1380 - * @param array $translationsInfo Array of all translations info.
1381 - * @param int $site_offset_for_groups Offset value.
1382 - *
1383 - * @since 4.1
1384 - */
1385 - do_action( 'mainwp_updates_pergroup_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1386 - MainWP_Updates_Per_Group::render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
1387 - /**
1388 - * Action: mainwp_updates_pergroup_after_translation_updates
1389 - *
1390 - * Fires at the bottom of the Translation updates tab, per Group view.
1391 - *
1392 - * @param object $websites Object containing child sites info.
1393 - * @param int $total_translation_upgrades Number of available translation updates.
1394 - * @param object $userExtension User extension.
1395 - * @param array $all_groups_sites Array of all groups and sites.
1396 - * @param array $all_groups Array of all groups.
1397 - * @param array $allTranslations Array of all translations.
1398 - * @param array $translationsInfo Array of all translations info.
1399 - * @param int $site_offset_for_groups Offset value.
1400 - *
1401 - * @since 4.1
1402 - */
1403 - do_action( 'mainwp_updates_pergroup_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1404 - } else {
1405 - /**
1406 - * Action: mainwp_updates_pertranslation_before_translation_updates
1407 - *
1408 - * Fires at the top of the Translation updates tab, per Translation view.
1409 - *
1410 - * @param object $websites Object containing child sites info.
1411 - * @param int $total_translation_upgrades Number of available translation updates.
1412 - * @param object $userExtension User extension.
1413 - * @param array $all_groups_sites Array of all groups and sites.
1414 - * @param array $all_groups Array of all groups.
1415 - * @param array $allTranslations Array of all translations.
1416 - * @param array $translationsInfo Array of all translations info.
1417 - * @param int $site_offset_for_groups Offset value.
1418 - *
1419 - * @since 4.1
1420 - */
1421 - do_action( 'mainwp_updates_pertranslation_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1422 - MainWP_Updates_Per_Item::render_trans_update( $websites, $total_translation_upgrades, $userExtension, $allTranslations, $translationsInfo );
1423 - /**
1424 - * Action: mainwp_updates_pertranslation_after_translation_updates
1425 - *
1426 - * Fires at the bottom of the Translation updates tab, per Translation view.
1427 - *
1428 - * @param object $websites Object containing child sites info.
1429 - * @param int $total_translation_upgrades Number of available translation updates.
1430 - * @param object $userExtension User extension.
1431 - * @param array $all_groups_sites Array of all groups and sites.
1432 - * @param array $all_groups Array of all groups.
1433 - * @param array $allTranslations Array of all translations.
1434 - * @param array $translationsInfo Array of all translations info.
1435 - * @param int $site_offset_for_groups Offset value.
1436 - *
1437 - * @since 4.1
1438 - */
1439 - do_action( 'mainwp_updates_pertranslation_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1440 - }
1441 - /**
1442 - * Action: mainwp_updates_after_translation_updates
1443 - *
1444 - * Fires at the bottom of the Translation updates tab.
1445 - *
1446 - * @param object $websites Object containing child sites info.
1447 - * @param int $total_translation_upgrades Number of available translation updates.
1448 - * @param object $userExtension User extension.
1449 - * @param array $all_groups_sites Array of all groups and sites.
1450 - * @param array $all_groups Array of all groups.
1451 - * @param array $allTranslations Array of all translations.
1452 - * @param array $translationsInfo Array of all translations info.
1453 - * @param int $site_offset_for_groups Offset value.
1454 - *
1455 - * @since 4.1
1456 - */
1457 - do_action( 'mainwp_updates_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1458 - ?>
1459 - </div>
1460 - <?php
1461 - }
1462 - }
811 + ?>
812 + <div class="ui padded segment" id="mainwp-manage-updates">
813 + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-updates-message' ) ) { ?>
814 + <div class="ui info message">
815 + <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-updates-message"></i>
816 + <div><?php /* translators: 1: opening anchor tag for plugins, 2: closing anchor tag, 3: opening anchor tag for themes, 4: closing anchor tag with icon, 5: opening anchor tag for WordPress core, 6: closing anchor tag with icon */ printf( esc_html__( 'Manage available updates for all your child sites. From here, you can update update %1$splugins%2$s, %3$sthemes%4$s, and %5$sWordPress core%6$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-updates" target="_blank">', '</a>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div>
817 + <div><?php /* translators: 1: opening anchor tag for WordPress core, 2: closing anchor tag with icon, 3: opening anchor tag for plugins, 4: closing anchor tag with icon, 5: opening anchor tag for themes, 6: closing anchor tag with icon */ printf( esc_html__( 'Also, from here, you can ignore updates for %1$sWordPress core%2$s, %3$splugins%4$s, and %5$sthemes%6$s.', 'mainwp' ), '<a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">', '</a> <i class="external alternate icon"></i>', '<a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-theme-updates" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></div>
818 + </div>
819 + <?php } ?>
820 + <?php
1463 821
1464 - /**
1465 - * Renders abandoned plugins tab.
1466 - *
1467 - * @param object $websites Object containing child sites info.
1468 - * @param array $all_groups_sites Array of all groups and sites.
1469 - * @param array $all_groups Array of all groups.
1470 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1471 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1472 - * @param int $site_offset_for_groups Offset value.
1473 - * @param string $site_view Current site view.
1474 - *
1475 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_plugins()
1476 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_plugins()
1477 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_plugins()
1478 - */
1479 - public static function render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view ) {
1480 - ?>
1481 - <div class="ui active tab" data-tab="abandoned-plugins">
1482 - <?php
1483 - /**
1484 - * Action: mainwp_updates_before_abandoned_plugins
1485 - *
1486 - * Fires at the top of the Abandoned plugins tab.
1487 - *
1488 - * @param object $websites Object containing child sites info.
1489 - * @param array $all_groups_sites Array of all groups and sites.
1490 - * @param array $all_groups Array of all groups.
1491 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1492 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1493 - * @param int $site_offset_for_groups Offset value.
1494 - *
1495 - * @since 4.1
1496 - */
1497 - do_action( 'mainwp_updates_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1498 - if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1499 - /**
1500 - * Action: mainwp_updates_persite_before_abandoned_plugins
1501 - *
1502 - * Fires at the top of the Abandoned plugins tab, per Site view.
1503 - *
1504 - * @param object $websites Object containing child sites info.
1505 - * @param array $all_groups_sites Array of all groups and sites.
1506 - * @param array $all_groups Array of all groups.
1507 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1508 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1509 - * @param int $site_offset_for_groups Offset value.
1510 - *
1511 - * @since 4.1
1512 - */
1513 - do_action( 'mainwp_updates_persite_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1514 - MainWP_Updates_Per_Site::render_abandoned_plugins( $websites, $decodedDismissedPlugins );
1515 - /**
1516 - * Action: mainwp_updates_persite_after_abandoned_plugins
1517 - *
1518 - * Fires at the bottom of the Abandoned plugins tab, per Site view.
1519 - *
1520 - * @param object $websites Object containing child sites info.
1521 - * @param array $all_groups_sites Array of all groups and sites.
1522 - * @param array $all_groups Array of all groups.
1523 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1524 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1525 - * @param int $site_offset_for_groups Offset value.
1526 - *
1527 - * @since 4.1
1528 - */
1529 - do_action( 'mainwp_updates_persite_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1530 - } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1531 - /**
1532 - * Action: mainwp_updates_pergroup_before_abandoned_plugins
1533 - *
1534 - * Fires at the top of the Abandoned plugins tab, per Group view.
1535 - *
1536 - * @param object $websites Object containing child sites info.
1537 - * @param array $all_groups_sites Array of all groups and sites.
1538 - * @param array $all_groups Array of all groups.
1539 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1540 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1541 - * @param int $site_offset_for_groups Offset value.
1542 - *
1543 - * @since 4.1
1544 - */
1545 - do_action( 'mainwp_updates_pergroup_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1546 - MainWP_Updates_Per_Group::render_abandoned_plugins( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins );
1547 - /**
1548 - * Action: mainwp_updates_pergroup_after_abandoned_plugins
1549 - *
1550 - * Fires at the bottom of the Abandoned plugins tab, per Group view.
1551 - *
1552 - * @param object $websites Object containing child sites info.
1553 - * @param array $all_groups_sites Array of all groups and sites.
1554 - * @param array $all_groups Array of all groups.
1555 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1556 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1557 - * @param int $site_offset_for_groups Offset value.
1558 - *
1559 - * @since 4.1
1560 - */
1561 - do_action( 'mainwp_updates_pergroup_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1562 - } else {
1563 - /**
1564 - * Action: mainwp_updates_perplugin_before_abandoned_plugins
1565 - *
1566 - * Fires at the top of the Abandoned plugins tab, per Plugin view.
1567 - *
1568 - * @param object $websites Object containing child sites info.
1569 - * @param array $all_groups_sites Array of all groups and sites.
1570 - * @param array $all_groups Array of all groups.
1571 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1572 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1573 - * @param int $site_offset_for_groups Offset value.
1574 - *
1575 - * @since 4.1
1576 - */
1577 - do_action( 'mainwp_updates_perplugin_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1578 - MainWP_Updates_Per_Item::render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins );
1579 - /**
1580 - * Action: mainwp_updates_perplugin_after_abandoned_plugins
1581 - *
1582 - * Fires at the bottom of the Abandoned plugins tab, per Plugin view.
1583 - *
1584 - * @param object $websites Object containing child sites info.
1585 - * @param array $all_groups_sites Array of all groups and sites.
1586 - * @param array $all_groups Array of all groups.
1587 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1588 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1589 - * @param int $site_offset_for_groups Offset value.
1590 - *
1591 - * @since 4.1
1592 - */
1593 - do_action( 'mainwp_updates_perplugin_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1594 - }
1595 - /**
1596 - * Action: mainwp_updates_after_abandoned_plugins
1597 - *
1598 - * Fires at the bottom of the Abandoned plugins tab.
1599 - *
1600 - * @param object $websites Object containing child sites info.
1601 - * @param array $all_groups_sites Array of all groups and sites.
1602 - * @param array $all_groups Array of all groups.
1603 - * @param array $allPluginsOutdate Array of all abandoned plugins.
1604 - * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1605 - * @param int $site_offset_for_groups Offset value.
1606 - *
1607 - * @since 4.1
1608 - */
1609 - do_action( 'mainwp_updates_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1610 - ?>
1611 - </div>
1612 - <?php
1613 - }
822 + $hooks_tabs = apply_filters( 'mainwp_pages_updates_render_tabs', false, $current_tab );
1614 823
1615 - /**
1616 - * Renders abandoned themes tab.
1617 - *
1618 - * @param object $websites Object containing child sites info.
1619 - * @param array $all_groups_sites Array of all groups and sites.
1620 - * @param array $all_groups Array of all groups.
1621 - * @param array $allThemesOutdate Array of all abandoned plugins.
1622 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1623 - * @param int $site_offset_for_groups Offset value.
1624 - * @param string $site_view Current site view.
1625 - *
1626 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_themes()
1627 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_themes()
1628 - * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_themes()
1629 - */
1630 - public static function render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view ) {
1631 - ?>
1632 - <div class="ui active tab" data-tab="abandoned-themes">
1633 - <?php
1634 - /**
1635 - * Action: mainwp_updates_before_abandoned_themes
1636 - *
1637 - * Fires at the top of the Abandoned themes tab.
1638 - *
1639 - * @param object $websites Object containing child sites info.
1640 - * @param array $all_groups_sites Array of all groups and sites.
1641 - * @param array $all_groups Array of all groups.
1642 - * @param array $allThemesOutdate Array of all abandoned plugins.
1643 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1644 - * @param int $site_offset_for_groups Offset value.
1645 - *
1646 - * @since 4.1
1647 - */
1648 - do_action( 'mainwp_updates_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1649 - if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1650 - /**
1651 - * Action: mainwp_updates_persite_before_abandoned_themes
1652 - *
1653 - * Fires at the top of the Abandoned themes tab, per Site view.
1654 - *
1655 - * @param object $websites Object containing child sites info.
1656 - * @param array $all_groups_sites Array of all groups and sites.
1657 - * @param array $all_groups Array of all groups.
1658 - * @param array $allThemesOutdate Array of all abandoned plugins.
1659 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1660 - * @param int $site_offset_for_groups Offset value.
1661 - *
1662 - * @since 4.1
1663 - */
1664 - do_action( 'mainwp_updates_persite_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1665 - MainWP_Updates_Per_Site::render_abandoned_themes( $websites, $decodedDismissedThemes );
1666 - /**
1667 - * Action: mainwp_updates_persite_after_abandoned_themes
1668 - *
1669 - * Fires at the bottom of the Abandoned themes tab, per Site view.
1670 - *
1671 - * @param object $websites Object containing child sites info.
1672 - * @param array $all_groups_sites Array of all groups and sites.
1673 - * @param array $all_groups Array of all groups.
1674 - * @param array $allThemesOutdate Array of all abandoned plugins.
1675 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1676 - * @param int $site_offset_for_groups Offset value.
1677 - *
1678 - * @since 4.1
1679 - */
1680 - do_action( 'mainwp_updates_persite_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1681 - } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1682 - /**
1683 - * Action: mainwp_updates_pergroup_before_abandoned_themes
1684 - *
1685 - * Fires at the top of the Abandoned themes tab, per Group view.
1686 - *
1687 - * @param object $websites Object containing child sites info.
1688 - * @param array $all_groups_sites Array of all groups and sites.
1689 - * @param array $all_groups Array of all groups.
1690 - * @param array $allThemesOutdate Array of all abandoned plugins.
1691 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1692 - * @param int $site_offset_for_groups Offset value.
1693 - *
1694 - * @since 4.1
1695 - */
1696 - do_action( 'mainwp_updates_pergroup_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1697 - MainWP_Updates_Per_Group::render_abandoned_themes( $websites, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes );
1698 - /**
1699 - * Action: mainwp_updates_pergroup_after_abandoned_themes
1700 - *
1701 - * Fires at the bottom of the Abandoned themes tab, per Group view.
1702 - *
1703 - * @param object $websites Object containing child sites info.
1704 - * @param array $all_groups_sites Array of all groups and sites.
1705 - * @param array $all_groups Array of all groups.
1706 - * @param array $allThemesOutdate Array of all abandoned plugins.
1707 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1708 - * @param int $site_offset_for_groups Offset value.
1709 - *
1710 - * @since 4.1
1711 - */
1712 - do_action( 'mainwp_updates_pergroup_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1713 - } else {
1714 - /**
1715 - * Action: mainwp_updates_pertheme_before_abandoned_themes
1716 - *
1717 - * Fires at the top of the Abandoned themes tab, per Theme view.
1718 - *
1719 - * @param object $websites Object containing child sites info.
1720 - * @param array $all_groups_sites Array of all groups and sites.
1721 - * @param array $all_groups Array of all groups.
1722 - * @param array $allThemesOutdate Array of all abandoned plugins.
1723 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1724 - * @param int $site_offset_for_groups Offset value.
1725 - *
1726 - * @since 4.1
1727 - */
1728 - do_action( 'mainwp_updates_pertheme_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1729 - MainWP_Updates_Per_Item::render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes );
1730 - /**
1731 - * Action: mainwp_updates_pertheme_after_abandoned_themes
1732 - *
1733 - * Fires at the bottom of the Abandoned themes tab, per Theme view.
1734 - *
1735 - * @param object $websites Object containing child sites info.
1736 - * @param array $all_groups_sites Array of all groups and sites.
1737 - * @param array $all_groups Array of all groups.
1738 - * @param array $allThemesOutdate Array of all abandoned plugins.
1739 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1740 - * @param int $site_offset_for_groups Offset value.
1741 - *
1742 - * @since 4.1
1743 - */
1744 - do_action( 'mainwp_updates_pertheme_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1745 - }
1746 - /**
1747 - * Action: mainwp_updates_after_abandoned_themes
1748 - *
1749 - * Fires at the bottom of the Abandoned themes tab.
1750 - *
1751 - * @param object $websites Object containing child sites info.
1752 - * @param array $all_groups_sites Array of all groups and sites.
1753 - * @param array $all_groups Array of all groups.
1754 - * @param array $allThemesOutdate Array of all abandoned plugins.
1755 - * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1756 - * @param int $site_offset_for_groups Offset value.
1757 - *
1758 - * @since 4.1
1759 - */
1760 - do_action( 'mainwp_updates_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1761 - ?>
1762 - </div>
1763 - <?php
1764 - }
824 + if ( false === $hooks_tabs ) {
825 + if ( 'wordpress-updates' === $current_tab ) {
826 + static::render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view );
827 + } elseif ( 'updates-ignore' === $current_tab ) {
828 + static::render_wp_ignore_update_tab( $websites, $userExtension );
829 + } elseif ( 'plugins-updates' === $current_tab ) {
830 + static::render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view );
831 + } elseif ( 'themes-updates' === $current_tab ) {
832 + static::render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view );
833 + } elseif ( 'translations-updates' === $current_tab ) {
834 + static::render_trans_update_tab( $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups, $site_view );
835 + } elseif ( 'abandoned-plugins' === $current_tab ) {
836 + static::render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view );
837 + } elseif ( 'abandoned-themes' === $current_tab ) {
838 + static::render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view );
839 + }
840 + ?>
841 + </div>
842 + <?php
843 + static::render_js_updates( $site_view );
844 + }
1765 845
1766 - /**
1767 - * Renders JavaScript for update page.
1768 - *
1769 - * @param string $site_view current site view.
1770 - */
1771 - public static function render_js_updates( $site_view ) {
1772 - $table_features = array(
1773 - 'searching' => 'false',
1774 - 'paging' => 'false',
1775 - 'stateSave' => 'true',
1776 - 'info' => 'false',
1777 - 'exclusive' => 'false',
1778 - 'duration' => '200',
1779 - );
1780 - /**
1781 - * Filter: mainwp_updates_table_features
1782 - *
1783 - * Filters the Updates table features.
1784 - *
1785 - * @since 4.1
1786 - */
1787 - $table_features = apply_filters( 'mainwp_updates_table_features', $table_features );
1788 - ?>
1789 - <script type="text/javascript">
1790 - jQuery( document ).ready( function () {
1791 - jQuery( '#mainwp-manage-updates .ui.accordion' ).accordion( {
1792 - "exclusive": <?php echo esc_html( $table_features['exclusive'] ); ?>,
1793 - "duration": <?php echo esc_html( $table_features['duration'] ); ?>,
1794 - onOpen: function(){
1795 - //mainwp_datatable_init_and_fix_recalc('table.mainwp-manage-updates-item-table');
1796 - }
1797 - } );
1798 - } );
846 + static::render_updates_modal();
1799 847
1800 - mainwp_datatable_init_and_fix_recalc = function(selector){
1801 - jQuery(selector).each( function(e) {
1802 - if(jQuery(this).is(":visible")){
1803 - console.log('visible ' + jQuery(this).attr('id'));
1804 - jQuery(this).css( 'display', 'table' );
1805 - jQuery(this).DataTable().destroy();
1806 - var tb = jQuery(this).DataTable({
1807 - "paging":false,
1808 - "info": false,
1809 - "searching": false,
1810 - "ordering" : false,
1811 - "responsive": true,
1812 - });
1813 - tb.columns.adjust();
1814 - tb.responsive.recalc();
1815 - }
1816 - });
1817 - }
848 + static::render_plugin_details_modal();
849 + MainWP_UI::render_modal_upload_icon();
850 + static::render_screen_options_modal();
851 + static::render_changes_history_modal();
852 + static::render_footer();
853 + ?>
854 + <script type="text/javascript">
855 + mainwp_manage_updates_screen_options = function () {
856 + jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'show' );
857 + jQuery( '#manage-updates-screen-options-form' ).submit( function() {
858 + jQuery( '#mainwp-manage-updates-screen-options-modal' ).modal( 'hide' );
859 + } );
860 + return false;
861 + };
862 + </script>
863 + <?php
864 + }
1818 865
1819 - jQuery( document ).on( 'click', '.trigger-all-accordion', function() {
1820 - if ( jQuery( this ).hasClass( 'active' ) ) {
1821 - jQuery( this ).removeClass( 'active' );
1822 - jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1823 - if ( jQuery( this ).hasClass( 'active' ) ) {
1824 - jQuery( this ).trigger( 'click' );
1825 - }
1826 - } );
1827 - } else {
1828 - jQuery( this ).addClass( 'active' );
1829 - jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1830 - if ( !jQuery( this ).hasClass( 'active' ) ) {
1831 - jQuery( this ).trigger( 'click' );
1832 - }
1833 - } );
1834 - }
1835 - } );
866 + /**
867 + * Render WP updates tab.
868 + *
869 + * @param object $websites Object containing child sites info.
870 + * @param object $userExtension User Extension object.
871 + * @param int $total_wp_upgrades Number of available WP upates.
872 + * @param array $all_groups_sites Array containing all groups and sites.
873 + * @param array $all_groups Array containing all groups.
874 + * @param int $site_offset_for_groups Offset value.
875 + * @param string $site_view Current view.
876 + *
877 + * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
878 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_wpcore_updates()
879 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_wpcore_updates()
880 + */
881 + public static function render_wp_update_tab( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $site_view ) {
882 + ?>
883 + <div class="ui active tab" data-tab="wordpress-updates">
884 + <?php
885 + /**
886 + * Action: mainwp_updates_before_wp_updates
887 + *
888 + * Fires at the top of the WP updates tab.
889 + *
890 + * @param object $websites Object containing child sites info.
891 + * @param int $total_wp_upgrades Number of available WP upates.
892 + * @param array $all_groups_sites Array containing all groups and sites.
893 + * @param array $all_groups Array containing all groups.
894 + * @param int $site_offset_for_groups Offset value.
895 + *
896 + * @since 4.1
897 + */
898 + do_action( 'mainwp_updates_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
899 + if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
900 + /**
901 + * Action: mainwp_updates_pergroup_before_wp_updates
902 + *
903 + * Fires at the top of the WP updates tab, per Group view.
904 + *
905 + * @param object $websites Object containing child sites info.
906 + * @param int $total_wp_upgrades Number of available WP upates.
907 + * @param array $all_groups_sites Array containing all groups and sites.
908 + * @param array $all_groups Array containing all groups.
909 + * @param int $site_offset_for_groups Offset value.
910 + *
911 + * @since 4.1
912 + */
913 + do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
914 + MainWP_Updates_Per_Group::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
915 + /**
916 + * Action: mainwp_updates_pergroup_after_wp_updates
917 + *
918 + * Fires at the bottom of the WP updates tab, per Group view.
919 + *
920 + * @param object $websites Object containing child sites info.
921 + * @param int $total_wp_upgrades Number of available WP upates.
922 + * @param array $all_groups_sites Array containing all groups and sites.
923 + * @param array $all_groups Array containing all groups.
924 + * @param int $site_offset_for_groups Offset value.
925 + *
926 + * @since 4.1
927 + */
928 + do_action( 'mainwp_updates_pergroup_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
929 + } else {
930 + /**
931 + * Action: mainwp_updates_persite_before_wp_updates
932 + *
933 + * Fires at the top of the WP updates tab, per Site view.
934 + *
935 + * @param object $websites Object containing child sites info.
936 + * @param int $total_wp_upgrades Number of available WP upates.
937 + * @param array $all_groups_sites Array containing all groups and sites.
938 + * @param array $all_groups Array containing all groups.
939 + * @param int $site_offset_for_groups Offset value.
940 + *
941 + * @since 4.1
942 + */
943 + do_action( 'mainwp_updates_pergroup_before_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
944 + MainWP_DB::data_seek( $websites, 0 );
945 + MainWP_Updates_Per_Site::render_wpcore_updates( $websites, $userExtension, $total_wp_upgrades );
946 + /**
947 + * Action: mainwp_updates_persite_after_wp_updates
948 + *
949 + * Fires at the bottom of the WP updates tab, per Site view.
950 + *
951 + * @param object $websites Object containing child sites info.
952 + * @param int $total_wp_upgrades Number of available WP upates.
953 + * @param array $all_groups_sites Array containing all groups and sites.
954 + * @param array $all_groups Array containing all groups.
955 + * @param int $site_offset_for_groups Offset value.
956 + *
957 + * @since 4.1
958 + */
959 + do_action( 'mainwp_updates_persite_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
960 + }
961 + /**
962 + * Action: mainwp_updates_after_wp_updates
963 + *
964 + * Fires at the top of the WP updates tab.
965 + *
966 + * @param object $websites Object containing child sites info.
967 + * @param int $total_wp_upgrades Number of available WP upates.
968 + * @param array $all_groups_sites Array containing all groups and sites.
969 + * @param array $all_groups Array containing all groups.
970 + * @param int $site_offset_for_groups Offset value.
971 + *
972 + * @since 4.1
973 + */
974 + do_action( 'mainwp_updates_after_wp_updates', $websites, $total_wp_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups );
975 + ?>
976 + </div>
977 + <?php
978 + }
1836 979
1837 - </script>
1838 - <?php
1839 980
1840 - if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1841 - ?>
1842 - <script type="text/javascript">
1843 - jQuery( document ).ready( function () {
1844 - updatesoverview_updates_init_group_view();
1845 - } );
1846 - </script>
1847 - <?php
1848 - }
1849 - }
981 + /**
982 + * Renders WP updates tab.
983 + *
984 + * @param array $websites Object containing child sites info.
985 + * @param object $userExtension User extension.
986 + */
987 + public static function render_wp_ignore_update_tab( $websites, $userExtension ) {
988 + MainWP_WP_Updates::instance()->render_ignore( $websites, $userExtension );
989 + }
1850 990
991 + /**
992 + * Renders WP updates tab.
993 + *
994 + * @param object $websites Object containing child sites info.
995 + * @param int $total_plugin_upgrades Number of available plugin updates.
996 + * @param object $userExtension User extension.
997 + * @param array $all_groups_sites Array of all groups and sites.
998 + * @param array $all_groups Array of all groups.
999 + * @param array $allPlugins Array of all plugins.
1000 + * @param array $pluginsInfo Array of all plugins info.
1001 + * @param int $site_offset_for_groups Offset value.
1002 + * @param string $site_view Current view.
1003 + *
1004 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_plugins_updates()
1005 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_plugins_updates()
1006 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_plugins_updates()
1007 + */
1008 + public static function render_plugins_update_tab( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups, $site_view ) { //phpcs:ignore -- NOSONAR - compatible.
1009 + $trustedPlugins = json_decode( $userExtension->trusted_plugins, true );
1010 + if ( ! is_array( $trustedPlugins ) ) {
1011 + $trustedPlugins = array();
1012 + }
1013 + ?>
1014 + <div class="ui active tab" data-tab="plugins-updates">
1015 + <?php
1016 + /**
1017 + * Action: mainwp_updates_before_plugin_updates
1018 + *
1019 + * Fires at the top of the Plugin updates tab.
1020 + *
1021 + * @param object $websites Object containing child sites info.
1022 + * @param int $total_plugin_upgrades Number of available plugin updates.
1023 + * @param object $userExtension User extension.
1024 + * @param array $all_groups_sites Array of all groups and sites.
1025 + * @param array $all_groups Array of all groups.
1026 + * @param array $allPlugins Array of all plugins.
1027 + * @param array $pluginsInfo Array of all plugins info.
1028 + * @param int $site_offset_for_groups Offset value.
1029 + *
1030 + * @since 4.1
1031 + */
1032 + do_action( 'mainwp_updates_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1033 + if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1034 + /**
1035 + * Action: mainwp_updates_persite_before_plugin_updates
1036 + *
1037 + * Fires at the top of the Plugin updates tab, per Site view.
1038 + *
1039 + * @param object $websites Object containing child sites info.
1040 + * @param int $total_plugin_upgrades Number of available plugin updates.
1041 + * @param object $userExtension User extension.
1042 + * @param array $all_groups_sites Array of all groups and sites.
1043 + * @param array $all_groups Array of all groups.
1044 + * @param array $allPlugins Array of all plugins.
1045 + * @param array $pluginsInfo Array of all plugins info.
1046 + * @param int $site_offset_for_groups Offset value.
1047 + *
1048 + * @since 4.1
1049 + */
1050 + do_action( 'mainwp_updates_persite_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1051 + MainWP_Updates_Per_Site::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $trustedPlugins );
1052 + /**
1053 + * Action: mainwp_updates_persite_after_plugin_updates
1054 + *
1055 + * Fires at the bottom of the Plugin updates tab, per Site view.
1056 + *
1057 + * @param object $websites Object containing child sites info.
1058 + * @param int $total_plugin_upgrades Number of available plugin updates.
1059 + * @param object $userExtension User extension.
1060 + * @param array $all_groups_sites Array of all groups and sites.
1061 + * @param array $all_groups Array of all groups.
1062 + * @param array $allPlugins Array of all plugins.
1063 + * @param array $pluginsInfo Array of all plugins info.
1064 + * @param int $site_offset_for_groups Offset value.
1065 + *
1066 + * @since 4.1
1067 + */
1068 + do_action( 'mainwp_updates_persite_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1069 + } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1070 + /**
1071 + * Action: mainwp_updates_pergroup_before_plugin_updates
1072 + *
1073 + * Fires at the top of the Plugin updates tab, per Group view.
1074 + *
1075 + * @param object $websites Object containing child sites info.
1076 + * @param int $total_plugin_upgrades Number of available plugin updates.
1077 + * @param object $userExtension User extension.
1078 + * @param array $all_groups_sites Array of all groups and sites.
1079 + * @param array $all_groups Array of all groups.
1080 + * @param array $allPlugins Array of all plugins.
1081 + * @param array $pluginsInfo Array of all plugins info.
1082 + * @param int $site_offset_for_groups Offset value.
1083 + *
1084 + * @since 4.1
1085 + */
1086 + do_action( 'mainwp_updates_pergroup_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1087 + MainWP_Updates_Per_Group::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedPlugins );
1088 + /**
1089 + * Action: mainwp_updates_pergroup_after_plugin_updates
1090 + *
1091 + * Fires at the bottom of the Plugin updates tab, per Group view.
1092 + *
1093 + * @param object $websites Object containing child sites info.
1094 + * @param int $total_plugin_upgrades Number of available plugin updates.
1095 + * @param object $userExtension User extension.
1096 + * @param array $all_groups_sites Array of all groups and sites.
1097 + * @param array $all_groups Array of all groups.
1098 + * @param array $allPlugins Array of all plugins.
1099 + * @param array $pluginsInfo Array of all plugins info.
1100 + * @param int $site_offset_for_groups Offset value.
1101 + *
1102 + * @since 4.1
1103 + */
1104 + do_action( 'mainwp_updates_pergroup_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1105 + } else {
1106 + /**
1107 + * Action: mainwp_updates_perplugin_before_plugin_updates
1108 + *
1109 + * Fires at the top of the Plugin updates tab, per Plugin view.
1110 + *
1111 + * @param object $websites Object containing child sites info.
1112 + * @param int $total_plugin_upgrades Number of available plugin updates.
1113 + * @param object $userExtension User extension.
1114 + * @param array $all_groups_sites Array of all groups and sites.
1115 + * @param array $all_groups Array of all groups.
1116 + * @param array $allPlugins Array of all plugins.
1117 + * @param array $pluginsInfo Array of all plugins info.
1118 + * @param int $site_offset_for_groups Offset value.
1119 + *
1120 + * @since 4.1
1121 + */
1122 + do_action( 'mainwp_updates_perplugin_before_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1123 + MainWP_Updates_Per_Item::render_plugins_updates( $websites, $total_plugin_upgrades, $userExtension, $allPlugins, $pluginsInfo, $trustedPlugins );
1124 + /**
1125 + * Action: mainwp_updates_perplugin_after_plugin_updates
1126 + *
1127 + * Fires at the bottom of the Plugin updates tab, per Plugin view.
1128 + *
1129 + * @param object $websites Object containing child sites info.
1130 + * @param int $total_plugin_upgrades Number of available plugin updates.
1131 + * @param object $userExtension User extension.
1132 + * @param array $all_groups_sites Array of all groups and sites.
1133 + * @param array $all_groups Array of all groups.
1134 + * @param array $allPlugins Array of all plugins.
1135 + * @param array $pluginsInfo Array of all plugins info.
1136 + * @param int $site_offset_for_groups Offset value.
1137 + *
1138 + * @since 4.1
1139 + */
1140 + do_action( 'mainwp_updates_perplugin_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1141 + }
1142 + /**
1143 + * Action: mainwp_updates_after_plugin_updates
1144 + *
1145 + * Fires at the bottom of the Plugin updates tab.
1146 + *
1147 + * @param object $websites Object containing child sites info.
1148 + * @param int $total_plugin_upgrades Number of available plugin updates.
1149 + * @param object $userExtension User extension.
1150 + * @param array $all_groups_sites Array of all groups and sites.
1151 + * @param array $all_groups Array of all groups.
1152 + * @param array $allPlugins Array of all plugins.
1153 + * @param array $pluginsInfo Array of all plugins info.
1154 + * @param int $site_offset_for_groups Offset value.
1155 + *
1156 + * @since 4.1
1157 + */
1158 + do_action( 'mainwp_updates_after_plugin_updates', $websites, $total_plugin_upgrades, $userExtension, $all_groups_sites, $all_groups, $allPlugins, $pluginsInfo, $site_offset_for_groups );
1159 + ?>
1160 + </div>
1161 + <?php
1162 + }
1851 1163
1852 - /**
1853 - * Gets sites for updates
1854 - *
1855 - * @return object Object containing websites info.
1856 - *
1857 - * @uses \MainWP\Dashboard\MainWP_DB::query()
1858 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id()
1859 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1860 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1861 - * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1862 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
1863 - */
1864 - public static function get_sites_for_current_user() {
1865 - /**
1866 - * Current user global.
1867 - *
1868 - * @global string
1869 - */
1870 - global $current_user;
1164 + /**
1165 + * Renders theme update tab.
1166 + *
1167 + * @param object $websites Object containing child sites info.
1168 + * @param int $total_theme_upgrades Number of available theme updates.
1169 + * @param object $userExtension User extension.
1170 + * @param array $all_groups_sites Array of all groups and sites.
1171 + * @param array $all_groups Array of all groups.
1172 + * @param array $allThemes Array of all themes.
1173 + * @param array $themesInfo Array of all themes info.
1174 + * @param int $site_offset_for_groups Offset value.
1175 + * @param string $site_view Current view.
1176 + *
1177 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_themes_updates()
1178 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_themes_updates()
1179 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_themes_updates()
1180 + */
1181 + public static function render_themes_update_tab( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups, $site_view ) { //phpcs:ignore -- NOSONAR - compatible.
1182 + $trustedThemes = json_decode( $userExtension->trusted_themes, true );
1183 + if ( ! is_array( $trustedThemes ) ) {
1184 + $trustedThemes = array();
1185 + }
1186 + ?>
1187 + <div class="ui active tab" data-tab="themes-updates">
1188 + <?php
1189 + /**
1190 + * Action: mainwp_updates_before_theme_updates
1191 + *
1192 + * Fires at the top of the Theme updates tab.
1193 + *
1194 + * @param object $websites Object containing child sites info.
1195 + * @param int $total_theme_upgrades Number of available theme updates.
1196 + * @param object $userExtension User extension.
1197 + * @param array $all_groups_sites Array of all groups and sites.
1198 + * @param array $all_groups Array of all groups.
1199 + * @param array $allThemes Array of all themes.
1200 + * @param array $themesInfo Array of all themes info.
1201 + * @param int $site_offset_for_groups Offset value.
1202 + *
1203 + * @since 4.1
1204 + */
1205 + do_action( 'mainwp_updates_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1206 + if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1207 + /**
1208 + * Action: mainwp_updates_persite_before_theme_updates
1209 + *
1210 + * Fires at the top of the Theme updates tab, per Site view.
1211 + *
1212 + * @param object $websites Object containing child sites info.
1213 + * @param int $total_theme_upgrades Number of available theme updates.
1214 + * @param object $userExtension User extension.
1215 + * @param array $all_groups_sites Array of all groups and sites.
1216 + * @param array $all_groups Array of all groups.
1217 + * @param array $allThemes Array of all themes.
1218 + * @param array $themesInfo Array of all themes info.
1219 + * @param int $site_offset_for_groups Offset value.
1220 + *
1221 + * @since 4.1
1222 + */
1223 + do_action( 'mainwp_updates_persite_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1224 + MainWP_Updates_Per_Site::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $trustedThemes );
1225 + /**
1226 + * Action: mainwp_updates_persite_after_theme_updates
1227 + *
1228 + * Fires at the bottom of the Theme updates tab, per Site view.
1229 + *
1230 + * @param object $websites Object containing child sites info.
1231 + * @param int $total_theme_upgrades Number of available theme updates.
1232 + * @param object $userExtension User extension.
1233 + * @param array $all_groups_sites Array of all groups and sites.
1234 + * @param array $all_groups Array of all groups.
1235 + * @param array $allThemes Array of all themes.
1236 + * @param array $themesInfo Array of all themes info.
1237 + * @param int $site_offset_for_groups Offset value.
1238 + *
1239 + * @since 4.1
1240 + */
1241 + do_action( 'mainwp_updates_persite_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1242 + } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1243 + /**
1244 + * Action: mainwp_updates_pergroup_before_theme_updates
1245 + *
1246 + * Fires at the top of the Theme updates tab, per Group view.
1247 + *
1248 + * @param object $websites Object containing child sites info.
1249 + * @param int $total_theme_upgrades Number of available theme updates.
1250 + * @param object $userExtension User extension.
1251 + * @param array $all_groups_sites Array of all groups and sites.
1252 + * @param array $all_groups Array of all groups.
1253 + * @param array $allThemes Array of all themes.
1254 + * @param array $themesInfo Array of all themes info.
1255 + * @param int $site_offset_for_groups Offset value.
1256 + *
1257 + * @since 4.1
1258 + */
1259 + do_action( 'mainwp_updates_pergroup_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1260 + MainWP_Updates_Per_Group::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $site_offset_for_groups, $trustedThemes );
1261 + /**
1262 + * Action: mainwp_updates_pergroup_after_theme_updates
1263 + *
1264 + * Fires at the bottom of the Theme updates tab, per Group view.
1265 + *
1266 + * @param object $websites Object containing child sites info.
1267 + * @param int $total_theme_upgrades Number of available theme updates.
1268 + * @param object $userExtension User extension.
1269 + * @param array $all_groups_sites Array of all groups and sites.
1270 + * @param array $all_groups Array of all groups.
1271 + * @param array $allThemes Array of all themes.
1272 + * @param array $themesInfo Array of all themes info.
1273 + * @param int $site_offset_for_groups Offset value.
1274 + *
1275 + * @since 4.1
1276 + */
1277 + do_action( 'mainwp_updates_pergroup_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1278 + } else {
1279 + /**
1280 + * Action: mainwp_updates_pertheme_before_theme_updates
1281 + *
1282 + * Fires at the top of the Theme updates tab, per Theme view.
1283 + *
1284 + * @param object $websites Object containing child sites info.
1285 + * @param int $total_theme_upgrades Number of available theme updates.
1286 + * @param object $userExtension User extension.
1287 + * @param array $all_groups_sites Array of all groups and sites.
1288 + * @param array $all_groups Array of all groups.
1289 + * @param array $allThemes Array of all themes.
1290 + * @param array $themesInfo Array of all themes info.
1291 + * @param int $site_offset_for_groups Offset value.
1292 + *
1293 + * @since 4.1
1294 + */
1295 + do_action( 'mainwp_updates_pertheme_before_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1296 + MainWP_Updates_Per_Item::render_themes_updates( $websites, $total_theme_upgrades, $userExtension, $allThemes, $themesInfo, $trustedThemes );
1297 + /**
1298 + * Action: mainwp_updates_pertheme_after_theme_updates
1299 + *
1300 + * Fires at the bottom of the Theme updates tab, per Theme view.
1301 + *
1302 + * @param object $websites Object containing child sites info.
1303 + * @param int $total_theme_upgrades Number of available theme updates.
1304 + * @param object $userExtension User extension.
1305 + * @param array $all_groups_sites Array of all groups and sites.
1306 + * @param array $all_groups Array of all groups.
1307 + * @param array $allThemes Array of all themes.
1308 + * @param array $themesInfo Array of all themes info.
1309 + * @param int $site_offset_for_groups Offset value.
1310 + *
1311 + * @since 4.1
1312 + */
1313 + do_action( 'mainwp_updates_pertheme_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1314 + }
1315 + /**
1316 + * Action: mainwp_updates_after_theme_updates
1317 + *
1318 + * Fires at the bottom of the Theme updates tab.
1319 + *
1320 + * @param object $websites Object containing child sites info.
1321 + * @param int $total_theme_upgrades Number of available theme updates.
1322 + * @param object $userExtension User extension.
1323 + * @param array $all_groups_sites Array of all groups and sites.
1324 + * @param array $all_groups Array of all groups.
1325 + * @param array $allThemes Array of all themes.
1326 + * @param array $themesInfo Array of all themes info.
1327 + * @param int $site_offset_for_groups Offset value.
1328 + *
1329 + * @since 4.1
1330 + */
1331 + do_action( 'mainwp_updates_after_theme_updates', $websites, $total_theme_upgrades, $userExtension, $all_groups_sites, $all_groups, $allThemes, $themesInfo, $site_offset_for_groups );
1332 + ?>
1333 + </div>
1334 + <?php
1335 + }
1871 1336
1872 - $current_wpid = MainWP_System_Utility::get_current_wpid();
1873 - if ( $current_wpid ) {
1874 - $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
1875 - } else {
1876 - $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
1877 - $is_staging = 'no';
1878 - if ( $staging_enabled ) {
1879 - $staging_updates_view = MainWP_System_Utility::get_staging_options_sites_view_for_current_users();
1880 - if ( 'staging' === $staging_updates_view ) {
1881 - $is_staging = 'yes';
1882 - }
1883 - }
1884 - $params = array(
1885 - 'connected' => 'yes',
1886 - );
1887 - $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ), $is_staging, $params );
1888 - }
1889 - return MainWP_DB::instance()->query( $sql );
1890 - }
1337 + /**
1338 + * Renders translations update tab.
1339 + *
1340 + * @param object $websites Object containing child sites info.
1341 + * @param int $total_translation_upgrades Number of available translation updates.
1342 + * @param object $userExtension User extension.
1343 + * @param array $all_groups_sites Array of all groups and sites.
1344 + * @param array $all_groups Array of all groups.
1345 + * @param array $allTranslations Array of all translations.
1346 + * @param array $translationsInfo Array of all translations info.
1347 + * @param bool $mainwp_show_language_updates Either or not show language updates.
1348 + * @param int $site_offset_for_groups Offset value.
1349 + * @param string $site_view Current Site view.
1350 + *
1351 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_trans_update()
1352 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_trans_update()
1353 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_trans_update()
1354 + */
1355 + public static function render_trans_update_tab( $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups, $site_view ) { //phpcs:ignore -- NOSONAR - compatible.
1356 + if ( 1 === (int) $mainwp_show_language_updates ) {
1357 + ?>
1358 + <div class="ui active tab" data-tab="translations-updates">
1359 + <?php
1360 + /**
1361 + * Action: mainwp_updates_before_translation_updates
1362 + *
1363 + * Fires at the top of the Translation updates tab.
1364 + *
1365 + * @param object $websites Object containing child sites info.
1366 + * @param int $total_translation_upgrades Number of available translation updates.
1367 + * @param object $userExtension User extension.
1368 + * @param array $all_groups_sites Array of all groups and sites.
1369 + * @param array $all_groups Array of all groups.
1370 + * @param array $allTranslations Array of all translations.
1371 + * @param array $translationsInfo Array of all translations info.
1372 + * @param int $site_offset_for_groups Offset value.
1373 + *
1374 + * @since 4.1
1375 + */
1376 + do_action( 'mainwp_updates_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1377 + if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1378 + /**
1379 + * Action: mainwp_updates_persite_before_translation_updates
1380 + *
1381 + * Fires at the top of the Translation updates tab, per Site view.
1382 + *
1383 + * @param object $websites Object containing child sites info.
1384 + * @param int $total_translation_upgrades Number of available translation updates.
1385 + * @param object $userExtension User extension.
1386 + * @param array $all_groups_sites Array of all groups and sites.
1387 + * @param array $all_groups Array of all groups.
1388 + * @param array $allTranslations Array of all translations.
1389 + * @param array $translationsInfo Array of all translations info.
1390 + * @param int $site_offset_for_groups Offset value.
1391 + *
1392 + * @since 4.1
1393 + */
1394 + do_action( 'mainwp_updates_persite_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1395 + MainWP_Updates_Per_Site::render_trans_update( $websites, $total_translation_upgrades, $userExtension );
1396 + /**
1397 + * Action: mainwp_updates_persite_after_translation_updates
1398 + *
1399 + * Fires at the bottom of the Translation updates tab, per Site view.
1400 + *
1401 + * @param object $websites Object containing child sites info.
1402 + * @param int $total_translation_upgrades Number of available translation updates.
1403 + * @param object $userExtension User extension.
1404 + * @param array $all_groups_sites Array of all groups and sites.
1405 + * @param array $all_groups Array of all groups.
1406 + * @param array $allTranslations Array of all translations.
1407 + * @param array $translationsInfo Array of all translations info.
1408 + * @param int $site_offset_for_groups Offset value.
1409 + *
1410 + * @since 4.1
1411 + */
1412 + do_action( 'mainwp_updates_persite_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1413 + } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1414 + /**
1415 + * Action: mainwp_updates_pergroup_before_translation_updates
1416 + *
1417 + * Fires at the top of the Translation updates tab, per Group view.
1418 + *
1419 + * @param object $websites Object containing child sites info.
1420 + * @param int $total_translation_upgrades Number of available translation updates.
1421 + * @param object $userExtension User extension.
1422 + * @param array $all_groups_sites Array of all groups and sites.
1423 + * @param array $all_groups Array of all groups.
1424 + * @param array $allTranslations Array of all translations.
1425 + * @param array $translationsInfo Array of all translations info.
1426 + * @param int $site_offset_for_groups Offset value.
1427 + *
1428 + * @since 4.1
1429 + */
1430 + do_action( 'mainwp_updates_pergroup_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1431 + MainWP_Updates_Per_Group::render_trans_update( $websites, $total_translation_upgrades, $all_groups_sites, $all_groups, $site_offset_for_groups, $userExtension );
1432 + /**
1433 + * Action: mainwp_updates_pergroup_after_translation_updates
1434 + *
1435 + * Fires at the bottom of the Translation updates tab, per Group view.
1436 + *
1437 + * @param object $websites Object containing child sites info.
1438 + * @param int $total_translation_upgrades Number of available translation updates.
1439 + * @param object $userExtension User extension.
1440 + * @param array $all_groups_sites Array of all groups and sites.
1441 + * @param array $all_groups Array of all groups.
1442 + * @param array $allTranslations Array of all translations.
1443 + * @param array $translationsInfo Array of all translations info.
1444 + * @param int $site_offset_for_groups Offset value.
1445 + *
1446 + * @since 4.1
1447 + */
1448 + do_action( 'mainwp_updates_pergroup_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1449 + } else {
1450 + /**
1451 + * Action: mainwp_updates_pertranslation_before_translation_updates
1452 + *
1453 + * Fires at the top of the Translation updates tab, per Translation view.
1454 + *
1455 + * @param object $websites Object containing child sites info.
1456 + * @param int $total_translation_upgrades Number of available translation updates.
1457 + * @param object $userExtension User extension.
1458 + * @param array $all_groups_sites Array of all groups and sites.
1459 + * @param array $all_groups Array of all groups.
1460 + * @param array $allTranslations Array of all translations.
1461 + * @param array $translationsInfo Array of all translations info.
1462 + * @param int $site_offset_for_groups Offset value.
1463 + *
1464 + * @since 4.1
1465 + */
1466 + do_action( 'mainwp_updates_pertranslation_before_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1467 + MainWP_Updates_Per_Item::render_trans_update( $websites, $total_translation_upgrades, $userExtension, $allTranslations, $translationsInfo );
1468 + /**
1469 + * Action: mainwp_updates_pertranslation_after_translation_updates
1470 + *
1471 + * Fires at the bottom of the Translation updates tab, per Translation view.
1472 + *
1473 + * @param object $websites Object containing child sites info.
1474 + * @param int $total_translation_upgrades Number of available translation updates.
1475 + * @param object $userExtension User extension.
1476 + * @param array $all_groups_sites Array of all groups and sites.
1477 + * @param array $all_groups Array of all groups.
1478 + * @param array $allTranslations Array of all translations.
1479 + * @param array $translationsInfo Array of all translations info.
1480 + * @param int $site_offset_for_groups Offset value.
1481 + *
1482 + * @since 4.1
1483 + */
1484 + do_action( 'mainwp_updates_pertranslation_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1485 + }
1486 + /**
1487 + * Action: mainwp_updates_after_translation_updates
1488 + *
1489 + * Fires at the bottom of the Translation updates tab.
1490 + *
1491 + * @param object $websites Object containing child sites info.
1492 + * @param int $total_translation_upgrades Number of available translation updates.
1493 + * @param object $userExtension User extension.
1494 + * @param array $all_groups_sites Array of all groups and sites.
1495 + * @param array $all_groups Array of all groups.
1496 + * @param array $allTranslations Array of all translations.
1497 + * @param array $translationsInfo Array of all translations info.
1498 + * @param int $site_offset_for_groups Offset value.
1499 + *
1500 + * @since 4.1
1501 + */
1502 + do_action( 'mainwp_updates_after_translation_updates', $websites, $total_translation_upgrades, $userExtension, $all_groups_sites, $all_groups, $allTranslations, $translationsInfo, $mainwp_show_language_updates, $site_offset_for_groups );
1503 + ?>
1504 + </div>
1505 + <?php
1506 + }
1507 + }
1891 1508
1892 - /**
1893 - * Renders header tabs
1894 - *
1895 - * @param bool $show_language_updates show language update.
1896 - * @param string $current_tab current tab.
1897 - * @param int $total_wp_upgrades total WP update.
1898 - * @param int $total_plugin_upgrades total plugins update.
1899 - * @param int $total_theme_upgrades total themes update.
1900 - * @param int $total_translation_upgrades total translation update.
1901 - * @param int $total_plugins_outdate total plugins outdate.
1902 - * @param int $total_themes_outdate total theme outdate.
1903 - * @param string $site_view current site view.
1904 - */
1905 - public static function render_header_tabs( $show_language_updates, $current_tab, $total_wp_upgrades, $total_plugin_upgrades, $total_theme_upgrades, $total_translation_upgrades, $total_plugins_outdate, $total_themes_outdate, $site_view ) { // phpcs:ignore -- Current complexity is the only way to achieve desired results, pull request solutions appreciated.
1509 + /**
1510 + * Renders abandoned plugins tab.
1511 + *
1512 + * @param object $websites Object containing child sites info.
1513 + * @param array $all_groups_sites Array of all groups and sites.
1514 + * @param array $all_groups Array of all groups.
1515 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1516 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1517 + * @param int $site_offset_for_groups Offset value.
1518 + * @param string $site_view Current site view.
1519 + *
1520 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_plugins()
1521 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_plugins()
1522 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_plugins()
1523 + */
1524 + public static function render_abandoned_plugins_tab( $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups, $site_view ) {
1525 + ?>
1526 + <div class="ui active tab" data-tab="abandoned-plugins">
1527 + <?php
1528 + /**
1529 + * Action: mainwp_updates_before_abandoned_plugins
1530 + *
1531 + * Fires at the top of the Abandoned plugins tab.
1532 + *
1533 + * @param object $websites Object containing child sites info.
1534 + * @param array $all_groups_sites Array of all groups and sites.
1535 + * @param array $all_groups Array of all groups.
1536 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1537 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1538 + * @param int $site_offset_for_groups Offset value.
1539 + *
1540 + * @since 4.1
1541 + */
1542 + do_action( 'mainwp_updates_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1543 + if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1544 + /**
1545 + * Action: mainwp_updates_persite_before_abandoned_plugins
1546 + *
1547 + * Fires at the top of the Abandoned plugins tab, per Site view.
1548 + *
1549 + * @param object $websites Object containing child sites info.
1550 + * @param array $all_groups_sites Array of all groups and sites.
1551 + * @param array $all_groups Array of all groups.
1552 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1553 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1554 + * @param int $site_offset_for_groups Offset value.
1555 + *
1556 + * @since 4.1
1557 + */
1558 + do_action( 'mainwp_updates_persite_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1559 + MainWP_Updates_Per_Site::render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins );
1560 + /**
1561 + * Action: mainwp_updates_persite_after_abandoned_plugins
1562 + *
1563 + * Fires at the bottom of the Abandoned plugins tab, per Site view.
1564 + *
1565 + * @param object $websites Object containing child sites info.
1566 + * @param array $all_groups_sites Array of all groups and sites.
1567 + * @param array $all_groups Array of all groups.
1568 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1569 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1570 + * @param int $site_offset_for_groups Offset value.
1571 + *
1572 + * @since 4.1
1573 + */
1574 + do_action( 'mainwp_updates_persite_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1575 + } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1576 + /**
1577 + * Action: mainwp_updates_pergroup_before_abandoned_plugins
1578 + *
1579 + * Fires at the top of the Abandoned plugins tab, per Group view.
1580 + *
1581 + * @param object $websites Object containing child sites info.
1582 + * @param array $all_groups_sites Array of all groups and sites.
1583 + * @param array $all_groups Array of all groups.
1584 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1585 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1586 + * @param int $site_offset_for_groups Offset value.
1587 + *
1588 + * @since 4.1
1589 + */
1590 + do_action( 'mainwp_updates_pergroup_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1591 + MainWP_Updates_Per_Group::render_abandoned_plugins( $websites, $allPluginsOutdate, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedPlugins );
1592 + /**
1593 + * Action: mainwp_updates_pergroup_after_abandoned_plugins
1594 + *
1595 + * Fires at the bottom of the Abandoned plugins tab, per Group view.
1596 + *
1597 + * @param object $websites Object containing child sites info.
1598 + * @param array $all_groups_sites Array of all groups and sites.
1599 + * @param array $all_groups Array of all groups.
1600 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1601 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1602 + * @param int $site_offset_for_groups Offset value.
1603 + *
1604 + * @since 4.1
1605 + */
1606 + do_action( 'mainwp_updates_pergroup_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1607 + } else {
1608 + /**
1609 + * Action: mainwp_updates_perplugin_before_abandoned_plugins
1610 + *
1611 + * Fires at the top of the Abandoned plugins tab, per Plugin view.
1612 + *
1613 + * @param object $websites Object containing child sites info.
1614 + * @param array $all_groups_sites Array of all groups and sites.
1615 + * @param array $all_groups Array of all groups.
1616 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1617 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1618 + * @param int $site_offset_for_groups Offset value.
1619 + *
1620 + * @since 4.1
1621 + */
1622 + do_action( 'mainwp_updates_perplugin_before_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1623 + MainWP_Updates_Per_Item::render_abandoned_plugins( $websites, $allPluginsOutdate, $decodedDismissedPlugins );
1624 + /**
1625 + * Action: mainwp_updates_perplugin_after_abandoned_plugins
1626 + *
1627 + * Fires at the bottom of the Abandoned plugins tab, per Plugin view.
1628 + *
1629 + * @param object $websites Object containing child sites info.
1630 + * @param array $all_groups_sites Array of all groups and sites.
1631 + * @param array $all_groups Array of all groups.
1632 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1633 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1634 + * @param int $site_offset_for_groups Offset value.
1635 + *
1636 + * @since 4.1
1637 + */
1638 + do_action( 'mainwp_updates_perplugin_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1639 + }
1640 + /**
1641 + * Action: mainwp_updates_after_abandoned_plugins
1642 + *
1643 + * Fires at the bottom of the Abandoned plugins tab.
1644 + *
1645 + * @param object $websites Object containing child sites info.
1646 + * @param array $all_groups_sites Array of all groups and sites.
1647 + * @param array $all_groups Array of all groups.
1648 + * @param array $allPluginsOutdate Array of all abandoned plugins.
1649 + * @param array $decodedDismissedPlugins Array of dismissed abandoned plugins.
1650 + * @param int $site_offset_for_groups Offset value.
1651 + *
1652 + * @since 4.1
1653 + */
1654 + do_action( 'mainwp_updates_after_abandoned_plugins', $websites, $all_groups_sites, $all_groups, $allPluginsOutdate, $decodedDismissedPlugins, $site_offset_for_groups );
1655 + ?>
1656 + </div>
1657 + <?php
1658 + }
1906 1659
1907 - /**
1908 - * Action: mainwp_updates_before_nav_tabs
1909 - *
1910 - * Fires before the navigation tabs on the Updates page.
1911 - *
1912 - * @since 4.1
1913 - */
1914 - do_action( 'mainwp_updates_before_nav_tabs' );
1660 + /**
1661 + * Renders abandoned themes tab.
1662 + *
1663 + * @param object $websites Object containing child sites info.
1664 + * @param array $all_groups_sites Array of all groups and sites.
1665 + * @param array $all_groups Array of all groups.
1666 + * @param array $allThemesOutdate Array of all abandoned plugins.
1667 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1668 + * @param int $site_offset_for_groups Offset value.
1669 + * @param string $site_view Current site view.
1670 + *
1671 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Group::render_abandoned_themes()
1672 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Item::render_abandoned_themes()
1673 + * @uses \MainWP\Dashboard\MainWP_Updates_Per_Site::render_abandoned_themes()
1674 + */
1675 + public static function render_abandoned_themes_tab( $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups, $site_view ) {
1676 + ?>
1677 + <div class="ui active tab" data-tab="abandoned-themes">
1678 + <?php
1679 + /**
1680 + * Action: mainwp_updates_before_abandoned_themes
1681 + *
1682 + * Fires at the top of the Abandoned themes tab.
1683 + *
1684 + * @param object $websites Object containing child sites info.
1685 + * @param array $all_groups_sites Array of all groups and sites.
1686 + * @param array $all_groups Array of all groups.
1687 + * @param array $allThemesOutdate Array of all abandoned plugins.
1688 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1689 + * @param int $site_offset_for_groups Offset value.
1690 + *
1691 + * @since 4.1
1692 + */
1693 + do_action( 'mainwp_updates_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1694 + if ( MAINWP_VIEW_PER_SITE === $site_view ) {
1695 + /**
1696 + * Action: mainwp_updates_persite_before_abandoned_themes
1697 + *
1698 + * Fires at the top of the Abandoned themes tab, per Site view.
1699 + *
1700 + * @param object $websites Object containing child sites info.
1701 + * @param array $all_groups_sites Array of all groups and sites.
1702 + * @param array $all_groups Array of all groups.
1703 + * @param array $allThemesOutdate Array of all abandoned plugins.
1704 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1705 + * @param int $site_offset_for_groups Offset value.
1706 + *
1707 + * @since 4.1
1708 + */
1709 + do_action( 'mainwp_updates_persite_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1710 + MainWP_Updates_Per_Site::render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes );
1711 + /**
1712 + * Action: mainwp_updates_persite_after_abandoned_themes
1713 + *
1714 + * Fires at the bottom of the Abandoned themes tab, per Site view.
1715 + *
1716 + * @param object $websites Object containing child sites info.
1717 + * @param array $all_groups_sites Array of all groups and sites.
1718 + * @param array $all_groups Array of all groups.
1719 + * @param array $allThemesOutdate Array of all abandoned plugins.
1720 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1721 + * @param int $site_offset_for_groups Offset value.
1722 + *
1723 + * @since 4.1
1724 + */
1725 + do_action( 'mainwp_updates_persite_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1726 + } elseif ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1727 + /**
1728 + * Action: mainwp_updates_pergroup_before_abandoned_themes
1729 + *
1730 + * Fires at the top of the Abandoned themes tab, per Group view.
1731 + *
1732 + * @param object $websites Object containing child sites info.
1733 + * @param array $all_groups_sites Array of all groups and sites.
1734 + * @param array $all_groups Array of all groups.
1735 + * @param array $allThemesOutdate Array of all abandoned plugins.
1736 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1737 + * @param int $site_offset_for_groups Offset value.
1738 + *
1739 + * @since 4.1
1740 + */
1741 + do_action( 'mainwp_updates_pergroup_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1742 + MainWP_Updates_Per_Group::render_abandoned_themes( $websites, $allThemesOutdate, $all_groups_sites, $all_groups, $site_offset_for_groups, $decodedDismissedThemes );
1743 + /**
1744 + * Action: mainwp_updates_pergroup_after_abandoned_themes
1745 + *
1746 + * Fires at the bottom of the Abandoned themes tab, per Group view.
1747 + *
1748 + * @param object $websites Object containing child sites info.
1749 + * @param array $all_groups_sites Array of all groups and sites.
1750 + * @param array $all_groups Array of all groups.
1751 + * @param array $allThemesOutdate Array of all abandoned plugins.
1752 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1753 + * @param int $site_offset_for_groups Offset value.
1754 + *
1755 + * @since 4.1
1756 + */
1757 + do_action( 'mainwp_updates_pergroup_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1758 + } else {
1759 + /**
1760 + * Action: mainwp_updates_pertheme_before_abandoned_themes
1761 + *
1762 + * Fires at the top of the Abandoned themes tab, per Theme view.
1763 + *
1764 + * @param object $websites Object containing child sites info.
1765 + * @param array $all_groups_sites Array of all groups and sites.
1766 + * @param array $all_groups Array of all groups.
1767 + * @param array $allThemesOutdate Array of all abandoned plugins.
1768 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1769 + * @param int $site_offset_for_groups Offset value.
1770 + *
1771 + * @since 4.1
1772 + */
1773 + do_action( 'mainwp_updates_pertheme_before_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1774 + MainWP_Updates_Per_Item::render_abandoned_themes( $websites, $allThemesOutdate, $decodedDismissedThemes );
1775 + /**
1776 + * Action: mainwp_updates_pertheme_after_abandoned_themes
1777 + *
1778 + * Fires at the bottom of the Abandoned themes tab, per Theme view.
1779 + *
1780 + * @param object $websites Object containing child sites info.
1781 + * @param array $all_groups_sites Array of all groups and sites.
1782 + * @param array $all_groups Array of all groups.
1783 + * @param array $allThemesOutdate Array of all abandoned plugins.
1784 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1785 + * @param int $site_offset_for_groups Offset value.
1786 + *
1787 + * @since 4.1
1788 + */
1789 + do_action( 'mainwp_updates_pertheme_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1790 + }
1791 + /**
1792 + * Action: mainwp_updates_after_abandoned_themes
1793 + *
1794 + * Fires at the bottom of the Abandoned themes tab.
1795 + *
1796 + * @param object $websites Object containing child sites info.
1797 + * @param array $all_groups_sites Array of all groups and sites.
1798 + * @param array $all_groups Array of all groups.
1799 + * @param array $allThemesOutdate Array of all abandoned plugins.
1800 + * @param array $decodedDismissedThemes Array of dismissed abandoned plugins.
1801 + * @param int $site_offset_for_groups Offset value.
1802 + *
1803 + * @since 4.1
1804 + */
1805 + do_action( 'mainwp_updates_after_abandoned_themes', $websites, $all_groups_sites, $all_groups, $allThemesOutdate, $decodedDismissedThemes, $site_offset_for_groups );
1806 + ?>
1807 + </div>
1808 + <?php
1809 + }
1915 1810
1916 - $header_tabs = array(
1917 - 'plugins-updates' => array(
1918 - 'slug' => 'plugins-updates',
1919 - 'title' => esc_html__( 'Plugins Updates', 'mainwp' ),
1920 - 'total_upgrades' => $total_plugin_upgrades,
1921 - ),
1922 - 'themes-updates' => array(
1923 - 'slug' => 'themes-updates',
1924 - 'title' => esc_html__( 'Themes Updates', 'mainwp' ),
1925 - 'total_upgrades' => $total_theme_upgrades,
1926 - ),
1927 - 'wordpress-updates' => array(
1928 - 'slug' => 'wordpress-updates',
1929 - 'title' => esc_html__( 'WordPress Updates', 'mainwp' ),
1930 - 'total_upgrades' => $total_wp_upgrades,
1931 - ),
1932 - );
1811 + /**
1812 + * Renders JavaScript for update page.
1813 + *
1814 + * @param string $site_view current site view.
1815 + */
1816 + public static function render_js_updates( $site_view ) {
1817 + $table_features = array(
1818 + 'searching' => 'false',
1819 + 'paging' => 'false',
1820 + 'stateSave' => 'true',
1821 + 'info' => 'false',
1822 + 'exclusive' => 'false',
1823 + 'duration' => '200',
1824 + );
1825 + /**
1826 + * Filter: mainwp_updates_table_features
1827 + *
1828 + * Filters the Updates table features.
1829 + *
1830 + * @since 4.1
1831 + */
1832 + $table_features = apply_filters( 'mainwp_updates_table_features', $table_features );
1833 + ?>
1834 + <script type="text/javascript">
1835 + jQuery( document ).ready( function ($) {
1836 + jQuery( '#mainwp-manage-updates .ui.accordion' ).accordion( {
1837 + "exclusive": <?php echo esc_html( $table_features['exclusive'] ); ?>,
1838 + "duration": <?php echo esc_html( $table_features['duration'] ); ?>,
1839 + onOpen: function(){
1840 + //mainwp_datatable_init_and_fix_recalc('table.mainwp-manage-updates-item-table');
1841 + }
1842 + } );
1933 1843
1934 - if ( $show_language_updates ) {
1935 - $header_tabs['translations-updates'] = array(
1936 - 'slug' => 'translations-updates',
1937 - 'title' => esc_html__( 'Translations Updates', 'mainwp' ),
1938 - 'total_upgrades' => $total_translation_upgrades,
1939 - );
1940 - }
1844 + $('table.mainwp-js-persistent-table').each(function () {
1845 + const table = this; // DOM element
1846 + new TablePersistentState(table, {
1847 + headerSelector: '.handle-accordion-sorting',
1848 + onPersist:function( { table, column, direction, isrestore } ){
1849 + if(isrestore){
1850 + const $th = $(table).find(
1851 + `.handle-accordion-sorting[data-key="${column}"]` // header column must have data-key property.
1852 + );
1853 + if (!$th) return;
1854 + setTimeout(function () {// to fix binding delay issue.
1855 + $($th).trigger('click');
1856 + if(direction === 'desc'){
1857 + $($th).trigger('click');
1858 + }
1859 + }, 500);
1860 + }
1861 + }
1862 + });
1863 + });
1941 1864
1942 - $header_tabs['abandoned-plugins'] = array(
1943 - 'slug' => 'abandoned-plugins',
1944 - 'title' => esc_html__( 'Abandoned Plugins', 'mainwp' ),
1945 - 'total_upgrades' => $total_plugins_outdate,
1946 - );
1865 + } );
1947 1866
1948 - $header_tabs['abandoned-themes'] = array(
1949 - 'slug' => 'abandoned-themes',
1950 - 'title' => esc_html__( 'Abandoned Themes', 'mainwp' ),
1951 - 'total_upgrades' => $total_themes_outdate,
1952 - );
1867 + mainwp_datatable_init_and_fix_recalc = function(selector){
1868 + jQuery(selector).each( function(e) {
1869 + if(jQuery(this).is(":visible")){
1870 + jQuery(this).css( 'display', 'table' );
1871 + jQuery(this).DataTable().destroy();
1872 + let tb = jQuery(this).DataTable({
1873 + "paging":false,
1874 + "info": false,
1875 + "searching": false,
1876 + "ordering" : false,
1877 + "responsive": true
1878 + });
1879 + tb.columns.adjust();
1880 + tb.responsive.recalc();
1881 + }
1882 + });
1883 + }
1953 1884
1954 - $header_tabs = apply_filters( 'mainwp_page_hearder_tabs_updates', $header_tabs );
1955 1885
1956 - ?>
1957 - <div id="mainwp-page-navigation-wrapper">
1958 - <div class="ui vertical menu mainwp-page-navigation">
1959 - <?php
1960 - foreach ( $header_tabs as $slug => $tab ) {
1961 - if ( empty( $tab['title'] ) ) {
1962 - continue;
1963 - }
1964 - ?>
1965 - <a class="<?php echo( $slug === $current_tab ? 'active' : '' ); ?> item" data-tab="<?php echo esc_html( $slug ); ?>" href="admin.php?page=UpdatesManage&tab=<?php echo esc_html( $slug ); ?>"><?php echo esc_html( $tab['title'] ); ?><div class="ui small <?php echo empty( $tab['total_upgrades'] ) ? 'green' : 'red'; ?> label" timestamp="<?php echo esc_html( time() ); ?>"><?php echo intval( $tab['total_upgrades'] ); ?></div></a>
1966 - <?php
1967 - }
1968 - ?>
1969 - </div>
1970 - </div>
1971 - <?php
1972 1886
1973 - $hide_show_updates_per = apply_filters( 'mainwp_updates_hide_show_updates_per', false, $current_tab );
1887 + jQuery( document ).on( 'click', '.trigger-all-accordion', function() {
1888 + if ( jQuery( this ).hasClass( 'active' ) ) {
1889 + jQuery( this ).removeClass( 'active' );
1890 + jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1891 + if ( jQuery( this ).hasClass( 'active' ) ) {
1892 + jQuery( this ).trigger( 'click' );
1893 + }
1894 + } );
1895 + } else {
1896 + jQuery( this ).addClass( 'active' );
1897 + jQuery( '#mainwp-manage-updates .ui.accordion tr.title' ).each( function( i ) {
1898 + if ( !jQuery( this ).hasClass( 'active' ) ) {
1899 + jQuery( this ).trigger( 'click' );
1900 + }
1901 + } );
1902 + }
1903 + } );
1974 1904
1975 - /**
1976 - * Action: mainwp_updates_after_nav_tabs
1977 - *
1978 - * Fires after the navigation tabs on the Updates page.
1979 - *
1980 - * @since 4.1
1981 - */
1982 - do_action( 'mainwp_updates_after_nav_tabs' );
1905 + </script>
1906 + <?php
1983 1907
1984 - /**
1985 - * Action: mainwp_updates_before_actions_bar
1986 - *
1987 - * Fires before the actions bar on the Updates page.
1988 - *
1989 - * @since 4.1
1990 - */
1991 - do_action( 'mainwp_updates_before_actions_bar' );
1908 + if ( MAINWP_VIEW_PER_GROUP === $site_view ) {
1909 + ?>
1910 + <script type="text/javascript">
1911 + jQuery( document ).ready( function () {
1912 + updatesoverview_updates_init_group_view();
1913 + } );
1914 + </script>
1915 + <?php
1916 + }
1917 + }
1992 1918
1993 - if ( ! $hide_show_updates_per ) {
1994 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
1995 - ?>
1996 - <div class="mainwp-sub-header">
1997 - <div class="ui grid">
1998 - <div class="equal width row">
1999 - <div class="middle aligned column">
2000 - <form method="post" action="" class="ui mini form">
2001 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2002 - <div class="inline field">
2003 - <select class="ui dropdown" onchange="mainwp_siteview_onchange(this)" id="mainwp_select_options_siteview" name="select_mainwp_options_siteview">
2004 - <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Site', 'mainwp' ); ?></option>
2005 - <option value="0" class="item" <?php echo MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Item', 'mainwp' ); ?></option>
2006 - <option value="2" class="item" <?php echo MAINWP_VIEW_PER_GROUP === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Tag', 'mainwp' ); ?></option>
2007 - </select>
2008 - </div>
2009 - </form>
2010 - </div>
2011 - <div class="middle aligned right aligned column">
2012 - <?php
2013 - /**
2014 - * Filter: mainwp_widgetupdates_actions_top
2015 - *
2016 - * Filters the udpates actions top content.
2017 - *
2018 - * @since Unknown
2019 - */
2020 - echo apply_filters( 'mainwp_widgetupdates_actions_top', '' ); // phpcs:ignore WordPress.Security.EscapeOutput
2021 - if ( 'abandoned-plugins' === $current_tab ) {
2022 - if ( $is_demo ) {
2023 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini basic button disabled" disabled="disabled">' . esc_html__( 'Check for Abandoned Plugins', 'mainwp' ) . '</a>' );
2024 - } else {
2025 - ?>
2026 - <a href="#" onClick="updatesoverview_bulk_check_abandoned('plugin'); return false;" class="ui green mini basic button" data-tooltip="<?php esc_html_e( 'Check for Abandoned Plugins.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Check for Abandoned Plugins', 'mainwp' ); ?></a>
2027 - <?php
2028 - }
2029 - } elseif ( 'abandoned-themes' === $current_tab ) {
2030 - if ( $is_demo ) {
2031 - MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" class="ui green mini basic button disabled" disabled="disabled">' . esc_html__( 'Check for Abandoned Themes', 'mainwp' ) . '</a>' );
2032 - } else {
2033 - ?>
2034 - <a href="#" onClick="updatesoverview_bulk_check_abandoned('theme'); return false;" class="ui green mini basic button" data-tooltip="<?php esc_html_e( 'Check for Abandoned Themes.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><?php esc_html_e( 'Check for Abandoned Themes', 'mainwp' ); ?></a>
2035 - <?php
2036 - }
2037 - }
2038 - ?>
2039 - </div>
2040 - </div>
2041 - </div>
2042 - </div>
2043 - <?php
2044 - }
2045 1919
2046 - /**
2047 - * Action: mainwp_updates_after_actions_bar
2048 - *
2049 - * Fires after the actions bar on the Updates page.
2050 - *
2051 - * @since 4.1
2052 - */
2053 - do_action( 'mainwp_updates_after_actions_bar' );
2054 - }
1920 + /**
1921 + * Gets sites for updates
1922 + *
1923 + * @return object Object containing websites info.
1924 + *
1925 + * @uses \MainWP\Dashboard\MainWP_DB::query()
1926 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_website_by_id()
1927 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1928 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1929 + * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1930 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
1931 + */
1932 + public static function get_sites_for_current_user() {
1933 + /**
1934 + * Current user global.
1935 + *
1936 + * @global string
1937 + */
1938 + global $current_user;
2055 1939
2056 - /**
2057 - * Renders the HTTP Check html content.
2058 - *
2059 - * @param object $websites Child Sites.
2060 - *
2061 - * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2062 - * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
2063 - */
2064 - public static function render_http_checks( $websites ) {
1940 + $current_wpid = MainWP_System_Utility::get_current_wpid();
1941 + if ( $current_wpid ) {
1942 + $sql = MainWP_DB::instance()->get_sql_website_by_id( $current_wpid, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'ignored_wp_upgrades', 'ignored_trans_updates', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon', 'site_info' ) );
1943 + } else {
1944 + $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) || is_plugin_active( 'mainwp-timecapsule-extension/mainwp-timecapsule-extension.php' );
1945 + $is_staging = 'no';
1946 + if ( $staging_enabled ) {
1947 + $staging_updates_view = MainWP_System_Utility::get_select_staging_view_sites();
1948 + if ( 'staging' === $staging_updates_view ) {
1949 + $is_staging = 'yes';
1950 + }
1951 + }
1952 + $params = array(
1953 + 'connected' => 'yes',
1954 + 'maybe_cache' => true,
1955 + );
2065 1956
2066 - $enable_legacy_backup = get_option( 'mainwp_enableLegacyBackupFeature' );
2067 - $mainwp_primaryBackup = get_option( 'mainwp_primaryBackup' );
1957 + $limit_sites = get_option( 'mainwp_manage_updates_limit_sites' );
1958 + if ( ! empty( $limit_sites ) ) {
1959 + $params['limit_sites'] = $limit_sites;
1960 + }
1961 + $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'wp_upgrades', 'ignored_wp_upgrades', 'ignored_trans_updates', 'premium_upgrades', 'rollback_updates_data', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon', 'site_info' ), $is_staging, $params );
1962 + }
1963 + return MainWP_DB::instance()->query( $sql );
1964 + }
2068 1965
2069 - /**
2070 - * Custom backup pages
2071 - *
2072 - * Filters backup options to set correct page for restore options.
2073 - *
2074 - * @since 4.0
2075 - */
2076 - $customPage = apply_filters_deprecated( 'mainwp-getcustompage-backups', array( false ), '4.0.7.2', 'mainwp_getcustompage_backups' ); // @deprecated Use 'mainwp_getcustompage_backups' instead.
2077 - $customPage = apply_filters( 'mainwp_getcustompage_backups', $customPage );
1966 + /**
1967 + * Renders header tabs
1968 + *
1969 + * @param bool $show_language_updates show language update.
1970 + * @param string $current_tab current tab.
1971 + * @param int $total_wp_upgrades total WP update.
1972 + * @param int $total_plugin_upgrades total plugins update.
1973 + * @param int $total_theme_upgrades total themes update.
1974 + * @param int $total_translation_upgrades total translation update.
1975 + * @param int $total_plugins_outdate total plugins outdate.
1976 + * @param int $total_themes_outdate total theme outdate.
1977 + * @param string $site_view current site view.
1978 + */
1979 + public static function render_header_tabs( $show_language_updates, $current_tab, $total_wp_upgrades, $total_plugin_upgrades, $total_theme_upgrades, $total_translation_upgrades, $total_plugins_outdate, $total_themes_outdate, $site_view ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
2078 1980
2079 - $restorePageSlug = '';
2080 - if ( empty( $enable_legacy_backup ) && ! empty( $mainwp_primaryBackup ) && is_array( $customPage ) && isset( $customPage['managesites_slug'] ) ) {
2081 - $restorePageSlug = 'admin.php?page=ManageSites' . $customPage['managesites_slug'];
2082 - } elseif ( $enable_legacy_backup ) {
2083 - $restorePageSlug = 'admin.php?page=managesites';
2084 - }
2085 - ?>
2086 - <div class="" id="mainwp-http-response-issues">
2087 - <?php
2088 - /**
2089 - * Action: mainwp_updates_before_http_response_table
2090 - *
2091 - * Fires before the HTTP responses table on the Updates pages
2092 - *
2093 - * @since 4.1
2094 - */
2095 - do_action( 'mainwp_updates_before_http_response_table' );
2096 - ?>
2097 - <table class="ui single line inverted unstackable table" id="mainwp-http-response-issues-table">
2098 - <thead>
2099 - <tr>
2100 - <th class="no-sort" colspan="3"><?php esc_html_e( 'HTTP Response Check Results', 'mainwp' ); ?></th>
2101 - </tr>
2102 - <tr>
2103 - <th><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
2104 - <th><?php esc_html_e( 'HTTP Code', 'mainwp' ); ?></th>
2105 - <th class="collapsing no-sort"></th>
2106 - </tr>
2107 - </thead>
2108 - <tbody>
2109 - <?php
2110 - MainWP_DB::data_seek( $websites, 0 );
2111 - while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2112 - if ( 1 === (int) $website->offline_check_result || '-1' === $website->http_response_code ) {
2113 - continue;
2114 - }
1981 + /**
1982 + * Action: mainwp_updates_before_nav_tabs
1983 + *
1984 + * Fires before the navigation tabs on the Updates page.
1985 + *
1986 + * @since 4.1
1987 + */
1988 + do_action( 'mainwp_updates_before_nav_tabs' );
2115 1989
2116 - $restoreSlug = '';
1990 + $header_tabs = array(
1991 + 'plugins-updates' => array(
1992 + 'slug' => 'plugins-updates',
1993 + 'title' => esc_html__( 'Plugin Updates', 'mainwp' ),
1994 + 'total_upgrades' => $total_plugin_upgrades,
1995 + ),
1996 + 'themes-updates' => array(
1997 + 'slug' => 'themes-updates',
1998 + 'title' => esc_html__( 'Theme Updates', 'mainwp' ),
1999 + 'total_upgrades' => $total_theme_upgrades,
2000 + ),
2001 + 'wordpress-updates' => array(
2002 + 'slug' => 'wordpress-updates',
2003 + 'title' => esc_html__( 'WordPress Updates', 'mainwp' ),
2004 + 'total_upgrades' => $total_wp_upgrades,
2005 + ),
2006 + );
2117 2007
2118 - if ( ! empty( $restorePageSlug ) ) {
2119 - if ( $enable_legacy_backup ) {
2120 - $restoreSlug = $restorePageSlug . '&backupid=' . intval( $website->id );
2121 - } elseif ( self::activated_primary_backup_plugin( $mainwp_primaryBackup, $website ) ) {
2122 - $restoreSlug = $restorePageSlug . '&id=' . intval( $website->id );
2123 - }
2124 - }
2125 - ?>
2126 - <tr id="child-site-<?php echo intval( $website->id ); ?>" class="child-site mainwp-child-site-<?php echo intval( $website->id ); ?>" siteid="<?php echo intval( $website->id ); ?>" site-url="<?php echo esc_url( $website->url ); ?>">
2127 - <td>
2128 - <?php self::render_site_link_dashboard( $website ); ?>
2129 - </td>
2130 - <td id="wp_http_response_code_<?php echo esc_attr( $website->id ); ?>">
2131 - <label class="ui red label http-code"><?php echo 'HTTP ' . esc_html( $website->http_response_code ); ?></label>
2132 - </td>
2133 - <td class="right aligned">
2134 - <a href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo esc_attr( $website->id ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="ui mini button" target="_blank"><?php esc_html_e( 'WP Admin', 'mainwp' ); ?></a>
2135 - <a href="javascript:void(0)" onclick="return updatesoverview_recheck_http( this, <?php echo intval( $website->id ); ?> )" class="ui basic mini green button"><?php esc_html_e( 'Recheck', 'mainwp' ); ?></a>
2136 - <?php if ( ! empty( $website->sync_errors ) ) { ?>
2137 - <a href="#" class="mainwp_site_reconnect ui green mini button"><?php esc_html_e( 'Reconnect', 'mainwp' ); ?></a>
2138 - <?php } ?>
2139 - <a href="javascript:void(0)" onClick="return updatesoverview_ignore_http_response( this, <?php echo intval( $website->id ); ?> )" class="ui basic mini button"><?php esc_html_e( 'Ignore', 'mainwp' ); ?></a>
2140 - <?php if ( ! empty( $restoreSlug ) ) { ?>
2141 - <a href="<?php echo esc_url( $restoreSlug ); ?>" class="ui green mini basic button"><?php esc_html_e( 'Restore', 'mainwp' ); ?></a>
2142 - <?php } ?>
2143 - </td>
2144 - </tr>
2145 - <?php
2146 - }
2147 - ?>
2148 - </tbody>
2149 - <tfoot>
2150 - <tr>
2151 - <th><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
2152 - <th><?php esc_html_e( 'HTTP Code', 'mainwp' ); ?></th>
2153 - <th class="collapsing no-sort"></th>
2154 - </tr>
2155 - </tfoot>
2156 - </table>
2157 - <?php
2158 - /**
2159 - * Action: mainwp_updates_after_http_response_table
2160 - *
2161 - * Fires after the HTTP responses table on the Updates pages.
2162 - *
2163 - * @since 4.1
2164 - */
2165 - do_action( 'mainwp_updates_after_http_response_table' );
2008 + if ( $show_language_updates ) {
2009 + $header_tabs['translations-updates'] = array(
2010 + 'slug' => 'translations-updates',
2011 + 'title' => esc_html__( 'Translations Updates', 'mainwp' ),
2012 + 'total_upgrades' => $total_translation_upgrades,
2013 + );
2014 + }
2166 2015
2167 - $table_features = array(
2168 - 'searching' => 'false',
2169 - 'paging' => 'false',
2170 - 'stateSave' => 'true',
2171 - 'info' => 'false',
2172 - 'responsive' => 'true',
2173 - );
2016 + $header_tabs['abandoned-plugins'] = array(
2017 + 'slug' => 'abandoned-plugins',
2018 + 'title' => esc_html__( 'Abandoned Plugins', 'mainwp' ),
2019 + 'total_upgrades' => $total_plugins_outdate,
2020 + );
2174 2021
2175 - /**
2176 - * Filter: mainwp_updates_http_responses_datatable_features
2177 - *
2178 - * Filters the DataTable options for the HTTP Responses table on the Updates page.
2179 - *
2180 - * @since 4.1
2181 - */
2182 - $table_features = apply_filters( 'mainwp_updates_http_responses_datatable_features', $table_features );
2183 - ?>
2184 - <script>
2185 - var responsive = <?php echo esc_html( $table_features['responsive'] ); ?>;
2186 - if( jQuery( window ).width() > 1140 ) {
2187 - responsive = false;
2188 - }
2189 - jQuery( document ).ready( function() {
2190 - jQuery( '#mainwp-http-response-issues-table' ).DataTable( {
2191 - "responsive": responsive,
2192 - "searching": <?php echo esc_html( $table_features['searching'] ); ?>,
2193 - "paging" : <?php echo esc_html( $table_features['paging'] ); ?>,
2194 - "stateSave": <?php echo esc_html( $table_features['stateSave'] ); ?>,
2195 - "info" : <?php echo esc_html( $table_features['info'] ); ?>,
2196 - "columnDefs" : [ { "orderable": false, "targets": "no-sort" } ],
2197 - "language" : { "emptyTable": "No HTTP issues detected." }
2198 - } );
2199 - } );
2200 - </script>
2201 - </div>
2202 - <div class="ui hidden clearing divider"></div>
2203 - <?php
2204 - }
2022 + $header_tabs['abandoned-themes'] = array(
2023 + 'slug' => 'abandoned-themes',
2024 + 'title' => esc_html__( 'Abandoned Themes', 'mainwp' ),
2025 + 'total_upgrades' => $total_themes_outdate,
2026 + );
2205 2027
2206 - /**
2207 - * Cheks which primary backup plugin is being used.
2208 - *
2209 - * @param mixed $what Which backup plugin is being use.
2210 - * @param object $website Website array of information.
2211 - *
2212 - * @return boolean True|False.
2213 - */
2214 - public static function activated_primary_backup_plugin( $what, $website ) {
2215 - $plugins = json_decode( $website->plugins, 1 );
2216 - if ( ! is_array( $plugins ) || 0 === count( $plugins ) ) {
2217 - return false;
2218 - }
2028 + $header_tabs = apply_filters( 'mainwp_page_hearder_tabs_updates', $header_tabs );
2219 2029
2220 - $checks = array(
2221 - 'backupbuddy' => 'backupbuddy/backupbuddy.php',
2222 - 'backupwp' => array( 'backwpup/backwpup.php', 'backwpup-pro/backwpup.php' ),
2223 - 'updraftplus' => 'updraftplus/updraftplus.php',
2030 + ?>
2031 + <div id="mainwp-page-navigation-wrapper">
2032 + <div class="ui vertical menu mainwp-page-navigation">
2033 + <?php
2034 + foreach ( $header_tabs as $slug => $tab ) {
2035 + if ( empty( $tab['title'] ) ) {
2036 + continue;
2037 + }
2038 + ?>
2039 + <a class="<?php echo $slug === $current_tab ? 'active' : ''; ?> item" data-tab="<?php echo esc_html( $slug ); ?>" href="admin.php?page=UpdatesManage&tab=<?php echo esc_html( $slug ); ?>"><?php echo esc_html( $tab['title'] ); ?><div class="ui small <?php echo empty( $tab['total_upgrades'] ) ? 'green' : 'red'; ?> label" timestamp="<?php echo esc_html( time() ); ?>"><?php echo intval( $tab['total_upgrades'] ); ?></div></a>
2040 + <?php
2041 + }
2042 + ?>
2043 + </div>
2044 + </div>
2045 + <?php
2224 2046
2225 - );
2047 + $hide_show_updates_per = 'updates-ignore' === $current_tab ? true : false;
2226 2048
2227 - $slug = isset( $checks[ $what ] ) ? $checks[ $what ] : '';
2049 + $hide_show_updates_per = apply_filters( 'mainwp_updates_hide_show_updates_per', $hide_show_updates_per, $current_tab );
2228 2050
2229 - if ( empty( $slug ) ) {
2230 - return false;
2231 - }
2051 + $show_select_staging_sites = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' );
2052 + $has_ignored_updates = in_array(
2053 + $current_tab,
2054 + array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ),
2055 + true
2056 + ) && 0 < static::get_ignored_updates_count( $current_tab );
2057 + $show_updates_actions_bar = $has_ignored_updates
2058 + || ( 'plugins-updates' === $current_tab && 0 < $total_plugin_upgrades )
2059 + || ( 'themes-updates' === $current_tab && 0 < $total_theme_upgrades )
2060 + || ( 'wordpress-updates' === $current_tab && 0 < $total_wp_upgrades )
2061 + || ( 'translations-updates' === $current_tab && 0 < $total_translation_upgrades )
2062 + || 'abandoned-plugins' === $current_tab
2063 + || 'abandoned-themes' === $current_tab;
2064 + $current_tab_updates_count = 0;
2232 2065
2233 - $installed = false;
2066 + if ( 'plugins-updates' === $current_tab ) {
2067 + $current_tab_updates_count = $total_plugin_upgrades;
2068 + } elseif ( 'themes-updates' === $current_tab ) {
2069 + $current_tab_updates_count = $total_theme_upgrades;
2070 + } elseif ( 'wordpress-updates' === $current_tab ) {
2071 + $current_tab_updates_count = $total_wp_upgrades;
2072 + } elseif ( 'translations-updates' === $current_tab ) {
2073 + $current_tab_updates_count = $total_translation_upgrades;
2074 + }
2234 2075
2235 - foreach ( $plugins as $plugin ) {
2236 - if ( ( is_string( $slug ) && strtolower( $plugin['slug'] ) === $slug ) || ( is_array( $slug ) && in_array( $plugin['slug'], $slug ) ) ) {
2237 - if ( $plugin['active'] ) {
2238 - $installed = true;
2239 - }
2240 - break;
2241 - }
2242 - }
2076 + /**
2077 + * Action: mainwp_updates_after_nav_tabs
2078 + *
2079 + * Fires after the navigation tabs on the Updates page.
2080 + *
2081 + * @since 4.1
2082 + */
2083 + do_action( 'mainwp_updates_after_nav_tabs' );
2243 2084
2244 - return $installed;
2245 - }
2085 + /**
2086 + * Action: mainwp_updates_before_actions_bar
2087 + *
2088 + * Fires before the actions bar on the Updates page.
2089 + *
2090 + * @since 4.1
2091 + */
2092 + do_action( 'mainwp_updates_before_actions_bar' );
2093 + ?>
2246 2094
2247 - /**
2248 - * Sets the HTML selector to continue updates.
2249 - *
2250 - * @param string $current_update current update string.
2251 - * @param bool $slug Whether to update slug.
2252 - */
2253 - public static function set_continue_update_html_selector( $current_update, $slug = false ) {
2095 + <?php if ( ! $hide_show_updates_per || $show_select_staging_sites ) : ?>
2096 + <?php if ( $show_updates_actions_bar ) : ?>
2097 + <div class="mainwp-sub-header">
2098 + <div class="ui three column grid">
2099 + <div class="left aligned middle aligned column">
2100 + <?php static::render_updates_view_options( $site_view ); ?>
2101 + <?php
2102 + if ( $show_select_staging_sites ) {
2103 + static::render_select_staging_sites_view();
2104 + }
2105 + ?>
2106 + </div>
2107 + <div class="center aligned middle aligned column"></div>
2108 + <div class="right aligned middle aligned column">
2109 + <?php
2110 + /**
2111 + * Action: mainwp_widget_updates_actions_top
2112 + *
2113 + * Updates actions top content.
2114 + *
2115 + * @since 5.5
2116 + */
2117 + do_action( 'mainwp_widget_updates_actions_top', $current_tab );
2118 + ?>
2119 + <?php static::render_updates_actions_buttons( $current_tab, $current_tab_updates_count ); ?>
2120 + <?php static::render_button_view_ignored_updates( $current_tab ); ?>
2121 + <?php static::render_abandoned_plugins_themes_buttons( $current_tab ); ?>
2122 + </div>
2123 + </div>
2124 + </div>
2125 + <?php elseif ( $show_select_staging_sites ) : ?>
2126 + <div class="mainwp-sub-header">
2127 + <div class="ui three column grid">
2128 + <div class="left aligned middle aligned column">
2129 + <?php static::render_select_staging_sites_view(); ?>
2130 + </div>
2131 + <div class="center aligned middle aligned column"></div>
2132 + <div class="right aligned middle aligned column">
2133 + </div>
2134 + </div>
2135 + </div>
2136 + <?php endif; ?>
2137 + <?php endif; ?>
2138 + <?php
2139 + /**
2140 + * Action: mainwp_updates_after_actions_bar
2141 + *
2142 + * Fires after the actions bar on the Updates page.
2143 + *
2144 + * @since 4.1
2145 + */
2146 + do_action( 'mainwp_updates_after_actions_bar' );
2147 + }
2254 2148
2255 - $check_slug = true;
2256 - if ( ! empty( $slug ) ) {
2257 - $check_slug = ( $slug === self::$continue_update_slug ) ? true : false;
2258 - }
2149 + /**
2150 + * Method handle_post_staging_sites_view.
2151 + *
2152 + * @return void
2153 + */
2154 + public static function handle_post_staging_sites_view() {
2155 + //phpcs:disable WordPress.Security.NonceVerification.Missing
2156 + if ( isset( $_POST['mainwpStagingNonceView'] ) && wp_verify_nonce( sanitize_key( $_POST['mainwpStagingNonceView'] ), 'mainwpStagingNonceView' ) ) {
2157 + global $current_user;
2158 + if ( isset( $_POST['select_staging_options_siteview'] ) && in_array( $_POST['select_staging_options_siteview'], array( 'live', 'staging' ), true ) ) {
2159 + update_user_option( $current_user->ID, 'mainwp_staging_options_updates_view', $_POST['select_staging_options_siteview'] );
2160 + }
2161 + }
2162 + //phpcs:enable WordPress.Security.NonceVerification.Missing
2163 + }
2259 2164
2260 - if ( $check_slug && $current_update === self::$continue_update ) {
2261 - self::$continue_selector = 'updatesoverview_continue_update_me';
2262 - } else {
2263 - self::$continue_selector = '';
2264 - }
2265 - }
2165 + /**
2166 + * Method render_select_staging_sites_view.
2167 + *
2168 + * @return void
2169 + */
2170 + public static function render_select_staging_sites_view() {
2171 + $view = MainWP_System_Utility::get_select_staging_view_sites();
2172 + $view_stagings = 'staging' === (string) $view ? true : false;
2266 2173
2267 - /**
2268 - * Gets the HTML selector to continue updates.
2269 - *
2270 - * @return void.
2271 - */
2272 - public static function get_continue_update_selector() {
2273 - echo esc_attr( self::$continue_selector );
2274 - }
2174 + ?>
2175 + <form method="post" action="" style="display:inline">
2176 + <select class="ui dropdown mini" id="mainwp_staging_select_options_siteview" name="select_staging_options_siteview">
2177 + <option value="live" <?php echo $view_stagings ? '' : 'selected'; ?>><?php esc_html_e( 'Production sites', 'mainwp' ); ?></option>
2178 + <option value="staging" <?php echo $view_stagings ? 'selected' : ''; ?>><?php esc_html_e( 'Staging sites', 'mainwp' ); ?></option>
2179 + </select>
2180 + <?php wp_nonce_field( 'mainwpStagingNonceView', 'mainwpStagingNonceView' ); ?>
2181 + </form>
2182 + <script type="text/javascript">
2183 + jQuery(document).ready(function ($) {
2184 + jQuery("#mainwp_staging_select_options_siteview").change(function() {
2185 + jQuery(this).closest("form").submit();
2186 + });
2187 + })
2188 + </script>
2189 + <?php
2190 + }
2275 2191
2276 - /**
2277 - * Displays the updates modal window during updates.
2278 - */
2279 - public static function render_updates_modal() {
2280 - ?>
2281 - <div class="ui modal" id="updatesoverview-backup-box">
2282 - <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div>
2283 - <div class="scrolling content mainwp-modal-content"></div>
2284 - <div class="actions mainwp-modal-actions">
2285 - <input id="updatesoverview-backup-all" type="button" name="Backup All" value="<?php esc_html_e( 'Backup All', 'mainwp' ); ?>" class="button-primary"/>
2286 - <a id="updatesoverview-backup-now" href="javascript:void(0)" target="_blank" style="display: none" class="button-primary button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a>&nbsp;
2287 - <input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/>
2288 - </div>
2289 - </div>
2290 - <?php
2291 - }
2292 2192
2293 - /**
2294 - * Displays the plugin details modal window.
2295 - */
2296 - public static function render_plugin_details_modal() {
2297 - ?>
2298 - <div class="ui modal" id="mainwp-plugin-details-modal">
2299 - <i class="close icon"></i>
2300 - <div class="header"><?php echo esc_html__( 'Plugin Details', 'mainwp' ); ?></div>
2301 - <div class="content">
2302 - <div class="ui embed"></div>
2303 - </div>
2304 - <div class="actions">
2305 - </div>
2306 - </div>
2307 - <?php
2308 - }
2193 + /**
2194 + * Method render_updates_view_options().
2195 + *
2196 + * @param mixed $site_view Site view.
2197 + * @return void
2198 + */
2199 + public static function render_updates_view_options( $site_view = '' ) {
2200 + ?>
2201 + <form method="post" action="" class="ui mini form" style="display:inline flow-root">
2202 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
2203 + <select class="ui mini dropdown" onchange="mainwp_siteview_onchange(this)" id="mainwp_select_options_siteview" name="select_mainwp_options_siteview">
2204 + <option value="1" class="item" <?php echo MAINWP_VIEW_PER_SITE === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Site', 'mainwp' ); ?></option>
2205 + <option value="0" class="item" <?php echo MAINWP_VIEW_PER_PLUGIN_THEME === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Item', 'mainwp' ); ?></option>
2206 + <option value="2" class="item" <?php echo MAINWP_VIEW_PER_GROUP === $site_view ? 'selected' : ''; ?>><?php esc_html_e( 'Show updates per Tag', 'mainwp' ); ?></option>
2207 + </select>
2208 + </form>
2209 + <?php
2210 + }
2309 2211
2310 - /**
2311 - * Method render_screen_options_modal()
2312 - *
2313 - * Renders Page Settings Modal.
2314 - */
2315 - public static function render_screen_options_modal() { // phpcs:ignore -- complex method.
2212 + /**
2213 + * Method render_abandoned_plugins_themes_buttons().
2214 + *
2215 + * @param mixed $current_tab Current tab.
2216 + * @return void
2217 + */
2218 + public static function render_abandoned_plugins_themes_buttons( $current_tab = '' ) {
2219 + if ( 'abandoned-plugins' === $current_tab ) {
2220 + ?>
2221 + <a href="#" onClick="updatesoverview_bulk_check_abandoned('plugin'); return false;" class="ui green mini basic button"><?php esc_html_e( 'Check for Abandoned Plugins', 'mainwp' ); ?></a>
2222 + <?php } elseif ( 'abandoned-themes' === $current_tab ) { ?>
2223 + <a href="#" onClick="updatesoverview_bulk_check_abandoned('theme'); return false;" class="ui green mini basic button"><?php esc_html_e( 'Check for Abandoned Themes', 'mainwp' ); ?></a>
2224 + <?php
2225 + }
2226 + }
2316 2227
2317 - $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate' );
2318 - $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate' );
2319 - $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate' );
2320 - $mainwp_show_language_updates = (int) get_option( 'mainwp_show_language_updates', 1 );
2321 - $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
2322 - $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
2323 - ?>
2324 - <div class="ui modal" id="mainwp-manage-updates-screen-options-modal">
2325 - <i class="close icon"></i>
2326 - <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
2327 - <div class="scrolling content ui form">
2328 - <form method="POST" action="" id="manage-updates-screen-options-form" name="manage-updates-screen-options-form">
2329 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2330 - <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdatesScrOptions' ) ); ?>" />
2331 - <div class="ui grid field">
2332 - <label class="six wide column middle aligned"><?php esc_html_e( 'Plugin advanced automatic updates', 'mainwp' ); ?></label>
2333 - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugins updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2334 - <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown">
2335 - <option value="1" <?php echo ( 1 === $snPluginAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2336 - <option value="0" <?php echo ( ( false !== $snPluginAutomaticDailyUpdate && empty( $snPluginAutomaticDailyUpdate ) ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2337 - </select>
2338 - </div>
2339 - </div>
2340 - <div class="ui grid field">
2341 - <label class="six wide column middle aligned"><?php esc_html_e( 'Theme advanced automatic updates', 'mainwp' ); ?></label>
2342 - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic themes updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2343 - <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown">
2344 - <option value="1" <?php echo ( 1 === $snThemeAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2345 - <option value="0" <?php echo ( ( false !== $snThemeAutomaticDailyUpdate && 0 === $snThemeAutomaticDailyUpdate ) || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2346 - </select>
2347 - </div>
2348 - </div>
2349 - <div class="ui grid field">
2350 - <label class="six wide column middle aligned"><?php esc_html_e( 'WP Core advanced automatic updates', 'mainwp' ); ?></label>
2351 - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic WordPress core updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2352 - <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown">
2353 - <option value="1" <?php echo ( 1 === $snAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2354 - <option value="0" <?php echo ( ( false !== $snAutomaticDailyUpdate && 0 === $snAutomaticDailyUpdate ) || 2 === $snAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2355 - </select>
2356 - </div>
2357 - </div>
2358 - <div class="ui grid field">
2359 - <label class="six wide column middle aligned"><?php esc_html_e( 'Advanced automatic updates delay', 'mainwp' ); ?></label>
2360 - <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'Set the number of days to delay automatic updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2361 - <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown">
2362 - <option value="0" <?php echo ( 0 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
2363 - <option value="1" <?php echo ( 1 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
2364 - <option value="2" <?php echo ( 2 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
2365 - <option value="3" <?php echo ( 3 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
2366 - <option value="4" <?php echo ( 4 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
2367 - <option value="5" <?php echo ( 5 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
2368 - <option value="6" <?php echo ( 6 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
2369 - <option value="7" <?php echo ( 7 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
2370 - <option value="14" <?php echo ( 14 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
2371 - <option value="30" <?php echo ( 30 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
2372 - </select>
2373 - </div>
2374 - </div>
2375 - <div class="ui grid field">
2376 - <label class="six wide column middle aligned"><?php esc_html_e( 'Show WordPress language updates', 'mainwp' ); ?></label>
2377 - <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to manage Translation updates', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2378 - <input type="checkbox" name="mainwp_show_language_updates" id="mainwp_show_language_updates" <?php echo ( 1 === $mainwp_show_language_updates ? 'checked="true"' : '' ); ?>/>
2379 - </div>
2380 - </div>
2381 - <div class="ui grid field">
2382 - <label class="six wide column middle aligned"><?php esc_html_e( 'Update confirmations', 'mainwp' ); ?></label>
2383 - <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Choose if you want to disable the popup confirmations when performing updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2384 - <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown">
2385 - <option value="0" <?php echo ( 0 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
2386 - <option value="2" <?php echo ( 2 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
2387 - <option value="1" <?php echo ( 1 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
2388 - </select>
2389 - </div>
2390 - </div>
2391 - <div class="ui hidden divider"></div>
2392 - <div class="ui hidden divider"></div>
2393 - </div>
2394 - <div class="actions">
2395 - <div class="ui two columns grid">
2396 - <div class="left aligned column"></div>
2397 - <div class="ui right aligned column">
2398 - <input type="submit" class="ui green button" name="btnSubmit" id="submit-manage-updates-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2399 - </div>
2400 - </div>
2401 - </div>
2402 - </form>
2403 - </div>
2404 - <?php
2405 - }
2228 + /**
2229 + * Method get_ignored_core_versions().
2230 + *
2231 + * @param array $decodedIgnoredCores Decoded ignored cores.
2232 + *
2233 + * @return array Ignored core versions.
2234 + */
2235 + public static function get_ignored_core_versions( $decodedIgnoredCores ) {
2236 + if (
2237 + ! is_array( $decodedIgnoredCores )
2238 + || empty( $decodedIgnoredCores['ignored_versions'] )
2239 + || ! is_array( $decodedIgnoredCores['ignored_versions'] )
2240 + ) {
2241 + return array();
2242 + }
2406 2243
2244 + return array_filter( $decodedIgnoredCores['ignored_versions'] );
2245 + }
2407 2246
2408 - /**
2409 - * MainWP Help Box content. Hook the section help content to the Help Sidebar element.
2410 - */
2411 - public static function mainwp_help_content() {
2412 - if ( isset( $_GET['page'] ) && 'UpdatesManage' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2413 - ?>
2414 - <p><?php esc_html_e( 'If you need help with managing updates, please review following help documents', 'mainwp' ); ?></p>
2415 - <div class="ui relaxed bulleted list">
2416 - <div class="item"><a href="https://kb.mainwp.com/docs/update-plugins/" target="_blank">Update Plugins</a> <i class="external alternate icon"></i></div>
2417 - <div class="item"><a href="https://kb.mainwp.com/docs/plugins-auto-updates/" target="_blank">Plugins Auto Updates</a> <i class="external alternate icon"></i></div>
2418 - <div class="item"><a href="https://kb.mainwp.com/docs/ignore-plugin-updates/" target="_blank">Ignore Plugin Updates</a> <i class="external alternate icon"></i></div>
2419 - <div class="item"><a href="https://kb.mainwp.com/docs/update-themes/" target="_blank">Update Themes</a> <i class="external alternate icon"></i></div>
2420 - <div class="item"><a href="https://kb.mainwp.com/docs/themes-auto-updates/" target="_blank">Themes Auto Updates</a> <i class="external alternate icon"></i></div>
2421 - <div class="item"><a href="https://kb.mainwp.com/docs/ignore-theme-updates/" target="_blank">Ignore Theme Updates</a> <i class="external alternate icon"></i></div>
2422 - <div class="item"><a href="https://kb.mainwp.com/docs/update-wordpress-core/" target="_blank">Update WordPress Core</a> <i class="external alternate icon"></i></div>
2423 - <div class="item"><a href="https://kb.mainwp.com/docs/auto-update-wordpress-core/" target="_blank">Auto Update WordPress Core</a> <i class="external alternate icon"></i></div>
2424 - <div class="item"><a href="https://kb.mainwp.com/docs/ignore-wordpress-core-update/" target="_blank">Ignore WordPress Core Update</a> <i class="external alternate icon"></i></div>
2425 - <?php
2426 - /**
2427 - * Action: mainwp_updates_help_item
2428 - *
2429 - * Fires at the bottom of the help articles list in the Help sidebar on the Updates page.
2430 - *
2431 - * Suggested HTML markup:
2432 - *
2433 - * <div class="item"><a href="Your custom URL">Your custom text</a></div>
2434 - *
2435 - * @since 4.1
2436 - */
2437 - do_action( 'mainwp_updates_help_item' );
2438 - ?>
2439 - </div>
2440 - <?php
2441 - }
2442 - }
2247 + /**
2248 + * Method get_ignored_updates_count().
2249 + *
2250 + * @param string $current_tab Current tab.
2251 + *
2252 + * @return int Ignored updates count.
2253 + */
2254 + public static function get_ignored_updates_count( $current_tab = '' ) { //phpcs:ignore -- NOSONAR - complex.
2255 + if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ), true ) ) {
2256 + return 0;
2257 + }
2258 +
2259 + if ( isset( static::$ignored_updates_counts[ $current_tab ] ) ) {
2260 + return static::$ignored_updates_counts[ $current_tab ];
2261 + }
2262 +
2263 + $count = 0;
2264 + $userExtension = MainWP_DB_Common::instance()->get_user_extension();
2265 +
2266 + if ( 'plugins-updates' === $current_tab ) {
2267 + $decodedIgnoredPlugins = is_object( $userExtension ) && ! empty( $userExtension->ignored_plugins ) ? json_decode( $userExtension->ignored_plugins, true ) : array();
2268 + $count = is_array( $decodedIgnoredPlugins ) ? count( $decodedIgnoredPlugins ) : 0;
2269 + } elseif ( 'themes-updates' === $current_tab ) {
2270 + $decodedIgnoredThemes = is_object( $userExtension ) && ! empty( $userExtension->ignored_themes ) ? json_decode( $userExtension->ignored_themes, true ) : array();
2271 + $count = is_array( $decodedIgnoredThemes ) ? count( $decodedIgnoredThemes ) : 0;
2272 + } elseif ( 'wordpress-updates' === $current_tab ) {
2273 + $decodedIgnoredCores = is_object( $userExtension ) && ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
2274 + $count = count( static::get_ignored_core_versions( $decodedIgnoredCores ) );
2275 + }
2276 +
2277 + $websites = MainWP_DB::instance()->query(
2278 + MainWP_DB::instance()->get_sql_websites_for_current_user(
2279 + false,
2280 + null,
2281 + 'wp.url',
2282 + false,
2283 + false,
2284 + null,
2285 + false,
2286 + array( 'ignored_wp_upgrades' )
2287 + )
2288 + );
2289 +
2290 + while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
2291 + if ( 'plugins-updates' === $current_tab ) {
2292 + $decodedIgnoredPlugins = ! empty( $website->ignored_plugins ) ? json_decode( $website->ignored_plugins, true ) : array();
2293 + if ( ! empty( $decodedIgnoredPlugins ) && is_array( $decodedIgnoredPlugins ) ) {
2294 + ++$count;
2295 + }
2296 + } elseif ( 'themes-updates' === $current_tab ) {
2297 + $decodedIgnoredThemes = ! empty( $website->ignored_themes ) ? json_decode( $website->ignored_themes, true ) : array();
2298 + if ( ! empty( $decodedIgnoredThemes ) && is_array( $decodedIgnoredThemes ) ) {
2299 + ++$count;
2300 + }
2301 + } elseif ( 'wordpress-updates' === $current_tab && empty( $website->is_ignoreCoreUpdates ) ) {
2302 + $decodedIgnoredCores = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array();
2303 + if ( ! empty( static::get_ignored_core_versions( $decodedIgnoredCores ) ) ) {
2304 + ++$count;
2305 + }
2306 + }
2307 + }
2308 +
2309 + if ( $websites ) {
2310 + MainWP_DB::free_result( $websites );
2311 + }
2312 +
2313 + static::$ignored_updates_counts[ $current_tab ] = $count;
2314 +
2315 + return $count;
2316 + }
2317 +
2318 + /**
2319 + * Method render_updates_actions_buttons().
2320 + *
2321 + * @param mixed $current_tab Current tab.
2322 + * @param int $updates_count Available updates count.
2323 + * @return void
2324 + */
2325 + public static function render_updates_actions_buttons( $current_tab, $updates_count = 0 ) {
2326 + $has_updates = 0 < intval( $updates_count );
2327 +
2328 + if ( 'plugins-updates' === $current_tab ) {
2329 + if ( static::user_can_update_plugins() ) {
2330 + if ( $has_updates ) {
2331 + static::set_continue_update_html_selector( 'plugins_global_upgrade_all' );
2332 + ?>
2333 + <a href="javascript:void(0)" onClick="updatesoverview_plugins_global_upgrade_all( false, true ); return false;" class="mainwp-update-selected-button ui mini green basic button"><?php esc_html_e( 'Update Selected Plugins', 'mainwp' ); ?></a>
2334 + <a href="javascript:void(0)" onClick="updatesoverview_plugins_global_upgrade_all(); return false;" class="mainwp-update-all-button ui mini green button"><?php esc_html_e( 'Update All Plugins', 'mainwp' ); ?></a>
2335 + <?php
2336 + } else {
2337 + ?>
2338 + <a href="javascript:void(0)" class="mainwp-update-selected-button ui mini green basic disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update Selected Plugins', 'mainwp' ); ?></a>
2339 + <a href="javascript:void(0)" class="mainwp-update-all-button ui mini green disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update All Plugins', 'mainwp' ); ?></a>
2340 + <?php
2341 + }
2342 + }
2343 + } elseif ( 'themes-updates' === $current_tab ) {
2344 + if ( static::user_can_update_themes() ) {
2345 + if ( $has_updates ) {
2346 + static::set_continue_update_html_selector( 'themes_global_upgrade_all' );
2347 + ?>
2348 + <a href="javascript:void(0)" onClick="updatesoverview_themes_global_upgrade_all( false, true ); return false;" class="mainwp-update-selected-button ui mini green basic button"><?php esc_html_e( 'Update Selected Themes', 'mainwp' ); ?></a>
2349 + <a href="javascript:void(0)" onClick="updatesoverview_themes_global_upgrade_all(); return false;" class="mainwp-update-all-button ui mini green button"><?php esc_html_e( 'Update All Themes', 'mainwp' ); ?></a>
2350 + <?php
2351 + } else {
2352 + ?>
2353 + <a href="javascript:void(0)" class="mainwp-update-selected-button ui mini green basic disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update Selected Themes', 'mainwp' ); ?></a>
2354 + <a href="javascript:void(0)" class="mainwp-update-all-button ui mini green disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update All Themes', 'mainwp' ); ?></a>
2355 + <?php
2356 + }
2357 + }
2358 + } elseif ( 'wordpress-updates' === $current_tab ) {
2359 + if ( static::user_can_update_wp() ) {
2360 + if ( $has_updates ) {
2361 + static::set_continue_update_html_selector( 'wpcore_global_upgrade_all' );
2362 + ?>
2363 + <a href="javascript:void(0)" class="mainwp-update-selected-button ui green mini basic button" onclick="event.stopPropagation(); updatesoverview_wordpress_global_upgrade_all( false, true ); return false;"><?php esc_html_e( 'Update Selected WP Cores', 'mainwp' ); ?></a>
2364 + <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini button" onclick="updatesoverview_wordpress_global_upgrade_all(); return false;"><?php esc_html_e( 'Update All WP Cores', 'mainwp' ); ?></a>
2365 + <?php
2366 + } else {
2367 + ?>
2368 + <a href="javascript:void(0)" class="mainwp-update-selected-button ui green mini basic disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update Selected WP Cores', 'mainwp' ); ?></a>
2369 + <a href="javascript:void(0)" class="mainwp-update-all-button ui green mini disabled button" aria-disabled="true" tabindex="-1"><?php esc_html_e( 'Update All WP Cores', 'mainwp' ); ?></a>
2370 + <?php
2371 + }
2372 + }
2373 + } elseif ( 'translations-updates' === $current_tab ) {
2374 + if ( static::user_can_update_trans() ) {
2375 + ?>
2376 + <a href="javascript:void(0)" onClick="updatesoverview_translations_global_upgrade_all( false, true ); return false;" class="mainwp-update-selected-button ui button mini basic green"><?php esc_html_e( 'Update Selected Translations', 'mainwp' ); ?></a>
2377 + <a href="javascript:void(0)" onClick="updatesoverview_translations_global_upgrade_all(); return false;" class="mainwp-update-all-button ui button mini green"><?php esc_html_e( 'Update All Translations', 'mainwp' ); ?></a>
2378 + <?php
2379 + }
2380 + }
2381 + }
2382 +
2383 +
2384 + /**
2385 + * Method render_button_view_ignored_updates().
2386 + *
2387 + * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
2388 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
2389 + * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
2390 + *
2391 + * @param string $current_tab current tab.
2392 + *
2393 + * @return null
2394 + */
2395 + public static function render_button_view_ignored_updates( $current_tab = '' ) { //phpcs:ignore -- NOSONAR - complex.
2396 + if ( ! in_array( $current_tab, array( 'wordpress-updates', 'plugins-updates', 'themes-updates' ) ) ) {
2397 + return;
2398 + }
2399 + $count_ignored_updates = static::get_ignored_updates_count( $current_tab );
2400 + $ignored_core_url = add_query_arg(
2401 + array(
2402 + 'page' => 'UpdatesManage',
2403 + 'tab' => 'updates-ignore',
2404 + ),
2405 + admin_url( 'admin.php' )
2406 + );
2407 + $ignored_plugins_url = add_query_arg(
2408 + array(
2409 + 'page' => 'PluginsIgnore',
2410 + ),
2411 + admin_url( 'admin.php' )
2412 + );
2413 + $ignored_themes_url = add_query_arg(
2414 + array(
2415 + 'page' => 'ThemesIgnore',
2416 + ),
2417 + admin_url( 'admin.php' )
2418 + );
2419 + ?>
2420 + <?php if ( 'wordpress-updates' === $current_tab && 0 < $count_ignored_updates ) : ?>
2421 + <a class="ui mini basic button" href="<?php echo esc_url( $ignored_core_url ); ?>" data-position="bottom right" data-tooltip="<?php esc_attr_e( 'Click here to see the list of ignored WordPress core updates.', 'mainwp' ); ?>" data-inverted=""><?php esc_html_e( 'View Ignored Updates', 'mainwp' ); ?></a>
2422 + <?php elseif ( 'plugins-updates' === $current_tab && 0 < $count_ignored_updates ) : ?>
2423 + <a class="ui mini basic button" href="<?php echo esc_url( $ignored_plugins_url ); ?>"><?php esc_html_e( 'View Ignored Updates', 'mainwp' ); ?></a>
2424 + <?php elseif ( 'themes-updates' === $current_tab && 0 < $count_ignored_updates ) : ?>
2425 + <a class="ui mini basic button" href="<?php echo esc_url( $ignored_themes_url ); ?>" ><?php esc_html_e( 'View Ignored Updates', 'mainwp' ); ?></a>
2426 + <?php endif; ?>
2427 + <?php
2428 + }
2429 +
2430 + /**
2431 + * Method handle_limit_sites().
2432 + */
2433 + public static function handle_limit_sites(){ // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
2434 + // put hook here before loading sites.
2435 + $limit_number = apply_filters( 'mainwp_manage_updates_limit_loading', false, 'updates' );
2436 + $current_limit = get_option( 'mainwp_manage_updates_limit_sites' );
2437 +
2438 + if ( (int) $limit_number !== (int) $current_limit ) {
2439 + update_option( 'mainwp_manage_updates_limit_sites', $limit_number );
2440 + update_option( 'mainwp_manage_updates_limit_current_page', 1 );
2441 + }
2442 +
2443 + if ( ! empty( $limit_number ) ) {
2444 +
2445 + $count = MainWP_DB::instance()->get_websites_count( null, true );
2446 +
2447 + $current_page = 1;
2448 + if ( isset( $_GET['current_page'] ) && isset( $_GET['_opennonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_opennonce'] ), 'mainwp-admin-nonce' ) ) {
2449 + $current_page = intval( $_GET['current_page'] );
2450 + }
2451 +
2452 + if ( 0 >= $current_page ) {
2453 + $current_page = 1;
2454 + }
2455 +
2456 + $total_page = ceil( $count / $limit_number );
2457 +
2458 + if ( $current_page > $total_page ) {
2459 + $current_page = $total_page;
2460 + }
2461 + update_option( 'mainwp_manage_updates_limit_current_page', $current_page );
2462 + }
2463 + }
2464 +
2465 + /**
2466 + * Method render_limit_load_sites().
2467 + *
2468 + * @param int $limit_number limit loading sites.
2469 + */
2470 + public static function render_limit_load_sites( $limit_number) { // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated.
2471 +
2472 + $count = MainWP_DB::instance()->get_websites_count( null, true );
2473 + $total_page = ceil( $count / $limit_number );
2474 +
2475 + $current_page = (int) get_option( 'mainwp_manage_updates_limit_current_page' );
2476 +
2477 + $first = 1 === $current_page;
2478 + $last = $total_page <= $current_page;
2479 +
2480 + ?>
2481 + <div class="dt-paging paging_full_numbers">
2482 + <div class="ui stackable pagination menu"><menu>
2483 + <?php if ( $first ) { ?>
2484 + <li class="dt-paging-button item disabled"><div class="page-link first" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="First" data-dt-idx="first" tabindex="-1">First</div></li>
2485 + <li class="dt-paging-button item disabled"><div class="page-link previous" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="Previous" data-dt-idx="previous" tabindex="-1">Previous</div></li>
2486 + <?php } else { ?>
2487 + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage" class="page-link first" aria-controls="mainwp-manage-sites-table" aria-label="First" data-dt-idx="first" tabindex="0">First</a></li>
2488 + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage&current_page=<?php echo intval( $current_page - 1 ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link previous" aria-controls="mainwp-manage-sites-table" aria-label="Previous" data-dt-idx="previous" tabindex="0">Previous</a></li>
2489 + <?php } ?>
2490 + <?php
2491 + for ( $i = 1; $i <= $total_page;$i++ ) {
2492 + ?>
2493 + <li class="dt-paging-button item <?php echo $current_page === $i ? 'active' : ''; ?>"><a href="admin.php?page=UpdatesManage&current_page=<?php echo intval( $i ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link" aria-controls="mainwp-manage-sites-table" aria-current="page" data-dt-idx="1" tabindex="0"><?php echo intval( $i ); ?></a></li>
2494 + <?php
2495 + }
2496 + ?>
2497 + <?php if ( $last ) { ?>
2498 + <li class="dt-paging-button item disabled"><div class="page-link next" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="Next" data-dt-idx="next" tabindex="-1">Next</div></li>
2499 + <li class="dt-paging-button item disabled"><div class="page-link last" aria-controls="mainwp-manage-sites-table" aria-disabled="true" aria-label="Last" data-dt-idx="last" tabindex="-1">Last</div></li>
2500 + <?php } else { ?>
2501 + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage&current_page=<?php echo $current_page === $last ? intval( $last ) : intval( $current_page + 1 ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link next" aria-controls="mainwp-manage-sites-table" aria-label="Next" data-dt-idx="next" tabindex="0">Next</a></li>
2502 + <li class="dt-paging-button item"><a href="admin.php?page=UpdatesManage&current_page=<?php echo intval( $total_page ); ?>&_opennonce=<?php echo esc_html( wp_create_nonce( 'mainwp-admin-nonce' ) ); ?>" class="page-link last" aria-controls="mainwp-manage-sites-table" aria-label="Last" data-dt-idx="last" tabindex="0">Last</a></li>
2503 + <?php } ?>
2504 + </menu></div>
2505 + </div>
2506 + <br/>
2507 + <?php
2508 + }
2509 +
2510 + /**
2511 + * Cheks which primary backup plugin is being used.
2512 + *
2513 + * @param mixed $what Which backup plugin is being use.
2514 + * @param object $website Website array of information.
2515 + *
2516 + * @return boolean True|False.
2517 + */
2518 + public static function activated_primary_backup_plugin( $what, $website ) {
2519 + $plugins = json_decode( $website->plugins, 1 );
2520 + if ( ! is_array( $plugins ) || empty( $plugins ) ) {
2521 + return false;
2522 + }
2523 +
2524 + $checks = array(
2525 + 'backupbuddy' => 'backupbuddy/backupbuddy.php',
2526 + 'backupwp' => array( 'backwpup/backwpup.php', 'backwpup-pro/backwpup.php' ),
2527 + 'updraftplus' => 'updraftplus/updraftplus.php',
2528 +
2529 + );
2530 +
2531 + $slug = isset( $checks[ $what ] ) ? $checks[ $what ] : '';
2532 +
2533 + if ( empty( $slug ) ) {
2534 + return false;
2535 + }
2536 +
2537 + $installed = false;
2538 +
2539 + foreach ( $plugins as $plugin ) {
2540 + if ( ( is_string( $slug ) && strtolower( $plugin['slug'] ) === $slug ) || ( is_array( $slug ) && in_array( $plugin['slug'], $slug ) ) ) {
2541 + if ( $plugin['active'] ) {
2542 + $installed = true;
2543 + }
2544 + break;
2545 + }
2546 + }
2547 +
2548 + return $installed;
2549 + }
2550 +
2551 + /**
2552 + * Sets the HTML selector to continue updates.
2553 + *
2554 + * @param string $current_update current update string.
2555 + * @param bool $slug Whether to update slug.
2556 + */
2557 + public static function set_continue_update_html_selector( $current_update, $slug = false ) {
2558 +
2559 + $check_slug = true;
2560 + if ( ! empty( $slug ) ) {
2561 + $check_slug = ( $slug === static::$continue_update_slug ) ? true : false;
2562 + }
2563 +
2564 + if ( $check_slug && $current_update === static::$continue_update ) {
2565 + static::$continue_selector = 'updatesoverview_continue_update_me';
2566 + } else {
2567 + static::$continue_selector = '';
2568 + }
2569 + }
2570 +
2571 + /**
2572 + * Gets the HTML selector to continue updates.
2573 + *
2574 + * @return void.
2575 + */
2576 + public static function get_continue_update_selector() {
2577 + echo esc_attr( static::$continue_selector );
2578 + }
2579 +
2580 + /**
2581 + * Displays the updates modal window during updates.
2582 + */
2583 + public static function render_updates_modal() {
2584 + ?>
2585 + <div class="ui modal" id="updatesoverview-backup-box">
2586 + <div class="header"><?php esc_html_e( 'Backup Check', 'mainwp' ); ?></div>
2587 + <div class="scrolling content mainwp-modal-content"></div>
2588 + <div class="actions mainwp-modal-actions">
2589 + <input id="updatesoverview-backup-all" type="button" name="Backup All" value="<?php esc_html_e( 'Backup All', 'mainwp' ); ?>" class="button-primary"/>
2590 + <a id="updatesoverview-backup-now" href="javascript:void(0)" target="_blank" style="display: none" class="button-primary button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a>&nbsp;
2591 + <input id="updatesoverview-backup-ignore" type="button" name="Ignore" value="<?php esc_html_e( 'Ignore', 'mainwp' ); ?>" class="button"/>
2592 + </div>
2593 + </div>
2594 + <?php
2595 + }
2596 +
2597 + /**
2598 + * Displays the plugin details modal window.
2599 + */
2600 + public static function render_plugin_details_modal() {
2601 + ?>
2602 + <div class="ui modal" id="mainwp-plugin-details-modal">
2603 + <i class="close icon"></i>
2604 + <div class="header"><?php echo esc_html__( 'Plugin Details', 'mainwp' ); ?></div>
2605 + <div class="content">
2606 + <div class="ui embed"></div>
2607 + </div>
2608 + <div class="actions">
2609 + </div>
2610 + </div>
2611 + <?php
2612 + }
2613 +
2614 + /**
2615 + * Method get_site_tz_info().
2616 + *
2617 + * @param object $website Website.
2618 + *
2619 + * @return string Timezone site info.
2620 + */
2621 + public static function get_site_tz_info( $website ) {
2622 + if ( is_object( $website ) && ! empty( $website->site_info ) ) {
2623 + $wp_info = ! empty( $website->site_info ) ? json_decode( $website->site_info, true ) : array();
2624 + if ( ! is_array( $wp_info ) ) {
2625 + $wp_info = array();
2626 + }
2627 + $use_tzformat = ! empty( $wp_info['format_datetime'] ) && is_array( $wp_info['format_datetime'] ) ? $wp_info['format_datetime'] : array();
2628 + $offs = ! empty( $use_tzformat['gmt_offset'] ) ? intval( $use_tzformat['gmt_offset'] ) : 0;
2629 + return esc_html__( '- Timezone:', 'mainwp' ) . ' UTC' . ( $offs >= 0 ? '+' . $offs : $offs );
2630 + }
2631 + return '';
2632 + }
2633 +
2634 + /**
2635 + * Method render_changes_history_modal()
2636 + */
2637 + public static function render_changes_history_modal() {
2638 + ?>
2639 + <div class="ui modal" id="mainwp-plugin-theme-history-changes-modal">
2640 + <i class="close icon"></i>
2641 + <div class="ui header">
2642 + <div class="main-text"><?php esc_html_e( 'History', 'mainwp' ); ?></div>
2643 + <div class="sub header" style="display:none;"></div>
2644 + </div>
2645 + <div class="scrolling content"></div>
2646 + <div class="actions">
2647 + <div class="ui two columns stackable grid">
2648 + <div class="left aligned column col-left"></div>
2649 + <div class="right aligned column col-right"></div>
2650 + </div>
2651 + </div>
2652 + </div>
2653 + <?php
2654 + }
2655 +
2656 + /**
2657 + * Method render_screen_options_modal()
2658 + *
2659 + * Renders Page Settings Modal.
2660 + */
2661 + public static function render_screen_options_modal() { // phpcs:ignore -- NOSONAR - complex method.
2662 +
2663 + $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate' );
2664 + $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate' );
2665 + $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate' );
2666 + $snTransAutomaticUpdate = (int) get_option( 'mainwp_transAutomaticDailyUpdate' );
2667 +
2668 + $mainwp_show_language_updates = (int) get_option( 'mainwp_show_language_updates', 1 );
2669 + $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
2670 + $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
2671 + ?>
2672 + <div class="ui modal" id="mainwp-manage-updates-screen-options-modal">
2673 + <i class="close icon"></i>
2674 + <div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div>
2675 + <div class="scrolling content ui form">
2676 + <form method="POST" action="" id="manage-updates-screen-options-form" name="manage-updates-screen-options-form">
2677 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
2678 + <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdatesScrOptions' ) ); ?>" />
2679 + <div class="ui grid field">
2680 + <label class="six wide column middle aligned"><?php esc_html_e( 'Plugin advanced automatic updates', 'mainwp' ); ?></label>
2681 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugin updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2682 + <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown">
2683 + <option value="1" <?php echo 1 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2684 + <option value="0" <?php echo ( false !== $snPluginAutomaticDailyUpdate && empty( $snPluginAutomaticDailyUpdate ) ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2685 + </select>
2686 + </div>
2687 + </div>
2688 + <div class="ui grid field">
2689 + <label class="six wide column middle aligned"><?php esc_html_e( 'Theme advanced automatic updates', 'mainwp' ); ?></label>
2690 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic theme updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2691 + <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown">
2692 + <option value="1" <?php echo 1 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2693 + <option value="0" <?php echo ( false !== $snThemeAutomaticDailyUpdate && 0 === $snThemeAutomaticDailyUpdate ) || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2694 + </select>
2695 + </div>
2696 + </div>
2697 + <div class="ui grid field">
2698 + <label class="six wide column middle aligned"><?php esc_html_e( 'Translation advanced automatic updates', 'mainwp' ); ?></label>
2699 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic translation updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2700 + <select name="mainwp_transAutomaticDailyUpdate" id="mainwp_transAutomaticDailyUpdate" class="ui dropdown">
2701 + <option value="1" <?php echo 1 === $snTransAutomaticUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2702 + <option value="0" <?php echo ( false !== $snTransAutomaticUpdate && 0 === $snTransAutomaticUpdate ) || 2 === $snTransAutomaticUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2703 + </select>
2704 + </div>
2705 + </div>
2706 + <div class="ui grid field">
2707 + <label class="six wide column middle aligned"><?php esc_html_e( 'WP Core advanced automatic updates', 'mainwp' ); ?></label>
2708 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic WordPress core updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2709 + <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown">
2710 + <option value="1" <?php echo 1 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
2711 + <option value="0" <?php echo ( false !== $snAutomaticDailyUpdate && 0 === $snAutomaticDailyUpdate ) || 2 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
2712 + </select>
2713 + </div>
2714 + </div>
2715 + <div class="ui grid field">
2716 + <label class="six wide column middle aligned"><?php esc_html_e( 'Advanced automatic updates delay', 'mainwp' ); ?></label>
2717 + <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'Set the number of days to delay automatic updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2718 + <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown">
2719 + <option value="0" <?php echo 0 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
2720 + <option value="1" <?php echo 1 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
2721 + <option value="2" <?php echo 2 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
2722 + <option value="3" <?php echo 3 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
2723 + <option value="4" <?php echo 4 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
2724 + <option value="5" <?php echo 5 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
2725 + <option value="6" <?php echo 6 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
2726 + <option value="7" <?php echo 7 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
2727 + <option value="14" <?php echo 14 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
2728 + <option value="30" <?php echo 30 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
2729 + </select>
2730 + </div>
2731 + </div>
2732 + <div class="ui grid field">
2733 + <label class="six wide column middle aligned"><?php esc_html_e( 'Show WordPress language updates', 'mainwp' ); ?></label>
2734 + <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to manage Translation updates', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2735 + <input type="checkbox" name="mainwp_show_language_updates" id="mainwp_show_language_updates" <?php echo 1 === $mainwp_show_language_updates ? 'checked="true"' : ''; ?>/>
2736 + </div>
2737 + </div>
2738 + <div class="ui grid field">
2739 + <label class="six wide column middle aligned"><?php esc_html_e( 'Update confirmations', 'mainwp' ); ?></label>
2740 + <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Choose if you want to disable the popup confirmations when performing updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2741 + <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown">
2742 + <option value="0" <?php echo 0 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
2743 + <option value="2" <?php echo 2 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
2744 + <option value="1" <?php echo 1 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
2745 + </select>
2746 + </div>
2747 + </div>
2748 + <div class="ui hidden divider"></div>
2749 + <div class="ui hidden divider"></div>
2750 + </div>
2751 + <div class="actions">
2752 + <div class="ui two columns grid">
2753 + <div class="left aligned column"></div>
2754 + <div class="ui right aligned column">
2755 + <input type="submit" class="ui green button" name="btnSubmit" id="submit-manage-updates-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" />
2756 + </div>
2757 + </div>
2758 + </div>
2759 + </form>
2760 + </div>
2761 + <?php
2762 + }
2763 +
2764 +
2765 + /**
2766 + * Method mainwp_help_content()
2767 + *
2768 + * Creates the MainWP Help Documentation List for the help component in the sidebar.
2769 + */
2770 + public static function mainwp_help_content() {
2771 + if ( isset( $_GET['page'] ) && 'UpdatesManage' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
2772 + ?>
2773 + <p><?php esc_html_e( 'If you need help with managing updates, please review following help documents', 'mainwp' ); ?></p>
2774 + <div class="ui list">
2775 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-updates" target="_blank">Update Plugins</a></div>
2776 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#plugin-auto-updates" target="_blank">Plugins Auto Updates</a></div>
2777 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">Ignore Plugin Updates</a></div>
2778 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-plugin-updates" target="_blank">Update Themes</a></div>
2779 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#theme-auto-updates" target="_blank">Themes Auto Updates</a></div>
2780 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-theme-updates" target="_blank">Ignore Theme Updates</a></div>
2781 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#wordpress-core-updates" target="_blank">Update WordPress Core</a></div>
2782 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#auto-update-wordpress-core" target="_blank">Auto Update WordPress Core</a></div>
2783 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#ignore-wordpress-core-updates" target="_blank">Ignore WordPress Core Update</a></div>
2784 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/updates/manage-updates#safe-updates-%2F-rollback" target="_blank">Safe Updates/Updates Rollback</a></div>
2785 + <?php
2786 + /**
2787 + * Action: mainwp_updates_help_item
2788 + *
2789 + * Fires at the bottom of the help articles list in the Help sidebar on the Updates page.
2790 + *
2791 + * Suggested HTML markup:
2792 + *
2793 + * <div class="item"><a href="Your custom URL">Your custom text</a></div>
2794 + *
2795 + * @since 4.1
2796 + */
2797 + do_action( 'mainwp_updates_help_item' );
2798 + ?>
2799 + </div>
2800 + <?php
2801 + }
2802 + }
2443 2803 }