errors[] = $message; break; case 'message': $this->messages[] = $message; break; case 'warning': $this->warnings[] = $message; break; } } /** * Add footer link to specific ( errors|messages|wanrnings ) block * * @author peshkov@UD */ public function add_action_link( $link, $type = 'error' ) { switch( $type ) { case 'error': $this->action_links[ 'errors' ][] = $link; break; case 'message': $this->action_links[ 'messages' ][] = $link; break; case 'message': $this->action_links[ 'warnings' ][] = $link; break; } } /** * Determine if errors exist * * @author peshkov@UD */ public function has_errors() { return !empty( $this->errors ) ? true : false; } /** * Renders admin notes in case there are errors or notices on bootstrap init * * @author peshkov@UD */ public function admin_notices() { global $wp_version; //** Don't show the message if the user has no enough permissions. */ if ( ! function_exists( 'wp_get_current_user' ) ) { require_once( ABSPATH . 'wp-includes/pluggable.php' ); } if( empty( $this->args['type'] ) || ( $this->args['type'] == 'plugin' && !current_user_can( 'activate_plugins' ) ) || ( $this->args['type'] == 'theme' && !current_user_can( 'switch_themes' ) ) ) { return; } //** Don't show the message if on a multisite and the user isn't a super user. */ if ( is_multisite() && ! is_super_admin() ) { return; } //** Ignore messages on TGM Plugin Activation page */ if( TGM_Plugin_Activation::get_instance()->is_tgmpa_page() ) { return; } $errors = apply_filters( 'ud:errors:admin_notices', $this->errors, $this->args ); $messages = apply_filters( 'ud:messages:admin_notices', $this->messages, $this->args ); $warnings = apply_filters( 'ud:warnings:admin_notices', $this->warnings, $this->args ); if( !empty( $errors ) || !empty( $messages ) || !empty( $warnings ) ) { echo ""; } //** Errors Block */ if( !empty( $errors ) && is_array( $errors ) ) { $message = '
%s is not active due to following errors:
%s', $this->domain ), $this->name, $message ); if( !empty( $this->action_links[ 'errors' ] ) && is_array( $this->action_links[ 'errors' ] ) ) { $message .= '' . implode( ' | ', $this->action_links[ 'errors' ] ) . '
'; } echo '%s has the following warnings:
%s', $this->domain ), $this->name, $message ); if( $this->dismiss ) { $this->action_links[ 'warnings' ][] = '' . __( 'Dismiss this warning', $this->domain ) . ''; } if( !empty( $this->action_links[ 'warnings' ] ) && is_array( $this->action_links[ 'warnings' ] ) ) { $message .= '' . implode( ' | ', $this->action_links[ 'warnings' ] ) . '
'; } echo '%s has the following additional notices:
%s', $this->domain ), $this->name, $message ); } else { $message = sprintf( __( '%s is active, but has the following notices:
%s', $this->domain ), $this->name, $message ); } if( $this->dismiss ) { $this->action_links[ 'messages' ][] = '' . __( 'Dismiss this notice', $this->domain ) . ''; } $message .= '' . implode( ' | ', $this->action_links[ 'messages' ] ) . '
'; echo '