Skip to content

Commit

Permalink
Simplify 'return to installer/dashboard' code
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Apr 27, 2015
1 parent 8b4eef0 commit 2301eca
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,24 +580,17 @@ protected function do_plugin_install() {
}

// Display message based on if all plugins are now active or not.
$complete = array();
$complete = true;
foreach ( $this->plugins as $plugin ) {
if ( ! is_plugin_active( $plugin['file_path'] ) ) {
echo '<p><a href="', esc_url( add_query_arg( 'page', urlencode( $this->menu ), self_admin_url( $this->parent_slug ) ) ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
$complete[] = $plugin;
$complete = false;
break;
}
// Nothing to store.
else {
$complete[] = '';
}
}

// Filter out any empty entries.
$complete = array_filter( $complete );

// All plugins are active, so we display the complete string and hide the plugin menu.
if ( empty( $complete ) ) {
if ( true === $complete ) {
echo '<p>', sprintf( esc_html( $this->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>';
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
}
Expand Down Expand Up @@ -2397,24 +2390,17 @@ public function bulk_footer() {
wp_clean_plugins_cache();

// Display message based on if all plugins are now active or not.
$complete = array();
$complete = true;
foreach ( $this->tgmpa->plugins as $plugin ) {
if ( ! is_plugin_active( $plugin['file_path'] ) ) {
echo '<p><a href="', esc_url( add_query_arg( 'page', urlencode( $this->tgmpa->menu ), self_admin_url( $this->tgmpa->parent_slug ) ) ), '" target="_parent">', esc_html( $this->tgmpa->strings['return'] ), '</a></p>';
$complete[] = $plugin;
$complete = false;
break;
}
// Nothing to store.
else {
$complete[] = '';
}
}

// Filter out any empty entries.
$complete = array_filter( $complete );

// All plugins are active, so we display the complete string and hide the menu to protect users.
if ( empty( $complete ) ) {
if ( true === $complete ) {
echo '<p>', sprintf( esc_html( $this->tgmpa->strings['complete'] ), '<a href="' . esc_url( self_admin_url() ) . '">' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>' ), '</p>';
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
}
Expand Down

0 comments on commit 2301eca

Please sign in to comment.