Completed
Pull Request — develop (#571)
by Juliette
02:14
created
class-tgm-plugin-activation.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
 		 *
1893 1893
 		 * @since 2.4.0
1894 1894
 		 *
1895
-		 * @return object The TGM_Plugin_Activation object.
1895
+		 * @return TGM_Plugin_Activation The TGM_Plugin_Activation object.
1896 1896
 		 */
1897 1897
 		public static function get_instance() {
1898 1898
 			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
 		 *
2050 2050
 		 * @since 2.5.0
2051 2051
 		 *
2052
-		 * @return array CSS classnames.
2052
+		 * @return string[] CSS classnames.
2053 2053
 		 */
2054 2054
 		public function get_table_classes() {
2055 2055
 			return array( 'widefat', 'fixed' );
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1441,13 +1441,13 @@
 block discarded – undo
1441 1441
 			$key     = preg_replace( '`[^A-Za-z0-9_-]`', '', $key );
1442 1442
 
1443 1443
 			/**
1444
-			* Filter a sanitized key string.
1445
-			*
1446
-			* @since 2.5.0
1447
-			*
1448
-			* @param string $key     Sanitized key.
1449
-			* @param string $raw_key The key prior to sanitization.
1450
-			*/
1444
+			 * Filter a sanitized key string.
1445
+			 *
1446
+			 * @since 2.5.0
1447
+			 *
1448
+			 * @param string $key     Sanitized key.
1449
+			 * @param string $raw_key The key prior to sanitization.
1450
+			 */
1451 1451
 			return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key );
1452 1452
 		}
1453 1453
 
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 			$args = apply_filters(
696 696
 				'tgmpa_admin_menu_args',
697 697
 				array(
698
-					'parent_slug' => $this->parent_slug,                     // Parent Menu slug.
699
-					'page_title'  => $this->strings['page_title'],           // Page title.
700
-					'menu_title'  => $this->strings['menu_title'],           // Menu title.
701
-					'capability'  => $this->capability,                      // Capability.
702
-					'menu_slug'   => $this->menu,                            // Menu slug.
698
+					'parent_slug' => $this->parent_slug, // Parent Menu slug.
699
+					'page_title'  => $this->strings['page_title'], // Page title.
700
+					'menu_title'  => $this->strings['menu_title'], // Menu title.
701
+					'capability'  => $this->capability, // Capability.
702
+					'menu_slug'   => $this->menu, // Menu slug.
703 703
 					'function'    => array( $this, 'install_plugins_page' ), // Callback.
704 704
 				)
705 705
 			);
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 			// All plugin information will be stored in an array for processing.
802 802
 			$slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) );
803 803
 
804
-			if ( ! isset( $this->plugins[ $slug ] ) ) {
804
+			if ( ! isset( $this->plugins[$slug] ) ) {
805 805
 				return false;
806 806
 			}
807 807
 
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 				$extra         = array();
846 846
 				$extra['slug'] = $slug; // Needed for potentially renaming of directory name.
847 847
 				$source        = $this->get_download_url( $slug );
848
-				$api           = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
848
+				$api           = ( 'repo' === $this->plugins[$slug]['source_type'] ) ? $this->get_plugins_api( $slug ) : null;
849 849
 				$api           = ( false !== $api ) ? $api : null;
850 850
 
851 851
 				$url = add_query_arg(
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 
863 863
 				$title     = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing'];
864 864
 				$skin_args = array(
865
-					'type'   => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload',
866
-					'title'  => sprintf( $title, $this->plugins[ $slug ]['name'] ),
865
+					'type'   => ( 'bundled' !== $this->plugins[$slug]['source_type'] ) ? 'web' : 'upload',
866
+					'title'  => sprintf( $title, $this->plugins[$slug]['name'] ),
867 867
 					'url'    => esc_url_raw( $url ),
868 868
 					'nonce'  => $install_type . '-plugin_' . $slug,
869 869
 					'plugin' => '',
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 				unset( $title );
874 874
 
875 875
 				if ( 'update' === $install_type ) {
876
-					$skin_args['plugin'] = $this->plugins[ $slug ]['file_path'];
876
+					$skin_args['plugin'] = $this->plugins[$slug]['file_path'];
877 877
 					$skin                = new Plugin_Upgrader_Skin( $skin_args );
878 878
 				} else {
879 879
 					$skin = new Plugin_Installer_Skin( $skin_args );
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
 
888 888
 				if ( 'update' === $install_type ) {
889 889
 					// Inject our info into the update transient.
890
-					$to_inject                    = array( $slug => $this->plugins[ $slug ] );
891
-					$to_inject[ $slug ]['source'] = $source;
890
+					$to_inject                    = array( $slug => $this->plugins[$slug] );
891
+					$to_inject[$slug]['source'] = $source;
892 892
 					$this->inject_update_info( $to_inject );
893 893
 
894
-					$upgrader->upgrade( $this->plugins[ $slug ]['file_path'] );
894
+					$upgrader->upgrade( $this->plugins[$slug]['file_path'] );
895 895
 				} else {
896 896
 					$upgrader->install( $source );
897 897
 				}
@@ -921,11 +921,11 @@  discard block
 block discarded – undo
921 921
 				}
922 922
 
923 923
 				return true;
924
-			} elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
924
+			} elseif ( isset( $this->plugins[$slug]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
925 925
 				// Activate action link was clicked.
926 926
 				check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' );
927 927
 
928
-				if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) {
928
+				if ( false === $this->activate_single_plugin( $this->plugins[$slug]['file_path'], $slug ) ) {
929 929
 					return true; // Finish execution of the function early as we encountered an error.
930 930
 				}
931 931
 			}
@@ -950,17 +950,17 @@  discard block
 block discarded – undo
950 950
 			foreach ( $plugins as $slug => $plugin ) {
951 951
 				$file_path = $plugin['file_path'];
952 952
 
953
-				if ( empty( $repo_updates->response[ $file_path ] ) ) {
954
-					$repo_updates->response[ $file_path ] = new stdClass;
953
+				if ( empty( $repo_updates->response[$file_path] ) ) {
954
+					$repo_updates->response[$file_path] = new stdClass;
955 955
 				}
956 956
 
957 957
 				// We only really need to set package, but let's do all we can in case WP changes something.
958
-				$repo_updates->response[ $file_path ]->slug        = $slug;
959
-				$repo_updates->response[ $file_path ]->plugin      = $file_path;
960
-				$repo_updates->response[ $file_path ]->new_version = $plugin['version'];
961
-				$repo_updates->response[ $file_path ]->package     = $plugin['source'];
962
-				if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) {
963
-					$repo_updates->response[ $file_path ]->url = $plugin['external_url'];
958
+				$repo_updates->response[$file_path]->slug        = $slug;
959
+				$repo_updates->response[$file_path]->plugin      = $file_path;
960
+				$repo_updates->response[$file_path]->new_version = $plugin['version'];
961
+				$repo_updates->response[$file_path]->package     = $plugin['source'];
962
+				if ( empty( $repo_updates->response[$file_path]->url ) && ! empty( $plugin['external_url'] ) ) {
963
+					$repo_updates->response[$file_path]->url = $plugin['external_url'];
964 964
 				}
965 965
 			}
966 966
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			} else {
1004 1004
 				// Bulk installer contains less info, so fall back on the info registered here.
1005 1005
 				foreach ( $this->plugins as $slug => $plugin ) {
1006
-					if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) {
1006
+					if ( ! empty( $upgrader->skin->plugin_names[$upgrader->skin->i] ) && $plugin['name'] === $upgrader->skin->plugin_names[$upgrader->skin->i] ) {
1007 1007
 						$desired_slug = $slug;
1008 1008
 						break;
1009 1009
 					}
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 						// Make sure message doesn't display again if bulk activation is performed
1057 1057
 						// immediately after a single activation.
1058 1058
 						if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
1059
-							echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>';
1059
+							echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[$slug]['name'] ), '.</strong></p></div>';
1060 1060
 						}
1061 1061
 					} else {
1062 1062
 						// Simpler message layout for use on the plugin install page.
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 				echo '<div id="message" class="error"><p>',
1070 1070
 					sprintf(
1071 1071
 						esc_html( $this->strings['plugin_already_active'] ),
1072
-						'<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
1072
+						'<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>'
1073 1073
 					),
1074 1074
 					'</p></div>';
1075 1075
 			} elseif ( $this->does_plugin_require_update( $slug ) ) {
@@ -1080,13 +1080,13 @@  discard block
 block discarded – undo
1080 1080
 						echo '<div id="message" class="error"><p>',
1081 1081
 							sprintf(
1082 1082
 								esc_html( $this->strings['plugin_needs_higher_version'] ),
1083
-								'<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
1083
+								'<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>'
1084 1084
 							),
1085 1085
 							'</p></div>';
1086 1086
 					}
1087 1087
 				} else {
1088 1088
 					// Simpler message layout for use on the plugin install page.
1089
-					echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>';
1089
+					echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[$slug]['name'] ) ), '</p>';
1090 1090
 				}
