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.
git-svn-id: https://develop.svn.wordpress.org/trunk@19418 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b087efe566
commit
4d89846637
@ -1064,10 +1064,7 @@ case 'update-welcome-panel' :
|
||||
if ( ! current_user_can( 'edit_theme_options' ) )
|
||||
die('-1');
|
||||
|
||||
if ( empty( $_POST['visible'] ) )
|
||||
delete_user_option( get_current_user_id(), 'show_welcome_panel' );
|
||||
else
|
||||
update_user_option( get_current_user_id(), 'show_welcome_panel', 1 );
|
||||
update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
|
||||
|
||||
die('1');
|
||||
break;
|
||||
|
@ -1276,14 +1276,17 @@ function wp_welcome_panel() {
|
||||
|
||||
$classes = 'welcome-panel';
|
||||
|
||||
if ( ! get_user_option( 'show_welcome_panel' ) )
|
||||
$option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
|
||||
// 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
|
||||
$hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
|
||||
if ( $hide )
|
||||
$classes .= ' hidden';
|
||||
|
||||
list( $display_version ) = explode( '-', $wp_version );
|
||||
?>
|
||||
<div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
|
||||
<?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
|
||||
<a class="welcome-panel-close" href="#"><?php _e('Dismiss'); ?></a>
|
||||
<a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?welcome=0' ) ); ?>"><?php _e('Dismiss'); ?></a>
|
||||
<div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div>
|
||||
|
||||
<div class="welcome-panel-content">
|
||||
@ -1349,7 +1352,7 @@ function wp_welcome_panel() {
|
||||
endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<p class="welcome-panel-dismiss"><?php _e( 'Already know what you’re doing? <a href="#">Dismiss this message</a>.' ); ?></p>
|
||||
<p class="welcome-panel-dismiss"><?php printf( __( 'Already know what you’re doing? <a href="%s">Dismiss this message</a>.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -824,8 +824,16 @@ final class WP_Screen {
|
||||
meta_box_prefs( $this );
|
||||
|
||||
if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) {
|
||||
if ( isset( $_GET['welcome'] ) ) {
|
||||
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
|
||||
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
|
||||
} else {
|
||||
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
|
||||
if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )
|
||||
$welcome_checked = false;
|
||||
}
|
||||
echo '<label for="wp_welcome_panel-hide">';
|
||||
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) get_user_option( 'show_welcome_panel' ), true, false ) . ' />';
|
||||
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
|
||||
echo __( 'Welcome' ) . "</label>\n";
|
||||
}
|
||||
?>
|
||||
|
@ -283,6 +283,11 @@ As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to d
|
||||
update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
|
||||
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 ) );
|
||||
|
||||
if ( ! is_multisite() )
|
||||
update_user_meta( $user_id, 'show_welcome_panel', 1 );
|
||||
elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
|
||||
update_user_meta( $user_id, 'show_welcome_panel', 2 );
|
||||
|
||||
if ( is_multisite() ) {
|
||||
// Flush rules to pick up the new page.
|
||||
$wp_rewrite->init();
|
||||
|
@ -15,7 +15,8 @@ jQuery(document).ready( function($) {
|
||||
if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') )
|
||||
welcomePanel.removeClass('hidden');
|
||||
|
||||
$('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function() {
|
||||
$('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {
|
||||
e.preventDefault();
|
||||
welcomePanel.addClass('hidden');
|
||||
updateWelcomePanel( 0 );
|
||||
$('#wp_welcome_panel-hide').prop('checked', false);
|
||||
|
@ -1 +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()});
|
||||
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(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()});
|
@ -369,7 +369,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
|
||||
$scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
|
||||
|
||||
$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20111118', 1 );
|
||||
$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20111123', 1 );
|
||||
|
||||
$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user