static::get_mshots_image_url( $url, $width ),
'requeue_src' => static::get_mshots_image_url( $url, $width, true ),
);
}
/**
* Method select_sites_box()
*
* Select sites box.
*
* @deprecated 4.3 Use MainWP_UI_Select_Sites::select_sites_box().
*
* @param string $type Input type, radio.
* @param bool $show_group Whether or not to show group, Default: true.
* @param bool $show_select_all Whether to show select all.
* @param string $class_style Default = ''.
* @param string $style Default = ''.
* @param array $selected_websites Selected Child Sites.
* @param array $selected_groups Selected Groups.
* @param bool $enableOfflineSites (bool) True, if offline sites is enabled. False if not.
* @param integer $postId Post Meta ID.
*
* @uses \MainWP\Dashboard\MainWP_System_Utility::maybe_unserialyze()
*/
public static function select_sites_box( $type = 'checkbox', $show_group = true, $show_select_all = true, $class_style = '', $style = '', &$selected_websites = array(), &$selected_groups = array(), $enableOfflineSites = false, $postId = 0 ) { // phpcs:ignore -- NOSONAR - compatible.
if ( $postId ) {
$sites_val = get_post_meta( $postId, '_selected_sites', true );
$selected_websites = MainWP_System_Utility::maybe_unserialyze( $sites_val );
if ( empty( $selected_websites ) ) {
$selected_websites = array();
}
$groups_val = get_post_meta( $postId, '_selected_groups', true );
$selected_groups = MainWP_System_Utility::maybe_unserialyze( $groups_val );
if ( empty( $selected_groups ) ) {
$selected_groups = array();
}
}
if ( empty( $selected_websites ) && isset( $_GET['selected_sites'] ) && ! empty( $_GET['selected_sites'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
$selected_sites = explode( '-', sanitize_text_field( wp_unslash( $_GET['selected_sites'] ) ) );// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
$selected_sites = array_map( 'intval', $selected_sites );
$selected_websites = array_filter( $selected_sites );
}
/**
* Action: mainwp_before_seclect_sites
*
* Fires before the Select Sites box.
*
* @since 4.1
*/
do_action( 'mainwp_before_seclect_sites' );
?>
query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'favi_icon' ), 'yes' ) );
static $rendered_count = 0;
$rand_id_prefix2 = '';
if ( ! empty( $rendered_count ) ) {
$rand_id_prefix2 = '-' . MainWP_Utility::gen_rand_id();
}
++$rendered_count;
?>
query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp.name' ) );
$count_sites = MainWP_DB::instance()->get_websites_count();
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( empty( $count_sites ) && ! isset( $_GET['do'] ) ) {
static::render_modal_no_sites_note();
}
$siteViewMode = MainWP_Utility::get_siteview_mode();
$page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
$tour_id = '';
if ( 'mainwp_tab' === $page ) {
$tour_id = '30496';
} elseif ( 'managesites' === $page ) {
if ( isset( $_GET['do'] ) && 'new' === $_GET['do'] ) {
$tour_id = '13210';
} elseif ( isset( $_GET['do'] ) && 'bulknew' === $_GET['do'] ) {
$tour_id = '60206';
} elseif ( ! isset( $_GET['dashboard'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['updateid'] ) && ! isset( $_GET['emailsettingsid'] ) && ! isset( $_GET['scanid'] ) ) {
if ( 'grid' === $siteViewMode ) {
$tour_id = '27217';
} else {
$tour_id = '29331';
}
}
} elseif ( 'MonitoringSites' === $page ) {
$tour_id = '29003';
} elseif ( 'ManageClients' === $page ) {
if ( isset( $_GET['client_id'] ) ) {
$tour_id = '28258';
} else {
$tour_id = '28240';
}
} elseif ( 'ClientAddNew' === $page ) {
if ( isset( $_GET['client_id'] ) ) {
$tour_id = '28962';
} else {
$tour_id = '28256';
}
} elseif ( 'ClientAddField' === $page ) {
$tour_id = '28257';
} elseif ( 'PluginsManage' === $page ) {
$tour_id = '28510';
} elseif ( 'ManageGroups' === $page ) {
$tour_id = '27275';
} elseif ( 'UpdatesManage' === $page ) {
$tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
if ( 'plugins-updates' === $tab ) {
$tour_id = '28259';
} elseif ( 'themes-updates' === $tab ) {
$tour_id = '28447';
} elseif ( 'wordpress-updates' === $tab ) {
$tour_id = '29005';
} elseif ( 'translations-updates' === $tab ) {
$tour_id = '29007';
} elseif ( 'abandoned-plugins' === $tab ) {
$tour_id = '29008';
} elseif ( 'abandoned-themes' === $tab ) {
$tour_id = '29009';
} elseif ( 'plugin-db-updates' === $tab ) {
$tour_id = '33161';
} else {
$tour_id = '28259';
}
} elseif ( 'PluginsInstall' === $page ) {
$tour_id = '29011';
} elseif ( 'PluginsAutoUpdate' === $page ) {
$tour_id = '29015';
} elseif ( 'PluginsIgnore' === $page ) {
$tour_id = '29018';
} elseif ( 'PluginsIgnoredAbandoned' === $page ) {
$tour_id = '29329';
} elseif ( 'ThemesManage' === $page ) {
$tour_id = '28511';
} elseif ( 'ThemesInstall' === $page ) {
$tour_id = '29010';
} elseif ( 'ThemesAutoUpdate' === $page ) {
$tour_id = '29016';
} elseif ( 'ThemesIgnore' === $page ) {
$tour_id = '29019';
} elseif ( 'ThemesIgnoredAbandoned' === $page ) {
$tour_id = '29330';
} elseif ( 'UserBulkManage' === $page ) {
$tour_id = '28574';
} elseif ( 'UserBulkAdd' === $page ) {
$tour_id = '28575';
} elseif ( 'PasswordPolicy' === $page ) {
$tour_id = '80725';
} elseif ( 'BulkImportUsers' === $page ) {
$tour_id = '28736';
} elseif ( 'UpdateAdminPasswords' === $page ) {
$tour_id = '28737';
} elseif ( 'PostBulkManage' === $page ) {
$tour_id = '28796';
} elseif ( 'PostBulkAdd' === $page ) {
$tour_id = '28799';
} elseif ( 'PageBulkManage' === $page ) {
$tour_id = '29045';
} elseif ( 'PageBulkAdd' === $page ) {
$tour_id = '29048';
} elseif ( 'Extensions' === $page ) {
$tour_id = '28800';
} elseif ( 'Settings' === $page ) {
$tour_id = '28883';
} elseif ( 'SettingsAdvanced' === $page ) {
$tour_id = '28886';
} elseif ( 'SettingsEmail' === $page ) {
$tour_id = '29054';
} elseif ( 'MonitoringSettings' === $page ) {
$tour_id = '80726';
} elseif ( 'MainWPTools' === $page ) {
$tour_id = '29272';
} elseif ( 'RESTAPI' === $page ) {
$tour_id = '29273';
} elseif ( 'ApplicationPasswords' === $page ) {
$tour_id = '80727';
} elseif ( 'ServerInformation' === $page ) {
$tour_id = '28873';
} elseif ( 'ServerInformationCron' === $page ) {
$tour_id = '28874';
} elseif ( 'ErrorLog' === $page ) {
$tour_id = '28876';
} elseif ( 'ActionLogs' === $page ) {
$tour_id = '28877';
} elseif ( 'Extensions-Mainwp-Jetpack-Protect-Extension' === $page ) {
$tour_id = '31700';
} elseif ( 'Extensions-Mainwp-Jetpack-Scan-Extension' === $page ) {
$tour_id = '31694';
} elseif ( 'Extensions-Termageddon-For-Mainwp' === $page ) {
$tour_id = '32104';
} elseif ( 'Extensions-Advanced-Uptime-Monitor-Extension' === $page ) {
$tour_id = '32149';
} elseif ( 'Extensions-Mainwp-Custom-Dashboard-Extension' === $page ) {
$tour_id = '32150';
} elseif ( 'Extensions-Mainwp-Updraftplus-Extension' === $page ) {
$tour_id = '32151';
} elseif ( 'Extensions-Mainwp-Sucuri-Extension' === $page ) {
$tour_id = '32152';
} elseif ( 'Extensions-Mainwp-Clean-And-Lock-Extension' === $page ) {
$tour_id = '32153';
} elseif ( 'Extensions-Mainwp-Woocommerce-Shortcuts-Extension' === $page ) {
$tour_id = '32851';
} elseif ( 'Extensions-Mainwp-Buddy-Extension' === $page ) {
$tour_id = '33064';
} elseif ( 'Extensions-Mainwp-Backwpup-Extension' === $page ) {
$tour_id = '32923';
} elseif ( 'Extensions-Mainwp-Ssl-Monitor-Extension' === $page ) {
$tour_id = '33164';
} elseif ( 'Extensions-Mainwp-Cache-Control-Extension' === $page ) {
$tour_id = '33167';
} elseif ( 'Extensions-Mainwp-Maintenance-Extension' === $page ) {
$tour_id = '33301';
} elseif ( 'Extensions-Mainwp-Domain-Monitor-Extension' === $page ) {
$tour_id = '66031';
} elseif ( 'Extensions-Mainwp-Favorites-Extension' === $page ) {
$tour_id = '66035';
} elseif ( 'Extensions-Mainwp-Regression-Testing-Extension' === $page ) {
$tour_id = '66037';
}
// phpcs:enable
?>
get_sql_websites_for_current_user( false, null, 'wp.url', false, false, null, false, array( 'premium_upgrades', 'plugins_outdate_dismissed', 'themes_outdate_dismissed', 'plugins_outdate_info', 'themes_outdate_info', 'favi_icon' ) );
$websites = MainWP_DB::instance()->query( $sql );
$g = isset( $_GET['g'] ) ? intval( $_GET['g'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
$s = isset( $_GET['dashboard'] ) ? intval( $_GET['dashboard'] ) : -1; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
?>
value="-1" class="item">
get_groups_for_manage_sites();
foreach ( $groups as $group ) {
?>
id ) ? 'selected' : ''; ?> value="id ); ?>">name ) ); ?>
value="-1" class="item" >
id ) ? 'selected' : ''; ?> class="item" >name ) ); ?>
get_websites_count();
$sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' );
$sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter.
$sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages );
$current_user = get_current_user_id();
$custom_theme = MainWP_Settings::get_instance()->get_current_user_theme();
$screen = get_current_screen();
$show_command_palette_trigger = wp_script_is( 'wp-core-commands', 'enqueued' );
$command_palette_shortcut = '';
$command_palette_label = '';
if ( $show_command_palette_trigger ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Used only to mirror WordPress core shortcut labels.
$is_apple_os = (bool) preg_match( '/Macintosh|Mac OS X|Mac_PowerPC/i', $_SERVER['HTTP_USER_AGENT'] ?? '' );
$command_palette_shortcut = $is_apple_os
? _x( '⌘K', 'keyboard shortcut to open the command palette', 'mainwp' )
: _x( 'Ctrl+K', 'keyboard shortcut to open the command palette', 'mainwp' );
/* translators: %s: Keyboard shortcut label. */
$command_palette_label = sprintf( esc_attr__( 'Open command palette (%s)', 'mainwp' ), $command_palette_shortcut );
}
if ( false === $custom_theme ) {
$compat_theme = null;
// to compatible with Custom Dashboard extension settings.
$compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
$compat_theme = $compat_settings['theme'];
}
if ( null !== $compat_theme ) {
$custom_theme = $compat_theme;
}
}
$themes_files = MainWP_Settings::get_instance()->get_custom_themes_files();
if ( empty( $themes_files ) ) {
$themes_files = array();
}
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : '';
$id = 0;
$website = null;
if ( isset( $_GET['dashboard'] ) || ( isset( $_GET['id'] ) && 'CostTrackerAdd' !== $page ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) {
if ( isset( $_GET['dashboard'] ) ) {
$id = intval( $_GET['dashboard'] );
} elseif ( isset( $_GET['id'] ) ) {
$id = intval( $_GET['id'] );
} elseif ( isset( $_GET['updateid'] ) ) {
$id = intval( $_GET['updateid'] );
} elseif ( isset( $_GET['emailsettingsid'] ) ) {
$id = intval( $_GET['emailsettingsid'] );
} elseif ( isset( $_GET['scanid'] ) ) {
$id = intval( $_GET['scanid'] );
} elseif ( isset( $_GET['monitor_wpid'] ) ) {
$id = intval( $_GET['monitor_wpid'] );
}
if ( $id ) {
$website = MainWP_DB::instance()->get_website_by_id( $id );
}
}
ob_start();
if ( $show_command_palette_trigger ) :
?>
sync_errors ) : ?>
name );
if ( ! empty( $site_sync_info['timestamp'] ) && ( $current_time - $site_sync_info['timestamp'] ) > $twenty_four_h ) {
$site_sync_outdated = true;
/* translators: 1: Site name. */
$site_sync_tooltip = sprintf( esc_attr__( 'Data not synced for more than 24h. Click here to sync %1$s.', 'mainwp' ), $site_name );
} elseif ( ! empty( $site_sync_info['formatted'] ) ) {
/* translators: 1: Last sync date/time, 2: Site name. */
$site_sync_tooltip = sprintf( esc_attr__( 'Last sync: %1$s. Click here to sync %2$s.', 'mainwp' ), $site_sync_info['formatted'], $site_name );
} else {
/* translators: 1: Site name. */
$site_sync_tooltip = sprintf( esc_attr__( 'Get fresh data from %1$s.', 'mainwp' ), $site_name );
}
?>
$twenty_four_h ) {
$sync_outdated = true;
$sync_tooltip = esc_attr__( 'Data not synced for more than 24h. Click here to sync all sites.', 'mainwp' );
} elseif ( ! empty( $sync_info['formatted'] ) ) {
/* translators: 1: Last sync date/time. */
$sync_tooltip = sprintf( esc_attr__( 'Last sync: %1$s. Click here to sync all sites.', 'mainwp' ), $sync_info['formatted'] );
} else {
$sync_tooltip = esc_attr__( 'Click here to sync all sites.', 'mainwp' );
}
?>
id ); ?>
'style="width:38px!important;height:38px!important;"',
'class' => 'ui small avatar image',
)
);
} else {
?>
get_website_by_id( $id );
// To avoid error in case of direct access to page with wrong id.
if ( ! empty( $website ) && ! empty( $website->url ) ) {
$overview_mshot = static::get_mshots_image_sources( $website->url, 170 );
?>
';
}
}
/**
* Method render_header()
*
* Render page title.
*
* @param string $title Page title.
*
* @return void Render page title and hidden divider html.
*/
public static function render_header( $title = '' ) {
static::render_top_header( array( 'title' => $title ) );
echo '
';
echo '
';
}
/**
* Method render_footer()
*
* Render page footer.
*
* @return void Render closing tags for page container.
*/
public static function render_footer() {
$is_site = MainWP_System::is_mainwp_site_page();
if ( $is_site ) {
echo '
';
}
echo '
';
echo '';
}
/**
* Method add_widget_box()
*
* Customize WordPress add_meta_box() function.
*
* @param mixed $id Widget ID parameter.
* @param mixed $callback Callback function.
* @param null $screen Current page.
* @param array $layout widget layout.
*
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
*/
public static function add_widget_box( $id, $callback, $screen = null, $layout = array() ) {
/**
* MainWP widget boxes array.
*
* @global object
*/
global $mainwp_widget_boxes;
$page = MainWP_System_Utility::get_page_id( $screen );
if ( empty( $page ) ) {
return;
}
if ( ! isset( $mainwp_widget_boxes ) ) {
$mainwp_widget_boxes = array();
}
if ( ! isset( $mainwp_widget_boxes[ $page ] ) ) {
$mainwp_widget_boxes[ $page ] = array();
}
$mainwp_widget_boxes[ $page ][ $id ] = array(
'id' => $id,
'callback' => $callback,
'layout' => $layout,
);
}
/**
* Method do_widget_boxes()
*
* Customize WordPress do_meta_boxes() function.
*
* @param mixed $screen_id Current page ID.
* @param array ...$args Widget callback args.
*
* @return void Renders widget container box.
*
* @uses \MainWP\Dashboard\MainWP_System_Utility::get_page_id()
*/
public static function do_widget_boxes( $screen_id, ...$args ) { // phpcs:ignore -- NOSONAR - complex.
global $mainwp_widget_boxes;
$page = MainWP_System_Utility::get_page_id( $screen_id );
if ( empty( $page ) ) {
return;
}
$page_widget = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
$wgsorted = false;
$selected_widget_layout = '';
if ( ! empty( $_GET['page'] ) && ! empty( $_GET['select_layout'] ) && ! empty( $_GET['_opennonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_opennonce'] ), 'mainwp-admin-nonce' ) && ! empty( $_GET['updated'] ) && ! empty( $_GET['screen_slug'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
$layid = sanitize_text_field( wp_unslash( $_GET['updated'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
$screen_slug = sanitize_text_field( wp_unslash( $_GET['screen_slug'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
$saved_layouts = MainWP_Ui_Manage_Widgets_Layout::set_get_widgets_layout( false, array(), $screen_slug );
$selected_layout = is_array( $saved_layouts ) && isset( $saved_layouts[ $layid ] ) ? $saved_layouts[ $layid ] : array();
if ( is_array( $selected_layout ) && isset( $selected_layout['layout'] ) ) {
$wgsorted = $selected_layout['layout'];
if ( isset( $selected_layout['name'] ) ) {
$selected_widget_layout = $selected_layout['name'];
}
}
}
if ( empty( $wgsorted ) ) {
$wgsorted = get_user_option( 'mainwp_widgets_sorted_' . $page );
}
if ( ! empty( $wgsorted ) && is_string( $wgsorted ) ) {
$wgsorted = json_decode( $wgsorted, true );
}
if ( ! is_array( $wgsorted ) ) {
$wgsorted = array();
}
$client_id = 0;
if ( 'mainwp_page_manageclients' === $page ) {
$sorted_array = is_array( $wgsorted ) ? $wgsorted : array();
$wgsorted = array();
$client_id = isset( $_GET['client_id'] ) ? intval( $_GET['client_id'] ) : 0; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Recommended
if ( ! empty( $client_id ) && is_array( $sorted_array ) && isset( $sorted_array[ $client_id ] ) ) {
$wgsorted = $sorted_array[ $client_id ];
}
}
$wgsorted = apply_filters( 'mainwp_do_widget_boxes_sorted', $wgsorted, $page, $client_id );
if ( 'mainwp_page_manageclients' === $page ) {
$show_widgets = get_user_option( 'mainwp_clients_show_widgets' );
} elseif ( 'toplevel_page_mainwp_tab' === $page || 'mainwp_page_managesites' === $page ) {
$show_widgets = get_user_option( 'mainwp_settings_show_widgets' );
} else {
$show_widgets = apply_filters( 'mainwp_widget_boxes_show_widgets', array(), $page );
}
if ( ! is_array( $show_widgets ) ) {
$show_widgets = array();
}
if ( $selected_widget_layout ) {
// to support saving selected layout.
?>
$val['x'],
'y' => $val['y'],
'w' => $val['w'],
'h' => $val['h'],
);
}
}
// init widget layout settings.
if ( ! isset( $layout['x'] ) && ! isset( $layout['w'] ) && isset( $box['layout']['2'] ) ) {
$layout = array(
'x' => $box['layout']['0'],
'y' => $box['layout']['1'],
'w' => $box['layout']['2'],
'h' => $box['layout']['3'],
);
}
$layout_attrs_escaped = '';
if ( isset( $layout['x'] ) && (int) $layout['x'] >= 0 ) {
$layout_attrs_escaped .= ' gs-x="' . esc_attr( $layout['x'] ) . '"';
}
if ( isset( $layout['y'] ) && (int) $layout['y'] >= 0 ) {
$layout_attrs_escaped .= ' gs-y="' . esc_attr( $layout['y'] ) . '"';
}
if ( isset( $layout['w'] ) && (int) $layout['w'] > 0 ) {
$layout_attrs_escaped .= ' gs-w="' . esc_attr( $layout['w'] ) . '"';
}
if ( isset( $layout['h'] ) && (int) $layout['h'] > 0 ) {
$layout_attrs_escaped .= ' gs-h="' . esc_attr( $layout['h'] ) . '"';
}
echo '
\n";
}
}
?>