1091 1091
 			}
1092 1092
 
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 						$rendered .= sprintf(
1214 1214
 							$line_template,
1215 1215
 							sprintf(
1216
-								translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ),
1216
+								translate_nooped_plural( $this->strings[$type], $count, 'tgmpa' ),
1217 1217
 								$imploded,
1218 1218
 								$count
1219 1219
 							)
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 
1331 1331
 			foreach ( (array) $wp_settings_errors as $key => $details ) {
1332 1332
 				if ( 'tgmpa' === $details['setting'] ) {
1333
-					unset( $wp_settings_errors[ $key ] );
1333
+					unset( $wp_settings_errors[$key] );
1334 1334
 					break;
1335 1335
 				}
1336 1336
 			}
@@ -1366,20 +1366,20 @@  discard block
 block discarded – undo
1366 1366
 				return;
1367 1367
 			}
1368 1368
 
1369
-			if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) {
1369
+			if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[$plugin['slug']] ) ) {
1370 1370
 				return;
1371 1371
 			}
1372 1372
 
1373 1373
 			$defaults = array(
1374
-				'name'               => '',      // String
1375
-				'slug'               => '',      // String
1376
-				'source'             => 'repo',  // String
1377
-				'required'           => false,   // Boolean
1378
-				'version'            => '',      // String
1379
-				'force_activation'   => false,   // Boolean
1380
-				'force_deactivation' => false,   // Boolean
1381
-				'external_url'       => '',      // String
1382
-				'is_callable'        => '',      // String|Array.
1374
+				'name'               => '', // String
1375
+				'slug'               => '', // String
1376
+				'source'             => 'repo', // String
1377
+				'required'           => false, // Boolean
1378
+				'version'            => '', // String
1379
+				'force_activation'   => false, // Boolean
1380
+				'force_deactivation' => false, // Boolean
1381
+				'external_url'       => '', // String
1382
+				'is_callable'        => '', // String|Array.
1383 1383
 			);
1384 1384
 
1385 1385
 			// Prepare the received data.
@@ -1400,8 +1400,8 @@  discard block
 block discarded – undo
1400 1400
 			$plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] );
1401 1401
 
1402 1402
 			// Set the class properties.
1403
-			$this->plugins[ $plugin['slug'] ]    = $plugin;
1404
-			$this->sort_order[ $plugin['slug'] ] = $plugin['name'];
1403
+			$this->plugins[$plugin['slug']]    = $plugin;
1404
+			$this->sort_order[$plugin['slug']] = $plugin['name'];
1405 1405
 
1406 1406
 			// Should we add the force activation hook ?
1407 1407
 			if ( true === $plugin['force_activation'] ) {
@@ -1485,11 +1485,11 @@  discard block
 block discarded – undo
1485 1485
 			);
1486 1486
 
1487 1487
 			foreach ( $keys as $key ) {
1488
-				if ( isset( $config[ $key ] ) ) {
1489
-					if ( is_array( $config[ $key ] ) ) {
1490
-						$this->$key = array_merge( $this->$key, $config[ $key ] );
1488
+				if ( isset( $config[$key] ) ) {
1489
+					if ( is_array( $config[$key] ) ) {
1490
+						$this->$key = array_merge( $this->$key, $config[$key] );
1491 1491
 					} else {
1492
-						$this->$key = $config[ $key ];
1492
+						$this->$key = $config[$key];
1493 1493
 					}
1494 1494
 				}
1495 1495
 			}
@@ -1534,12 +1534,12 @@  discard block
 block discarded – undo
1534 1534
 		 *                            Parameter added in v2.5.0.
1535 1535
 		 */
1536 1536
 		public function populate_file_path( $plugin_slug = '' ) {
1537
-			if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) {
1538
-				$this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
1537
+			if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[$plugin_slug] ) ) {
1538
+				$this->plugins[$plugin_slug]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
1539 1539
 			} else {
1540 1540
 				// Add file_path key for all plugins.
1541 1541
 				foreach ( $this->plugins as $slug => $values ) {
1542
-					$this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
1542
+					$this->plugins[$slug]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
1543 1543
 				}
1544 1544
 			}
1545 1545
 		}
@@ -1579,8 +1579,8 @@  discard block
 block discarded – undo
1579 1579
 		 */
