Make WordPress Core


Ignore:
Timestamp:
09/04/2013 06:34:38 AM (12 years ago)
Author:
dd32
Message:

Upgrader: Split the UI "skins" out from the main Upgrader file into a seperate file to reduce the length of the files. See #22704

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r25181 r25227  
    1212 */
    1313
     14require ABSPATH . 'wp-admin/includes/class-wp-upgrader-skins.php';
     15
    1416/**
    1517 * WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file.
    16  *
    17  * @TODO More Detailed docs, for methods as well.
    1818 *
    1919 * @package WordPress
     
    368368 * Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file.
    369369 *
    370  * @TODO More Detailed docs, for methods as well.
    371  *
    372370 * @package WordPress
    373371 * @subpackage Upgrader
     
    653651/**
    654652 * Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
    655  *
    656  * @TODO More Detailed docs, for methods as well.
    657653 *
    658654 * @package WordPress
     
    10281024 * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combination with the wp-admin/includes/update-core.php file
    10291025 *
    1030  * @TODO More Detailed docs, for methods as well.
    1031  *
    10321026 * @package WordPress
    10331027 * @subpackage Upgrader
     
    11031097
    11041098/**
    1105  * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
    1106  *
    1107  * @TODO More Detailed docs, for methods as well.
    1108  *
    1109  * @package WordPress
    1110  * @subpackage Upgrader
    1111  * @since 2.8.0
    1112  */
    1113 class WP_Upgrader_Skin {
    1114 
    1115     var $upgrader;
    1116     var $done_header = false;
    1117     var $result = false;
    1118 
    1119     function __construct($args = array()) {
    1120         $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
    1121         $this->options = wp_parse_args($args, $defaults);
    1122     }
    1123 
    1124     function set_upgrader(&$upgrader) {
    1125         if ( is_object($upgrader) )
    1126             $this->upgrader =& $upgrader;
    1127         $this->add_strings();
    1128     }
    1129 
    1130     function add_strings() {
    1131     }
    1132 
    1133     function set_result($result) {
    1134         $this->result = $result;
    1135     }
    1136 
    1137     function request_filesystem_credentials($error = false) {
    1138         $url = $this->options['url'];
    1139         $context = $this->options['context'];
    1140         if ( !empty($this->options['nonce']) )
    1141             $url = wp_nonce_url($url, $this->options['nonce']);
    1142         return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
    1143     }
    1144 
    1145     function header() {
    1146         if ( $this->done_header )
    1147             return;
    1148         $this->done_header = true;
    1149         echo '<div class="wrap">';
    1150         screen_icon();
    1151         echo '<h2>' . $this->options['title'] . '</h2>';
    1152     }
    1153     function footer() {
    1154         echo '</div>';
    1155     }
    1156 
    1157     function error($errors) {
    1158         if ( ! $this->done_header )
    1159             $this->header();
    1160         if ( is_string($errors) ) {
    1161             $this->feedback($errors);
    1162         } elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
    1163             foreach ( $errors->get_error_messages() as $message ) {
    1164                 if ( $errors->get_error_data() )
    1165                     $this->feedback($message . ' ' . esc_html( $errors->get_error_data() ) );
    1166                 else
    1167                     $this->feedback($message);
    1168             }
    1169         }
    1170     }
    1171 
    1172     function feedback($string) {
    1173         if ( isset( $this->upgrader->strings[$string] ) )
    1174             $string = $this->upgrader->strings[$string];
    1175 
    1176         if ( strpos($string, '%') !== false ) {
    1177             $args = func_get_args();
    1178             $args = array_splice($args, 1);
    1179             if ( $args ) {
    1180                 $args = array_map( 'strip_tags', $args );
    1181                 $args = array_map( 'esc_html', $args );
    1182                 $string = vsprintf($string, $args);
    1183             }
    1184         }
    1185         if ( empty($string) )
    1186             return;
    1187         show_message($string);
    1188     }
    1189     function before() {}
    1190     function after() {}
    1191 
    1192 }
    1193 
    1194 /**
    1195  * Plugin Upgrader Skin for WordPress Plugin Upgrades.
    1196  *
    1197  * @TODO More Detailed docs, for methods as well.
    1198  *
    1199  * @package WordPress
    1200  * @subpackage Upgrader
    1201  * @since 2.8.0
    1202  */
    1203 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
    1204     var $plugin = '';
    1205     var $plugin_active = false;
    1206     var $plugin_network_active = false;
    1207 
    1208     function __construct($args = array()) {
    1209         $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
    1210         $args = wp_parse_args($args, $defaults);
    1211 
    1212         $this->plugin = $args['plugin'];
    1213 
    1214         $this->plugin_active = is_plugin_active( $this->plugin );
    1215         $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
    1216 
    1217         parent::__construct($args);
    1218     }
    1219 
    1220     function after() {
    1221         $this->plugin = $this->upgrader->plugin_info();
    1222         if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
    1223             echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>';
    1224         }
    1225 
    1226         $update_actions =  array(
    1227             'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
    1228             'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
    1229         );
    1230         if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
    1231             unset( $update_actions['activate_plugin'] );
    1232 
    1233         $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin);
    1234         if ( ! empty($update_actions) )
    1235             $this->feedback(implode(' | ', (array)$update_actions));
    1236     }
    1237 
    1238     function before() {
    1239         if ( $this->upgrader->show_before ) {
    1240             echo $this->upgrader->show_before;
    1241             $this->upgrader->show_before = '';
    1242         }
    1243     }
    1244 }
    1245 
    1246 /**
    1247  * Plugin Upgrader Skin for WordPress Plugin Upgrades.
    1248  *
    1249  * @package WordPress
    1250  * @subpackage Upgrader
    1251  * @since 3.0.0
    1252  */
    1253 class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
    1254     var $in_loop = false;
    1255     var $error = false;
    1256 
    1257     function __construct($args = array()) {
    1258         $defaults = array( 'url' => '', 'nonce' => '' );
    1259         $args = wp_parse_args($args, $defaults);
    1260 
    1261         parent::__construct($args);
    1262     }
    1263 
    1264     function add_strings() {
    1265         $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
    1266         $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>');
    1267         $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
    1268         $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span>.</a>';
    1269         $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
    1270     }
    1271 
    1272     function feedback($string) {
    1273         if ( isset( $this->upgrader->strings[$string] ) )
    1274             $string = $this->upgrader->strings[$string];
    1275 
    1276         if ( strpos($string, '%') !== false ) {
    1277             $args = func_get_args();
    1278             $args = array_splice($args, 1);
    1279             if ( $args ) {
    1280                 $args = array_map( 'strip_tags', $args );
    1281                 $args = array_map( 'esc_html', $args );
    1282                 $string = vsprintf($string, $args);
    1283             }
    1284         }
    1285         if ( empty($string) )
    1286             return;
    1287         if ( $this->in_loop )
    1288             echo "$string<br />\n";
    1289         else
    1290             echo "<p>$string</p>\n";
    1291     }
    1292 
    1293     function header() {
    1294         // Nothing, This will be displayed within a iframe.
    1295     }
    1296 
    1297     function footer() {
    1298         // Nothing, This will be displayed within a iframe.
    1299     }
    1300     function error($error) {
    1301         if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
    1302             $this->error = $this->upgrader->strings[$error];
    1303 
    1304         if ( is_wp_error($error) ) {
    1305             foreach ( $error->get_error_messages() as $emessage ) {
    1306                 if ( $error->get_error_data() )
    1307                     $messages[] = $emessage . ' ' . esc_html( $error->get_error_data() );
    1308                 else
    1309                     $messages[] = $emessage;
    1310             }
    1311             $this->error = implode(', ', $messages);
    1312         }
    1313         echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
    1314     }
    1315 
    1316     function bulk_header() {
    1317         $this->feedback('skin_upgrade_start');
    1318     }
    1319 
    1320     function bulk_footer() {
    1321         $this->feedback('skin_upgrade_end');
    1322     }
    1323 
    1324     function before($title = '') {
    1325         $this->in_loop = true;
    1326         printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h4>',  $title, $this->upgrader->update_current, $this->upgrader->update_count);
    1327         echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
    1328         echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
    1329         $this->flush_output();
    1330     }
    1331 
    1332     function after($title = '') {
    1333         echo '</p></div>';
    1334         if ( $this->error || ! $this->result ) {
    1335             if ( $this->error )
    1336                 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
    1337             else
    1338                 echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
    1339 
    1340             echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
    1341         }
    1342         if ( $this->result && ! is_wp_error( $this->result ) ) {
    1343             if ( ! $this->error )
    1344                 echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>';
    1345             echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
    1346         }
    1347 
    1348         $this->reset();
    1349         $this->flush_output();
    1350     }
    1351 
    1352     function reset() {
    1353         $this->in_loop = false;
    1354         $this->error = false;
    1355     }
    1356 
    1357     function flush_output() {
    1358         wp_ob_end_flush_all();
    1359         flush();
    1360     }
    1361 }
    1362 
    1363 class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
    1364     var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
    1365 
    1366     function __construct($args = array()) {
    1367         parent::__construct($args);
    1368     }
    1369 
    1370     function add_strings() {
    1371         parent::add_strings();
    1372         $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
    1373     }
    1374 
    1375     function before($title = '') {
    1376         parent::before($this->plugin_info['Title']);
    1377     }
    1378 
    1379     function after($title = '') {
    1380         parent::after($this->plugin_info['Title']);
    1381     }
    1382     function bulk_footer() {
    1383         parent::bulk_footer();
    1384         $update_actions =  array(
    1385             'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
    1386             'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
    1387         );
    1388         if ( ! current_user_can( 'activate_plugins' ) )
    1389             unset( $update_actions['plugins_page'] );
    1390 
    1391         $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
    1392         if ( ! empty($update_actions) )
    1393             $this->feedback(implode(' | ', (array)$update_actions));
    1394     }
    1395 }
    1396 
    1397 class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
    1398     var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
    1399 
    1400     function __construct($args = array()) {
    1401         parent::__construct($args);
    1402     }
    1403 
    1404     function add_strings() {
    1405         parent::add_strings();
    1406         $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
    1407     }
    1408 
    1409     function before($title = '') {
    1410         parent::before( $this->theme_info->display('Name') );
    1411     }
    1412 
    1413     function after($title = '') {
    1414         parent::after( $this->theme_info->display('Name') );
    1415     }
    1416 
    1417     function bulk_footer() {
    1418         parent::bulk_footer();
    1419         $update_actions =  array(
    1420             'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
    1421             'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
    1422         );
    1423         if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
    1424             unset( $update_actions['themes_page'] );
    1425 
    1426         $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
    1427         if ( ! empty($update_actions) )
    1428             $this->feedback(implode(' | ', (array)$update_actions));
    1429     }
    1430 }
    1431 
    1432 /**
    1433  * Plugin Installer Skin for WordPress Plugin Installer.
    1434  *
    1435  * @TODO More Detailed docs, for methods as well.
    1436  *
    1437  * @package WordPress
    1438  * @subpackage Upgrader
    1439  * @since 2.8.0
    1440  */
    1441 class Plugin_Installer_Skin extends WP_Upgrader_Skin {
    1442     var $api;
    1443     var $type;
    1444 
    1445     function __construct($args = array()) {
    1446         $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
    1447         $args = wp_parse_args($args, $defaults);
    1448 
    1449         $this->type = $args['type'];
    1450         $this->api = isset($args['api']) ? $args['api'] : array();
    1451 
    1452         parent::__construct($args);
    1453     }
    1454 
    1455     function before() {
    1456         if ( !empty($this->api) )
    1457             $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
    1458     }
    1459 
    1460     function after() {
    1461 
    1462         $plugin_file = $this->upgrader->plugin_info();
    1463 
    1464         $install_actions = array();
    1465 
    1466         $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
    1467 
    1468         if ( 'import' == $from )
    1469             $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin &amp; Run Importer') . '</a>';
    1470         else
    1471             $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
    1472 
    1473         if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
    1474             $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
    1475             unset( $install_actions['activate_plugin'] );
    1476         }
    1477 
    1478         if ( 'import' == $from )
    1479             $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
    1480         else if ( $this->type == 'web' )
    1481             $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
    1482         else
    1483             $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>';
    1484 
    1485         if ( ! $this->result || is_wp_error($this->result) ) {
    1486             unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
    1487         } elseif ( ! current_user_can( 'activate_plugins' ) ) {
    1488             unset( $install_actions['activate_plugin'] );
    1489         }
    1490 
    1491         $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
    1492         if ( ! empty($install_actions) )
    1493             $this->feedback(implode(' | ', (array)$install_actions));
    1494     }
    1495 }
    1496 
    1497 /**
    1498  * Theme Installer Skin for the WordPress Theme Installer.
    1499  *
    1500  * @TODO More Detailed docs, for methods as well.
    1501  *
    1502  * @package WordPress
    1503  * @subpackage Upgrader
    1504  * @since 2.8.0
    1505  */
    1506 class Theme_Installer_Skin extends WP_Upgrader_Skin {
    1507     var $api;
    1508     var $type;
    1509 
    1510     function __construct($args = array()) {
    1511         $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
    1512         $args = wp_parse_args($args, $defaults);
    1513 
    1514         $this->type = $args['type'];
    1515         $this->api = isset($args['api']) ? $args['api'] : array();
    1516 
    1517         parent::__construct($args);
    1518     }
    1519 
    1520     function before() {
    1521         if ( !empty($this->api) )
    1522             $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
    1523     }
    1524 
    1525     function after() {
    1526         if ( empty($this->upgrader->result['destination_name']) )
    1527             return;
    1528 
    1529         $theme_info = $this->upgrader->theme_info();
    1530         if ( empty( $theme_info ) )
    1531             return;
    1532 
    1533         $name       = $theme_info->display('Name');
    1534         $stylesheet = $this->upgrader->result['destination_name'];
    1535         $template   = $theme_info->get_template();
    1536 
    1537         $preview_link = add_query_arg( array(
    1538             'preview'    => 1,
    1539             'template'   => urlencode( $template ),
    1540             'stylesheet' => urlencode( $stylesheet ),
    1541         ), trailingslashit( home_url() ) );
    1542 
    1543         $activate_link = add_query_arg( array(
    1544             'action'     => 'activate',
    1545             'template'   => urlencode( $template ),
    1546             'stylesheet' => urlencode( $stylesheet ),
    1547         ), admin_url('themes.php') );
    1548         $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
    1549 
    1550         $install_actions = array();
    1551         $install_actions['preview']  = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
    1552         $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Live Preview') . '</a>';
    1553         $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
    1554 
    1555         if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
    1556             $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
    1557 
    1558         if ( $this->type == 'web' )
    1559             $install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
    1560         elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
    1561             $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
    1562 
    1563         if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
    1564             unset( $install_actions['activate'], $install_actions['preview'] );
    1565 
    1566         $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
    1567         if ( ! empty($install_actions) )
    1568             $this->feedback(implode(' | ', (array)$install_actions));
    1569     }
    1570 }
    1571 
    1572 /**
    1573  * Theme Upgrader Skin for WordPress Theme Upgrades.
    1574  *
    1575  * @TODO More Detailed docs, for methods as well.
    1576  *
    1577  * @package WordPress
    1578  * @subpackage Upgrader
    1579  * @since 2.8.0
    1580  */
    1581 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
    1582     var $theme = '';
    1583 
    1584     function __construct($args = array()) {
    1585         $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
    1586         $args = wp_parse_args($args, $defaults);
    1587 
    1588         $this->theme = $args['theme'];
    1589 
    1590         parent::__construct($args);
    1591     }
    1592 
    1593     function after() {
    1594 
    1595         $update_actions = array();
    1596         if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
    1597             $name       = $theme_info->display('Name');
    1598             $stylesheet = $this->upgrader->result['destination_name'];
    1599             $template   = $theme_info->get_template();
    1600 
    1601             $preview_link = add_query_arg( array(
    1602                 'preview'    => 1,
    1603                 'template'   => urlencode( $template ),
    1604                 'stylesheet' => urlencode( $stylesheet ),
    1605             ), trailingslashit( home_url() ) );
    1606 
    1607             $activate_link = add_query_arg( array(
    1608                 'action'     => 'activate',
    1609                 'template'   => urlencode( $template ),
    1610                 'stylesheet' => urlencode( $stylesheet ),
    1611             ), admin_url('themes.php') );
    1612             $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
    1613 
    1614             if ( get_stylesheet() == $stylesheet ) {
    1615                 if ( current_user_can( 'edit_theme_options' ) )
    1616                     $update_actions['preview']  = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize &#8220;%s&#8221;'), $name ) ) . '">' . __('Customize') . '</a>';
    1617             } elseif ( current_user_can( 'switch_themes' ) ) {
    1618                 $update_actions['preview']  = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Preview') . '</a>';
    1619                 $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview &#8220;%s&#8221;'), $name ) ) . '">' . __('Live Preview') . '</a>';
    1620                 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
    1621             }
    1622 
    1623             if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
    1624                 unset( $update_actions['preview'], $update_actions['activate'] );
    1625         }
    1626 
    1627         $update_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
    1628 
    1629         $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
    1630         if ( ! empty($update_actions) )
    1631             $this->feedback(implode(' | ', (array)$update_actions));
    1632     }
    1633 }
    1634 
    1635 /**
    16361099 * Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if it's a local file to the Upgrade/Installer functions.
    1637  *
    1638  * @TODO More Detailed docs, for methods as well.
    16391100 *
    16401101 * @package WordPress
Note: See TracChangeset for help on using the changeset viewer.