-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/simplify passed info #368
Conversation
- register plugins with the $slug as array key - ensure that all plugins have defaults registered for the keys not passed - add `$has_forced_activation` and `$has_forced_deactivation` properties to the TGMPA class which are set from the plugin registration method and used to determine whether to add the relevant actions - add `$sort_order` property which holds the plugin names for use in sorting the `$plugins` property for internal use - as - no matter what - we'll always need the file_path, we might as well also set it in the registration method and get rid of the repeated calls to `$this->populate_file_path()` - also made the `populate_file_path()` a little bit more flexible so it can be used in a leaner manner for those cases where it's still needed
- retrieve most information we need from our `$plugins` array rather than pass it through URL or $_POST - properly sanitize and validate received information from URL or $_POST - leverage the use of the WP_filesystem API - show an appropriate error message if user tries to activate an already active plugin - deprecate the `TGMPA_List_Table::_get_plugin_data_from_name()` method which is no longer needed as we have access to the `TGM_Plugin_Activation::_get_plugin_data_from_name()` method - Fix unauthorized issue on bulk installs when not using direct file access caused by #227 - Only prepare some variables and update recently activated plugins option when we actually need to Also: - abstract the regexes which are used a number of times to class constants - combine multiple `isset()`'s if used within the same if statement - don't nest what doesn't need nesting - unset loop variables if the function doesn't return straight after
…ion into feature/simplify-passed-info
@@ -758,17 +775,17 @@ public function notices() { | |||
$install_link = true; // We need to display the 'install' action link. | |||
$install_link_count++; // Increment the install link count. | |||
if ( current_user_can( 'install_plugins' ) ) { | |||
if ( isset( $plugin['required'] ) && $plugin['required'] ) { | |||
$message['notice_can_install_required'][] = $plugin['name']; | |||
if ( true === $plugin['required'] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about if the user has registered slightly incorrect as a string:
required => 'true',
? We should allow a little leeway for 2.5, and then make it stricter for 3.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some type casting to the registration method now to account for this. Using some of the filter/filter emulate code I pointed to elsewhere from the WPSEO plugin. Not giving credit to them as I wrote it ;-)
Phew! Excellent stuff. I realise some of my suggestions may well be other PRs once this is merged, but wanted to mention them to get them on your radar if they weren't already. |
Most notable addition is a new class with two new validation methods for validating booleans and the use of this code in the plugin registration function
516c3b8
to
5650c61
Compare
Simplify the handling of information that is passed around.
Tested reasonably extensively
Improve plugin registration method
$slug
as associative array key$has_forced_activation
and$has_forced_deactivation
properties to the TGMPA class which are set from the plugin registration method and used to determine whether to add the relevant actions$sort_order
property which holds the plugin names for use in sorting the$plugins
property for internal usefile_path
, we might as well also set it in the registration method and get rid of the repeated calls to$this->populate_file_path()
populate_file_path()
a little bit more flexible so it can be used in a leaner manner for those cases where it's still neededSimplify the table generation, install and activate code
$plugins
array rather than pass it through URL or$_POST
$_POST
TGMPA_List_Table::_get_plugin_data_from_name()
method which is no longer needed as we have access to theTGM_Plugin_Activation::_get_plugin_data_from_name()
methodAlso:
isset()
's if used within the same if statement