@@ -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 | } |
@@ -2226,7 +2226,7 @@ |
||
2226 | 2226 | * |
2227 | 2227 | * @since 2.5.0 |
2228 | 2228 | * |
2229 | - * @return array CSS classnames. |
|
2229 | + * @return string[] CSS classnames. |
|
2230 | 2230 | */ |
2231 | 2231 | public function get_table_classes() { |
2232 | 2232 | return array( 'widefat', 'fixed' ); |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | $args = apply_filters( |
705 | 705 | 'tgmpa_admin_menu_args', |
706 | 706 | array( |
707 | - 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
708 | - 'page_title' => $this->strings['page_title'], // Page title. |
|
709 | - 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
710 | - 'capability' => $this->capability, // Capability. |
|
711 | - 'menu_slug' => $this->menu, // Menu slug. |
|
707 | + 'parent_slug' => $this->parent_slug, // Parent Menu slug. |
|
708 | + 'page_title' => $this->strings['page_title'], // Page title. |
|
709 | + 'menu_title' => $this->strings['menu_title'], // Menu title. |
|
710 | + 'capability' => $this->capability, // Capability. |
|
711 | + 'menu_slug' => $this->menu, // Menu slug. |
|
712 | 712 | 'function' => array( $this, 'install_plugins_page' ), // Callback. |
713 | 713 | ) |
714 | 714 | ); |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | // All plugin information will be stored in an array for processing. |
811 | 811 | $slug = $this->sanitize_key( urldecode( $_GET['plugin'] ) ); |
812 | 812 | |
813 | - if ( ! isset( $this->plugins[ $slug ] ) ) { |
|
813 | + if ( ! isset( $this->plugins[$slug] ) ) { |
|
814 | 814 | return false; |
815 | 815 | } |
816 | 816 | |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | $extra = array(); |
856 | 856 | $extra['slug'] = $slug; // Needed for potentially renaming of directory name. |
857 | 857 | $source = $this->get_download_url( $slug ); |
858 | - $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
858 | + $api = ( 'repo' === $this->plugins[$slug]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; |
|
859 | 859 | $api = ( false !== $api ) ? $api : null; |
860 | 860 | |
861 | 861 | $url = add_query_arg( |
@@ -872,8 +872,8 @@ discard block |
||
872 | 872 | |
873 | 873 | $title = ( 'update' === $install_type ) ? $this->strings['updating'] : $this->strings['installing']; |
874 | 874 | $skin_args = array( |
875 | - 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', |
|
876 | - 'title' => sprintf( $title, $this->plugins[ $slug ]['name'] ), |
|
875 | + 'type' => ( 'bundled' !== $this->plugins[$slug]['source_type'] ) ? 'web' : 'upload', |
|
876 | + 'title' => sprintf( $title, $this->plugins[$slug]['name'] ), |
|
877 | 877 | 'url' => esc_url_raw( $url ), |
878 | 878 | 'nonce' => $install_type . '-plugin_' . $slug, |
879 | 879 | 'plugin' => '', |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | unset( $title ); |
884 | 884 | |
885 | 885 | if ( 'update' === $install_type ) { |
886 | - $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; |
|
886 | + $skin_args['plugin'] = $this->plugins[$slug]['file_path']; |
|
887 | 887 | $skin = new Plugin_Upgrader_Skin( $skin_args ); |
888 | 888 | } else { |
889 | 889 | $skin = new Plugin_Installer_Skin( $skin_args ); |
@@ -898,12 +898,12 @@ discard block |
||
898 | 898 | if ( 'update' === $install_type ) { |
899 | 899 | // Inject our info into the update transient. |
900 | 900 | $to_inject = array( |
901 | - $slug => $this->plugins[ $slug ], |
|
901 | + $slug => $this->plugins[$slug], |
|
902 | 902 | ); |
903 | - $to_inject[ $slug ]['source'] = $source; |
|
903 | + $to_inject[$slug]['source'] = $source; |
|
904 | 904 | $this->inject_update_info( $to_inject ); |
905 | 905 | |
906 | - $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); |
|
906 | + $upgrader->upgrade( $this->plugins[$slug]['file_path'] ); |
|
907 | 907 | } else { |
908 | 908 | $upgrader->install( $source ); |
909 | 909 | } |
@@ -933,11 +933,11 @@ discard block |
||
933 | 933 | } |
934 | 934 | |
935 | 935 | return true; |
936 | - } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
936 | + } elseif ( isset( $this->plugins[$slug]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { |
|
937 | 937 | // Activate action link was clicked. |
938 | 938 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); |
939 | 939 | |
940 | - if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { |
|
940 | + if ( false === $this->activate_single_plugin( $this->plugins[$slug]['file_path'], $slug ) ) { |
|
941 | 941 | return true; // Finish execution of the function early as we encountered an error. |
942 | 942 | } |
943 | 943 | } |
@@ -962,17 +962,17 @@ discard block |
||
962 | 962 | foreach ( $plugins as $slug => $plugin ) { |
963 | 963 | $file_path = $plugin['file_path']; |
964 | 964 | |
965 | - if ( empty( $repo_updates->response[ $file_path ] ) ) { |
|
966 | - $repo_updates->response[ $file_path ] = new stdClass(); |
|
965 | + if ( empty( $repo_updates->response[$file_path] ) ) { |
|
966 | + $repo_updates->response[$file_path] = new stdClass(); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | // We only really need to set package, but let's do all we can in case WP changes something. |
970 | - $repo_updates->response[ $file_path ]->slug = $slug; |
|
971 | - $repo_updates->response[ $file_path ]->plugin = $file_path; |
|
972 | - $repo_updates->response[ $file_path ]->new_version = $plugin['version']; |
|
973 | - $repo_updates->response[ $file_path ]->package = $plugin['source']; |
|
974 | - if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
975 | - $repo_updates->response[ $file_path ]->url = $plugin['external_url']; |
|
970 | + $repo_updates->response[$file_path]->slug = $slug; |
|
971 | + $repo_updates->response[$file_path]->plugin = $file_path; |
|
972 | + $repo_updates->response[$file_path]->new_version = $plugin['version']; |
|
973 | + $repo_updates->response[$file_path]->package = $plugin['source']; |
|
974 | + if ( empty( $repo_updates->response[$file_path]->url ) && ! empty( $plugin['external_url'] ) ) { |
|
975 | + $repo_updates->response[$file_path]->url = $plugin['external_url']; |
|
976 | 976 | } |
977 | 977 | } |
978 | 978 | |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | } else { |
1016 | 1016 | // Bulk installer contains less info, so fall back on the info registered here. |
1017 | 1017 | foreach ( $this->plugins as $slug => $plugin ) { |
1018 | - if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { |
|
1018 | + if ( ! empty( $upgrader->skin->plugin_names[$upgrader->skin->i] ) && $plugin['name'] === $upgrader->skin->plugin_names[$upgrader->skin->i] ) { |
|
1019 | 1019 | $desired_slug = $slug; |
1020 | 1020 | break; |
1021 | 1021 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | // Make sure message doesn't display again if bulk activation is performed |
1083 | 1083 | // immediately after a single activation. |
1084 | 1084 | if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. |
1085 | - echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[ $slug ]['name'] ), '.</strong></p></div>'; |
|
1085 | + echo '<div id="message" class="updated"><p>', esc_html( $this->strings['activated_successfully'] ), ' <strong>', esc_html( $this->plugins[$slug]['name'] ), '.</strong></p></div>'; |
|
1086 | 1086 | } |
1087 | 1087 | } else { |
1088 | 1088 | // Simpler message layout for use on the plugin install page. |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | echo '<div id="message" class="error"><p>', |
1096 | 1096 | sprintf( |
1097 | 1097 | esc_html( $this->strings['plugin_already_active'] ), |
1098 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1098 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
1099 | 1099 | ), |
1100 | 1100 | '</p></div>'; |
1101 | 1101 | } elseif ( $this->does_plugin_require_update( $slug ) ) { |
@@ -1106,13 +1106,13 @@ discard block |
||
1106 | 1106 | echo '<div id="message" class="error"><p>', |
1107 | 1107 | sprintf( |
1108 | 1108 | esc_html( $this->strings['plugin_needs_higher_version'] ), |
1109 | - '<strong>' . esc_html( $this->plugins[ $slug ]['name'] ) . '</strong>' |
|
1109 | + '<strong>' . esc_html( $this->plugins[$slug]['name'] ) . '</strong>' |
|
1110 | 1110 | ), |
1111 | 1111 | '</p></div>'; |
1112 | 1112 | } |
1113 | 1113 | } else { |
1114 | 1114 | // Simpler message layout for use on the plugin install page. |
1115 | - echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '</p>'; |
|
1115 | + echo '<p>', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[$slug]['name'] ) ), '</p>'; |
|
1116 | 1116 | } |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | $rendered .= sprintf( |
1240 | 1240 | $line_template, |
1241 | 1241 | sprintf( |
1242 | - translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), |
|
1242 | + translate_nooped_plural( $this->strings[$type], $count, 'tgmpa' ), |
|
1243 | 1243 | $imploded, |
1244 | 1244 | $count |
1245 | 1245 | ) |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | |
1357 | 1357 | foreach ( (array) $wp_settings_errors as $key => $details ) { |
1358 | 1358 | if ( 'tgmpa' === $details['setting'] ) { |
1359 | - unset( $wp_settings_errors[ $key ] ); |
|
1359 | + unset( $wp_settings_errors[$key] ); |
|
1360 | 1360 | break; |
1361 | 1361 | } |
1362 | 1362 | } |
@@ -1392,21 +1392,21 @@ discard block |
||
1392 | 1392 | return; |
1393 | 1393 | } |
1394 | 1394 | |
1395 | - if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { |
|
1395 | + if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[$plugin['slug']] ) ) { |
|
1396 | 1396 | return; |
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | $defaults = array( |
1400 | - 'name' => '', // String. |
|
1401 | - 'slug' => '', // String. |
|
1402 | - 'source' => 'repo', // String. |
|
1403 | - 'required' => false, // Boolean. |
|
1404 | - 'version' => '', // String. |
|
1405 | - 'force_activation' => false, // Boolean. |
|
1406 | - 'force_deactivation' => false, // Boolean. |
|
1407 | - 'external_url' => '', // String. |
|
1408 | - 'is_callable' => '', // String|Array. |
|
1409 | - 'class_exists' => '', // String. |
|
1400 | + 'name' => '', // String. |
|
1401 | + 'slug' => '', // String. |
|
1402 | + 'source' => 'repo', // String. |
|
1403 | + 'required' => false, // Boolean. |
|
1404 | + 'version' => '', // String. |
|
1405 | + 'force_activation' => false, // Boolean. |
|
1406 | + 'force_deactivation' => false, // Boolean. |
|
1407 | + 'external_url' => '', // String. |
|
1408 | + 'is_callable' => '', // String|Array. |
|
1409 | + 'class_exists' => '', // String. |
|
1410 | 1410 | ); |
1411 | 1411 | |
1412 | 1412 | // Prepare the received data. |
@@ -1427,8 +1427,8 @@ discard block |
||
1427 | 1427 | $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); |
1428 | 1428 | |
1429 | 1429 | // Set the class properties. |
1430 | - $this->plugins[ $plugin['slug'] ] = $plugin; |
|
1431 | - $this->sort_order[ $plugin['slug'] ] = $plugin['name']; |
|
1430 | + $this->plugins[$plugin['slug']] = $plugin; |
|
1431 | + $this->sort_order[$plugin['slug']] = $plugin['name']; |
|
1432 | 1432 | |
1433 | 1433 | // Should we add the force activation hook ? |
1434 | 1434 | if ( true === $plugin['force_activation'] ) { |
@@ -1512,11 +1512,11 @@ discard block |
||
1512 | 1512 | ); |
1513 | 1513 | |
1514 | 1514 | foreach ( $keys as $key ) { |
1515 | - if ( isset( $config[ $key ] ) ) { |
|
1516 | - if ( is_array( $config[ $key ] ) ) { |
|
1517 | - $this->$key = array_merge( $this->$key, $config[ $key ] ); |
|
1515 | + if ( isset( $config[$key] ) ) { |
|
1516 | + if ( is_array( $config[$key] ) ) { |
|
1517 | + $this->$key = array_merge( $this->$key, $config[$key] ); |
|
1518 | 1518 | } else { |
1519 | - $this->$key = $config[ $key ]; |
|
1519 | + $this->$key = $config[$key]; |
|
1520 | 1520 | } |
1521 | 1521 | } |
1522 | 1522 | } |
@@ -1561,12 +1561,12 @@ discard block |
||
1561 | 1561 | * Parameter added in v2.5.0. |
1562 | 1562 | */ |
1563 | 1563 | public function populate_file_path( $plugin_slug = '' ) { |
1564 | - if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { |
|
1565 | - $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1564 | + if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[$plugin_slug] ) ) { |
|
1565 | + $this->plugins[$plugin_slug]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); |
|
1566 | 1566 | } else { |
1567 | 1567 | // Add file_path key for all plugins. |
1568 | 1568 | foreach ( $this->plugins as $slug => $values ) { |
1569 | - $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1569 | + $this->plugins[$slug]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); |
|
1570 | 1570 | } |
1571 | 1571 | } |
1572 | 1572 | } |
@@ -1606,8 +1606,8 @@ discard block |
||
1606 | 1606 | */ |
1607 | 1607 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
1608 | 1608 | foreach ( $this->plugins as $values ) { |
1609 | - if ( $name === $values['name'] && isset( $values[ $data ] ) ) { |
|
1610 | - return $values[ $data ]; |
|
1609 | + if ( $name === $values['name'] && isset( $values[$data] ) ) { |
|
1610 | + return $values[$data]; |
|
1611 | 1611 | } |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1625,13 +1625,13 @@ discard block |
||
1625 | 1625 | public function get_download_url( $slug ) { |
1626 | 1626 | $dl_source = ''; |
1627 | 1627 | |
1628 | - switch ( $this->plugins[ $slug ]['source_type'] ) { |
|
1628 | + switch ( $this->plugins[$slug]['source_type'] ) { |
|
1629 | 1629 | case 'repo': |
1630 | 1630 | return $this->get_wp_repo_download_url( $slug ); |
1631 | 1631 | case 'external': |
1632 | - return $this->plugins[ $slug ]['source']; |
|
1632 | + return $this->plugins[$slug]['source']; |
|
1633 | 1633 | case 'bundled': |
1634 | - return $this->default_path . $this->plugins[ $slug ]['source']; |
|
1634 | + return $this->default_path . $this->plugins[$slug]['source']; |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | 1637 | return $dl_source; // Should never happen. |
@@ -1667,7 +1667,7 @@ discard block |
||
1667 | 1667 | protected function get_plugins_api( $slug ) { |
1668 | 1668 | static $api = array(); // Cache received responses. |
1669 | 1669 | |
1670 | - if ( ! isset( $api[ $slug ] ) ) { |
|
1670 | + if ( ! isset( $api[$slug] ) ) { |
|
1671 | 1671 | if ( ! function_exists( 'plugins_api' ) ) { |
1672 | 1672 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
1673 | 1673 | } |
@@ -1682,16 +1682,16 @@ discard block |
||
1682 | 1682 | ) |
1683 | 1683 | ); |
1684 | 1684 | |
1685 | - $api[ $slug ] = false; |
|
1685 | + $api[$slug] = false; |
|
1686 | 1686 | |
1687 | 1687 | if ( is_wp_error( $response ) ) { |
1688 | 1688 | wp_die( esc_html( $this->strings['oops'] ) ); |
1689 | 1689 | } else { |
1690 | - $api[ $slug ] = $response; |
|
1690 | + $api[$slug] = $response; |
|
1691 | 1691 | } |
1692 | 1692 | } |
1693 | 1693 | |
1694 | - return $api[ $slug ]; |
|
1694 | + return $api[$slug]; |
|
1695 | 1695 | } |
1696 | 1696 | |
1697 | 1697 | /** |
@@ -1704,13 +1704,13 @@ discard block |
||
1704 | 1704 | * or the plugin name if not. |
1705 | 1705 | */ |
1706 | 1706 | public function get_info_link( $slug ) { |
1707 | - if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { |
|
1707 | + if ( ! empty( $this->plugins[$slug]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[$slug]['external_url'] ) ) { |
|
1708 | 1708 | $link = sprintf( |
1709 | 1709 | '<a href="%1$s" target="_blank">%2$s</a>', |
1710 | - esc_url( $this->plugins[ $slug ]['external_url'] ), |
|
1711 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1710 | + esc_url( $this->plugins[$slug]['external_url'] ), |
|
1711 | + esc_html( $this->plugins[$slug]['name'] ) |
|
1712 | 1712 | ); |
1713 | - } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { |
|
1713 | + } elseif ( 'repo' === $this->plugins[$slug]['source_type'] ) { |
|
1714 | 1714 | $url = add_query_arg( |
1715 | 1715 | array( |
1716 | 1716 | 'tab' => 'plugin-information', |
@@ -1725,10 +1725,10 @@ discard block |
||
1725 | 1725 | $link = sprintf( |
1726 | 1726 | '<a href="%1$s" class="thickbox">%2$s</a>', |
1727 | 1727 | esc_url( $url ), |
1728 | - esc_html( $this->plugins[ $slug ]['name'] ) |
|
1728 | + esc_html( $this->plugins[$slug]['name'] ) |
|
1729 | 1729 | ); |
1730 | 1730 | } else { |
1731 | - $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. |
|
1731 | + $link = esc_html( $this->plugins[$slug]['name'] ); // No hyperlink. |
|
1732 | 1732 | } |
1733 | 1733 | |
1734 | 1734 | return $link; |
@@ -1853,7 +1853,7 @@ discard block |
||
1853 | 1853 | public function is_plugin_installed( $slug ) { |
1854 | 1854 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1855 | 1855 | |
1856 | - return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); |
|
1856 | + return ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']] ) ); |
|
1857 | 1857 | } |
1858 | 1858 | |
1859 | 1859 | /** |
@@ -1865,9 +1865,9 @@ discard block |
||
1865 | 1865 | * @return bool True if active, false otherwise. |
1866 | 1866 | */ |
1867 | 1867 | public function is_plugin_active( $slug ) { |
1868 | - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) |
|
1869 | - || ( ! empty( $this->plugins[ $slug ]['class_exists'] ) && class_exists( $this->plugins[ $slug ]['class_exists'] ) ) |
|
1870 | - || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); |
|
1868 | + return ( ( ! empty( $this->plugins[$slug]['is_callable'] ) && is_callable( $this->plugins[$slug]['is_callable'] ) ) |
|
1869 | + || ( ! empty( $this->plugins[$slug]['class_exists'] ) && class_exists( $this->plugins[$slug]['class_exists'] ) ) |
|
1870 | + || is_plugin_active( $this->plugins[$slug]['file_path'] ) ); |
|
1871 | 1871 | } |
1872 | 1872 | |
1873 | 1873 | /** |
@@ -1881,7 +1881,7 @@ discard block |
||
1881 | 1881 | */ |
1882 | 1882 | public function can_plugin_update( $slug ) { |
1883 | 1883 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1884 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1884 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
1885 | 1885 | return true; |
1886 | 1886 | } |
1887 | 1887 | |
@@ -1937,8 +1937,8 @@ discard block |
||
1937 | 1937 | public function get_installed_version( $slug ) { |
1938 | 1938 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). |
1939 | 1939 | |
1940 | - if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { |
|
1941 | - return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; |
|
1940 | + if ( ! empty( $installed_plugins[$this->plugins[$slug]['file_path']]['Version'] ) ) { |
|
1941 | + return $installed_plugins[$this->plugins[$slug]['file_path']]['Version']; |
|
1942 | 1942 | } |
1943 | 1943 | |
1944 | 1944 | return ''; |
@@ -1954,7 +1954,7 @@ discard block |
||
1954 | 1954 | */ |
1955 | 1955 | public function does_plugin_require_update( $slug ) { |
1956 | 1956 | $installed_version = $this->get_installed_version( $slug ); |
1957 | - $minimum_version = $this->plugins[ $slug ]['version']; |
|
1957 | + $minimum_version = $this->plugins[$slug]['version']; |
|
1958 | 1958 | |
1959 | 1959 | return version_compare( $minimum_version, $installed_version, '>' ); |
1960 | 1960 | } |
@@ -1969,9 +1969,9 @@ discard block |
||
1969 | 1969 | */ |
1970 | 1970 | public function does_plugin_have_update( $slug ) { |
1971 | 1971 | // Presume bundled and external plugins will point to a package which meets the minimum required version. |
1972 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1972 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
1973 | 1973 | if ( $this->does_plugin_require_update( $slug ) ) { |
1974 | - return $this->plugins[ $slug ]['version']; |
|
1974 | + return $this->plugins[$slug]['version']; |
|
1975 | 1975 | } |
1976 | 1976 | |
1977 | 1977 | return false; |
@@ -1979,8 +1979,8 @@ discard block |
||
1979 | 1979 | |
1980 | 1980 | $repo_updates = get_site_transient( 'update_plugins' ); |
1981 | 1981 | |
1982 | - if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { |
|
1983 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; |
|
1982 | + if ( isset( $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version ) ) { |
|
1983 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->new_version; |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | return false; |
@@ -1996,14 +1996,14 @@ discard block |
||
1996 | 1996 | */ |
1997 | 1997 | public function get_upgrade_notice( $slug ) { |
1998 | 1998 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. |
1999 | - if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { |
|
1999 | + if ( 'repo' !== $this->plugins[$slug]['source_type'] ) { |
|
2000 | 2000 | return ''; |
2001 | 2001 | } |
2002 | 2002 | |
2003 | 2003 | $repo_updates = get_site_transient( 'update_plugins' ); |
2004 | 2004 | |
2005 | - if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { |
|
2006 | - return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; |
|
2005 | + if ( ! empty( $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice ) ) { |
|
2006 | + return $repo_updates->response[$this->plugins[$slug]['file_path']]->upgrade_notice; |
|
2007 | 2007 | } |
2008 | 2008 | |
2009 | 2009 | return ''; |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | */ |
2088 | 2088 | if ( true === $plugin['force_deactivation'] && is_plugin_active( $plugin['file_path'] ) ) { |
2089 | 2089 | deactivate_plugins( $plugin['file_path'] ); |
2090 | - $deactivated[ $plugin['file_path'] ] = time(); |
|
2090 | + $deactivated[$plugin['file_path']] = time(); |
|
2091 | 2091 | } |
2092 | 2092 | } |
2093 | 2093 | |
@@ -2324,30 +2324,30 @@ discard block |
||
2324 | 2324 | $i = 0; |
2325 | 2325 | |
2326 | 2326 | // Redirect to the 'all' view if no plugins were found for the selected view context. |
2327 | - if ( empty( $plugins[ $this->view_context ] ) ) { |
|
2327 | + if ( empty( $plugins[$this->view_context] ) ) { |
|
2328 | 2328 | $this->view_context = 'all'; |
2329 | 2329 | } |
2330 | 2330 | |
2331 | - foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
|
2332 | - $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
|
2333 | - $table_data[ $i ]['slug'] = $slug; |
|
2334 | - $table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2335 | - $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2336 | - $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2337 | - $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
|
2338 | - $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2339 | - $table_data[ $i ]['minimum_version'] = $plugin['version']; |
|
2340 | - $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2331 | + foreach ( $plugins[$this->view_context] as $slug => $plugin ) { |
|
2332 | + $table_data[$i]['sanitized_plugin'] = $plugin['name']; |
|
2333 | + $table_data[$i]['slug'] = $slug; |
|
2334 | + $table_data[$i]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
|
2335 | + $table_data[$i]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
|
2336 | + $table_data[$i]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
|
2337 | + $table_data[$i]['status'] = $this->get_plugin_status_text( $slug ); |
|
2338 | + $table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
|
2339 | + $table_data[$i]['minimum_version'] = $plugin['version']; |
|
2340 | + $table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
|
2341 | 2341 | |
2342 | 2342 | // Prep the upgrade notice info. |
2343 | 2343 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
2344 | 2344 | if ( ! empty( $upgrade_notice ) ) { |
2345 | - $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
|
2345 | + $table_data[$i]['upgrade_notice'] = $upgrade_notice; |
|
2346 | 2346 | |
2347 | 2347 | add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
2348 | 2348 | } |
2349 | 2349 | |
2350 | - $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); |
|
2350 | + $table_data[$i] = apply_filters( 'tgmpa_table_data_item', $table_data[$i], $plugin ); |
|
2351 | 2351 | |
2352 | 2352 | $i++; |
2353 | 2353 | } |
@@ -2373,17 +2373,17 @@ discard block |
||
2373 | 2373 | // No need to display plugins if they are installed, up-to-date and active. |
2374 | 2374 | continue; |
2375 | 2375 | } else { |
2376 | - $plugins['all'][ $slug ] = $plugin; |
|
2376 | + $plugins['all'][$slug] = $plugin; |
|
2377 | 2377 | |
2378 | 2378 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
2379 | - $plugins['install'][ $slug ] = $plugin; |
|
2379 | + $plugins['install'][$slug] = $plugin; |
|
2380 | 2380 | } else { |
2381 | 2381 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
2382 | - $plugins['update'][ $slug ] = $plugin; |
|
2382 | + $plugins['update'][$slug] = $plugin; |
|
2383 | 2383 | } |
2384 | 2384 | |
2385 | 2385 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
2386 | - $plugins['activate'][ $slug ] = $plugin; |
|
2386 | + $plugins['activate'][$slug] = $plugin; |
|
2387 | 2387 | } |
2388 | 2388 | } |
2389 | 2389 | } |
@@ -2401,7 +2401,7 @@ discard block |
||
2401 | 2401 | */ |
2402 | 2402 | protected function set_view_totals( $plugins ) { |
2403 | 2403 | foreach ( $plugins as $type => $list ) { |
2404 | - $this->view_totals[ $type ] = count( $list ); |
|
2404 | + $this->view_totals[$type] = count( $list ); |
|
2405 | 2405 | } |
2406 | 2406 | } |
2407 | 2407 | |
@@ -2503,8 +2503,8 @@ discard block |
||
2503 | 2503 | $name = array(); |
2504 | 2504 | |
2505 | 2505 | foreach ( $items as $i => $plugin ) { |
2506 | - $type[ $i ] = $plugin['type']; // Required / recommended. |
|
2507 | - $name[ $i ] = $plugin['sanitized_plugin']; |
|
2506 | + $type[$i] = $plugin['type']; // Required / recommended. |
|
2507 | + $name[$i] = $plugin['sanitized_plugin']; |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
@@ -2551,7 +2551,7 @@ discard block |
||
2551 | 2551 | |
2552 | 2552 | if ( ! empty( $text ) ) { |
2553 | 2553 | |
2554 | - $status_links[ $type ] = sprintf( |
|
2554 | + $status_links[$type] = sprintf( |
|
2555 | 2555 | '<a href="%s"%s>%s</a>', |
2556 | 2556 | esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), |
2557 | 2557 | ( $type === $this->view_context ) ? ' class="current"' : '', |
@@ -2574,7 +2574,7 @@ discard block |
||
2574 | 2574 | * @return string |
2575 | 2575 | */ |
2576 | 2576 | public function column_default( $item, $column_name ) { |
2577 | - return $item[ $column_name ]; |
|
2577 | + return $item[$column_name]; |
|
2578 | 2578 | } |
2579 | 2579 | |
2580 | 2580 | /** |
@@ -2774,7 +2774,7 @@ discard block |
||
2774 | 2774 | 'tgmpa-nonce' |
2775 | 2775 | ); |
2776 | 2776 | |
2777 | - $action_links[ $action ] = sprintf( |
|
2777 | + $action_links[$action] = sprintf( |
|
2778 | 2778 | '<a href="%1$s">' . esc_html( $text ) . '</a>', // $text contains the second placeholder. |
2779 | 2779 | esc_url( $nonce_url ), |
2780 | 2780 | '<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
@@ -2925,19 +2925,19 @@ discard block |
||
2925 | 2925 | // Validate the received input. |
2926 | 2926 | foreach ( $plugins_to_install as $key => $slug ) { |
2927 | 2927 | // Check if the plugin was registered with TGMPA and remove if not. |
2928 | - if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { |
|
2929 | - unset( $plugins_to_install[ $key ] ); |
|
2928 | + if ( ! isset( $this->tgmpa->plugins[$slug] ) ) { |
|
2929 | + unset( $plugins_to_install[$key] ); |
|
2930 | 2930 | continue; |
2931 | 2931 | } |
2932 | 2932 | |
2933 | 2933 | // For install: make sure this is a plugin we *can* install and not one already installed. |
2934 | 2934 | if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) { |
2935 | - unset( $plugins_to_install[ $key ] ); |
|
2935 | + unset( $plugins_to_install[$key] ); |
|
2936 | 2936 | } |
2937 | 2937 | |
2938 | 2938 | // For updates: make sure this is a plugin we *can* update (update available and WP version ok). |
2939 | 2939 | if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) { |
2940 | - unset( $plugins_to_install[ $key ] ); |
|
2940 | + unset( $plugins_to_install[$key] ); |
|
2941 | 2941 | } |
2942 | 2942 | } |
2943 | 2943 | |
@@ -2989,7 +2989,7 @@ discard block |
||
2989 | 2989 | |
2990 | 2990 | // Prepare the data for validated plugins for the install/upgrade. |
2991 | 2991 | foreach ( $plugins_to_install as $slug ) { |
2992 | - $name = $this->tgmpa->plugins[ $slug ]['name']; |
|
2992 | + $name = $this->tgmpa->plugins[$slug]['name']; |
|
2993 | 2993 | $source = $this->tgmpa->get_download_url( $slug ); |
2994 | 2994 | |
2995 | 2995 | if ( ! empty( $name ) && ! empty( $source ) ) { |
@@ -3002,9 +3002,9 @@ discard block |
||
3002 | 3002 | break; |
3003 | 3003 | |
3004 | 3004 | case 'update': |
3005 | - $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
3006 | - $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
|
3007 | - $to_inject[ $slug ]['source'] = $source; |
|
3005 | + $file_paths[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
3006 | + $to_inject[$slug] = $this->tgmpa->plugins[$slug]; |
|
3007 | + $to_inject[$slug]['source'] = $source; |
|
3008 | 3008 | break; |
3009 | 3009 | } |
3010 | 3010 | } |
@@ -3071,8 +3071,8 @@ discard block |
||
3071 | 3071 | // Grab the file paths for the selected & inactive plugins from the registration array. |
3072 | 3072 | foreach ( $plugins as $slug ) { |
3073 | 3073 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
3074 | - $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
|
3075 | - $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
|
3074 | + $plugins_to_activate[] = $this->tgmpa->plugins[$slug]['file_path']; |
|
3075 | + $plugin_names[] = $this->tgmpa->plugins[$slug]['name']; |
|
3076 | 3076 | } |
3077 | 3077 | } |
3078 | 3078 | unset( $slug ); |
@@ -3104,8 +3104,8 @@ discard block |
||
3104 | 3104 | // Update recently activated plugins option. |
3105 | 3105 | $recent = (array) get_option( 'recently_activated' ); |
3106 | 3106 | foreach ( $plugins_to_activate as $plugin => $time ) { |
3107 | - if ( isset( $recent[ $plugin ] ) ) { |
|
3108 | - unset( $recent[ $plugin ] ); |
|
3107 | + if ( isset( $recent[$plugin] ) ) { |
|
3108 | + unset( $recent[$plugin] ); |
|
3109 | 3109 | } |
3110 | 3110 | } |
3111 | 3111 | update_option( 'recently_activated', $recent ); |
@@ -3436,7 +3436,7 @@ discard block |
||
3436 | 3436 | ) |
3437 | 3437 | ); |
3438 | 3438 | |
3439 | - $results[ $plugin ] = $this->result; |
|
3439 | + $results[$plugin] = $this->result; |
|
3440 | 3440 | |
3441 | 3441 | // Prevent credentials auth screen from displaying multiple times. |
3442 | 3442 | if ( false === $result ) { |
@@ -3626,7 +3626,7 @@ discard block |
||
3626 | 3626 | 'names' => array(), |
3627 | 3627 | 'install_type' => 'install', |
3628 | 3628 | ); |
3629 | - $args = wp_parse_args( $args, $defaults ); |
|
3629 | + $args = wp_parse_args( $args, $defaults ); |
|
3630 | 3630 | |
3631 | 3631 | // Set plugin names to $this->plugin_names property. |
3632 | 3632 | $this->plugin_names = $args['names']; |
@@ -3688,7 +3688,7 @@ discard block |
||
3688 | 3688 | */ |
3689 | 3689 | public function before( $title = '' ) { |
3690 | 3690 | if ( empty( $title ) ) { |
3691 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3691 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
3692 | 3692 | } |
3693 | 3693 | parent::before( $title ); |
3694 | 3694 | } |
@@ -3705,7 +3705,7 @@ discard block |
||
3705 | 3705 | */ |
3706 | 3706 | public function after( $title = '' ) { |
3707 | 3707 | if ( empty( $title ) ) { |
3708 | - $title = esc_html( $this->plugin_names[ $this->i ] ); |
|
3708 | + $title = esc_html( $this->plugin_names[$this->i] ); |
|
3709 | 3709 | } |
3710 | 3710 | parent::after( $title ); |
3711 | 3711 | |
@@ -3878,7 +3878,7 @@ discard block |
||
3878 | 3878 | */ |
3879 | 3879 | protected static function emulate_filter_bool( $value ) { |
3880 | 3880 | // @codingStandardsIgnoreStart |
3881 | - static $true = array( |
|
3881 | + static $true = array( |
|
3882 | 3882 | '1', |
3883 | 3883 | 'true', 'True', 'TRUE', |
3884 | 3884 | 'y', 'Y', |
@@ -121,16 +121,16 @@ |
||
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( |