You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

72 rivejä
2.5 KiB

  1. <?php
  2. /**
  3. * Upgrader API: Plugin_Upgrader_Skin class
  4. *
  5. * @package WordPress
  6. * @subpackage Upgrader
  7. * @since 4.6.0
  8. */
  9. /**
  10. * Plugin Upgrader Skin for WordPress Plugin Upgrades.
  11. *
  12. * @since 2.8.0
  13. * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
  14. *
  15. * @see WP_Upgrader_Skin
  16. */
  17. class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
  18. public $plugin = '';
  19. public $plugin_active = false;
  20. public $plugin_network_active = false;
  21. /**
  22. *
  23. * @param array $args
  24. */
  25. public function __construct( $args = array() ) {
  26. $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
  27. $args = wp_parse_args($args, $defaults);
  28. $this->plugin = $args['plugin'];
  29. $this->plugin_active = is_plugin_active( $this->plugin );
  30. $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
  31. parent::__construct($args);
  32. }
  33. /**
  34. * @access public
  35. */
  36. public function after() {
  37. $this->plugin = $this->upgrader->plugin_info();
  38. if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
  39. // Currently used only when JS is off for a single plugin update?
  40. echo '<iframe title="' . esc_attr__( 'Update progress' ) . '" style="border:0;overflow:hidden" width="100%" height="170" src="' . wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '"></iframe>';
  41. }
  42. $this->decrement_update_count( 'plugin' );
  43. $update_actions = array(
  44. 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
  45. 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>'
  46. );
  47. if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
  48. unset( $update_actions['activate_plugin'] );
  49. /**
  50. * Filters the list of action links available following a single plugin update.
  51. *
  52. * @since 2.7.0
  53. *
  54. * @param array $update_actions Array of plugin action links.
  55. * @param string $plugin Path to the plugin file.
  56. */
  57. $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
  58. if ( ! empty($update_actions) )
  59. $this->feedback(implode(' | ', (array)$update_actions));
  60. }
  61. }