494 foreach ( $plugins as $plugin ) { |
494 foreach ( $plugins as $plugin ) { |
495 $this->update_current++; |
495 $this->update_current++; |
496 $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); |
496 $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); |
497 |
497 |
498 if ( !isset( $current->response[ $plugin ] ) ) { |
498 if ( !isset( $current->response[ $plugin ] ) ) { |
499 $this->skin->set_result(false); |
499 $this->skin->set_result(true); |
500 $this->skin->before(); |
500 $this->skin->before(); |
501 $this->skin->error('up_to_date'); |
501 $this->skin->feedback('up_to_date'); |
502 $this->skin->after(); |
502 $this->skin->after(); |
503 $results[$plugin] = false; |
503 $results[$plugin] = true; |
504 continue; |
504 continue; |
505 } |
505 } |
506 |
506 |
507 // Get the URL to the zip file |
507 // Get the URL to the zip file |
508 $r = $current->response[ $plugin ]; |
508 $r = $current->response[ $plugin ]; |
761 |
761 |
762 if ( ! $this->result || is_wp_error($this->result) ) |
762 if ( ! $this->result || is_wp_error($this->result) ) |
763 return $this->result; |
763 return $this->result; |
764 |
764 |
765 // Force refresh of theme update information |
765 // Force refresh of theme update information |
766 delete_site_transient('update_themes'); |
766 wp_clean_themes_cache(); |
767 search_theme_directories( true ); |
|
768 foreach ( wp_get_themes() as $theme ) |
|
769 $theme->cache_delete(); |
|
770 |
767 |
771 return true; |
768 return true; |
772 } |
769 } |
773 |
770 |
774 function upgrade($theme) { |
771 function upgrade($theme) { |
810 |
807 |
811 if ( ! $this->result || is_wp_error($this->result) ) |
808 if ( ! $this->result || is_wp_error($this->result) ) |
812 return $this->result; |
809 return $this->result; |
813 |
810 |
814 // Force refresh of theme update information |
811 // Force refresh of theme update information |
815 delete_site_transient('update_themes'); |
812 wp_clean_themes_cache(); |
816 search_theme_directories( true ); |
|
817 foreach ( wp_get_themes() as $theme ) |
|
818 $theme->cache_delete(); |
|
819 |
813 |
820 return true; |
814 return true; |
821 } |
815 } |
822 |
816 |
823 function bulk_upgrade($themes) { |
817 function bulk_upgrade($themes) { |
855 $this->update_count = count($themes); |
849 $this->update_count = count($themes); |
856 $this->update_current = 0; |
850 $this->update_current = 0; |
857 foreach ( $themes as $theme ) { |
851 foreach ( $themes as $theme ) { |
858 $this->update_current++; |
852 $this->update_current++; |
859 |
853 |
|
854 $this->skin->theme_info = $this->theme_info($theme); |
|
855 |
860 if ( !isset( $current->response[ $theme ] ) ) { |
856 if ( !isset( $current->response[ $theme ] ) ) { |
861 $this->skin->set_result(false); |
857 $this->skin->set_result(true); |
862 $this->skin->before(); |
858 $this->skin->before(); |
863 $this->skin->error('up_to_date'); |
859 $this->skin->feedback('up_to_date'); |
864 $this->skin->after(); |
860 $this->skin->after(); |
865 $results[$theme] = false; |
861 $results[$theme] = true; |
866 continue; |
862 continue; |
867 } |
863 } |
868 |
|
869 $this->skin->theme_info = $this->theme_info($theme); |
|
870 |
864 |
871 // Get the URL to the zip file |
865 // Get the URL to the zip file |
872 $r = $current->response[ $theme ]; |
866 $r = $current->response[ $theme ]; |
873 |
867 |
874 $options = array( |
868 $options = array( |
900 remove_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); |
894 remove_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); |
901 remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); |
895 remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); |
902 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); |
896 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); |
903 |
897 |
904 // Force refresh of theme update information |
898 // Force refresh of theme update information |
905 delete_site_transient('update_themes'); |
899 wp_clean_themes_cache(); |
906 search_theme_directories( true ); |
|
907 foreach ( wp_get_themes() as $theme ) |
|
908 $theme->cache_delete(); |
|
909 |
900 |
910 return $results; |
901 return $results; |
911 } |
902 } |
912 |
903 |
913 function check_package($source) { |
904 function check_package($source) { |
960 $theme = isset($theme['theme']) ? $theme['theme'] : ''; |
951 $theme = isset($theme['theme']) ? $theme['theme'] : ''; |
961 |
952 |
962 if ( $theme != get_stylesheet() ) // If not current |
953 if ( $theme != get_stylesheet() ) // If not current |
963 return $return; |
954 return $return; |
964 |
955 |
965 // Ensure stylesheet name hasnt changed after the upgrade: |
956 // Ensure stylesheet name hasn't changed after the upgrade: |
966 // @TODO: Note, This doesn't handle the Template changing, or the Template name changing. |
|
967 if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) { |
957 if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) { |
968 $theme_info = $this->theme_info(); |
958 wp_clean_themes_cache(); |
969 $stylesheet = $this->result['destination_name']; |
959 $stylesheet = $this->result['destination_name']; |
970 $template = $theme_info->get_template(); |
960 switch_theme( $stylesheet ); |
971 switch_theme($template, $stylesheet, true); |
|
972 } |
961 } |
973 |
962 |
974 //Time to remove maintenance mode |
963 //Time to remove maintenance mode |
975 if ( ! $this->bulk ) |
964 if ( ! $this->bulk ) |
976 $this->maintenance_mode(false); |
965 $this->maintenance_mode(false); |
1204 |
1193 |
1205 $update_actions = array( |
1194 $update_actions = array( |
1206 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', |
1195 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>', |
1207 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>' |
1196 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>' |
1208 ); |
1197 ); |
1209 if ( $this->plugin_active ) |
1198 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) ) |
1210 unset( $update_actions['activate_plugin'] ); |
|
1211 if ( ! $this->result || is_wp_error($this->result) ) |
|
1212 unset( $update_actions['activate_plugin'] ); |
1199 unset( $update_actions['activate_plugin'] ); |
1213 |
1200 |
1214 $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); |
1201 $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); |
1215 if ( ! empty($update_actions) ) |
1202 if ( ! empty($update_actions) ) |
1216 $this->feedback(implode(' | ', (array)$update_actions)); |
1203 $this->feedback(implode(' | ', (array)$update_actions)); |
1299 $this->feedback('skin_upgrade_end'); |
1286 $this->feedback('skin_upgrade_end'); |
1300 } |
1287 } |
1301 |
1288 |
1302 function before($title = '') { |
1289 function before($title = '') { |
1303 $this->in_loop = true; |
1290 $this->in_loop = true; |
1304 printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <img alt="" src="' . admin_url( 'images/wpspin_light.gif' ) . '" class="hidden waiting-' . $this->upgrader->update_current . '" style="vertical-align:middle;" /></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count); |
1291 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); |
1305 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; |
1292 echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>'; |
1306 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>'; |
1293 echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>'; |
1307 $this->flush_output(); |
1294 $this->flush_output(); |
1308 } |
1295 } |
1309 |
1296 |
1310 function after($title = '') { |
1297 function after($title = '') { |
1360 parent::bulk_footer(); |
1347 parent::bulk_footer(); |
1361 $update_actions = array( |
1348 $update_actions = array( |
1362 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>', |
1349 'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>', |
1363 '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>' |
1350 '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>' |
1364 ); |
1351 ); |
|
1352 if ( ! current_user_can( 'activate_plugins' ) ) |
|
1353 unset( $update_actions['plugins_page'] ); |
1365 |
1354 |
1366 $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); |
1355 $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); |
1367 if ( ! empty($update_actions) ) |
1356 if ( ! empty($update_actions) ) |
1368 $this->feedback(implode(' | ', (array)$update_actions)); |
1357 $this->feedback(implode(' | ', (array)$update_actions)); |
1369 } |
1358 } |
1393 parent::bulk_footer(); |
1382 parent::bulk_footer(); |
1394 $update_actions = array( |
1383 $update_actions = array( |
1395 'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>', |
1384 'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>', |
1396 '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>' |
1385 '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>' |
1397 ); |
1386 ); |
|
1387 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) |
|
1388 unset( $update_actions['themes_page'] ); |
1398 |
1389 |
1399 $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info ); |
1390 $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info ); |
1400 if ( ! empty($update_actions) ) |
1391 if ( ! empty($update_actions) ) |
1401 $this->feedback(implode(' | ', (array)$update_actions)); |
1392 $this->feedback(implode(' | ', (array)$update_actions)); |
1402 } |
1393 } |
1454 $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>'; |
1445 $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>'; |
1455 else |
1446 else |
1456 $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>'; |
1447 $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>'; |
1457 |
1448 |
1458 if ( ! $this->result || is_wp_error($this->result) ) { |
1449 if ( ! $this->result || is_wp_error($this->result) ) { |
|
1450 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] ); |
|
1451 } elseif ( ! current_user_can( 'activate_plugins' ) ) { |
1459 unset( $install_actions['activate_plugin'] ); |
1452 unset( $install_actions['activate_plugin'] ); |
1460 unset( $install_actions['network_activate'] ); |
1453 } |
1461 } |
1454 |
1462 $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); |
1455 $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file); |
1463 if ( ! empty($install_actions) ) |
1456 if ( ! empty($install_actions) ) |
1464 $this->feedback(implode(' | ', (array)$install_actions)); |
1457 $this->feedback(implode(' | ', (array)$install_actions)); |
1465 } |
1458 } |
1466 } |
1459 } |
1507 |
1500 |
1508 $preview_link = add_query_arg( array( |
1501 $preview_link = add_query_arg( array( |
1509 'preview' => 1, |
1502 'preview' => 1, |
1510 'template' => urlencode( $template ), |
1503 'template' => urlencode( $template ), |
1511 'stylesheet' => urlencode( $stylesheet ), |
1504 'stylesheet' => urlencode( $stylesheet ), |
1512 ), trailingslashit( get_home_url() ) ); |
1505 ), trailingslashit( home_url() ) ); |
1513 |
1506 |
1514 $activate_link = add_query_arg( array( |
1507 $activate_link = add_query_arg( array( |
1515 'action' => 'activate', |
1508 'action' => 'activate', |
1516 'template' => urlencode( $template ), |
1509 'template' => urlencode( $template ), |
1517 'stylesheet' => urlencode( $stylesheet ), |
1510 'stylesheet' => urlencode( $stylesheet ), |
1522 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; |
1515 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; |
1523 $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>'; |
1516 $install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>'; |
1524 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; |
1517 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; |
1525 |
1518 |
1526 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) |
1519 if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) |
1527 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
1520 $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
1528 |
1521 |
1529 if ( $this->type == 'web' ) |
1522 if ( $this->type == 'web' ) |
1530 $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>'; |
1523 $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>'; |
1531 else |
1524 elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) |
1532 $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>'; |
1525 $install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>'; |
1533 |
1526 |
1534 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() ) |
1527 if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) |
1535 unset( $install_actions['activate'], $install_actions['preview'] ); |
1528 unset( $install_actions['activate'], $install_actions['preview'] ); |
1536 |
1529 |
1537 $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info); |
1530 $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info); |
1538 if ( ! empty($install_actions) ) |
1531 if ( ! empty($install_actions) ) |
1539 $this->feedback(implode(' | ', (array)$install_actions)); |
1532 $this->feedback(implode(' | ', (array)$install_actions)); |
1571 |
1564 |
1572 $preview_link = add_query_arg( array( |
1565 $preview_link = add_query_arg( array( |
1573 'preview' => 1, |
1566 'preview' => 1, |
1574 'template' => urlencode( $template ), |
1567 'template' => urlencode( $template ), |
1575 'stylesheet' => urlencode( $stylesheet ), |
1568 'stylesheet' => urlencode( $stylesheet ), |
1576 ), trailingslashit( get_home_url() ) ); |
1569 ), trailingslashit( home_url() ) ); |
1577 |
1570 |
1578 $activate_link = add_query_arg( array( |
1571 $activate_link = add_query_arg( array( |
1579 'action' => 'activate', |
1572 'action' => 'activate', |
1580 'template' => urlencode( $template ), |
1573 'template' => urlencode( $template ), |
1581 'stylesheet' => urlencode( $stylesheet ), |
1574 'stylesheet' => urlencode( $stylesheet ), |
1582 ), admin_url('themes.php') ); |
1575 ), admin_url('themes.php') ); |
1583 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
1576 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
1584 |
1577 |
1585 if ( get_stylesheet() == $stylesheet ) { |
1578 if ( get_stylesheet() == $stylesheet ) { |
1586 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>'; |
1579 if ( current_user_can( 'edit_theme_options' ) ) |
1587 } else { |
1580 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>'; |
|
1581 } elseif ( current_user_can( 'switch_themes' ) ) { |
1588 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; |
1582 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; |
1589 $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>'; |
1583 $update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>'; |
1590 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; |
1584 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; |
1591 } |
1585 } |
1592 |
1586 |