1580 1580
 		public function _get_plugin_data_from_name( $name, $data = 'slug' ) {
1581 1581
 			foreach ( $this->plugins as $values ) {
1582
-				if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
1583
-					return $values[ $data ];
1582
+				if ( $name === $values['name'] && isset( $values[$data] ) ) {
1583
+					return $values[$data];
1584 1584
 				}
1585 1585
 			}
1586 1586
 
@@ -1598,13 +1598,13 @@  discard block
 block discarded – undo
1598 1598
 		public function get_download_url( $slug ) {
1599 1599
 			$dl_source = '';
1600 1600
 
1601
-			switch ( $this->plugins[ $slug ]['source_type'] ) {
1601
+			switch ( $this->plugins[$slug]['source_type'] ) {
1602 1602
 				case 'repo':
1603 1603
 					return $this->get_wp_repo_download_url( $slug );
1604 1604
 				case 'external':
1605
-					return $this->plugins[ $slug ]['source'];
1605
+					return $this->plugins[$slug]['source'];
1606 1606
 				case 'bundled':
1607
-					return $this->default_path . $this->plugins[ $slug ]['source'];
1607
+					return $this->default_path . $this->plugins[$slug]['source'];
1608 1608
 			}
1609 1609
 
1610 1610
 			return $dl_source; // Should never happen.
@@ -1640,23 +1640,23 @@  discard block
 block discarded – undo
1640 1640
 		protected function get_plugins_api( $slug ) {
1641 1641
 			static $api = array(); // Cache received responses.
1642 1642
 
1643
-			if ( ! isset( $api[ $slug ] ) ) {
1643
+			if ( ! isset( $api[$slug] ) ) {
1644 1644
 				if ( ! function_exists( 'plugins_api' ) ) {
1645 1645
 					require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
1646 1646
 				}
1647 1647
 
1648 1648
 				$response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) );
1649 1649
 
1650
-				$api[ $slug ] = false;
1650
+				$api[$slug] = false;
1651 1651
 
1652 1652
 				if ( is_wp_error( $response ) ) {
1653 1653
 					wp_die( esc_html( $this->strings['oops'] ) );
1654 1654
 				} else {
1655
-					$api[ $slug ] = $response;
1655
+					$api[$slug] = $response;
1656 1656
 				}
1657 1657
 			}
1658 1658
 
1659
-			return $api[ $slug ];
1659
+			return $api[$slug];
1660 1660
 		}
1661 1661
 
1662 1662
 		/**
@@ -1669,13 +1669,13 @@  discard block
 block discarded – undo
1669 1669
 		 *                or the plugin name if not.
1670 1670
 		 */
1671 1671
 		public function get_info_link( $slug ) {
1672
-			if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) {
1672
+			if ( ! empty( $this->plugins[$slug]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[$slug]['external_url'] ) ) {
1673 1673
 				$link = sprintf(
1674 1674
 					'<a href="%1$s" target="_blank">%2$s</a>',
1675
-					esc_url( $this->plugins[ $slug ]['external_url'] ),
1676
-					esc_html( $this->plugins[ $slug ]['name'] )
1675
+					esc_url( $this->plugins[$slug]['external_url'] ),
1676
+					esc_html( $this->plugins[$slug]['name'] )
1677 1677
 				);
1678
-			} elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
1678
+			} elseif ( 'repo' === $this->plugins[$slug]['source_type'] ) {
1679 1679
 				$url = add_query_arg(
1680 1680
 					array(
1681 1681
 						'tab'       => 'plugin-information',
@@ -1690,10 +1690,10 @@  discard block
 block discarded – undo
1690 1690
 				$link = sprintf(
1691 1691
 					'<a href="%1$s" class="thickbox">%2$s</a>',
1692 1692
 					esc_url( $url ),
1693
-					esc_html( $this->plugins[ $slug ]['name'] )
1693
+					esc_html( $this->plugins[$slug]['name'] )
1694 1694
 				);
1695 1695
 			} else {
1696
-				$link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink.
1696
+				$link = esc_html( $this->plugins[$slug]['name'] ); // No hyperlink.
1697 1697
 			}
1698 1698
 
1699 1699
 			return $link;
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
 		public function is_plugin_installed( $slug ) {
1819 1819
 			$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
1820 1820
 
1821
-			return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) );
1821
+			return ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']] ) );
1822 1822
 		}
1823 1823
 
1824 1824
 		/**
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 		 * @return bool True if active, false otherwise.
1831 1831
 		 */
1832 1832
 		public function is_plugin_active( $slug ) {
1833
-			return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) );
1833
+			return ( ( ! empty( $this->plugins[$slug]['is_callable'] ) && is_callable( $this->plugins[$slug]['is_callable'] ) ) || is_plugin_active( $this->plugins[$slug]['file_path'] ) );
1834 1834
 		}
1835 1835
 
1836 1836
 		/**
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 		 */
1845 1845
 		public function can_plugin_update( $slug ) {
1846 1846
 			// We currently can't get reliable info on non-WP-repo plugins - issue #380.
1847
-			if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
1847
+			if ( 'repo' !== $this->plugins[$slug]['source_type'] ) {
1848 1848
 				return true;
1849 1849
 			}
1850 1850
 
@@ -1900,8 +1900,8 @@  discard block
 block discarded – undo
1900 1900
 		public function get_installed_version( $slug ) {
1901 1901
 			$installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached).
1902 1902
 
1903
-			if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) {
1904
-				return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'];
1903
+			if ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']]['Version'] ) ) {
1904
+				return $installed_plugins[$this->plugins[$slug]['file_path']]['Version'];
1905 1905
 			}
1906 1906
 
1907 1907
 			return '';
@@ -1917,7 +1917,7 @@  discard block
 block discarded – undo
1917 1917
 		 */
1918 1918
 		public function does_plugin_require_update( $slug ) {
1919 1919
 			$installed_version = $this->get_installed_version( $slug );
1920
-			$minimum_version   = $this->plugins[ $slug ]['version'];
1920
+			$minimum_version   = $this->plugins[$slug]['version'];
1921 1921
 
1922 1922
 			return version_compare( $minimum_version, $installed_version, '>' );
1923 1923
 		}
@@ -1932,9 +1932,9 @@  discard block
 block discarded – undo
1932 1932
 		 */
1933 1933
 		public function does_plugin_have_update( $slug ) {
1934 1934
 			// Presume bundled and external plugins will point to a package which meets the minimum required version.
1935
-			if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
1935
+			if ( 'repo' !== $this->plugins[$slug]['source_type'] ) {
1936 1936
 				if ( $this->does_plugin_require_update( $slug ) ) {
1937
-					return $this->plugins[ $slug ]['version'];
1937
+					return $this->plugins[$slug]['version'];
1938 1938
 				}
1939 1939
 
1940 1940
 				return false;
@@ -1942,8 +1942,8 @@  discard block
 block discarded – undo
1942 1942
 
1943 1943
 			$repo_updates = get_site_transient( 'update_plugins' );
1944 1944
 
1945
-			if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) {
1946
-				return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version;
1945
+			if ( isset( $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version ) ) {
1946
+				return $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version;
1947 1947
 			}
1948 1948
 
1949 1949
 			return false;
@@ -1959,14 +1959,14 @@  discard block
 block discarded – undo
1959 1959
 		 */
1960 1960
 		public function get_upgrade_notice( $slug ) {
1961 1961
 			// We currently can't get reliable info on non-WP-repo plugins - issue #380.
1962
-			if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) {
1962
+			if ( 'repo' !== $this->plugins[$slug]['source_type'] ) {
1963 1963
 				return '';
1964 1964
 			}
1965 1965
 
1966 1966
 			$repo_updates = get_site_transient( 'update_plugins' );
1967 1967
 
1968
-			if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) {
1969
-				return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice;
1968
+			if ( ! empty( $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice ) ) {
1969
+				return $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice;
1970 1970
 			}
1971 1971
 
1972 1972
 			return '';
@@ -2255,30 +2255,30 @@  discard block
 block discarded – undo
2255 2255
 			$i          = 0;
2256 2256
 
2257 2257
 			// Redirect to the 'all' view if no plugins were found for the selected view context.
2258
-			if ( empty( $plugins[ $this->view_context ] ) ) {
2258
+			if ( empty( $plugins[$this->view_context] ) ) {
2259 2259
 				$this->view_context = 'all';
2260 2260
 			}
2261 2261
 
2262
-			foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) {
2263
-				$table_data[ $i ]['sanitized_plugin']  = $plugin['name'];
2264
-				$table_data[ $i ]['slug']              = $slug;
2265
-				$table_data[ $i ]['plugin']            = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>';
2266
-				$table_data[ $i ]['source']            = $this->get_plugin_source_type_text( $plugin['source_type'] );
2267
-				$table_data[ $i ]['type']              = $this->get_plugin_advise_type_text( $plugin['required'] );
2268
-				$table_data[ $i ]['status']            = $this->get_plugin_status_text( $slug );
2269
-				$table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug );
2270
-				$table_data[ $i ]['minimum_version']   = $plugin['version'];
2271
-				$table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug );
2262
+			foreach ( $plugins[$this->view_context] as $slug => $plugin ) {
2263
+				$table_data[$i]['sanitized_plugin']  = $plugin['name'];
2264
+				$table_data[$i]['slug']              = $slug;
2265
+				$table_data[$i]['plugin']            = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>';
2266
+				$table_data[$i]['source']            = $this->get_plugin_source_type_text( $plugin['source_type'] );
2267
+				$table_data[$i]['type']              = $this->get_plugin_advise_type_text( $plugin['required'] );
2268
+				$table_data[$i]['status']            = $this->get_plugin_status_text( $slug );
2269
+				$table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version( $slug );
2270
+				$table_data[$i]['minimum_version']   = $plugin['version'];
2271
+				$table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug );
2272 2272
 
2273 2273
 				// Prep the upgrade notice info.
2274 2274
 				$upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug );
2275 2275
 				if ( ! empty( $upgrade_notice ) ) {
2276
-					$table_data[ $i ]['upgrade_notice'] = $upgrade_notice;
2276
+					$table_data[$i]['upgrade_notice'] = $upgrade_notice;
2277 2277
 
2278 2278
 					add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 );
2279 2279
 				}
