~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-admin/includes/class-wp-upgrader.php

  • Committer: Andrew Glen-Young
  • Date: 2011-03-08 14:47:51 UTC
  • Revision ID: andrew.glen-young@canonical.com-20110308144751-1n6spqgayztf9h77
[AGY] import 3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
368
368
 
369
369
        function upgrade_strings() {
370
370
                $this->strings['up_to_date'] = __('The plugin is at the latest version.');
371
 
                $this->strings['no_package'] = __('Upgrade package not available.');
 
371
                $this->strings['no_package'] = __('Update package not available.');
372
372
                $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
373
373
                $this->strings['unpack_package'] = __('Unpacking the update&#8230;');
374
374
                $this->strings['deactivate_plugin'] = __('Deactivating the plugin&#8230;');
375
375
                $this->strings['remove_old'] = __('Removing the old version of the plugin&#8230;');
376
376
                $this->strings['remove_old_failed'] = __('Could not remove the old plugin.');
377
 
                $this->strings['process_failed'] = __('Plugin upgrade failed.');
378
 
                $this->strings['process_success'] = __('Plugin upgraded successfully.');
 
377
                $this->strings['process_failed'] = __('Plugin update failed.');
 
378
                $this->strings['process_success'] = __('Plugin updated successfully.');
379
379
        }
380
380
 
381
381
        function install_strings() {
468
468
 
469
469
                $this->skin->bulk_header();
470
470
 
471
 
                $this->maintenance_mode(true);
 
471
                // Only start maintenance mode if running in Multisite OR the plugin is in use
 
472
                $maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible.
 
473
                foreach ( $plugins as $plugin )
 
474
                        $maintenance = $maintenance || (is_plugin_active($plugin) && isset($current->response[ $plugin ]) ); // Only activate Maintenance mode if a plugin is active AND has an update available
 
475
                if ( $maintenance )
 
476
                        $this->maintenance_mode(true);
472
477
 
473
478
                $results = array();
474
479
 
603
608
 
604
609
        function upgrade_strings() {
605
610
                $this->strings['up_to_date'] = __('The theme is at the latest version.');
606
 
                $this->strings['no_package'] = __('Upgrade package not available.');
 
611
                $this->strings['no_package'] = __('Update package not available.');
607
612
                $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
608
613
                $this->strings['unpack_package'] = __('Unpacking the update&#8230;');
609
614
                $this->strings['remove_old'] = __('Removing the old version of the theme&#8230;');
610
615
                $this->strings['remove_old_failed'] = __('Could not remove the old theme.');
611
 
                $this->strings['process_failed'] = __('Theme upgrade failed.');
612
 
                $this->strings['process_success'] = __('Theme upgraded successfully.');
 
616
                $this->strings['process_failed'] = __('Theme update failed.');
 
617
                $this->strings['process_success'] = __('Theme updated successfully.');
613
618
        }
614
619
 
615
620
        function install_strings() {
712
717
 
713
718
                $this->skin->bulk_header();
714
719
 
715
 
                $this->maintenance_mode(true);
 
720
                // Only start maintenance mode if running in Multisite OR the theme is in use
 
721
                $maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible.
 
722
                foreach ( $themes as $theme )
 
723
                        $maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
 
724
                if ( $maintenance )
 
725
                        $this->maintenance_mode(true);
716
726
 
717
727
                $results = array();
718
728
 
780
790
 
781
791
                if ( $theme != get_stylesheet() ) //If not current
782
792
                        return $return;
783
 
                //Change to maintainence mode now.
 
793
                //Change to maintenance mode now.
784
794
                if ( ! $this->bulk )
785
795
                        $this->maintenance_mode(true);
786
796
 
796
806
                        return $return;
797
807
 
798
808
                //Ensure stylesheet name hasnt changed after the upgrade:
 
809
                // @TODO: Note, This doesnt handle the Template changing, or the Template name changing.
799
810
                if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
800
811
                        $theme_info = $this->theme_info();
801
812
                        $stylesheet = $this->result['destination_name'];
803
814
                        switch_theme($template, $stylesheet, true);
804
815
                }
805
816
 
806
 
                //Time to remove maintainence mode
 
817
                //Time to remove maintenance mode
807
818
                if ( ! $this->bulk )
808
819
                        $this->maintenance_mode(false);
809
820
                return $return;
850
861
 
851
862
        function upgrade_strings() {
852
863
                $this->strings['up_to_date'] = __('WordPress is at the latest version.');
853
 
                $this->strings['no_package'] = __('Upgrade package not available.');
 
864
                $this->strings['no_package'] = __('Update package not available.');
854
865
                $this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
855
866
                $this->strings['unpack_package'] = __('Unpacking the update&#8230;');
856
867
                $this->strings['copy_failed'] = __('Could not copy files.');
1006
1017
        }
1007
1018
 
1008
1019
        function __construct($args = array()) {
1009
 
                $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Upgrade Plugin') );
 
1020
                $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
1010
1021
                $args = wp_parse_args($args, $defaults);
1011
1022
 
1012
1023
                $this->plugin = $args['plugin'];
1026
1037
 
1027
1038
                $update_actions =  array(
1028
1039
                        'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
1029
 
                        'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
 
1040
                        'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
1030
1041
                );
1031
1042
                if ( $this->plugin_active )
1032
1043
                        unset( $update_actions['activate_plugin'] );
1035
1046
 
1036
1047
                $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin);
1037
1048
                if ( ! empty($update_actions) )
1038
 
                        $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
 
1049
                        $this->feedback(implode(' | ', (array)$update_actions));
1039
1050
        }
