]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/widgets.php
Wordpress 3.1-scripts
[autoinstalls/wordpress.git] / wp-admin / widgets.php
index e28f46ae9712529f3c90542b84e8bd3085dd8a90..4ae5478f1f007182e5bf5d2ac9bc6318cc8b8bc5 100644 (file)
@@ -7,12 +7,12 @@
  */
 
 /** WordPress Administration Bootstrap */
  */
 
 /** WordPress Administration Bootstrap */
-require_once( 'admin.php' );
+require_once( './admin.php' );
 
 /** WordPress Administration Widgets API */
 require_once(ABSPATH . 'wp-admin/includes/widgets.php');
 
 
 /** WordPress Administration Widgets API */
 require_once(ABSPATH . 'wp-admin/includes/widgets.php');
 
-if ( ! current_user_can('switch_themes') )
+if ( ! current_user_can('edit_theme_options') )
        wp_die( __( 'Cheatin’ uh?' ));
 
 wp_admin_css( 'widgets' );
        wp_die( __( 'Cheatin’ uh?' ));
 
 wp_admin_css( 'widgets' );
@@ -33,6 +33,19 @@ do_action( 'sidebar_admin_setup' );
 $title = __( 'Widgets' );
 $parent_file = 'themes.php';
 
 $title = __( 'Widgets' );
 $parent_file = 'themes.php';
 
+$help = '
+       <p>' . __('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.') . '</p>
+       <p>' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '</p>
+       <p>' . __('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.') . '</p>
+       <p>' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it&#8217;s not required.') . '</p>
+       <p>' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '</p>
+       <p>' . __('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.') . '</p>
+';
+$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Widgets_SubPanel" target="_blank">Documentation on Widgets</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+add_contextual_help($current_screen, $help);
+
 // register the inactive_widgets area as sidebar
 register_sidebar(array(
        'name' => __('Inactive Widgets'),
 // register the inactive_widgets area as sidebar
 register_sidebar(array(
        'name' => __('Inactive Widgets'),
@@ -120,7 +133,7 @@ retrieve_widgets();
 
 if ( count($wp_registered_sidebars) == 1 ) {
        // If only "wp_inactive_widgets" is defined the theme has no sidebars, die.
 
 if ( count($wp_registered_sidebars) == 1 ) {
        // If only "wp_inactive_widgets" is defined the theme has no sidebars, die.
-       require_once( 'admin-header.php' );
+       require_once( './admin-header.php' );
 ?>
 
        <div class="wrap">
 ?>
 
        <div class="wrap">
@@ -133,7 +146,7 @@ if ( count($wp_registered_sidebars) == 1 ) {
        </div>
 
 <?php
        </div>
 
 <?php
-       require_once( 'admin-footer.php' );
+       require_once( './admin-footer.php' );
        exit;
 }
 
        exit;
 }
 
@@ -162,7 +175,7 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
        if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
 
                if ( !in_array($widget_id, $sidebar, true) ) {
        if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
 
                if ( !in_array($widget_id, $sidebar, true) ) {
-                       wp_redirect('widgets.php?error=0');
+                       wp_redirect( admin_url('widgets.php?error=0') );
                        exit;
                }
 
                        exit;
                }
 
@@ -195,7 +208,7 @@ if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
        }
 
        wp_set_sidebars_widgets($sidebars_widgets);
        }
 
        wp_set_sidebars_widgets($sidebars_widgets);
-       wp_redirect('widgets.php?message=0');
+       wp_redirect( admin_url('widgets.php?message=0') );
        exit;
 }
 
        exit;
 }
 
@@ -244,7 +257,7 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
        $width = ' style="width:' . max($control['width'], 350) . 'px"';
        $key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
 
        $width = ' style="width:' . max($control['width'], 350) . 'px"';
        $key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
 
-       require_once( 'admin-header.php' ); ?>
+       require_once( './admin-header.php' ); ?>
        <div class="wrap">
        <?php screen_icon(); ?>
        <h2><?php echo esc_html( $title ); ?></h2>
        <div class="wrap">
        <?php screen_icon(); ?>
        <h2><?php echo esc_html( $title ); ?></h2>
@@ -279,7 +292,7 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
                        }
                        $selected = '';
                        echo "\t\t<select name='{$sbname}_position'>\n";
                        }
                        $selected = '';
                        echo "\t\t<select name='{$sbname}_position'>\n";
