Make WordPress Core

Changeset 35187


Ignore:
Timestamp:
10/15/2015 05:10:32 AM (9 years ago)
Author:
SergeyBiryukov
Message:

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

Props rabmalin for initial patch.
Fixes #32668.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/themes.php

    r34994 r35187  
    301301<?php
    302302$can_delete = current_user_can( 'delete_themes' );
     303$can_install = current_user_can( 'install_themes' );
    303304?>
    304305<table>
     
    307308        <th><?php _e('Description'); ?></th>
    308309        <?php if ( $can_delete ) { ?>
     310            <td></td>
     311        <?php } ?>
     312        <?php if ( $can_install ) { ?>
    309313            <td></td>
    310314        <?php } ?>
     
    326330                <?php
    327331            }
     332
     333            if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
     334                $parent_theme_name = $broken_theme->get( 'Template' );
     335                $parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
     336
     337                if ( ! is_wp_error( $parent_theme ) ) {
     338                    $install_url = add_query_arg( array(
     339                        'action' => 'install-theme',
     340                        'theme'  => urlencode( $parent_theme_name ),
     341                    ), admin_url( 'update.php' ) );
     342                    $install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
     343                    ?>
     344                    <td><a href="<?php echo esc_url( $install_url ); ?>" class="button button-secondary install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
     345                    <?php
     346                }
     347            }
    328348            ?>
    329349        </tr>
Note: See TracChangeset for help on using the changeset viewer.