Make WordPress Core

Changeset 19418


Ignore:
Timestamp:
11/23/2011 06:30:45 PM (13 years ago)
Author:
nacin
Message:

Change show/hide storage mechanism for show_welcome_panel. 0 = hide, 1 = show, 2 = show if the multisite owner. Make welcome panel dismissable without JS (openable too via the URL). fixes #19338, fixes #19127.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r19389 r19418  
    10651065        die('-1');
    10661066
    1067     if ( empty( $_POST['visible'] ) )
    1068         delete_user_option( get_current_user_id(), 'show_welcome_panel' );
    1069     else
    1070         update_user_option( get_current_user_id(), 'show_welcome_panel', 1 );
     1067    update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
    10711068
    10721069    die('1');
  • trunk/wp-admin/includes/dashboard.php

    r19363 r19418  
    12771277    $classes = 'welcome-panel';
    12781278
    1279     if ( ! get_user_option( 'show_welcome_panel' ) )
     1279    $option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
     1280    // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
     1281    $hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
     1282    if ( $hide )
    12801283        $classes .= ' hidden';
    12811284
     
    12841287    <div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
    12851288    <?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
    1286     <a class="welcome-panel-close" href="#"><?php _e('Dismiss'); ?></a>
     1289    <a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?welcome=0' ) ); ?>"><?php _e('Dismiss'); ?></a>
    12871290    <div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div>
    12881291
     
    13501353    </div>
    13511354    </div>
    1352     <p class="welcome-panel-dismiss"><?php _e( 'Already know what you&#8217;re doing? <a href="#">Dismiss this message</a>.' ); ?></p>
     1355    <p class="welcome-panel-dismiss"><?php printf( __( 'Already know what you&#8217;re doing? <a href="%s">Dismiss this message</a>.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?></p>
    13531356    </div>
    13541357    </div>
  • trunk/wp-admin/includes/screen.php

    r19385 r19418  
    825825
    826826                    if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) {
     827                        if ( isset( $_GET['welcome'] ) ) {
     828                            $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
     829                            update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
     830                        } else {
     831                            $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
     832                            if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )
     833                                $welcome_checked = false;
     834                        }
    827835                        echo '<label for="wp_welcome_panel-hide">';
    828                         echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) get_user_option( 'show_welcome_panel' ), true, false )  . ' />';
     836                        echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false )  . ' />';
    829837                        echo __( 'Welcome' ) . "</label>\n";
    830838                    }
  • trunk/wp-admin/includes/upgrade.php

    r19410 r19418  
    283283    update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
    284284    update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array ( ), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'sidebar-2' => array ( ), 'sidebar-3' => array ( ), 'sidebar-4' => array ( ), 'sidebar-5' => array ( ), 'array_version' => 3 ) );
     285
     286    if ( ! is_multisite() )
     287        update_user_meta( $user_id, 'show_welcome_panel', 1 );
     288    elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
     289        update_user_meta( $user_id, 'show_welcome_panel', 2 );
    285290
    286291    if ( is_multisite() ) {
  • trunk/wp-admin/js/dashboard.dev.js

    r19345 r19418  
    1616        welcomePanel.removeClass('hidden');
    1717
    18     $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function() {
     18    $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {
     19        e.preventDefault();
    1920        welcomePanel.addClass('hidden');
    2021        updateWelcomePanel( 0 );
  • trunk/wp-admin/js/dashboard.js

    r19345 r19418  
    1 var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(c){var d=c("#welcome-panel"),a=c("#wp_welcome_panel-hide"),b=function(e){c.post(ajaxurl,{action:"update-welcome-panel",visible:e,welcomepanelnonce:c("#welcomepanelnonce").val()})};if(d.hasClass("hidden")&&a.prop("checked")){d.removeClass("hidden")}c(".welcome-panel-close, .welcome-panel-dismiss a",d).click(function(){d.addClass("hidden");b(0);c("#wp_welcome_panel-hide").prop("checked",false)});a.click(function(){d.toggleClass("hidden",!this.checked);b(this.checked?1:0)});ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];ajaxPopulateWidgets=function(f){function e(g,k){var j,h=c("#"+k+" div.inside:visible").find(".widget-loading");if(h.length){j=h.parent();setTimeout(function(){j.load(ajaxurl.replace("/admin-ajax.php","")+"/index-extra.php?jax="+k,"",function(){j.hide().slideDown("normal",function(){c(this).css("display","")})})},g*500)}}if(f){f=f.toString();if(c.inArray(f,ajaxWidgets)!=-1){e(0,f)}}else{c.each(ajaxWidgets,e)}};ajaxPopulateWidgets();postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var e=c("#quickpost-action"),f;f=c("#quick-press").submit(function(){c("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",true);if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",false);c("#dashboard_quick_press ul").next("p").remove();c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();quickPressLoad()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")})};quickPressLoad()});
     1var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(c){var d=c("#welcome-panel"),a=c("#wp_welcome_panel-hide"),b=function(e){c.post(ajaxurl,{action:"update-welcome-panel",visible:e,welcomepanelnonce:c("#welcomepanelnonce").val()})};if(d.hasClass("hidden")&&a.prop("checked")){d.removeClass("hidden")}c(".welcome-panel-close, .welcome-panel-dismiss a",d).click(function(f){f.preventDefault();d.addClass("hidden");b(0);c("#wp_welcome_panel-hide").prop("checked",false)});a.click(function(){d.toggleClass("hidden",!this.checked);b(this.checked?1:0)});ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins"];ajaxPopulateWidgets=function(f){function e(g,k){var j,h=c("#"+k+" div.inside:visible").find(".widget-loading");if(h.length){j=h.parent();setTimeout(function(){j.load(ajaxurl.replace("/admin-ajax.php","")+"/index-extra.php?jax="+k,"",function(){j.hide().slideDown("normal",function(){c(this).css("display","")})})},g*500)}}if(f){f=f.toString();if(c.inArray(f,ajaxWidgets)!=-1){e(0,f)}}else{c.each(ajaxWidgets,e)}};ajaxPopulateWidgets();postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var e=c("#quickpost-action"),f;f=c("#quick-press").submit(function(){c("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",true);if("post"==e.val()){e.val("post-quickpress-publish")}c("#dashboard_quick_press div.inside").load(f.attr("action"),f.serializeArray(),function(){c("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");c('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled",false);c("#dashboard_quick_press ul").next("p").remove();c("#dashboard_quick_press ul").find("li").each(function(){c("#dashboard_recent_drafts ul").prepend(this)}).end().remove();quickPressLoad()});return false});c("#publish").click(function(){e.val("post-quickpress-publish")})};quickPressLoad()});
  • trunk/wp-includes/script-loader.php

    r19416 r19418  
    370370        $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
    371371
    372         $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20111118', 1 );
     372        $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20111123', 1 );
    373373
    374374        $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
Note: See TracChangeset for help on using the changeset viewer.