Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added option to display link to profile page #1

Open
wants to merge 2 commits into from

1 participant

Dan Bernardic
Dan Bernardic

Hello,

In order for website viewers to be able to see the rest of the list of favorite plugins
I've added an option to show a .org profile link after the list of plugins.

Hope you'll find it useful and include it in the plugin. Let me know if you need anything changed before you can accept it.

Thank you for sharing your software.

Dan Bernardic

I also added a "Shuffle Plugins?" option. It is useful to me because I don't necessarily want to always show the first 5 plugins I added to favorites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 7, 2012
  1. Dan Bernardic
  2. Dan Bernardic
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 1 deletion.
  1. +20 −1 favorite-plugins.php
21 favorite-plugins.php
View
@@ -107,6 +107,8 @@ function widget( $args, $instance ) {
$per_page = $instance['per_page'];
$stars = (bool)$instance['stars'];
$authors = (bool)$instance['authors'];
+ $show_profile_link = (bool)$instance['show_profile_link'];
+ $shuffle_plugins = (bool)$instance['shuffle_plugins'];
$api_data = get_transient( '_c3m_favorite_plugins' );
@@ -125,6 +127,9 @@ function widget( $args, $instance ) {
echo $before_title . apply_filters( 'widget_title', $title ) . $after_title;
echo '<ul class="c3m-favorites">';
$c = 0;
+
+ if ( $shuffle_plugins ) shuffle( $api_plugins );
+
foreach( $api_plugins as $plugin ) {
$c++;
if ( $c > $per_page )
@@ -141,6 +146,10 @@ function widget( $args, $instance ) {
endif; ?>
</li><?php
}
+
+ if( $show_profile_link ): ?>
+ <a href="http://profiles.wordpress.org/<?php echo $instance['wp_user'] ?>" target="_blank"><?php _e( 'See all plugins' ) ?></a>
+ <?php endif;
echo '</ul>';
/**
@@ -158,6 +167,8 @@ function update( $new_instance, $old_instance ) {
$instance['per_page'] = absint( $new_instance['per_page'] );
$instance['stars'] = (bool)$new_instance['stars'];
$instance['authors'] = (bool)$new_instance['authors'];
+ $instance['show_profile_link'] = (bool)$new_instance['show_profile_link'];
+ $instance['shuffle_plugins'] = (bool)$new_instance['shuffle_plugins'];
delete_transient( '_c3m_favorite_plugins' );
@@ -172,6 +183,8 @@ function form( $instance ) {
$per_page = isset( $instance['per_page'] ) ? absint( $instance['per_page'] ) : 5;
$stars = isset( $instance['stars'] ) ? (bool)$instance['stars'] : true;
$authors = isset( $instance['authors'] ) ? (bool)$instance['authors'] : true;
+ $show_profile_link = isset( $instance['show_profile_link'] ) ? (bool)$instance['show_profile_link'] : true;
+ $shuffle_plugins = isset( $instance['shuffle_plugins'] ) ? (bool)$instance['shuffle_plugins'] : true;
?>
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
@@ -189,10 +202,16 @@ function form( $instance ) {
<p><input class="checkbox" type="checkbox" <?php checked( $authors ); ?> id="<?php echo $this->get_field_id( 'authors' ); ?>" name="<?php echo $this->get_field_name( 'authors' ); ?>"/>
<label for="<?php echo $this->get_field_id( 'authors' ); ?>"><?php _e( 'Display Plugin Authors?' ); ?></label></p>
+ <p><input class="checkbox" type="checkbox" <?php checked( $show_profile_link ); ?> id="<?php echo $this->get_field_id( 'show_profile_link' ); ?>" name="<?php echo $this->get_field_name( 'show_profile_link' ); ?>"/>
+ <label for="<?php echo $this->get_field_id( 'show_profile_link' ); ?>"><?php _e( 'Show Profile Link?' ); ?></label></p>
+
+ <p><input class="checkbox" type="checkbox" <?php checked( $shuffle_plugins ); ?> id="<?php echo $this->get_field_id( 'shuffle_plugins' ); ?>" name="<?php echo $this->get_field_name( 'shuffle_plugins' ); ?>"/>
+ <label for="<?php echo $this->get_field_id( 'shuffle_plugins' ); ?>"><?php _e( 'Shuffle Plugins?' ); ?></label></p>
+
<?php }
}
function c3m_register() {
register_widget( 'C3M_My_Favs' );
-}
+}
Something went wrong with that request. Please try again.