Skip to content

Commit

Permalink
Merge pull request #331 from thomasgriffin/feature/minor-code-inspect…
Browse files Browse the repository at this point in the history
…ion-issues

Fix some minor issues detected in code inspection
  • Loading branch information
GaryJones committed Apr 24, 2015
2 parents 13a1c22 + 65f2395 commit d515000
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* TGMPA is now a singleton to prevent extra settings overrides.
* Fixed bug with duplicating plugins if multiple themes/plugins that used TGMPA were active at the same time.
* Added contextual message updates depending on WordPress version.
* Better nag message handling. If the nag has been dimissed, don't even attempt to build message (performance enhancement).
* Ensure class can only be instantiated once (instantion moved inside the `class_exists` check for TGMPA).
* Better nag message handling. If the nag has been dismissed, don't even attempt to build message (performance enhancement).
* Ensure class can only be instantiated once (instantiation moved inside the `class_exists` check for TGMPA).
* Change instances of `admin_url` to `network_admin_url` to add better support for MultiSite (falls back gracefully for non-MultiSite installs).
* Updated much of the code to match WP Coding Standards (braces, yoda conditionals, etc.).
* Myriads of other bug fixes and enhancements
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ and amend to suit. The `example.php` file is a model for how you should include

See https://github.com/thomasgriffin/TGM-Plugin-Activation/issues for current issues and for reporting bugs and enhancements.

Note that the authors of TGM Plugin Activation library are not resposible for the end-user support for any plugin or theme which uses the library.
Note that the authors of TGM Plugin Activation library are not responsible for the end-user support for any plugin or theme which uses the library.

## Changelog

