What UI elements to remove?
afragen opened this issue · comments
@Raruto I will consider a filter or 2 for you to eliminate various UI elements we disagree on.
Can you list them here please?
I added some notes here: #55
Can't you directly edit the pull code instead of working separately? (otherwise it's quite difficult to follow your progress)
Can we just work without a PR yet. I'll figure out the filters. I just want to know what would make you happy, not ecstatic, just happy. I do not plan on adding any more notices.
Can we just work without a PR yet. I'll figure out the filters. I just want to know what would make you happy, not ecstatic, just happy.
Each added element must be able to be selectively deactivated (not a single filter that disables everything). This would be the end result for a Required Plugin
with all the customizations turned off .
I do not plan on adding any more notices.
And it is also for this reason that (in that pull) I did something like this:
if ( $this->is_active( $slug ) ) {
// Do nothing.
} elseif ( $this->is_installed( $slug ) ) {
if ( $is_required ) {
$this->notices[] = $this->activate( $slug );
} else {
$this->notices[] = $this->activate_notice( $slug );
}
} else {
if ( $is_required ) {
$this->notices[] = $this->install( $slug );
} else {
$this->notices[] = $this->install_notice( $slug );
}
}
// Added at this point allows both:
// - to disable default notifications
// - to insert custom ones (keeping the right order)
// - and lastly to keep the code readable
$this->notices = apply_filters( 'wp_dependency_notices', $this->notices, $slug );
And this is the usual example of usage:
add_filter( 'wp_dependency_notices', 'wpdi_notices', 10, 2 );
/**
* Get plugin notices.
*
* @param string $slug Plugin slug.
*
* @return array Admin notices.
*/
function wpdi_notices( $notices, $slug ) {
$wpdi = WP_Dependency_Installer::instance();
if ( ! $wpdi->is_active( $slug ) ) {
return $notices;
}
$dependency = $wpdi->get_config( $slug );
foreach ( $dependency['sources'] as $source ) {
// Check if we were trying to deactivate a manadatory plugin.
if ( isset( $_REQUEST['wpdi_required'] ) && $slug === $_REQUEST['wpdi_required'] ) {
array_unshift(
$notices, [
'status' => 'error',
/* translators: %s: Plugin name */
'message' => sprintf( esc_html__( 'The %s plugin is a mandatory plugin.' ), $dependency['name'] ),
'source' => $source,
]
);
}
}
return $notices;
}
Can't you directly edit the pull code instead of working separately? (otherwise it's quite difficult to follow your progress)
Can we just work without a PR yet.
I wasn't referring to this issue...
Can I add them to wiki or do you want to rename / edit them?
I think the filter names are fine, unless you can thing of better.
Here it is: wiki/Actions-and-Hooks