base && self::$api_instance->check_credentials_health() ) { wp_enqueue_script( 'adminlabs-widget', plugins_url( 'assets/admin/widget.js', dirname( __FILE__ ) ), ADMINLABS_PLUGIN_VERSION, true ); wp_localize_script( 'adminlabs-widget', 'adminlabs', array( 'root' => esc_url_raw( rest_url() ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'messages' => array( 'comment_add_confirm' => esc_attr__( 'Really remove comment?', 'adminlabs' ), 'comment_add_failure' => esc_attr__( 'Adding comment failed. Try again and if problem presist, please send us a bug report.', 'adminlabs' ), 'comment_delete_failure' => esc_attr__( 'Removing comment failed. Try again and if problem presist, please send us a bug report.', 'adminlabs' ) ) ) ); } if ( 'settings_page_adminlabs' === $screen->base ) { wp_enqueue_script( 'adminlabs-settings', plugins_url( 'assets/admin/settings.js', dirname( __FILE__ ) ), ADMINLABS_PLUGIN_VERSION, true ); wp_localize_script( 'adminlabs-settings', 'adminlabs', array( 'root' => esc_url_raw( rest_url() ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'messages' => array( 'maintenance_add_confirm' => esc_attr__( 'Really remove scheduled maintenance?', 'adminlabs' ), 'maintenance_add_failure' => esc_attr__( 'Scheduling maintenance failed. Try again and if problem presist, please send us a bug report.', 'adminlabs' ), 'maintenance_delete_failure' => esc_attr__( 'Removing maintenance failed. Try again and if problem presist, please send us a bug report.', 'adminlabs' ), ) ) ); } } // end enqueue_admin /** * Check if things looks like we need to reset all adminlabs settings * * @since 1.0.0 */ public function maybe_do_reset() { if ( isset( $_GET['adminlabs_reset_credentials'] ) && current_user_can( 'manage_options' ) ) { AdminLabs_Tools::reset(); wp_redirect( admin_url( 'options-general.php?page=adminlabs&message=adminlabs_reset' ) ); exit; } } // end maybe_do_reset /** * Check if we need to show some admin notices * * @since 1.0.0 */ public function maybe_show_admin_notices() { $api_account_id = get_option( 'adminlabs_api_account_id' ); $api_key = get_option( 'adminlabs_api_key' ); // Maybe show general message. if ( isset( $_GET['message'] ) ) { if ( 'adminlabs_reset' === $_GET['message'] ) { add_action( 'admin_notices', array( $this, 'notice_reset_success' ) ); } } // Maybe show onboarding process. if ( current_user_can( 'manage_options' ) && ! AdminLabs_Tools::check_api_settings_existance() ) { add_action( 'admin_notices', array( $this, 'notice_onboarding' ) ); return; } // Maybe show API connectivity issue warning. if ( current_user_can( 'manage_options' ) && ! self::$api_instance->check_credentials_health() ) { add_action( 'admin_notices', array( $this, 'notice_no_api_connection' ) ); } } // end maybe_show_admin_notices /** * Show onboarding process when there's no API settings saved * * @since 1.0.0 */ public function notice_onboarding() { $screen = get_current_screen(); if ( 'settings_page_adminlabs' !== $screen->id ) : ?>
AdminLabs

  1. AdminLabs dashboard', 'adminlabs' ) ?>.

API credentials. If this problem persist, please contact our support.', 'adminlabs' ), 'options-general.php?page=adminlabs' ); ?>