Guest User

Untitled

a guest
Jan 23rd, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.14 KB | None | 0 0
  1.     public function notices() {
  2.  
  3.         global $current_screen;
  4.  
  5.         // Remove nag on the install pages
  6.         if ( 'appearance_page_' . $this->menu == $current_screen->id )
  7.             return;
  8.  
  9.         $installed_plugins = get_plugins(); // Retrieve a list of all the plugins
  10.  
  11.         $this->populate_file_path();
  12.  
  13.         $message = array();
  14.  
  15.         foreach ( $this->plugins as $plugin ) {
  16.  
  17.             if ( is_plugin_active( $plugin['file_path'] ) ) // If the plugin is active, no need to display nag
  18.                 continue;
  19.  
  20.             $already_dismissed = explode( ', ', (string) get_user_meta( get_current_user_id(), 'dismissed_admin_notices', true ) );
  21.  
  22.             if ( ! in_array( $plugin['slug'], $already_dismissed ) ) { // Don't display if users have dismissed
  23.  
  24.                 if ( ! isset( $installed_plugins[$plugin['file_path']] ) ) { // Not installed
  25.  
  26.                     if ( current_user_can( 'install_plugins' ) ) {
  27.  
  28.                         if ( $plugin['required'] ) {
  29.                             $message['notice_can_install'][] = $plugin['name'];
  30.                             $message['notice_can_install'][] .= sprintf( $this->strings['notice_can_install'], '<em>' . $plugin['name'] . '</em>', add_query_arg( 'page', $this->menu, admin_url( 'themes.php' ) ) );
  31.                             $message['notice_can_install'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
  32.                         }
  33.                         else { // This plugin is only recommended
  34.                             $message['notice_can_install_recommended'][] = $plugin['name'];
  35.                             $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' ) ) );
  36.                             $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 />';
  37.                         }
  38.  
  39.                     } else { // Need higher privileges to install the plugin
  40.                         $message['notice_cannot_install'][] = $plugin['name'];
  41.                         $message['notice_cannot_install'][] .= sprintf( $this->strings['notice_cannot_install'], '<em>' . $plugin['name'] . '</em>' );
  42.                         $message['notice_cannot_install'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
  43.                     }
  44.  
  45.                 } elseif ( is_plugin_inactive( $plugin['file_path'] ) ) { // Installed but not active
  46.  
  47.                     if ( current_user_can( 'activate_plugins' ) ) {
  48.  
  49.                         if ( $plugin['required'] ) {
  50.                             $message['notice_can_activate'][] = $plugin['name'];
  51.                             $message['notice_can_activate'][] .= sprintf( $this->strings['notice_can_activate'], '<em>' . $plugin['name'] . '</em>', admin_url( 'plugins.php' ) );
  52.                             $message['notice_can_activate'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
  53.                         }
  54.                         else { // This plugin is only recommended
  55.                             $message['notice_can_activate_recommended'][] = $plugin['name'];
  56.                             $message['notice_can_activate_recommended'][] .= sprintf( $this->strings['notice_can_activate_recommended'], '<em>' . $plugin['name'] . '</em>', admin_url( 'plugins.php' ) );
  57.                             $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 />';
  58.                         }
  59.  
  60.                     } else { // Need higher privileges to activate the plugin
  61.                         $message['notice_cannot_activate'][] = $plugin['name'];
  62.                         $message['notice_cannot_activate'][] .= sprintf( $this->strings['notice_cannot_activate'], '<em>' . $plugin['name'] . '</em>' );
  63.                         $message['notice_cannot_activate'][] .= ' <a class="dismiss-notice" href="' . add_query_arg( 'dismiss', $plugin['slug'] ) . '" target="_parent">' . __( 'Dismiss this notice', $this->domain ) . '</a><br />';
  64.                     }
  65.  
  66.                 }
  67.  
  68.             }
  69.            
  70.         }
  71.        
  72.         if ( ! empty( $message ) )
  73.             add_settings_error( 'tgmpa', 'tgmpa', $message, 'updated' );
  74.    
  75.         settings_errors( 'tgmpa' );
  76.  
  77.     }
Add Comment
Please, Sign In to add comment