W3cubDocs

/WordPress

wp_ajax_meta_box_order()

Ajax handler for saving the meta box order.

Description

Source

File: wp-admin/includes/ajax-actions.php

function wp_ajax_meta_box_order() {
	check_ajax_referer( 'meta-box-order' );
	$order        = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
	$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';

	if ( $page_columns != 'auto' ) {
		$page_columns = (int) $page_columns;
	}

	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';

	if ( $page != sanitize_key( $page ) ) {
		wp_die( 0 );
	}

	if ( ! $user = wp_get_current_user() ) {
		wp_die( -1 );
	}

	if ( $order ) {
		update_user_option( $user->ID, "meta-box-order_$page", $order, true );
	}

	if ( $page_columns ) {
		update_user_option( $user->ID, "screen_layout_$page", $page_columns, true );
	}

	wp_die( 1 );
}

Changelog

Version Description
3.1.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_ajax_meta_box_order