- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-theme-installer-skin.php
r41797 r42343 21 21 22 22 /** 23 *24 23 * @param array $args 25 24 */ 26 public function __construct($args = array()) { 27 $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); 28 $args = wp_parse_args($args, $defaults); 25 public function __construct( $args = array() ) { 26 $defaults = array( 27 'type' => 'web', 28 'url' => '', 29 'theme' => '', 30 'nonce' => '', 31 'title' => '', 32 ); 33 $args = wp_parse_args( $args, $defaults ); 29 34 30 35 $this->type = $args['type']; 31 $this->api = isset($args['api']) ? $args['api'] : array();36 $this->api = isset( $args['api'] ) ? $args['api'] : array(); 32 37 33 parent::__construct( $args);38 parent::__construct( $args ); 34 39 } 35 40 … … 37 42 */ 38 43 public function before() { 39 if ( !empty($this->api) ) 40 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); 44 if ( ! empty( $this->api ) ) { 45 $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version ); 46 } 41 47 } 42 48 … … 44 50 */ 45 51 public function after() { 46 if ( empty( $this->upgrader->result['destination_name']) )52 if ( empty( $this->upgrader->result['destination_name'] ) ) { 47 53 return; 54 } 48 55 49 56 $theme_info = $this->upgrader->theme_info(); 50 if ( empty( $theme_info ) ) 57 if ( empty( $theme_info ) ) { 51 58 return; 59 } 52 60 53 $name = $theme_info->display( 'Name');61 $name = $theme_info->display( 'Name' ); 54 62 $stylesheet = $this->upgrader->result['destination_name']; 55 63 $template = $theme_info->get_template(); 56 64 57 $activate_link = add_query_arg( array( 58 'action' => 'activate', 59 'template' => urlencode( $template ), 60 'stylesheet' => urlencode( $stylesheet ), 61 ), admin_url('themes.php') ); 65 $activate_link = add_query_arg( 66 array( 67 'action' => 'activate', 68 'template' => urlencode( $template ), 69 'stylesheet' => urlencode( $stylesheet ), 70 ), admin_url( 'themes.php' ) 71 ); 62 72 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 63 73 … … 65 75 66 76 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 67 $customize_url = add_query_arg(77 $customize_url = add_query_arg( 68 78 array( 69 'theme' => urlencode( $stylesheet ),79 'theme' => urlencode( $stylesheet ), 70 80 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), 71 81 ), … … 76 86 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; 77 87 78 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) 88 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) { 79 89 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; 90 } 80 91 81 if ( $this->type == 'web' ) 92 if ( $this->type == 'web' ) { 82 93 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; 83 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )94 } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { 84 95 $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; 96 } 85 97 86 if ( ! $this->result || is_wp_error( $this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )98 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) { 87 99 unset( $install_actions['activate'], $install_actions['preview'] ); 100 } 88 101 89 102 /** … … 98 111 */ 99 112 $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); 100 if ( ! empty($install_actions) ) 101 $this->feedback(implode(' | ', (array)$install_actions)); 113 if ( ! empty( $install_actions ) ) { 114 $this->feedback( implode( ' | ', (array) $install_actions ) ); 115 } 102 116 } 103 117 }
Note: See TracChangeset
for help on using the changeset viewer.