1040
1051
 
1041
1052
        function before() {
1069
1080
        }
1070
1081
 
1071
1082
        function add_strings() {
1072
 
                $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take awhile on some hosts, so please be patient.');
1073
 
                $this->upgrader->strings['skin_update_failed_error'] = __('An error occured while updating %1$s: <strong>%2$s</strong>.');
 
1083
                $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
 
1084
                $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>.');
1074
1085
                $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
1075
1086
                $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>';
1076
1087
                $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
1184
1195
        function bulk_footer() {
1185
1196
                parent::bulk_footer();
1186
1197
                $update_actions =  array(
1187
 
                        'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
1188
 
                        'updates_page' => '<a href="' . admin_url('update-core.php') . '" title="' . esc_attr__('Goto WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
 
1198
                        'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
 
1199
                        '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>'
1189
1200
                );
1190
1201
 
1191
1202
                $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
1192
1203
                if ( ! empty($update_actions) )
1193
 
                        $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
 
1204
                        $this->feedback(implode(' | ', (array)$update_actions));
1194
1205
        }
1195
1206
}
1196
1207
 
1215
1226
        function bulk_footer() {
1216
1227
                parent::bulk_footer();
1217
1228
                $update_actions =  array(
1218
 
                        'themes_page' => '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Goto themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
1219
 
                        'updates_page' => '<a href="' . admin_url('update-core.php') . '" title="' . esc_attr__('Goto WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
 
1229
                        'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
 
1230
                        '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>'
1220
1231
                );
1221
1232
 
1222
1233
                $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info);
1223
1234
                if ( ! empty($update_actions) )
1224
 
                        $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
 
1235
                        $this->feedback(implode(' | ', (array)$update_actions));
1225
1236
        }
1226
1237
}
1227
1238
 
1270
1281
                else
1271
1282
                        $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
1272
1283
 
1273
 
                if ( is_multisite() && current_user_can( 'manage_network_plugins' ) )
1274
 
                        $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
 
1284
                if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
 
1285
                        $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
 
1286
                        unset( $install_actions['activate_plugin'] );
 
1287
                }
1275
1288
 
1276
1289
                if ( 'import' == $from )
1277
1290
                        $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
1278
1291
                else if ( $this->type == 'web' )
1279
 
                        $install_actions['plugins_page'] = '<a href="' . admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
 
1292
                        $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>';
1280
1293
                else
1281
 
                        $install_actions['plugins_page'] = '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>';
 
1294
                        $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>';
1282
1295
 
1283
1296
 
1284
1297
                if ( ! $this->result || is_wp_error($this->result) ) {
1287
1300
                }
1288
1301
                $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
1289
1302
                if ( ! empty($install_actions) )
1290
 
                        $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$install_actions));
 
1303
                        $this->feedback(implode(' | ', (array)$install_actions));
1291
1304
        }
1292
1305
}
1293
1306
 
1345
1358
                                                        );
1346
1359
 
1347
1360
                if ( $this->type == 'web' )
1348
 
                        $install_actions['themes_page'] = '<a href="' . admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
 
1361
                        $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>';
1349
1362
                else
1350
 
                        $install_actions['themes_page'] = '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
 
1363
                        $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
1351
1364
 
1352
 
                if ( ! $this->result || is_wp_error($this->result) )
 
1365
                if ( ! $this->result || is_wp_error($this->result) || is_network_admin() )
1353
1366
                        unset( $install_actions['activate'], $install_actions['preview'] );
1354
1367
 
1355
1368
                $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
1356
1369
                if ( ! empty($install_actions) )
1357
 
                        $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$install_actions));
 
1370
                        $this->feedback(implode(' | ', (array)$install_actions));
1358
1371
        }
1359
1372
}
1360
1373
 
1375
1388
        }
1376
1389
 
1377
1390
        function __construct($args = array()) {
1378
 
                $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Upgrade Theme') );
 
1391
                $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
1379
1392
                $args = wp_parse_args($args, $defaults);
1380
1393
 
1381
1394
                $this->theme = $args['theme'];
1404
1417
                                unset($update_actions['preview'], $update_actions['activate']);
1405
1418
                }
1406
1419
 
1407
 
                $update_actions['themes_page'] = '<a href="' . admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
 
1420
                $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>';
1408
1421
 
1409
1422
                $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
1410
1423
                if ( ! empty($update_actions) )
1411
 
                        $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
 
1424
                        $this->feedback(implode(' | ', (array)$update_actions));
1412
1425
        }
1413
1426
}
1414
1427
 
1452
1465
                        $this->package = $uploads['basedir'] . '/' . $this->filename;
1453
1466
                }
1454
1467
        }
1455
 
}
 
1468
}
 
 
b'\\ No newline at end of file'