Permalink
Browse files

Second pass at the Supported Plugins detail screen. Some parts still …

…to be re-implemented.
  • Loading branch information...
1 parent d9c4221 commit 11f62ae2f924e9e3a6a5a6a10fbf28192b65f450 @paulgibbs committed Apr 30, 2012
View
@@ -127,7 +127,7 @@ public function screen_options() {
// "Supported Plugins" screen
if ( 'achievements-plugins' == $_GET['page'] )
- dpa_supported_plugins_load();
+ dpa_supported_plugins_on_load();
}
/**
@@ -165,10 +165,10 @@ public function enqueue_scripts() {
// "Supported Plugins" screen
if ( 'achievements-plugins' == $_GET['page'] ) {
- wp_enqueue_script( 'dpa_socialite', trailingslashit( $achievements->plugin_url ) . 'js/socialite-min.js', array(), '20120413', true );
- wp_enqueue_script( 'dpa_cookie_js', trailingslashit( $achievements->plugin_url ) . 'js/jquery-cookie-min.js', array( 'jquery' ), '20120413', true );
- wp_enqueue_script( 'tablesorter_js', trailingslashit( $achievements->plugin_url ) . 'js/jquery-tablesorter-min.js', array( 'jquery' ), '20120413', true );
- wp_enqueue_script( 'dpa_sp_admin_js', trailingslashit( $achievements->plugin_url ) . 'js/supportedplugins-min.js', array( 'jquery', 'dpa_cookie_js', 'dpa_socialite' ), '20120413', true );
+ wp_enqueue_script( 'dpa_socialite', trailingslashit( $achievements->plugin_url ) . 'js/socialite-min.js', array(), '20120413', true );
+ wp_enqueue_script( 'dpa_cookie_js', trailingslashit( $achievements->plugin_url ) . 'js/jquery-cookie-min.js', array( 'jquery' ), '20120413', true );
+ wp_enqueue_script( 'tablesorter_js', trailingslashit( $achievements->plugin_url ) . 'js/jquery-tablesorter-min.js', array( 'jquery' ), '20120413', true );
+ wp_enqueue_script( 'dpa_sp_admin_js', trailingslashit( $achievements->plugin_url ) . 'js/supportedplugins-min.js', array( 'jquery', 'dpa_cookie_js', 'dpa_socialite', 'dashboard', 'postbox' ), '20120413', true );
// Add thickbox for the 'not installed' links on the List view
add_thickbox();
@@ -14,7 +14,7 @@
*
* @since 3.0
*/
-function dpa_supported_plugins_load() {
+function dpa_supported_plugins_on_load() {
// Help panel - overview text
get_current_screen()->add_help_tab( array(
'id' => 'dpa-supported-plugins-overview',
@@ -38,6 +38,9 @@ function dpa_supported_plugins_load() {
'<p><strong>' . __( 'For more information:', 'dpa' ) . '</strong></p>' .
'<p>' . __( '<a href="http://buddypress.org/community/groups/achievements/forum/">Support Forums</a>', 'dpa' ) . '</p>'
);
+
+ // Detail view - metaboxes
+ add_meta_box( 'dpa-supported-plugins-switcher', __( 'View Plugin', 'dpa' ), 'dpa_supported_plugins_mb_switcher', 'dpa_achievements_page_achievements-plugins', 'side', 'core' );
}
/**
@@ -92,7 +95,11 @@ function dpa_supported_plugins_header() {
else
$filter = 'all';
?>
- <form name="dpa-toolbar" id="dpa-toolbar" method="post" enctype="multipart/form-data">
+ <form class="dpa-toolbar" enctype="multipart/form-data" id="dpa-toolbar" method="post" name="dpa-toolbar">
+
+ <?php // Required to remember the state of the metaboxes on the Detail view ?>
+ <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
+ <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
<div id="dpa-toolbar-wrapper">
<input type="search" results="5" name="dpa-toolbar-search" id="dpa-toolbar-search" placeholder="<?php esc_attr_e( 'Search for a plugin...', 'dpa' ); ?>" />
@@ -134,19 +141,9 @@ function dpa_supported_plugins_detail() {
$plugins = dpa_get_supported_plugins();
?>
- <ul id="dpa-details-plugins">
- <?php foreach ( $plugins as $plugin ) :
- $class = $plugin->slug;
-
- // Record if this plugin is installed by setting the class
- if ( in_array( $plugin->install_status['status'], array( 'latest_installed', 'newer_installed', 'update_available', ) ) )
- $class .= ' installed';
- else
- $class .= ' notinstalled';
- ?>
- <li class="<?php echo esc_attr( $class ); if ( $last_plugin == $plugin->slug ) echo ' current'; ?>"><?php echo convert_chars( wptexturize( $plugin->name ) ); ?></li>
- <?php endforeach; ?>
- </ul>
+ <div id="dpa-info-column" class="metabox-holder">
+ <?php do_meta_boxes( 'dpa_achievements_page_achievements-plugins', 'side', null ); ?>
+ </div>
<div id="dpa-detail-contents">
<?php foreach ( $plugins as $plugin ) :
@@ -166,50 +163,6 @@ function dpa_supported_plugins_detail() {
<a class="socialite googleplus" href="<?php echo esc_attr( esc_url( 'https://plus.google.com/share?url=' . urlencode( $plugin->wporg_url ) ) ); ?>" data-size="medium" data-href="<?php echo esc_attr( $plugin->wporg_url ); ?>" target="_blank"><?php _e( 'Share on Google', 'dpa' ); ?></a>
</div><!-- .plugin-title -->
- <div class="plugin-infobox">
- <h4><?php _e( 'Plugin Info', 'dpa' ); ?></h4>
- <p><?php echo convert_chars( wptexturize( $plugin->description ) ); ?></p>
-
- <ul>
- <li class="status <?php echo esc_attr( $class ); ?>">
- <?php
- // Is plugin installed?
- if ( in_array( $plugin->install_status['status'], array( 'latest_installed', 'newer_installed', 'update_available', ) ) ) {
- _e( 'Status: Ready', 'dpa' );
-
- // It's not installed
- } else {
- // If current user can install plugins, link directly to the install screen
- if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) )
- printf( '%1$s <a class="thickbox" href="%2$s">%3$s</a>', __( 'Status:', 'dpa' ), esc_url( $plugin->install_url ), __( 'Not installed', 'dpa' ) );
- else
- _e( 'Status: Not installed', 'dpa' );
- }
- ?>
- </li>
-
- <li class="links"><?php printf( '<a href="%1$s" target="_new">%2$s</a>', esc_url( $plugin->wporg_url ), __( 'More info', 'dpa' ) ); ?></li>
-
- <li class="authors">
- <?php
- foreach ( $plugin->contributors as $name => $gravatar_url ) {
- // Sanitise plugin info as it may have been fetched from wporg
- $gravatar_url = esc_url( $gravatar_url );
- $profile_url = esc_url( 'http://profiles.wordpress.org/users/' . urlencode( $name ) );
- $name = convert_chars( wptexturize( wp_kses_data( $name ) ) );
-
- printf( '<a href="%1$s"><img src="%2$s" alt="%3$s" title="%4$s" /></a>', esc_attr( $profile_url ), esc_attr( $gravatar_url ), esc_attr( $name ), esc_attr( $name ) );
- }
- ?>
- </li>
- </ul>
- </div><!-- .plugin-infobox -->
-
- <div class="plugin-achievements">
- <h3 class="screen-reader-text"><?php _e( 'Supported Events', 'dpa' ); ?></h3>
- <p><?php echo $plugin->supported_events; ?></p>
- </div><!-- .plugin-achievements -->
-
<div class="plugin-rss">
<h3><?php _e( 'Latest News', 'dpa' ); ?></h3>
@@ -407,4 +360,38 @@ function dpa_supported_plugins_grid() {
printf( '<a href="#" class="%1$s"><img class="%2$s" src="%3$s" alt="%4$s" title="%4$s" /></a>', esc_attr( $class ), esc_attr( $plugin->slug ), esc_attr( $plugin->image->large ), esc_attr( $plugin->name ) );
}
}
+
+/**
+ * The metabox for the "select a plugin" dropdown box on the Supported Plugins grid view.
+ *
+ * @since 3.0
+ */
+function dpa_supported_plugins_mb_switcher() {
+ $last_plugin = '';
+
+ // See if a cookie has been set to remember the last viewed plugin
+ if ( ! empty( $_COOKIE['dpa_sp_lastplugin'] ) )
+ $last_plugin = trim( $_COOKIE['dpa_sp_lastplugin'] );
+
+ // Get supported plugins
+ $plugins = dpa_get_supported_plugins();
+
+ // Build dropdown box
+ echo '<select id="dpa-details-plugins">';
+
+ foreach ( $plugins as $plugin ) {
+ $class = $plugin->slug;
+
+ // Record if this plugin is installed by setting the class
+ if ( in_array( $plugin->install_status['status'], array( 'latest_installed', 'newer_installed', 'update_available', ) ) )
+ $class .= ' installed';
+ else
+ $class .= ' notinstalled';
+
+ // Build option for the plugin
+ echo '<option class="' . esc_attr( $class ) . '"' . selected( $last_plugin, $plugin->slug ) . '>' . convert_chars( wptexturize( $plugin->name ) ) . '</li>';
+ }
+
+ echo '</select>';
+}
?>
View
@@ -1,12 +1,12 @@
// admin-forms.less
-// Form appearance stuff.
+// Form appearance/normalisation stuff.
//
// Taken from Formalize CSS http://formalize.me/, under the MIT License
// http://www.opensource.org/licenses/mit-license.php.
// ------------------------------------------------------------------
-.wp-admin input,
-.wp-admin select {
+.dpa-toolbar input,
+.dpa-toolbar select {
.background-clip(padding-box);
.ie7-inline-block();
box-shadow: none;
@@ -19,15 +19,15 @@
}
// Inputs within a label
-.wp-admin label select {
+.dpa-toolbar label select {
display: block;
}
-.wp-admin select {
+.dpa-toolbar select {
-webkit-appearance: textfield;
}
-.wp-admin select:focus {
+.dpa-toolbar select:focus {
box-shadow: none;
}
-.wp-admin input[type="search"] {
+.dpa-toolbar input[type="search"] {
-webkit-appearance: none;
}
@@ -3,7 +3,6 @@
// -----------------------------------------------------
@toolbarHeight: 45px;
@toolbarMargin: 10px;
-@toolbarFontSize: 13px;
@toolbarFontColour: #5C5C5C;
@toolbarGradientTop: #EAEAEA;
@toolbarGradientBottom: #FAFAFA;
@@ -13,4 +12,7 @@
@toolbarSunkenBorderColourBottom: rgb(223,223,223);
@smallFont: 12px;
-@mediumFont: 15px;
+@mediumFont: 15px;
+@toolbarFontSize: 13px;
+
+@metaboxWidth: 280px;
@@ -209,32 +209,21 @@ div.list {
div.detail {
display: none;
margin-top: @toolbarMargin;
- .clearfix();
- #dpa-detail-contents {
+ #dpa-info-column {
.box-sizing(border-box);
- .clearfix();
float: left;
- width: 75%;
+ width: @metaboxWidth;
}
- #dpa-details-plugins {
+ #dpa-detail-contents {
.box-sizing(border-box);
- float: left;
- list-style-type: square;
- margin: @toolbarMargin 0 0;
- padding-left: 20px;
- width: 25%;
-
- li {
- margin-bottom: 0;
+ .clearfix();
+ margin-left: @metaboxWidth + @toolbarMargin;
+ }
- &.current,
- &:hover {
- color: #D54E21;
- cursor: pointer;
- }
- }
+ #dpa-details-plugins {
+ width: 100%;
}
}
@@ -282,41 +271,6 @@ div.detail {
}
}
- .plugin-infobox {
- border: 1px solid @toolbarMainBorderColour;
- float: right; // @todo RTL
- font-size: @smallFont;
- margin: 0 0 @toolbarMargin @toolbarMargin; // @todo RTL
- padding: @toolbarMargin;
- text-align: center;
- width: 25%;
-
- .authors {
- a {
- margin-left: 10px;
-
- &:first-child {
- margin-left: 0;
- }
- }
-
- img {
- padding: 2px;
- .box-shadow( 0 0 4px rgba( 0, 0, 0, 0.4 ) );
- }
- }
- .installed { font-weight: bold; }
-
- h4 { margin: 0 0 0.6em 0; }
- li:last-child{ margin: 0; }
- ul { margin: 0; }
- }
-
- .plugin-achievements {
- float: left; /* RTL? */
- width: 71%;
- }
-
.plugin-rss {
.clearfix();
float: left; /* RTL? */
@@ -336,6 +290,7 @@ div.detail {
margin: 0;
li {
+ clear: left;
float: left; /* RTL? */
margin-bottom: @toolbarMargin;
Oops, something went wrong.

0 comments on commit 11f62ae

Please sign in to comment.