2280 2280
 
2281
-				$table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin );
2281
+				$table_data[$i] = apply_filters( 'tgmpa_table_data_item', $table_data[$i], $plugin );
2282 2282
 
2283 2283
 				$i++;
2284 2284
 			}
@@ -2304,17 +2304,17 @@  discard block
 block discarded – undo
2304 2304
 					// No need to display plugins if they are installed, up-to-date and active.
2305 2305
 					continue;
2306 2306
 				} else {
2307
-					$plugins['all'][ $slug ] = $plugin;
2307
+					$plugins['all'][$slug] = $plugin;
2308 2308
 
2309 2309
 					if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
2310
-						$plugins['install'][ $slug ] = $plugin;
2310
+						$plugins['install'][$slug] = $plugin;
2311 2311
 					} else {
2312 2312
 						if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
2313
-							$plugins['update'][ $slug ] = $plugin;
2313
+							$plugins['update'][$slug] = $plugin;
2314 2314
 						}
2315 2315
 
2316 2316
 						if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
2317
-							$plugins['activate'][ $slug ] = $plugin;
2317
+							$plugins['activate'][$slug] = $plugin;
2318 2318
 						}
2319 2319
 					}
2320 2320
 				}
@@ -2332,7 +2332,7 @@  discard block
 block discarded – undo
2332 2332
 		 */
2333 2333
 		protected function set_view_totals( $plugins ) {
2334 2334
 			foreach ( $plugins as $type => $list ) {
2335
-				$this->view_totals[ $type ] = count( $list );
2335
+				$this->view_totals[$type] = count( $list );
2336 2336
 			}
2337 2337
 		}
2338 2338
 
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 			$name = array();
2435 2435
 
2436 2436
 			foreach ( $items as $i => $plugin ) {
2437
-				$type[ $i ] = $plugin['type']; // Required / recommended.
2438
-				$name[ $i ] = $plugin['sanitized_plugin'];
2437
+				$type[$i] = $plugin['type']; // Required / recommended.
2438
+				$name[$i] = $plugin['sanitized_plugin'];
2439 2439
 			}
2440 2440
 
2441 2441
 			array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items );
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
 
