| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Manage Sites Page. |
| 4 |
* |
| 5 |
* @package MainWP/Dashboard |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace MainWP\Dashboard; |
| 9 |
|
| 10 |
/** |
| 11 |
* Class MainWP_Manage_Sites |
| 12 |
* |
| 13 |
* @package MainWP\Dashboard |
| 14 |
*/ |
| 15 |
class MainWP_Manage_Sites { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. |
| 16 |
|
| 17 |
/** |
| 18 |
* The single instance of the class |
| 19 |
* |
| 20 |
* @var mixed Default null |
| 21 |
*/ |
| 22 |
protected static $instance = null; |
| 23 |
|
| 24 |
/** |
| 25 |
* Private static variable to hold the total sites. |
| 26 |
* |
| 27 |
* @var mixed Default null |
| 28 |
*/ |
| 29 |
private static $total_sites = null; |
| 30 |
|
| 31 |
/** |
| 32 |
* Get instance. |
| 33 |
* |
| 34 |
* @return static::singlton |
| 35 |
*/ |
| 36 |
public static function get_instance() { |
| 37 |
if ( null === static::$instance ) { |
| 38 |
static::$instance = new self(); |
| 39 |
} |
| 40 |
return static::$instance; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* MainWP_Setup_Wizard constructor. |
| 45 |
* |
| 46 |
* Run each time the class is called. |
| 47 |
*/ |
| 48 |
public function __construct() { |
| 49 |
$this->get_total_sites(); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Get instance. |
| 54 |
* |
| 55 |
* @return static::singlton |
| 56 |
*/ |
| 57 |
public static function get_total_sites() { |
| 58 |
if ( null === static::$total_sites ) { |
| 59 |
static::$total_sites = MainWP_DB::instance()->get_websites_count(); |
| 60 |
} |
| 61 |
return static::$total_sites; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Get Class Name |
| 66 |
* |
| 67 |
* @return string __CLASS__ |
| 68 |
*/ |
| 69 |
public static function get_class_name() { |
| 70 |
return __CLASS__; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Sub pages |
| 75 |
* |
| 76 |
* @static |
| 77 |
* @var array $subPages Sub pages. |
| 78 |
*/ |
| 79 |
public static $subPages; |
| 80 |
|
| 81 |
/** |
| 82 |
* Current page. |
| 83 |
* |
| 84 |
* @static |
| 85 |
* @var string $page Current page. |
| 86 |
*/ |
| 87 |
public static $page; |
| 88 |
|
| 89 |
/** |
| 90 |
* Widgets to enable. |
| 91 |
* |
| 92 |
* @static |
| 93 |
* @var array $enable_widgets Widgets to enable. |
| 94 |
*/ |
| 95 |
private static $enable_widgets = array( |
| 96 |
'overview' => true, |
| 97 |
'recent_posts' => true, |
| 98 |
'recent_pages' => true, |
| 99 |
'security_issues' => true, |
| 100 |
'manage_backups' => true, |
| 101 |
'plugins' => true, |
| 102 |
'themes' => true, |
| 103 |
'notes' => true, |
| 104 |
'site_note' => true, |
| 105 |
'client_info' => true, |
| 106 |
'non_mainwp_changes' => true, |
| 107 |
|
| 108 |
); |
| 109 |
|
| 110 |
/** |
| 111 |
* Magage Sites table |
| 112 |
* |
| 113 |
* @var $sitesTable Magage Sites table. |
| 114 |
*/ |
| 115 |
public static $sitesTable; |
| 116 |
|
| 117 |
/** |
| 118 |
* Method init() |
| 119 |
* |
| 120 |
* Initiate Manage Sites. |
| 121 |
* |
| 122 |
* @uses \MainWP\Dashboard\MainWP_Security_Issues::get_class_name() |
| 123 |
*/ |
| 124 |
public static function init() { |
| 125 |
/** |
| 126 |
* This hook allows you to render the Sites page header via the 'mainwp-pageheader-sites' action. |
| 127 |
* |
| 128 |
* @link http://codex.mainwp.com/#mainwp-pageheader-sites |
| 129 |
* |
| 130 |
* This hook is normally used in the same context of 'mainwp-getsubpages-sites' |
| 131 |
* @link http://codex.mainwp.com/#mainwp-getsubpages-sites |
| 132 |
* |
| 133 |
* @see \MainWP_Manage_Sites::render_header |
| 134 |
*/ |
| 135 |
add_action( 'mainwp-pageheader-sites', array( static::get_class_name(), 'render_header' ) ); // @deprecated Use 'mainwp_pageheader_sites' instead. |
| 136 |
add_action( 'mainwp_pageheader_sites', array( static::get_class_name(), 'render_header' ) ); |
| 137 |
|
| 138 |
/** |
| 139 |
* This hook allows you to render the Sites page footer via the 'mainwp-pagefooter-sites' action. |
| 140 |
* |
| 141 |
* @link http://codex.mainwp.com/#mainwp-pagefooter-sites |
| 142 |
* |
| 143 |
* This hook is normally used in the same context of 'mainwp-getsubpages-sites' |
| 144 |
* @link http://codex.mainwp.com/#mainwp-getsubpages-sites |
| 145 |
* |
| 146 |
* @see \MainWP_Manage_Sites::render_footer |
| 147 |
*/ |
| 148 |
add_action( 'mainwp-pagefooter-sites', array( static::get_class_name(), 'render_footer' ) ); // @deprecated Use 'mainwp_pagefooter_sites' instead. |
| 149 |
add_action( 'mainwp_pagefooter_sites', array( static::get_class_name(), 'render_footer' ) ); |
| 150 |
|
| 151 |
add_action( 'mainwp_securityissues_sites', array( MainWP_Security_Issues::get_class_name(), 'render' ) ); |
| 152 |
add_action( 'mainwp_manage_sites_edit', array( static::get_class_name(), 'on_edit_site' ) ); |
| 153 |
|
| 154 |
// Hook the Help Sidebar content. |
| 155 |
add_action( 'mainwp_help_sidebar_content', array( static::get_class_name(), 'mainwp_help_content' ) ); |
| 156 |
MainWP_Post_Handler::instance()->add_action( 'mainwp_managesites_add_edit_site_upload_site_icon', array( static::class, 'ajax_upload_icon' ) ); |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* Method on_screen_layout_columns() |
| 161 |
* |
| 162 |
* Columns to display. |
| 163 |
* |
| 164 |
* @param mixed $columns Columns to display. |
| 165 |
* @param mixed $screen Current page. |
| 166 |
* |
| 167 |
* @return array $columns |
| 168 |
*/ |
| 169 |
public static function on_screen_layout_columns( $columns, $screen ) { |
| 170 |
if ( $screen === static::$page ) { |
| 171 |
$columns[ static::$page ] = 3; |
| 172 |
} |
| 173 |
|
| 174 |
return $columns; |
| 175 |
} |
| 176 |
|
| 177 |
/** |
| 178 |
* Initiate menu. |
| 179 |
* |
| 180 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::init_menu() |
| 181 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::init_left_menu() |
| 182 |
* @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() |
| 183 |
* @uses \MainWP\Dashboard\MainWP_Site_Open::get_class_name() |
| 184 |
* @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit() |
| 185 |
*/ |
| 186 |
public static function init_menu() { // phpcs:ignore -- NOSONAR - complex. |
| 187 |
static::$page = MainWP_Manage_Sites_View::init_menu(); |
| 188 |
add_action( 'load-' . static::$page, array( static::get_class_name(), 'on_load_page' ) ); |
| 189 |
|
| 190 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 191 |
if ( isset( $_REQUEST['dashboard'] ) ) { |
| 192 |
// phpcs:enable |
| 193 |
/** |
| 194 |
* Current user global. |
| 195 |
* |
| 196 |
* @global string |
| 197 |
*/ |
| 198 |
global $current_user; |
| 199 |
|
| 200 |
delete_user_option( $current_user->ID, 'screen_layout_toplevel_page_managesites' ); |
| 201 |
add_filter( 'screen_layout_columns', array( static::get_class_name(), 'on_screen_layout_columns' ), 10, 2 ); |
| 202 |
|
| 203 |
$val = get_user_option( 'screen_layout_' . static::$page ); |
| 204 |
if ( ! MainWP_Utility::ctype_digit( $val ) ) { |
| 205 |
global $current_user; |
| 206 |
update_user_option( $current_user->ID, 'screen_layout_' . static::$page, 2, true ); |
| 207 |
} |
| 208 |
} |
| 209 |
add_submenu_page( |
| 210 |
'mainwp_tab', |
| 211 |
__( 'Sites', 'mainwp' ), |
| 212 |
'<div class="mainwp-hidden">' . esc_html__( 'Sites', 'mainwp' ) . '</div>', |
| 213 |
'read', |
| 214 |
'SiteOpen', |
| 215 |
array( |
| 216 |
MainWP_Site_Open::get_class_name(), |
| 217 |
'render', |
| 218 |
) |
| 219 |
); |
| 220 |
add_submenu_page( |
| 221 |
'mainwp_tab', |
| 222 |
__( 'Sites', 'mainwp' ), |
| 223 |
'<div class="mainwp-hidden">' . esc_html__( 'Sites', 'mainwp' ) . '</div>', |
| 224 |
'read', |
| 225 |
'SiteRestore', |
| 226 |
array( |
| 227 |
MainWP_Site_Open::get_class_name(), |
| 228 |
'render_restore', |
| 229 |
) |
| 230 |
); |
| 231 |
|
| 232 |
/** |
| 233 |
* Sites Subpages |
| 234 |
* |
| 235 |
* Filters subpages for the Sites page. |
| 236 |
* |
| 237 |
* @since Unknown |
| 238 |
*/ |
| 239 |
$sub_pages = array(); |
| 240 |
$sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-sites', array( $sub_pages ), '4.0.7.2', 'mainwp_getsubpages_sites' ); // @deprecated Use 'mainwp_getsubpages_sites' instead. NOSONAR - not IP. |
| 241 |
static::$subPages = apply_filters( 'mainwp_getsubpages_sites', $sub_pages ); |
| 242 |
|
| 243 |
if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { |
| 244 |
foreach ( static::$subPages as $subPage ) { |
| 245 |
if ( ! empty( $subPage['no_submenu_page'] ) ) { |
| 246 |
continue; |
| 247 |
} |
| 248 |
if ( ! isset( $subPage['slug'] ) && ! isset( $subPage['title'] ) ) { |
| 249 |
continue; |
| 250 |
} |
| 251 |
if ( MainWP_Menu::is_disable_menu_item( 2, 'ManageSites' . $subPage['slug'] ) ) { |
| 252 |
continue; |
| 253 |
} |
| 254 |
$_page = add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'ManageSites' . $subPage['slug'], $subPage['callback'] ); |
| 255 |
add_action( 'load-' . $_page, array( static::get_class_name(), 'on_load_subpages' ), 9 ); |
| 256 |
if ( isset( $subPage['on_load_callback'] ) && ! empty( $subPage['on_load_callback'] ) ) { |
| 257 |
add_action( 'load-' . $_page, $subPage['on_load_callback'] ); |
| 258 |
} |
| 259 |
} |
| 260 |
} |
| 261 |
|
| 262 |
MainWP_Manage_Sites_View::init_left_menu( static::$subPages ); |
| 263 |
} |
| 264 |
|
| 265 |
/** |
| 266 |
* Initiate sub page menu. |
| 267 |
* |
| 268 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::init_subpages_menu() |
| 269 |
*/ |
| 270 |
public static function init_subpages_menu() { |
| 271 |
MainWP_Manage_Sites_View::init_subpages_menu( static::$subPages ); |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* Method on_load_page() |
| 276 |
* |
| 277 |
* Run on page load. |
| 278 |
* |
| 279 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_List_Table |
| 280 |
* @uses \MainWP\Dashboard\MainWP_System::enqueue_postbox_scripts() |
| 281 |
*/ |
| 282 |
public static function on_load_page() { |
| 283 |
|
| 284 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 285 |
if ( isset( $_REQUEST['dashboard'] ) ) { |
| 286 |
static::on_load_page_dashboard(); |
| 287 |
return; |
| 288 |
} |
| 289 |
|
| 290 |
MainWP_System::enqueue_postbox_scripts(); |
| 291 |
|
| 292 |
if ( isset( $_REQUEST['do'] ) ) { |
| 293 |
if ( 'new' === $_REQUEST['do'] ) { |
| 294 |
return; |
| 295 |
} |
| 296 |
} elseif ( isset( $_GET['id'] ) || isset( $_GET['scanid'] ) || isset( $_GET['backupid'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 297 |
return; |
| 298 |
} |
| 299 |
// phpcs:enable |
| 300 |
|
| 301 |
$sitesViewMode = MainWP_Utility::get_siteview_mode(); |
| 302 |
|
| 303 |
add_filter( 'mainwp_header_actions_right', array( static::get_class_name(), 'screen_options' ), 10, 2 ); |
| 304 |
if ( 'grid' !== $sitesViewMode ) { |
| 305 |
static::load_sites_table(); |
| 306 |
} else { |
| 307 |
MainWP_Manage_Screenshots::get_instance(); // to init hooks. |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
|
| 312 |
/** |
| 313 |
* Method load_sites_table() |
| 314 |
* |
| 315 |
* Load sites table. |
| 316 |
*/ |
| 317 |
public static function load_sites_table() { |
| 318 |
if ( empty( static::$sitesTable ) ) { |
| 319 |
static::$sitesTable = new MainWP_Manage_Sites_List_Table(); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
/** |
| 325 |
* Method on_load_sunpages() |
| 326 |
* |
| 327 |
* Run on subpage load. |
| 328 |
* |
| 329 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 330 |
*/ |
| 331 |
public static function on_load_subpages() { |
| 332 |
if ( ! empty( $_GET['id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 333 |
MainWP_System_Utility::set_current_wpid( intval( $_GET['id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
/** |
| 338 |
* Method render_header() |
| 339 |
* |
| 340 |
* Render page header. |
| 341 |
* |
| 342 |
* @param string $shownPage Current page slug. |
| 343 |
* |
| 344 |
* @uses \MainWP\Dashboard\MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook() |
| 345 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_header() |
| 346 |
*/ |
| 347 |
public static function render_header( $shownPage = '' ) { |
| 348 |
MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook(); |
| 349 |
MainWP_Manage_Sites_View::render_header( $shownPage, static::$subPages ); |
| 350 |
} |
| 351 |
|
| 352 |
/** |
| 353 |
* Method render_footer() |
| 354 |
* |
| 355 |
* Render page footer. |
| 356 |
*/ |
| 357 |
public static function render_footer() { |
| 358 |
MainWP_Manage_Sites_View::render_footer(); |
| 359 |
} |
| 360 |
|
| 361 |
/** |
| 362 |
* Method screen_options() |
| 363 |
* |
| 364 |
* Create Page Settings button. |
| 365 |
* |
| 366 |
* @param mixed $input Page Settings button HTML. |
| 367 |
* |
| 368 |
* @return mixed Page Settings button. |
| 369 |
*/ |
| 370 |
public static function screen_options( $input ) { |
| 371 |
return $input . |
| 372 |
'<a class="ui button basic icon" onclick="mainwp_manage_sites_screen_options(); return false;" data-inverted="" data-position="bottom right" href="#" target="_blank" data-tooltip="' . esc_html__( 'Page Settings', 'mainwp' ) . '"> |
| 373 |
<i class="cog icon"></i> |
| 374 |
</a>'; |
| 375 |
} |
| 376 |
|
| 377 |
/** |
| 378 |
* Method render_screen_options() |
| 379 |
* |
| 380 |
* Render Page Settings Modal. |
| 381 |
*/ |
| 382 |
public static function render_screen_options() { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 383 |
|
| 384 |
$columns = static::$sitesTable->get_columns(); |
| 385 |
|
| 386 |
if ( isset( $columns['cb'] ) ) { |
| 387 |
unset( $columns['cb'] ); |
| 388 |
} |
| 389 |
|
| 390 |
if ( isset( $columns['status'] ) ) { |
| 391 |
$columns['status'] = esc_html__( 'Status', 'mainwp' ); |
| 392 |
} |
| 393 |
|
| 394 |
if ( isset( $columns['favicon'] ) ) { |
| 395 |
$columns['favicon'] = esc_html__( 'Favicon', 'mainwp' ); |
| 396 |
} |
| 397 |
|
| 398 |
$list_items = array( |
| 399 |
'login' => esc_html__( 'Jump to WP Admin', 'mainwp' ), |
| 400 |
'update' => esc_html__( 'Available updates', 'mainwp' ), |
| 401 |
'wpcore_update' => esc_html__( 'Available WP core updates', 'mainwp' ), |
| 402 |
'plugin_update' => esc_html__( 'Available plugins updates', 'mainwp' ), |
| 403 |
'theme_update' => esc_html__( 'Available themes updates', 'mainwp' ), |
| 404 |
'site-cost-tracker' => esc_html__( 'Cost Tracker', 'mainwp' ), |
| 405 |
'note' => esc_html__( 'Notes', 'mainwp' ), |
| 406 |
'site_preview' => esc_html__( 'Site preview', 'mainwp' ), |
| 407 |
'time-tracker-tasks' => esc_html__( 'Time Tracker Tasks', 'mainwp' ), |
| 408 |
'lighthouse_desktop_score' => esc_html__( 'Lighthouse Desktop Score', 'mainwp' ), |
| 409 |
'lighthouse_mobile_score' => esc_html__( 'Lighthouse Mobile Score', 'mainwp' ), |
| 410 |
); |
| 411 |
|
| 412 |
foreach ( $list_items as $idx => $title ) { |
| 413 |
if ( isset( $columns[ $idx ] ) ) { |
| 414 |
$columns[ $idx ] = $title; |
| 415 |
} |
| 416 |
} |
| 417 |
|
| 418 |
$sites_per_page = get_option( 'mainwp_default_sites_per_page', 25 ); |
| 419 |
|
| 420 |
if ( isset( $columns['site_actions'] ) && empty( $columns['site_actions'] ) ) { |
| 421 |
$columns['site_actions'] = esc_html__( 'Actions', 'mainwp' ); |
| 422 |
} |
| 423 |
|
| 424 |
$show_cols = get_user_option( 'mainwp_settings_show_manage_sites_columns' ); |
| 425 |
if ( false === $show_cols ) { // to backwards. |
| 426 |
$show_cols = array(); |
| 427 |
foreach ( $columns as $name => $title ) { |
| 428 |
$show_cols[ $name ] = 1; |
| 429 |
} |
| 430 |
$user = wp_get_current_user(); |
| 431 |
if ( $user ) { |
| 432 |
update_user_option( $user->ID, 'mainwp_settings_show_manage_sites_columns', $show_cols, true ); |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
if ( ! is_array( $show_cols ) ) { |
| 437 |
$show_cols = array(); |
| 438 |
} |
| 439 |
|
| 440 |
$is_demo = MainWP_Demo_Handle::is_demo_mode(); |
| 441 |
$siteViewMode = MainWP_Utility::get_siteview_mode(); |
| 442 |
?> |
| 443 |
<div class="ui modal" id="mainwp-manage-sites-screen-options-modal"> |
| 444 |
<i class="close icon"></i> |
| 445 |
<div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div> |
| 446 |
<div class="scrolling content ui form"> |
| 447 |
<form method="POST" action="" id="manage-sites-screen-options-form" name="manage_sites_screen_options_form"> |
| 448 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 449 |
<input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'ManageSitesScrOptions' ) ); ?>" /> |
| 450 |
<div class="ui grid field"> |
| 451 |
<label class="top aligned six wide column" tabindex="0"><?php esc_html_e( 'Sites view mode', 'mainwp' ); ?></label> |
| 452 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Sites view mode.', 'mainwp' ); ?>" data-inverted="" data-position="left center"> |
| 453 |
<div class="ui info message"> |
| 454 |
<div><strong><?php echo esc_html__( 'Sites view mode is an experimental feature.', 'mainwp' ); ?></strong></div> |
| 455 |
<div><?php echo esc_html__( 'In the Grid mode, sites options are limited in comparison to the Table mode.', 'mainwp' ); ?></div> |
| 456 |
<div><?php echo esc_html__( 'Grid mode queries WordPress.com servers to capture a screenshot of your site the same way comments show you a preview of URLs.', 'mainwp' ); ?></div> |
| 457 |
</div> |
| 458 |
<select name="mainwp_sitesviewmode" id="mainwp_sitesviewmode" class="ui dropdown"> |
| 459 |
<option value="table" <?php echo 'table' === $siteViewMode ? 'selected' : ''; ?>><?php esc_html_e( 'Table', 'mainwp' ); ?></option> |
| 460 |
<option value="grid" <?php echo 'grid' === $siteViewMode ? 'selected' : ''; ?>><?php esc_html_e( 'Grid', 'mainwp' ); ?></option> |
| 461 |
</select> |
| 462 |
</div> |
| 463 |
</div> |
| 464 |
<div class="ui grid field"> |
| 465 |
<label class="six wide column"><?php esc_html_e( 'Default items per page value', 'mainwp' ); ?></label> |
| 466 |
<div class="ten wide column"> |
| 467 |
<div class="ui info message"> |
| 468 |
<ul> |
| 469 |
<li><?php esc_html_e( 'Based on your Dashboard server default large numbers can severely impact page load times.', 'mainwp' ); ?></li> |
| 470 |
<li><?php esc_html_e( 'Do not add commas for thousands (ex 1000).', 'mainwp' ); ?></li> |
| 471 |
<li><?php esc_html_e( '-1 to default to All of your Child Sites.', 'mainwp' ); ?></li> |
| 472 |
</ul> |
| 473 |
</div> |
| 474 |
<input type="text" name="mainwp_default_sites_per_page" id="mainwp_default_sites_per_page" saved-value="<?php echo intval( $sites_per_page ); ?>" value="<?php echo intval( $sites_per_page ); ?>"/> |
| 475 |
</div> |
| 476 |
</div> |
| 477 |
<div class="ui grid field"> |
| 478 |
<label class="six wide column"><?php esc_html_e( 'Show columns', 'mainwp' ); ?></label> |
| 479 |
<div class="ten wide column"> |
| 480 |
<ul class="mainwp_hide_wpmenu_checkboxes"> |
| 481 |
<?php |
| 482 |
foreach ( $columns as $name => $title ) { |
| 483 |
if ( empty( $title ) ) { |
| 484 |
continue; |
| 485 |
} |
| 486 |
?> |
| 487 |
<li> |
| 488 |
<div class="ui checkbox <?php echo ( 'site_preview' === $name ) ? 'site_preview not-auto-init' : ''; ?>"> |
| 489 |
<input type="checkbox" |
| 490 |
<?php |
| 491 |
$show_col = ! isset( $show_cols[ $name ] ) || ( 1 === (int) $show_cols[ $name ] ); |
| 492 |
|
| 493 |
if ( 'added_datetime' === $name && ! isset( $show_cols[ $name ] ) ) { |
| 494 |
$show_col = false; // default is hidden. |
| 495 |
} |
| 496 |
|
| 497 |
if ( $show_col ) { |
| 498 |
echo 'checked="checked"'; |
| 499 |
} |
| 500 |
|
| 501 |
?> |
| 502 |
id="mainwp_show_column_<?php echo esc_attr( $name ); ?>" name="mainwp_show_column_<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $name ); ?>"> |
| 503 |
<label for="mainwp_show_column_<?php echo esc_attr( $name ); ?>" ><?php echo $title; // phpcs:ignore WordPress.Security.EscapeOutput ?></label> |
| 504 |
<input type="hidden" value="<?php echo esc_attr( $name ); ?>" name="show_columns_name[]" /> |
| 505 |
</div> |
| 506 |
</li> |
| 507 |
<?php |
| 508 |
} |
| 509 |
?> |
| 510 |
</ul> |
| 511 |
</div> |
| 512 |
</div> |
| 513 |
<div class="ui grid field"> |
| 514 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Optimize for shared hosting or big networks', 'mainwp' ); ?></label> |
| 515 |
<div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, your MainWP Dashboard will cache updates for faster loading.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 516 |
<input type="checkbox" name="mainwp_optimize" id="mainwp_optimize" <?php echo 1 === (int) get_option( 'mainwp_optimize', 1 ) ? 'checked="true"' : ''; ?> /><label><?php esc_html_e( 'Default: Off', 'mainwp' ); ?></label> |
| 517 |
</div> |
| 518 |
</div> |
| 519 |
<div class="ui grid field"> |
| 520 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Export child sites to CSV file', 'mainwp' ); ?></label> |
| 521 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Click this button to export all connected sites to a CSV file.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><a href="admin.php?page=MainWPTools&doExportSites=yes&_wpnonce=<?php echo esc_html( wp_create_nonce( 'export_sites' ) ); ?>" class="ui button green basic"><?php esc_html_e( 'Export Child Sites', 'mainwp' ); ?></a></div> |
| 522 |
</div> |
| 523 |
<div class="ui grid field"> |
| 524 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Disconnect all child sites', 'mainwp' ); ?></label> |
| 525 |
<div class="ten wide column" id="mainwp-disconnect-sites-tool" data-tooltip="<?php esc_attr_e( 'This will function will break the connection and leave the MainWP Child plugin active.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left"> |
| 526 |
<?php |
| 527 |
if ( $is_demo ) { |
| 528 |
MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="#" disabled="disabled" class="ui button green basic disabled">' . esc_html__( 'Disconnect Websites.', 'mainwp' ) . '</a>' ); |
| 529 |
} else { |
| 530 |
?> |
| 531 |
<a href="admin.php?page=MainWPTools&disconnectSites=yes&_wpnonce=<?php echo esc_html( wp_create_nonce( 'disconnect_sites' ) ); ?>" onclick="mainwp_tool_disconnect_sites(); return false;" class="ui button green basic"><?php esc_html_e( 'Disconnect Websites.', 'mainwp' ); ?></a> |
| 532 |
<?php } ?> |
| 533 |
</div> |
| 534 |
</div> |
| 535 |
<div class="ui hidden divider"></div> |
| 536 |
<div class="ui hidden divider"></div> |
| 537 |
</div> |
| 538 |
<div class="actions"> |
| 539 |
<div class="ui two columns grid"> |
| 540 |
<div class="left aligned column"> |
| 541 |
<span data-tooltip="<?php esc_attr_e( 'Resets the page to its original layout and reinstates relocated columns.', 'mainwp' ); ?>" data-inverted="" data-position="top center"><input type="button" class="ui button" name="reset" id="reset-managersites-settings" value="<?php esc_attr_e( 'Reset Page', 'mainwp' ); ?>" /></span> |
| 542 |
</div> |
| 543 |
<div class="ui right aligned column"> |
| 544 |
<input type="submit" class="ui green button" name="btnSubmit" id="submit-managersites-settings" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>" /> |
| 545 |
</div> |
| 546 |
</div> |
| 547 |
</div> |
| 548 |
<input type="hidden" name="reset_managersites_columns_order" value="0"> |
| 549 |
</form> |
| 550 |
</div> |
| 551 |
<div class="ui small modal" id="mainwp-manage-sites-site-preview-screen-options-modal"> |
| 552 |
<div class="header"><?php esc_html_e( 'Page Settings', 'mainwp' ); ?></div> |
| 553 |
<div class="scrolling content ui form"> |
| 554 |
<span><?php esc_html_e( 'Would you like to turn on home screen previews? This function queries WordPress.com servers to capture a screenshot of your site the same way comments shows you preview of URLs.', 'mainwp' ); ?> |
| 555 |
</div> |
| 556 |
<div class="actions"> |
| 557 |
<div class="ui ok button"><?php esc_html_e( 'Yes', 'mainwp' ); ?></div> |
| 558 |
<div class="ui cancel button"><?php esc_html_e( 'No', 'mainwp' ); ?></div> |
| 559 |
</div> |
| 560 |
</div> |
| 561 |
<script type="text/javascript"> |
| 562 |
jQuery( document ).ready( function () { |
| 563 |
jQuery( '.ui.checkbox.not-auto-init.site_preview' ).checkbox( { |
| 564 |
onChecked : function() { |
| 565 |
let $chk = jQuery( this ); |
| 566 |
jQuery( '#mainwp-manage-sites-site-preview-screen-options-modal' ).modal( { |
| 567 |
allowMultiple: true, // multiple modals. |
| 568 |
width: 100, |
| 569 |
onDeny: function () { |
| 570 |
$chk.prop('checked', false); |
| 571 |
} |
| 572 |
} ).modal( 'show' ); |
| 573 |
} |
| 574 |
} ); |
| 575 |
jQuery('#reset-managersites-settings').on( 'click', function () { |
| 576 |
mainwp_confirm(__( 'Are you sure.' ), function(){ |
| 577 |
jQuery('#mainwp_sitesviewmode').dropdown( 'set selected', 'grid' ); |
| 578 |
jQuery('input[name=mainwp_default_sites_per_page]').val(25); |
| 579 |
jQuery('.mainwp_hide_wpmenu_checkboxes input[id^="mainwp_show_column_"]').prop( 'checked', false ); |
| 580 |
//default columns. |
| 581 |
let cols = ['status','site','login','url','update','client_name','site_actions']; |
| 582 |
jQuery.each( cols, function ( index, value ) { |
| 583 |
jQuery('.mainwp_hide_wpmenu_checkboxes input[id="mainwp_show_column_' + value + '"]').prop( 'checked', true ); |
| 584 |
} ); |
| 585 |
jQuery('input[name=reset_managersites_columns_order]').attr('value',1); |
| 586 |
jQuery('#submit-managersites-settings').click(); |
| 587 |
}, false, false, true ); |
| 588 |
return false; |
| 589 |
}); |
| 590 |
} ); |
| 591 |
</script> |
| 592 |
<?php |
| 593 |
} |
| 594 |
|
| 595 |
/** |
| 596 |
* Method ajax_optimize_display_rows() |
| 597 |
* |
| 598 |
* Display table rows, optimize for shared hosting or big networks. |
| 599 |
* |
| 600 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_List_Table |
| 601 |
*/ |
| 602 |
public static function ajax_optimize_display_rows() { |
| 603 |
static::load_sites_table(); |
| 604 |
static::$sitesTable->prepare_items( true ); |
| 605 |
$output = static::$sitesTable->ajax_get_datatable_rows(); |
| 606 |
static::$sitesTable->clear_items(); |
| 607 |
|
| 608 |
MainWP_Logger::instance()->log_execution_time( 'ajax_optimize_display_rows()' ); |
| 609 |
|
| 610 |
wp_send_json( $output ); |
| 611 |
} |
| 612 |
|
| 613 |
/** |
| 614 |
* Method render_new_site() |
| 615 |
* |
| 616 |
* Render add new site page. |
| 617 |
* |
| 618 |
* @return string Add new site html. |
| 619 |
* |
| 620 |
* @uses \MainWP\Dashboard\MainWP_DB_Common::get_groups_for_current_user() |
| 621 |
* @uses \MainWP\Dashboard\MainWP_DB::query() |
| 622 |
* @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user() |
| 623 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_sync_exts_settings() |
| 624 |
*/ |
| 625 |
public static function render_new_site() { |
| 626 |
|
| 627 |
$showpage = 'AddNew'; |
| 628 |
static::render_header( $showpage ); |
| 629 |
|
| 630 |
if ( ! mainwp_current_user_have_right( 'dashboard', 'add_sites' ) ) { |
| 631 |
mainwp_do_not_have_permissions( esc_html__( 'add sites', 'mainwp' ) ); |
| 632 |
return; |
| 633 |
} else { |
| 634 |
$groups = MainWP_DB_Common::instance()->get_groups_for_current_user(); |
| 635 |
if ( ! is_array( $groups ) ) { |
| 636 |
$groups = array(); |
| 637 |
} |
| 638 |
|
| 639 |
?> |
| 640 |
<div id="mainwp-add-new-site" class="ui segment"> |
| 641 |
|
| 642 |
<?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-add-site-info-message' ) ) : ?> |
| 643 |
<div class="ui info message"> |
| 644 |
<i class="close icon mainwp-notice-dismiss" notice-id="mainwp-add-site-info-message"></i> |
| 645 |
<div><?php printf( esc_html__( 'Use the provided form to connect your websites to your MainWP Dashboard. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/add-site-to-your-dashboard/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?></div> |
| 646 |
<div><?php printf( esc_html__( 'If you are experiencing issues with adding a website to your MainWP Dashboard, use the %1$sTest Connection%2$s feature to ensure that your MainWP Dashboard can communicate with your website.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/test-connection-between-your-mainwp-dashboard-and-child-site/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?></div> |
| 647 |
<div><?php printf( esc_html__( 'If you still can not connect the site, see the list of %1$spotential issues%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/potential-issues/" target="_blank">', '</a>' ); // NOSONAR - noopener - open safe. ?></div> |
| 648 |
</div> |
| 649 |
<?php endif; ?> |
| 650 |
|
| 651 |
<div id="mainwp-message-zone" style="display: none;" class="ui message"></div> |
| 652 |
|
| 653 |
<div id="mainwp_managesites_add_errors" style="display: none" class="mainwp-notice mainwp-notice-red"></div> |
| 654 |
<div id="mainwp_managesites_add_message" style="display: none" class="mainwp-notice mainwp-notice-green"></div> |
| 655 |
<div class="ui info message" id="mainwp_message_verify_installed_child" style="display:none"> |
| 656 |
<?php esc_html_e( 'MainWP requires the MainWP Child plugin to be installed and activated on the WordPress site that you want to connect to your MainWP Dashboard. ', 'mainwp' ); ?> |
| 657 |
<?php esc_html_e( 'To install the MainWP Child plugin, please follow these steps:', 'mainwp' ); ?> |
| 658 |
<ol> |
| 659 |
<li><?php printf( esc_html__( 'Login to the WordPress site you want to connect %1$s(open it in a new browser tab)%2$s', 'mainwp' ), '<em>', '</em>' ); ?></li> |
| 660 |
<li><?php printf( esc_html__( 'Go to the %1$sWP > Plugins%2$s page', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 661 |
<li><?php printf( esc_html__( 'Click %1$sAdd New%2$s to install a new plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 662 |
<li><?php printf( esc_html__( 'In the %1$sSearch Field%2$s, enter "MainWP Child" and once the plugin shows, click the Install button', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 663 |
<li><?php printf( esc_html__( '%1$sActivate%2$s the plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 664 |
</ol> |
| 665 |
</div> |
| 666 |
|
| 667 |
<form method="POST" class="ui form" action="" enctype="multipart/form-data" id="mainwp_managesites_add_form"> |
| 668 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 669 |
<h3 class="ui dividing header"> |
| 670 |
<?php esc_html_e( 'Add a New Site', 'mainwp' ); ?> |
| 671 |
<div class="sub header"><?php esc_html_e( 'Add a new site or use the Test Connection feature to check if the site can be connected.', 'mainwp' ); ?></div> |
| 672 |
</h3> |
| 673 |
<div class="ui grid field"> |
| 674 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Site URL', 'mainwp' ); ?></label> |
| 675 |
<div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter your website URL.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 676 |
<div class="ui left action input"> |
| 677 |
<select class="ui compact selection dropdown" id="mainwp_managesites_add_wpurl_protocol" name="mainwp_managesites_add_wpurl_protocol"> |
| 678 |
<option value="http">http://</option> |
| 679 |
<option selected="" value="https">https://</option> |
| 680 |
</select> |
| 681 |
<input type="text" id="mainwp_managesites_add_wpurl" name="mainwp_managesites_add_wpurl" value="" /> |
| 682 |
</div> |
| 683 |
</div> |
| 684 |
<div class="ui four wide middle aligned column"> |
| 685 |
<input type="button" name="mainwp_managesites_edit_test" id="mainwp_managesites_test" class="ui button basic green" value="<?php esc_attr_e( 'Test Connection', 'mainwp' ); ?>"/> |
| 686 |
</div> |
| 687 |
</div> |
| 688 |
<div class="ui grid field"> |
| 689 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Verify that the MainWP Child plugin is installed and activated', 'mainwp' ); ?></label> |
| 690 |
<div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Verify that MainWP Child is Installed and Activated.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 691 |
<input type="checkbox" name="mainwp_managesites_verify_installed_child" id="mainwp_managesites_verify_installed_child" /> |
| 692 |
<label><?php esc_attr_e( 'Select to confirm that the MainWP Child plugin is active on the child site.', 'mainwp' ); ?></label> |
| 693 |
</div> |
| 694 |
</div> |
| 695 |
|
| 696 |
<div id="mainwp-add-site-hidden-form" style="display:none"> |
| 697 |
<h3 class="ui dividing header"> |
| 698 |
<?php esc_html_e( 'Required Settings', 'mainwp' ); ?> |
| 699 |
<div class="sub header"><?php esc_html_e( 'Enter administrator username and site title.', 'mainwp' ); ?></div> |
| 700 |
</h3> |
| 701 |
|
| 702 |
<div class="ui grid field"> |
| 703 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Administrator username', 'mainwp' ); ?></label> |
| 704 |
<div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the website Administrator username.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 705 |
<div class="ui left labeled input"> |
| 706 |
<input type="text" id="mainwp_managesites_add_wpadmin" name="mainwp_managesites_add_wpadmin" value="" /> |
| 707 |
</div> |
| 708 |
</div> |
| 709 |
</div> |
| 710 |
|
| 711 |
<div class="ui grid field"> |
| 712 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Site title', 'mainwp' ); ?></label> |
| 713 |
<div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Enter the website title.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 714 |
<div class="ui left labeled input"> |
| 715 |
<input type="text" id="mainwp_managesites_add_wpname" name="mainwp_managesites_add_wpname" value="" /> |
| 716 |
</div> |
| 717 |
</div> |
| 718 |
</div> |
| 719 |
|
| 720 |
<div class="ui grid field"> |
| 721 |
<div class="six wide column middle aligned"> |
| 722 |
<a href="#" id="mainwp-add-site-advanced-options-toggle"><i class="eye slash outline icon"></i> <?php esc_html_e( 'Show Optional Settings', 'mainwp' ); ?></a> |
| 723 |
</div> |
| 724 |
<div class="six wide column middle aligned"> |
| 725 |
</div> |
| 726 |
</div> |
| 727 |
|
| 728 |
<div id="mainwp-add-site-advanced-options" class="ui secondary segment" style="display:none" > |
| 729 |
|
| 730 |
<h3 class="ui dividing header"> |
| 731 |
<?php esc_html_e( 'Optional Settings', 'mainwp' ); ?> |
| 732 |
<div class="sub header"><?php esc_html_e( 'Use optional settings when needed. In most cases, you can leave the default values.', 'mainwp' ); ?></div> |
| 733 |
</h3> |
| 734 |
|
| 735 |
<div class="ui grid field"> |
| 736 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Unique security ID (optional)', 'mainwp' ); ?></label> |
| 737 |
<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"> |
| 738 |
<div class="ui left labeled input"> |
| 739 |
<input type="text" id="mainwp_managesites_add_uniqueId" name="mainwp_managesites_add_uniqueId" value="" /> |
| 740 |
</div> |
| 741 |
</div> |
| 742 |
</div> |
| 743 |
|
| 744 |
<div class="ui grid field"> |
| 745 |
<label class="six wide column middle aligned"> |
| 746 |
<?php |
| 747 |
esc_html_e( 'Upload site icon', 'mainwp' ); |
| 748 |
?> |
| 749 |
</label> |
| 750 |
<input type="hidden" name="mainwp_managesites_add_site_uploaded_icon_hidden" id="mainwp_managesites_add_site_uploaded_icon_hidden" value=""> |
| 751 |
|
| 752 |
<div class="three wide middle aligned column" data-tooltip="<?php esc_attr_e( 'Upload the site icon.', 'mainwp' ); ?>" data-inverted="" data-position="left center"> |
| 753 |
<div class="ui green button basic mainwp-managesites-add-site-icon-customable" iconItemId="" iconFileSlug="" icon-src=""><?php esc_html_e( 'Upload Icon', 'mainwp' ); ?></div> |
| 754 |
<div style="display:inline-block;" id="mainw_managesites_add_edit_site_upload_custom_icon"></div> <?php // used for icon holder. ?> |
| 755 |
</div> |
| 756 |
</div> |
| 757 |
|
| 758 |
<?php |
| 759 |
$default_icons = MainWP_UI::get_default_icons(); |
| 760 |
$selected_default_icon = 'wordpress'; //phpcs:ignore -- WP icon. |
| 761 |
$selected_site_color = '#34424D'; |
| 762 |
?> |
| 763 |
|
| 764 |
<div class="ui grid field"> |
| 765 |
<label class="six wide column middle aligned"> |
| 766 |
<?php |
| 767 |
esc_html_e( 'Select icon', 'mainwp' ); |
| 768 |
?> |
| 769 |
</label> |
| 770 |
<input type="hidden" name="mainwp_managesites_add_site_select_icon_hidden" id="mainwp_managesites_add_site_select_icon_hidden" value=""> |
| 771 |
<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"> |
| 772 |
<div class="ui left action input mainwp-dropdown-color-picker-field"> |
| 773 |
<div class="ui five column selection search dropdown not-auto-init" id="mainwp_manage_add_edit_site_icon_select"> |
| 774 |
<div class="text"> |
| 775 |
<span style="color:<?php echo esc_attr( $selected_site_color ); ?>" ><?php echo ! empty( $selected_default_icon ) ? '<i class="' . esc_attr( $selected_default_icon ) . ' icon"></i>' : ''; ?></span> |
| 776 |
</div> |
| 777 |
<i class="dropdown icon"></i> |
| 778 |
<div class="menu"> |
| 779 |
<?php foreach ( $default_icons as $icon ) : ?> |
| 780 |
<?php echo '<div class="item" style="color:' . esc_attr( $selected_site_color ) . '" data-value="' . esc_attr( $icon ) . '"><i class="' . esc_attr( $icon ) . ' icon"></i></div>'; ?> |
| 781 |
<?php endforeach; ?> |
| 782 |
</div> |
| 783 |
</div> |
| 784 |
<input type="color" data-tooltip="Color will update on save" data-position="top center" data-inverted="" name="mainwp_managesites_add_site_color" class="mainwp-color-picker-input" id="mainwp_managesites_add_site_color" value="<?php echo esc_attr( $selected_site_color ); ?>" /> |
| 785 |
</div> |
| 786 |
</div> |
| 787 |
<div class="one wide column"></div> |
| 788 |
</div> |
| 789 |
|
| 790 |
|
| 791 |
<div class="ui grid field"> |
| 792 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Tags (optional)', 'mainwp' ); ?></label> |
| 793 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Add the website to existing tag(s).', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 794 |
<div class="ui multiple search selection dropdown" init-value="" id="mainwp_managesites_add_addgroups"> |
| 795 |
<i class="dropdown icon"></i> |
| 796 |
<div class="default text"></div> |
| 797 |
<div class="menu"> |
| 798 |
<?php foreach ( $groups as $group ) { ?> |
| 799 |
<div class="item" data-value="<?php echo intval( $group->id ); ?>"><?php echo esc_html( stripslashes( $group->name ) ); ?></div> |
| 800 |
<?php } ?> |
| 801 |
</div> |
| 802 |
</div> |
| 803 |
</div> |
| 804 |
</div> |
| 805 |
<?php |
| 806 |
$clients = MainWP_DB_Client::instance()->get_wp_client_by( 'all' ); |
| 807 |
?> |
| 808 |
<div class="ui grid field"> |
| 809 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Client (optional)', 'mainwp' ); ?></label> |
| 810 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Add a client to the website.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 811 |
<div class="ui search selection dropdown" init-value="" id="mainwp_managesites_add_client_id"> |
| 812 |
<i class="dropdown icon"></i> |
| 813 |
<div class="default text"></div> |
| 814 |
<div class="menu"> |
| 815 |
<div class="item" data-value="0"><?php esc_attr_e( 'Select client', 'mainwp' ); ?></div> |
| 816 |
<?php foreach ( $clients as $client ) { ?> |
| 817 |
<div class="item" data-value="<?php echo intval( $client->client_id ); ?>"><?php echo esc_html( $client->name ); ?></div> |
| 818 |
<?php } ?> |
| 819 |
</div> |
| 820 |
</div> |
| 821 |
</div> |
| 822 |
</div> |
| 823 |
|
| 824 |
<div class="ui grid field settings-field-indicator-wrapper"> |
| 825 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Verify SSL certificate (optional)', 'mainwp' ); ?></label> |
| 826 |
<div class="six wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Do you want to verify SSL certificate.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 827 |
<input type="checkbox" name="mainwp_managesites_verify_certificate" id="mainwp_managesites_verify_certificate" checked="true" /> |
| 828 |
</div> |
| 829 |
</div> |
| 830 |
|
| 831 |
<div class="ui grid field"> |
| 832 |
<label class="six wide column middle aligned"><?php esc_html_e( 'SSL version (optional)', 'mainwp' ); ?></label> |
| 833 |
<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"> |
| 834 |
<select class="ui dropdown" id="mainwp_managesites_add_ssl_version" name="mainwp_managesites_add_ssl_version"> |
| 835 |
<option value="0"><?php esc_html_e( 'Auto detect', 'mainwp' ); ?></option> |
| 836 |
<option value="6"><?php esc_html_e( 'TLS v1.2', 'mainwp' ); ?></option> |
| 837 |
<option value="1"><?php esc_html_e( 'TLS v1.x', 'mainwp' ); ?></option> |
| 838 |
<option value="2"><?php esc_html_e( 'SSL v2', 'mainwp' ); ?></option> |
| 839 |
<option value="3"><?php esc_html_e( 'SSL v3', 'mainwp' ); ?></option> |
| 840 |
<option value="4"><?php esc_html_e( 'TLS v1.0', 'mainwp' ); ?></option> |
| 841 |
<option value="5"><?php esc_html_e( 'TLS v1.1', 'mainwp' ); ?></option> |
| 842 |
</select> |
| 843 |
</div> |
| 844 |
</div> |
| 845 |
|
| 846 |
<!-- fake fields are a workaround for chrome autofill getting the wrong fields. --> |
| 847 |
<input style="display:none" type="text" name="fakeusernameremembered"/> |
| 848 |
<input style="display:none" type="password" name="fakepasswordremembered"/> |
| 849 |
|
| 850 |
<div class="ui grid field"> |
| 851 |
<label class="six wide column middle aligned"><?php esc_html_e( 'HTTP username (optional)', 'mainwp' ); ?></label> |
| 852 |
<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"> |
| 853 |
<div class="ui left labeled input"> |
| 854 |
<input type="text" id="mainwp_managesites_add_http_user" name="mainwp_managesites_add_http_user" value="" autocomplete="off" /> |
| 855 |
</div> |
| 856 |
</div> |
| 857 |
</div> |
| 858 |
|
| 859 |
<div class="ui grid field"> |
| 860 |
<label class="six wide column middle aligned"><?php esc_html_e( 'HTTP password (optional)', 'mainwp' ); ?></label> |
| 861 |
<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"> |
| 862 |
<div class="ui left labeled input"> |
| 863 |
<input type="password" id="mainwp_managesites_add_http_pass" name="mainwp_managesites_add_http_pass" value="" autocomplete="new-password" /> |
| 864 |
</div> |
| 865 |
</div> |
| 866 |
</div> |
| 867 |
|
| 868 |
<?php MainWP_Manage_Sites_View::render_sync_exts_settings(); ?> |
| 869 |
</div> |
| 870 |
|
| 871 |
<?php |
| 872 |
do_action_deprecated( 'mainwp-manage-sites-edit', array( false ), '4.0.7.2', 'mainwp_manage_sites_edit' ); // @deprecated Use 'mainwp_manage_sites_edit' instead. NOSONAR - not IP. |
| 873 |
|
| 874 |
/** |
| 875 |
* Edit site |
| 876 |
* |
| 877 |
* Fires on the Edit child site page and allows user to hook in new site options. |
| 878 |
* |
| 879 |
* @param bool false |
| 880 |
*/ |
| 881 |
do_action( 'mainwp_manage_sites_edit', false ); |
| 882 |
?> |
| 883 |
|
| 884 |
<div class="ui divider"></div> |
| 885 |
<input type="button" name="mainwp_managesites_add" id="mainwp_managesites_add" class="ui button green big" value="<?php esc_attr_e( 'Add Site', 'mainwp' ); ?>" /> |
| 886 |
<div class="ui hidden clearing divider"></div> |
| 887 |
</div> |
| 888 |
</form> |
| 889 |
</div> |
| 890 |
|
| 891 |
<div class="ui modal" id="mainwp-test-connection-modal"> |
| 892 |
<i class="close icon"></i> |
| 893 |
<div class="header"><?php esc_html_e( 'Connection Test', 'mainwp' ); ?></div> |
| 894 |
<div class="content"> |
| 895 |
<div class="ui active inverted dimmer"> |
| 896 |
<div class="ui text loader"><?php esc_html_e( 'Testing connection...', 'mainwp' ); ?></div> |
| 897 |
</div> |
| 898 |
<div id="mainwp-test-connection-result" class="ui segment" style="display:none"> |
| 899 |
<h2 class="ui center aligned icon header"> |
| 900 |
<i class=" icon"></i> |
| 901 |
<div class="content"> |
| 902 |
<span></span> |
| 903 |
<div class="sub header"></div> |
| 904 |
</div> |
| 905 |
</h2> |
| 906 |
</div> |
| 907 |
</div> |
| 908 |
<div class="actions"> |
| 909 |
</div> |
| 910 |
</div> |
| 911 |
<script type="text/javascript"> |
| 912 |
jQuery( document ).ready( function () { |
| 913 |
jQuery( '#mainwp_managesites_add_addgroups' ).dropdown( { |
| 914 |
allowAdditions: true |
| 915 |
} ); |
| 916 |
jQuery( '#mainwp_manage_add_edit_site_icon_select' ).dropdown( { |
| 917 |
onChange: function( val ) { |
| 918 |
jQuery( '#mainwp_managesites_add_site_select_icon_hidden' ).val(val); |
| 919 |
} |
| 920 |
} ); |
| 921 |
|
| 922 |
jQuery(document).on('click', '.mainwp-managesites-add-site-icon-customable', function () { |
| 923 |
let iconObj = jQuery(this); |
| 924 |
jQuery('#mainwp_delete_image_field').hide(); |
| 925 |
jQuery('#mainwp-upload-custom-icon-modal').modal('setting', 'closable', false).modal('show'); |
| 926 |
jQuery('#update_custom_icon_btn').removeAttr('disabled'); |
| 927 |
jQuery('#update_custom_icon_btn').attr('uploading-icon', 'site'); |
| 928 |
jQuery('#mainwp_delete_image_field').find('#mainwp_delete_image_chk').attr('iconItemId', iconObj.attr('iconItemId') ); // @see used by mainwp_upload_custom_types_icon(). |
| 929 |
jQuery('#mainwp_delete_image_field').find('#mainwp_delete_image_chk').attr('iconFileSlug', iconObj.attr('iconFileSlug') ); // @see used by mainwp_upload_custom_types_icon(). |
| 930 |
|
| 931 |
if (iconObj.attr('icon-src') != '') { |
| 932 |
jQuery('#mainwp_delete_image_field').find('.ui.image').attr('src', iconObj.attr('icon-src')); |
| 933 |
jQuery('#mainwp_delete_image_field').show(); |
| 934 |
} |
| 935 |
|
| 936 |
jQuery(document).on('click', '#update_custom_icon_btn', function () { |
| 937 |
let deleteIcon = jQuery('#mainwp_delete_image_chk').is(':checked'); |
| 938 |
let iconItemId = iconObj.attr('iconItemId'); |
| 939 |
let iconFileSlug = iconObj.attr('iconFileSlug'); // to support delete file when iconItemId = 0. |
| 940 |
// upload/delete icon action. |
| 941 |
mainwp_upload_custom_types_icon(iconObj, 'mainwp_managesites_add_edit_site_upload_site_icon', iconItemId, iconFileSlug, deleteIcon, function(response){ |
| 942 |
if (jQuery('#mainwp_managesites_add_site_uploaded_icon_hidden').length > 0) { |
| 943 |
if (typeof response.iconfile !== undefined) { |
| 944 |
jQuery('#mainwp_managesites_add_site_uploaded_icon_hidden').val(response.iconfile); |
| 945 |
} else { |
| 946 |
jQuery('#mainwp_managesites_add_site_uploaded_icon_hidden').val(''); |
| 947 |
} |
| 948 |
} |
| 949 |
let deleteIcon = jQuery('#mainwp_delete_image_chk').is(':checked'); // to delete. |
| 950 |
if(deleteIcon){ |
| 951 |
jQuery('#mainw_managesites_add_edit_site_upload_custom_icon').hide(); |
| 952 |
} else if (jQuery('#mainw_managesites_add_edit_site_upload_custom_icon').length > 0) { |
| 953 |
if (typeof response.iconfile !== undefined) { |
| 954 |
let icon_img = typeof response.iconimg !== undefined ? response.iconimg : ''; |
| 955 |
let icon_src = typeof response.iconsrc !== undefined ? response.iconsrc : ''; |
| 956 |
iconObj.attr('icon-src', icon_src); |
| 957 |
iconObj.attr('iconFileSlug', response.iconfile); // to support delete file when iconItemId = 0. |
| 958 |
jQuery('#mainwp_delete_image_field').find('.ui.image').attr('src', icon_src); |
| 959 |
jQuery('#mainw_managesites_add_edit_site_upload_custom_icon').html(icon_img).show(); |
| 960 |
} |
| 961 |
} |
| 962 |
setTimeout(function () { |
| 963 |
//window.location.href = location.href; |
| 964 |
jQuery('#mainwp-upload-custom-icon-modal').modal('hide') |
| 965 |
}, 1000); |
| 966 |
}); |
| 967 |
return false; |
| 968 |
}); |
| 969 |
}); |
| 970 |
|
| 971 |
} ); |
| 972 |
</script> |
| 973 |
<?php |
| 974 |
} |
| 975 |
static::render_footer( $showpage ); |
| 976 |
MainWP_UI::render_modal_upload_icon(); |
| 977 |
} |
| 978 |
|
| 979 |
/** |
| 980 |
* Method ajax_upload_icon() |
| 981 |
*/ |
| 982 |
public static function ajax_upload_icon() { //phpcs:ignore -- NOSONAR - complex. |
| 983 |
MainWP_Post_Handler::instance()->secure_request( 'mainwp_managesites_add_edit_site_upload_site_icon' ); |
| 984 |
|
| 985 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 986 |
$iconfile_slug = isset( $_POST['iconFileSlug'] ) ? sanitize_text_field( wp_unslash( $_POST['iconFileSlug'] ) ) : ''; |
| 987 |
$delete = isset( $_POST['delete'] ) ? intval( $_POST['delete'] ) : 0; |
| 988 |
$site_id = isset( $_POST['iconItemId'] ) ? intval( $_POST['iconItemId'] ) : 0; |
| 989 |
|
| 990 |
if ( $delete ) { |
| 991 |
if ( $site_id ) { |
| 992 |
$website = MainWP_DB::instance()->get_website_by_id( $site_id ); |
| 993 |
if ( $website && ! empty( $website->cust_site_icon_info ) ) { |
| 994 |
$uploaded_site_icon = static::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'uploaded' ); |
| 995 |
if ( ! empty( $uploaded_site_icon ) ) { |
| 996 |
$tmp = explode( ';', $website->cust_site_icon_info ); |
| 997 |
$new_info = 'uploaded:;' . $tmp[1] . ';' . $tmp[2]; |
| 998 |
MainWP_DB::instance()->update_website_option( $website, 'cust_site_icon_info', $new_info ); // to delete uploaded icon. |
| 999 |
MainWP_Utility::instance()->delete_uploaded_icon_file( 'site-icons', $uploaded_site_icon ); |
| 1000 |
} |
| 1001 |
} |
| 1002 |
} elseif ( ! empty( $iconfile_slug ) ) { |
| 1003 |
MainWP_Utility::instance()->delete_uploaded_icon_file( 'site-icons', $iconfile_slug ); |
| 1004 |
} |
| 1005 |
wp_die( wp_json_encode( array( 'result' => 'success' ) ) ); |
| 1006 |
} |
| 1007 |
|
| 1008 |
$output = isset( $_FILES['mainwp_upload_icon_uploader'] ) ? MainWP_System_Utility::handle_upload_image( 'site-icons', $_FILES['mainwp_upload_icon_uploader'] ) : null; |
| 1009 |
// phpcs:enable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1010 |
|
| 1011 |
$uploaded_icon = 'NOTCHANGE'; |
| 1012 |
if ( is_array( $output ) && isset( $output['filename'] ) && ! empty( $output['filename'] ) ) { |
| 1013 |
$uploaded_icon = $output['filename']; |
| 1014 |
} |
| 1015 |
|
| 1016 |
if ( 'NOTCHANGE' !== $uploaded_icon ) { |
| 1017 |
$dirs = MainWP_System_Utility::get_mainwp_dir( 'site-icons', true ); |
| 1018 |
$icon_url = $dirs[1] . $uploaded_icon; |
| 1019 |
wp_die( |
| 1020 |
wp_json_encode( |
| 1021 |
array( |
| 1022 |
'result' => 'success', |
| 1023 |
'iconfile' => esc_html( $uploaded_icon ), |
| 1024 |
'iconsrc' => esc_html( $icon_url ), |
| 1025 |
'iconimg' => '<img class="ui mini circular image" src="' . esc_attr( $icon_url ) . '" style="width:32px;height:auto;display:inline-block;" alt="Custom icon">', |
| 1026 |
) |
| 1027 |
) |
| 1028 |
); |
| 1029 |
} else { |
| 1030 |
wp_die( wp_json_encode( array( 'result' => 'failed' ) ) ); |
| 1031 |
} |
| 1032 |
} |
| 1033 |
|
| 1034 |
/** |
| 1035 |
* Method get_site_icon_display() |
| 1036 |
* |
| 1037 |
* Get site icon. |
| 1038 |
* |
| 1039 |
* @param string $icon_data icon data. |
| 1040 |
* @param string $favi_url favico url. |
| 1041 |
*/ |
| 1042 |
public function get_site_icon_display( $icon_data, $favi_url ) { |
| 1043 |
$output = ''; |
| 1044 |
// 1 priority. |
| 1045 |
if ( ! empty( $icon_data ) ) { |
| 1046 |
$uploaded = $this->get_cust_site_icon( $icon_data, 'uploaded' ); |
| 1047 |
if ( ! empty( $uploaded ) ) { |
| 1048 |
$output = $this->get_cust_site_icon( $icon_data, 'display' ); |
| 1049 |
} |
| 1050 |
} |
| 1051 |
|
| 1052 |
// 2 priority. |
| 1053 |
if ( empty( $output ) && ! empty( $favi_url ) ) { |
| 1054 |
$output = '<img src="' . esc_attr( $favi_url ) . '" style="width:28px;height:28px;" class="ui circular image" alt="Site icon"/>'; |
| 1055 |
} |
| 1056 |
|
| 1057 |
// 3 priority. |
| 1058 |
$selected = $this->get_cust_site_icon( $icon_data, 'selected' ); |
| 1059 |
if ( empty( $output ) && ! empty( $selected ) ) { |
| 1060 |
$output = $this->get_cust_site_icon( $icon_data, 'display_selected' ); |
| 1061 |
} |
| 1062 |
|
| 1063 |
if ( empty( $output ) ) { |
| 1064 |
$output = '<i class="icon big wordpress" style="width:28px;height:28px;"></i> '; // phpcs:ignore -- WP icon. |
| 1065 |
} |
| 1066 |
|
| 1067 |
// last default. |
| 1068 |
return $output; |
| 1069 |
} |
| 1070 |
|
| 1071 |
/** |
| 1072 |
* Method get_cust_site_icon() |
| 1073 |
* |
| 1074 |
* Get site icon. |
| 1075 |
* |
| 1076 |
* @param string $icon_data icon data. |
| 1077 |
* @param string $type Type: uploaded|selected|color|display. |
| 1078 |
*/ |
| 1079 |
public function get_cust_site_icon( $icon_data, $type = 'display' ) { //phpcs:ignore -- NOSONAR - complex. |
| 1080 |
|
| 1081 |
if ( empty( $icon_data ) ) { |
| 1082 |
return ''; |
| 1083 |
} |
| 1084 |
$data = explode( ';', $icon_data ); |
| 1085 |
|
| 1086 |
$uploaded = str_replace( 'uploaded:', '', $data[0] ); |
| 1087 |
$selected = str_replace( 'selected:', '', $data[1] ); |
| 1088 |
$color = str_replace( 'color:', '', $data[2] ); |
| 1089 |
|
| 1090 |
if ( empty( $color ) ) { |
| 1091 |
$color = '#34424D'; |
| 1092 |
} |
| 1093 |
|
| 1094 |
if ( 'display_selected' === $type ) { |
| 1095 |
if ( empty( $selected ) ) { |
| 1096 |
$selected = 'wordpress'; // phpcs:ignore -- WP icon. |
| 1097 |
} |
| 1098 |
return '<span style="color:' . esc_attr( $color ) . '" ><i class="' . esc_attr( $selected ) . ' big icon"></i></span>'; |
| 1099 |
} |
| 1100 |
|
| 1101 |
$output = ''; |
| 1102 |
if ( 'uploaded' === $type ) { |
| 1103 |
$output = $uploaded; |
| 1104 |
} elseif ( 'selected' === $type ) { |
| 1105 |
$output = $selected; |
| 1106 |
} elseif ( 'color' === $type ) { |
| 1107 |
$output = $color; |
| 1108 |
} elseif ( 'display' === $type || 'display_edit' === $type ) { |
| 1109 |
$style = 'width:32px;height:auto;display:inline-block;'; |
| 1110 |
$default_cls = 'mainw_site_custom_icon_display'; |
| 1111 |
$icon = ''; |
| 1112 |
if ( ! empty( $uploaded ) ) { |
| 1113 |
$dirs = MainWP_System_Utility::get_mainwp_dir( 'site-icons', true ); |
| 1114 |
$icon_base = $dirs[1]; |
| 1115 |
$scr = $icon_base . $uploaded; |
| 1116 |
$icon_wrapper_attr = ' class="' . esc_attr( $default_cls ) . ' ui mini circular image " '; |
| 1117 |
if ( 'display_edit' === $type ) { |
| 1118 |
$icon_wrapper_attr = ' id="mainw_managesites_add_edit_site_upload_custom_icon" class="' . esc_attr( $default_cls ) . ' ui mini circular image" '; |
| 1119 |
} |
| 1120 |
$icon = '<div style="display:inline-block;" ' . $icon_wrapper_attr . '><img style="' . $style . '" src="' . esc_attr( $scr ) . '" alt="Site icon"/></div>'; |
| 1121 |
} |
| 1122 |
$output = $icon; |
| 1123 |
} |
| 1124 |
return $output; |
| 1125 |
} |
| 1126 |
|
| 1127 |
|
| 1128 |
/** |
| 1129 |
* Method render_bulk_new_site() |
| 1130 |
* |
| 1131 |
* Render Import Sites - bulk new site modal. |
| 1132 |
* |
| 1133 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_import_sites() |
| 1134 |
*/ |
| 1135 |
public static function render_bulk_new_site() { |
| 1136 |
$showpage = 'BulkAddNew'; |
| 1137 |
static::render_header( $showpage ); |
| 1138 |
if ( ! mainwp_current_user_have_right( 'dashboard', 'add_sites' ) ) { |
| 1139 |
mainwp_do_not_have_permissions( esc_html__( 'add sites', 'mainwp' ) ); |
| 1140 |
return; |
| 1141 |
} elseif ( isset( $_FILES['mainwp_managesites_file_bulkupload'] ) && isset( $_FILES['mainwp_managesites_file_bulkupload']['error'] ) && UPLOAD_ERR_OK === $_FILES['mainwp_managesites_file_bulkupload']['error'] && check_admin_referer( 'mainwp-admin-nonce' ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 1142 |
?> |
| 1143 |
<div class="ui large modal" id="mainwp-import-sites-modal"> |
| 1144 |
<i class="close icon"></i> |
| 1145 |
<div class="header"><?php esc_html_e( 'Import Sites', 'mainwp' ); ?></div> |
| 1146 |
<div class="scrolling header"> |
| 1147 |
<?php MainWP_Manage_Sites_View::render_import_sites(); ?> |
| 1148 |
</div> |
| 1149 |
<div class="actions"> |
| 1150 |
<input type="button" name="mainwp_managesites_btn_import" id="mainwp_managesites_btn_import" class="ui basic button" value="<?php esc_attr_e( 'Pause', 'mainwp' ); ?>"/> |
| 1151 |
<input type="button" name="mainwp_managesites_btn_save_csv" id="mainwp_managesites_btn_save_csv" disabled="disabled" class="ui basic green button" value="<?php esc_attr_e( 'Save failed', 'mainwp' ); ?>"/> |
| 1152 |
</div> |
| 1153 |
</div> |
| 1154 |
<script type="text/javascript"> |
| 1155 |
jQuery( document ).ready( function () { |
| 1156 |
jQuery( "#mainwp-import-sites-modal" ).modal( { |
| 1157 |
closable: false, |
| 1158 |
onHide: function() { |
| 1159 |
location.href = 'admin.php?page=managesites&do=bulknew'; |
| 1160 |
} |
| 1161 |
} ).modal( 'show' ); |
| 1162 |
} ); |
| 1163 |
</script> |
| 1164 |
<?php |
| 1165 |
} else { |
| 1166 |
?> |
| 1167 |
<div class="ui segment" id="mainwp-import-sites"> |
| 1168 |
<?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-import-sites-info-message' ) ) : ?> |
| 1169 |
<div class="ui info message"> |
| 1170 |
<i class="close icon mainwp-notice-dismiss" notice-id="mainwp-import-sites-info-message"></i> |
| 1171 |
<?php printf( esc_html__( 'You can download the sample CSV file to see how to format the import file properly. For additional help, please check this %1$shelp documentation%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/import-sites/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); // NOSONAR - noopener - open safe. ?> |
| 1172 |
</div> |
| 1173 |
<?php endif; ?> |
| 1174 |
<div id="mainwp-message-zone" class="ui message" style="display:none"></div> |
| 1175 |
<h3 class="ui dividing header"> |
| 1176 |
<?php esc_html_e( 'Import Sites', 'mainwp' ); ?> |
| 1177 |
<div class="sub header"><?php esc_html_e( 'Import multiple websites to your MainWP Dashboard.', 'mainwp' ); ?></div> |
| 1178 |
</h3> |
| 1179 |
<form method="POST" action="" enctype="multipart/form-data" id="mainwp_managesites_bulkadd_form" class="ui form"> |
| 1180 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 1181 |
<div class="ui grid field"> |
| 1182 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Upload the CSV file', 'mainwp' ); ?></label> |
| 1183 |
<div class="ten wide column"> |
| 1184 |
<div class="ui file input"> |
| 1185 |
<input type="file" name="mainwp_managesites_file_bulkupload" id="mainwp_managesites_file_bulkupload" accept="text/comma-separated-values"/> |
| 1186 |
</div> |
| 1187 |
</div> |
| 1188 |
</div> |
| 1189 |
<div class="ui grid field"> |
| 1190 |
<label class="six wide column middle aligned"><?php esc_html_e( 'CSV file contains a header', 'mainwp' ); ?></label> |
| 1191 |
<div class="ui toggle checkbox"> |
| 1192 |
<input type="checkbox" name="mainwp_managesites_chk_header_first" checked="checked" id="mainwp_managesites_chk_header_first" value="1"/> |
| 1193 |
</div> |
| 1194 |
</div> |
| 1195 |
<div class="ui divider"></div> |
| 1196 |
<input type="button" name="mainwp_managesites_add" id="mainwp_managesites_bulkadd" class="ui big green button" value="<?php esc_attr_e( 'Import Sites', 'mainwp' ); ?>"/> |
| 1197 |
<a href="<?php echo esc_url( MAINWP_PLUGIN_URL . 'assets/csv/sample.csv' ); ?>" class="ui big green basic right floated button"><?php esc_html_e( 'Download Sample CSV file', 'mainwp' ); ?></a> |
| 1198 |
</form> |
| 1199 |
</div> |
| 1200 |
<?php |
| 1201 |
|
| 1202 |
} |
| 1203 |
static::render_footer( $showpage ); |
| 1204 |
} |
| 1205 |
|
| 1206 |
/** |
| 1207 |
* Method on_load_page_dashboard() |
| 1208 |
* |
| 1209 |
* Add individual meta boxes. |
| 1210 |
* |
| 1211 |
* @uses \MainWP\Dashboard\MainWP_System_Handler::apply_filters() |
| 1212 |
* @uses \MainWP\Dashboard\MainWP_UI::add_widget_box() |
| 1213 |
* @uses \MainWP\Dashboard\MainWP_Notes::get_class_name() |
| 1214 |
* @uses \MainWP\Dashboard\MainWP_Recent_Pages::get_class_name() |
| 1215 |
* @uses \MainWP\Dashboard\MainWP_Recent_Posts::get_class_name() |
| 1216 |
* @uses \MainWP\Dashboard\MainWP_Security_Issues_Widget::get_class_name() |
| 1217 |
* @uses \MainWP\Dashboard\MainWP_Site_Info::get_class_name() |
| 1218 |
* @uses \MainWP\Dashboard\MainWP_Updates_Overview::get_class_name() |
| 1219 |
* @uses \MainWP\Dashboard\MainWP_Widget_Plugins::get_class_name() |
| 1220 |
* @uses \MainWP\Dashboard\MainWP_Widget_Themes::get_class_name() |
| 1221 |
*/ |
| 1222 |
public static function on_load_page_dashboard() { // phpcs:ignore -- NOSONAR - current complexity is required to achieve desired results. Pull request solutions are welcome. |
| 1223 |
wp_enqueue_script( 'common' ); |
| 1224 |
wp_enqueue_script( 'wp-lists' ); |
| 1225 |
wp_enqueue_script( 'postbox' ); |
| 1226 |
wp_enqueue_script( 'dashboard' ); |
| 1227 |
wp_enqueue_script( 'widgets' ); |
| 1228 |
|
| 1229 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1230 |
$dashboard_siteid = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : null; |
| 1231 |
// phpcs:enable |
| 1232 |
|
| 1233 |
/** |
| 1234 |
* Get getmetaboxes |
| 1235 |
* |
| 1236 |
* Adds metaboxes (widgets) to the Overview page. |
| 1237 |
* |
| 1238 |
* @since Unknown |
| 1239 |
*/ |
| 1240 |
$extMetaBoxs = MainWP_System_Handler::instance()->apply_filters( 'mainwp-getmetaboxes', array() ); // @deprecated Use 'mainwp_getmetaboxes' instead. |
| 1241 |
$extMetaBoxs = apply_filters( 'mainwp_getmetaboxes', $extMetaBoxs, $dashboard_siteid ); // hooks load widgets for individual overview page and for manage sites's subpage. |
| 1242 |
|
| 1243 |
foreach ( $extMetaBoxs as $box ) { |
| 1244 |
// to compatible. |
| 1245 |
if ( isset( $box['custom'] ) && $box['custom'] && isset( $box['plugin'] ) ) { |
| 1246 |
continue; |
| 1247 |
} |
| 1248 |
|
| 1249 |
if ( isset( $box['plugin'] ) ) { |
| 1250 |
$name = basename( $box['plugin'], '.php' ); |
| 1251 |
static::$enable_widgets[ $name ] = true; |
| 1252 |
} elseif ( isset( $box['widget_id'] ) ) { |
| 1253 |
static::$enable_widgets[ $box['widget_id'] ] = true; |
| 1254 |
} |
| 1255 |
} |
| 1256 |
|
| 1257 |
$values = static::$enable_widgets; |
| 1258 |
|
| 1259 |
/** |
| 1260 |
* Unset unwanted Widgets |
| 1261 |
* |
| 1262 |
* Contains the list of enabled widgets and allows user to unset unwanted widgets. |
| 1263 |
* |
| 1264 |
* @param array $values Array containing enabled widgets. |
| 1265 |
* @param int $dashboard_siteid Child site (Overview) ID. |
| 1266 |
* |
| 1267 |
* @since 4.0 |
| 1268 |
*/ |
| 1269 |
$values = apply_filters( 'mainwp_overview_enabled_widgets', $values, $dashboard_siteid ); |
| 1270 |
static::$enable_widgets = array_merge( static::$enable_widgets, $values ); |
| 1271 |
|
| 1272 |
$i = 0; |
| 1273 |
foreach ( $extMetaBoxs as $metaBox ) { |
| 1274 |
$enabled = true; |
| 1275 |
if ( isset( $metaBox['plugin'] ) ) { |
| 1276 |
$name = basename( $metaBox['plugin'], '.php' ); |
| 1277 |
if ( isset( static::$enable_widgets[ $name ] ) && ! static::$enable_widgets[ $name ] ) { |
| 1278 |
$enabled = false; |
| 1279 |
} |
| 1280 |
} |
| 1281 |
|
| 1282 |
$id = isset( $metaBox['id'] ) ? $metaBox['id'] : $i++; |
| 1283 |
$id = 'advanced-' . $id; |
| 1284 |
|
| 1285 |
if ( $enabled ) { |
| 1286 |
$layout = array( 1, 1, 4, 11 ); |
| 1287 |
if ( isset( $metaBox['id'] ) && ( 'google-widget' === $metaBox['id'] || 'matomo' === $metaBox['id'] ) ) { |
| 1288 |
$layout = array( 1, 1, 4, 15 ); |
| 1289 |
} |
| 1290 |
$layout = ! empty( $metaBox['layout'] ) && is_array( $metaBox['layout'] ) ? $metaBox['layout'] : $layout; |
| 1291 |
MainWP_UI::add_widget_box( $id, $metaBox['callback'], static::$page, $layout ); |
| 1292 |
} |
| 1293 |
} |
| 1294 |
|
| 1295 |
// Load the Notes widget. |
| 1296 |
if ( static::$enable_widgets['notes'] ) { |
| 1297 |
MainWP_UI::add_widget_box( 'notes', array( MainWP_Notes::get_class_name(), 'render' ), static::$page, array( 1, 1, 4, 11 ) ); |
| 1298 |
} |
| 1299 |
|
| 1300 |
// Load the Client widget. |
| 1301 |
if ( static::$enable_widgets['client_info'] ) { |
| 1302 |
MainWP_UI::add_widget_box( 'client_info', array( MainWP_Client_Info::get_class_name(), 'render' ), static::$page, array( 1, 1, 4, 11 ) ); |
| 1303 |
} |
| 1304 |
|
| 1305 |
// Load the Recent Pages widget. |
| 1306 |
if ( mainwp_current_user_have_right( 'dashboard', 'manage_pages' ) && static::$enable_widgets['recent_pages'] ) { |
| 1307 |
MainWP_UI::add_widget_box( 'recent_pages', array( MainWP_Recent_Pages::get_class_name(), 'render' ), static::$page, array( 1, 1, 6, 11 ) ); |
| 1308 |
} |
| 1309 |
|
| 1310 |
// Load the Recent Posts widget. |
| 1311 |
if ( mainwp_current_user_have_right( 'dashboard', 'manage_posts' ) && static::$enable_widgets['recent_posts'] ) { |
| 1312 |
MainWP_UI::add_widget_box( 'recent_posts', array( MainWP_Recent_Posts::get_class_name(), 'render' ), static::$page, array( 1, 1, 6, 11 ) ); |
| 1313 |
} |
| 1314 |
|
| 1315 |
// Load the Themes widget. |
| 1316 |
if ( static::$enable_widgets['themes'] ) { |
| 1317 |
MainWP_UI::add_widget_box( 'themes', array( MainWP_Widget_Themes::get_class_name(), 'render' ), static::$page, array( 1, 1, 6, 11 ) ); |
| 1318 |
} |
| 1319 |
|
| 1320 |
// Load the Pluins widget. |
| 1321 |
if ( static::$enable_widgets['plugins'] ) { |
| 1322 |
MainWP_UI::add_widget_box( 'plugins', array( MainWP_Widget_Plugins::get_class_name(), 'render' ), static::$page, array( 1, 1, 6, 11 ) ); |
| 1323 |
} |
| 1324 |
|
| 1325 |
// Load the Non-MainWP Changes widget. |
| 1326 |
if ( static::$enable_widgets['non_mainwp_changes'] ) { |
| 1327 |
MainWP_UI::add_widget_box( 'non_mainwp_changes', array( MainWP_Site_Actions::get_class_name(), 'render' ), static::$page, array( 1, 1, 4, 10 ) ); |
| 1328 |
} |
| 1329 |
|
| 1330 |
// Load the Site Info widget. |
| 1331 |
MainWP_UI::add_widget_box( 'child_site_info', array( MainWP_Site_Info::get_class_name(), 'render' ), static::$page, array( 1, 1, 4, 18 ) ); |
| 1332 |
|
| 1333 |
// Load the Securtiy Issues widget. |
| 1334 |
if ( mainwp_current_user_have_right( 'dashboard', 'manage_security_issues' ) && static::$enable_widgets['security_issues'] ) { |
| 1335 |
MainWP_UI::add_widget_box( 'security_issues', array( MainWP_Security_Issues_Widget::get_class_name(), 'render_widget' ), static::$page, array( 1, 1, 4, 8 ) ); |
| 1336 |
} |
| 1337 |
|
| 1338 |
// Load the Updates Overview widget. |
| 1339 |
if ( static::$enable_widgets['overview'] ) { |
| 1340 |
MainWP_UI::add_widget_box( 'overview', array( MainWP_Updates_Overview::get_class_name(), 'render' ), static::$page, array( 1, 1, 4, 18 ) ); |
| 1341 |
} |
| 1342 |
} |
| 1343 |
|
| 1344 |
/** |
| 1345 |
* Method render_updates() |
| 1346 |
* |
| 1347 |
* Render updates. |
| 1348 |
* |
| 1349 |
* @param mixed $website Child Site. |
| 1350 |
* |
| 1351 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_Update_View::render_updates() |
| 1352 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 1353 |
*/ |
| 1354 |
public static function render_updates( $website ) { |
| 1355 |
MainWP_System_Utility::set_current_wpid( $website->id ); |
| 1356 |
static::render_header( 'ManageSitesUpdates' ); |
| 1357 |
MainWP_Manage_Sites_Update_View::render_updates( $website ); |
| 1358 |
static::render_footer( 'ManageSitesUpdates' ); |
| 1359 |
} |
| 1360 |
|
| 1361 |
/** |
| 1362 |
* Method render_email_settings() |
| 1363 |
* |
| 1364 |
* Render email settings. |
| 1365 |
* |
| 1366 |
* @param mixed $website Child Site. |
| 1367 |
* @param bool $updated updated settings. |
| 1368 |
* @param bool $updated_templ updated template file. |
| 1369 |
* |
| 1370 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1371 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_site_edit_email_settings() |
| 1372 |
* @uses \MainWP\Dashboard\MainWP_Notification_Settings::get_notification_types() |
| 1373 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 1374 |
*/ |
| 1375 |
public static function render_email_settings( $website, $updated, $updated_templ ) { |
| 1376 |
$website = MainWP_DB::instance()->get_website_by_id( $website->id, false, array( 'settings_notification_emails' ) ); // reload. |
| 1377 |
|
| 1378 |
MainWP_System_Utility::set_current_wpid( $website->id ); |
| 1379 |
|
| 1380 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1381 |
$edit = false; |
| 1382 |
$email_type = isset( $_GET['edit-email'] ) ? sanitize_text_field( wp_unslash( $_GET['edit-email'] ) ) : false; |
| 1383 |
|
| 1384 |
if ( ! empty( $email_type ) ) { |
| 1385 |
$notification_emails = MainWP_Notification_Settings::get_notification_types(); |
| 1386 |
if ( isset( $notification_emails[ $email_type ] ) ) { |
| 1387 |
$edit = true; |
| 1388 |
} |
| 1389 |
} |
| 1390 |
// phpcs:enable |
| 1391 |
|
| 1392 |
static::render_header( 'ManageSitesEmailSettings' ); |
| 1393 |
if ( $edit ) { |
| 1394 |
MainWP_Manage_Sites_View::render_site_edit_email_settings( $website, $email_type, $updated_templ ); |
| 1395 |
} else { |
| 1396 |
MainWP_Manage_Sites_View::render_edit_site_email_settings( $website, $updated ); |
| 1397 |
} |
| 1398 |
static::render_footer( 'ManageSitesEmailSettings' ); |
| 1399 |
} |
| 1400 |
|
| 1401 |
/** |
| 1402 |
* Method render_dashboard() |
| 1403 |
* |
| 1404 |
* Render Manage Sites Dashboard. |
| 1405 |
* |
| 1406 |
* @param mixed $website Child Site. |
| 1407 |
* |
| 1408 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_dashboard() |
| 1409 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 1410 |
*/ |
| 1411 |
public static function render_dashboard( $website ) { |
| 1412 |
MainWP_System_Utility::set_current_wpid( $website->id ); |
| 1413 |
static::render_header( 'ManageSitesDashboard' ); |
| 1414 |
MainWP_Manage_Sites_View::render_dashboard( $website ); |
| 1415 |
static::render_footer( 'ManageSitesDashboard' ); |
| 1416 |
} |
| 1417 |
|
| 1418 |
/** |
| 1419 |
* Method render_backup_site() |
| 1420 |
* |
| 1421 |
* Render Manage Sites Backups. |
| 1422 |
* |
| 1423 |
* @param mixed $website Child Site. |
| 1424 |
* |
| 1425 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_Backup_View::render_backup_site() |
| 1426 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 1427 |
*/ |
| 1428 |
public static function render_backup_site( $website ) { |
| 1429 |
MainWP_System_Utility::set_current_wpid( $website->id ); |
| 1430 |
static::render_header( 'ManageSitesBackups' ); |
| 1431 |
MainWP_Manage_Sites_Backup_View::render_backup_site( $website ); |
| 1432 |
static::render_footer( 'ManageSitesBackups' ); |
| 1433 |
} |
| 1434 |
|
| 1435 |
/** |
| 1436 |
* Method render_scan_site() |
| 1437 |
* |
| 1438 |
* Render Site Hardening. |
| 1439 |
* |
| 1440 |
* @param mixed $website Child Site. |
| 1441 |
* |
| 1442 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_scan_site() |
| 1443 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 1444 |
*/ |
| 1445 |
public static function render_scan_site( $website ) { |
| 1446 |
MainWP_System_Utility::set_current_wpid( $website->id ); |
| 1447 |
static::render_header( 'SecurityScan' ); |
| 1448 |
MainWP_Manage_Sites_View::render_scan_site( $website ); |
| 1449 |
static::render_footer( 'SecurityScan' ); |
| 1450 |
} |
| 1451 |
|
| 1452 |
/** |
| 1453 |
* Method show_backups() |
| 1454 |
* |
| 1455 |
* Render Backups. |
| 1456 |
* |
| 1457 |
* @param mixed $website Child Site. |
| 1458 |
* |
| 1459 |
* @uses \MainWP\Dashboard\MainWP_Backup_Handler::is_sql_file() |
| 1460 |
* @uses \MainWP\Dashboard\MainWP_Backup_Handler::is_archive() |
| 1461 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_Backup_View::show_backups() |
| 1462 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_specific_dir() |
| 1463 |
*/ |
| 1464 |
public static function show_backups( &$website ) { //phpcs:ignore -- NOSONAR - complex. |
| 1465 |
$dir = MainWP_System_Utility::get_mainwp_specific_dir( $website->id ); |
| 1466 |
|
| 1467 |
MainWP_System_Utility::touch( $dir . 'index.php' ); |
| 1468 |
|
| 1469 |
$dbBackups = array(); |
| 1470 |
$fullBackups = array(); |
| 1471 |
if ( file_exists( $dir ) ) { |
| 1472 |
$dh = opendir( $dir ); |
| 1473 |
if ( $dh ) { |
| 1474 |
while ( false !== ( $file = readdir( $dh ) ) ) { |
| 1475 |
if ( '.' !== $file && '..' !== $file ) { |
| 1476 |
$theFile = $dir . $file; |
| 1477 |
if ( MainWP_Backup_Handler::is_sql_file( $file ) ) { |
| 1478 |
$dbBackups[ filemtime( $theFile ) . $file ] = $theFile; |
| 1479 |
} elseif ( MainWP_Backup_Handler::is_archive( $file ) ) { |
| 1480 |
$fullBackups[ filemtime( $theFile ) . $file ] = $theFile; |
| 1481 |
} |
| 1482 |
} |
| 1483 |
} |
| 1484 |
closedir( $dh ); |
| 1485 |
} |
| 1486 |
} |
| 1487 |
krsort( $dbBackups ); |
| 1488 |
krsort( $fullBackups ); |
| 1489 |
|
| 1490 |
MainWP_Manage_Sites_Backup_View::show_backups( $website, $fullBackups, $dbBackups ); |
| 1491 |
} |
| 1492 |
|
| 1493 |
/** |
| 1494 |
* Method render_all_sites() |
| 1495 |
* |
| 1496 |
* Render manage sites content. |
| 1497 |
* |
| 1498 |
* @uses \MainWP\Dashboard\MainWP_UI::render_modal_edit_notes() |
| 1499 |
*/ |
| 1500 |
public static function render_all_sites() { |
| 1501 |
|
| 1502 |
static::load_sites_table();// to fix loading. |
| 1503 |
|
| 1504 |
$optimize_for_sites_table = apply_filters( 'mainwp_manage_sites_optimize_loading', 1, 'manage-sites' ); // use ajax to load sites table . |
| 1505 |
|
| 1506 |
if ( ! $optimize_for_sites_table ) { |
| 1507 |
static::$sitesTable->prepare_items( false ); |
| 1508 |
} |
| 1509 |
|
| 1510 |
static::render_header( '' ); |
| 1511 |
|
| 1512 |
$hide_loading = apply_filters( 'mainwp_manage_sites_hide_loading', false ); |
| 1513 |
?> |
| 1514 |
<div id="mainwp-manage-sites-content" class="ui segment"> |
| 1515 |
<div id="mainwp-message-zone" class="ui message"></div> |
| 1516 |
<div class="ui active inverted dimmer" <?php echo $hide_loading ? 'style="display:none;"' : ''; ?> id="mainwp-sites-table-loader"> |
| 1517 |
<div class="ui large text loader"><?php esc_html_e( 'Loading sites...', 'mainwp' ); ?></div> |
| 1518 |
</div> |
| 1519 |
<form method="post" class="mainwp-table-container"> |
| 1520 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 1521 |
<?php |
| 1522 |
static::$sitesTable->display( $optimize_for_sites_table ); |
| 1523 |
static::$sitesTable->clear_items(); |
| 1524 |
?> |
| 1525 |
</form> |
| 1526 |
</div> |
| 1527 |
<?php MainWP_UI::render_modal_edit_notes(); ?> |
| 1528 |
<div class="ui modal" id="managesites-backup-box" tabindex="0"> |
| 1529 |
<div class="header"><?php esc_html_e( 'Full backup required', 'mainwp' ); ?></div> |
| 1530 |
<div class="content mainwp-modal-content"></div> |
| 1531 |
<div class="actions mainwp-modal-actions"> |
| 1532 |
<input id="managesites-backup-all" type="button" name="Backup All" value="<?php esc_attr_e( 'Backup all', 'mainwp' ); ?>" class="button-primary"/> |
| 1533 |
<a id="managesites-backup-now" href="#" target="_blank" style="display: none" class="button-primary button"><?php esc_html_e( 'Backup Now', 'mainwp' ); ?></a> |
| 1534 |
<input id="managesites-backup-ignore" type="button" name="Ignore" value="<?php esc_attr_e( 'Ignore', 'mainwp' ); ?>" class="button"/> |
| 1535 |
</div> |
| 1536 |
</div> |
| 1537 |
<?php |
| 1538 |
static::render_screen_options(); |
| 1539 |
static::render_footer( '' ); |
| 1540 |
} |
| 1541 |
|
| 1542 |
/** |
| 1543 |
* Method render_manage_sites() |
| 1544 |
* |
| 1545 |
* Render Manage Sites Page. |
| 1546 |
* |
| 1547 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id() |
| 1548 |
* @uses \MainWP\Dashboard\MainWP_Notification_Template::handle_template_file_action() |
| 1549 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::can_edit_website() |
| 1550 |
*/ |
| 1551 |
public static function render_manage_sites() { // phpcs:ignore -- NOSONAR - complex function. Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 1552 |
|
| 1553 |
/** |
| 1554 |
* Current user global. |
| 1555 |
* |
| 1556 |
* @global string |
| 1557 |
*/ |
| 1558 |
global $current_user; |
| 1559 |
|
| 1560 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1561 |
if ( isset( $_REQUEST['do'] ) ) { |
| 1562 |
if ( 'new' === $_REQUEST['do'] ) { |
| 1563 |
static::render_new_site(); |
| 1564 |
} elseif ( 'bulknew' === $_REQUEST['do'] ) { |
| 1565 |
static::render_bulk_new_site(); |
| 1566 |
} |
| 1567 |
|
| 1568 |
return; |
| 1569 |
} |
| 1570 |
|
| 1571 |
if ( get_option( 'mainwp_enableLegacyBackupFeature' ) && ! empty( $_GET['backupid'] ) ) { |
| 1572 |
$websiteid = ! empty( $_GET['backupid'] ) ? intval( $_GET['backupid'] ) : false; |
| 1573 |
$backupwebsite = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 1574 |
if ( MainWP_System_Utility::can_edit_website( $backupwebsite ) ) { |
| 1575 |
static::render_backup_site( $backupwebsite ); |
| 1576 |
return; |
| 1577 |
} |
| 1578 |
} |
| 1579 |
|
| 1580 |
if ( isset( $_GET['scanid'] ) ) { |
| 1581 |
$websiteid = intval( $_GET['scanid'] ); |
| 1582 |
|
| 1583 |
$scanwebsite = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 1584 |
if ( MainWP_System_Utility::can_edit_website( $scanwebsite ) ) { |
| 1585 |
static::render_scan_site( $scanwebsite ); |
| 1586 |
|
| 1587 |
return; |
| 1588 |
} |
| 1589 |
} |
| 1590 |
|
| 1591 |
if ( isset( $_GET['dashboard'] ) ) { |
| 1592 |
$websiteid = intval( $_GET['dashboard'] ); |
| 1593 |
|
| 1594 |
$dashboardWebsite = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 1595 |
if ( MainWP_System_Utility::can_edit_website( $dashboardWebsite ) ) { |
| 1596 |
static::render_dashboard( $dashboardWebsite ); |
| 1597 |
|
| 1598 |
return; |
| 1599 |
} |
| 1600 |
} |
| 1601 |
|
| 1602 |
if ( isset( $_GET['updateid'] ) ) { |
| 1603 |
$websiteid = intval( $_GET['updateid'] ); |
| 1604 |
$updatesWebsite = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 1605 |
if ( MainWP_System_Utility::can_edit_website( $updatesWebsite ) ) { |
| 1606 |
static::render_updates( $updatesWebsite ); |
| 1607 |
return; |
| 1608 |
} |
| 1609 |
} |
| 1610 |
|
| 1611 |
if ( ! empty( $_GET['emailsettingsid'] ) ) { |
| 1612 |
$websiteid = intval( $_GET['emailsettingsid'] ); |
| 1613 |
$website = MainWP_DB::instance()->get_website_by_id( $websiteid, false, array( 'settings_notification_emails' ) ); |
| 1614 |
if ( MainWP_System_Utility::can_edit_website( $website ) ) { |
| 1615 |
// Edit email settings. |
| 1616 |
$updated = static::update_site_emails_settings_handle( $website ); |
| 1617 |
$updated_templ = MainWP_Notification_Template::instance()->handle_template_file_action(); |
| 1618 |
static::render_email_settings( $website, $updated, $updated_templ ); |
| 1619 |
return; |
| 1620 |
} |
| 1621 |
} |
| 1622 |
|
| 1623 |
if ( isset( $_GET['id'] ) ) { |
| 1624 |
$websiteid = intval( $_GET['id'] ); |
| 1625 |
$website = MainWP_DB::instance()->get_website_by_id( $websiteid ); |
| 1626 |
if ( MainWP_System_Utility::can_edit_website( $website ) ) { |
| 1627 |
// Edit website. |
| 1628 |
$updated = static::update_site_handle( $website ); |
| 1629 |
static::render_edit_site( $websiteid, $updated ); |
| 1630 |
return; |
| 1631 |
} |
| 1632 |
} |
| 1633 |
// phpcs:enable |
| 1634 |
|
| 1635 |
$sitesViewMode = MainWP_Utility::get_siteview_mode(); |
| 1636 |
if ( 'grid' === $sitesViewMode ) { |
| 1637 |
MainWP_Manage_Screenshots::render_all_sites(); |
| 1638 |
} else { |
| 1639 |
static::render_all_sites(); |
| 1640 |
} |
| 1641 |
MainWP_Logger::instance()->log_execution_time( 'render_manage_sites()' ); |
| 1642 |
} |
| 1643 |
|
| 1644 |
|
| 1645 |
/** |
| 1646 |
* Method update_site_emails_settings_handle() |
| 1647 |
* |
| 1648 |
* Handle site email settings update. |
| 1649 |
* |
| 1650 |
* @param mixed $website Child Site object. |
| 1651 |
* |
| 1652 |
* @return bool $updated Updated. |
| 1653 |
* |
| 1654 |
* @uses \MainWP\Dashboard\MainWP_DB::get_website_option() |
| 1655 |
* @uses \MainWP\Dashboard\MainWP_Notification_Settings::get_notification_types() |
| 1656 |
* @uses \MainWP\Dashboard\MainWP_Utility::valid_input_emails() |
| 1657 |
*/ |
| 1658 |
private static function update_site_emails_settings_handle( $website ) { // phpcs:ignore -- NOSONAR - complex. |
| 1659 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1660 |
$updated = false; |
| 1661 |
if ( isset( $_POST['submit'] ) && isset( $_GET['emailsettingsid'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'UpdateWebsiteEmailSettings' . sanitize_text_field( wp_unslash( $_GET['emailsettingsid'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1662 |
$settings_emails = MainWP_DB::instance()->get_website_option( $website, 'settings_notification_emails', '' ); |
| 1663 |
$settings_emails = ! empty( $settings_emails ) ? json_decode( $settings_emails, true ) : $settings_emails; |
| 1664 |
if ( ! is_array( $settings_emails ) ) { |
| 1665 |
$settings_emails = array(); |
| 1666 |
} |
| 1667 |
|
| 1668 |
$notification_emails = MainWP_Notification_Settings::get_notification_types(); |
| 1669 |
$type = isset( $_POST['mainwp_managesites_setting_emails_type'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_setting_emails_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1670 |
$edit_settingEmails = isset( $_POST['mainwp_managesites_edit_settingEmails'][ $type ] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_managesites_edit_settingEmails'][ $type ] ) ) : array(); // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1671 |
|
| 1672 |
if ( isset( $notification_emails[ $type ] ) && ! empty( $edit_settingEmails ) ) { |
| 1673 |
$update_settings = $edit_settingEmails; |
| 1674 |
$update_settings['recipients'] = MainWP_Utility::valid_input_emails( $edit_settingEmails['recipients'] ); |
| 1675 |
$update_settings['disable'] = isset( $edit_settingEmails['disable'] ) ? 0 : 1; // isset 'on' means enable (0), not isset mean disabled (1). |
| 1676 |
|
| 1677 |
/** |
| 1678 |
* Action: mainwp_before_save_email_settings |
| 1679 |
* |
| 1680 |
* Fires before save email settings. |
| 1681 |
* |
| 1682 |
* @since 4.1 |
| 1683 |
*/ |
| 1684 |
do_action( 'mainwp_before_save_email_settings', $type, $update_settings, $website ); |
| 1685 |
|
| 1686 |
$settings_emails[ $type ] = $update_settings; |
| 1687 |
MainWP_DB::instance()->update_website_option( $website, 'settings_notification_emails', wp_json_encode( $settings_emails ) ); |
| 1688 |
$updated = true; |
| 1689 |
|
| 1690 |
/** |
| 1691 |
* Action: mainwp_after_save_email_settings |
| 1692 |
* |
| 1693 |
* Fires after save email settings. |
| 1694 |
* |
| 1695 |
* @since 4.1 |
| 1696 |
*/ |
| 1697 |
do_action( 'mainwp_after_save_email_settings', $settings_emails ); |
| 1698 |
|
| 1699 |
} |
| 1700 |
} |
| 1701 |
// phpcs:enable |
| 1702 |
return $updated; |
| 1703 |
} |
| 1704 |
|
| 1705 |
/** |
| 1706 |
* Method update_site_handle() |
| 1707 |
* |
| 1708 |
* Handle site update. |
| 1709 |
* |
| 1710 |
* @param mixed $website Child Site object. |
| 1711 |
* |
| 1712 |
* @return bool $updated Updated. |
| 1713 |
* |
| 1714 |
* @uses \MainWP\Dashboard\MainWP_DB::update_website() |
| 1715 |
* @uses \MainWP\Dashboard\MainWP_DB::update_website_values() |
| 1716 |
* @uses \MainWP\Dashboard\MainWP_DB::update_website_option() |
| 1717 |
* @uses \MainWP\Dashboard\MainWP_Utility::remove_http_prefix() |
| 1718 |
* @uses \MainWP\Dashboard\MainWP_Utility::valid_input_emails() |
| 1719 |
*/ |
| 1720 |
private static function update_site_handle( $website ) { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 1721 |
|
| 1722 |
/** |
| 1723 |
* Current user global. |
| 1724 |
* |
| 1725 |
* @global string |
| 1726 |
*/ |
| 1727 |
global $current_user; |
| 1728 |
|
| 1729 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 1730 |
$updated = false; |
| 1731 |
if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && isset( $_REQUEST['id'] ) && isset( $_POST['mainwp_managesites_edit_siteadmin'] ) && ( '' !== $_POST['mainwp_managesites_edit_siteadmin'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'UpdateWebsite' . sanitize_key( $_REQUEST['id'] ) ) && mainwp_current_user_have_right( 'dashboard', 'edit_sites' ) ) { |
| 1732 |
// update site. |
| 1733 |
$groupids = array(); |
| 1734 |
$groupnames = array(); |
| 1735 |
if ( isset( $_POST['mainwp_managesites_edit_addgroups'] ) && ! empty( $_POST['mainwp_managesites_edit_addgroups'] ) ) { |
| 1736 |
$groupids = explode( ',', sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_addgroups'] ) ) ); |
| 1737 |
} |
| 1738 |
|
| 1739 |
// to fix update staging site. |
| 1740 |
if ( $website->is_staging ) { |
| 1741 |
$stag_gid = get_option( 'mainwp_stagingsites_group_id' ); |
| 1742 |
if ( $stag_gid && ! in_array( $stag_gid, $groupids, true ) ) { |
| 1743 |
$groupids[] = $stag_gid; |
| 1744 |
} |
| 1745 |
} |
| 1746 |
|
| 1747 |
$newPluginDir = ''; |
| 1748 |
|
| 1749 |
$maximumFileDescriptorsOverride = isset( $_POST['mainwp_options_maximumFileDescriptorsOverride'] ); |
| 1750 |
$maximumFileDescriptorsAuto = isset( $_POST['mainwp_maximumFileDescriptorsAuto'] ); |
| 1751 |
$maximumFileDescriptors = isset( $_POST['mainwp_options_maximumFileDescriptors'] ) ? intval( $_POST['mainwp_options_maximumFileDescriptors'] ) : 150; |
| 1752 |
|
| 1753 |
$archiveFormat = isset( $_POST['mainwp_archiveFormat'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_archiveFormat'] ) ) : 'global'; |
| 1754 |
|
| 1755 |
$http_user = isset( $_POST['mainwp_managesites_edit_http_user'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_http_user'] ) ) : ''; |
| 1756 |
$http_pass = isset( $_POST['mainwp_managesites_edit_http_pass'] ) ? wp_unslash( $_POST['mainwp_managesites_edit_http_pass'] ) : ''; |
| 1757 |
$url = ( isset( $_POST['mainwp_managesites_edit_wpurl_with_www'] ) && ( 'www' === sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_wpurl_with_www'] ) ) ) ? 'www.' : '' ) . MainWP_Utility::remove_http_www_prefix( $website->url, true ); |
| 1758 |
$url = ( isset( $_POST['mainwp_managesites_edit_siteurl_protocol'] ) && ( 'https' === sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_siteurl_protocol'] ) ) ) ? 'https' : 'http' ) . '://' . MainWP_Utility::remove_http_prefix( $url, true ); |
| 1759 |
|
| 1760 |
$disableChecking = isset( $_POST['mainwp_managesites_edit_disableChecking'] ) ? 0 : 1; |
| 1761 |
$checkInterval = isset( $_POST['mainwp_managesites_edit_checkInterval'] ) ? intval( $_POST['mainwp_managesites_edit_checkInterval'] ) : 1440; |
| 1762 |
$disableHealthChecking = isset( $_POST['mainwp_managesites_edit_disableSiteHealthMonitoring'] ) ? 0 : 1; |
| 1763 |
$healthThreshold = isset( $_POST['mainwp_managesites_edit_healthThreshold'] ) ? intval( $_POST['mainwp_managesites_edit_healthThreshold'] ) : 80; |
| 1764 |
|
| 1765 |
$site_name = isset( $_POST['mainwp_managesites_edit_sitename'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_sitename'] ) ) : ''; |
| 1766 |
$site_admin = isset( $_POST['mainwp_managesites_edit_siteadmin'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_siteadmin'] ) ) : ''; |
| 1767 |
$verifycertificate = isset( $_POST['mainwp_managesites_edit_verifycertificate'] ) ? intval( $_POST['mainwp_managesites_edit_verifycertificate'] ) : ''; |
| 1768 |
$uniqueId = isset( $_POST['mainwp_managesites_edit_uniqueId'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_uniqueId'] ) ) : ''; |
| 1769 |
$ssl_version = isset( $_POST['mainwp_managesites_edit_ssl_version'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_ssl_version'] ) ) : ''; |
| 1770 |
|
| 1771 |
MainWP_DB::instance()->update_website( $website->id, $url, $current_user->ID, $site_name, $site_admin, $groupids, $groupnames, $newPluginDir, $maximumFileDescriptorsOverride, $maximumFileDescriptorsAuto, $maximumFileDescriptors, $verifycertificate, $archiveFormat, $uniqueId, $http_user, $http_pass, $ssl_version, $disableChecking, $checkInterval, $disableHealthChecking, $healthThreshold ); |
| 1772 |
|
| 1773 |
$new_client_id = isset( $_POST['mainwp_managesites_edit_client_id'] ) ? intval( $_POST['mainwp_managesites_edit_client_id'] ) : 0; |
| 1774 |
|
| 1775 |
if ( $website->client_id !== $new_client_id ) { |
| 1776 |
|
| 1777 |
$update = array( |
| 1778 |
'client_id' => $new_client_id, |
| 1779 |
); |
| 1780 |
MainWP_DB::instance()->update_website_values( $website->id, $update ); |
| 1781 |
} |
| 1782 |
|
| 1783 |
/** |
| 1784 |
* Update site |
| 1785 |
* |
| 1786 |
* Fires after updating a website settings. |
| 1787 |
* |
| 1788 |
* @param int $website->id Child site ID. |
| 1789 |
* |
| 1790 |
* @since 3.4 |
| 1791 |
*/ |
| 1792 |
do_action( 'mainwp_update_site', $website->id ); |
| 1793 |
|
| 1794 |
$backup_before_upgrade = isset( $_POST['mainwp_backup_before_upgrade'] ) ? intval( $_POST['mainwp_backup_before_upgrade'] ) : 2; |
| 1795 |
if ( 2 < $backup_before_upgrade ) { |
| 1796 |
$backup_before_upgrade = 2; |
| 1797 |
} |
| 1798 |
|
| 1799 |
$forceuseipv4 = isset( $_POST['mainwp_managesites_edit_forceuseipv4'] ) ? intval( $_POST['mainwp_managesites_edit_forceuseipv4'] ) : 0; |
| 1800 |
if ( 2 < $forceuseipv4 ) { |
| 1801 |
$forceuseipv4 = 0; |
| 1802 |
} |
| 1803 |
|
| 1804 |
$old_suspended = (int) $website->suspended; |
| 1805 |
$suspended = isset( $_POST['mainwp_suspended_site'] ) ? 1 : 0; |
| 1806 |
$newValues = array( |
| 1807 |
'automatic_update' => ( ! isset( $_POST['mainwp_automaticDailyUpdate'] ) ? 0 : 1 ), |
| 1808 |
'backup_before_upgrade' => $backup_before_upgrade, |
| 1809 |
'force_use_ipv4' => $forceuseipv4, |
| 1810 |
'loadFilesBeforeZip' => isset( $_POST['mainwp_options_loadFilesBeforeZip'] ) ? 1 : 0, |
| 1811 |
'suspended' => $suspended, |
| 1812 |
); |
| 1813 |
|
| 1814 |
if ( mainwp_current_user_have_right( 'dashboard', 'ignore_unignore_updates' ) ) { |
| 1815 |
$newValues['is_ignoreCoreUpdates'] = ! empty( $_POST['mainwp_is_ignoreCoreUpdates'] ) ? 1 : 0; |
| 1816 |
$newValues['is_ignorePluginUpdates'] = ! empty( $_POST['mainwp_is_ignorePluginUpdates'] ) ? 1 : 0; |
| 1817 |
$newValues['is_ignoreThemeUpdates'] = ! empty( $_POST['mainwp_is_ignoreThemeUpdates'] ) ? 1 : 0; |
| 1818 |
} |
| 1819 |
|
| 1820 |
MainWP_DB::instance()->update_website_values( $website->id, $newValues ); |
| 1821 |
|
| 1822 |
$monitoring_emails = isset( $_POST['mainwp_managesites_edit_monitoringNotificationEmails'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_monitoringNotificationEmails'] ) ) : ''; |
| 1823 |
$monitoring_emails = MainWP_Utility::valid_input_emails( $monitoring_emails ); |
| 1824 |
MainWP_DB::instance()->update_website_option( $website, 'monitoring_notification_emails', $monitoring_emails ); |
| 1825 |
|
| 1826 |
$added = isset( $_POST['mainwp_managesites_edit_dt_added'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_dt_added'] ) ) : ''; |
| 1827 |
if ( ! empty( $added ) ) { |
| 1828 |
$added = strtotime( $added ); |
| 1829 |
} |
| 1830 |
MainWP_DB::instance()->update_website_option( $website, 'added_timestamp', $added ); |
| 1831 |
|
| 1832 |
$new_alg = isset( $_POST['mainwp_managesites_edit_openssl_alg'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_openssl_alg'] ) ) : ''; |
| 1833 |
MainWP_DB::instance()->update_website_option( $website, 'signature_algo', $new_alg ); |
| 1834 |
|
| 1835 |
$use_lib = isset( $_POST['mainwp_managesites_edit_verify_connection_method'] ) ? intval( $_POST['mainwp_managesites_edit_verify_connection_method'] ) : 0; |
| 1836 |
MainWP_DB::instance()->update_website_option( $website, 'verify_method', $use_lib ); |
| 1837 |
|
| 1838 |
$uploaded_site_icon = isset( $_POST['mainwp_managesites_edit_site_uploaded_icon_hidden'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_site_uploaded_icon_hidden'] ) ) : ''; |
| 1839 |
$selected_site_icon = isset( $_POST['mainwp_managesites_edit_site_selected_icon_hidden'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_managesites_edit_site_selected_icon_hidden'] ) ) : ''; |
| 1840 |
$cust_icon_color = isset( $_POST['mainwp_managesites_edit_site_color'] ) ? sanitize_hex_color( wp_unslash( $_POST['mainwp_managesites_edit_site_color'] ) ) : ''; |
| 1841 |
$icon_info = 'uploaded:' . $uploaded_site_icon . ';selected:' . $selected_site_icon . ';color:' . $cust_icon_color; |
| 1842 |
MainWP_DB::instance()->update_website_option( $website, 'cust_site_icon_info', $icon_info ); |
| 1843 |
|
| 1844 |
if ( ! empty( $website->cust_site_icon_info ) ) { |
| 1845 |
$current_uploaded = static::get_instance()->get_cust_site_icon( $website->cust_site_icon_info, 'uploaded' ); |
| 1846 |
if ( ! empty( $current_uploaded ) && $current_uploaded !== $uploaded_site_icon ) { |
| 1847 |
MainWP_Utility::instance()->delete_uploaded_icon_file( 'site-icons', $current_uploaded ); // delete old icon. |
| 1848 |
} |
| 1849 |
} |
| 1850 |
|
| 1851 |
/** |
| 1852 |
* Update site |
| 1853 |
* |
| 1854 |
* Fires after updating a website settings. |
| 1855 |
* |
| 1856 |
* @param int $website Child site Ọbject. |
| 1857 |
* |
| 1858 |
* @since 3.4 |
| 1859 |
*/ |
| 1860 |
do_action( 'mainwp_site_updated', $website, $_POST ); |
| 1861 |
|
| 1862 |
if ( $old_suspended !== $suspended ) { // changed suspended. |
| 1863 |
/** |
| 1864 |
* Site suspended changed. |
| 1865 |
* |
| 1866 |
* Fires after suspended a website changed. |
| 1867 |
* |
| 1868 |
* @param int $website->id Child site ID. |
| 1869 |
* |
| 1870 |
* @since 4.5.1.1 |
| 1871 |
*/ |
| 1872 |
do_action( 'mainwp_site_suspended', $website, $suspended ); |
| 1873 |
} |
| 1874 |
$updated = true; |
| 1875 |
} |
| 1876 |
// phpcs:enable |
| 1877 |
return $updated; |
| 1878 |
} |
| 1879 |
|
| 1880 |
/** |
| 1881 |
* Method render_edit_site() |
| 1882 |
* |
| 1883 |
* Render edit site. |
| 1884 |
* |
| 1885 |
* @param mixed $websiteid Child Site ID. |
| 1886 |
* @param mixed $updated Updated. |
| 1887 |
* |
| 1888 |
* @uses \MainWP\Dashboard\MainWP_Manage_Sites_View::render_edit_site() |
| 1889 |
* @uses \MainWP\Dashboard\MainWP_System_Utility::set_current_wpid() |
| 1890 |
*/ |
| 1891 |
public static function render_edit_site( $websiteid, $updated ) { |
| 1892 |
if ( $websiteid ) { |
| 1893 |
MainWP_System_Utility::set_current_wpid( $websiteid ); |
| 1894 |
} |
| 1895 |
static::render_header( 'ManageSitesEdit' ); |
| 1896 |
MainWP_Manage_Sites_View::render_edit_site( $websiteid, $updated ); |
| 1897 |
static::render_footer( 'ManageSitesEdit' ); |
| 1898 |
} |
| 1899 |
|
| 1900 |
/** |
| 1901 |
* Method on_edit_site() |
| 1902 |
* |
| 1903 |
* Render on edit. |
| 1904 |
* |
| 1905 |
* @param object $website The website object. |
| 1906 |
*/ |
| 1907 |
public static function on_edit_site( $website ) { |
| 1908 |
if ( isset( $_POST['submit'] ) && isset( $_REQUEST['id'] ) && isset( $_POST['wp_nonce'] ) && isset( $_POST['mainwp_managesites_edit_siteadmin'] ) && ( '' !== $_POST['mainwp_managesites_edit_siteadmin'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'UpdateWebsite' . sanitize_key( $_REQUEST['id'] ) ) && isset( $_POST['mainwp_managesites_edit_uniqueId'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1909 |
?> |
| 1910 |
<script type="text/javascript"> |
| 1911 |
jQuery( document ).ready( function () { |
| 1912 |
mainwp_managesites_update_childsite_value( <?php echo esc_attr( $website->id ); ?>, '<?php echo esc_js( $website->uniqueId ); ?>' ); |
| 1913 |
} ); |
| 1914 |
</script> |
| 1915 |
<?php |
| 1916 |
} |
| 1917 |
} |
| 1918 |
|
| 1919 |
/** |
| 1920 |
* Method mainwp_help_content() |
| 1921 |
* |
| 1922 |
* Creates the MainWP Help Documentation List for the help component in the sidebar. |
| 1923 |
*/ |
| 1924 |
public static function mainwp_help_content() { |
| 1925 |
// @NO_SONAR_START@ start block. |
| 1926 |
if ( isset( $_GET['page'] ) && 'managesites' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1927 |
if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1928 |
?> |
| 1929 |
<p><?php esc_html_e( 'If you need help connecting your websites, please review following help documents', 'mainwp' ); ?></p> |
| 1930 |
<div class="ui list"> |
| 1931 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/get-started-with-mainwp/#install-mainwp-dashboard" target="_blank">Set up the MainWP Plugin</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1932 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/get-started-with-mainwp/#install-mainwp-child" target="_blank">Install MainWP Child</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1933 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#add-a-site-to-your-dashboard" target="_blank">Add a Site to your Dashboard</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1934 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#import-sites" target="_blank">Import Sites</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1935 |
</div> |
| 1936 |
<?php |
| 1937 |
} elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) { // phpcs:ignore WordPress.Security.NonceVerification,ized |
| 1938 |
?> |
| 1939 |
<p><?php esc_html_e( 'If you need help connecting your websites, please review following help documents', 'mainwp' ); ?></p> |
| 1940 |
<div class="ui list"> |
| 1941 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/get-started-with-mainwp/#install-mainwp-dashboard" target="_blank">Set up the MainWP Plugin</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1942 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/get-started-with-mainwp/#install-mainwp-child" target="_blank">Install MainWP Child</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1943 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#add-a-site-to-your-dashboard" target="_blank">Add a Site to your Dashboard</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1944 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#import-sites" target="_blank">Import Sites</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1945 |
</div> |
| 1946 |
<?php |
| 1947 |
} else { |
| 1948 |
?> |
| 1949 |
<p><?php esc_html_e( 'If you need help with managing child sites, please review following help documents', 'mainwp' ); ?></p> |
| 1950 |
<div class="ui list"> |
| 1951 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/" target="_blank">Manage Child Sites</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1952 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#access-child-site-wp-admin" target="_blank">Access Child Site WP Admin</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1953 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#synchronize-a-child-site" target="_blank">Synchronize a Child Site</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1954 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#edit-a-child-site" target="_blank">Edit a Child Site</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1955 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#reconnect-a-child-site" target="_blank">Reconnect a Child Site</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1956 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#delete-a-child-site" target="_blank">Delete a Child Site</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1957 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#security-issues" target="_blank">Security Issues</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1958 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#manage-child-site-tags" target="_blank">Manage Child Site Tags</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1959 |
<div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/manage-child-sites/#manage-child-site-notes" target="_blank">Manage Child Site Notes</a></div> <?php // NOSONAR - noopener - open safe. ?> |
| 1960 |
</div> |
| 1961 |
<?php |
| 1962 |
} |
| 1963 |
} |
| 1964 |
// @NO_SONAR_END@ end of block. |
| 1965 |
} |
| 1966 |
} |
| 1967 |
|