Dashboard: Introduce a "Try Gutenberg" callout.

To encourage more people to try Gutenberg, this new Dashboard box allows site users to easily install and try out Gutenberg.

Props pento, melchoyce, joen, karmatosed, joemcgill, SergeyBiryukov, jorbin.

Fixes #41316.


Built from https://develop.svn.wordpress.org/branches/4.9@42869


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2018-03-22 00:59:44 +00:00
parent c12c3a96b3
commit 61be857c95
20 changed files with 345 additions and 55 deletions

View File

@ -64,7 +64,7 @@ $core_actions_post = array(
'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'crop-image', 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'crop-image',
'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins', 'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins',
'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme',
'get-post-thumbnail-html', 'get-community-events', 'edit-theme-plugin-file', 'get-post-thumbnail-html', 'get-community-events', 'edit-theme-plugin-file', 'update-try-gutenberg-panel',
); );
// Deprecated // Deprecated

View File

@ -764,6 +764,7 @@ img.emoji {
/* @todo can we combine these into a class or use an existing dashicon one? */ /* @todo can we combine these into a class or use an existing dashicon one? */
.welcome-panel .welcome-panel-close:before, .welcome-panel .welcome-panel-close:before,
.try-gutenberg-panel .try-gutenberg-panel-close:before,
.tagchecklist .ntdelbutton .remove-tag-icon:before, .tagchecklist .ntdelbutton .remove-tag-icon:before,
#bulk-titles div a:before, #bulk-titles div a:before,
.notice-dismiss:before { .notice-dismiss:before {

File diff suppressed because one or more lines are too long

View File

@ -764,6 +764,7 @@ img.emoji {
/* @todo can we combine these into a class or use an existing dashicon one? */ /* @todo can we combine these into a class or use an existing dashicon one? */
.welcome-panel .welcome-panel-close:before, .welcome-panel .welcome-panel-close:before,
.try-gutenberg-panel .try-gutenberg-panel-close:before,
.tagchecklist .ntdelbutton .remove-tag-icon:before, .tagchecklist .ntdelbutton .remove-tag-icon:before,
#bulk-titles div a:before, #bulk-titles div a:before,
.notice-dismiss:before { .notice-dismiss:before {

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,8 @@
} }
/* Welcome Panel */ /* Welcome Panel */
.welcome-panel { .welcome-panel,
.try-gutenberg-panel {
position: relative; position: relative;
overflow: auto; overflow: auto;
margin: 16px 0; margin: 16px 0;
@ -110,27 +111,33 @@
line-height: 2.1em; line-height: 2.1em;
} }
.welcome-panel h2 { .welcome-panel h2,
.try-gutenberg-panel h2 {
margin: 0; margin: 0;
font-size: 21px; font-size: 21px;
font-weight: 400; font-weight: 400;
line-height: 1.2; line-height: 1.2;
} }
.welcome-panel h3 { .welcome-panel h3,
.try-gutenberg-panel h3 {
margin: 1.33em 0 0; margin: 1.33em 0 0;
font-size: 16px; font-size: 16px;
} }
.welcome-panel li { .welcome-panel li,
.try-gutenberg-panel li {
font-size: 14px; font-size: 14px;
} }
.welcome-panel p { .welcome-panel p,
.try-gutenberg-panel p,
.try-gutenberg-panel-column p.about-description {
color: #72777c; color: #72777c;
} }
.welcome-panel a { .welcome-panel a,
.try-gutenberg-panel a {
text-decoration: none; text-decoration: none;
} }
@ -139,8 +146,15 @@
margin: 0; margin: 0;
} }
.welcome-panel .welcome-panel-close { .try-gutenberg-panel .about-description {
font-size: 16px;
margin-top: 1.33em;
}
.welcome-panel .welcome-panel-close,
.try-gutenberg-panel .try-gutenberg-panel-close {
position: absolute; position: absolute;
z-index: 10;
top: 10px; top: 10px;
left: 10px; left: 10px;
padding: 10px 21px 10px 15px; padding: 10px 21px 10px 15px;
@ -149,7 +163,8 @@
text-decoration: none; text-decoration: none;
} }
.welcome-panel .welcome-panel-close:before { .welcome-panel .welcome-panel-close:before,
.try-gutenberg-panel .try-gutenberg-panel-close:before {
position: absolute; position: absolute;
top: 8px; top: 8px;
right: 0; right: 0;
@ -164,27 +179,48 @@
white-space: normal; white-space: normal;
} }
.welcome-panel-content { .welcome-panel-content,
margin-right: 13px; .try-gutenberg-panel-content {
margin: 0 13px;
max-width: 1500px; max-width: 1500px;
} }
.welcome-panel .welcome-panel-column-container { .try-gutenberg-panel img {
max-width: 360px;
width: 100%;
border: 1px solid #f3f4f5;
}
.try-gutenberg-panel .install-now.updating-message:before,
.try-gutenberg-panel .install-now.updated-message:before {
margin-top: 11px;
}
.welcome-panel .welcome-panel-column-container,
.try-gutenberg-panel .try-gutenberg-panel-column-container {
clear: both; clear: both;
position: relative; position: relative;
} }
.welcome-panel .welcome-panel-column { .welcome-panel .welcome-panel-column,
.try-gutenberg-panel .try-gutenberg-panel-column {
width: 32%; width: 32%;
min-width: 200px; min-width: 200px;
float: right; float: right;
} }
.ie8 .welcome-panel .welcome-panel-column { .try-gutenberg-panel .try-gutenberg-panel-column {
width: calc( 32% - 20px );
padding: 0 0 20px 20px;
}
.ie8 .welcome-panel .welcome-panel-column,
.ie8 .try-gutenberg-panel .try-gutenberg-panel-column {
min-width: 230px; min-width: 230px;
} }
.welcome-panel .welcome-panel-column:first-child { .welcome-panel .welcome-panel-column:first-child
.try-gutenberg-panel .try-gutenberg-panel-column:first-child {
width: 36%; width: 36%;
} }
@ -192,7 +228,8 @@
margin-top: 10px; margin-top: 10px;
} }
.welcome-panel-column p { .welcome-panel-column p,
.try-gutenberg-panel-column p {
margin-top: 7px; margin-top: 7px;
color: #444; color: #444;
} }
@ -201,16 +238,22 @@
line-height: 16px; line-height: 16px;
} }
.welcome-panel .welcome-panel-column ul { .welcome-panel .welcome-panel-column ul,
.try-gutenberg-panel .try-gutenberg-panel-column ul {
margin: 0.8em 0 1em 1em; margin: 0.8em 0 1em 1em;
} }
.welcome-panel .welcome-panel-column li { .welcome-panel .welcome-panel-column li,
.try-gutenberg-panel .try-gutenberg-panel-column li {
line-height: 16px; line-height: 16px;
list-style-type: none; list-style-type: none;
padding: 0 0 8px; padding: 0 0 8px;
} }
.try-gutenberg-panel .notice {
display: inline-block;
}
.welcome-panel .welcome-icon { .welcome-panel .welcome-icon {
background: transparent !important; background: transparent !important;
} }
@ -1207,14 +1250,29 @@ a.rsswidget {
} }
} }
@media screen and (max-width: 1024px) {
.try-gutenberg-panel .try-gutenberg-panel-image-column {
display: none;
}
.try-gutenberg-panel .try-gutenberg-panel-column {
width: calc( 49% - 20px );
}
}
@media screen and (max-width: 870px) { @media screen and (max-width: 870px) {
.welcome-panel .welcome-panel-column, .welcome-panel .welcome-panel-column,
.try-gutenberg-panel .try-gutenberg-panel-column,
.welcome-panel .welcome-panel-column:first-child { .welcome-panel .welcome-panel-column:first-child {
display: block; display: block;
float: none; float: none;
width: 100%; width: 100%;
} }
.try-gutenberg-panel .try-gutenberg-panel-image-column {
display: none;
}
.welcome-panel .welcome-panel-column li { .welcome-panel .welcome-panel-column li {
display: inline-block; display: inline-block;
margin-left: 13px; margin-left: 13px;
@ -1223,7 +1281,6 @@ a.rsswidget {
.welcome-panel .welcome-panel-column ul { .welcome-panel .welcome-panel-column ul {
margin: 0.4em 0 0; margin: 0.4em 0 0;
} }
} }
@media screen and ( max-width: 782px ) { @media screen and ( max-width: 782px ) {
@ -1266,7 +1323,8 @@ a.rsswidget {
/* Smartphone */ /* Smartphone */
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
/* Keep the close icon from overlapping the Welcome text. */ /* Keep the close icon from overlapping the Welcome text. */
.welcome-panel .welcome-panel-close { .welcome-panel .welcome-panel-close,
.try-gutenberg-panel .try-gutenberg-panel-close {
overflow: hidden; overflow: hidden;
text-indent: 40px; text-indent: 40px;
white-space: nowrap; white-space: nowrap;
@ -1278,7 +1336,8 @@ a.rsswidget {
} }
/* Make the close icon larger for tappability. */ /* Make the close icon larger for tappability. */
.welcome-panel .welcome-panel-close:before { .welcome-panel .welcome-panel-close:before,
.try-gutenberg-panel .try-gutenberg-panel-close:before {
font-size: 20px; font-size: 20px;
top: 5px; top: 5px;
right: -35px; right: -35px;

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,8 @@
} }
/* Welcome Panel */ /* Welcome Panel */
.welcome-panel { .welcome-panel,
.try-gutenberg-panel {
position: relative; position: relative;
overflow: auto; overflow: auto;
margin: 16px 0; margin: 16px 0;
@ -110,27 +111,33 @@
line-height: 2.1em; line-height: 2.1em;
} }
.welcome-panel h2 { .welcome-panel h2,
.try-gutenberg-panel h2 {
margin: 0; margin: 0;
font-size: 21px; font-size: 21px;
font-weight: 400; font-weight: 400;
line-height: 1.2; line-height: 1.2;
} }
.welcome-panel h3 { .welcome-panel h3,
.try-gutenberg-panel h3 {
margin: 1.33em 0 0; margin: 1.33em 0 0;
font-size: 16px; font-size: 16px;
} }
.welcome-panel li { .welcome-panel li,
.try-gutenberg-panel li {
font-size: 14px; font-size: 14px;
} }
.welcome-panel p { .welcome-panel p,
.try-gutenberg-panel p,
.try-gutenberg-panel-column p.about-description {
color: #72777c; color: #72777c;
} }
.welcome-panel a { .welcome-panel a,
.try-gutenberg-panel a {
text-decoration: none; text-decoration: none;
} }
@ -139,8 +146,15 @@
margin: 0; margin: 0;
} }
.welcome-panel .welcome-panel-close { .try-gutenberg-panel .about-description {
font-size: 16px;
margin-top: 1.33em;
}
.welcome-panel .welcome-panel-close,
.try-gutenberg-panel .try-gutenberg-panel-close {
position: absolute; position: absolute;
z-index: 10;
top: 10px; top: 10px;
right: 10px; right: 10px;
padding: 10px 15px 10px 21px; padding: 10px 15px 10px 21px;
@ -149,7 +163,8 @@
text-decoration: none; text-decoration: none;
} }
.welcome-panel .welcome-panel-close:before { .welcome-panel .welcome-panel-close:before,
.try-gutenberg-panel .try-gutenberg-panel-close:before {
position: absolute; position: absolute;
top: 8px; top: 8px;
left: 0; left: 0;
@ -164,27 +179,48 @@
white-space: normal; white-space: normal;
} }
.welcome-panel-content { .welcome-panel-content,
margin-left: 13px; .try-gutenberg-panel-content {
margin: 0 13px;
max-width: 1500px; max-width: 1500px;
} }
.welcome-panel .welcome-panel-column-container { .try-gutenberg-panel img {
max-width: 360px;
width: 100%;
border: 1px solid #f3f4f5;
}
.try-gutenberg-panel .install-now.updating-message:before,
.try-gutenberg-panel .install-now.updated-message:before {
margin-top: 11px;
}
.welcome-panel .welcome-panel-column-container,
.try-gutenberg-panel .try-gutenberg-panel-column-container {
clear: both; clear: both;
position: relative; position: relative;
} }
.welcome-panel .welcome-panel-column { .welcome-panel .welcome-panel-column,
.try-gutenberg-panel .try-gutenberg-panel-column {
width: 32%; width: 32%;
min-width: 200px; min-width: 200px;
float: left; float: left;
} }
.ie8 .welcome-panel .welcome-panel-column { .try-gutenberg-panel .try-gutenberg-panel-column {
width: calc( 32% - 20px );
padding: 0 20px 20px 0;
}
.ie8 .welcome-panel .welcome-panel-column,
.ie8 .try-gutenberg-panel .try-gutenberg-panel-column {
min-width: 230px; min-width: 230px;
} }
.welcome-panel .welcome-panel-column:first-child { .welcome-panel .welcome-panel-column:first-child
.try-gutenberg-panel .try-gutenberg-panel-column:first-child {
width: 36%; width: 36%;
} }
@ -192,7 +228,8 @@
margin-top: 10px; margin-top: 10px;
} }
.welcome-panel-column p { .welcome-panel-column p,
.try-gutenberg-panel-column p {
margin-top: 7px; margin-top: 7px;
color: #444; color: #444;
} }
@ -201,16 +238,22 @@
line-height: 16px; line-height: 16px;
} }
.welcome-panel .welcome-panel-column ul { .welcome-panel .welcome-panel-column ul,
.try-gutenberg-panel .try-gutenberg-panel-column ul {
margin: 0.8em 1em 1em 0; margin: 0.8em 1em 1em 0;
} }
.welcome-panel .welcome-panel-column li { .welcome-panel .welcome-panel-column li,
.try-gutenberg-panel .try-gutenberg-panel-column li {
line-height: 16px; line-height: 16px;
list-style-type: none; list-style-type: none;
padding: 0 0 8px; padding: 0 0 8px;
} }
.try-gutenberg-panel .notice {
display: inline-block;
}
.welcome-panel .welcome-icon { .welcome-panel .welcome-icon {
background: transparent !important; background: transparent !important;
} }
@ -1207,14 +1250,29 @@ a.rsswidget {
} }
} }
@media screen and (max-width: 1024px) {
.try-gutenberg-panel .try-gutenberg-panel-image-column {
display: none;
}
.try-gutenberg-panel .try-gutenberg-panel-column {
width: calc( 49% - 20px );
}
}
@media screen and (max-width: 870px) { @media screen and (max-width: 870px) {
.welcome-panel .welcome-panel-column, .welcome-panel .welcome-panel-column,
.try-gutenberg-panel .try-gutenberg-panel-column,
.welcome-panel .welcome-panel-column:first-child { .welcome-panel .welcome-panel-column:first-child {
display: block; display: block;
float: none; float: none;
width: 100%; width: 100%;
} }
.try-gutenberg-panel .try-gutenberg-panel-image-column {
display: none;
}
.welcome-panel .welcome-panel-column li { .welcome-panel .welcome-panel-column li {
display: inline-block; display: inline-block;
margin-right: 13px; margin-right: 13px;
@ -1223,7 +1281,6 @@ a.rsswidget {
.welcome-panel .welcome-panel-column ul { .welcome-panel .welcome-panel-column ul {
margin: 0.4em 0 0; margin: 0.4em 0 0;
} }
} }
@media screen and ( max-width: 782px ) { @media screen and ( max-width: 782px ) {
@ -1266,7 +1323,8 @@ a.rsswidget {
/* Smartphone */ /* Smartphone */
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
/* Keep the close icon from overlapping the Welcome text. */ /* Keep the close icon from overlapping the Welcome text. */
.welcome-panel .welcome-panel-close { .welcome-panel .welcome-panel-close,
.try-gutenberg-panel .try-gutenberg-panel-close {
overflow: hidden; overflow: hidden;
text-indent: 40px; text-indent: 40px;
white-space: nowrap; white-space: nowrap;
@ -1278,7 +1336,8 @@ a.rsswidget {
} }
/* Make the close icon larger for tappability. */ /* Make the close icon larger for tappability. */
.welcome-panel .welcome-panel-close:before { .welcome-panel .welcome-panel-close:before,
.try-gutenberg-panel .try-gutenberg-panel-close:before {
font-size: 20px; font-size: 20px;
top: 5px; top: 5px;
left: -35px; left: -35px;

File diff suppressed because one or more lines are too long

View File

@ -1484,6 +1484,19 @@ function wp_ajax_update_welcome_panel() {
wp_die( 1 ); wp_die( 1 );
} }
/**
* Ajax handler for updating whether to display the Try Gutenberg panel.
*
* @since 4.9.5
*/
function wp_ajax_update_try_gutenberg_panel() {
check_ajax_referer( 'try-gutenberg-panel-nonce', 'trygutenbergpanelnonce' );
update_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', empty( $_POST['visible'] ) ? 0 : 1 );
wp_die( 1 );
}
/** /**
* Ajax handler for retrieving menu meta boxes. * Ajax handler for retrieving menu meta boxes.
* *

View File

@ -1020,7 +1020,10 @@ final class WP_Screen {
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
} else { } else {
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); $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' ) ) { if ( '' === $welcome_checked ) {
$welcome_checked = '1';
}
if ( '2' === $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
$welcome_checked = false; $welcome_checked = false;
} }
} }
@ -1028,6 +1031,24 @@ final class WP_Screen {
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
} }
if ( 'dashboard' === $this->id && has_action( 'try_gutenberg_panel' ) ) {
if ( isset( $_GET['try_gutenberg'] ) ) {
$try_gutenberg_checked = empty( $_GET['try_gutenberg'] ) ? 0 : 1;
update_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', $try_gutenberg_checked );
} else {
$try_gutenberg_checked = get_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', true );
if ( '' === $try_gutenberg_checked ) {
$try_gutenberg_checked = '1';
}
if ( '2' === $try_gutenberg_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
$try_gutenberg_checked = false;
}
}
echo '<label for="wp_try_gutenberg_panel-hide">';
echo '<input type="checkbox" id="wp_try_gutenberg_panel-hide"' . checked( (bool) $try_gutenberg_checked, true, false ) . ' />';
echo __( 'New Editor' ) . "</label>\n";
}
?> ?>
</fieldset> </fieldset>
<?php <?php

View File

@ -1619,3 +1619,59 @@ function wp_welcome_panel() {
</div> </div>
<?php <?php
} }
/**
* Displays a Try Gutenberg Panel, to introduce people to Gutenberg
*
* @since 4.9.5
*/
function wp_try_gutenberg_panel() {
$plugins = get_plugins();
$action = $url = $classes = '';
if ( current_user_can( 'install_plugins' ) && empty( $plugins['gutenberg/gutenberg.php'] ) ) {
$action = __( 'Install Today' );
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=gutenberg' ), 'install-plugin_gutenberg' );
$classes = ' install-now';
} else if ( current_user_can( 'install_plugins' ) && is_plugin_inactive( 'gutenberg/gutenberg.php' ) ) {
$action = __( 'Activate Today' );
$url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=gutenberg/gutenberg.php&from=try-gutenberg' ), 'activate-plugin_gutenberg/gutenberg.php' );
$classes = ' activate-now';
} else if ( current_user_can( 'edit_posts' ) && is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
$action = __( 'Try Today' );
$url = admin_url( 'admin.php?page=gutenberg' );
}
?>
<div class="try-gutenberg-panel-content plugin-card-gutenberg">
<div class="try-gutenberg-panel-column-container">
<div class="try-gutenberg-panel-column try-gutenberg-panel-image-column">
<img src="https://s.w.org/images/core/gutenberg-screenshot.gif?<?php echo date( 'Ymd' ); ?>" alt="<?php esc_attr_e( 'Gutenberg animated preview' ); ?>" />
</div>
<h2><?php _e( 'Try the new editing experience' ); ?></h2>
<div class="try-gutenberg-panel-column">
<p class="about-description"><?php _e( 'WordPress is working on a better way to control your content. How about giving it a try early?' ); ?></p>
<?php if ( $action ) { ?>
<p><a class="button button-primary button-hero<?php echo $classes; ?>" href="<?php echo esc_url( $url ); ?>"><?php echo $action; ?></a></p>
<?php } ?>
</div>
<div class="try-gutenberg-panel-column try-gutenberg-panel-last">
<h3><?php _e( 'Want to get involved?' ); ?></h3>
<ul>
<li><?php
printf( __( 'Learn more about the project <a href="%s">codenamed Gutenberg</a>.' ),
'https://wordpress.org/gutenberg/'
);
?></li>
<li><?php
printf( __( 'Help <a href="%1$s">with testing</a>, or contribute on the <a href="%2$s">GitHub repository</a>.' ),
__( 'https://make.wordpress.org/test/handbook/call-for-testing/gutenberg-testing/' ),
'https://github.com/WordPress/gutenberg/'
);
?></li>
</ul>
</div>
</div>
</div>
<?php
}

View File

@ -103,12 +103,38 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<div class="wrap"> <div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1> <h1><?php echo esc_html( $title ); ?></h1>
<?php if ( has_action( 'try_gutenberg_panel' ) ) :
$classes = 'try-gutenberg-panel';
$option = get_user_meta( get_current_user_id(), 'show_try_gutenberg_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'; ?>
<div id="try-gutenberg-panel" class="<?php echo esc_attr( $classes ); ?>">
<?php wp_nonce_field( 'try-gutenberg-panel-nonce', 'trygutenbergpanelnonce', false ); ?>
<a class="try-gutenberg-panel-close" href="<?php echo esc_url( admin_url( '?try_gutenberg=0' ) ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the Try Gutenberg panel' ); ?>"><?php _e( 'Dismiss' ); ?></a>
<?php
/**
* Add content to the Try Gutenberg panel on the admin dashboard.
*
* To remove the Try Gutenberg panel, use remove_action():
*
* remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
*
* @since 4.9.5
*/
do_action( 'try_gutenberg_panel' );
?>
</div>
<?php endif; ?>
<?php if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) : <?php if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) :
$classes = 'welcome-panel'; $classes = 'welcome-panel';
$option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); $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 // 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' ) ); $hide = '0' === $option || ( '2' === $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
if ( $hide ) if ( $hide )
$classes .= ' hidden'; ?> $classes .= ' hidden'; ?>

View File

@ -31,6 +31,48 @@ jQuery(document).ready( function($) {
updateWelcomePanel( this.checked ? 1 : 0 ); updateWelcomePanel( this.checked ? 1 : 0 );
}); });
var tryGutenbergPanel = $( '#try-gutenberg-panel' ),
tryGutenbergPanelHide = $('#wp_try_gutenberg_panel-hide'),
updateTryGutenbergPanel, installGutenbergSuccess;
updateTryGutenbergPanel = function( visible ) {
$.post( ajaxurl, {
action: 'update-try-gutenberg-panel',
visible: visible,
trygutenbergpanelnonce: $( '#trygutenbergpanelnonce' ).val()
});
};
installGutenbergSuccess = function( response ) {
response.activateUrl += '&from=try-gutenberg';
wp.updates.installPluginSuccess( response );
};
if ( tryGutenbergPanel.hasClass('hidden') && tryGutenbergPanelHide.prop('checked') ) {
tryGutenbergPanel.removeClass('hidden');
}
$('.try-gutenberg-panel-close, .try-gutenberg-panel-dismiss a', tryGutenbergPanel).click( function(e) {
e.preventDefault();
tryGutenbergPanel.addClass('hidden');
updateTryGutenbergPanel( 0 );
$('#wp_try_gutenberg_panel-hide').prop('checked', false);
});
tryGutenbergPanelHide.click( function() {
tryGutenbergPanel.toggleClass('hidden', ! this.checked );
updateTryGutenbergPanel( this.checked ? 1 : 0 );
});
tryGutenbergPanel.on( 'click', '.install-now', function( e ) {
e.preventDefault();
var args = {
slug: 'gutenberg',
success: installGutenbergSuccess
};
wp.updates.installPlugin( args );
} );
// These widgets are sometimes populated via ajax // These widgets are sometimes populated via ajax
ajaxWidgets = ['dashboard_primary']; ajaxWidgets = ['dashboard_primary'];

File diff suppressed because one or more lines are too long

View File

@ -585,10 +585,18 @@
$message $message
.removeClass( 'updating-message' ) .removeClass( 'updating-message' )
.addClass( 'updated-message installed button-disabled' ) .addClass( 'updated-message installed' )
.attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) ) .attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
.text( wp.updates.l10n.pluginInstalled ); .text( wp.updates.l10n.pluginInstalled );
if ( $message.hasClass( 'button-primary' ) ) {
$message.addClass( 'button-primary-disabled' );
} else if ( $message.hasClass( 'button-secondary' ) ) {
$message.addClass( 'button-secondary-disabled' );
} else {
$message.addClass( 'button-disabled' );
}
wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' ); wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
$document.trigger( 'wp-plugin-install-success', response ); $document.trigger( 'wp-plugin-install-success', response );
@ -597,7 +605,8 @@
setTimeout( function() { setTimeout( function() {
// Transform the 'Install' button into an 'Activate' button. // Transform the 'Install' button into an 'Activate' button.
$message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' ) $message.removeClass( 'install-now installed button-primary-disabled button-secondary-disabled button-disabled updated-message' )
.addClass( 'activate-now button-primary' )
.attr( 'href', response.activateUrl ) .attr( 'href', response.activateUrl )
.attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) ) .attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
.text( wp.updates.l10n.activatePlugin ); .text( wp.updates.l10n.activatePlugin );

File diff suppressed because one or more lines are too long

View File

@ -65,6 +65,8 @@ if ( $action ) {
wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
} else if ( isset($_GET['from']) && 'press-this' == $_GET['from'] ) { } else if ( isset($_GET['from']) && 'press-this' == $_GET['from'] ) {
wp_redirect( self_admin_url( "press-this.php") ); wp_redirect( self_admin_url( "press-this.php") );
} else if ( isset($_GET['from']) && 'try-gutenberg' == $_GET['from'] ) {
wp_redirect( self_admin_url( "admin.php?page=gutenberg") );
} else { } else {
wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
} }

View File

@ -318,6 +318,7 @@ add_action( 'transition_post_status', '_transition_post_status',
add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 );
add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); add_action( 'admin_init', 'send_frame_options_header', 10, 0 );
add_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
add_action( 'welcome_panel', 'wp_welcome_panel' ); add_action( 'welcome_panel', 'wp_welcome_panel' );
// Cron tasks // Cron tasks

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9.5-beta1-42868'; $wp_version = '4.9.5-beta1-42869';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.