url = menu_page_url( 'onecom-wp-health-monitor', false ); $this->staging_url = (empty(menu_page_url( 'onecom-wp-staging', false ))) ? menu_page_url( 'onecom-wp-staging-blocked', false ) : menu_page_url( 'onecom-wp-staging', false ); $this->theme_url = menu_page_url( 'onecom-wp-themes', false ); $this->cookie_banner_url = menu_page_url( 'onecom-wp-cookie-banner', false ); //plugin page one.com Plugins menu $this->plugin_url = ( is_multisite() && is_network_admin() ) ? network_admin_url( 'admin.php?page='.MARKETPLACE_PAGE_SLUG ) : admin_url( 'admin.php?page='.MARKETPLACE_PAGE_SLUG ); $this->health_tooltip = addslashes( __( 'Health Monitor scans your website for potential security issues and checks the overall state of your site.', 'onecom-wp' ) ); $this->theme_tooltip = addslashes( __( 'Exclusive themes specially crafted for one.com customers.', 'onecom-wp' ) ); $this->plugin_tooltip = addslashes( __( 'Plugins that bring the one.com experience and services to WordPress.', 'onecom-wp' ) ); $this->cookie_banner_tooltip = addslashes( __( 'Show a banner on your website to inform visitors about cookies and get their consent.', 'onecom-wp' ) ); add_action( 'wp_dashboard_setup', array( $this, 'osch_widget_cb' ) ); //removed themes shortcut link from the welcome panel// add_action( 'admin_head-themes.php', array( $this, 'oc_themes_button' ) ); add_action( 'admin_head-plugins.php', array( $this, 'oc_plugins_button' ) ); add_action( 'admin_head-plugin-install.php', array( $this, 'oc_plugins_button' ) ); add_action( 'admin_head-widgets.php', array( $this, 'oc_cookie_banner_button' ) ); add_action( 'admin_head-options-privacy.php', array( $this, 'oc_cookie_banner_box' ) ); add_action( 'admin_head-options-general.php', array( $this, 'oc_staging_button' ) ); add_action( 'admin_head-site-health.php', array( $this, 'oc_site_health_info' ) ); add_action( 'tool_box', array( $this, 'tools_page_staging_box' ) ); add_action( 'tool_box', array( $this, 'tools_page_health_monitor_box' ) ); add_action( 'admin_head', array( $this, 'oc_button_css' ) ); } /** * adds widget to the wp admin dashboard */ public function osch_widget_cb() { $user = wp_get_current_user(); if ( ( ! isset( $user->roles ) ) || ( ! in_array( 'administrator', (array) $user->roles ) ) ) { return; } wp_add_dashboard_widget( self::WID, '
', array( $this, 'ocsh_widget_cb' ) ); global $wp_meta_boxes; if ( isset( $wp_meta_boxes[ self::DASHBOARD ] ) ) { $normal_dashboard = $wp_meta_boxes[ self::DASHBOARD ]['normal']['core']; $example_widget_backup = array( self::WID => $normal_dashboard[ self::WID ] ); unset( $normal_dashboard[ self::WID ] ); $sorted_dashboard = array_merge( $example_widget_backup, $normal_dashboard ); $wp_meta_boxes[ self::DASHBOARD ]['normal']['core'] = $sorted_dashboard; } } /** * checks for health monitor scan in db and returns value based on the result */ public function ocsh_widget_cb() { $site_scan_transient = get_site_transient( 'ocsh_site_scan_result' ); $site_scan_result = oc_sh_calculate_score( $site_scan_transient ); $colors = array( 'poor' => '#D20019', 'ok' => '#FF755A', 'good' => '#76B82A', ); $color = $colors['good']; $score = ''; if ( isset( $site_scan_result[ self::SCORE ] ) ) { if ( $site_scan_result[ self::SCORE ] < 75 && $site_scan_result[ self::SCORE ] >= 50 ) { $color = $colors['ok']; } elseif ( $site_scan_result[ self::SCORE ] < 50 ) { $color = $colors['poor']; } $score = '' . round( $site_scan_result[ self::SCORE ] ) . '%'; } echo '