2483 2483
 				if ( ! empty( $text ) ) {
2484 2484
 
2485
-					$status_links[ $type ] = sprintf(
2485
+					$status_links[$type] = sprintf(
2486 2486
 						'<a href="%s"%s>%s</a>',
2487 2487
 						esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ),
2488 2488
 						( $type === $this->view_context ) ? ' class="current"' : '',
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
 		 * @return string
2506 2506
 		 */
2507 2507
 		public function column_default( $item, $column_name ) {
2508
-			return $item[ $column_name ];
2508
+			return $item[$column_name];
2509 2509
 		}
2510 2510
 
2511 2511
 		/**
@@ -2705,7 +2705,7 @@  discard block
 block discarded – undo
2705 2705
 					'tgmpa-nonce'
2706 2706
 				);
2707 2707
 
2708
-				$action_links[ $action ] = sprintf(
2708
+				$action_links[$action] = sprintf(
2709 2709
 					'<a href="%1$s">' . esc_html( $text ) . '</a>',
2710 2710
 					esc_url( $nonce_url ),
2711 2711
 					'<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>'
@@ -2854,19 +2854,19 @@  discard block
 block discarded – undo
2854 2854
 				// Validate the received input.
2855 2855
 				foreach ( $plugins_to_install as $key => $slug ) {
2856 2856
 					// Check if the plugin was registered with TGMPA and remove if not.
2857
-					if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) {
2858
-						unset( $plugins_to_install[ $key ] );
2857
+					if ( ! isset( $this->tgmpa->plugins[$slug] ) ) {
2858
+						unset( $plugins_to_install[$key] );
2859 2859
 						continue;
2860 2860
 					}
2861 2861
 
2862 2862
 					// For install: make sure this is a plugin we *can* install and not one already installed.
2863 2863
 					if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) {
2864
-						unset( $plugins_to_install[ $key ] );
2864
+						unset( $plugins_to_install[$key] );
2865 2865
 					}
2866 2866
 
2867 2867
 					// For updates: make sure this is a plugin we *can* update (update available and WP version ok).
2868 2868
 					if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) {
2869
-						unset( $plugins_to_install[ $key ] );
2869
+						unset( $plugins_to_install[$key] );
2870 2870
 					}
2871 2871
 				}
2872 2872
 
@@ -2917,7 +2917,7 @@  discard block
 block discarded – undo
2917 2917
 
2918 2918
 				// Prepare the data for validated plugins for the install/upgrade.
2919 2919
 				foreach ( $plugins_to_install as $slug ) {
2920
-					$name   = $this->tgmpa->plugins[ $slug ]['name'];
2920
+					$name   = $this->tgmpa->plugins[$slug]['name'];
2921 2921
 					$source = $this->tgmpa->get_download_url( $slug );
2922 2922
 
2923 2923
 					if ( ! empty( $name ) && ! empty( $source ) ) {
@@ -2930,9 +2930,9 @@  discard block
 block discarded – undo
2930 2930
 								break;
2931 2931
 
2932 2932
 							case 'update':
2933
-								$file_paths[]                 = $this->tgmpa->plugins[ $slug ]['file_path'];
2934
-								$to_inject[ $slug ]           = $this->tgmpa->plugins[ $slug ];
2935
-								$to_inject[ $slug ]['source'] = $source;
2933
+								$file_paths[]                 = $this->tgmpa->plugins[$slug]['file_path'];
2934
+								$to_inject[$slug]           = $this->tgmpa->plugins[$slug];
2935
+								$to_inject[$slug]['source'] = $source;
2936 2936
 								break;
2937 2937
 						}
2938 2938
 					}
@@ -2999,8 +2999,8 @@  discard block
 block discarded – undo
2999 2999
 				// Grab the file paths for the selected & inactive plugins from the registration array.
3000 3000
 				foreach ( $plugins as $slug ) {
3001 3001
 					if ( $this->tgmpa->can_plugin_activate( $slug ) ) {
3002
-						$plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path'];
3003
-						$plugin_names[]        = $this->tgmpa->plugins[ $slug ]['name'];
3002
+						$plugins_to_activate[] = $this->tgmpa->plugins[$slug]['file_path'];
3003
+						$plugin_names[]        = $this->tgmpa->plugins[$slug]['name'];
3004 3004
 					}
3005 3005
 				}
3006 3006
 				unset( $slug );
@@ -3032,8 +3032,8 @@  discard block
 block discarded – undo
3032 3032
 					// Update recently activated plugins option.
3033 3033
 					$recent = (array) get_option( 'recently_activated' );
3034 3034
 					foreach ( $plugins_to_activate as $plugin => $time ) {
3035
-						if ( isset( $recent[ $plugin ] ) ) {
3036
-							unset( $recent[ $plugin ] );
3035
+						if ( isset( $recent[$plugin] ) ) {
3036
+							unset( $recent[$plugin] );
3037 3037
 						}
3038 3038
 					}
3039 3039
 					update_option( 'recently_activated', $recent );
@@ -3354,7 +3354,7 @@  discard block
 block discarded – undo
3354 3354
 								)
3355 3355
 							);
3356 3356
 
3357
-							$results[ $plugin ] = $this->result;
3357
+							$results[$plugin] = $this->result;
3358 3358
 
3359 3359
 							// Prevent credentials auth screen from displaying multiple times.
3360 3360
 							if ( false === $result ) {
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
 							'names'        => array(),
3541 3541
 							'install_type' => 'install',
3542 3542
 						);
3543
-						$args     = wp_parse_args( $args, $defaults );
3543
+						$args = wp_parse_args( $args, $defaults );
3544 3544
 
3545 3545
 						// Set plugin names to $this->plugin_names property.
3546 3546
 						$this->plugin_names = $args['names'];
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
 					 */
3598 3598
 					public function before( $title = '' ) {
3599 3599
 						if ( empty( $title ) ) {
3600
-							$title = esc_html( $this->plugin_names[ $this->i ] );
3600
+							$title = esc_html( $this->plugin_names[$this->i] );
3601 3601
 						}
3602 3602
 						parent::before( $title );
3603 3603
 					}
@@ -3614,7 +3614,7 @@  discard block
 block discarded – undo
3614 3614
 					 */
3615 3615
 					public function after( $title = '' ) {
3616 3616
 						if ( empty( $title ) ) {
3617
-							$title = esc_html( $this->plugin_names[ $this->i ] );
3617
+							$title = esc_html( $this->plugin_names[$this->i] );
3618 3618
 						}
3619 3619
 						parent::after( $title );
3620 3620
 
@@ -3787,7 +3787,7 @@  discard block
 block discarded – undo
3787 3787
 		 */
3788 3788
 		protected static function emulate_filter_bool( $value ) {
3789 3789
 			// @codingStandardsIgnoreStart
3790
-			static $true  = array(
3790
+			static $true = array(
3791 3791
 				'1',
3792 3792
 				'true', 'True', 'TRUE',
3793 3793
 				'y', 'Y',
Please login to merge, or discard this patch.
Braces   +128 added lines, -63 removed lines patch added patch discarded remove patch
@@ -472,7 +472,8 @@  discard block
 block discarded – undo
472 472
 				add_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10, 2 );
473 473
 				load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' );
474 474
 				remove_action( 'load_textdomain_mofile', array( $this, 'correct_plugin_mofile' ), 10 );
475
-			} else {
475
+			}
476
+			else {
476 477
 				load_theme_textdomain( 'tgmpa', dirname( __FILE__ ) . '/languages' );
477 478
 			}
478 479
 		}
@@ -527,9 +528,11 @@  discard block
 block discarded – undo
527 528
 			// Current fallback file is not valid, let's try the alternative option.
528 529
 			if ( false !== strpos( $mofile, '/themes/' ) ) {
529 530
 				return str_replace( '/themes/', '/plugins/', $mofile );
530
-			} elseif ( false !== strpos( $mofile, '/plugins/' ) ) {
531
+			}
532
+			elseif ( false !== strpos( $mofile, '/plugins/' ) ) {
531 533
 				return str_replace( '/plugins/', '/themes/', $mofile );
532
-			} else {
534
+			}
535
+			else {
533 536
 				return $mofile;
534 537
 			}
535 538
 		}
@@ -724,7 +727,8 @@  discard block
 block discarded – undo
724 727
 
725 728
 			if ( 'themes.php' === $this->parent_slug ) {
726 729
 				$this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
727
-			} else {
730
+			}
731
+			else {
728 732
 				$this->page_hook = call_user_func( 'add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );
729 733
 			}
730 734
 		}
@@ -875,7 +879,8 @@  discard block
 block discarded – undo
875 879
 				if ( 'update' === $install_type ) {
876 880
 					$skin_args['plugin'] = $this->plugins[ $slug ]['file_path'];
877 881
 					$skin                = new Plugin_Upgrader_Skin( $skin_args );
878
-				} else {
882
+				}
883
+				else {
879 884
 					$skin = new Plugin_Installer_Skin( $skin_args );
880 885
 				}
881 886
 
@@ -892,7 +897,8 @@  discard block
 block discarded – undo
892 897
 					$this->inject_update_info( $to_inject );
893 898
 
894 899
 					$upgrader->upgrade( $this->plugins[ $slug ]['file_path'] );
895
-				} else {
900
+				}
901
+				else {
896 902
 					$upgrader->install( $source );
897 903
 				}
898 904
 
@@ -916,12 +922,14 @@  discard block
 block discarded – undo
916 922
 				if ( $this->is_tgmpa_complete() ) {
917 923
 					echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>';
918 924
 					echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
919
-				} else {
925
+				}
926
+				else {
920 927
 					echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
921 928
 				}
922 929
 
923 930
 				return true;
924
-			} elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
931
+			}
932
+			elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) {
925 933
 				// Activate action link was clicked.
926 934
 				check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' );
927 935
 
@@ -1000,7 +1008,8 @@  discard block
 block discarded – undo
1000 1008
 			// Figure out what the slug is supposed to be.
1001 1009
 			if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) {
1002 1010
 				$desired_slug = $upgrader->skin->options['extra']['slug'];
1003
-			} else {
1011
+			}
1012
+			else {
1004 1013
 				// Bulk installer contains less info, so fall back on the info registered here.
1005 1014
 				foreach ( $this->plugins as $slug => $plugin ) {
1006 1015
 					if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) {
@@ -1020,10 +1029,12 @@  discard block
 block discarded – undo
1020 1029
 
1021 1030
 					if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) {
1022 1031
 						return trailingslashit( $to );
1023
-					} else {
1032
+					}
1033
+					else {
1024 1034
 						return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
1025 1035
 					}
1026
-				} elseif ( empty( $subdir_name ) ) {
1036
+				}
1037
+				elseif ( empty( $subdir_name ) ) {
1027 1038
 					return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) );
1028 1039
 				}
1029 1040
 			}
@@ -1051,19 +1062,23 @@  discard block
 block discarded – undo
1051 1062
 						'<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
1052 1063
 
1053 1064
 					return false; // End it here if there is an error with activation.
