Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 20 additions and 1 deletion. Show diff stats Hide diff stats

  1. 21  favorite-plugins.php
21  favorite-plugins.php
@@ -107,6 +107,8 @@ function widget( $args, $instance ) {
107 107
 		$per_page = $instance['per_page'];
108 108
 		$stars = (bool)$instance['stars'];
109 109
 		$authors = (bool)$instance['authors'];
  110
+		$show_profile_link = (bool)$instance['show_profile_link'];
  111
+		$shuffle_plugins = (bool)$instance['shuffle_plugins'];
110 112
 
111 113
 		$api_data = get_transient( '_c3m_favorite_plugins' );
112 114
 
@@ -125,6 +127,9 @@ function widget( $args, $instance ) {
125 127
 		echo $before_title . apply_filters( 'widget_title', $title ) . $after_title;
126 128
 		echo '<ul class="c3m-favorites">';
127 129
 		$c = 0;
  130
+		
  131
+		if ( $shuffle_plugins ) shuffle( $api_plugins );
  132
+
128 133
 		foreach( $api_plugins as $plugin ) {
129 134
 			$c++;
130 135
 			if ( $c > $per_page )
@@ -141,6 +146,10 @@ function widget( $args, $instance ) {
141 146
 			endif; ?>
142 147
 			</li><?php
143 148
 		}
  149
+
  150
+		if( $show_profile_link ): ?>
  151
+			<a href="http://profiles.wordpress.org/<?php echo $instance['wp_user'] ?>" target="_blank"><?php _e( 'See all plugins' ) ?></a>
  152
+		<?php endif;
144 153
 		echo '</ul>';
145 154
 
146 155
 		/**
@@ -158,6 +167,8 @@ function update( $new_instance, $old_instance ) {
158 167
 		$instance['per_page'] = absint( $new_instance['per_page'] );
159 168
 		$instance['stars'] = (bool)$new_instance['stars'];
160 169
 		$instance['authors'] = (bool)$new_instance['authors'];
  170
+		$instance['show_profile_link'] = (bool)$new_instance['show_profile_link'];
  171
+		$instance['shuffle_plugins'] = (bool)$new_instance['shuffle_plugins'];
161 172
 
162 173
 		delete_transient( '_c3m_favorite_plugins' );
163 174
 
@@ -172,6 +183,8 @@ function form( $instance ) {
172 183
 		$per_page  = isset( $instance['per_page'] ) ? absint( $instance['per_page'] ) : 5;
173 184
 		$stars = isset( $instance['stars'] ) ? (bool)$instance['stars'] : true;
174 185
 		$authors = isset( $instance['authors'] ) ? (bool)$instance['authors'] : true;
  186
+		$show_profile_link = isset( $instance['show_profile_link'] ) ? (bool)$instance['show_profile_link'] : true;
  187
+		$shuffle_plugins = isset( $instance['shuffle_plugins'] ) ? (bool)$instance['shuffle_plugins'] : true;
175 188
 		?>
176 189
 
177 190
 		<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
@@ -189,10 +202,16 @@ function form( $instance ) {
189 202
         <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' ); ?>"/>
190 203
 		<label for="<?php echo $this->get_field_id( 'authors' ); ?>"><?php _e( 'Display Plugin Authors?' ); ?></label></p>
191 204
 
  205
+        <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' ); ?>"/>
  206
+		<label for="<?php echo $this->get_field_id( 'show_profile_link' ); ?>"><?php _e( 'Show Profile Link?' ); ?></label></p>
  207
+
  208
+        <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' ); ?>"/>
  209
+		<label for="<?php echo $this->get_field_id( 'shuffle_plugins' ); ?>"><?php _e( 'Shuffle Plugins?' ); ?></label></p>
  210
+
192 211
 	<?php }
193 212
 
194 213
  }
195 214
 
196 215
 function c3m_register() {
197 216
 	register_widget( 'C3M_My_Favs' );
198  
-}
  217
+}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.