X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/a66f9e26487c560245ef9cd17d7e87c0cbb650af..refs/tags/wordpress-2.5.1:/wp-admin/widgets.php diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php index a33dc846..83264e43 100644 --- a/wp-admin/widgets.php +++ b/wp-admin/widgets.php @@ -1,360 +1,323 @@ - - - $sidebar ) { - $cols[] = '\'' . $index . '\''; - } - $cols = implode( ', ', $cols ); +$title = __( 'Widgets' ); +$parent_file = 'themes.php'; - $widgets = array(); - foreach ( $wp_registered_widgets as $name => $widget ) { - $widgets[] = '\'' . $widget['id'] . '\''; - } - $widgets = implode( ', ', $widgets ); +// $sidebar = What sidebar are we editing? +if ( isset($_GET['sidebar']) && isset($wp_registered_sidebars[$_GET['sidebar']]) ) { + $sidebar = attribute_escape( $_GET['sidebar'] ); +} elseif ( is_array($wp_registered_sidebars) && !empty($wp_registered_sidebars) ) { + // By default we look at the first defined sidebar + $sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) ); +} else { + // If no sidebars, die. + require_once( 'admin-header.php' ); ?> - + +
+

+
+ +
+

follow these instructions.' ); /* TODO: article on codex */; ?>

+
+ $control ) { + if ( in_array( $control['callback'], $already_done ) ) + continue; + + if ( is_callable( $control['callback'] ) ) { + call_user_func_array( $control['callback'], $control['params'] ); + $control_output = ob_get_contents(); + if ( false !== strpos( $control_output, '%i%' ) ) // if it's a multi-widget, only call control function once. + $already_done[] = $control['callback']; + } + + ob_clean(); + } + ob_end_clean(); - $sanitized_name = sanitize_title( $wp_registered_widgets[$name]['id'] ); - $link_title = __( 'Configure' ); - $popper = ( isset( $wp_registered_widget_controls[$name] ) ) - ? '
' - : ''; + // Prophylactic. Take out empty ids. + foreach ( (array) $_POST['widget-id'] as $key => $val ) + if ( !$val ) + unset($_POST['widget-id'][$key]); - $output = '
  • %2$s
  • '; + // Reset the key numbering and store + $new_sidebar = isset( $_POST['widget-id'] ) && is_array( $_POST['widget-id'] ) ? array_values( $_POST['widget-id'] ) : array(); + $sidebars_widgets[$_POST['sidebar']] = $new_sidebar; + wp_set_sidebars_widgets( $sidebars_widgets ); - printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper ); + wp_redirect( add_query_arg( 'message', 'updated' ) ); + exit; } -$title = __( 'Widgets' ); -$parent_file = 'themes.php'; -require_once 'admin-header.php'; -if ( count( $wp_registered_sidebars ) < 1 ) { -?> -
    -

    -

    follow these instructions.' ); /* TODO: article on codex */; ?>

    -
    - +
    +

    +
    +
    + + +
    +
    + $sidebar_widget_count", $wp_registered_sidebars[$sidebar]['name'] ); - case 'save_widget_order' : - $sidebars_widgets = array(); +$page = isset($_GET['apage']) ? abs( (int) $_GET['apage'] ) : 1; - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $postindex = $index . 'order'; +/* TODO: Paginate widgets list +$page_links = paginate_links( array( + 'base' => add_query_arg( 'apage', '%#%' ), + 'format' => '', + 'total' => ceil(($total = 105 )/ 10), + 'current' => $page +)); +*/ +$page_links = ' '; - parse_str( $_POST[$postindex], $order ); +// Unsanitized! +$widget_search = isset($_GET['s']) ? $_GET['s'] : false; - $new_order = $order[$index]; +// Not entirely sure what all should be here +$show_values = array( + '' => $widget_search ? __( 'Show any widgets' ) : __( 'Show all widgets' ), + 'unused' => __( 'Show unused widgets' ), + 'used' => __( 'Show used widgets' ) +); - if ( is_array( $new_order ) ) { - foreach ( $new_order as $sanitized_name ) { - foreach ( $wp_registered_widgets as $name => $widget ) { - if ( $sanitized_name == $widget['id'] ) { - $sidebars_widgets[$index][] = $name; - } - } - } - } - } +$show = isset($_GET['show']) && isset($show_values[$_GET['show']]) ? attribute_escape( $_GET['show'] ) : false; - wp_set_sidebars_widgets( $sidebars_widgets ); - break; - } -} -ksort( $wp_registered_widgets ); +$messages = array( + 'updated' => __('Changes saved.') +); -$inactive_widgets = array(); +require_once( 'admin-header.php' ); -foreach ( $wp_registered_widgets as $name => $widget ) { - $is_active = false; +if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) : ?> - foreach ( $wp_registered_sidebars as $index => $sidebar ) { - if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) { - $is_active = true; - break; - } - } +

    - if ( !$is_active ) { - $inactive_widgets[] = $name; - } -} + -$containers = array( 'palette' ); +
    -foreach ( $wp_registered_sidebars as $index => $sidebar ) { - $containers[] = $index; -} +
    -$c_string = ''; +

    + -foreach ( $containers as $container ) { - $c_string .= '"' . $container . '",'; -} +
    +
    +

    + +
    +
    -$c_string = substr( $c_string, 0, -1 ); +
    +

    + + -if ( isset( $_POST['action'] ) ) { -?> -
    -

    View site »' ), get_bloginfo( 'url' ) . '/' ); ?>

    - -
    -

    -

    + -
    -

    - -

    -
    - $sidebar ) { - ?> - - -
    -

    - -
    - -

    - -
    -
    +
    -
      - -
    -
    - +
    + + + +
    +
    -
    -

    + -
      - -
    -
    +
    - - -

    - - - -

    + -
    - $widget ) { ?> - - -
    - +
    + +
    +
    + + + +
    -
    +

    + + + + +

    -
    + + +
    + + + +
    - + -