wp_ajax_widgets_order

Ajax handler for saving the widgets order.

Description

wp_ajax_widgets_order(); 

Usage

  1. if ( !function_exists( 'wp_ajax_widgets_order' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_widgets_order(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_widgets_order() { 
  2. check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' ); 
  3.  
  4. if ( !current_user_can('edit_theme_options') ) 
  5. wp_die( -1 ); 
  6.  
  7. unset( $_POST['savewidgets'], $_POST['action'] ); 
  8.  
  9. // Save widgets order for all sidebars. 
  10. if ( is_array($_POST['sidebars']) ) { 
  11. $sidebars = array(); 
  12. foreach ( $_POST['sidebars'] as $key => $val ) { 
  13. $sb = array(); 
  14. if ( !empty($val) ) { 
  15. $val = explode(', ', $val); 
  16. foreach ( $val as $k => $v ) { 
  17. if ( strpos($v, 'widget-') === false ) 
  18. continue; 
  19.  
  20. $sb[$k] = substr($v, strpos($v, '_') + 1); 
  21. $sidebars[$key] = $sb; 
  22. wp_die( 1 ); 
  23.  
  24. wp_die( -1 );