-                       echo "\t\t<option value=''>" . __('-- select --') . "</option>\n";
+                       echo "\t\t<option value=''>" . __('&mdash; Select &mdash;') . "</option>\n";
                        for ( $i = 1; $i <= $j; $i++ ) {
                                if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
                                        $selected = selected( $i, $key + 1, false );
                        for ( $i = 1; $i <= $j; $i++ ) {
                                if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
                                        $selected = selected( $i, $key + 1, false );
@@ -293,12 +306,14 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
        </div>
 
        <div class="widget-control-actions">
        </div>
 
        <div class="widget-control-actions">
-<?php  if ( isset($_GET['addnew']) ) { ?>
+<?php
+       if ( isset($_GET['addnew']) ) { ?>
        <a href="widgets.php" class="button alignleft"><?php _e('Cancel'); ?></a>
        <a href="widgets.php" class="button alignleft"><?php _e('Cancel'); ?></a>
-<?php  } else { ?>
-       <input type="submit" name="removewidget" class="button alignleft" value="<?php esc_attr_e('Delete'); ?>" />
-<?php  } ?>
-       <input type="submit" name="savewidget" class="button-primary alignright" value="<?php esc_attr_e('Save Widget'); ?>" />
+<?php
+       } else {
+               submit_button( __( 'Delete' ), 'button alignleft', 'removewidget', false );
+       }
+       submit_button( __( 'Save Widget' ), 'button-primary alignright', 'savewidget', false ); ?>
        <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($widget_id); ?>" />
        <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
        <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
        <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($widget_id); ?>" />
        <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
        <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
@@ -309,7 +324,7 @@ if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
        </div>
        </div>
 <?php
        </div>
        </div>
 <?php
-       require_once( 'admin-footer.php' );
+       require_once( './admin-footer.php' );
        exit;
 }
 
        exit;
 }
 
@@ -322,19 +337,21 @@ $errors = array(
        __('Error in displaying the widget settings form.')
 );
 
        __('Error in displaying the widget settings form.')
 );
 
-require_once( 'admin-header.php' ); ?>
+require_once( './admin-header.php' ); ?>
 
 <div class="wrap">
 <?php screen_icon(); ?>
 <h2><?php echo esc_html( $title ); ?></h2>
 
 <?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
 
 <div class="wrap">
 <?php screen_icon(); ?>
 <h2><?php echo esc_html( $title ); ?></h2>
 
 <?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
-<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<div id="message" class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
 <?php } ?>
 <?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
 <div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
 <?php } ?>
 
 <?php } ?>
 <?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
 <div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
 <?php } ?>
 
+<?php do_action( 'widgets_admin_page' ); ?>
+
 <div class="widget-liquid-left">
 <div id="widgets-left">
        <div id="available-widgets" class="widgets-holder-wrap">
 <div class="widget-liquid-left">
 <div id="widgets-left">
        <div id="available-widgets" class="widgets-holder-wrap">
@@ -355,7 +372,7 @@ require_once( 'admin-header.php' ); ?>
                <div class="sidebar-name">
                <div class="sidebar-name-arrow"><br /></div>
                <h3><?php _e('Inactive Widgets'); ?>
                <div class="sidebar-name">
                <div class="sidebar-name-arrow"><br /></div>
                <h3><?php _e('Inactive Widgets'); ?>
-               <span><img src="images/wpspin_light.gif" class="ajax-feedback" title="" alt="" /></span></h3></div>
+               <span><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /></span></h3></div>
                <div class="widget-holder inactive">
                <p class="description"><?php _e('Drag widgets here to remove them from the sidebar but keep their settings.'); ?></p>
                <?php wp_list_widget_controls('wp_inactive_widgets'); ?>
                <div class="widget-holder inactive">
                <p class="description"><?php _e('Drag widgets here to remove them from the sidebar but keep their settings.'); ?></p>
                <?php wp_list_widget_controls('wp_inactive_widgets'); ?>
@@ -377,7 +394,7 @@ foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
        <div class="sidebar-name">
        <div class="sidebar-name-arrow"><br /></div>
        <h3><?php echo esc_html( $registered_sidebar['name'] ); ?>
        <div class="sidebar-name">
        <div class="sidebar-name-arrow"><br /></div>
        <h3><?php echo esc_html( $registered_sidebar['name'] ); ?>
-       <span><img src="images/wpspin_dark.gif" class="ajax-feedback" title="" alt="" /></span></h3></div>
+       <span><img src="<?php echo esc_url( admin_url( 'images/wpspin_dark.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /></span></h3></div>
        <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
        </div>
 <?php
        <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
        </div>
 <?php
@@ -393,4 +410,4 @@ foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
 
 <?php
 do_action( 'sidebar_admin_page' );
 
 <?php
 do_action( 'sidebar_admin_page' );
-require_once( 'admin-footer.php' );
+require_once( './admin-footer.php' );