Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function notices() {
- global $current_screen;
- // Remove nag on the install pages
- if ( 'appearance_page_' . $this->menu == $current_screen->id )
- return;
- $installed_plugins = get_plugins(); // Retrieve a list of all the plugins
- $this->populate_file_path();
- $message = array();
- foreach ( $this->plugins as $plugin ) {
- if ( is_plugin_active( $plugin['file_path'] ) ) // If the plugin is active, no need to display nag
- continue;
- $already_dismissed = explode( ', ', (string) get_user_meta( get_current_user_id(), 'dismissed_admin_notices', true ) );
- if ( ! in_array( $plugin['slug'], $already_dismissed ) ) { // Don't display if users have dismissed
- if ( ! isset( $installed_plugins[$plugin['file_path']] ) ) { // Not installed
- if ( current_user_can( 'install_plugins' ) ) {
- if ( $plugin['required'] ) {
- $message['notice_can_install'][] = $plugin['name'];
- $message['notice_can_install'][] .= sprintf( $this->strings['notice_can_install'], '<em>' . $plugin['name'] . '</em>', add_query_arg( 'page', $this->menu, admin_url( 'themes.php' ) ) );
- $message['notice_can_install'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
- }
- else { // This plugin is only recommended
- $message['notice_can_install_recommended'][] = $plugin['name'];
- $message['notice_can_install_recommended'][] .= sprintf( $this->strings['notice_can_install_recommended'], '<em>' . $plugin['name'] . '</em>', add_query_arg( 'page', $this->menu, admin_url( 'themes.php' ) ) );
- $message['notice_can_install_recommended'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
- }
- } else { // Need higher privileges to install the plugin
- $message['notice_cannot_install'][] = $plugin['name'];
- $message['notice_cannot_install'][] .= sprintf( $this->strings['notice_cannot_install'], '<em>' . $plugin['name'] . '</em>' );
- $message['notice_cannot_install'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
- }
- } elseif ( is_plugin_inactive( $plugin['file_path'] ) ) { // Installed but not active
- if ( current_user_can( 'activate_plugins' ) ) {
- if ( $plugin['required'] ) {
- $message['notice_can_activate'][] = $plugin['name'];
- $message['notice_can_activate'][] .= sprintf( $this->strings['notice_can_activate'], '<em>' . $plugin['name'] . '</em>', admin_url( 'plugins.php' ) );
- $message['notice_can_activate'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
- }
- else { // This plugin is only recommended
- $message['notice_can_activate_recommended'][] = $plugin['name'];
- $message['notice_can_activate_recommended'][] .= sprintf( $this->strings['notice_can_activate_recommended'], '<em>' . $plugin['name'] . '</em>', admin_url( 'plugins.php' ) );
- $message['notice_can_activate_recommended'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
- }
- } else { // Need higher privileges to activate the plugin
- $message['notice_cannot_activate'][] = $plugin['name'];
- $message['notice_cannot_activate'][] .= sprintf( $this->strings['notice_cannot_activate'], '<em>' . $plugin['name'] . '</em>' );
- $message['notice_cannot_activate'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
- }
- }
- }
- }
- if ( ! empty( $message ) )
- add_settings_error( 'tgmpa', 'tgmpa', $message, 'updated' );
- settings_errors( 'tgmpa' );
- }
Add Comment
Please, Sign In to add comment