Browse: Home / Snippets /

ProPanel: Remove widgets from admin dashboard screen

Contents


Snippet #

add_action( 'wp_dashboard_setup', function() {
	global $wp_meta_boxes;

	if ( ( isset( $wp_meta_boxes['dashboard'] ) ) && ( ! empty( $wp_meta_boxes['dashboard'] ) ) ) {
		foreach ( $wp_meta_boxes['dashboard'] as $priority_key => $priority_set ) {
			if ( ! empty( $priority_set ) ) {
				foreach ( $priority_set as $location_key => $location_set ) {
					if ( ! empty( $location_set ) ) {
						foreach ( $location_set as $widget_key => $widget ) {
							if ( substr( $widget_key, 0, strlen( 'learndash-propanel-' ) ) === 'learndash-propanel-' ) {
								unset( $wp_meta_boxes['dashboard'][ $priority_key ][ $location_key ][ $widget_key ] );
							}
						}
					}
				}
			}
		}
	}
}, 100 );