1054
-				} else {
1065
+				}
1066
+				else {
1055 1067
 					if ( ! $automatic ) {
1056 1068
 						// Make sure message doesn't display again if bulk activation is performed
1057 1069
 						// immediately after a single activation.
1058
-						if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
1070
+						if ( ! isset( $_POST['action'] ) ) {
1071
+// WPCS: CSRF OK.
1059 1072
 							echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>';
1060 1073
 						}
1061
-					} else {
1074
+					}
1075
+					else {
1062 1076
 						// Simpler message layout for use on the plugin install page.
1063 1077
 						echo '<p>', esc_html( $this->strings['plugin_activated'] ), '</p>';
1064 1078
 					}
1065 1079
 				}
1066
-			} elseif ( $this->is_plugin_active( $slug ) ) {
1080
+			}
1081
+			elseif ( $this->is_plugin_active( $slug ) ) {
1067 1082
 				// No simpler message format provided as this message should never be encountered
1068 1083
 				// on the plugin install page.
1069 1084
 				echo '<div id="message" class="error"><p>',
@@ -1072,11 +1087,13 @@  discard block
 block discarded – undo
1072 1087
 						'<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>'
1073 1088
 					),
1074 1089
 					'</p></div>';
1075
-			} elseif ( $this->does_plugin_require_update( $slug ) ) {
1090
+			}
1091
+			elseif ( $this->does_plugin_require_update( $slug ) ) {
1076 1092
 				if ( ! $automatic ) {
1077 1093
 					// Make sure message doesn't display again if bulk activation is performed
1078 1094
 					// immediately after a single activation.
1079
-					if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK.
1095
+					if ( ! isset( $_POST['action'] ) ) {
1096
+// WPCS: CSRF OK.
1080 1097
 						echo '<div id="message" class="error"><p>',
1081 1098
 							sprintf(
1082 1099
 								esc_html( $this->strings['plugin_needs_higher_version'] ),
@@ -1084,7 +1101,8 @@  discard block
 block discarded – undo
1084 1101
 							),
1085 1102
 							'</p></div>';
1086 1103
 					}
1087
-				} else {
1104
+				}
1105
+				else {
1088 1106
 					// Simpler message layout for use on the plugin install page.
1089 1107
 					echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>';
1090 1108
 				}
@@ -1134,21 +1152,24 @@  discard block
 block discarded – undo
1134 1152
 
1135 1153
 						if ( true === $plugin['required'] ) {
1136 1154
 							$message['notice_can_install_required'][] = $slug;
1137
-						} else {
1155
+						}
1156
+						else {
1138 1157
 							$message['notice_can_install_recommended'][] = $slug;
1139 1158
 						}
1140 1159
 					}
1141 1160
 					if ( true === $plugin['required'] ) {
1142 1161
 						$total_required_action_count++;
1143 1162
 					}
1144
-				} else {
1163
+				}
1164
+				else {
1145 1165
 					if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) {
1146 1166
 						if ( current_user_can( 'activate_plugins' ) ) {
1147 1167
 							$activate_link_count++;
1148 1168
 
1149 1169
 							if ( true === $plugin['required'] ) {
1150 1170
 								$message['notice_can_activate_required'][] = $slug;
1151
-							} else {
1171
+							}
1172
+							else {
1152 1173
 								$message['notice_can_activate_recommended'][] = $slug;
1153 1174
 							}
1154 1175
 						}
@@ -1164,7 +1185,8 @@  discard block
 block discarded – undo
1164 1185
 
1165 1186
 							if ( $this->does_plugin_require_update( $slug ) ) {
1166 1187
 								$message['notice_ask_to_update'][] = $slug;
1167
-							} elseif ( false !== $this->does_plugin_have_update( $slug ) ) {
1188
+							}
1189
+							elseif ( false !== $this->does_plugin_have_update( $slug ) ) {
1168 1190
 								$message['notice_ask_to_update_maybe'][] = $slug;
1169 1191
 							}
1170 1192
 						}
@@ -1188,7 +1210,8 @@  discard block
 block discarded – undo
1188 1210
 				if ( ! current_user_can( 'activate_plugins' ) && ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) {
1189 1211
 					$rendered = esc_html__( $this->strings['notice_cannot_install_activate'] ) . ' ' . esc_html__( $this->strings['contact_admin'] );
1190 1212
 					$rendered .= $this->create_user_action_links_for_notice( 0, 0, 0, $line_template );
1191
-				} else {
1213
+				}
1214
+				else {
1192 1215
 
1193 1216
 					// If dismissable is false and a message is set, output it now.
1194 1217
 					if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) {
@@ -1289,7 +1312,8 @@  discard block
 block discarded – undo
1289 1312
 			if ( ! empty( $action_links ) ) {
1290 1313
 				$action_links = sprintf( $line_template, implode( ' | ', $action_links ) );
1291 1314
 				return apply_filters( 'tgmpa_notice_rendered_action_links', $action_links );
1292
-			} else {
1315
+			}
1316
+			else {
1293 1317
 				return '';
1294 1318
 			}
1295 1319
 		}
@@ -1307,12 +1331,15 @@  discard block
 block discarded – undo
1307 1331
 		protected function get_admin_notice_class() {
1308 1332
 			if ( ! empty( $this->strings['nag_type'] ) ) {
1309 1333
 				return sanitize_html_class( strtolower( $this->strings['nag_type'] ) );
1310
-			} else {
1334
+			}
1335
+			else {
1311 1336
 				if ( version_compare( $this->wp_version, '4.2', '>=' ) ) {
1312 1337
 					return 'notice-warning';
1313
-				} elseif ( version_compare( $this->wp_version, '4.1', '>=' ) ) {
1338
+				}
1339
+				elseif ( version_compare( $this->wp_version, '4.1', '>=' ) ) {
1314 1340
 					return 'notice';
1315
-				} else {
1341
+				}
1342
+				else {
1316 1343
 					return 'updated';
1317 1344
 				}
1318 1345
 			}
@@ -1426,9 +1453,11 @@  discard block
 block discarded – undo
1426 1453
 		protected function get_plugin_source_type( $source ) {
1427 1454
 			if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) {
1428 1455
 				return 'repo';
1429
-			} elseif ( preg_match( self::IS_URL_REGEX, $source ) ) {
1456
+			}
1457
+			elseif ( preg_match( self::IS_URL_REGEX, $source ) ) {
1430 1458
 				return 'external';
1431
-			} else {
1459
+			}
1460
+			else {
1432 1461
 				return 'bundled';
1433 1462
 			}
1434 1463
 		}
@@ -1488,7 +1517,8 @@  discard block
 block discarded – undo
1488 1517
 				if ( isset( $config[ $key ] ) ) {
1489 1518
 					if ( is_array( $config[ $key ] ) ) {
1490 1519
 						$this->$key = array_merge( $this->$key, $config[ $key ] );
1491
-					} else {
1520
+					}
1521
+					else {
1492 1522
 						$this->$key = $config[ $key ];
1493 1523
 					}
1494 1524
 				}
@@ -1536,7 +1566,8 @@  discard block
 block discarded – undo
1536 1566
 		public function populate_file_path( $plugin_slug = '' ) {
1537 1567
 			if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) {
1538 1568
 				$this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug );
