In `WP_MS_Themes_List_Table::display_rows()`:
* Move the giant `switch` statement into methods * Call `->single_row_columns()`, which we now override See #29881. Built from https://develop.svn.wordpress.org/trunk@32756 git-svn-id: http://core.svn.wordpress.org/trunk@32727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2bdcc71bc0
commit
3855cfbffd
|
@ -336,15 +336,29 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @global string $status
|
* @since 4.3.0
|
||||||
* @global int $page
|
|
||||||
* @global string $s
|
|
||||||
* @global array $totals
|
|
||||||
*
|
*
|
||||||
* @param WP_Theme $theme
|
* @param WP_Theme $theme
|
||||||
*/
|
*/
|
||||||
public function single_row( $theme ) {
|
public function column_cb( $theme ) {
|
||||||
global $status, $page, $s, $totals;
|
$checkbox_id = 'checkbox_' . md5( $theme->get('Name') );
|
||||||
|
?>
|
||||||
|
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ) ?>" id="<?php echo $checkbox_id ?>" />
|
||||||
|
<label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e( 'Select' ) ?> <?php echo $theme->display( 'Name' ) ?></label>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.3.0
|
||||||
|
*
|
||||||
|
* @global string $status
|
||||||
|
* @global int $page
|
||||||
|
* @global string $s
|
||||||
|
*
|
||||||
|
* @param WP_Theme $theme
|
||||||
|
*/
|
||||||
|
public function column_name( $theme ) {
|
||||||
|
global $status, $page, $s;
|
||||||
|
|
||||||
$context = $status;
|
$context = $status;
|
||||||
|
|
||||||
|
@ -368,18 +382,20 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||||
$theme_key = urlencode( $stylesheet );
|
$theme_key = urlencode( $stylesheet );
|
||||||
|
|
||||||
if ( ! $allowed ) {
|
if ( ! $allowed ) {
|
||||||
if ( ! $theme->errors() )
|
if ( ! $theme->errors() ) {
|
||||||
$actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
|
$actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
|
$actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current_user_can('edit_themes') )
|
if ( current_user_can('edit_themes') ) {
|
||||||
$actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
|
$actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) )
|
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
|
||||||
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Filter the action links displayed for each theme in the Multisite
|
* Filter the action links displayed for each theme in the Multisite
|
||||||
* themes list table.
|
* themes list table.
|
||||||
|
@ -420,53 +436,48 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||||
*/
|
*/
|
||||||
$actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context );
|
$actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context );
|
||||||
|
|
||||||
$class = ! $allowed ? 'inactive' : 'active';
|
echo $this->row_actions( $actions, true );
|
||||||
$checkbox_id = "checkbox_" . md5( $theme->get('Name') );
|
|
||||||
$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
|
|
||||||
|
|
||||||
$id = sanitize_html_class( $theme->get_stylesheet() );
|
|
||||||
|
|
||||||
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
|
|
||||||
$class .= ' update';
|
|
||||||
|
|
||||||
echo "<tr id='$id' class='$class'>";
|
|
||||||
|
|
||||||
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
|
|
||||||
|
|
||||||
foreach ( $columns as $column_name => $column_display_name ) {
|
|
||||||
$extra_classes = '';
|
|
||||||
if ( in_array( $column_name, $hidden ) ) {
|
|
||||||
$extra_classes .= ' hidden';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( $column_name ) {
|
/**
|
||||||
case 'cb':
|
* @since 4.3.0
|
||||||
echo "<th scope='row' class='check-column'>$checkbox</th>";
|
*
|
||||||
break;
|
* @global string $status
|
||||||
case 'name':
|
* @global array $totals
|
||||||
echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $theme->display('Name') . "</strong>";
|
*
|
||||||
echo $this->row_actions($actions, true);
|
* @param WP_Theme $theme
|
||||||
echo "</td>";
|
*/
|
||||||
break;
|
public function column_description( $theme ) {
|
||||||
case 'description':
|
global $status, $totals;
|
||||||
echo "<td class='column-description desc{$extra_classes}'>";
|
|
||||||
if ( $theme->errors() ) {
|
if ( $theme->errors() ) {
|
||||||
$pre = $status == 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
|
$pre = $status == 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
|
||||||
echo '<p><strong class="attention">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
|
echo '<p><strong class="attention">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $this->is_site_themes ) {
|
||||||
|
$allowed = $theme->is_allowed( 'site', $this->site_id );
|
||||||
|
} else {
|
||||||
|
$allowed = $theme->is_allowed( 'network' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = ! $allowed ? 'inactive' : 'active';
|
||||||
|
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
|
||||||
|
$class .= ' update';
|
||||||
|
|
||||||
echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
|
echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
|
||||||
<div class='$class second theme-version-author-uri'>";
|
<div class='$class second theme-version-author-uri'>";
|
||||||
|
|
||||||
|
$stylesheet = $theme->get_stylesheet();
|
||||||
$theme_meta = array();
|
$theme_meta = array();
|
||||||
|
|
||||||
if ( $theme->get('Version') )
|
if ( $theme->get('Version') ) {
|
||||||
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
|
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
|
||||||
|
}
|
||||||
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
|
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
|
||||||
|
|
||||||
if ( $theme->get('ThemeURI') )
|
if ( $theme->get('ThemeURI') ) {
|
||||||
$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
|
$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Filter the array of row meta for each theme in the Multisite themes
|
* Filter the array of row meta for each theme in the Multisite themes
|
||||||
* list table.
|
* list table.
|
||||||
|
@ -484,12 +495,16 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||||
echo implode( ' | ', $theme_meta );
|
echo implode( ' | ', $theme_meta );
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
echo '</td>';
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
echo "<td class='$column_name column-$column_name{$extra_classes}'>";
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.3.0
|
||||||
|
*
|
||||||
|
* @param WP_Theme $theme
|
||||||
|
* @param string $column_name
|
||||||
|
*/
|
||||||
|
public function column_default( $theme, $column_name ) {
|
||||||
|
$stylesheet = $theme->get_stylesheet();
|
||||||
/**
|
/**
|
||||||
* Fires inside each custom column of the Multisite themes list table.
|
* Fires inside each custom column of the Multisite themes list table.
|
||||||
*
|
*
|
||||||
|
@ -500,10 +515,86 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||||
* @param WP_Theme $theme Current WP_Theme object.
|
* @param WP_Theme $theme Current WP_Theme object.
|
||||||
*/
|
*/
|
||||||
do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
|
do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 4.3.0
|
||||||
|
*
|
||||||
|
* @param WP_Theme $item
|
||||||
|
*/
|
||||||
|
public function single_row_columns( $item ) {
|
||||||
|
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
|
||||||
|
|
||||||
|
foreach ( $columns as $column_name => $column_display_name ) {
|
||||||
|
$extra_classes = '';
|
||||||
|
if ( in_array( $column_name, $hidden ) ) {
|
||||||
|
$extra_classes .= ' hidden';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( $column_name ) {
|
||||||
|
case 'cb':
|
||||||
|
echo '<th scope="row" class="check-column">';
|
||||||
|
|
||||||
|
$this->column_cb( $item );
|
||||||
|
|
||||||
|
echo '</th>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'name':
|
||||||
|
echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display('Name') . "</strong>";
|
||||||
|
|
||||||
|
$this->column_name( $item );
|
||||||
|
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'description':
|
||||||
|
echo "<td class='column-description desc{$extra_classes}'>";
|
||||||
|
|
||||||
|
$this->column_description( $item );
|
||||||
|
|
||||||
|
echo '</td>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
echo "<td class='$column_name column-$column_name{$extra_classes}'>";
|
||||||
|
|
||||||
|
$this->column_default( $item, $column_name );
|
||||||
|
|
||||||
|
echo "</td>";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @global string $status
|
||||||
|
* @global array $totals
|
||||||
|
*
|
||||||
|
* @param WP_Theme $theme
|
||||||
|
*/
|
||||||
|
public function single_row( $theme ) {
|
||||||
|
global $status, $totals;
|
||||||
|
|
||||||
|
if ( $this->is_site_themes ) {
|
||||||
|
$allowed = $theme->is_allowed( 'site', $this->site_id );
|
||||||
|
} else {
|
||||||
|
$allowed = $theme->is_allowed( 'network' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$stylesheet = $theme->get_stylesheet();
|
||||||
|
|
||||||
|
$class = ! $allowed ? 'inactive' : 'active';
|
||||||
|
|
||||||
|
$id = sanitize_html_class( $theme->get_stylesheet() );
|
||||||
|
|
||||||
|
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
|
||||||
|
$class .= ' update';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<tr id='$id' class='$class'>";
|
||||||
|
|
||||||
|
$this->single_row_columns( $theme );
|
||||||
|
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32755';
|
$wp_version = '4.3-alpha-32756';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue