| @@ -6,8 +6,13 @@ | ||
| 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_Manage_Sites_View |
| 12 | 17 | * |
| 13 | 18 | * @package MainWP\Dashboard |
| @@ -47,10 +52,10 @@ | ||
| 47 | 52 | <div id="menu-mainwp-Sites" class="mainwp-submenu-wrapper"> |
| 48 | 53 | <div class="wp-submenu sub-open" style=""> |
| 49 | 54 | <div class="mainwp_boxout"> |
| 50 | 55 | <div class="mainwp_boxoutin"></div> |
| 51 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Manage Sites', 'mainwp' ); ?></a> | |
| 52 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'add_sites' ) ) { ?> | |
| 56 | + <a href="<?php echo esc_url( admin_url( MainWP_Unhooks_Helper::add_unhooks_params( 'admin.php?page=managesites' ) ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Manage Sites', 'mainwp' ); ?></a> | |
| 57 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'add_sites' ) ) { ?> | |
| 53 | 58 | <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'managesites_add_new' ) ) { ?> |
| 54 | 59 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Add New', 'mainwp' ); ?></a> |
| 55 | 60 | <?php } ?> |
| 56 | 61 | <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'managesites_import' ) ) { ?> |
| @@ -63,13 +68,15 @@ | ||
| 63 | 68 | <?php |
| 64 | 69 | if ( isset( $subPages ) && is_array( $subPages ) ) { |
| 65 | 70 | foreach ( $subPages as $subPage ) { |
| 66 | 71 | if ( ! isset( $subPage['menu_hidden'] ) || ( isset( $subPage['menu_hidden'] ) && true !== $subPage['menu_hidden'] ) ) { |
| 67 | - if ( MainWP_Menu::is_disable_menu_item( 3, 'ManageSites' . $subPage['slug'] ) ) { | |
| 72 | + $sub_slug = isset( $subPage['slug'] ) ? $subPage['slug'] : ''; | |
| 73 | + $sub_title = isset( $subPage['title'] ) ? $subPage['title'] : ''; | |
| 74 | + if ( MainWP_Menu::is_disable_menu_item( 3, 'ManageSites' . $sub_slug ) ) { | |
| 68 | 75 | continue; |
| 69 | 76 | } |
| 70 | 77 | ?> |
| 71 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=ManageSites' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $subPage['title'] ); ?></a> | |
| 78 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=ManageSites' . $sub_slug ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $sub_title ); ?></a> | |
| 72 | 79 | <?php |
| 73 | 80 | } |
| 74 | 81 | } |
| 75 | 82 | } |
| @@ -97,9 +104,9 @@ | ||
| 97 | 104 | array( |
| 98 | 105 | 'title' => esc_html__( 'Sites', 'mainwp' ), |
| 99 | 106 | 'parent_key' => 'mainwp_tab', |
| 100 | 107 | 'slug' => 'managesites', |
| 101 | - 'href' => 'admin.php?page=managesites', | |
| 108 | + 'href' => MainWP_Unhooks_Helper::add_unhooks_params( 'admin.php?page=managesites' ), | |
| 102 | 109 | 'icon' => '<i class="globe icon"></i>', |
| 103 | 110 | ), |
| 104 | 111 | 0 |
| 105 | 112 | ); |
| @@ -108,11 +115,12 @@ | ||
| 108 | 115 | array( |
| 109 | 116 | 'title' => esc_html__( 'Manage Sites', 'mainwp' ), |
| 110 | 117 | 'parent_key' => 'managesites', |
| 111 | 118 | 'slug' => 'managesites', |
| 112 | - 'href' => 'admin.php?page=managesites', | |
| 119 | + 'href' => MainWP_Unhooks_Helper::add_unhooks_params( 'admin.php?page=managesites' ), | |
| 113 | 120 | 'right' => '', |
| 114 | 121 | 'leftsub_order_level2' => 1, |
| 122 | + 'id' => 'managesites-root', | |
| 115 | 123 | ), |
| 116 | 124 | array( |
| 117 | 125 | 'title' => esc_html__( 'Add New', 'mainwp' ), |
| 118 | 126 | 'parent_key' => 'managesites', |
| @@ -119,19 +127,11 @@ | ||
| 119 | 127 | 'href' => 'admin.php?page=managesites&do=new', |
| 120 | 128 | 'slug' => 'managesites', |
| 121 | 129 | 'right' => 'add_sites', |
| 122 | 130 | 'item_slug' => 'managesites_add_new', |
| 131 | + 'id' => 'managesites-addnew', | |
| 123 | 132 | 'leftsub_order_level2' => 2, |
| 124 | 133 | ), |
| 125 | - array( | |
| 126 | - 'title' => esc_html__( 'Import Sites', 'mainwp' ), | |
| 127 | - 'parent_key' => 'managesites', | |
| 128 | - 'href' => 'admin.php?page=managesites&do=bulknew', | |
| 129 | - 'slug' => 'managesites', | |
| 130 | - 'right' => 'add_sites', | |
| 131 | - 'item_slug' => 'managesites_import', | |
| 132 | - 'leftsub_order_level2' => 3, | |
| 133 | - ), | |
| 134 | 134 | ); |
| 135 | 135 | |
| 136 | 136 | MainWP_Menu::init_subpages_left_menu( $subPages, $items_menu, 'managesites', 'ManageSites' ); |
| 137 | 137 | |
| @@ -140,9 +140,9 @@ | ||
| 140 | 140 | if ( MainWP_Menu::is_disable_menu_item( 3, $item['item_slug'] ) ) { |
| 141 | 141 | continue; |
| 142 | 142 | } |
| 143 | 143 | } elseif ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { |
| 144 | - continue; | |
| 144 | + continue; | |
| 145 | 145 | } |
| 146 | 146 | MainWP_Menu::add_left_menu( $item, 2 ); |
| 147 | 147 | } |
| 148 | 148 | } |
| @@ -152,9 +152,9 @@ | ||
| 152 | 152 | * |
| 153 | 153 | * Build Sites page header. |
| 154 | 154 | * |
| 155 | 155 | * @param string $shownPage Current Page. |
| 156 | - * @param string $subPages Sites subpages. | |
| 156 | + * @param array $subPages Sites subpages. | |
| 157 | 157 | * |
| 158 | 158 | * @uses \MainWP\Dashboard\MainWP_Connect::get_favico_url() |
| 159 | 159 | * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 160 | 160 | * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() |
| @@ -159,9 +159,9 @@ | ||
| 159 | 159 | * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 160 | 160 | * @uses \MainWP\Dashboard\MainWP_UI::render_top_header() |
| 161 | 161 | * @uses \MainWP\Dashboard\MainWP_UI::render_second_top_header() |
| 162 | 162 | */ |
| 163 | - public static function render_header( $shownPage = '', $subPages = '' ) { // phpcs:ignore -- NOSONAR - complex. | |
| 163 | + public static function render_header( $shownPage = '', $subPages = array() ) { // phpcs:ignore -- NOSONAR - complex. | |
| 164 | 164 | |
| 165 | 165 | if ( '' === $shownPage || 'managesites' === $shownPage ) { |
| 166 | 166 | $shownPage = 'ManageSites'; |
| 167 | 167 | } |
| @@ -181,14 +181,16 @@ | ||
| 181 | 181 | } elseif ( isset( $_GET['emailsettingsid'] ) && ! empty( $_GET['emailsettingsid'] ) ) { |
| 182 | 182 | $site_id = intval( $_GET['emailsettingsid'] ); |
| 183 | 183 | } elseif ( isset( $_GET['cacheControlId'] ) && ! empty( $_GET['cacheControlId'] ) ) { |
| 184 | 184 | $site_id = intval( $_GET['cacheControlId'] ); |
| 185 | + } elseif ( ! empty( $_GET['monitor_wpid'] ) ) { | |
| 186 | + $site_id = intval( $_GET['monitor_wpid'] ); | |
| 185 | 187 | } |
| 186 | 188 | // phpcs:enable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 187 | 189 | |
| 188 | 190 | $managesites_pages = array( |
| 189 | 191 | 'ManageSites' => array( |
| 190 | - 'href' => 'admin.php?page=managesites', | |
| 192 | + 'href' => MainWP_Unhooks_Helper::add_unhooks_params( 'admin.php?page=managesites' ), | |
| 191 | 193 | 'title' => esc_html__( 'Manage Sites', 'mainwp' ), |
| 192 | 194 | 'access' => true, |
| 193 | 195 | ), |
| 194 | 196 | 'AddNew' => array( |
| @@ -193,14 +195,14 @@ | ||
| 193 | 195 | ), |
| 194 | 196 | 'AddNew' => array( |
| 195 | 197 | 'href' => 'admin.php?page=managesites&do=new', |
| 196 | 198 | 'title' => esc_html__( 'Add New', 'mainwp' ), |
| 197 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'add_sites' ), | |
| 199 | + 'access' => \mainwp_current_user_can( 'dashboard', 'add_sites' ), | |
| 198 | 200 | ), |
| 199 | 201 | 'BulkAddNew' => array( |
| 200 | 202 | 'href' => 'admin.php?page=managesites&do=bulknew', |
| 201 | 203 | 'title' => esc_html__( 'Import Sites', 'mainwp' ), |
| 202 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'add_sites' ), | |
| 204 | + 'access' => \mainwp_current_user_can( 'dashboard', 'add_sites' ), | |
| 203 | 205 | ), |
| 204 | 206 | 'MonitoringSites' => array( |
| 205 | 207 | 'href' => 'admin.php?page=MonitoringSites', |
| 206 | 208 | 'title' => esc_html__( 'Monitoring', 'mainwp' ), |
| @@ -209,38 +211,33 @@ | ||
| 209 | 211 | ); |
| 210 | 212 | |
| 211 | 213 | $total_info = MainWP_Manage_Sites_Update_View::get_total_info( $site_id ); |
| 212 | 214 | $total_updates = $total_info['total_upgrades']; |
| 213 | - $after_title = empty( $total_updates ) ? '' : '<div class="ui mini circular red label" timestamp="' . time() . '" style="font-size:6px;" data-tooltip="View pending updates" data-inverted="" data-position="top center"></div>'; | |
| 215 | + $after_title = empty( $total_updates ) ? '' : '<div class="ui tiny green label" timestamp="' . time() . '">' . absint( $total_updates ) . '</div>'; | |
| 214 | 216 | |
| 215 | 217 | $site_pages = array( |
| 216 | - 'ManageSitesDashboard' => array( | |
| 218 | + 'ManageSitesDashboard' => array( | |
| 217 | 219 | 'href' => 'admin.php?page=managesites&dashboard=' . $site_id, |
| 218 | 220 | 'title' => esc_html__( 'Overview', 'mainwp' ), |
| 219 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'access_individual_dashboard' ), | |
| 221 | + 'access' => \mainwp_current_user_can( 'dashboard', 'access_individual_dashboard' ), | |
| 220 | 222 | ), |
| 221 | - 'ManageSitesEdit' => array( | |
| 223 | + 'ManageSitesEdit' => array( | |
| 222 | 224 | 'href' => 'admin.php?page=managesites&id=' . $site_id, |
| 223 | - 'title' => esc_html__( 'Edit', 'mainwp' ), | |
| 224 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'edit_sites' ), | |
| 225 | + 'title' => esc_html__( 'Settings', 'mainwp' ), | |
| 226 | + 'access' => \mainwp_current_user_can( 'dashboard', 'edit_sites' ), | |
| 225 | 227 | ), |
| 226 | - 'ManageSitesUpdates' => array( | |
| 228 | + 'ManageSitesUpdates' => array( | |
| 227 | 229 | 'href' => 'admin.php?page=managesites&updateid=' . $site_id, |
| 228 | 230 | 'title' => esc_html__( 'Updates', 'mainwp' ), |
| 229 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'access_individual_dashboard' ), | |
| 231 | + 'access' => \mainwp_current_user_can( 'dashboard', 'access_individual_dashboard' ), | |
| 230 | 232 | 'after_title' => $after_title, |
| 231 | 233 | ), |
| 232 | - 'ManageSitesEmailSettings' => array( | |
| 233 | - 'href' => 'admin.php?page=managesites&emailsettingsid=' . $site_id, | |
| 234 | - 'title' => esc_html__( 'Email Settings', 'mainwp' ), | |
| 235 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'edit_sites' ), | |
| 236 | - ), | |
| 237 | - 'ManageSitesBackups' => array( | |
| 234 | + 'ManageSitesBackups' => array( | |
| 238 | 235 | 'href' => 'admin.php?page=managesites&backupid=' . $site_id, |
| 239 | 236 | 'title' => esc_html__( 'Backups', 'mainwp' ), |
| 240 | - 'access' => mainwp_current_user_have_right( 'dashboard', 'execute_backups' ), | |
| 237 | + 'access' => \mainwp_current_user_can( 'dashboard', 'execute_backups' ), | |
| 241 | 238 | ), |
| 242 | - 'SecurityScan' => array( | |
| 239 | + 'SecurityScan' => array( | |
| 243 | 240 | 'href' => 'admin.php?page=managesites&scanid=' . $site_id, |
| 244 | 241 | 'title' => esc_html__( 'Site Hardening', 'mainwp' ), |
| 245 | 242 | 'access' => true, |
| 246 | 243 | ), |
| @@ -267,14 +264,14 @@ | ||
| 267 | 264 | $website = MainWP_DB::instance()->get_website_by_id( $site_id ); |
| 268 | 265 | if ( $website ) { |
| 269 | 266 | $reconnect = ''; |
| 270 | 267 | if ( $site_id && $website && '' !== $website->sync_errors ) { |
| 271 | - $reconnect = '<a href="#" class="mainwp-updates-overview-reconnect-site item" siteid="' . intval( $site_id ) . '"><i class="sync alternate icon"></i> Reconnect</a>'; | |
| 268 | + $reconnect = '<a href="#" class="mainwp-updates-overview-reconnect-site item" adminuser="' . esc_attr( $website->adminname ) . '" siteid="' . intval( $site_id ) . '"><i class="sync alternate icon"></i> Reconnect</a>'; | |
| 272 | 269 | } |
| 273 | 270 | $wp_admin_href = MainWP_Site_Open::get_open_site_url( $site_id, false, false ); |
| 274 | 271 | $dropdown = $reconnect . ' |
| 275 | - <a class="item mainwp-remove-site-button" site-id="' . intval( $site_id ) . '" id="mainwp-remove-site-button" href="#"><i class="trash alternate icon"></i> Remove Site</a> | |
| 276 | - <a id="mainwp-go-wp-admin-button" target="_blank" href="' . $wp_admin_href . '" class="item open_newwindow_wpadmin"><i class="sign in icon"></i> Go to WP Admin</a> | |
| 272 | + <a class="item mainwp-remove-site-button" site-id="' . intval( $site_id ) . '" id="mainwp-remove-site-button" href="#"><i class="trash grey icon"></i> Remove Site</a> | |
| 273 | + <a id="mainwp-go-wp-admin-button" target="_blank" href="' . $wp_admin_href . '" class="item open_newwindow_wpadmin"><i class="sign in grey icon"></i> Go to WP Admin</a> | |
| 277 | 274 | '; |
| 278 | 275 | $site_icon = ''; |
| 279 | 276 | if ( 1 === (int) get_option( 'mainwp_use_favicon', 1 ) ) { |
| 280 | 277 | $favi_url = MainWP_Connect::get_favico_url( $website ); |
| @@ -279,9 +276,17 @@ | ||
| 279 | 276 | if ( 1 === (int) get_option( 'mainwp_use_favicon', 1 ) ) { |
| 280 | 277 | $favi_url = MainWP_Connect::get_favico_url( $website ); |
| 281 | 278 | $site_icon = MainWP_Manage_Sites::get_instance()->get_site_icon_display( $website->cust_site_icon_info, $favi_url ); |
| 282 | 279 | } |
| 283 | - $pagetitle = $site_icon . '<div class="content"><div class="ui pointing dropdown"><div class="text">' . $website->name . '</div><i class="dropdown icon"></i><div class="menu">' . $dropdown . '</div></div><div class="sub header"><a href="' . $website->url . '" target="_blank" style="font-weight:normal!important;">' . MainWP_Utility::get_nice_url( $website->url ) . '</a> <a href="' . MainWP_Site_Open::get_open_site_url( $website->id, '', false ) . '" target="_blank" class="open_newwindow_wpadmin" style="font-weight:normal!important;"><i class="sign in icon" style="font-weight:normal!important;"></i></a></div></div>'; | |
| 280 | + $pagetitle = $site_icon . '<div class="content"><a href="' . esc_url( MainWP_Site_Open::get_open_site_url( $website->id, '', false ) ) . '" target="_blank" class="open_newwindow_wpadmin" rel="noopener noreferrer" style="font-weight:normal!important;"><i class="sign in grey icon" style="font-weight:normal!important;"></i></a><div class="ui pointing dropdown"><div class="text">' . esc_html( $website->name ) . '</div><i class="dropdown icon"></i><div class="menu">' . $dropdown . '</div></div><div class="sub header"><a href="' . esc_url( $website->url ) . '" target="_blank" style="font-size:10px" class="ui grey text" rel="noopener noreferrer">' . esc_html( MainWP_Utility::get_nice_url( $website->url ) ) . '</a></div></div>'; | |
| 281 | + $site_pages['JumpToWPAdmin'] = array( | |
| 282 | + 'href' => $wp_admin_href, | |
| 283 | + 'title' => esc_html__( 'Go to WP Admin', 'mainwp' ), | |
| 284 | + 'access' => true, | |
| 285 | + 'class' => 'open_newwindow_wpadmin', | |
| 286 | + 'target' => '_blank', | |
| 287 | + 'rel' => 'noopener noreferrer', | |
| 288 | + ); | |
| 284 | 289 | } |
| 285 | 290 | } |
| 286 | 291 | |
| 287 | 292 | $params = array( |
| @@ -297,11 +302,18 @@ | ||
| 297 | 302 | |
| 298 | 303 | static::render_managesites_header( $site_pages, $managesites_pages, $subPages, $site_id, $shownPage ); |
| 299 | 304 | |
| 300 | 305 | if ( $manage_sites ) { |
| 301 | - $which = strtolower( $shownPage ); | |
| 302 | - MainWP_UI::render_second_top_header( $which ); | |
| 306 | + $count = MainWP_DB::instance()->get_websites_count( null, false ); | |
| 307 | + if ( ! empty( $count ) ) { | |
| 308 | + $which = strtolower( $shownPage ); | |
| 309 | + MainWP_UI::render_second_top_header( $which ); | |
| 310 | + } | |
| 303 | 311 | } |
| 312 | + | |
| 313 | + if ( ! empty( $site_id ) ) { | |
| 314 | + MainWP_UI::render_modal_reconnect(); | |
| 315 | + } | |
| 304 | 316 | } |
| 305 | 317 | |
| 306 | 318 | /** |
| 307 | 319 | * Method render_footer() |
| @@ -359,15 +371,17 @@ | ||
| 359 | 371 | if ( isset( $subPage['sitetab'] ) && true === $subPage['sitetab'] && empty( $site_id ) ) { |
| 360 | 372 | continue; |
| 361 | 373 | } |
| 362 | 374 | $item = array(); |
| 363 | - $item['title'] = $subPage['title']; | |
| 375 | + $item['title'] = isset( $subPage['title'] ) ? $subPage['title'] : ''; | |
| 376 | + $sub_slug = isset( $subPage['slug'] ) ? $subPage['slug'] : ''; | |
| 377 | + | |
| 364 | 378 | if ( ! empty( $subPage['href'] ) ) { |
| 365 | 379 | $item['href'] = $subPage['href']; |
| 366 | 380 | } else { |
| 367 | - $item['href'] = 'admin.php?page=ManageSites' . $subPage['slug'] . ( $site_id ? '&id=' . esc_attr( $site_id ) : '' ); | |
| 381 | + $item['href'] = 'admin.php?page=ManageSites' . $sub_slug . ( $site_id ? '&id=' . esc_attr( $site_id ) : '' ); | |
| 368 | 382 | } |
| 369 | - $item['active'] = isset( $subPage['slug'] ) && ( $subPage['slug'] === $shownPage ) ? true : false; | |
| 383 | + $item['active'] = ( $sub_slug === $shownPage ) ? true : false; | |
| 370 | 384 | $renderItems[] = $item; |
| 371 | 385 | } |
| 372 | 386 | } |
| 373 | 387 | $renderItems = apply_filters( 'mainwp_manage_sites_navigation_items', $renderItems, $site_id, $shownPage ); |
| @@ -383,20 +397,23 @@ | ||
| 383 | 397 | * @uses \MainWP\Dashboard\MainWP_Utility::starts_with() |
| 384 | 398 | */ |
| 385 | 399 | public static function render_import_sites() { // phpcs:ignore -- NOSONAR - complex. |
| 386 | 400 | ?> |
| 387 | - <div id="mainwp-importing-sites" class="ui active inverted dimmer" style="display:none"> | |
| 388 | - <div class="ui medium text loader"><?php esc_html_e( 'Importing', 'mainwp' ); ?></div> | |
| 401 | + <div id="mainwp-importing-sites" class="ui active dimmer"> | |
| 402 | + <div class="ui double text loader"><?php esc_html_e( 'Importing...', 'mainwp' ); ?></div> | |
| 389 | 403 | </div> |
| 404 | + <div class="ui message" id="mainwp-import-sites-status-message"> | |
| 405 | + <?php echo '<i class="notched circle loading icon"></i> ' . esc_html__( 'Importing...', 'mainwp' ); ?> | |
| 406 | + </div> | |
| 390 | 407 | <?php |
| 391 | 408 | $errors = array(); |
| 392 | 409 | //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended |
| 393 | 410 | if ( isset( $_FILES['mainwp_managesites_file_bulkupload']['error'] ) && UPLOAD_ERR_OK === $_FILES['mainwp_managesites_file_bulkupload']['error'] && check_admin_referer( 'mainwp-admin-nonce' ) ) { |
| 394 | 411 | if ( isset( $_FILES['mainwp_managesites_file_bulkupload']['tmp_name'] ) && is_uploaded_file( $_FILES['mainwp_managesites_file_bulkupload']['tmp_name'] ) ) { |
| 395 | - $tmp_path = isset( $_FILES['mainwp_managesites_file_bulkupload']['tmp_name'] ) ? sanitize_text_field( wp_unslash( $_FILES['mainwp_managesites_file_bulkupload']['tmp_name'] ) ) : ''; | |
| 396 | - MainWP_System_Utility::get_wp_file_system(); | |
| 397 | - //phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended | |
| 412 | + $tmp_path = $_FILES['mainwp_managesites_file_bulkupload']['tmp_name']; | |
| 398 | 413 | |
| 414 | + $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system(); | |
| 415 | + //phpcs:enable | |
| 399 | 416 | /** |
| 400 | 417 | * WordPress files system object. |
| 401 | 418 | * |
| 402 | 419 | * @global object |
| @@ -402,19 +419,31 @@ | ||
| 402 | 419 | * @global object |
| 403 | 420 | */ |
| 404 | 421 | global $wp_filesystem; |
| 405 | 422 | |
| 406 | - $content = $wp_filesystem->get_contents( $tmp_path ); | |
| 423 | + $lines = array(); | |
| 424 | + if ( $hasWPFileSystem && ! empty( $wp_filesystem ) ) { | |
| 425 | + $content = $wp_filesystem->get_contents( $tmp_path ); | |
| 426 | + if ( ! empty( $content ) ) { | |
| 427 | + // to compatible with EOL on OSs. | |
| 428 | + $content = str_replace( "\r\n", "\r", $content ); | |
| 429 | + $content = str_replace( "\n", "\r", $content ); | |
| 430 | + $lines = explode( "\r", $content ); | |
| 431 | + } | |
| 432 | + } else { | |
| 433 | + ?> | |
| 434 | + <div class="error below-h2"> | |
| 435 | + <p><strong><?php esc_html_e( 'Error', 'mainwp' ); ?></strong>: <?php esc_html_e( 'Unable to initialize the WordPress filesystem. Please try again.', 'mainwp' ); ?></p> | |
| 436 | + </div> | |
| 437 | + <?php | |
| 438 | + return; | |
| 439 | + } | |
| 407 | 440 | |
| 408 | - // to compatible with EOL on OSs. | |
| 409 | - $content = str_replace( "\r\n", "\r", $content ); | |
| 410 | - $content = str_replace( "\n", "\r", $content ); | |
| 411 | - $lines = explode( "\r", $content ); | |
| 412 | - | |
| 413 | 441 | $default_values = array( |
| 414 | 442 | 'name' => '', |
| 415 | 443 | 'url' => '', |
| 416 | 444 | 'adminname' => '', |
| 445 | + 'adminpwd' => '', | |
| 417 | 446 | 'wpgroups' => '', |
| 418 | 447 | 'uniqueId' => '', |
| 419 | 448 | 'http_user' => '', |
| 420 | 449 | 'http_pass' => '', |
| @@ -436,13 +465,13 @@ | ||
| 436 | 465 | |
| 437 | 466 | $items = str_getcsv( $line, ',' ); |
| 438 | 467 | |
| 439 | 468 | if ( ( null === $header_line ) && ! empty( $_POST['mainwp_managesites_chk_header_first'] ) ) { |
| 440 | - $header_line = $line . "\r"; | |
| 469 | + $header_line = sanitize_text_field( $line ) . "\r"; | |
| 441 | 470 | continue; |
| 442 | 471 | } |
| 443 | 472 | |
| 444 | - if ( 3 > count( $items ) ) { | |
| 473 | + if ( 10 > count( $items ) ) { | |
| 445 | 474 | continue; |
| 446 | 475 | } |
| 447 | 476 | |
| 448 | 477 | $x = 0; |
| @@ -456,25 +485,23 @@ | ||
| 456 | 485 | $value = '0'; |
| 457 | 486 | } |
| 458 | 487 | } |
| 459 | 488 | |
| 460 | - $import_data[ $field ] = $value; | |
| 489 | + $import_data[ $field ] = sanitize_text_field( wp_unslash( $value ) ); | |
| 461 | 490 | ++$x; |
| 462 | 491 | } |
| 463 | 492 | $encoded = wp_json_encode( $import_data ); |
| 464 | 493 | ?> |
| 465 | - <input type="hidden" id="mainwp_managesites_import_csv_line_<?php echo esc_attr( $row + 1 ); ?>" value="" encoded-data="<?php echo esc_attr( $encoded ); ?>" original="<?php echo esc_attr( $originalLine ); ?>" /> | |
| 494 | + <input type="hidden" id="mainwp_managesites_import_csv_line_<?php echo esc_attr( $row + 1 ); ?>" value="" encoded-data="<?php echo esc_attr( $encoded ); ?>" original="<?php echo esc_attr( sanitize_text_field( $originalLine ) ); ?>" /> | |
| 466 | 495 | <?php |
| 467 | 496 | ++$row; |
| 468 | 497 | } |
| 469 | 498 | $header_line = trim( $header_line ); |
| 470 | - | |
| 471 | 499 | ?> |
| 472 | 500 | <input type="hidden" id="mainwp_managesites_do_import" value="1"/> |
| 473 | 501 | <input type="hidden" id="mainwp_managesites_total_import" value="<?php echo esc_attr( $row ); ?>"/> |
| 474 | - | |
| 475 | 502 | <div class="mainwp_managesites_import_listing" id="mainwp_managesites_import_logging"> |
| 476 | - <span class="log ui small text"><?php echo esc_html( $header_line ) . '<br/>'; ?></span> | |
| 503 | + <span class="log ui medium text"><?php echo esc_html( $header_line ) . '<br/>'; ?></span> | |
| 477 | 504 | </div> |
| 478 | 505 | <div class="mainwp_managesites_import_listing" id="mainwp_managesites_import_fail_logging" style="display: none;"> |
| 479 | 506 | <?php |
| 480 | 507 | echo esc_html( $header_line ); |
| @@ -487,10 +514,70 @@ | ||
| 487 | 514 | } |
| 488 | 515 | } else { |
| 489 | 516 | $errors[] = esc_html__( 'Upload failed. Please, try again.', 'mainwp' ) . '<br />'; |
| 490 | 517 | } |
| 518 | + } elseif ( ! empty( $_POST['mainwp_managesites_import'] ) && check_admin_referer( 'mainwp-admin-nonce' ) ) { | |
| 519 | + // Set site data by POST value. | |
| 520 | + $sites_data = ! empty( $_POST['mainwp_managesites_import'] ) ? wp_unslash( $_POST['mainwp_managesites_import'] ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 521 | + if ( ! empty( $sites_data ) ) { | |
| 522 | + $import_data = array(); // Create default import data. | |
| 523 | + // Map data sites data to import_data. | |
| 524 | + foreach ( $sites_data as $site ) { | |
| 525 | + // Break site if site_url and admin_name empty. | |
| 526 | + if ( empty( $site['site_url'] ) && empty( $site['admin_name'] ) ) { | |
| 527 | + continue; | |
| 528 | + } | |
| 529 | + // Map POST data to import data. | |
| 530 | + $import_data[] = array( | |
| 531 | + 'name' => ! empty( $site['site_name'] ) ? sanitize_text_field( wp_unslash( $site['site_name'] ) ) : '', | |
| 532 | + 'url' => ! empty( $site['site_url'] ) ? sanitize_text_field( wp_unslash( $site['site_url'] ) ) : '', | |
| 533 | + 'adminname' => ! empty( $site['admin_name'] ) ? sanitize_text_field( wp_unslash( $site['admin_name'] ) ) : '', | |
| 534 | + 'adminpwd' => ! empty( $site['admin_password'] ) ? wp_unslash( $site['admin_password'] ) : '', | |
| 535 | + 'wpgroups' => ! empty( $site['tag'] ) ? sanitize_text_field( wp_unslash( $site['tag'] ) ) : '', | |
| 536 | + 'uniqueId' => ! empty( $site['security_id'] ) ? sanitize_text_field( wp_unslash( $site['security_id'] ) ) : '', | |
| 537 | + 'http_user' => ! empty( $site['http_username'] ) ? sanitize_text_field( wp_unslash( $site['http_username'] ) ) : '', | |
| 538 | + 'http_pass' => ! empty( $site['http_password'] ) ? wp_unslash( $site['http_password'] ) : '', | |
| 539 | + 'verify_certificate' => isset( $site['verify_certificate'] ) ? intval( $site['verify_certificate'] ) : 1, | |
| 540 | + 'ssl_version' => ! empty( $site['ssl_version'] ) ? sanitize_text_field( wp_unslash( $site['ssl_version'] ) ) : 'auto', | |
| 541 | + ); | |
| 542 | + | |
| 543 | + } | |
| 544 | + // Import website if import data is not empty. | |
| 545 | + if ( ! empty( $import_data ) ) { | |
| 546 | + $header_line = trim( 'Site Name, Url, Admin Name, Tag,Security ID,HTTP Username,HTTP Password,Verify Certificate,SSL Version' ); // Set Header Line. | |
| 547 | + // Map import data to input html. | |
| 548 | + foreach ( $import_data as $key_import => $val_import ) { | |
| 549 | + $line = trim( implode( ',', $val_import ) ) | |
| 550 | + ?> | |
| 551 | + <input type="hidden" id="mainwp_managesites_import_csv_line_<?php echo esc_attr( $key_import + 1 ); ?>" value="" encoded-data="<?php echo esc_attr( wp_json_encode( $val_import ) ); ?>" original="<?php echo esc_attr( $line ); ?>" /> | |
| 552 | + <?php | |
| 553 | + } | |
| 554 | + $hd_id1 = 'mainwp_managesites_do_import'; | |
| 555 | + $hd_id2 = 'mainwp_managesites_total_import'; | |
| 556 | + $list_id = 'mainwp_managesites_import_logging'; | |
| 557 | + $fail_list_id = 'mainwp_managesites_import_fail_logging'; | |
| 558 | + ?> | |
| 559 | + <input type="hidden" id="mainwp_managesites_do_managesites_import" value="1"/> | |
| 560 | + <input type="hidden" id="<?php echo esc_attr( $hd_id1 ); ?>" value="1"/> | |
| 561 | + <input type="hidden" id="<?php echo esc_attr( $hd_id2 ); ?>" value="<?php echo esc_attr( count( $import_data ) ); ?>"/> | |
| 562 | + | |
| 563 | + <div class="mainwp_managesites_import_listing" id="<?php echo esc_attr( $list_id ); ?>"> | |
| 564 | + <span class="log ui small text"> | |
| 565 | + <?php echo esc_html( $header_line ) . '<br/>'; ?> | |
| 566 | + </span> | |
| 567 | + </div> | |
| 568 | + <div class="mainwp_managesites_import_listing" id="<?php echo esc_attr( $fail_list_id ); ?>" style="display: none;"> | |
| 569 | + <?php echo esc_html( $header_line ); ?> | |
| 570 | + </div> | |
| 571 | + <?php | |
| 572 | + } else { | |
| 573 | + $errors[] = esc_html__( 'An error occurred. Please, try again.', 'mainwp' ) . '<br />'; | |
| 574 | + } | |
| 575 | + } else { | |
| 576 | + $errors[] = esc_html__( 'Import failed. Please, try again.', 'mainwp' ) . '<br />'; | |
| 577 | + } | |
| 491 | 578 | } else { |
| 492 | - $errors[] = esc_html__( 'Upload failed. Please, try again.', 'mainwp' ) . '<br />'; | |
| 579 | + $errors[] = esc_html__( 'Import failed. Please, try again.', 'mainwp' ) . '<br />'; | |
| 493 | 580 | } |
| 494 | 581 | |
| 495 | 582 | if ( ! empty( $errors ) ) { |
| 496 | 583 | ?> |
| @@ -521,10 +608,10 @@ | ||
| 521 | 608 | if ( ! empty( $working_extensions ) && ! empty( $sync_extensions_options ) ) { |
| 522 | 609 | ?> |
| 523 | 610 | |
| 524 | 611 | <h3 class="ui dividing header"> |
| 525 | - <?php esc_html_e( 'Extensions Settings Synchronization', 'mainwp' ); ?> | |
| 526 | - <div class="sub header"><?php esc_html_e( 'Select the plugins you want to install and if you want to apply the Extensions default settings to this Child site.', 'mainwp' ); ?></div> | |
| 612 | + <?php esc_html_e( 'Add-ons Settings Synchronization', 'mainwp' ); ?> | |
| 613 | + <div class="sub header"><?php esc_html_e( 'Select the plugins you want to install and if you want to apply the Add-ons default settings to this Child site.', 'mainwp' ); ?></div> | |
| 527 | 614 | </h3> |
| 528 | 615 | |
| 529 | 616 | <?php |
| 530 | 617 | $loader = '<i class="ui active inline loader tiny" style="display: none"></i> <span class="status"></span>'; |
| @@ -543,8 +630,9 @@ | ||
| 543 | 630 | $html .= '<div class="sync-ext-row" slug="' . $dir_slug . '" ext_name = "' . esc_attr( $ext_name ) . '"status="queue">'; |
| 544 | 631 | $html .= '<h4>' . $ext_name . '</h4>'; |
| 545 | 632 | if ( isset( $sync_info['plugin_slug'] ) && ! empty( $sync_info['plugin_slug'] ) ) { |
| 546 | 633 | $html .= '<div class="sync-install-plugin" slug="' . esc_attr( dirname( $sync_info['plugin_slug'] ) ) . '" plugin_name="' . esc_attr( $sync_info['plugin_name'] ) . '">'; |
| 634 | + /* translators: 1: Plugin name. */ | |
| 547 | 635 | $html .= '<div class="ui checkbox"><input type="checkbox" class="chk-sync-install-plugin" /> <label>' . esc_html( sprintf( esc_html__( 'Install %1$s plugin', 'mainwp' ), esc_html( $sync_info['plugin_name'] ) ) ) . '</label></div> '; |
| 548 | 636 | $html .= $loader; |
| 549 | 637 | $html .= '</div>'; |
| 550 | 638 | if ( ! isset( $sync_info['no_setting'] ) || empty( $sync_info['no_setting'] ) ) { |
| @@ -549,8 +637,9 @@ | ||
| 549 | 637 | $html .= '</div>'; |
| 550 | 638 | if ( ! isset( $sync_info['no_setting'] ) || empty( $sync_info['no_setting'] ) ) { |
| 551 | 639 | $html .= '<div class="sync-options options-row">'; |
| 552 | 640 | $html .= '<div class="ui checkbox"><input type="checkbox" /><label> '; |
| 641 | + /* translators: 1: Plugin name, 2: Opening anchor tag, 3: Closing anchor tag. */ | |
| 553 | 642 | $html .= sprintf( esc_html__( 'Apply %1$s %2$ssettings%3$s', 'mainwp' ), esc_html( $sync_info['plugin_name'] ), '<a href="admin.php?page=' . $data['page'] . '">', '</a>' ); |
| 554 | 643 | $html .= '</label>'; |
| 555 | 644 | $html .= '</div> '; |
| 556 | 645 | $html .= $loader; |
| @@ -566,9 +655,10 @@ | ||
| 566 | 655 | $html .= '</div>'; |
| 567 | 656 | } |
| 568 | 657 | } else { |
| 569 | 658 | $html .= '<div class="sync-global-options options-row">'; |
| 570 | - $html .= '<div class="ui checkbox"><input type="checkbox" /> <label>' . esc_html( sprintf( esc_html__( 'Apply global %1$s options' ), trim( $ext_name ) ) ) . '</label></div> '; | |
| 659 | + /* translators: 1: Extension name. */ | |
| 660 | + $html .= '<div class="ui checkbox"><input type="checkbox" /> <label>' . esc_html( sprintf( esc_html__( 'Apply global %1$s options', 'mainwp' ), trim( $ext_name ) ) ) . '</label></div> '; | |
| 571 | 661 | $html .= '<i class="ui active inline loader tiny" style="display: none"></i> <span class="status"></span>'; |
| 572 | 662 | $html .= '</div>'; |
| 573 | 663 | } |
| 574 | 664 | $html .= '</div>'; |
| @@ -581,19 +671,19 @@ | ||
| 581 | 671 | |
| 582 | 672 | /** |
| 583 | 673 | * Method render_dashboard() |
| 584 | 674 | * |
| 585 | - * Render individual Child Site Overview page. | |
| 675 | + * Render individual Child Site Operations page. | |
| 586 | 676 | * |
| 587 | 677 | * @param mixed $website Child Site. |
| 588 | 678 | * |
| 589 | - * @return string Sites Overview Page. | |
| 679 | + * @return string Sites Operations Page. | |
| 590 | 680 | * |
| 591 | 681 | * @uses \MainWP\Dashboard\MainWP_Overview::render_dashboard_body() |
| 592 | 682 | */ |
| 593 | 683 | public static function render_dashboard( &$website ) { |
| 594 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'access_individual_dashboard' ) ) { | |
| 595 | - mainwp_do_not_have_permissions( esc_html__( 'individual dashboard', 'mainwp' ) ); | |
| 684 | + if ( ! \mainwp_current_user_can( 'dashboard', 'access_individual_dashboard' ) ) { | |
| 685 | + \mainwp_do_not_have_permissions( esc_html__( 'individual dashboard', 'mainwp' ) ); | |
| 596 | 686 | return; |
| 597 | 687 | } |
| 598 | 688 | ?> |
| 599 | 689 | <div> |
| @@ -625,23 +715,26 @@ | ||
| 625 | 715 | * @param mixed $show_language_updates Whether or not to show translations. |
| 626 | 716 | */ |
| 627 | 717 | public static function render_header_tabs( $active_tab, $active_text, $show_language_updates ) { |
| 628 | 718 | ?> |
| 629 | - <div class="mainwp-sub-header"> | |
| 630 | - <div class="ui grid mini form"> | |
| 719 | + <div class="mainwp-actions-bar"> | |
| 720 | + <div class="ui grid"> | |
| 631 | 721 | <div class="equal width row"> |
| 632 | - <div class="right aligned middle aligned column"> | |
| 722 | + <div class="middle aligned column"> | |
| 633 | 723 | <div class="inline field"> |
| 634 | - <div class="ui selection fluid dropdown"> | |
| 724 | + <div class="ui selection mini dropdown select-individual-updates"> | |
| 635 | 725 | <div class="text"><?php echo esc_html( $active_text ); ?></div> |
| 636 | 726 | <i class="dropdown icon"></i> |
| 637 | 727 | <div class="menu"> |
| 638 | - <div class="<?php echo 'WordPress' === $active_tab ? 'active' : ''; ?> item" data-tab="wordpress" data-value="wordpress"><?php esc_html_e( 'WordPress Updates', 'mainwp' ); ?></div> | |
| 639 | - <div class="<?php echo 'plugins' === $active_tab ? 'active' : ''; ?> item" data-tab="plugins" data-value="plugins"><?php esc_html_e( 'Plugins Updates', 'mainwp' ); ?></div> | |
| 640 | - <div class="<?php echo 'themes' === $active_tab ? 'active' : ''; ?> item" data-tab="themes" data-value="themes"><?php esc_html_e( 'Themes Updates', 'mainwp' ); ?></div> | |
| 728 | + <div class="<?php echo 'wordpress' === $active_tab ? 'active' : ''; ?> item" data-tab="wordpress" data-value="wordpress"><?php esc_html_e( 'WordPress Updates', 'mainwp' ); ?></div> | |
| 729 | + <div class="<?php echo 'plugins' === $active_tab ? 'active' : ''; ?> item" data-tab="plugins" data-value="plugins"><?php esc_html_e( 'Plugin Updates', 'mainwp' ); ?></div> | |
| 730 | + <div class="<?php echo 'themes' === $active_tab ? 'active' : ''; ?> item" data-tab="themes" data-value="themes"><?php esc_html_e( 'Theme Updates', 'mainwp' ); ?></div> | |
| 641 | 731 | <?php if ( $show_language_updates ) { ?> |
| 642 | - <div class="<?php echo 'trans' === $active_tab ? 'active' : ''; ?> item" data-tab="translations" data-value="translations"><?php esc_html_e( 'Translations Updates', 'mainwp' ); ?></div> | |
| 732 | + <div class="<?php echo 'trans' === $active_tab ? 'active' : ''; ?> item" data-tab="translations" data-value="translations"><?php esc_html_e( 'Translation Updates', 'mainwp' ); ?></div> | |
| 643 | 733 | <?php } ?> |
| 734 | + <?php if ( is_plugin_active( 'mainwp-database-updater-extension/mainwp-database-updater-extension.php' ) ) { ?> | |
| 735 | + <div class="item" data-tab="dbupdates" data-value="dbupdates"><?php esc_html_e( 'Database Updates', 'mainwp' ); ?></div> | |
| 736 | + <?php } ?> | |
| 644 | 737 | <div class="<?php echo 'abandoned-plugins' === $active_tab ? 'active' : ''; ?> item" data-tab="abandoned-plugins" data-value="abandoned-plugins"><?php esc_html_e( 'Abandoned Plugins', 'mainwp' ); ?></div> |
| 645 | 738 | <div class="<?php echo 'abandoned-themes' === $active_tab ? 'active' : ''; ?> item" data-tab="abandoned-themes" data-value="abandoned-themes"><?php esc_html_e( 'Abandoned Themes', 'mainwp' ); ?></div> |
| 646 | 739 | </div> |
| 647 | 740 | </div> |
| @@ -647,12 +740,23 @@ | ||
| 647 | 740 | </div> |
| 648 | 741 | </div> |
| 649 | 742 | </div> |
| 650 | 743 | <div class="middle aligned column"> |
| 651 | - <?php echo apply_filters( 'mainwp_widgetupdates_actions_top', '' ); // phpcs:ignore WordPress.Security.EscapeOutput ?> | |
| 744 | + <?php | |
| 745 | + /** | |
| 746 | + * Action: mainwp_widget_updates_actions_top | |
| 747 | + * | |
| 748 | + * Updates actions top content. | |
| 749 | + * | |
| 750 | + * @since 5.5 | |
| 751 | + */ | |
| 752 | + do_action( 'mainwp_widget_updates_actions_top', $active_tab ); | |
| 753 | + ?> | |
| 652 | 754 | </div> |
| 653 | - <div class="middle aligned column"></div> | |
| 654 | - <div class="middle aligned column"></div> | |
| 755 | + <div class="middle aligned right aligned column select-buttons-individual-updates"> | |
| 756 | + <?php echo '<a href="javascript:void(0)" data-tooltip="' . esc_html__( 'Update Selected Plugins.', 'mainwp' ) . '" onClick="updatesoverview_plugins_global_upgrade_all( false, true ); return false;" class="ui mini green basic button plugins ' . ( 'plugins' === $active_tab ? '' : 'hidden' ) . '" data-inverted="" data-position="top right">' . esc_html__( 'Update Selected', 'mainwp' ) . '</a>'; ?> | |
| 757 | + <?php echo '<a href="javascript:void(0)" onClick="updatesoverview_themes_global_upgrade_all( false, true );return false;" class="ui mini green basic button themes ' . ( 'themes' === $active_tab ? '' : 'hidden' ) . '" data-tooltip="' . esc_html__( 'Update Selected Themes.', 'mainwp' ) . '" data-inverted="" data-position="top right">' . esc_html__( 'Update Selected', 'mainwp' ) . '</a>'; ?> | |
| 758 | + </div> | |
| 655 | 759 | </div> |
| 656 | 760 | </div> |
| 657 | 761 | </div> |
| 658 | 762 | <?php |
| @@ -667,18 +771,25 @@ | ||
| 667 | 771 | * |
| 668 | 772 | * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 669 | 773 | */ |
| 670 | 774 | public static function render_scan_site( &$website ) { |
| 671 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_security_issues' ) ) { | |
| 672 | - mainwp_do_not_have_permissions( esc_html__( 'security scan', 'mainwp' ) ); | |
| 775 | + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_security_issues' ) ) { | |
| 776 | + \mainwp_do_not_have_permissions( esc_html__( 'security scan', 'mainwp' ) ); | |
| 673 | 777 | return; |
| 674 | 778 | } |
| 675 | 779 | ?> |
| 676 | - <div class="ui segment"> | |
| 780 | + <div class="mainwp-actions-bar"> | |
| 781 | + <div class="ui one column grid"> | |
| 782 | + <div class="column"> | |
| 783 | + <input type="button" id="securityIssues_refresh" class="ui mini green button" value="<?php esc_html_e( 'Scan Site', 'mainwp' ); ?>"/> | |
| 784 | + </div> | |
| 785 | + </div> | |
| 786 | + </div> | |
| 787 | + <div class="ui padded segment"> | |
| 677 | 788 | <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-manage-security-info-message' ) ) { ?> |
| 678 | 789 | <div class="ui info message"> |
| 679 | 790 | <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-manage-security-info-message"></i> |
| 680 | - <?php printf( esc_html__( 'Fix detected hardening issues on the childs site. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/security-issues/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?> | |
| 791 | + <?php esc_html_e( 'Ensure your sites are secure and up to date with automated security and update checks.', 'mainwp' ); // NOSONAR - noopener - open safe. ?> | |
| 681 | 792 | </div> |
| 682 | 793 | <?php } ?> |
| 683 | 794 | <?php |
| 684 | 795 | // Render security check issues. |
| @@ -689,9 +800,9 @@ | ||
| 689 | 800 | $website = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 690 | 801 | if ( empty( $website ) ) { |
| 691 | 802 | return; |
| 692 | 803 | } |
| 693 | - if ( mainwp_current_user_have_right( 'dashboard', 'manage_security_issues' ) ) { | |
| 804 | + if ( \mainwp_current_user_can( 'dashboard', 'manage_security_issues' ) ) { | |
| 694 | 805 | do_action_deprecated( 'mainwp-securityissues-sites', array( $website ), '4.0.7.2', 'mainwp_securityissues_sites' ); // @deprecated Use 'mainwp_securityissues_sites' instead. NOSONAR - not IP. |
| 695 | 806 | |
| 696 | 807 | /** |
| 697 | 808 | * Action: mainwp_securityissues_sites |
| @@ -709,9 +820,9 @@ | ||
| 709 | 820 | ?> |
| 710 | 821 | |
| 711 | 822 | <?php |
| 712 | 823 | // Hook in MainWP Sucuri Extension. |
| 713 | - if ( mainwp_current_user_have_right( 'extension', 'mainwp-sucuri-extension' ) && is_plugin_active( 'mainwp-sucuri-extension/mainwp-sucuri-extension.php' ) ) { | |
| 824 | + if ( \mainwp_current_user_can( 'extension', 'mainwp-sucuri-extension' ) && is_plugin_active( 'mainwp-sucuri-extension/mainwp-sucuri-extension.php' ) ) { | |
| 714 | 825 | do_action_deprecated( 'mainwp-sucuriscan-sites', array( $website ), '4.0.7.2', 'mainwp_sucuriscan_sites' ); // @deprecated Use 'mainwp_sucuriscan_sites' instead. NOSONAR - not IP. |
| 715 | 826 | |
| 716 | 827 | /** |
| 717 | 828 | * Action: mainwp_sucuriscan_sites |
| @@ -729,9 +840,9 @@ | ||
| 729 | 840 | ?> |
| 730 | 841 | |
| 731 | 842 | <?php |
| 732 | 843 | // Hook in MainWP Wordfence Extension. |
| 733 | - if ( mainwp_current_user_have_right( 'extension', 'mainwp-wordfence-extension' ) && is_plugin_active( 'mainwp-wordfence-extension/mainwp-wordfence-extension.php' ) ) { | |
| 844 | + if ( \mainwp_current_user_can( 'extension', 'mainwp-wordfence-extension' ) && is_plugin_active( 'mainwp-wordfence-extension/mainwp-wordfence-extension.php' ) ) { | |
| 734 | 845 | do_action_deprecated( 'mainwp-wordfence-sites', array( $website ), '4.0.7.2', 'mainwp_wordfence_sites' ); // @deprecated Use 'mainwp_wordfence_sites' instead. NOSONAR - not IP. |
| 735 | 846 | |
| 736 | 847 | /** |
| 737 | 848 | * Action: mainwp_wordfence_sites |
| @@ -769,14 +880,14 @@ | ||
| 769 | 880 | * @uses \MainWP\Dashboard\MainWP_Utility::starts_with() |
| 770 | 881 | * @uses \MainWP\Dashboard\MainWP_Utility::remove_http_prefix() |
| 771 | 882 | */ |
| 772 | 883 | public static function render_edit_site( $websiteid, $updated ) { // phpcs:ignore -- NOSONAR - complex. |
| 773 | - if ( ! mainwp_current_user_have_right( 'dashboard', 'edit_sites' ) ) { | |
| 774 | - mainwp_do_not_have_permissions( esc_html__( 'edit sites', 'mainwp' ) ); | |
| 884 | + if ( ! \mainwp_current_user_can( 'dashboard', 'edit_sites' ) ) { | |
| 885 | + \mainwp_do_not_have_permissions( esc_html__( 'edit sites', 'mainwp' ) ); | |
| 775 | 886 | return; |
| 776 | 887 | } |
| 777 | 888 | |
| 778 | - $website = MainWP_DB::instance()->get_website_by_id( $websiteid, false, array( 'monitoring_notification_emails', 'settings_notification_emails' ) ); | |
| 889 | + $website = MainWP_DB::instance()->get_website_by_id( $websiteid, false, array( 'monitoring_notification_emails', 'settings_notification_emails', 'ignored_trans_updates' ) ); | |
| 779 | 890 | if ( ! MainWP_System_Utility::can_edit_website( $website ) ) { |
| 780 | 891 | $website = null; |
| 781 | 892 | } |
| 782 | 893 | |
| @@ -794,13 +905,13 @@ | ||
| 794 | 905 | |
| 795 | 906 | $text_use_global = esc_html__( 'Use global setting', 'mainwp' ); |
| 796 | 907 | $style_checked = 'checked="true"'; |
| 797 | 908 | ?> |
| 798 | - <div class="ui segment mainwp-edit-site-<?php echo intval( $website->id ); ?>" id="mainwp-edit-site"> | |
| 909 | + <div class="ui padded segment mainwp-edit-site-<?php echo intval( $website->id ); ?>" id="mainwp-edit-site"> | |
| 799 | 910 | <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-edit-site-info-message' ) ) { ?> |
| 800 | 911 | <div class="ui info message"> |
| 801 | 912 | <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-edit-site-info-message"></i> |
| 802 | - <?php printf( esc_html__( 'Edit the %1$s (%2$s) child site settings. For additional help, please check this %3$shelp documentation%4$s.', 'mainwp' ), esc_html( stripslashes( $website->name ) ), '<a href="' . esc_url( $website->url ) . '" target="_blank">' . esc_url( $website->url ) . '</a>', '<a href="https://kb.mainwp.com/docs/edit-a-child-site/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // phpcs:ignore WordPress.Security.EscapeOutput -- NOSONAR - noopener - open safe. ?> | |
| 913 | + <?php /* translators: 1: Site name, 2: Site URL with anchor tag, 3: Opening anchor tag for documentation link, 4: Closing anchor tag. */ printf( esc_html__( 'Edit the %1$s (%2$s) child site settings. For additional help, please check this %3$shelp documentation%4$s.', 'mainwp' ), esc_html( stripslashes( $website->name ) ), '<a href="' . esc_url( $website->url ) . '" target="_blank">' . esc_url( $website->url ) . '</a>', '<a href="https://docs.mainwp.com/sites/management/manage-child-sites#edit-child-site-settings" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // phpcs:ignore WordPress.Security.EscapeOutput -- NOSONAR - noopener - open safe. ?> | |
| 803 | 914 | </div> |
| 804 | 915 | <?php } ?> |
| 805 | 916 | <?php |
| 806 | 917 | MainWP_Client_Handler::show_notice_existed_contact_emails(); |
| @@ -809,27 +920,33 @@ | ||
| 809 | 920 | <?php if ( $updated ) { ?> |
| 810 | 921 | <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Child site settings saved successfully.', 'mainwp' ); ?></div> |
| 811 | 922 | <?php } ?> |
| 812 | 923 | <form method="POST" action="" id="mainwp-edit-single-site-form" enctype="multipart/form-data" class="ui form"> |
| 813 | - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> | |
| 924 | + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?> | |
| 814 | 925 | <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdateWebsite' . $website->id ) ); ?>" /> |
| 815 | - <h3 class="ui dividing header"> | |
| 816 | - <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-general' ); ?> | |
| 817 | - <?php esc_html_e( 'General Settings', 'mainwp' ); ?> | |
| 818 | - </h3> | |
| 926 | + | |
| 927 | + <div class="ui basic accordion mainwp-blank-accordion mainwp-sidebar-accordion" id="mainwp-edit-site-general-settings-accordion"> | |
| 928 | + <h2 class="ui dividing header active title"> | |
| 929 | + <i class="right dropdown icon"></i> | |
| 930 | + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-general' ); ?> | |
| 931 | + <?php esc_html_e( 'General Settings', 'mainwp' ); ?> | |
| 932 | + <div class="sub header"><?php esc_html_e( 'Basic site details, organization, and update behavior.', 'mainwp' ); ?></div> | |
| 933 | + </h2> | |
| 934 | + <div class="content active"> | |
| 935 | + <h4 class="ui dividing tiny header"><?php esc_html_e( 'Site Identity', 'mainwp' ); ?></h4> | |
| 819 | 936 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general" default-indi-value=""> |
| 820 | 937 | <label class="six wide column middle aligned"> |
| 821 | 938 | <?php |
| 822 | 939 | MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $website->url ); |
| 823 | 940 | ?> |
| 824 | - <?php esc_html_e( 'Site URL', 'mainwp' ); ?></label> | |
| 825 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter your website URL.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 941 | + <?php esc_html_e( 'Site URL', 'mainwp' ); ?> <span class="ui small red text">(<?php esc_html_e( 'Required', 'mainwp' ); ?>)</span></label> | |
| 942 | + <div class="ui six wide column"> | |
| 826 | 943 | <div class="ui left action input"> |
| 827 | 944 | <select class="ui compact selection dropdown" id="mainwp_managesites_edit_siteurl_protocol" name="mainwp_managesites_edit_siteurl_protocol"> |
| 828 | 945 | <option <?php echo MainWP_Utility::starts_with( $website->url, 'http:' ) ? 'selected' : ''; ?> value="http">http://</option> |
| 829 | 946 | <option <?php echo MainWP_Utility::starts_with( $website->url, 'https:' ) ? 'selected' : ''; ?> value="https">https://</option> |
| 830 | 947 | </select> |
| 831 | - <div class="ui compact selection dropdown"> | |
| 948 | + <div class="ui compact selection dropdown" id="mainwp-edit-site-edit-url-www"> | |
| 832 | 949 | <input type="hidden" name="mainwp_managesites_edit_wpurl_with_www" value="<?php echo false !== stripos( $website->url, '/www.' ) ? 'www' : 'none-www'; ?>"> |
| 833 | 950 | <i class="dropdown icon"></i> |
| 834 | 951 | <div class="default text"><?php esc_html_e( 'www', 'mainwp' ); ?></div> |
| 835 | 952 | <div class="menu"> |
| @@ -844,20 +961,35 @@ | ||
| 844 | 961 | <input type="button" name="mainwp_managesites_edit_test" id="mainwp_managesites_edit_test" class="ui button basic green" value="<?php esc_attr_e( 'Test Connection', 'mainwp' ); ?>"/> |
| 845 | 962 | </div> |
| 846 | 963 | </div> |
| 847 | 964 | <?php |
| 848 | - $adminname = $website->adminname; | |
| 849 | - ?> | |
| 965 | + $reported_siteurl = isset( $website->siteurl ) ? $website->siteurl : ''; | |
| 966 | + $url_mismatch_cat = MainWP_Site_Url_Corrector::classify( $website->url, $reported_siteurl ); | |
| 967 | + $url_correct_lock = MainWP_Site_Url_Corrector::is_locked( $website ); | |
| 968 | + if ( MainWP_Site_Url_Corrector::is_scheme_www_category( $url_mismatch_cat ) ) : | |
| 969 | + $detected_scheme = wp_parse_url( $reported_siteurl, PHP_URL_SCHEME ); | |
| 970 | + $detected_host = wp_parse_url( $reported_siteurl, PHP_URL_HOST ); | |
| 971 | + $detected_www = is_string( $detected_host ) && 0 === stripos( $detected_host, 'www.' ) ? 'www' : 'none-www'; | |
| 972 | + ?> | |
| 850 | 973 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| 974 | + <label class="six wide column middle aligned"></label> | |
| 975 | + <div class="ui six wide column middle aligned"> | |
| 976 | + <i class="yellow exclamation triangle icon"></i> <?php esc_html_e( 'The child site reports its address as:', 'mainwp' ); ?> <strong><?php echo esc_url( $reported_siteurl ); ?></strong> | |
| 977 | + </div> | |
| 978 | + <div class="ui four wide middle aligned column"> | |
| 979 | + <input type="button" id="mainwp_managesites_edit_use_detected" class="ui button basic" data-scheme="<?php echo esc_attr( $detected_scheme ); ?>" data-www="<?php echo esc_attr( $detected_www ); ?>" value="<?php esc_attr_e( 'Use detected', 'mainwp' ); ?>" data-tooltip="<?php esc_attr_e( 'Sets the protocol and www selectors above to match the address the child site reports. Review and click Save Settings to apply.', 'mainwp' ); ?>" data-inverted="" data-position="top right"/> | |
| 980 | + </div> | |
| 981 | + </div> | |
| 982 | + <?php endif; ?> | |
| 983 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general" default-indi-value="0"> | |
| 851 | 984 | <label class="six wide column middle aligned"> |
| 852 | 985 | <?php |
| 853 | - MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $adminname ); | |
| 986 | + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $url_correct_lock ? 1 : '' ); | |
| 987 | + esc_html_e( 'Lock site URL', 'mainwp' ); | |
| 854 | 988 | ?> |
| 855 | - <?php esc_html_e( 'Administrator username', 'mainwp' ); ?></label> | |
| 856 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the website Administrator username.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 857 | - <div class="ui left labeled input"> | |
| 858 | - <input type="text" id="mainwp_managesites_edit_siteadmin" class="settings-field-value-change-handler" name="mainwp_managesites_edit_siteadmin" value="<?php echo esc_attr( $adminname ); ?>" /> | |
| 859 | - </div> | |
| 989 | + </label> | |
| 990 | + <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, MainWP will never automatically correct or reroute this site URL. This lock is set automatically when you save a URL that differs from the address the child site reports.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 991 | + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_managesites_edit_url_lock" id="mainwp_managesites_edit_url_lock" <?php echo $url_correct_lock ? 'checked="true"' : ''; ?> /><label><?php esc_html_e( 'Default: Disabled', 'mainwp' ); ?></label> | |
| 860 | 992 | </div> |
| 861 | 993 | </div> |
| 862 | 994 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| 863 | 995 | <label class="six wide column middle aligned"> |
| @@ -864,23 +996,37 @@ | ||
| 864 | 996 | <?php |
| 865 | 997 | MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $website->name ); |
| 866 | 998 | ?> |
| 867 | 999 | <?php esc_html_e( 'Site title', 'mainwp' ); ?></label> |
| 868 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the website title.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1000 | + <div class="ui six wide column"> | |
| 869 | 1001 | <div class="ui left labeled input"> |
| 870 | 1002 | <input type="text" class="settings-field-value-change-handler" id="mainwp_managesites_edit_sitename" name="mainwp_managesites_edit_sitename" value="<?php echo esc_attr( stripslashes( $website->name ) ); ?>" /> |
| 871 | 1003 | </div> |
| 872 | 1004 | </div> |
| 873 | 1005 | </div> |
| 874 | - | |
| 1006 | + <?php | |
| 1007 | + $adminname = $website->adminname; | |
| 1008 | + ?> | |
| 875 | 1009 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| 876 | 1010 | <label class="six wide column middle aligned"> |
| 877 | 1011 | <?php |
| 1012 | + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $adminname ); | |
| 1013 | + ?> | |
| 1014 | + <?php esc_html_e( 'Administrator username', 'mainwp' ); ?> <span class="ui small red text">(<?php esc_html_e( 'Required', 'mainwp' ); ?>)</span></label> | |
| 1015 | + <div class="ui six wide column"> | |
| 1016 | + <div class="ui left labeled input"> | |
| 1017 | + <input type="text" id="mainwp_managesites_edit_siteadmin" class="settings-field-value-change-handler" name="mainwp_managesites_edit_siteadmin" value="<?php echo esc_attr( $adminname ); ?>" /> | |
| 1018 | + </div> | |
| 1019 | + </div> | |
| 1020 | + </div> | |
| 1021 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> | |
| 1022 | + <label class="six wide column middle aligned"> | |
| 1023 | + <?php | |
| 878 | 1024 | MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $website->uniqueId ); |
| 879 | 1025 | ?> |
| 880 | 1026 | |
| 881 | 1027 | <?php esc_html_e( 'Unique security ID', 'mainwp' ); ?></label> |
| 882 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'If in use, enter the website Unique ID.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1028 | + <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'If in use, enter the website Unique ID.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 883 | 1029 | <div class="ui left labeled input"> |
| 884 | 1030 | <input type="text" id="mainwp_managesites_edit_uniqueId" class="settings-field-value-change-handler" name="mainwp_managesites_edit_uniqueId" value="<?php echo esc_attr( $website->uniqueId ); ?>" /> |
| 885 | 1031 | </div> |
| 886 | 1032 | </div> |
| @@ -885,8 +1031,10 @@ | ||
| 885 | 1031 | </div> |
| 886 | 1032 | </div> |
| 887 | 1033 | </div> |
| 888 | 1034 | |
| 1035 | + <h4 class="ui dividing tiny header"><?php esc_html_e( 'Organization', 'mainwp' ); ?></h4> | |
| 1036 | + | |
| 889 | 1037 | <?php |
| 890 | 1038 | $uploaded_site_icon = MainWP_Manage_Sites::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'uploaded' ); |
| 891 | 1039 | $selected_site_icon = MainWP_Manage_Sites::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'selected' ); |
| 892 | 1040 | $selected_site_color = MainWP_Manage_Sites::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'color' ); |
| @@ -909,8 +1057,9 @@ | ||
| 909 | 1057 | $uploaded_icon_src = $icon_base . $cust_prod_icon_file; |
| 910 | 1058 | } |
| 911 | 1059 | |
| 912 | 1060 | $default_icons = MainWP_UI::get_default_icons(); |
| 1061 | + $delnonce = MainWP_System_Utility::get_custom_nonce( 'site', esc_attr( $uploaded_site_icon ) ); | |
| 913 | 1062 | |
| 914 | 1063 | ?> |
| 915 | 1064 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cost-add-edit"> |
| 916 | 1065 | <label class="six wide column middle aligned"> |
| @@ -920,15 +1069,23 @@ | ||
| 920 | 1069 | esc_html_e( 'Upload site icon', 'mainwp' ); |
| 921 | 1070 | ?> |
| 922 | 1071 | </label> |
| 923 | 1072 | <input type="hidden" name="mainwp_managesites_edit_site_uploaded_icon_hidden" class="settings-field-value-change-handler" id="mainwp_managesites_edit_site_uploaded_icon_hidden" value="<?php echo esc_attr( $uploaded_site_icon ); ?>"> |
| 924 | - <div class="three wide middle aligned column" data-tooltip="<?php esc_attr_e( 'Upload the product icon.', 'mainwp' ); ?>" data-inverted="" data-position="left center"> | |
| 925 | - <div class="ui green button basic mainwp-managesites-edit-site-icon-customable" iconItemId="<?php echo intval( $website->id ); ?>" iconFileSlug="<?php echo esc_attr( $uploaded_site_icon ); ?>" icon-src="<?php echo esc_attr( $uploaded_icon_src ); ?>"><?php esc_html_e( 'Upload Icon', 'mainwp' ); ?></div> | |
| 926 | - <?php if ( ! empty( $uploaded_site_icon ) ) { ?> | |
| 927 | - <?php echo MainWP_Manage_Sites::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'display_edit' ); //phpcs:ignore --ok. ?> | |
| 928 | - <?php } else { ?> | |
| 929 | - <div style="display:inline-block;" id="mainw_managesites_add_edit_site_upload_custom_icon"></div> <?php // used for icon holder. ?> | |
| 930 | - <?php } ?> | |
| 1073 | + <div class="three wide middle aligned column" > | |
| 1074 | + <span class="ui circular bordered image"> | |
| 1075 | + <?php if ( ! empty( $uploaded_site_icon ) ) { ?> | |
| 1076 | + <?php echo MainWP_Manage_Sites::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'display_edit' ); //phpcs:ignore --ok. ?> | |
| 1077 | + <?php } else { ?> | |
| 1078 | + <div style="display:inline-block;" id="mainw_managesites_add_edit_site_upload_custom_icon"></div> <?php // used for icon holder. ?> | |
| 1079 | + <?php } ?> | |
| 1080 | + </span> | |
| 1081 | + <div class="ui basic button mainwp-managesites-edit-site-icon-customable" | |
| 1082 | + iconItemId="<?php echo intval( $website->id ); ?>" | |
| 1083 | + iconFileSlug="<?php echo esc_attr( $uploaded_site_icon ); ?>" | |
| 1084 | + del-icon-nonce="<?php echo esc_attr( $delnonce ); ?>" | |
| 1085 | + icon-src="<?php echo esc_attr( $uploaded_icon_src ); ?>"> | |
| 1086 | + <i class="image icon"></i> <?php echo ! empty( $uploaded_site_icon ) ? esc_html__( 'Change Image', 'mainwp' ) : esc_html__( 'Upload Image', 'mainwp' ); ?> | |
| 1087 | + </div> | |
| 931 | 1088 | </div> |
| 932 | 1089 | </div> |
| 933 | 1090 | |
| 934 | 1091 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general" default-indi-value="wordpress"> |
| @@ -939,9 +1096,9 @@ | ||
| 939 | 1096 | esc_html_e( 'Select icon', 'mainwp' ); |
| 940 | 1097 | ?> |
| 941 | 1098 | </label> |
| 942 | 1099 | <input type="hidden" name="mainwp_managesites_edit_site_selected_icon_hidden" class="settings-field-value-change-handler" id="mainwp_managesites_edit_site_selected_icon_hidden" value="<?php echo esc_attr( $selected_site_icon ); ?>"> |
| 943 | - <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Select an icon if not using original site icon.', 'mainwp' ); ?>" data-inverted="" data-position="left center"> | |
| 1100 | + <div class="six wide column" data-tooltip="<?php esc_attr_e( 'Select an icon if not using original site icon.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 944 | 1101 | <div class="ui left action input mainwp-dropdown-color-picker-field"> |
| 945 | 1102 | <div class="ui five column selection search dropdown not-auto-init" id="mainwp_manage_add_edit_site_icon_select"> |
| 946 | 1103 | <div class="text"> |
| 947 | 1104 | <span style="color:<?php echo esc_attr( $selected_site_color ); ?>" ><?php echo ! empty( $selected_site_icon ) ? '<i class="' . esc_attr( $selected_site_icon ) . ' icon"></i>' : ''; ?></span> |
| @@ -974,9 +1131,9 @@ | ||
| 974 | 1131 | <?php |
| 975 | 1132 | MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', $init_groups ); |
| 976 | 1133 | ?> |
| 977 | 1134 | <?php esc_html_e( 'Tags', 'mainwp' ); ?></label> |
| 978 | - <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Add the website to existing tags(s).', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1135 | + <div class="ten wide column"> | |
| 979 | 1136 | <div class="ui multiple selection dropdown" init-value="<?php echo esc_attr( $init_groups ); ?>"> |
| 980 | 1137 | <input name="mainwp_managesites_edit_addgroups" value="" class="settings-field-value-change-handler" type="hidden"> |
| 981 | 1138 | <i class="dropdown icon"></i> |
| 982 | 1139 | <div class="default text"><?php echo '' === $init_groups ? esc_html__( 'No Tags added yet.', 'mainwp' ) : ''; ?></div> |
| @@ -988,10 +1145,11 @@ | ||
| 988 | 1145 | </div> |
| 989 | 1146 | </div> |
| 990 | 1147 | </div> |
| 991 | 1148 | <?php |
| 992 | - $clients = MainWP_DB_Client::instance()->get_wp_client_by( 'all' ); | |
| 993 | - ?> | |
| 1149 | + if ( \mainwp_current_user_can( 'dashboard', 'manage_clients' ) ) { | |
| 1150 | + $clients = MainWP_DB_Client::instance()->get_wp_client_by( 'all' ); | |
| 1151 | + ?> | |
| 994 | 1152 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| 995 | 1153 | <label class="six wide column middle aligned"> |
| 996 | 1154 | <?php |
| 997 | 1155 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_client_id', (int) $website->client_id ); |
| @@ -997,9 +1155,9 @@ | ||
| 997 | 1155 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_client_id', (int) $website->client_id ); |
| 998 | 1156 | esc_html_e( 'Client', 'mainwp' ); |
| 999 | 1157 | ?> |
| 1000 | 1158 | </label> |
| 1001 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Select Client.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1159 | + <div class="ui six wide column"> | |
| 1002 | 1160 | <div class="ui search selection dropdown"> |
| 1003 | 1161 | <input type="hidden" name="mainwp_managesites_edit_client_id" class="settings-field-value-change-handler" value="<?php echo intval( $website->client_id ); ?>"> |
| 1004 | 1162 | <i class="dropdown icon"></i> |
| 1005 | 1163 | <div class="default text"><?php esc_html_e( 'Select Client', 'mainwp' ); ?></div> |
| @@ -1015,11 +1173,14 @@ | ||
| 1015 | 1173 | } |
| 1016 | 1174 | ?> |
| 1017 | 1175 | </div> |
| 1018 | 1176 | </div> |
| 1019 | - <a href="javascript:void(0)" class="ui basic green button edit-site-new-client-button"><?php esc_html_e( 'Create New Client', 'mainwp' ); ?></a> | |
| 1177 | + <a href="javascript:void(0)" class="ui basic grey button edit-site-new-client-button"><?php esc_html_e( 'Create New Client', 'mainwp' ); ?></a> | |
| 1020 | 1178 | </div> |
| 1021 | 1179 | </div> |
| 1180 | + <?php } ?> | |
| 1181 | + | |
| 1182 | + <h4 class="ui dividing tiny header"><?php esc_html_e( 'Update and Maintenance', 'mainwp' ); ?></h4> | |
| 1022 | 1183 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general" default-indi-value="2"> |
| 1023 | 1184 | <label class="six wide column middle aligned"> |
| 1024 | 1185 | <?php |
| 1025 | 1186 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_backup_before_upgrade', (int) $website->backup_before_upgrade ); |
| @@ -1036,28 +1197,17 @@ | ||
| 1036 | 1197 | </div> |
| 1037 | 1198 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| 1038 | 1199 | <label class="six wide column middle aligned"> |
| 1039 | 1200 | <?php |
| 1040 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_suspended_site', (int) $website->suspended ); | |
| 1041 | - esc_html_e( 'Suspend Site', 'mainwp' ); | |
| 1042 | - ?> | |
| 1043 | - </label> | |
| 1044 | - <div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want Suspend this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1045 | - <input type="checkbox" name="mainwp_suspended_site" class="settings-field-value-change-handler" id="mainwp_suspended_site" <?php echo 1 === (int) $website->suspended ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_suspended_site"></label> | |
| 1046 | - </div> | |
| 1047 | - </div> | |
| 1048 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> | |
| 1049 | - <label class="six wide column middle aligned"> | |
| 1050 | - <?php | |
| 1051 | 1201 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_automatic_update', (int) $website->automatic_update ); |
| 1052 | - esc_html_e( 'Install trusted updates', 'mainwp' ); | |
| 1202 | + esc_html_e( 'Auto update WP Core', 'mainwp' ); | |
| 1053 | 1203 | ?> |
| 1054 | 1204 | </label> |
| 1055 | - <div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want MainWP to automatically update WP Core on this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1205 | + <div class="one wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want MainWP to automatically update WP Core on this website.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1056 | 1206 | <input type="checkbox" name="mainwp_automaticDailyUpdate" class="settings-field-value-change-handler" id="mainwp_automaticDailyUpdate" <?php echo 1 === (int) $website->automatic_update ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_automaticDailyUpdate"></label> |
| 1057 | 1207 | </div> |
| 1058 | 1208 | </div> |
| 1059 | - <?php if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { ?> | |
| 1209 | + <?php if ( \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) { ?> | |
| 1060 | 1210 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| 1061 | 1211 | <label class="six wide column middle aligned"> |
| 1062 | 1212 | <?php |
| 1063 | 1213 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_is_ignoreCoreUpdates', (int) $website->is_ignoreCoreUpdates ); |
| @@ -1063,9 +1213,9 @@ | ||
| 1063 | 1213 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_is_ignoreCoreUpdates', (int) $website->is_ignoreCoreUpdates ); |
| 1064 | 1214 | esc_html_e( 'Ignore core updates', 'mainwp' ); |
| 1065 | 1215 | ?> |
| 1066 | 1216 | </label> |
| 1067 | - <div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore WP Core updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1217 | + <div class="one wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore WP Core updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1068 | 1218 | <input type="checkbox" name="mainwp_is_ignoreCoreUpdates" class="settings-field-value-change-handler" id="mainwp_is_ignoreCoreUpdates" <?php echo 1 === (int) $website->is_ignoreCoreUpdates ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_is_ignoreCoreUpdates"></label> |
| 1069 | 1219 | </div> |
| 1070 | 1220 | </div> |
| 1071 | 1221 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| @@ -1074,9 +1224,9 @@ | ||
| 1074 | 1224 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_is_ignorePluginUpdates', (int) $website->is_ignorePluginUpdates ); |
| 1075 | 1225 | esc_html_e( 'Ignore plugin updates', 'mainwp' ); |
| 1076 | 1226 | ?> |
| 1077 | 1227 | </label> |
| 1078 | - <div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore plugin updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1228 | + <div class="one wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore plugin updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1079 | 1229 | <input type="checkbox" name="mainwp_is_ignorePluginUpdates" class="settings-field-value-change-handler" id="mainwp_is_ignorePluginUpdates" <?php echo 1 === (int) $website->is_ignorePluginUpdates ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_is_ignorePluginUpdates"></label> |
| 1080 | 1230 | </div> |
| 1081 | 1231 | </div> |
| 1082 | 1232 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> |
| @@ -1085,139 +1235,84 @@ | ||
| 1085 | 1235 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_is_ignoreThemeUpdates', (int) $website->is_ignoreThemeUpdates ); |
| 1086 | 1236 | esc_html_e( 'Ignore theme updates', 'mainwp' ); |
| 1087 | 1237 | ?> |
| 1088 | 1238 | </label> |
| 1089 | - <div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore theme updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1239 | + <div class="one wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore theme updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1090 | 1240 | <input type="checkbox" name="mainwp_is_ignoreThemeUpdates" class="settings-field-value-change-handler" id="mainwp_is_ignoreThemeUpdates" <?php echo 1 === (int) $website->is_ignoreThemeUpdates ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_is_ignoreThemeUpdates"></label> |
| 1091 | 1241 | </div> |
| 1092 | 1242 | </div> |
| 1093 | - <?php } ?> | |
| 1094 | - | |
| 1095 | - <div class="ui grid field"> | |
| 1096 | - <label class="six wide column middle aligned"><?php esc_html_e( 'Connected on', 'mainwp' ); ?></label> | |
| 1097 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Set the date your site was added to your MainWP Dashboard.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1098 | - <div class="ui left labeled input"> | |
| 1099 | - <div class="ui calendar mainwp_datepicker" > | |
| 1100 | - <div class="ui input left icon"> | |
| 1101 | - <i class="calendar icon"></i> | |
| 1102 | - <input type="text" autocomplete="off" name="mainwp_managesites_edit_dt_added" placeholder="<?php esc_attr_e( 'Date', 'mainwp' ); ?>" id="mainwp_managesites_edit_dt_added" value="<?php echo ! empty( $website->added_timestamp ) ? esc_attr( date( 'Y-m-d', $website->added_timestamp ) ) : ''; // phpcs:ignore -- local time works. ?>"/> | |
| 1103 | - </div> | |
| 1104 | - </div> | |
| 1243 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> | |
| 1244 | + <label class="six wide column middle aligned"> | |
| 1245 | + <?php | |
| 1246 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_is_ignore_trans_updates', (int) $website->ignored_trans_updates ); | |
| 1247 | + esc_html_e( 'Ignore translation updates', 'mainwp' ); | |
| 1248 | + ?> | |
| 1249 | + </label> | |
| 1250 | + <div class="one wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to ignore translation updates on this website.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1251 | + <input type="checkbox" name="mainwp_is_ignore_trans_updates" class="settings-field-value-change-handler" id="mainwp_is_ignore_trans_updates" <?php echo 1 === (int) $website->ignored_trans_updates ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_is_ignore_trans_updates"></label> | |
| 1105 | 1252 | </div> |
| 1106 | 1253 | </div> |
| 1107 | - </div> | |
| 1254 | + <?php } ?> | |
| 1108 | 1255 | |
| 1109 | - <h3 class="ui dividing header"> | |
| 1110 | - <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-uptime' ); ?> | |
| 1111 | - <?php esc_html_e( 'Child Site Uptime Monitoring (Optional)', 'mainwp' ); ?></h3> | |
| 1112 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-uptime" defaul-value="0"> | |
| 1256 | + <h4 class="ui dividing tiny header"><?php esc_html_e( 'Site Status', 'mainwp' ); ?></h4> | |
| 1257 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-general"> | |
| 1113 | 1258 | <label class="six wide column middle aligned"> |
| 1114 | 1259 | <?php |
| 1115 | - $indi_compatible_val = ! $website->disable_status_check ? 1 : 0; | |
| 1116 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disableSitesChecking', $indi_compatible_val ); | |
| 1117 | - esc_html_e( 'Enable basic uptime monitoring (optional)', 'mainwp' ); | |
| 1260 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_suspended_site', (int) $website->suspended ); | |
| 1261 | + esc_html_e( 'Suspend Site', 'mainwp' ); | |
| 1118 | 1262 | ?> |
| 1119 | 1263 | </label> |
| 1120 | - <div class="six wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="monitoring" data-tooltip="<?php esc_attr_e( 'Enable if you want to monitoring this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1121 | - <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_managesites_edit_disableChecking" id="mainwp_managesites_edit_disableChecking" <?php echo 0 === (int) $website->disable_status_check ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_managesites_edit_disableChecking"></label> | |
| 1264 | + <div class="one wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Suspends MainWP actions for this site (updates, maintenance tasks) without disconnecting it.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1265 | + <input type="checkbox" name="mainwp_suspended_site" class="settings-field-value-change-handler" id="mainwp_suspended_site" <?php echo 1 === (int) $website->suspended ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_suspended_site"></label> | |
| 1122 | 1266 | </div> |
| 1123 | 1267 | </div> |
| 1124 | - <?php | |
| 1125 | - $check_interval = (int) $website->status_check_interval; | |
| 1126 | - $hide_style = 'style="display:none"'; | |
| 1127 | - ?> | |
| 1128 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-uptime" <?php echo 1 === (int) $website->disable_status_check ? $hide_style : ''; //phpcs:ignore -- ok. ?> hide-element="monitoring"> | |
| 1129 | - <label class="six wide column middle aligned"> | |
| 1130 | - <?php | |
| 1131 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_status_check_interval', (int) $check_interval ); | |
| 1132 | - esc_html_e( 'Check interval (optional)', 'mainwp' ); | |
| 1133 | - ?> | |
| 1134 | - </label> | |
| 1135 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Check interval (optional)', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1136 | - <select name="mainwp_managesites_edit_checkInterval" id="mainwp_managesites_edit_checkInterval" class="ui dropdown settings-field-value-change-handler"> | |
| 1137 | - <option value="5" <?php echo 5 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Every 5 minutes', 'mainwp' ); ?></option> | |
| 1138 | - <option value="10" <?php echo 10 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Every 10 minutes', 'mainwp' ); ?></option> | |
| 1139 | - <option value="30" <?php echo 30 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Every 30 minutes', 'mainwp' ); ?></option> | |
| 1140 | - <option value="60" <?php echo 60 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Every hour', 'mainwp' ); ?></option> | |
| 1141 | - <option value="180" <?php echo 180 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Every 3 hours', 'mainwp' ); ?></option> | |
| 1142 | - <option value="360" <?php echo 360 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Every 6 hours', 'mainwp' ); ?></option> | |
| 1143 | - <option value="720" <?php echo 720 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Twice a day', 'mainwp' ); ?></option> | |
| 1144 | - <option value="1440" <?php echo 1440 === $check_interval ? 'selected' : ''; ?>><?php esc_html_e( 'Once a day', 'mainwp' ); ?></option> | |
| 1145 | - <option value="0" <?php echo 0 === $check_interval ? 'selected' : ''; ?>><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> | |
| 1146 | - </select> | |
| 1147 | - </div> | |
| 1148 | - </div> | |
| 1149 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-uptime" <?php echo 1 === (int) $website->disable_status_check ? $hide_style : ''; //phpcs:ignore -- ok.?> hide-element="monitoring"> | |
| 1150 | - <label class="six wide column middle aligned"> | |
| 1151 | - <?php | |
| 1152 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_monitoring_notification_emails', $website->monitoring_notification_emails ); | |
| 1153 | - esc_html_e( 'Additional notification emails (comma-separated)', 'mainwp' ); | |
| 1154 | - ?> | |
| 1155 | - </label> | |
| 1156 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Additional notification emails (comma-separated).', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1268 | + <div class="ui grid field"> | |
| 1269 | + <label class="six wide column middle aligned"><?php esc_html_e( 'Connected on', 'mainwp' ); ?></label> | |
| 1270 | + <div class="three wide column" data-tooltip="<?php esc_attr_e( 'Set the date your site was added to your MainWP Dashboard.', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1157 | 1271 | <div class="ui left labeled input"> |
| 1158 | - <input type="text" class="settings-field-value-change-handler" id="mainwp_managesites_edit_monitoringNotificationEmails" name="mainwp_managesites_edit_monitoringNotificationEmails" value="<?php echo ! empty( $website->monitoring_notification_emails ) ? esc_html( $website->monitoring_notification_emails ) : ''; ?>"/> | |
| 1272 | + <div class="ui calendar mainwp_datepicker" > | |
| 1273 | + <div class="ui input left icon"> | |
| 1274 | + <i class="calendar icon"></i> | |
| 1275 | + <input type="text" autocomplete="off" name="mainwp_managesites_edit_dt_added" placeholder="<?php esc_attr_e( 'Date', 'mainwp' ); ?>" id="mainwp_managesites_edit_dt_added" value="<?php echo ! empty( $website->added_timestamp ) ? esc_attr( date( 'Y-m-d', $website->added_timestamp ) ) : ''; // phpcs:ignore -- local time works. ?>"/> | |
| 1276 | + </div> | |
| 1277 | + </div> | |
| 1159 | 1278 | </div> |
| 1160 | 1279 | </div> |
| 1161 | 1280 | </div> |
| 1162 | - <h3 class="ui dividing header"> | |
| 1163 | - <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-health' ); ?> | |
| 1164 | - <?php esc_html_e( 'Sites Health Monitoring (Optional)', 'mainwp' ); ?></h3> | |
| 1165 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-health" default-indi-value="1"> | |
| 1166 | - <label class="six wide column middle aligned"> | |
| 1167 | - <?php | |
| 1168 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_disable_health_check', (int) $website->disable_health_check ); | |
| 1169 | - esc_html_e( 'Enable Child Site Health monitoring (optional)', 'mainwp' ); | |
| 1170 | - ?> | |
| 1171 | - </label> | |
| 1172 | - <div class="six wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="health-monitoring" data-tooltip="<?php esc_attr_e( 'Enable if you want to monitoring this website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1173 | - <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_managesites_edit_disableSiteHealthMonitoring" id="mainwp_managesites_edit_disableSiteHealthMonitoring" <?php echo 0 === (int) $website->disable_health_check ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_managesites_edit_disableSiteHealthMonitoring"></label> | |
| 1174 | 1281 | </div> |
| 1175 | 1282 | </div> |
| 1176 | - <?php | |
| 1177 | - $healthThreshold = $website->health_threshold; | |
| 1178 | - ?> | |
| 1179 | - <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-health" default-indi-value="80" <?php echo 1 === (int) $website->disable_health_check ? $hide_style : ''; //phpcs:ignore -- ok.?> hide-element="health-monitoring"> | |
| 1283 | + | |
| 1284 | + <div class="ui basic accordion mainwp-blank-accordion mainwp-sidebar-accordion" id="mainwp-edit-site-advanced-settings-accordion"> | |
| 1285 | + <h2 class="ui dividing header title"> | |
| 1286 | + <i class="right dropdown icon"></i> | |
| 1287 | + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-advanced' ); ?> | |
| 1288 | + <?php esc_html_e( 'Advanced Settings (Optional)', 'mainwp' ); ?> | |
| 1289 | + <div class="sub header"><?php esc_html_e( 'Fine-tune behavior and control edge-case options.', 'mainwp' ); ?></div> | |
| 1290 | + </h2> | |
| 1291 | + <div class="content"> | |
| 1292 | + <div class="ui grid field settings-field-indicator-wrapper" default-indi-value="2"> | |
| 1180 | 1293 | <label class="six wide column middle aligned"> |
| 1181 | 1294 | <?php |
| 1182 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sitehealthThreshold', (int) $healthThreshold ); | |
| 1183 | - esc_html_e( 'Site health threshold (optional)', 'mainwp' ); | |
| 1295 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_verify_certificate', (int) $website->verify_certificate ); | |
| 1296 | + esc_html_e( 'Verify certificate', 'mainwp' ); | |
| 1184 | 1297 | ?> |
| 1185 | 1298 | </label> |
| 1186 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Site health threshold.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1187 | - <select name="mainwp_managesites_edit_healthThreshold" id="mainwp_managesites_edit_healthThreshold" class="ui dropdown settings-field-value-change-handler"> | |
| 1188 | - <option value="80" <?php echo 80 === $healthThreshold ? 'selected' : ''; ?>><?php esc_html_e( 'Should be improved', 'mainwp' ); ?></option> | |
| 1189 | - <option value="100" <?php echo 100 === $healthThreshold ? 'selected' : ''; ?>><?php esc_html_e( 'Good', 'mainwp' ); ?></option> | |
| 1190 | - <option value="0" <?php echo 0 === $healthThreshold ? 'selected' : ''; ?>><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> | |
| 1299 | + <div class="three wide column"> | |
| 1300 | + <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_verifycertificate" name="mainwp_managesites_edit_verifycertificate"> | |
| 1301 | + <option <?php echo 1 === (int) $website->verify_certificate ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'Yes', 'mainwp' ); ?></option> | |
| 1302 | + <option <?php echo 0 === (int) $website->verify_certificate ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'No', 'mainwp' ); ?></option> | |
| 1303 | + <option <?php echo 2 === (int) $website->verify_certificate ? 'selected' : ''; ?> value="2"><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> | |
| 1191 | 1304 | </select> |
| 1192 | 1305 | </div> |
| 1193 | 1306 | </div> |
| 1194 | - <h3 class="ui dividing header"> | |
| 1195 | - <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-advanced' ); ?> | |
| 1196 | - <?php esc_html_e( 'Advanced Settings (Optional)', 'mainwp' ); ?></h3> | |
| 1197 | - <div class="ui grid field settings-field-indicator-wrapper" default-indi-value="2"> | |
| 1198 | - <label class="six wide column middle aligned"> | |
| 1199 | - <?php | |
| 1200 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_verify_certificate', (int) $website->verify_certificate ); | |
| 1201 | - esc_html_e( 'Verify certificate (optional)', 'mainwp' ); | |
| 1202 | - ?> | |
| 1203 | - </label> | |
| 1204 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Do you want to verify SSL certificate.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1205 | - <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_verifycertificate" name="mainwp_managesites_edit_verifycertificate"> | |
| 1206 | - <option <?php echo 1 === (int) $website->verify_certificate ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'Yes', 'mainwp' ); ?></option> | |
| 1207 | - <option <?php echo 0 === (int) $website->verify_certificate ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'No', 'mainwp' ); ?></option> | |
| 1208 | - <option <?php echo 2 === (int) $website->verify_certificate ? 'selected' : ''; ?> value="2"><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> | |
| 1209 | - </select> | |
| 1210 | - </div> | |
| 1211 | - </div> | |
| 1212 | 1307 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-advanced"> |
| 1213 | 1308 | <label class="six wide column middle aligned"> |
| 1214 | 1309 | <?php |
| 1215 | 1310 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_ssl_version', (int) $website->ssl_version ); |
| 1216 | - esc_html_e( 'SSL version (optional)', 'mainwp' ); | |
| 1311 | + esc_html_e( 'SSL version', 'mainwp' ); | |
| 1217 | 1312 | ?> |
| 1218 | 1313 | </label> |
| 1219 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Select SSL Version. If you are not sure, select "Auto Detect".', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1314 | + <div class="three wide column" data-tooltip="<?php esc_attr_e( 'If you are not sure, select "Auto Detect".', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1220 | 1315 | <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_ssl_version" name="mainwp_managesites_edit_ssl_version"> |
| 1221 | 1316 | <option <?php echo 0 === (int) $website->ssl_version ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'Auto detect', 'mainwp' ); ?></option> |
| 1222 | 1317 | <option <?php echo 6 === (int) $website->ssl_version ? 'selected' : ''; ?> value="6"><?php esc_html_e( 'TLS v1.2', 'mainwp' ); ?></option> |
| 1223 | 1318 | <option <?php echo 1 === (int) $website->ssl_version ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'TLS v1.x', 'mainwp' ); ?></option> |
| @@ -1241,9 +1336,9 @@ | ||
| 1241 | 1336 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_verify_method', (int) $verify_conn_method ); |
| 1242 | 1337 | esc_html_e( 'Verify connection method', 'mainwp' ); |
| 1243 | 1338 | ?> |
| 1244 | 1339 | </label> |
| 1245 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Select Verify connection method. If you are not sure, select "Default".', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1340 | + <div class="three wide column" data-tooltip="<?php esc_attr_e( 'If you are not sure, select "Default".', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1246 | 1341 | <select class="ui dropdown settings-field-value-change-handler"id="mainwp_managesites_edit_verify_connection_method" name="mainwp_managesites_edit_verify_connection_method"> |
| 1247 | 1342 | <option <?php echo 1 === (int) $verify_conn_method ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'OpenSSL (default)', 'mainwp' ); ?></option> |
| 1248 | 1343 | <option <?php echo 2 === (int) $verify_conn_method ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'PHPSECLIB (fallback)', 'mainwp' ); ?></option> |
| 1249 | 1344 | <option <?php echo 3 === (int) $verify_conn_method ? 'selected' : ''; ?> value="3"><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> |
| @@ -1265,9 +1360,9 @@ | ||
| 1265 | 1360 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_signature_algo', (int) $site_sign_algo ); |
| 1266 | 1361 | esc_html_e( 'OpenSSL signature algorithm', 'mainwp' ); |
| 1267 | 1362 | ?> |
| 1268 | 1363 | </label> |
| 1269 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Select OpenSSL signature algorithm. If you are not sure, select "Default".', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1364 | + <div class="three wide column" data-tooltip="<?php esc_attr_e( 'If you are not sure, select "Default".', 'mainwp' ); ?>" data-inverted="" data-position="right center"> | |
| 1270 | 1365 | <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_openssl_alg" name="mainwp_managesites_edit_openssl_alg"> |
| 1271 | 1366 | <?php |
| 1272 | 1367 | foreach ( $sign_algs as $val => $text ) { |
| 1273 | 1368 | ?> |
| @@ -1284,12 +1379,12 @@ | ||
| 1284 | 1379 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-advanced" default-indi-value="2"> |
| 1285 | 1380 | <label class="six wide column middle aligned"> |
| 1286 | 1381 | <?php |
| 1287 | 1382 | MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_force_use_ipv4', (int) $website->force_use_ipv4 ); |
| 1288 | - esc_html_e( 'Force IPv4 (optional)', 'mainwp' ); | |
| 1383 | + esc_html_e( 'Force IPv4', 'mainwp' ); | |
| 1289 | 1384 | ?> |
| 1290 | 1385 | </label> |
| 1291 | - <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Do you want to force IPv4 for this child site?', 'mainwp' ); ?>" data-inverted="" data-position="top left"> | |
| 1386 | + <div class="three wide column"> | |
| 1292 | 1387 | <select class="ui dropdown settings-field-value-change-handler" id="mainwp_managesites_edit_forceuseipv4" name="mainwp_managesites_edit_forceuseipv4"> |
| 1293 | 1388 | <option <?php echo ( 1 === (int) $website->force_use_ipv4 ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'Yes', 'mainwp' ); ?></option> |
| 1294 | 1389 | <option <?php echo ( 0 === (int) $website->force_use_ipv4 ) ? 'selected' : ''; ?> value="0"><?php esc_html_e( 'No', 'mainwp' ); ?></option> |
| 1295 | 1390 | <option <?php echo ( 2 === (int) $website->force_use_ipv4 ) ? 'selected' : ''; ?> value="2"><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> |
| @@ -1297,18 +1392,28 @@ | ||
| 1297 | 1392 | </div> |
| 1298 | 1393 | </div> |
| 1299 | 1394 | <input style="display:none" type="text" name="fakeusernameremembered"/> |
| 1300 | 1395 | <input style="display:none" type="password" name="fakepasswordremembered"/> |
| 1396 | + <?php | |
| 1397 | + // MWP-1548: http_user is encrypted at rest; decrypt for the | |
| 1398 | + // visible username field. The "is set" indicator and the | |
| 1399 | + // change-detection handler still need a truthy/falsy hint | |
| 1400 | + // so we expose plaintext to those calls. http_pass uses the | |
| 1401 | + // sentinel render (below) so the live password never enters | |
| 1402 | + // the DOM, regardless of what's stored. | |
| 1403 | + $http_user_plain = MainWP_Credential_Storage::decrypt_credential( $website->http_user ); | |
| 1404 | + $http_pass_set = ! empty( $website->http_pass ); | |
| 1405 | + ?> | |
| 1301 | 1406 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-advanced"> |
| 1302 | 1407 | <label class="six wide column middle aligned"> |
| 1303 | 1408 | <?php |
| 1304 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_http_user', $website->http_user ); | |
| 1305 | - esc_html_e( 'HTTP Username (optional)', 'mainwp' ); | |
| 1409 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_http_user', $http_user_plain ); | |
| 1410 | + esc_html_e( 'HTTP Username', 'mainwp' ); | |
| 1306 | 1411 | ?> |
| 1307 | 1412 | </label> |
| 1308 | 1413 | <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'If the child site is HTTP Basic Auth protected, enter the HTTP username here.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 1309 | 1414 | <div class="ui left labeled input"> |
| 1310 | - <input type="text" class="settings-field-value-change-handler" id="mainwp_managesites_edit_http_user" name="mainwp_managesites_edit_http_user" value="<?php echo empty( $website->http_user ) ? '' : esc_attr( $website->http_user ); ?>" autocomplete="off" /> | |
| 1415 | + <input type="text" class="settings-field-value-change-handler" id="mainwp_managesites_edit_http_user" name="mainwp_managesites_edit_http_user" value="<?php echo empty( $http_user_plain ) ? '' : esc_attr( $http_user_plain ); ?>" autocomplete="off" /> | |
| 1311 | 1416 | </div> |
| 1312 | 1417 | </div> |
| 1313 | 1418 | </div> |
| 1314 | 1419 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-advanced"> |
| @@ -1313,19 +1418,69 @@ | ||
| 1313 | 1418 | </div> |
| 1314 | 1419 | <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-advanced"> |
| 1315 | 1420 | <label class="six wide column middle aligned"> |
| 1316 | 1421 | <?php |
| 1317 | - MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_http_pass', $website->http_pass ); | |
| 1318 | - esc_html_e( 'HTTP Password (optional)', 'mainwp' ); | |
| 1422 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_http_pass', $http_pass_set ? '1' : '' ); | |
| 1423 | + esc_html_e( 'HTTP Password', 'mainwp' ); | |
| 1319 | 1424 | ?> |
| 1320 | 1425 | </label> |
| 1321 | 1426 | <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'If the child site is HTTP Basic Auth protected, enter the HTTP password here.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 1322 | 1427 | <div class="ui left labeled input"> |
| 1323 | - <input type="password" id="mainwp_managesites_edit_http_pass" class="settings-field-value-change-handler" name="mainwp_managesites_edit_http_pass" value="<?php echo empty( $website->http_pass ) ? '' : esc_attr( $website->http_pass ); ?>" autocomplete="new-password" /> | |
| 1428 | + <input type="password" id="mainwp_managesites_edit_http_pass" class="settings-field-value-change-handler" name="mainwp_managesites_edit_http_pass" value="<?php echo esc_attr( MainWP_Credential_Render::value_for_input( $http_pass_set ) ); ?>" autocomplete="new-password" /> | |
| 1324 | 1429 | </div> |
| 1325 | 1430 | </div> |
| 1326 | 1431 | </div> |
| 1432 | + </div> | |
| 1433 | + </div> | |
| 1434 | + | |
| 1435 | + <div class="ui basic accordion mainwp-blank-accordion mainwp-sidebar-accordion" id="mainwp-edit-site-health-monitoring-accordion"> | |
| 1436 | + <h2 class="ui dividing header title"> | |
| 1437 | + <i class="right dropdown icon"></i> | |
| 1438 | + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-edit-site-health' ); ?> | |
| 1439 | + <?php esc_html_e( 'Sites Health Monitoring (Optional)', 'mainwp' ); ?> | |
| 1440 | + <div class="sub header"><?php esc_html_e( 'Configure checks and alerts to stay on top of site health.', 'mainwp' ); ?></div> | |
| 1441 | + </h2> | |
| 1442 | + <div class="content"> | |
| 1443 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-health" default-indi-value="1"> | |
| 1444 | + <label class="six wide column middle aligned"> | |
| 1445 | + <?php | |
| 1446 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_disable_health_check', (int) $website->disable_health_check ); | |
| 1447 | + esc_html_e( 'Enable Child Site Health monitoring', 'mainwp' ); | |
| 1448 | + ?> | |
| 1449 | + </label> | |
| 1450 | + <div class="one wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="health-monitoring"> | |
| 1451 | + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_managesites_edit_disableSiteHealthMonitoring" id="mainwp_managesites_edit_disableSiteHealthMonitoring" <?php echo 0 === (int) $website->disable_health_check ? $style_checked : ''; //phpcs:ignore -- ok. ?>><label for="mainwp_managesites_edit_disableSiteHealthMonitoring"></label> | |
| 1452 | + </div> | |
| 1453 | + </div> | |
| 1327 | 1454 | <?php |
| 1455 | + $healthThreshold = $website->health_threshold; | |
| 1456 | + $indi_val = 0 !== (int) $healthThreshold ? 1 : 0; | |
| 1457 | + $hide_style = 'style="display:none;"'; | |
| 1458 | + ?> | |
| 1459 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-health" default-indi-value="0" <?php echo 1 === (int) $website->disable_health_check ? $hide_style : ''; //phpcs:ignore -- ok.?> hide-element="health-monitoring"> | |
| 1460 | + <label class="six wide column middle aligned"> | |
| 1461 | + <?php | |
| 1462 | + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', (int) $indi_val ); | |
| 1463 | + esc_html_e( 'Site health threshold (optional)', 'mainwp' ); | |
| 1464 | + ?> | |
| 1465 | + </label> | |
| 1466 | + <div class="three wide column"> | |
| 1467 | + <select name="mainwp_managesites_edit_healthThreshold" id="mainwp_managesites_edit_healthThreshold" class="ui dropdown settings-field-value-change-handler"> | |
| 1468 | + <option value="80" <?php echo 80 === (int) $healthThreshold ? 'selected' : ''; ?>><?php esc_html_e( 'Should be improved', 'mainwp' ); ?></option> | |
| 1469 | + <option value="100" <?php echo 100 === (int) $healthThreshold ? 'selected' : ''; ?>><?php esc_html_e( 'Good', 'mainwp' ); ?></option> | |
| 1470 | + <option value="0" <?php echo 0 === (int) $healthThreshold ? 'selected' : ''; ?>><?php echo $text_use_global; //phpcs:ignore --ok. ?></option> | |
| 1471 | + </select> | |
| 1472 | + </div> | |
| 1473 | + </div> | |
| 1474 | + </div> | |
| 1475 | + </div> | |
| 1476 | + <?php | |
| 1477 | + MainWP_Uptime_Monitoring_Edit::instance()->render_monitor_settings( $website->id, true ); | |
| 1478 | + | |
| 1479 | + MainWP_Manage_Sites::render_email_settings( $website ); | |
| 1480 | + | |
| 1481 | + MainWP_Manage_Backups::render_individual_settings( $website ); | |
| 1482 | + | |
| 1328 | 1483 | do_action_deprecated( 'mainwp-manage-sites-edit', array( $website ), '4.0.7.2', 'mainwp_manage_sites_edit' ); // @deprecated Use 'mainwp_manage_sites_edit' instead. NOSONAR - not IP. |
| 1329 | 1484 | do_action_deprecated( 'mainwp-extension-sites-edit', array( $website ), '4.0.7.2', 'mainwp_manage_sites_edit' ); // @deprecated Use 'mainwp_manage_sites_edit' instead. NOSONAR - not IP. |
| 1330 | 1485 | |
| 1331 | 1486 | /** This action is documented in ../pages/page-mainwp-manage-sites.php */ |
| @@ -1333,8 +1488,9 @@ | ||
| 1333 | 1488 | do_action( 'mainwp_extension_sites_edit_tablerow', $website ); |
| 1334 | 1489 | ?> |
| 1335 | 1490 | <div class="ui divider"></div> |
| 1336 | 1491 | <input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/> |
| 1492 | + <input type="button" name="submit_remove_website" id="mainwp-managesites-remove-site" class="ui button red big floated right" value="<?php esc_attr_e( 'Remove Site', 'mainwp' ); ?>"/> | |
| 1337 | 1493 | </form> |
| 1338 | 1494 | </div> |
| 1339 | 1495 | <div class="ui modal" id="mainwp-test-connection-modal"> |
| 1340 | 1496 | <i class="close icon"></i> |
| @@ -1339,9 +1495,9 @@ | ||
| 1339 | 1495 | <div class="ui modal" id="mainwp-test-connection-modal"> |
| 1340 | 1496 | <i class="close icon"></i> |
| 1341 | 1497 | <div class="header"><?php esc_html_e( 'Connection Test', 'mainwp' ); ?></div> |
| 1342 | 1498 | <div class="content"> |
| 1343 | - <div class="ui active inverted dimmer"> | |
| 1499 | + <div class="ui active dimmer"> | |
| 1344 | 1500 | <div class="ui text loader"><?php esc_html_e( 'Testing connection...', 'mainwp' ); ?></div> |
| 1345 | 1501 | </div> |
| 1346 | 1502 | <div id="mainwp-test-connection-result" class="ui segment" style="display:none"> |
| 1347 | 1503 | <h2 class="ui center aligned icon header"> |
| @@ -1409,14 +1565,14 @@ | ||
| 1409 | 1565 | let icon_img = typeof response.iconimg !== undefined ? response.iconimg : ''; |
| 1410 | 1566 | let icon_src = typeof response.iconsrc !== undefined ? response.iconsrc : ''; |
| 1411 | 1567 | iconObj.attr('icon-src', icon_src); |
| 1412 | 1568 | iconObj.attr('iconFileSlug', response.iconfile); // to support delete file when iconItemId = 0. |
| 1569 | + iconObj.attr('del-icon-nonce', response.iconnonce); | |
| 1413 | 1570 | jQuery('#mainwp_delete_image_field').find('.ui.image').attr('src', icon_src); |
| 1414 | 1571 | jQuery('#mainw_managesites_add_edit_site_upload_custom_icon').html(icon_img).show(); |
| 1415 | 1572 | } |
| 1416 | 1573 | } |
| 1417 | 1574 | setTimeout(function () { |
| 1418 | - //window.location.href = location.href; | |
| 1419 | 1575 | jQuery('#mainwp-upload-custom-icon-modal').modal('hide') |
| 1420 | 1576 | }, 1000); |
| 1421 | 1577 | }); |
| 1422 | 1578 | return false; |
| @@ -1473,9 +1629,9 @@ | ||
| 1473 | 1629 | $style_checked = 'checked="true"'; |
| 1474 | 1630 | ?> |
| 1475 | 1631 | <div class="ui segment"> |
| 1476 | 1632 | <?php MainWP_Notification_Settings::render_update_template_message( $updated_templ ); ?> |
| 1477 | - <form method="POST" action="admin.php?page=managesites&emailsettingsid=<?php echo intval( $siteid ); ?>" class="ui form"> | |
| 1633 | + <form method="POST" action="admin.php?page=managesites&id=<?php echo intval( $siteid ); ?>&emailsettingsid=<?php echo intval( $siteid ); ?>" class="ui form"> | |
| 1478 | 1634 | <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'UpdateWebsiteEmailSettings' . $siteid ) ); ?>" /> |
| 1479 | 1635 | <input type="hidden" name="mainwp_managesites_setting_emails_type" value="<?php echo esc_html( $type ); ?>" /> |
| 1480 | 1636 | <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-email-tokens-info-message' ) ) { ?> |
| 1481 | 1637 | <div class="ui info message"> |
| @@ -1561,13 +1717,13 @@ | ||
| 1561 | 1717 | <div class="ui grid field" > |
| 1562 | 1718 | <label class="six wide column middle aligned"></label> |
| 1563 | 1719 | <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Manage the email HTML template.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 1564 | 1720 | <?php if ( $overrided ) { ?> |
| 1565 | - <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=managesites&emailsettingsid=' . intval( $siteid ) . '&edit-email=' . esc_attr( $type ), 'delete-email-template' ) ); ?>" onclick="mainwp_confirm('<?php echo esc_js( 'Are you sure you want to delete this template file?', 'mainwp' ); ?>', function(){ window.location = jQuery('a#email-delete-template').attr('href');}); return false;" id="email-delete-template" class="ui button"><?php esc_html_e( 'Return to Default Template', 'mainwp' ); ?></a> | |
| 1721 | + <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=managesites&id=' . intval( $siteid ) . '&emailsettingsid=' . intval( $siteid ) . '&edit-email=' . esc_attr( $type ), 'delete-email-template' ) ); ?>" onclick="mainwp_confirm('<?php echo esc_js( 'Are you sure you want to delete this template file?', 'mainwp' ); ?>', function(){ window.location = jQuery('a#email-delete-template').attr('href');}); return false;" id="email-delete-template" class="ui button"><?php esc_html_e( 'Return to Default Template', 'mainwp' ); ?></a> | |
| 1566 | 1722 | <?php |
| 1567 | 1723 | } else { |
| 1568 | 1724 | ?> |
| 1569 | - <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=managesites&emailsettingsid=' . intval( $siteid ) . '&edit-email=' . esc_attr( $type ), 'copy-email-template' ) ); ?>" class="ui button"><?php esc_html_e( 'Copy file to uploads', 'mainwp' ); ?></a> | |
| 1725 | + <a href="<?php echo esc_url( wp_nonce_url( 'admin.php?page=managesites&id=' . intval( $siteid ) . '&emailsettingsid=' . intval( $siteid ) . '&edit-email=' . esc_attr( $type ), 'copy-email-template' ) ); ?>" class="ui button"><?php esc_html_e( 'Copy file to uploads', 'mainwp' ); ?></a> | |
| 1570 | 1726 | <?php } ?> |
| 1571 | 1727 | <?php if ( $overrided ) { ?> |
| 1572 | 1728 | <a href="javascript:void(0)" class="ui button" onclick="mainwp_view_template('<?php echo esc_js( $type ); ?>'); return false;"><?php esc_html_e( 'Edit Template', 'mainwp' ); ?></a> |
| 1573 | 1729 | <?php |
| @@ -1577,9 +1733,9 @@ | ||
| 1577 | 1733 | <?php } ?> |
| 1578 | 1734 | </div> |
| 1579 | 1735 | </div> |
| 1580 | 1736 | <div class="ui divider"></div> |
| 1581 | - <a href="admin.php?page=managesites&emailsettingsid=<?php echo intval( $siteid ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> | |
| 1737 | + <a href="admin.php?page=managesites&id=<?php echo (int) ( $siteid ); ?>&emailsettingsid=<?php echo intval( $siteid ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> | |
| 1582 | 1738 | <input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/> |
| 1583 | 1739 | </form> |
| 1584 | 1740 | </div> |
| 1585 | 1741 | </div> |
| @@ -1615,9 +1771,9 @@ | ||
| 1615 | 1771 | $default_file = $default_dir . $template; |
| 1616 | 1772 | $template_file = apply_filters( 'mainwp_default_template_locate', $default_file, $template, $default_dir, $type, $siteid ); |
| 1617 | 1773 | |
| 1618 | 1774 | if ( $siteid ) { |
| 1619 | - $localion = 'admin.php?page=managesites&emailsettingsid=' . $siteid . '&edit-email=' . $type; | |
| 1775 | + $localion = 'admin.php?page=managesites&id=' . (int) $siteid . '&emailsettingsid=' . $siteid . '&edit-email=' . $type; | |
| 1620 | 1776 | } else { |
| 1621 | 1777 | $localion = 'admin.php?page=SettingsEmail&edit-email=' . $type; |
| 1622 | 1778 | } |
| 1623 | 1779 | |
| @@ -1625,9 +1781,9 @@ | ||
| 1625 | 1781 | ?> |
| 1626 | 1782 | <div class="ui large modal" id="mainwp-edit-email-template-modal"> |
| 1627 | 1783 | <i class="close icon"></i> |
| 1628 | 1784 | <div class="header"><?php esc_html_e( 'Edit Email Template', 'mainwp' ); ?></div> |
| 1629 | - <div class="scrolling header"> | |
| 1785 | + <div class="scrolling content"> | |
| 1630 | 1786 | <form method="POST" id="email-template-form" action="<?php echo esc_html( $localion ); ?>" class="ui form"> |
| 1631 | 1787 | <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'save-email-template' ) ); ?>" /> |
| 1632 | 1788 | <div class="template <?php echo esc_attr( $type ); ?>"> |
| 1633 | 1789 | <?php if ( file_exists( $custom_file ) ) { ?> |
| @@ -1709,14 +1865,22 @@ | ||
| 1709 | 1865 | $notification_emails = MainWP_Notification_Settings::get_notification_types(); |
| 1710 | 1866 | $text_recipients = esc_html__( 'Recipient(s)', 'mainwp' ); |
| 1711 | 1867 | |
| 1712 | 1868 | ?> |
| 1713 | - <div class="ui segment"> | |
| 1869 | + | |
| 1870 | + <div class="ui basic accordion mainwp-blank-accordion mainwp-sidebar-accordion" id="mainwp-edit-site-email-settings-accordion"> | |
| 1871 | + <h2 class="ui dividing header title"> | |
| 1872 | + <i class="right dropdown icon"></i> | |
| 1873 | + <?php esc_html_e( 'Email Settings', 'mainwp' ); ?> | |
| 1874 | + <div class="sub header"><?php esc_html_e( 'Set up email notifications with per-site options, extra recipients, and template controls.', 'mainwp' ); ?></div> | |
| 1875 | + </h2> | |
| 1876 | + <div class="content"> | |
| 1877 | + | |
| 1714 | 1878 | <?php if ( $updated ) { ?> |
| 1715 | 1879 | <div class="ui message green"><i class="close icon"></i> <?php esc_html_e( 'Email settings saved successfully.', 'mainwp' ); ?></div> |
| 1716 | 1880 | <?php } ?> |
| 1717 | 1881 | <div class="ui info message"> |
| 1718 | - <?php esc_html_e( 'Email notifications sent from MainWP Dashboard about this child site are listed below. Click on an email to configure it.', 'mainwp' ); ?> | |
| 1882 | + <?php esc_html_e( 'Email notifications sent from MainWP Dashboard about this child site are listed below. Click on an email to configure it.', 'mainwp' ); ?> | |
| 1719 | 1883 | </div> |
| 1720 | 1884 | <table class="ui unstackable table" id="mainwp-emails-settings-table"> |
| 1721 | 1885 | <thead> |
| 1722 | 1886 | <tr> |
| @@ -1736,24 +1900,15 @@ | ||
| 1736 | 1900 | $email_description = MainWP_Notification_Settings::get_settings_desc( $type ); |
| 1737 | 1901 | ?> |
| 1738 | 1902 | <tr> |
| 1739 | 1903 | <td><?php echo ( ! $options['disable'] ) ? '<span data-tooltip="Enabled." data-position="right center" data-inverted=""><i class="circular green check inverted icon"></i></span>' : '<span data-tooltip="Disabled." data-position="right center" data-inverted=""><i class="circular x icon inverted disabled"></i></span>'; ?></td> |
| 1740 | - <td><a href="admin.php?page=managesites&emailsettingsid=<?php echo intval( $website->id ); ?>&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_html_e( 'Click to configure the email settings.', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php echo esc_html( $name ); ?></a></td> | |
| 1904 | + <td><a href="admin.php?page=managesites&id=<?php echo intval( $website->id ); ?>&emailsettingsid=<?php echo intval( $website->id ); ?>&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_html_e( 'Click to configure the email settings.', 'mainwp' ); ?>" data-position="right center" data-inverted=""><?php echo esc_html( $name ); ?></a></td> | |
| 1741 | 1905 | <td><?php echo esc_html( $email_description ); ?></td> |
| 1742 | 1906 | <td><?php echo esc_html( $options['recipients'] ); ?></td> |
| 1743 | - <td style="text-align:right"><a href="admin.php?page=managesites&emailsettingsid=<?php echo intval( $website->id ); ?>&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_html_e( 'Click to configure the email settings.', 'mainwp' ); ?>" data-position="left center" data-inverted="" class="ui green mini button"><?php esc_html_e( 'Manage', 'mainwp' ); ?></a></td> | |
| 1907 | + <td style="text-align:right"><a href="admin.php?page=managesites&id=<?php echo intval( $website->id ); ?>&emailsettingsid=<?php echo intval( $website->id ); ?>&edit-email=<?php echo esc_html( rawurlencode( $type ) ); ?>" data-tooltip="<?php esc_html_e( 'Click to configure the email settings.', 'mainwp' ); ?>" data-position="left center" data-inverted="" class="ui green mini button"><?php esc_html_e( 'Manage', 'mainwp' ); ?></a></td> | |
| 1744 | 1908 | </tr> |
| 1745 | 1909 | <?php } ?> |
| 1746 | 1910 | </tbody> |
| 1747 | - <tfoot> | |
| 1748 | - <tr> | |
| 1749 | - <th scope="col" class="collapsing"><?php esc_html_e( 'Status', 'mainwp' ); ?></th> | |
| 1750 | - <th scope="col" ><?php esc_html_e( 'Email', 'mainwp' ); ?></th> | |
| 1751 | - <th scope="col" ><?php esc_html_e( 'Description', 'mainwp' ); ?></th> | |
| 1752 | - <th scope="col" ><?php echo $text_recipients; //phpcs:ignore -- ok. ?></th> | |
| 1753 | - <th scope="col" > </th> | |
| 1754 | - </tr> | |
| 1755 | - </tfoot> | |
| 1756 | 1911 | </table> |
| 1757 | 1912 | <?php |
| 1758 | 1913 | /** |
| 1759 | 1914 | * Action: mainwp_manage_sites_email_settings |
| @@ -1765,8 +1920,26 @@ | ||
| 1765 | 1920 | * @since 4.1 |
| 1766 | 1921 | */ |
| 1767 | 1922 | do_action( 'mainwp_manage_sites_email_settings', $website ); |
| 1768 | 1923 | ?> |
| 1924 | + <?php if ( ! empty( $website->monitoring_notification_emails ) ) : ?> | |
| 1925 | + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-edit-site-uptime" default-indi-value="" hide-element="monitoring"> | |
| 1926 | + <label class="six wide column middle aligned"> | |
| 1927 | + <?php | |
| 1928 | + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_site_monitoring_notification_emails', $website->monitoring_notification_emails ); | |
| 1929 | + esc_html_e( 'Additional notification emails (comma-separated)', 'mainwp' ); | |
| 1930 | + ?> | |
| 1931 | + <span class="ui yellow small label" data-tooltip="<?php esc_attr_e( 'Deprecated. Customize recipients using the email settings above. This option will be removed in a future update.', 'mainwp' ); ?>" data-position="top left" data-inverted=""><?php esc_html_e( 'Legacy', 'mainwp' ); ?></span> | |
| 1932 | + </label> | |
| 1933 | + <div class="six wide column"> | |
| 1934 | + <div class="ui left labeled input"> | |
| 1935 | + <input type="text" class="settings-field-value-change-handler" id="mainwp_managesites_edit_monitoringNotificationEmails" name="mainwp_managesites_edit_monitoringNotificationEmails" value="<?php echo ! empty( $website->monitoring_notification_emails ) ? esc_attr( $website->monitoring_notification_emails ) : ''; ?>"/> | |
| 1936 | + </div> | |
| 1937 | + </div> | |
| 1938 | + </div> | |
| 1939 | + <?php endif; ?> | |
| 1940 | + </div> | |
| 1941 | + </div> | |
| 1769 | 1942 | <script type="text/javascript"> |
| 1770 | 1943 | let responsive = true; |
| 1771 | 1944 | if( jQuery( window ).width() > 1140 ) { |
| 1772 | 1945 | responsive = false; |
| @@ -1773,8 +1946,9 @@ | ||
| 1773 | 1946 | } |
| 1774 | 1947 | jQuery( document ).ready( function() { |
| 1775 | 1948 | jQuery( '#mainwp-emails-settings-table' ).DataTable( { |
| 1776 | 1949 | "stateSave": true, |
| 1950 | + "searching": false, | |
| 1777 | 1951 | "paging": false, |
| 1778 | 1952 | "ordering": true, |
| 1779 | 1953 | "columnDefs": [ { "orderable": false, "targets": [ 4 ] } ], |
| 1780 | 1954 | "order": [ [ 1, "asc" ] ], |
| @@ -1781,9 +1955,8 @@ | ||
| 1781 | 1955 | "responsive": responsive, |
| 1782 | 1956 | } ); |
| 1783 | 1957 | } ); |
| 1784 | 1958 | </script> |
| 1785 | - </div> | |
| 1786 | 1959 | <?php |
| 1787 | 1960 | } |
| 1788 | 1961 | |
| 1789 | 1962 | /** |
| @@ -1792,8 +1965,9 @@ | ||
| 1792 | 1965 | * Reconnect child site. |
| 1793 | 1966 | * |
| 1794 | 1967 | * @param object $website The website object. |
| 1795 | 1968 | * @param bool $sync_first True try to sync before reconnect. |
| 1969 | + * @param array $params others params. | |
| 1796 | 1970 | * |
| 1797 | 1971 | * @return boolean true|false. |
| 1798 | 1972 | * @throws \MainWP_Exception Exception On errors. |
| 1799 | 1973 | * |
| @@ -1805,12 +1979,13 @@ | ||
| 1805 | 1979 | * @uses \MainWP\Dashboard\MainWP_System_Utility::get_openssl_conf() |
| 1806 | 1980 | * @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() |
| 1807 | 1981 | * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() |
| 1808 | 1982 | */ |
| 1809 | - public static function m_reconnect_site( $website, $sync_first = true ) { //phpcs:ignore -- NOSONAR - complex method. | |
| 1983 | + public static function m_reconnect_site( $website, $sync_first = true, $params = array() ) { //phpcs:ignore -- NOSONAR - complex method. | |
| 1810 | 1984 | if ( MainWP_System_Utility::can_edit_website( $website ) ) { |
| 1811 | - $success = false; | |
| 1812 | - $_error = ''; | |
| 1985 | + $success = false; | |
| 1986 | + $_error = ''; | |
| 1987 | + $error_code = ''; | |
| 1813 | 1988 | try { |
| 1814 | 1989 | if ( $sync_first ) { |
| 1815 | 1990 | $success = MainWP_Sync::sync_site( $website, true ); |
| 1816 | 1991 | if ( ! $success && ! MainWP_Connect_Lib::is_use_fallback_sec_lib( $website ) ) { // fix sign algo in case not use phpseclib. |
| @@ -1818,8 +1993,11 @@ | ||
| 1818 | 1993 | $alg = is_object( $website ) && property_exists( $website, 'signature_algo' ) && ! empty( $website->signature_algo ) ? $website->signature_algo : false; |
| 1819 | 1994 | if ( empty( $alg ) && is_object( $website ) ) { |
| 1820 | 1995 | MainWP_DB::instance()->update_website_option( $website, 'signature_algo', 9999 ); // use global. |
| 1821 | 1996 | $website = MainWP_DB::instance()->get_website_by_id( $website->id ); |
| 1997 | + if ( class_exists( __NAMESPACE__ . '\MainWP_Stack_Helper' ) ) { | |
| 1998 | + MainWP_Stack_Helper::stack_push( 'sync_before_reconnect' ); | |
| 1999 | + } | |
| 1822 | 2000 | $success = MainWP_Sync::sync_site( $website, true ); |
| 1823 | 2001 | } |
| 1824 | 2002 | } |
| 1825 | 2003 | } |
| @@ -1848,38 +2026,75 @@ | ||
| 1848 | 2026 | $privkey = '-1'; |
| 1849 | 2027 | $pubkey = '-1'; |
| 1850 | 2028 | } |
| 1851 | 2029 | |
| 2030 | + $verify_reg = MainWP_DB::instance()->get_website_option( $website, 'register_verify_key', '' ); | |
| 2031 | + | |
| 2032 | + $register_data = array( | |
| 2033 | + 'pubkey' => $pubkey, | |
| 2034 | + 'server' => get_admin_url(), | |
| 2035 | + 'uniqueId' => $website->uniqueId, | |
| 2036 | + 'regverify' => $verify_reg, | |
| 2037 | + ); | |
| 2038 | + | |
| 2039 | + $recon_user = ''; | |
| 2040 | + $recon_userpwd = ''; | |
| 2041 | + | |
| 2042 | + if ( is_array( $params ) && ! empty( $params['wpadmin'] ) && ! empty( $params['adminpwd'] ) ) { | |
| 2043 | + $recon_user = ! empty( $params['wpadmin'] ) ? $params['wpadmin'] : ''; | |
| 2044 | + $recon_userpwd = ! empty( $params['adminpwd'] ) ? $params['adminpwd'] : ''; | |
| 2045 | + } | |
| 2046 | + | |
| 2047 | + if ( ! empty( $recon_user ) && ! empty( $recon_userpwd ) ) { | |
| 2048 | + $register_data['user'] = $recon_user; | |
| 2049 | + $register_data['userpwd'] = $recon_userpwd; | |
| 2050 | + } | |
| 2051 | + | |
| 2052 | + // MWP-1548: decrypt at the boundary for the reconnect/register call. | |
| 1852 | 2053 | $information = MainWP_Connect::fetch_url_not_authed( |
| 1853 | 2054 | $website->url, |
| 1854 | 2055 | $website->adminname, |
| 1855 | 2056 | 'register', |
| 1856 | - array( | |
| 1857 | - 'pubkey' => $pubkey, | |
| 1858 | - 'server' => get_admin_url(), | |
| 1859 | - 'uniqueId' => $website->uniqueId, | |
| 1860 | - ), | |
| 2057 | + $register_data, | |
| 1861 | 2058 | true, |
| 1862 | 2059 | $website->verify_certificate, |
| 1863 | - $website->http_user, | |
| 1864 | - $website->http_pass, | |
| 2060 | + MainWP_Credential_Storage::decrypt_credential( $website->http_user ), | |
| 2061 | + MainWP_Credential_Storage::decrypt_credential( $website->http_pass ), | |
| 1865 | 2062 | $website->ssl_version |
| 1866 | 2063 | ); |
| 1867 | 2064 | |
| 1868 | 2065 | if ( isset( $information['error'] ) && '' !== $information['error'] ) { |
| 1869 | - $err = urldecode( $information['error'] ); | |
| 1870 | - $_error = MainWP_Utility::esc_content( $err ); | |
| 2066 | + $err = urldecode( $information['error'] ); | |
| 2067 | + $_error = MainWP_Utility::esc_content( $err ); | |
| 2068 | + $error_code = isset( $information['error_code'] ) ? sanitize_text_field( wp_unslash( $information['error_code'] ) ) : ''; | |
| 1871 | 2069 | } elseif ( isset( $information['register'] ) && 'OK' === $information['register'] ) { |
| 1872 | - MainWP_DB::instance()->update_website_values( | |
| 1873 | - $website->id, | |
| 1874 | - array( | |
| 1875 | - 'pubkey' => base64_encode( $pubkey ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode() used for backwards compatibility. | |
| 1876 | - 'privkey' => base64_encode( $privkey ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode() used for backwards compatibility. | |
| 1877 | - 'uniqueId' => ( isset( $information['uniqueId'] ) ? $information['uniqueId'] : '' ), | |
| 1878 | - ) | |
| 1879 | - ); | |
| 1880 | - MainWP_Sync::sync_information_array( $website, $information ); | |
| 1881 | - $success = true; | |
| 2070 | + | |
| 2071 | + $en_pk_data = MainWP_Encrypt_Data_Lib::instance()->encrypt_privkey( $privkey, $website->id, true ); | |
| 2072 | + $en_privkey = isset( $en_pk_data['en_data'] ) ? $en_pk_data['en_data'] : ''; | |
| 2073 | + | |
| 2074 | + $site_values = array( | |
| 2075 | + 'pubkey' => base64_encode( $pubkey ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode() used for backwards compatibility. | |
| 2076 | + 'privkey' => base64_encode( $en_privkey ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode() used for backwards compatibility. | |
| 2077 | + 'uniqueId' => ( isset( $information['uniqueId'] ) ? $information['uniqueId'] : '' ), | |
| 2078 | + ); | |
| 2079 | + | |
| 2080 | + if ( ! empty( $recon_user ) && ! empty( $recon_userpwd ) && ( $website->adminname !== $recon_user ) ) { | |
| 2081 | + $site_values['adminname'] = $recon_user; | |
| 2082 | + } | |
| 2083 | + | |
| 2084 | + MainWP_DB::instance()->update_website_values( | |
| 2085 | + $website->id, | |
| 2086 | + $site_values | |
| 2087 | + ); | |
| 2088 | + | |
| 2089 | + if ( ! empty( $information['regverify'] ) ) { | |
| 2090 | + MainWP_DB::instance()->update_website_option( $website, 'register_verify_key', $information['regverify'] ); | |
| 2091 | + } | |
| 2092 | + if ( class_exists( __NAMESPACE__ . '\MainWP_Stack_Helper' ) ) { | |
| 2093 | + MainWP_Stack_Helper::stack_push( 'sync_reconnect' ); | |
| 2094 | + } | |
| 2095 | + MainWP_Sync::sync_information_array( $website, $information ); | |
| 2096 | + $success = true; | |
| 1882 | 2097 | } else { |
| 1883 | 2098 | $_error = esc_html__( 'Undefined error!', 'mainwp' ); |
| 1884 | 2099 | } |
| 1885 | 2100 | } |
| @@ -1904,9 +2119,9 @@ | ||
| 1904 | 2119 | return true; |
| 1905 | 2120 | } |
| 1906 | 2121 | |
| 1907 | 2122 | if ( ! empty( $_error ) ) { |
| 1908 | - throw new MainWP_Exception( $_error ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 2123 | + throw new MainWP_Exception( $_error, '', $error_code ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped | |
| 1909 | 2124 | } |
| 1910 | 2125 | } else { |
| 1911 | 2126 | throw new MainWP_Exception( esc_html__( 'This operation is not allowed!', 'mainwp' ) ); |
| 1912 | 2127 | } |
| @@ -1923,13 +2138,14 @@ | ||
| 1923 | 2138 | * @param array $output Output values. |
| 1924 | 2139 | * |
| 1925 | 2140 | * @return self add_wp_site() |
| 1926 | 2141 | */ |
| 1927 | - public static function add_site( $website = false, &$output = array() ) { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR - complexity. | |
| 1928 | - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 2142 | + public static function add_site( $website = false, &$output = array() ) { //phpcs:ignore -- NOSONAR - complexity. | |
| 2143 | + //phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1929 | 2144 | $params['url'] = isset( $_POST['managesites_add_wpurl'] ) ? sanitize_text_field( wp_unslash( $_POST['managesites_add_wpurl'] ) ) : ''; |
| 1930 | 2145 | $params['name'] = isset( $_POST['managesites_add_wpname'] ) ? sanitize_text_field( wp_unslash( $_POST['managesites_add_wpname'] ) ) : ''; |
| 1931 | 2146 | $params['wpadmin'] = isset( $_POST['managesites_add_wpadmin'] ) ? sanitize_text_field( wp_unslash( $_POST['managesites_add_wpadmin'] ) ) : ''; |
| 2147 | + $params['adminpwd'] = isset( $_POST['managesites_add_adminpwd'] ) ? wp_unslash( $_POST['managesites_add_adminpwd'] ) : ''; //phpcs:ignore -- NOSONAR - requires urlencoded passwd, do not sanitize for specical chars. | |
| 1932 | 2148 | $params['unique_id'] = isset( $_POST['managesites_add_uniqueId'] ) ? sanitize_text_field( wp_unslash( $_POST['managesites_add_uniqueId'] ) ) : ''; |
| 1933 | 2149 | $params['ssl_verify'] = empty( $_POST['verify_certificate'] ) ? false : intval( $_POST['verify_certificate'] ); |
| 1934 | 2150 | $params['ssl_version'] = empty( $_POST['ssl_version'] ) ? false : intval( $_POST['ssl_version'] ); |
| 1935 | 2151 | $params['force_use_ipv4'] = apply_filters( 'mainwp_manage_sites_force_use_ipv4', null, $params['url'] ); |
| @@ -1944,14 +2160,75 @@ | ||
| 1944 | 2160 | |
| 1945 | 2161 | if ( isset( $_POST['qsw_page'] ) ) { |
| 1946 | 2162 | $params['qsw_page'] = sanitize_text_field( wp_unslash( $_POST['qsw_page'] ) ); |
| 1947 | 2163 | } |
| 1948 | - // phpcs:enable | |
| 2164 | + //phpcs:enable | |
| 1949 | 2165 | |
| 1950 | 2166 | return static::add_wp_site( $website, $params, $output ); |
| 1951 | 2167 | } |
| 1952 | 2168 | |
| 1953 | 2169 | /** |
| 2170 | + * Correct the entered URL against the child-reported address at | |
| 2171 | + * registration time. | |
| 2172 | + * | |
| 2173 | + * Delegates to MainWP_Site_Url_Corrector::correct_entered_url(): adopts | |
| 2174 | + * the reported www variant and http -> https scheme upgrades, never | |
| 2175 | + * downgrades https -> http and never crosses domains. | |
| 2176 | + * | |
| 2177 | + * @param string $entered_url Entered child site URL. | |
| 2178 | + * @param string $reported_url Child-reported site URL. | |
| 2179 | + * | |
| 2180 | + * @return string Corrected URL or the original entered URL. | |
| 2181 | + */ | |
| 2182 | + private static function maybe_correct_www_variant_url( $entered_url, $reported_url ) { | |
| 2183 | + if ( ! is_string( $entered_url ) || ! is_string( $reported_url ) ) { | |
| 2184 | + return $entered_url; | |
| 2185 | + } | |
| 2186 | + | |
| 2187 | + $corrected = MainWP_Site_Url_Corrector::correct_entered_url( $entered_url, $reported_url ); | |
| 2188 | + | |
| 2189 | + if ( $corrected !== $entered_url ) { | |
| 2190 | + $entered_scheme = wp_parse_url( trim( $entered_url ), PHP_URL_SCHEME ); | |
| 2191 | + $corrected_scheme = wp_parse_url( $corrected, PHP_URL_SCHEME ); | |
| 2192 | + if ( $entered_scheme !== $corrected_scheme ) { | |
| 2193 | + // The registration handshake ran over the ENTERED scheme, so an | |
| 2194 | + // adopted https upgrade is unverified; probe it before saving and | |
| 2195 | + // fall back to a www-only correction when https does not answer. | |
| 2196 | + $probe = MainWP_Connect::try_visit( $corrected, true ); | |
| 2197 | + if ( ! is_array( $probe ) || ! empty( $probe['error'] ) || 200 !== (int) $probe['httpCode'] ) { | |
| 2198 | + $corrected = MainWP_Site_Url_Corrector::correct_entered_url( $entered_url, $reported_url, false ); | |
| 2199 | + } | |
| 2200 | + } | |
| 2201 | + } | |
| 2202 | + | |
| 2203 | + return $corrected; | |
| 2204 | + } | |
| 2205 | + | |
| 2206 | + /** | |
| 2207 | + * Try to fetch the child site favicon immediately after a successful add. | |
| 2208 | + * | |
| 2209 | + * @param int $site_id Child site ID. | |
| 2210 | + * @param array $params Child site add parameters. | |
| 2211 | + */ | |
| 2212 | + private static function maybe_fetch_initial_site_favicon( $site_id, $params ) { | |
| 2213 | + if ( empty( $site_id ) ) { | |
| 2214 | + return; | |
| 2215 | + } | |
| 2216 | + | |
| 2217 | + $uploaded_site_icon = isset( $params['uploaded_site_icon'] ) ? $params['uploaded_site_icon'] : ''; | |
| 2218 | + $selected_site_icon = isset( $params['selected_site_icon'] ) ? $params['selected_site_icon'] : ''; | |
| 2219 | + | |
| 2220 | + if ( ! empty( $uploaded_site_icon ) || ! empty( $selected_site_icon ) ) { | |
| 2221 | + return; | |
| 2222 | + } | |
| 2223 | + | |
| 2224 | + $result = MainWP_Sync::get_wp_icon( $site_id ); | |
| 2225 | + if ( isset( $result['error'] ) && ! empty( $result['error'] ) ) { | |
| 2226 | + MainWP_Logger::instance()->debug( 'Initial favicon fetch failed :: ' . esc_html( $result['error'] ) ); | |
| 2227 | + } | |
| 2228 | + } | |
| 2229 | + | |
| 2230 | + /** | |
| 1954 | 2231 | * Medthod add_wp_site() |
| 1955 | 2232 | * |
| 1956 | 2233 | * Add new Child Site. |
| 1957 | 2234 | * |
| @@ -1965,23 +2242,71 @@ | ||
| 1965 | 2242 | * @uses \MainWP\Dashboard\MainWP_DB_Common::get_group_by_name() |
| 1966 | 2243 | * @uses \MainWP\Dashboard\MainWP_DB::add_website() |
| 1967 | 2244 | * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1968 | 2245 | * @uses \MainWP\Dashboard\MainWP_Exception |
| 2246 | + * @uses \MainWP\Dashboard\MainWP_Sync::get_wp_icon() | |
| 1969 | 2247 | * @uses \MainWP\Dashboard\MainWP_Sync::sync_information_array() |
| 1970 | 2248 | * @uses \MainWP\Dashboard\MainWP_System_Utility::get_openssl_conf() |
| 1971 | 2249 | * @uses \MainWP\Dashboard\MainWP_Utility::esc_content() |
| 1972 | 2250 | */ |
| 1973 | - public static function add_wp_site( $website, $params = array(), &$output = array() ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 2251 | + public static function add_wp_site( $website, $params = array(), &$output = array() ) { //phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. | |
| 1974 | 2252 | $error = ''; |
| 1975 | 2253 | $message = ''; |
| 1976 | 2254 | $id = 0; |
| 1977 | - $fetch_data = null; | |
| 2255 | + $existed_id = 0; | |
| 1978 | 2256 | |
| 2257 | + $error_category = 'unknown'; | |
| 2258 | + $error_code = ''; | |
| 2259 | + $connection_step = ''; | |
| 2260 | + | |
| 1979 | 2261 | if ( $website ) { |
| 1980 | 2262 | $error = esc_html__( 'The site is already connected to your MainWP Dashboard', 'mainwp' ); |
| 2263 | + if ( is_array( $website ) && ! empty( $website[0] ) && is_object( $website[0] ) ) { | |
| 2264 | + $existed_id = $website[0]->id; | |
| 2265 | + } elseif ( is_object( $website ) && property_exists( $website, 'id' ) ) { | |
| 2266 | + $existed_id = $website->id; | |
| 2267 | + } | |
| 2268 | + $error_category = 'already_connected'; | |
| 1981 | 2269 | } else { |
| 1982 | 2270 | try { |
| 1983 | - if ( MainWP_Connect_Lib::is_use_fallback_sec_lib( $website ) ) { | |
| 2271 | + | |
| 2272 | + /** | |
| 2273 | + * Filter to skip generating connection keys when adding a site in PHPUnit tests. | |
| 2274 | + * | |
| 2275 | + * This filter fires before connection keys are generated, allowing tests to | |
| 2276 | + * bypass RSA key generation when testing site-add functionality. | |
| 2277 | + * | |
| 2278 | + * SECURITY WARNING - TEST ONLY: | |
| 2279 | + * This filter ONLY fires when ALL of the following conditions are met: | |
| 2280 | + * 1. MAINWP_TESTING_MODE constant is defined and true. | |
| 2281 | + * 2. A PHPUnit test harness constant is present (WP_TESTS_DOMAIN, | |
| 2282 | + * PHPUNIT_COMPOSER_INSTALL, or WP_TESTS_DIR). | |
| 2283 | + * | |
| 2284 | + * These checks prevent malicious code from defining MAINWP_TESTING_MODE | |
| 2285 | + * in production to bypass connection key generation. | |
| 2286 | + * | |
| 2287 | + * IMPORTANT: MAINWP_TESTING_MODE must ONLY be defined in the PHPUnit bootstrap | |
| 2288 | + * file (tests/bootstrap.php). Defining it in production code, wp-config.php, | |
| 2289 | + * or plugin files would create a security vulnerability by allowing connection | |
| 2290 | + * key generation to be bypassed. | |
| 2291 | + * | |
| 2292 | + * @since 6.2.1 | |
| 2293 | + * | |
| 2294 | + * @param bool $skip_keys Whether to skip connection key generation. | |
| 2295 | + * @param object $website Website object being added. | |
| 2296 | + * @param array $params Site connection parameters. | |
| 2297 | + * | |
| 2298 | + * @return bool True to skip connection key generation, false to generate keys normally. | |
| 2299 | + */ | |
| 2300 | + $is_phpunit_env = defined( 'WP_TESTS_DOMAIN' ) || defined( 'PHPUNIT_COMPOSER_INSTALL' ) || ( defined( 'WP_TESTS_DIR' ) && WP_TESTS_DIR ); | |
| 2301 | + | |
| 2302 | + $skip_keys = false; | |
| 2303 | + | |
| 2304 | + if ( defined( 'MAINWP_TESTING_MODE' ) && MAINWP_TESTING_MODE && $is_phpunit_env ) { | |
| 2305 | + $skip_keys = apply_filters( 'mainwp_add_site_skip_key_generation', false, $website, $params ); | |
| 2306 | + } | |
| 2307 | + | |
| 2308 | + if ( ! $skip_keys && MainWP_Connect_Lib::is_use_fallback_sec_lib( $website ) ) { | |
| 1984 | 2309 | $details = MainWP_Connect_Lib::instance()->create_connect_keys(); |
| 1985 | 2310 | if ( is_array( $details ) ) { |
| 1986 | 2311 | $pubkey = $details['pub']; |
| 1987 | 2312 | $privkey = $details['priv']; |
| @@ -1988,9 +2313,9 @@ | ||
| 1988 | 2313 | } else { |
| 1989 | 2314 | $privkey = '-1'; |
| 1990 | 2315 | $pubkey = '-1'; |
| 1991 | 2316 | } |
| 1992 | - } elseif ( function_exists( 'openssl_pkey_new' ) ) { | |
| 2317 | + } elseif ( ! $skip_keys && function_exists( 'openssl_pkey_new' ) ) { | |
| 1993 | 2318 | $conf = array( 'private_key_bits' => 2048 ); |
| 1994 | 2319 | $conf_loc = MainWP_System_Utility::get_openssl_conf(); |
| 1995 | 2320 | if ( ! empty( $conf_loc ) ) { |
| 1996 | 2321 | $conf['config'] = $conf_loc; |
| @@ -2011,9 +2336,14 @@ | ||
| 2011 | 2336 | $addUniqueId = isset( $params['unique_id'] ) ? $params['unique_id'] : ''; |
| 2012 | 2337 | $http_user = isset( $params['http_user'] ) ? $params['http_user'] : ''; |
| 2013 | 2338 | $http_pass = isset( $params['http_pass'] ) ? $params['http_pass'] : ''; |
| 2014 | 2339 | $force_use_ipv4 = isset( $params['force_use_ipv4'] ) ? $params['force_use_ipv4'] : null; |
| 2015 | - $information = MainWP_Connect::fetch_url_not_authed( | |
| 2340 | + | |
| 2341 | + MainWP_Logger::instance()->debug( ' :: register site :: ' . $url ); | |
| 2342 | + | |
| 2343 | + $connection_step = 'handshake'; | |
| 2344 | + | |
| 2345 | + $information = MainWP_Connect::fetch_url_not_authed( | |
| 2016 | 2346 | $url, |
| 2017 | 2347 | $params['wpadmin'], |
| 2018 | 2348 | 'register', |
| 2019 | 2349 | array( |
| @@ -2019,8 +2349,9 @@ | ||
| 2019 | 2349 | array( |
| 2020 | 2350 | 'pubkey' => $pubkey, |
| 2021 | 2351 | 'server' => get_admin_url(), |
| 2022 | 2352 | 'uniqueId' => $addUniqueId, |
| 2353 | + 'userpwd' => isset( $params['adminpwd'] ) ? $params['adminpwd'] : '', // require urlencoded. | |
| 2023 | 2354 | ), |
| 2024 | 2355 | false, |
| 2025 | 2356 | $verifyCertificate, |
| 2026 | 2357 | $http_user, |
| @@ -2029,16 +2360,34 @@ | ||
| 2029 | 2360 | array( 'force_use_ipv4' => $force_use_ipv4 ), |
| 2030 | 2361 | $output |
| 2031 | 2362 | ); |
| 2032 | 2363 | |
| 2033 | - $fetch_data = isset( $output['fetch_data'] ) ? $output['fetch_data'] : ''; | |
| 2034 | - | |
| 2035 | 2364 | if ( isset( $information['error'] ) && '' !== $information['error'] ) { |
| 2036 | 2365 | $error = MainWP_Utility::esc_content( $information['error'] ); |
| 2366 | + if ( is_array( $output ) ) { | |
| 2367 | + if ( ! empty( $output['error_category'] ) ) { | |
| 2368 | + $error_category = $output['error_category']; | |
| 2369 | + } | |
| 2370 | + if ( ! empty( $output['connection_step'] ) ) { | |
| 2371 | + $connection_step = $output['connection_step']; | |
| 2372 | + } | |
| 2373 | + if ( ! empty( $output['error_code'] ) ) { | |
| 2374 | + $error_code = $output['error_code']; | |
| 2375 | + } | |
| 2376 | + } | |
| 2037 | 2377 | } elseif ( isset( $information['register'] ) && 'OK' === $information['register'] ) { |
| 2038 | - $groupids = array(); | |
| 2039 | - $groupnames = array(); | |
| 2040 | - $tmpArr = array(); | |
| 2378 | + $reported_site_url = isset( $information['siteurl'] ) ? trim( wp_unslash( $information['siteurl'] ) ) : ''; | |
| 2379 | + | |
| 2380 | + $corrected_url = static::maybe_correct_www_variant_url( $params['url'], $reported_site_url ); | |
| 2381 | + if ( $corrected_url !== $params['url'] ) { | |
| 2382 | + MainWP_Logger::instance()->debug( ' :: register site :: corrected www variant from ' . $params['url'] . ' to ' . $corrected_url ); | |
| 2383 | + $params['url'] = $corrected_url; | |
| 2384 | + } | |
| 2385 | + | |
| 2386 | + $connection_step = 'save_site'; | |
| 2387 | + $groupids = array(); | |
| 2388 | + $groupnames = array(); | |
| 2389 | + $tmpArr = array(); | |
| 2041 | 2390 | if ( isset( $params['groupids'] ) && is_array( $params['groupids'] ) ) { |
| 2042 | 2391 | foreach ( $params['groupids'] as $group ) { |
| 2043 | 2392 | if ( is_numeric( $group ) ) { |
| 2044 | 2393 | $groupids[] = $group; |
| @@ -2078,77 +2427,103 @@ | ||
| 2078 | 2427 | if ( ! isset( $information['uniqueId'] ) || empty( $information['uniqueId'] ) ) { |
| 2079 | 2428 | $addUniqueId = ''; |
| 2080 | 2429 | } |
| 2081 | 2430 | |
| 2082 | - $http_user = isset( $params['http_user'] ) ? $params['http_user'] : ''; | |
| 2083 | - $http_pass = isset( $params['http_pass'] ) ? $params['http_pass'] : ''; | |
| 2431 | + $http_user = isset( $params['http_user'] ) ? $params['http_user'] : ''; | |
| 2432 | + $http_pass = isset( $params['http_pass'] ) ? $params['http_pass'] : ''; | |
| 2084 | 2433 | |
| 2085 | - /** | |
| 2086 | - * Current user global. | |
| 2087 | - * | |
| 2088 | - * @global string | |
| 2089 | - */ | |
| 2090 | - global $current_user; | |
| 2434 | + /** | |
| 2435 | + * Current user global. | |
| 2436 | + * | |
| 2437 | + * @global string | |
| 2438 | + */ | |
| 2439 | + global $current_user; | |
| 2091 | 2440 | |
| 2092 | - $others = array( | |
| 2093 | - 'groupids' => $groupids, | |
| 2094 | - 'groupnames' => $groupnames, | |
| 2095 | - 'verifyCertificate' => $verifyCertificate, | |
| 2096 | - 'addUniqueId' => $addUniqueId, | |
| 2097 | - 'http_user' => $http_user, | |
| 2098 | - 'http_pass' => $http_pass, | |
| 2099 | - 'sslVersion' => $sslVersion, | |
| 2100 | - ); | |
| 2441 | + $others = array( | |
| 2442 | + 'groupids' => $groupids, | |
| 2443 | + 'groupnames' => $groupnames, | |
| 2444 | + 'verifyCertificate' => $verifyCertificate || false === $verifyCertificate ? 2 : 0, // 2 use global. | |
| 2445 | + 'addUniqueId' => $addUniqueId, | |
| 2446 | + 'http_user' => $http_user, | |
| 2447 | + 'http_pass' => $http_pass, | |
| 2448 | + 'sslVersion' => $sslVersion, | |
| 2449 | + // Steers the handshake above; passing it on is what gets it stored, | |
| 2450 | + // instead of the column waiting for the first edit of the site. | |
| 2451 | + 'force_use_ipv4' => $force_use_ipv4, | |
| 2452 | + ); | |
| 2101 | 2453 | |
| 2102 | - $id = MainWP_DB::instance()->add_website( $current_user->ID, $params['name'], $params['url'], $params['wpadmin'], base64_encode( $pubkey ), base64_encode( $privkey ), $others ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode() used for http encoding compatible. | |
| 2454 | + $id = MainWP_DB::instance()->add_website( $current_user->ID, $params['name'], $params['url'], $params['wpadmin'], base64_encode( $pubkey ), base64_encode( $privkey ), $others ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode() used for http encoding compatible. | |
| 2103 | 2455 | |
| 2104 | - if ( $id && isset( $params['clientid'] ) ) { | |
| 2105 | - MainWP_DB::instance()->update_website_values( $id, array( 'client_id' => intval( $params['clientid'] ) ) ); | |
| 2106 | - } | |
| 2456 | + if ( $id && isset( $params['clientid'] ) ) { | |
| 2457 | + MainWP_DB::instance()->update_website_values( $id, array( 'client_id' => intval( $params['clientid'] ) ) ); | |
| 2458 | + } | |
| 2107 | 2459 | |
| 2108 | - if ( $id ) { | |
| 2109 | - $obj_site = (object) array( 'id' => $id ); | |
| 2110 | - MainWP_DB::instance()->update_website_option( $obj_site, 'added_timestamp', time() ); | |
| 2111 | - MainWP_DB::instance()->update_website_option( $obj_site, 'signature_algo', 9999 ); // use global. | |
| 2112 | - $icon_info = 'uploaded:' . $params['uploaded_site_icon'] . ';selected:' . $params['selected_site_icon'] . ';color:' . $params['cust_icon_color']; | |
| 2113 | - MainWP_DB::instance()->update_website_option( $obj_site, 'cust_site_icon_info', $icon_info ); | |
| 2460 | + if ( $id ) { | |
| 2461 | + $obj_site = (object) array( 'id' => $id ); | |
| 2462 | + $uploaded_site_icon = isset( $params['uploaded_site_icon'] ) | |
| 2463 | + ? $params['uploaded_site_icon'] | |
| 2464 | + : ''; | |
| 2465 | + $selected_site_icon = isset( $params['selected_site_icon'] ) | |
| 2466 | + ? $params['selected_site_icon'] | |
| 2467 | + : ''; | |
| 2468 | + $cust_icon_color = isset( $params['cust_icon_color'] ) | |
| 2469 | + ? $params['cust_icon_color'] | |
| 2470 | + : ''; | |
| 2471 | + MainWP_DB::instance()->update_website_option( $obj_site, 'added_timestamp', time() ); | |
| 2472 | + MainWP_DB::instance()->update_website_option( $obj_site, 'signature_algo', 9999 ); // use global. | |
| 2473 | + $icon_info = 'uploaded:' . $uploaded_site_icon | |
| 2474 | + . ';selected:' . $selected_site_icon | |
| 2475 | + . ';color:' . $cust_icon_color; | |
| 2476 | + MainWP_DB::instance()->update_website_option( $obj_site, 'cust_site_icon_info', $icon_info ); | |
| 2477 | + } | |
| 2478 | + | |
| 2479 | + if ( isset( $params['qsw_page'] ) && $params['qsw_page'] ) { | |
| 2480 | + set_transient( 'mainwp_transient_just_connected_site_id', $id, HOUR_IN_SECONDS ); | |
| 2481 | + /* translators: 1: Opening div tag, 2: Site name wrapped in strong tag, 3: Closing div tag, 4: Continue button anchor tag. */ | |
| 2482 | + $message = sprintf( esc_html__( '%4$s%1$sCongratulations you have connected %2$s.%3$s After finishing the Quick Setup Wizard, you can add additional sites from the Add New Sites page. Proceeding to the next step in 3 seconds...', 'mainwp' ), '<div class="ui header">', '<strong>' . esc_html( $params['name'] ) . '</strong>', '</div>', '<a href="admin.php?page=mainwp-setup&step=monitoring" class="ui mini basic green right floated button">Continue</a>' ); | |
| 2483 | + } else { | |
| 2484 | + /* translators: 1: Opening anchor tag for dashboard link, 2: Closing anchor tag, 3: Line break HTML tag. */ | |
| 2485 | + $message = sprintf( esc_html__( 'Site successfully added - Visit the Site\'s %1$sDashboard%2$s now.%3$s', 'mainwp' ), '<a href="admin.php?page=managesites&dashboard=' . $id . '" style="text-decoration: none;" title="' . esc_html__( 'Dashboard', 'mainwp' ) . '">', '</a>', '<br/>' ); | |
| 2486 | + } | |
| 2487 | + | |
| 2488 | + $website = MainWP_DB::instance()->get_website_by_id( $id ); | |
| 2489 | + | |
| 2490 | + if ( $website ) { // to fix. | |
| 2491 | + | |
| 2492 | + if ( ! empty( $information['regverify'] ) ) { | |
| 2493 | + MainWP_DB::instance()->update_website_option( $website, 'register_verify_key', $information['regverify'] ); | |
| 2114 | 2494 | } |
| 2115 | 2495 | |
| 2116 | - if ( isset( $params['qsw_page'] ) && $params['qsw_page'] ) { | |
| 2117 | - set_transient( 'mainwp_transient_just_connected_site_id', $id, HOUR_IN_SECONDS ); | |
| 2118 | - $message = sprintf( esc_html__( '%1$sCongratulations you have connected %2$s.%3$s After finishing the Quick Setup Wizard, you can add additional sites from the Add New Sites page.', 'mainwp' ), '<div class="ui header">', '<strong>' . esc_html( $params['name'] ) . '</strong>', '</div>' ); | |
| 2119 | - } else { | |
| 2120 | - $message = sprintf( esc_html__( 'Site successfully added - Visit the Site\'s %1$sDashboard%2$s now.', 'mainwp' ), '<a href="admin.php?page=managesites&dashboard=' . $id . '" style="text-decoration: none;" title="' . esc_html__( 'Dashboard', 'mainwp' ) . '">', '</a>' ); | |
| 2121 | - } | |
| 2496 | + /** | |
| 2497 | + * Fires immediately after a new website is added. | |
| 2498 | + * | |
| 2499 | + * @since 4.5.1.1 | |
| 2500 | + * | |
| 2501 | + * @param object $website website data. | |
| 2502 | + * @param array $information The array of information data . | |
| 2503 | + */ | |
| 2504 | + do_action( 'mainwp_site_added', $website, $information ); | |
| 2122 | 2505 | |
| 2123 | - $website = MainWP_DB::instance()->get_website_by_id( $id ); | |
| 2506 | + /** | |
| 2507 | + * New site added | |
| 2508 | + * | |
| 2509 | + * Fires after adding a website to MainWP Dashboard. | |
| 2510 | + * | |
| 2511 | + * @param int $id Child site ID. | |
| 2512 | + * | |
| 2513 | + * @since 3.4 | |
| 2514 | + */ | |
| 2515 | + do_action( 'mainwp_added_new_site', $id, $website ); | |
| 2124 | 2516 | |
| 2125 | - if ( $website ) { // to fix. | |
| 2126 | - /** | |
| 2127 | - * Fires immediately after a new website is added. | |
| 2128 | - * | |
| 2129 | - * @since 4.5.1.1 | |
| 2130 | - * | |
| 2131 | - * @param object $website website data. | |
| 2132 | - * @param array $information The array of information data . | |
| 2133 | - */ | |
| 2134 | - do_action( 'mainwp_site_added', $website, $information ); | |
| 2517 | + MainWP_Sync::sync_init_empty_values( $website ); | |
| 2135 | 2518 | |
| 2136 | - /** | |
| 2137 | - * New site added | |
| 2138 | - * | |
| 2139 | - * Fires after adding a website to MainWP Dashboard. | |
| 2140 | - * | |
| 2141 | - * @param int $id Child site ID. | |
| 2142 | - * | |
| 2143 | - * @since 3.4 | |
| 2144 | - */ | |
| 2145 | - do_action( 'mainwp_added_new_site', $id, $website ); | |
| 2519 | + $connection_step = 'post_add_sync'; | |
| 2146 | 2520 | |
| 2147 | - MainWP_Sync::sync_information_array( $website, $information ); | |
| 2148 | - } | |
| 2521 | + MainWP_Sync::sync_information_array( $website, $information ); | |
| 2522 | + self::maybe_fetch_initial_site_favicon( $id, $params ); | |
| 2523 | + } | |
| 2149 | 2524 | } else { |
| 2150 | - $error = sprintf( esc_html__( 'Undefined error occurred. Please try again. For additional help, contact the MainWP Support.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/potential-issues/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. | |
| 2525 | + $error = sprintf( esc_html__( 'Undefined error occurred. Please try again. For additional help, contact the MainWP Support.', 'mainwp' ), '<a href="https://docs.mainwp.com/troubleshooting/potential-issues" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. | |
| 2151 | 2526 | } |
| 2152 | 2527 | } catch ( MainWP_Exception $e ) { |
| 2153 | 2528 | if ( 'HTTPERROR' === $e->getMessage() ) { |
| 2154 | 2529 | $error = 'HTTP error' . ( null !== $e->get_message_extra() ? ' - ' . $e->get_message_extra() : '' ); |
| @@ -2156,13 +2531,42 @@ | ||
| 2156 | 2531 | $error = MainWP_Error_Helper::get_error_not_detected_connect(); |
| 2157 | 2532 | } else { |
| 2158 | 2533 | $error = $e->getMessage(); |
| 2159 | 2534 | } |
| 2160 | - $fetch_data = $e->get_data(); | |
| 2161 | 2535 | } |
| 2162 | 2536 | } |
| 2163 | 2537 | |
| 2164 | - return array( $message, $error, $id, $fetch_data ); | |
| 2538 | + $source_screen = 'manage_sites'; | |
| 2539 | + $flow_type = ! empty( $_POST['bulk'] ) ? 'bulk' : 'single'; //phpcs:ignore -- NOSONAR -nonce ok. | |
| 2540 | + if ( ! empty( $_POST['qsw_page'] ) ) { //phpcs:ignore -- NOSONAR -nonce ok. | |
| 2541 | + $flow_type = 'wizard'; | |
| 2542 | + $source_screen = 'onboarding_wizard'; | |
| 2543 | + } | |
| 2544 | + if ( 'bulk' === $flow_type ) { | |
| 2545 | + $source_screen = 'quick_add_modal'; | |
| 2546 | + } | |
| 2547 | + | |
| 2548 | + $telem_info = array( | |
| 2549 | + 'flow_type' => $flow_type, | |
| 2550 | + 'source_screen' => $source_screen, | |
| 2551 | + ); | |
| 2552 | + | |
| 2553 | + if ( empty( $id ) ) { | |
| 2554 | + $telem_info['error_message'] = $error; | |
| 2555 | + $telem_info['error_category'] = $error_category; | |
| 2556 | + $telem_info['error_code'] = $error_code; | |
| 2557 | + | |
| 2558 | + if ( ! empty( $connection_step ) ) { | |
| 2559 | + $telem_info['connection_step'] = $connection_step; | |
| 2560 | + } | |
| 2561 | + if ( is_array( $output ) && ! empty( $output['http_status'] ) ) { | |
| 2562 | + $telem_info['http_status'] = $output['http_status']; | |
| 2563 | + } | |
| 2564 | + } | |
| 2565 | + | |
| 2566 | + do_action( 'mainwp_after_add_site', array( $message, $error, $id, $existed_id ), $website, $params, $output, $telem_info ); | |
| 2567 | + | |
| 2568 | + return array( $message, $error, $id, $existed_id ); | |
| 2165 | 2569 | } |
| 2166 | 2570 | |
| 2167 | 2571 | /** |
| 2168 | 2572 | * Method update_wp_site() |