1539
-			} else {
1569
+			}
1570
+			else {
1540 1571
 				// Add file_path key for all plugins.
1541 1572
 				foreach ( $this->plugins as $slug => $values ) {
1542 1573
 					$this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug );
@@ -1651,7 +1682,8 @@  discard block
 block discarded – undo
1651 1682
 
1652 1683
 				if ( is_wp_error( $response ) ) {
1653 1684
 					wp_die( esc_html( $this->strings['oops'] ) );
1654
-				} else {
1685
+				}
1686
+				else {
1655 1687
 					$api[ $slug ] = $response;
1656 1688
 				}
1657 1689
 			}
@@ -1675,7 +1707,8 @@  discard block
 block discarded – undo
1675 1707
 					esc_url( $this->plugins[ $slug ]['external_url'] ),
1676 1708
 					esc_html( $this->plugins[ $slug ]['name'] )
1677 1709
 				);
1678
-			} elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
1710
+			}
1711
+			elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) {
1679 1712
 				$url = add_query_arg(
1680 1713
 					array(
1681 1714
 						'tab'       => 'plugin-information',
@@ -1692,7 +1725,8 @@  discard block
 block discarded – undo
1692 1725
 					esc_url( $url ),
1693 1726
 					esc_html( $this->plugins[ $slug ]['name'] )
1694 1727
 				);
1695
-			} else {
1728
+			}
1729
+			else {
1696 1730
 				$link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink.
1697 1731
 			}
1698 1732
 
@@ -1728,10 +1762,14 @@  discard block
 block discarded – undo
1728 1762
 			if ( 'update-core' === $screen->base ) {
1729 1763
 				// Core update screen.
1730 1764
 				return true;
1731
-			} elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok.
1765
+			}
1766
+			elseif ( 'plugins' === $screen->base && ! empty( $_POST['action'] ) ) {
1767
+// WPCS: CSRF ok.
1732 1768
 				// Plugins bulk update screen.
1733 1769
 				return true;
1734
-			} elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) { // WPCS: CSRF ok.
1770
+			}
1771
+			elseif ( 'update' === $screen->base && ! empty( $_POST['action'] ) ) {
1772
+// WPCS: CSRF ok.
1735 1773
 				// Individual updates (ajax call).
1736 1774
 				return true;
1737 1775
 			}
@@ -1870,7 +1908,8 @@  discard block
 block discarded – undo
1870 1908
 		public function is_plugin_updatetable( $slug ) {
1871 1909
 			if ( ! $this->is_plugin_installed( $slug ) ) {
1872 1910
 				return false;
1873
-			} else {
1911
+			}
1912
+			else {
1874 1913
 				return ( $this->does_plugin_have_update( $slug ) && $this->can_plugin_update( $slug ) );
1875 1914
 			}
1876 1915
 		}
@@ -2020,7 +2059,8 @@  discard block
 block discarded – undo
2020 2059
 					if ( ! $this->is_plugin_installed( $slug ) ) {
2021 2060
 						// Oops, plugin isn't there so iterate to next condition.
2022 2061
 						continue;
2023
-					} elseif ( $this->can_plugin_activate( $slug ) ) {
2062
+					}
2063
+					elseif ( $this->can_plugin_activate( $slug ) ) {
2024 2064
 						// There we go, activate the plugin.
2025 2065
 						activate_plugin( $plugin['file_path'] );
2026 2066
 					}
@@ -2091,7 +2131,8 @@  discard block
 block discarded – undo
2091 2131
 
2092 2132
 	if ( did_action( 'plugins_loaded' ) ) {
2093 2133
 		load_tgm_plugin_activation();
2094
-	} else {
2134
+	}
2135
+	else {
2095 2136
 		add_action( 'plugins_loaded', 'load_tgm_plugin_activation' );
2096 2137
 	}
2097 2138
 }
@@ -2303,12 +2344,14 @@  discard block
 block discarded – undo
2303 2344
 				if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
2304 2345
 					// No need to display plugins if they are installed, up-to-date and active.
2305 2346
 					continue;
2306
-				} else {
2347
+				}
2348
+				else {
2307 2349
 					$plugins['all'][ $slug ] = $plugin;
2308 2350
 
2309 2351
 					if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) {
2310 2352
 						$plugins['install'][ $slug ] = $plugin;
2311
-					} else {
2353
+					}
2354
+					else {
2312 2355
 						if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
2313 2356
 							$plugins['update'][ $slug ] = $plugin;
2314 2357
 						}
@@ -2393,7 +2436,8 @@  discard block
 block discarded – undo
2393 2436
 
2394 2437
 			if ( ! $this->tgmpa->is_plugin_active( $slug ) ) {
2395 2438
 				$install_status = __( 'Installed But Not Activated', 'tgmpa' );
2396
-			} else {
2439
+			}
2440
+			else {
2397 2441
 				$install_status = __( 'Active', 'tgmpa' );
2398 2442
 			}
2399 2443
 
@@ -2402,10 +2446,12 @@  discard block
 block discarded – undo
2402 2446
 			if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) {
2403 2447
 				$update_status = __( 'Required Update not Available', 'tgmpa' );
2404 2448
 
2405
-			} elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) {
2449
+			}
2450
+			elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) {
2406 2451
 				$update_status = __( 'Requires Update', 'tgmpa' );
2407 2452
 
2408
-			} elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
2453
+			}
2454
+			elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) {
2409 2455
 				$update_status = __( 'Update recommended', 'tgmpa' );
2410 2456
 			}
2411 2457
 
@@ -2591,7 +2637,8 @@  discard block
 block discarded – undo
2591 2637
 
2592 2638
 			if ( empty( $output ) ) {
2593 2639
 				return '&nbsp;'; // Let's not break the table layout.
2594
-			} else {
2640
+			}
2641
+			else {
2595 2642
 				return implode( "\n", $output );
2596 2643
 			}
2597 2644
 		}
@@ -2656,7 +2703,8 @@  discard block
 block discarded – undo
2656 2703
 		protected function get_primary_column_name() {
2657 2704
 			if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) {
2658 2705
 				return parent::get_primary_column_name();
2659
-			} else {
2706
+			}
2707
+			else {
2660 2708
 				return $this->get_default_primary_column_name();
2661 2709
 			}
2662 2710
 		}
@@ -2677,7 +2725,8 @@  discard block
 block discarded – undo
2677 2725
 			if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
2678 2726
 				/* translators: %s: plugin name in screen reader markup */
2679 2727
 				$actions['install'] = __( 'Install %s', 'tgmpa' );
