@@ -949,7 +949,8 @@ discard block |
||
| 949 | 949 | if ( ! $automatic ) { |
| 950 | 950 | // Make sure message doesn't display again if bulk activation is performed |
| 951 | 951 | // immediately after a single activation. |
| 952 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
| 952 | + if ( ! isset( $_POST['action'] ) ) { |
|
| 953 | +// WPCS: CSRF OK. |
|
| 953 | 954 | echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
| 954 | 955 | } |
| 955 | 956 | } else { |
@@ -970,7 +971,8 @@ discard block |
||
| 970 | 971 | if ( ! $automatic ) { |
| 971 | 972 | // Make sure message doesn't display again if bulk activation is performed |
| 972 | 973 | // immediately after a single activation. |
| 973 | - if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
|
| 974 | + if ( ! isset( $_POST['action'] ) ) { |
|
| 975 | +// WPCS: CSRF OK. |
|
| 974 | 976 | echo '<div id="message" class="error"><p>', |
| 975 | 977 | sprintf( |
| 976 | 978 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
@@ -1621,10 +1623,12 @@ discard block |
||
| 1621 | 1623 | if ( 'update-core' === $screen->base ) { |
| 1622 | 1624 | // Core update screen. |
| 1623 | 1625 | return true; |
| 1624 | - } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok. |
|
| 1626 | + } elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { |
|
| 1627 | +// WPCS: CSRF ok. |
|
| 1625 | 1628 | // Plugins bulk update screen. |
| 1626 | 1629 | return true; |
| 1627 | - } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok. |
|
| 1630 | + } elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { |
|
| 1631 | +// WPCS: CSRF ok. |
|
| 1628 | 1632 | // Individual updates (ajax call). |
| 1629 | 1633 | return true; |
| 1630 | 1634 | } |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | * @param array $args Arguments to pass for use within the class. |
| 66 | 66 | */ |
| 67 | 67 | public function __construct( $args = array() ) { |
| 68 | - // Get TGMPA class instance. |
|
| 69 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 70 | - |
|
| 71 | - // Parse default and new args. |
|
| 72 | - $defaults = array( |
|
| 73 | - 'url' => '', |
|
| 74 | - 'nonce' => '', |
|
| 75 | - 'names' => array(), |
|
| 76 | - 'install_type' => 'install', |
|
| 77 | - ); |
|
| 78 | - $args = wp_parse_args( $args, $defaults ); |
|
| 79 | - |
|
| 80 | - // Set plugin names to $this->plugin_names property. |
|
| 81 | - $this->plugin_names = $args['names']; |
|
| 82 | - |
|
| 83 | - // Extract the new args. |
|
| 84 | - parent::__construct( $args ); |
|
| 68 | + // Get TGMPA class instance. |
|
| 69 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 70 | + |
|
| 71 | + // Parse default and new args. |
|
| 72 | + $defaults = array( |
|
| 73 | + 'url' => '', |
|
| 74 | + 'nonce' => '', |
|
| 75 | + 'names' => array(), |
|
| 76 | + 'install_type' => 'install', |
|
| 77 | + ); |
|
| 78 | + $args = wp_parse_args( $args, $defaults ); |
|
| 79 | + |
|
| 80 | + // Set plugin names to $this->plugin_names property. |
|
| 81 | + $this->plugin_names = $args['names']; |
|
| 82 | + |
|
| 83 | + // Extract the new args. |
|
| 84 | + parent::__construct( $args ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -93,39 +93,39 @@ discard block |
||
| 93 | 93 | * @since 2.2.0 |
| 94 | 94 | */ |
| 95 | 95 | public function add_strings() { |
| 96 | - if ( 'update' === $this->options['install_type'] ) { |
|
| 97 | - parent::add_strings(); |
|
| 98 | - /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 99 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 100 | - } else { |
|
| 101 | - /* translators: 1: plugin name, 2: error message. */ |
|
| 102 | - $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
| 103 | - /* translators: 1: plugin name. */ |
|
| 104 | - $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
| 105 | - |
|
| 106 | - if ( $this->tgmpa->is_automatic ) { |
|
| 107 | - // Automatic activation strings. |
|
| 108 | - $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); |
|
| 109 | - /* translators: 1: plugin name. */ |
|
| 110 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ); |
|
| 111 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
| 112 | - /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 113 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 114 | - } else { |
|
| 115 | - // Default installation strings. |
|
| 116 | - $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); |
|
| 117 | - /* translators: 1: plugin name. */ |
|
| 118 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ); |
|
| 119 | - $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
| 120 | - /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 121 | - $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // Add "read more" link only for WP < 4.8. |
|
| 125 | - if ( version_compare( $this->tgmpa->wp_version, '4.8', '<' ) ) { |
|
| 126 | - $this->upgrader->strings['skin_update_successful'] .= ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>'; |
|
| 127 | - } |
|
| 128 | - } |
|
| 96 | + if ( 'update' === $this->options['install_type'] ) { |
|
| 97 | + parent::add_strings(); |
|
| 98 | + /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 99 | + $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 100 | + } else { |
|
| 101 | + /* translators: 1: plugin name, 2: error message. */ |
|
| 102 | + $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' ); |
|
| 103 | + /* translators: 1: plugin name. */ |
|
| 104 | + $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); |
|
| 105 | + |
|
| 106 | + if ( $this->tgmpa->is_automatic ) { |
|
| 107 | + // Automatic activation strings. |
|
| 108 | + $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); |
|
| 109 | + /* translators: 1: plugin name. */ |
|
| 110 | + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ); |
|
| 111 | + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); |
|
| 112 | + /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 113 | + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 114 | + } else { |
|
| 115 | + // Default installation strings. |
|
| 116 | + $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); |
|
| 117 | + /* translators: 1: plugin name. */ |
|
| 118 | + $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed successfully.', 'tgmpa' ); |
|
| 119 | + $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); |
|
| 120 | + /* translators: 1: plugin name, 2: action number 3: total number of actions. */ |
|
| 121 | + $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // Add "read more" link only for WP < 4.8. |
|
| 125 | + if ( version_compare( $this->tgmpa->wp_version, '4.8', '<' ) ) { |
|
| 126 | + $this->upgrader->strings['skin_update_successful'] .= ' <a href="#" class="hide-if-no-js" onclick="%2$s"><span>' . esc_html__( 'Show Details', 'tgmpa' ) . '</span><span class="hidden">' . esc_html__( 'Hide Details', 'tgmpa' ) . '</span>.</a>'; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | * @param string $title Unused in this implementation. |
| 137 | 137 | */ |
| 138 | 138 | public function before( $title = '' ) { |
| 139 | - if ( empty( $title ) ) { |
|
| 140 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 141 | - } |
|
| 142 | - parent::before( $title ); |
|
| 139 | + if ( empty( $title ) ) { |
|
| 140 | + $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 141 | + } |
|
| 142 | + parent::before( $title ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -153,12 +153,12 @@ discard block |
||
| 153 | 153 | * @param string $title Unused in this implementation. |
| 154 | 154 | */ |
| 155 | 155 | public function after( $title = '' ) { |
| 156 | - if ( empty( $title ) ) { |
|
| 157 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 158 | - } |
|
| 159 | - parent::after( $title ); |
|
| 156 | + if ( empty( $title ) ) { |
|
| 157 | + $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
| 158 | + } |
|
| 159 | + parent::after( $title ); |
|
| 160 | 160 | |
| 161 | - $this->i++; |
|
| 161 | + $this->i++; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -167,41 +167,41 @@ discard block |
||
| 167 | 167 | * @since 2.2.0 |
| 168 | 168 | */ |
| 169 | 169 | public function bulk_footer() { |
| 170 | - // Serve up the string to say installations (and possibly activations) are complete. |
|
| 171 | - parent::bulk_footer(); |
|
| 172 | - |
|
| 173 | - // Flush plugins cache so we can make sure that the installed plugins list is always up to date. |
|
| 174 | - wp_clean_plugins_cache(); |
|
| 175 | - |
|
| 176 | - $this->tgmpa->show_tgmpa_version(); |
|
| 177 | - |
|
| 178 | - // Display message based on if all plugins are now active or not. |
|
| 179 | - $update_actions = array(); |
|
| 180 | - |
|
| 181 | - if ( $this->tgmpa->is_tgmpa_complete() ) { |
|
| 182 | - // All plugins are active, so we display the complete string and hide the menu to protect users. |
|
| 183 | - echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
|
| 184 | - $update_actions['dashboard'] = sprintf( |
|
| 185 | - esc_html( $this->tgmpa->strings['complete'] ), |
|
| 186 | - '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html( $this->tgmpa->strings['dashboard'] ) . '</a>' |
|
| 187 | - ); |
|
| 188 | - } else { |
|
| 189 | - $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Filter the list of action links available following bulk plugin installs/updates. |
|
| 194 | - * |
|
| 195 | - * @since 2.5.0 |
|
| 196 | - * |
|
| 197 | - * @param array $update_actions Array of plugin action links. |
|
| 198 | - * @param array $plugin_info Array of information for the last-handled plugin. |
|
| 199 | - */ |
|
| 200 | - $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
| 201 | - |
|
| 202 | - if ( ! empty( $update_actions ) ) { |
|
| 203 | - $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
| 204 | - } |
|
| 170 | + // Serve up the string to say installations (and possibly activations) are complete. |
|
| 171 | + parent::bulk_footer(); |
|
| 172 | + |
|
| 173 | + // Flush plugins cache so we can make sure that the installed plugins list is always up to date. |
|
| 174 | + wp_clean_plugins_cache(); |
|
| 175 | + |
|
| 176 | + $this->tgmpa->show_tgmpa_version(); |
|
| 177 | + |
|
| 178 | + // Display message based on if all plugins are now active or not. |
|
| 179 | + $update_actions = array(); |
|
| 180 | + |
|
| 181 | + if ( $this->tgmpa->is_tgmpa_complete() ) { |
|
| 182 | + // All plugins are active, so we display the complete string and hide the menu to protect users. |
|
| 183 | + echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
|
| 184 | + $update_actions['dashboard'] = sprintf( |
|
| 185 | + esc_html( $this->tgmpa->strings['complete'] ), |
|
| 186 | + '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html( $this->tgmpa->strings['dashboard'] ) . '</a>' |
|
| 187 | + ); |
|
| 188 | + } else { |
|
| 189 | + $update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>'; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Filter the list of action links available following bulk plugin installs/updates. |
|
| 194 | + * |
|
| 195 | + * @since 2.5.0 |
|
| 196 | + * |
|
| 197 | + * @param array $update_actions Array of plugin action links. |
|
| 198 | + * @param array $plugin_info Array of information for the last-handled plugin. |
|
| 199 | + */ |
|
| 200 | + $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); |
|
| 201 | + |
|
| 202 | + if ( ! empty( $update_actions ) ) { |
|
| 203 | + $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
| 204 | + } |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /* *********** DEPRECATED METHODS *********** */ |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | * @see Bulk_Upgrader_Skin::flush_output() |
| 215 | 215 | */ |
| 216 | 216 | public function before_flush_output() { |
| 217 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 218 | - $this->flush_output(); |
|
| 217 | + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 218 | + $this->flush_output(); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | * @see Bulk_Upgrader_Skin::flush_output() |
| 228 | 228 | */ |
| 229 | 229 | public function after_flush_output() { |
| 230 | - _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 231 | - $this->flush_output(); |
|
| 232 | - $this->i++; |
|
| 230 | + _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); |
|
| 231 | + $this->flush_output(); |
|
| 232 | + $this->i++; |
|
| 233 | 233 | } |
| 234 | 234 | } |
@@ -63,20 +63,20 @@ discard block |
||
| 63 | 63 | * @param \Bulk_Upgrader_Skin|null $skin Installer skin. |
| 64 | 64 | */ |
| 65 | 65 | public function __construct( $skin = null ) { |
| 66 | - // Get TGMPA class instance. |
|
| 67 | - $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 66 | + // Get TGMPA class instance. |
|
| 67 | + $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
|
| 68 | 68 | |
| 69 | - parent::__construct( $skin ); |
|
| 69 | + parent::__construct( $skin ); |
|
| 70 | 70 | |
| 71 | - if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
| 72 | - $this->clear_destination = true; |
|
| 73 | - } |
|
| 71 | + if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { |
|
| 72 | + $this->clear_destination = true; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - if ( $this->tgmpa->is_automatic ) { |
|
| 76 | - $this->activate_strings(); |
|
| 77 | - } |
|
| 75 | + if ( $this->tgmpa->is_automatic ) { |
|
| 76 | + $this->activate_strings(); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); |
|
| 79 | + add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @since 2.2.0 |
| 86 | 86 | */ |
| 87 | 87 | public function activate_strings() { |
| 88 | - $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
| 89 | - $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
| 88 | + $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); |
|
| 89 | + $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | * @return null|array Return early if error, array of installation data on success. |
| 101 | 101 | */ |
| 102 | 102 | public function run( $options ) { |
| 103 | - $result = parent::run( $options ); |
|
| 104 | - |
|
| 105 | - // Reset the strings in case we changed one during automatic activation. |
|
| 106 | - if ( $this->tgmpa->is_automatic ) { |
|
| 107 | - if ( 'update' === $this->skin->options['install_type'] ) { |
|
| 108 | - $this->upgrade_strings(); |
|
| 109 | - } else { |
|
| 110 | - $this->install_strings(); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return $result; |
|
| 103 | + $result = parent::run( $options ); |
|
| 104 | + |
|
| 105 | + // Reset the strings in case we changed one during automatic activation. |
|
| 106 | + if ( $this->tgmpa->is_automatic ) { |
|
| 107 | + if ( 'update' === $this->skin->options['install_type'] ) { |
|
| 108 | + $this->upgrade_strings(); |
|
| 109 | + } else { |
|
| 110 | + $this->install_strings(); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return $result; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -134,59 +134,59 @@ discard block |
||
| 134 | 134 | * @return array|false Install confirmation messages on success, false on failure. |
| 135 | 135 | */ |
| 136 | 136 | public function bulk_install( $plugins, $args = array() ) { |
| 137 | - // [TGMPA + ] Hook auto-activation in. |
|
| 138 | - add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 137 | + // [TGMPA + ] Hook auto-activation in. |
|
| 138 | + add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 139 | 139 | |
| 140 | - $defaults = array( |
|
| 141 | - 'clear_update_cache' => true, |
|
| 142 | - ); |
|
| 143 | - $parsed_args = wp_parse_args( $args, $defaults ); |
|
| 140 | + $defaults = array( |
|
| 141 | + 'clear_update_cache' => true, |
|
| 142 | + ); |
|
| 143 | + $parsed_args = wp_parse_args( $args, $defaults ); |
|
| 144 | 144 | |
| 145 | - $this->init(); |
|
| 146 | - $this->bulk = true; |
|
| 145 | + $this->init(); |
|
| 146 | + $this->bulk = true; |
|
| 147 | 147 | |
| 148 | - $this->install_strings(); // [TGMPA + ] adjusted. |
|
| 148 | + $this->install_strings(); // [TGMPA + ] adjusted. |
|
| 149 | 149 | |
| 150 | - /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ |
|
| 150 | + /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ |
|
| 151 | 151 | |
| 152 | - /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ |
|
| 152 | + /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ |
|
| 153 | 153 | |
| 154 | - $this->skin->header(); |
|
| 154 | + $this->skin->header(); |
|
| 155 | 155 | |
| 156 | - // Connect to the Filesystem first. |
|
| 157 | - $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
|
| 158 | - if ( ! $res ) { |
|
| 159 | - $this->skin->footer(); |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 156 | + // Connect to the Filesystem first. |
|
| 157 | + $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); |
|
| 158 | + if ( ! $res ) { |
|
| 159 | + $this->skin->footer(); |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $this->skin->bulk_header(); |
|
| 163 | + $this->skin->bulk_header(); |
|
| 164 | 164 | |
| 165 | - /* |
|
| 165 | + /* |
|
| 166 | 166 | * Only start maintenance mode if: |
| 167 | 167 | * - running Multisite and there are one or more plugins specified, OR |
| 168 | 168 | * - a plugin with an update available is currently active. |
| 169 | 169 | * @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. |
| 170 | 170 | */ |
| 171 | - $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
| 171 | + $maintenance = ( is_multisite() && ! empty( $plugins ) ); |
|
| 172 | 172 | |
| 173 | - /* |
|
| 173 | + /* |
|
| 174 | 174 | [TGMPA - ] |
| 175 | 175 | foreach ( $plugins as $plugin ) |
| 176 | 176 | $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); |
| 177 | 177 | */ |
| 178 | - if ( $maintenance ) { |
|
| 179 | - $this->maintenance_mode( true ); |
|
| 180 | - } |
|
| 178 | + if ( $maintenance ) { |
|
| 179 | + $this->maintenance_mode( true ); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - $results = array(); |
|
| 182 | + $results = array(); |
|
| 183 | 183 | |
| 184 | - $this->update_count = count( $plugins ); |
|
| 185 | - $this->update_current = 0; |
|
| 186 | - foreach ( $plugins as $plugin ) { |
|
| 187 | - $this->update_current++; |
|
| 184 | + $this->update_count = count( $plugins ); |
|
| 185 | + $this->update_current = 0; |
|
| 186 | + foreach ( $plugins as $plugin ) { |
|
| 187 | + $this->update_current++; |
|
| 188 | 188 | |
| 189 | - /* |
|
| 189 | + /* |
|
| 190 | 190 | [TGMPA - ] |
| 191 | 191 | $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); |
| 192 | 192 | |
@@ -205,70 +205,70 @@ discard block |
||
| 205 | 205 | $this->skin->plugin_active = is_plugin_active($plugin); |
| 206 | 206 | */ |
| 207 | 207 | |
| 208 | - $result = $this->run( |
|
| 209 | - array( |
|
| 210 | - 'package' => $plugin, // [TGMPA + ] adjusted. |
|
| 211 | - 'destination' => WP_PLUGIN_DIR, |
|
| 212 | - 'clear_destination' => false, // [TGMPA + ] adjusted. |
|
| 213 | - 'clear_working' => true, |
|
| 214 | - 'is_multi' => true, |
|
| 215 | - 'hook_extra' => array( |
|
| 216 | - 'plugin' => $plugin, |
|
| 217 | - ), |
|
| 218 | - ) |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - $results[ $plugin ] = $this->result; |
|
| 222 | - |
|
| 223 | - // Prevent credentials auth screen from displaying multiple times. |
|
| 224 | - if ( false === $result ) { |
|
| 225 | - break; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - $this->maintenance_mode( false ); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Fires when the bulk upgrader process is complete. |
|
| 233 | - * |
|
| 234 | - * @since WP 3.6.0 / TGMPA 2.5.0 |
|
| 235 | - * |
|
| 236 | - * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might |
|
| 237 | - * be a Theme_Upgrader or Core_Upgrade instance. |
|
| 238 | - * @param array $data { |
|
| 239 | - * Array of bulk item update data. |
|
| 240 | - * |
|
| 241 | - * @type string $action Type of action. Default 'update'. |
|
| 242 | - * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. |
|
| 243 | - * @type bool $bulk Whether the update process is a bulk update. Default true. |
|
| 244 | - * @type array $packages Array of plugin, theme, or core packages to update. |
|
| 245 | - * } |
|
| 246 | - */ |
|
| 247 | - do_action( // WPCS: prefix OK. |
|
| 248 | - 'upgrader_process_complete', |
|
| 249 | - $this, |
|
| 250 | - array( |
|
| 251 | - 'action' => 'install', // [TGMPA + ] adjusted. |
|
| 252 | - 'type' => 'plugin', |
|
| 253 | - 'bulk' => true, |
|
| 254 | - 'plugins' => $plugins, |
|
| 255 | - ) |
|
| 256 | - ); |
|
| 257 | - |
|
| 258 | - $this->skin->bulk_footer(); |
|
| 259 | - |
|
| 260 | - $this->skin->footer(); |
|
| 261 | - |
|
| 262 | - // Cleanup our hooks, in case something else does a upgrade on this connection. |
|
| 263 | - /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ |
|
| 264 | - |
|
| 265 | - // [TGMPA + ] Remove our auto-activation hook. |
|
| 266 | - remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 267 | - |
|
| 268 | - // Force refresh of plugin update information. |
|
| 269 | - wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
| 270 | - |
|
| 271 | - return $results; |
|
| 208 | + $result = $this->run( |
|
| 209 | + array( |
|
| 210 | + 'package' => $plugin, // [TGMPA + ] adjusted. |
|
| 211 | + 'destination' => WP_PLUGIN_DIR, |
|
| 212 | + 'clear_destination' => false, // [TGMPA + ] adjusted. |
|
| 213 | + 'clear_working' => true, |
|
| 214 | + 'is_multi' => true, |
|
| 215 | + 'hook_extra' => array( |
|
| 216 | + 'plugin' => $plugin, |
|
| 217 | + ), |
|
| 218 | + ) |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + $results[ $plugin ] = $this->result; |
|
| 222 | + |
|
| 223 | + // Prevent credentials auth screen from displaying multiple times. |
|
| 224 | + if ( false === $result ) { |
|
| 225 | + break; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + $this->maintenance_mode( false ); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Fires when the bulk upgrader process is complete. |
|
| 233 | + * |
|
| 234 | + * @since WP 3.6.0 / TGMPA 2.5.0 |
|
| 235 | + * |
|
| 236 | + * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might |
|
| 237 | + * be a Theme_Upgrader or Core_Upgrade instance. |
|
| 238 | + * @param array $data { |
|
| 239 | + * Array of bulk item update data. |
|
| 240 | + * |
|
| 241 | + * @type string $action Type of action. Default 'update'. |
|
| 242 | + * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. |
|
| 243 | + * @type bool $bulk Whether the update process is a bulk update. Default true. |
|
| 244 | + * @type array $packages Array of plugin, theme, or core packages to update. |
|
| 245 | + * } |
|
| 246 | + */ |
|
| 247 | + do_action( // WPCS: prefix OK. |
|
| 248 | + 'upgrader_process_complete', |
|
| 249 | + $this, |
|
| 250 | + array( |
|
| 251 | + 'action' => 'install', // [TGMPA + ] adjusted. |
|
| 252 | + 'type' => 'plugin', |
|
| 253 | + 'bulk' => true, |
|
| 254 | + 'plugins' => $plugins, |
|
| 255 | + ) |
|
| 256 | + ); |
|
| 257 | + |
|
| 258 | + $this->skin->bulk_footer(); |
|
| 259 | + |
|
| 260 | + $this->skin->footer(); |
|
| 261 | + |
|
| 262 | + // Cleanup our hooks, in case something else does a upgrade on this connection. |
|
| 263 | + /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ |
|
| 264 | + |
|
| 265 | + // [TGMPA + ] Remove our auto-activation hook. |
|
| 266 | + remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 267 | + |
|
| 268 | + // Force refresh of plugin update information. |
|
| 269 | + wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); |
|
| 270 | + |
|
| 271 | + return $results; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function bulk_upgrade( $plugins, $args = array() ) { |
| 286 | 286 | |
| 287 | - add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 287 | + add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 288 | 288 | |
| 289 | - $result = parent::bulk_upgrade( $plugins, $args ); |
|
| 289 | + $result = parent::bulk_upgrade( $plugins, $args ); |
|
| 290 | 290 | |
| 291 | - remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 291 | + remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); |
|
| 292 | 292 | |
| 293 | - return $result; |
|
| 293 | + return $result; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -304,30 +304,30 @@ discard block |
||
| 304 | 304 | * @return bool |
| 305 | 305 | */ |
| 306 | 306 | public function auto_activate( $bool ) { |
| 307 | - // Only process the activation of installed plugins if the automatic flag is set to true. |
|
| 308 | - if ( $this->tgmpa->is_automatic ) { |
|
| 309 | - // Flush plugins cache so the headers of the newly installed plugins will be read correctly. |
|
| 310 | - wp_clean_plugins_cache(); |
|
| 311 | - |
|
| 312 | - // Get the installed plugin file. |
|
| 313 | - $plugin_info = $this->plugin_info(); |
|
| 314 | - |
|
| 315 | - // Don't try to activate on upgrade of active plugin as WP will do this already. |
|
| 316 | - if ( ! is_plugin_active( $plugin_info ) ) { |
|
| 317 | - $activate = activate_plugin( $plugin_info ); |
|
| 318 | - |
|
| 319 | - // Adjust the success string based on the activation result. |
|
| 320 | - $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
| 321 | - |
|
| 322 | - if ( is_wp_error( $activate ) ) { |
|
| 323 | - $this->skin->error( $activate ); |
|
| 324 | - $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
| 325 | - } else { |
|
| 326 | - $this->strings['process_success'] .= $this->strings['activation_success']; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - return $bool; |
|
| 307 | + // Only process the activation of installed plugins if the automatic flag is set to true. |
|
| 308 | + if ( $this->tgmpa->is_automatic ) { |
|
| 309 | + // Flush plugins cache so the headers of the newly installed plugins will be read correctly. |
|
| 310 | + wp_clean_plugins_cache(); |
|
| 311 | + |
|
| 312 | + // Get the installed plugin file. |
|
| 313 | + $plugin_info = $this->plugin_info(); |
|
| 314 | + |
|
| 315 | + // Don't try to activate on upgrade of active plugin as WP will do this already. |
|
| 316 | + if ( ! is_plugin_active( $plugin_info ) ) { |
|
| 317 | + $activate = activate_plugin( $plugin_info ); |
|
| 318 | + |
|
| 319 | + // Adjust the success string based on the activation result. |
|
| 320 | + $this->strings['process_success'] = $this->strings['process_success'] . "<br />\n"; |
|
| 321 | + |
|
| 322 | + if ( is_wp_error( $activate ) ) { |
|
| 323 | + $this->skin->error( $activate ); |
|
| 324 | + $this->strings['process_success'] .= $this->strings['activation_failed']; |
|
| 325 | + } else { |
|
| 326 | + $this->strings['process_success'] .= $this->strings['activation_success']; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + return $bool; |
|
| 332 | 332 | } |
| 333 | 333 | } |