wp_ajax_widgets_order() – Ajax handler for saving the widgets order.

You appear to be a bot. Output may be restricted

Description

Ajax handler for saving the widgets order.

Usage

wp_ajax_widgets_order();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/includes/ajax-actions.php
Lines:

1 to 36 of 36
function wp_ajax_widgets_order() {
  check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );

  if ( ! current_user_can( 'edit_theme_options' ) ) {
    wp_die( -1 );
  }

  unset( $_POST['savewidgets'], $_POST['action'] );

  // Save widgets order for all sidebars.
  if ( is_array( $_POST['sidebars'] ) ) {
    $sidebars = array();

    foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) {
      $sb = array();

      if ( ! empty( $val ) ) {
        $val = explode( ',', $val );

        foreach ( $val as $k => $v ) {
          if ( strpos( $v, 'widget-' ) === false ) {
            continue;
          }

          $sb[ $k ] = substr( $v, strpos( $v, '_' ) + 1 );
        }
      }
      $sidebars[ $key ] = $sb;
    }

    wp_set_sidebars_widgets( $sidebars );
    wp_die( 1 );
  }

  wp_die( -1 );
}
 

 View on GitHub View on Trac