2680
-			} else {
2728
+			}
2729
+			else {
2681 2730
 				// Display the 'Update' action link if an update is available and WP complies with plugin minimum.
2682 2731
 				if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) {
2683 2732
 					/* translators: %s: plugin name in screen reader markup */
@@ -2831,7 +2880,8 @@  discard block
 block discarded – undo
2831 2880
 				if ( empty( $_POST['plugin'] ) ) {
2832 2881
 					if ( 'install' === $install_type ) {
2833 2882
 						$message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' );
2834
-					} else {
2883
+					}
2884
+					else {
2835 2885
 						$message = __( 'No plugins were selected to be updated. No action taken.', 'tgmpa' );
2836 2886
 					}
2837 2887
 
@@ -2842,7 +2892,8 @@  discard block
 block discarded – undo
2842 2892
 
2843 2893
 				if ( is_array( $_POST['plugin'] ) ) {
2844 2894
 					$plugins_to_install = (array) $_POST['plugin'];
2845
-				} elseif ( is_string( $_POST['plugin'] ) ) {
2895
+				}
2896
+				elseif ( is_string( $_POST['plugin'] ) ) {
2846 2897
 					// Received via Filesystem page - un-flatten array (WP bug #19643).
2847 2898
 					$plugins_to_install = explode( ',', $_POST['plugin'] );
2848 2899
 				}
@@ -2874,7 +2925,8 @@  discard block
 block discarded – undo
2874 2925
 				if ( empty( $plugins_to_install ) ) {
2875 2926
 					if ( 'install' === $install_type ) {
2876 2927
 						$message = __( 'No plugins are available to be installed at this time.', 'tgmpa' );
2877
-					} else {
2928
+					}
2929
+					else {
2878 2930
 						$message = __( 'No plugins are available to be updated at this time.', 'tgmpa' );
2879 2931
 					}
2880 2932
 
@@ -2964,7 +3016,8 @@  discard block
 block discarded – undo
2964 3016
 					$this->tgmpa->inject_update_info( $to_inject );
2965 3017
 
2966 3018
 					$installer->bulk_upgrade( $file_paths );
2967
-				} else {
3019
+				}
3020
+				else {
2968 3021
 					$installer->bulk_install( $sources );
2969 3022
 				}
2970 3023
 
@@ -3017,7 +3070,8 @@  discard block
 block discarded – undo
3017 3070
 
3018 3071
 				if ( is_wp_error( $activate ) ) {
3019 3072
 					echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>';
3020
-				} else {
3073
+				}
3074
+				else {
3021 3075
 					$count        = count( $plugin_names ); // Count so we can use _n function.
3022 3076
 					$plugin_names = array_map( array( 'TGMPA_Utils', 'wrap_in_strong' ), $plugin_names );
3023 3077
 					$last_plugin  = array_pop( $plugin_names ); // Pop off last name to prep for readability.
@@ -3242,7 +3296,8 @@  discard block
 block discarded – undo
3242 3296
 						if ( $this->tgmpa->is_automatic ) {
3243 3297
 							if ( 'update' === $this->skin->options['install_type'] ) {
3244 3298
 								$this->upgrade_strings();
3245
-							} else {
3299
+							}
3300
+							else {
3246 3301
 								$this->install_strings();
3247 3302
 							}
3248 3303
 						}
@@ -3454,7 +3509,8 @@  discard block
 block discarded – undo
3454 3509
 								if ( is_wp_error( $activate ) ) {
3455 3510
 									$this->skin->error( $activate );
3456 3511
 									$this->strings['process_success'] .= $this->strings['activation_failed'];
3457
-								} else {
3512
+								}
3513
+								else {
3458 3514
 									$this->strings['process_success'] .= $this->strings['activation_success'];
3459 3515
 								}
3460 3516
 							}
@@ -3562,7 +3618,8 @@  discard block
 block discarded – undo
3562 3618
 							parent::add_strings();
3563 3619
 							/* translators: 1: plugin name, 2: action number 3: total number of actions. */
3564 3620
 							$this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
3565
-						} else {
3621
+						}
3622
+						else {
3566 3623
 							/* translators: 1: plugin name, 2: error message. */
3567 3624
 							$this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: <strong>%2$s</strong>.', 'tgmpa' );
3568 3625
 							/* translators: 1: plugin name. */
@@ -3576,7 +3633,8 @@  discard block
 block discarded – undo
3576 3633
 								$this->upgrader->strings['skin_upgrade_end']          = __( 'All installations and activations have been completed.', 'tgmpa' );
3577 3634
 								/* translators: 1: plugin name, 2: action number 3: total number of actions. */
3578 3635
 								$this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' );
3579
-							} else {
3636
+							}
3637
+							else {
3580 3638
 								// Default installation strings.
3581 3639
 								$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' );
3582 3640
 								/* translators: 1: plugin name. */
@@ -3645,7 +3703,8 @@  discard block
 block discarded – undo
3645 3703
 								esc_html( $this->tgmpa->strings['complete'] ),
3646 3704
 								'<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>'
3647 3705
 							);
3648
-						} else {
3706
+						}
3707
+						else {
3649 3708
 							$update_actions['tgmpa_page'] = '<a href="' . esc_url( $this->tgmpa->get_tgmpa_url() ) . '" target="_parent">' . esc_html( $this->tgmpa->strings['return'] ) . '</a>';
3650 3709
 						}
3651 3710
 
@@ -3770,7 +3829,8 @@  discard block
 block discarded – undo
3770 3829
 
3771 3830
 			if ( self::$has_filters ) {
3772 3831
 				return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
3773
-			} else {
3832
+			}
3833
+			else {
3774 3834
 				return self::emulate_filter_bool( $value );
3775 3835
 			}
3776 3836
 		}
@@ -3805,17 +3865,22 @@  discard block
 block discarded – undo
3805 3865
 
3806 3866
 			if ( is_bool( $value ) ) {
3807 3867
 				return $value;
3808
-			} else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) {
3868
+			}
3869
+			else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) {
3809 3870
 				return (bool) $value;
3810
-			} else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) {
3871
+			}
3872
+			else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) {
3811 3873
 				return (bool) $value;
3812
-			} else if ( is_string( $value ) ) {
3874
+			}
3875
+			else if ( is_string( $value ) ) {
3813 3876
 				$value = trim( $value );
3814 3877
 				if ( in_array( $value, $true, true ) ) {
3815 3878
 					return true;
3816
-				} else if ( in_array( $value, $false, true ) ) {
3879
+				}
3880
+				else if ( in_array( $value, $false, true ) ) {
3817 3881
 					return false;
3818
-				} else {
3882
+				}
3883
+				else {
3819 3884
 					return false;
3820 3885
 				}
3821 3886
 			}
Please login to merge, or discard this patch.
example.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -121,16 +121,16 @@
 block discarded – undo
121 121
 	 * Only uncomment the strings in the config array if you want to customize the strings.
122 122
 	 */
123 123
 	$config = array(
124
-		'id'           => 'tgmpa',                 // Unique ID for hashing notices for multiple instances of TGMPA.
125
-		'default_path' => '',                      // Default absolute path to bundled plugins.
124
+		'id'           => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
125
+		'default_path' => '', // Default absolute path to bundled plugins.
126 126
 		'menu'         => 'tgmpa-install-plugins', // Menu slug.
127
-		'parent_slug'  => 'themes.php',            // Parent menu slug.
128
-		'capability'   => 'edit_theme_options',    // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
129
-		'has_notices'  => true,                    // Show admin notices or not.
130
-		'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
131
-		'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
132
-		'is_automatic' => false,                   // Automatically activate plugins after installation or not.
133
-		'message'      => '',                      // Message to output right before the plugins table.
127
+		'parent_slug'  => 'themes.php', // Parent menu slug.
128
+		'capability'   => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
129
+		'has_notices'  => true, // Show admin notices or not.
130
+		'dismissable'  => true, // If false, a user cannot dismiss the nag message.
131
+		'dismiss_msg'  => '', // If 'dismissable' is false, this message will be output at top of nag.
132
+		'is_automatic' => false, // Automatically activate plugins after installation or not.
133
+		'message'      => '', // Message to output right before the plugins table.
134 134
 
135 135
 		/*
136 136
 		'strings'      => array(
Please login to merge, or discard this patch.