Created
June 27, 2022 07:11
-
-
Save swoboda/0012700c7f0d00ab8190f002dd14485b to your computer and use it in GitHub Desktop.
Make sure our widget is always on top
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'admin_init', 'set_dashboard_meta_order' ); | |
/** | |
* Make sure our widget is always on top | |
* | |
*/ | |
function set_dashboard_meta_order() { | |
$user_id = get_current_user_id(); | |
$user_metabox_order = get_user_meta( $user_id, 'meta-box-order_dashboard' ); | |
$meta_value = array(); | |
$wpstore_meta_box = 'wpstore-dashboard-widget'; | |
foreach ( $user_metabox_order as $key => $value ) { | |
foreach ( $value as $type => $order ) { | |
if ( $type === 'normal' ) { | |
$order = str_replace( $wpstore_meta_box . ',', '', $order ); | |
$order = $wpstore_meta_box . ',' . $order; | |
} | |
$meta_value[ $type ] = $order; | |
} | |
} | |
update_user_meta( $user_id, 'meta-box-order_dashboard', $meta_value ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment