Themes: Add Install Parent Theme button for child themes that are missing a parent theme.

Props rabmalin for initial patch.
Fixes #32668.

git-svn-id: https://develop.svn.wordpress.org/trunk@35187 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2015-10-15 05:10:32 +00:00
parent 16d98ebf73
commit 80178d8dc8
1 changed files with 20 additions and 0 deletions

View File

@ -300,6 +300,7 @@ if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_
<?php
$can_delete = current_user_can( 'delete_themes' );
$can_install = current_user_can( 'install_themes' );
?>
<table>
<tr>
@ -308,6 +309,9 @@ $can_delete = current_user_can( 'delete_themes' );
<?php if ( $can_delete ) { ?>
<td></td>
<?php } ?>
<?php if ( $can_install ) { ?>
<td></td>
<?php } ?>
</tr>
<?php foreach ( $broken_themes as $broken_theme ) : ?>
<tr>
@ -325,6 +329,22 @@ $can_delete = current_user_can( 'delete_themes' );
<td><a href="<?php echo esc_url( $delete_url ); ?>" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a></td>
<?php
}
if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
$parent_theme_name = $broken_theme->get( 'Template' );
$parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
if ( ! is_wp_error( $parent_theme ) ) {
$install_url = add_query_arg( array(
'action' => 'install-theme',
'theme' => urlencode( $parent_theme_name ),
), admin_url( 'update.php' ) );
$install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
?>
<td><a href="<?php echo esc_url( $install_url ); ?>" class="button button-secondary install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
<?php
}
}
?>
</tr>
<?php endforeach; ?>