Fix usage of admin notices
shadyvb opened this issue · comments
Shady Sharaf commented
Checking this add_action( 'all_admin_notices', array( __CLASS__, 'admin_notices' ) );
and seeing that the callback function admin_notices( $message, $is_error = true )
actually needs argument to display messages, makes the action registration pointless.
However, that same callback is used directly like in :
public static function fail_php_version() {
add_action( 'plugins_loaded', array( __CLASS__, 'i18n' ) );
self::notice( __( 'Stream requires PHP version 5.3+, plugin is currently NOT ACTIVE.', 'stream' ) );
}
defined here
public static function notice( $message, $is_error = true ) {
if ( defined( 'WP_CLI' ) ) {
$message = strip_tags( $message );
if ( $is_error ) {
WP_CLI::warning( $message );
} else {
WP_CLI::success( $message );
}
} else {
self::admin_notices( $message, $is_error );
}
}
I recall there was some logic to retain messages locally in the class and then outputting in via the callback registered to that action. Anyway, we need to fix that.