Expand Down
55 changes: 25 additions & 30 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TGM_Plugin_Activation {
public $id = 'tgmpa';

/**
* Name of the querystring argument for the admin page.
* Name of the query-string argument for the admin page.
*
* @since 1.0.0
*
Expand Down Expand Up @@ -296,7 +296,7 @@ public function init() {
* than the typical plugin-install.php file, so we can prepare everything
* beforehand.
*
* WP doesn't make it easy to show the plugin information in the thickbox -
* WP does not make it easy to show the plugin information in the thickbox -
* here we have to require a file that includes a function that does the
* main work of displaying it, enqueue some styles, set up some globals and
* finally call that function before exiting.
Expand Down Expand Up @@ -331,7 +331,7 @@ public function admin_init() {
}

/**
* Enqueues thickbox scripts/styles for plugin info.
* Enqueue thickbox scripts/styles for plugin info.
*
* Thickbox is not automatically included on all admin pages, so we must
* manually enqueue it for those pages.
Expand Down Expand Up @@ -640,8 +640,8 @@ protected function do_plugin_install() {
* as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to
* the expected plugin slug.
*
* @param string $source Path to upgrade/zipfilename.tmp/subdirectory/
* @param string $remote_source Path to upgrade/zipfilename.tmp
* @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/
* @param string $remote_source Path to upgrade/zip-file-name.tmp
* @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin
*
* @return string $source
Expand Down Expand Up @@ -972,8 +972,8 @@ public function config( $config ) {
foreach ( $keys as $key ) {
if ( isset( $config[ $key ] ) ) {
if ( is_array( $config[ $key ] ) ) {
foreach ( $config[ $key ] as $subkey => $value ) {
$this->{$key}[ $subkey ] = $value;
foreach ( $config[ $key ] as $sub_key => $value ) {
$this->{$key}[ $sub_key ] = $value;
}
}
else {
Expand Down Expand Up @@ -1066,7 +1066,7 @@ protected function _get_plugin_basename_from_slug( $slug ) {
*/
protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {

foreach ( $this->plugins as $plugin => $values ) {
foreach ( $this->plugins as $values ) {
if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
return $values[ $data ];
}
Expand Down Expand Up @@ -1187,7 +1187,9 @@ public static function get_instance() {
}

if ( ! function_exists( 'load_tgm_plugin_activation' ) ) {
// Ensure only one instance of the class is ever invoked.
/**
* Ensure only one instance of the class is ever invoked.
*/
function load_tgm_plugin_activation() {
$GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance();
}
Expand Down Expand Up @@ -1421,14 +1423,7 @@ protected function _gather_plugin_data() {
*/
protected function _get_plugin_data_from_name( $name, $data = 'slug' ) {

foreach ( $this->tgmpa->plugins as $plugin => $values ) {
if ( $name === $values['name'] && isset( $values[ $data ] ) ) {
return $values[ $data ];
}
}

return false;

return $this->tgmpa->_get_plugin_data_from_name( $name, $data );
}

/**
Expand Down Expand Up @@ -1458,14 +1453,10 @@ public function column_default( $item, $column_name ) {
public function column_plugin( $item ) {

$installed_plugins = get_plugins();

// No need to display any hover links.
if ( is_plugin_active( $item['file_path'] ) ) {
$actions = array();
}
$actions = array();

// We need to display the 'Install' hover link.
if ( ! isset( $installed_plugins[ $item['file_path'] ] ) ) {
if ( ! is_plugin_active( $item['file_path'] ) || ! isset( $installed_plugins[ $item['file_path'] ] ) ) {
$install_nonce_url = wp_nonce_url(
add_query_arg(
array(
Expand Down Expand Up @@ -1662,7 +1653,7 @@ public function process_bulk_actions() {
if ( isset( $_GET['plugin_paths'] ) ) {
$plugin_paths = explode( ',', stripslashes( $_GET['plugin_paths'] ) );
}
// Looks like the user doesn't need to enter his FTP creds.
// Looks like the user doesn't need to enter his FTP credentials.
elseif ( isset( $_POST['plugin'] ) ) {
$plugin_paths = (array) $plugin_path;
}
Expand All @@ -1675,7 +1666,7 @@ public function process_bulk_actions() {
if ( isset( $_GET['plugin_names'] ) ) {
$plugin_names = explode( ',', stripslashes( $_GET['plugin_names'] ) );
}
// Looks like the user doesn't need to enter his FTP creds.
// Looks like the user doesn't need to enter his FTP credentials.
elseif ( isset( $_POST['plugin'] ) ) {
$plugin_names = (array) $plugin_name;
}
Expand Down Expand Up @@ -1751,7 +1742,6 @@ public function process_bulk_actions() {
// Store all information in arrays since we are processing a bulk installation.
$api = array();
$sources = array();
$install_path = array();

// Loop through each plugin to install and try to grab information from WordPress API, if not create 'tgmpa-empty' scalar.
$i = 0;
Expand Down Expand Up @@ -1814,7 +1804,7 @@ public function process_bulk_actions() {
$plugins_to_activate = array();

// Split plugin value into array with plugin file path, plugin source and plugin name.
foreach ( $plugins as $i => $plugin ) {
foreach ( $plugins as $plugin ) {
$plugins_to_activate[] = explode( ',', $plugin );
}

Expand Down Expand Up @@ -1867,6 +1857,8 @@ public function process_bulk_actions() {

return true;
}

return false;
}

/**
Expand Down Expand Up @@ -1897,13 +1889,16 @@ public function prepare_items() {
* we load it here.
*
* We check to make sure no action or activation keys are set so that WordPress
* doesn't try to re-include the class when processing upgrades or installs outside
* does not try to re-include the class when processing upgrades or installs outside
* of the class.
*
* @since 2.2.0
*/
add_action( 'admin_init', 'tgmpa_load_bulk_installer' );
if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) {
/**
* Load bulk installer
*/
function tgmpa_load_bulk_installer() {
// Get TGMPA class instance
$tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
Expand Down Expand Up @@ -2215,9 +2210,9 @@ public function plugin_info() {
}

// Assume the requested plugin is the first in the list.
$pluginfiles = array_keys( $plugin );
$plugin_files = array_keys( $plugin );

return $this->result['destination_name'] . '/' . $pluginfiles[0];
return $this->result['destination_name'] . '/' . $plugin_files[0];

}

Expand Down
2 changes: 1 addition & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function my_theme_register_required_plugins() {
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* Some of the strings are wrapped in a sprintf(), so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
Expand Down

0 comments on commit d515000

Please sign in to comment.