Version Description
- Usability enhancements.
- Stripping out useless code.
- Updating documentation
Download this release
Release Info
| Developer | ronalfy |
| Plugin | |
| Version | 1.0.10 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.9 to 1.0.10
- js/mpp.js +3 -2
- metronet-profile-picture.php +4 -122
- readme.txt +20 -3
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
js/mpp.js
CHANGED
|
@@ -5,9 +5,10 @@ jQuery( document ).ready( function( $ ) {
|
|
| 5 |
state: 'featured-image',
|
| 6 |
states: [ new wp.media.controller.FeaturedImage() ]
|
| 7 |
});
|
|
|
|
| 8 |
uploader.on( 'toolbar:create:featured-image', function( toolbar ) {
|
| 9 |
this.createSelectToolbar( toolbar, {
|
| 10 |
-
text:
|
| 11 |
});
|
| 12 |
}, uploader );
|
| 13 |
|
|
@@ -16,7 +17,7 @@ jQuery( document ).ready( function( $ ) {
|
|
| 16 |
var settings = wp.media.view.settings;
|
| 17 |
|
| 18 |
settings.post.featuredImageId = id;
|
| 19 |
-
$.post( ajaxurl, { action: 'metronet_add_thumbnail', json: false, post_id: settings.post.id, user_id: jQuery( "#metronet_profile_id" ).val(), thumbnail_id: settings.post.featuredImageId,_wpnonce:
|
| 20 |
jQuery( "#metronet-profile-image a" ).html( response );
|
| 21 |
} );
|
| 22 |
};
|
| 5 |
state: 'featured-image',
|
| 6 |
states: [ new wp.media.controller.FeaturedImage() ]
|
| 7 |
});
|
| 8 |
+
//Create featured image button
|
| 9 |
uploader.on( 'toolbar:create:featured-image', function( toolbar ) {
|
| 10 |
this.createSelectToolbar( toolbar, {
|
| 11 |
+
text: metronet_profile_image.set_profile_text
|
| 12 |
});
|
| 13 |
}, uploader );
|
| 14 |
|
| 17 |
var settings = wp.media.view.settings;
|
| 18 |
|
| 19 |
settings.post.featuredImageId = id;
|
| 20 |
+
$.post( ajaxurl, { action: 'metronet_add_thumbnail', json: false, post_id: settings.post.id, user_id: jQuery( "#metronet_profile_id" ).val(), thumbnail_id: settings.post.featuredImageId,_wpnonce: settings.post.nonce }, function( response ) {
|
| 21 |
jQuery( "#metronet-profile-image a" ).html( response );
|
| 22 |
} );
|
| 23 |
};
|
metronet-profile-picture.php
CHANGED
|
@@ -4,7 +4,7 @@ Plugin Name: Metronet Profile Picture
|
|
| 4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
| 5 |
Description: Use the native WP uploader on your user profile page.
|
| 6 |
Author: Metronet
|
| 7 |
-
Version: 1.0.
|
| 8 |
Requires at least: 3.5
|
| 9 |
Author URI: http://www.metronet.no
|
| 10 |
Contributors: ronalfy, metronet
|
|
@@ -28,23 +28,17 @@ class Metronet_Profile_Picture {
|
|
| 28 |
*/
|
| 29 |
function __construct(){
|
| 30 |
|
| 31 |
-
$this->admin_options = $this->get_admin_options();
|
| 32 |
$this->plugin_path = plugin_basename( __FILE__ );
|
| 33 |
$this->plugin_url = rtrim( plugin_dir_url(__FILE__), '/' );
|
| 34 |
$this->plugin_dir = rtrim( plugin_dir_path(__FILE__), '/' );
|
| 35 |
|
| 36 |
add_action( 'init', array( &$this, 'init' ) );
|
| 37 |
add_action( 'personal_options', array( &$this, 'insert_upload_form' ) );
|
| 38 |
-
add_action( 'admin_menu', array( &$this, 'admin_menus' ) );
|
| 39 |
|
| 40 |
//Scripts
|
| 41 |
add_action( 'admin_print_scripts-user-edit.php', array( &$this, 'print_media_scripts' ) );
|
| 42 |
add_action( 'admin_print_scripts-profile.php', array( &$this, 'print_media_scripts' ) );
|
| 43 |
|
| 44 |
-
//Styles
|
| 45 |
-
add_action( 'admin_print_styles-user-edit.php', array( &$this, 'print_media_styles' ) );
|
| 46 |
-
add_action( 'admin_print_styles-profile.php', array( &$this, 'print_media_styles' ) );
|
| 47 |
-
|
| 48 |
//Ajax
|
| 49 |
add_action( 'wp_ajax_metronet_add_thumbnail', array( &$this, 'ajax_add_thumbnail' ) );
|
| 50 |
|
|
@@ -56,14 +50,6 @@ class Metronet_Profile_Picture {
|
|
| 56 |
add_filter( 'get_avatar', array( &$this, 'avatar_override' ), 10, 5 );
|
| 57 |
} //end constructor
|
| 58 |
|
| 59 |
-
/**
|
| 60 |
-
* admin_menus
|
| 61 |
-
* Helper method for initializes all admin menus and registering settings
|
| 62 |
-
*/
|
| 63 |
-
public function admin_menus() {
|
| 64 |
-
|
| 65 |
-
} //end admin_menus
|
| 66 |
-
|
| 67 |
/**
|
| 68 |
* ajax_add_thumbnail()
|
| 69 |
*
|
|
@@ -135,78 +121,6 @@ class Metronet_Profile_Picture {
|
|
| 135 |
return $custom_avatar;
|
| 136 |
} //end avatar_override
|
| 137 |
|
| 138 |
-
/**
|
| 139 |
-
* get_admin_option()
|
| 140 |
-
*
|
| 141 |
-
* Returns a localized admin option
|
| 142 |
-
*
|
| 143 |
-
* @param string $key Admin Option Key to Retrieve
|
| 144 |
-
* @return mixed The results of the admin key. False if not present.
|
| 145 |
-
*/
|
| 146 |
-
public function get_admin_option( $key = '' ) {
|
| 147 |
-
$admin_options = $this->get_admin_options();
|
| 148 |
-
if ( array_key_exists( $key, $admin_options ) ) {
|
| 149 |
-
return $admin_options[ $key ];
|
| 150 |
-
}
|
| 151 |
-
return false;
|
| 152 |
-
}
|
| 153 |
-
|
| 154 |
-
/**
|
| 155 |
-
* get_admin_options()
|
| 156 |
-
*
|
| 157 |
-
* Initialize and return an array of all admin options
|
| 158 |
-
*
|
| 159 |
-
* @return array All Admin Options
|
| 160 |
-
*/
|
| 161 |
-
public function get_admin_options( ) {
|
| 162 |
-
|
| 163 |
-
if (empty($this->admin_options)) {
|
| 164 |
-
$admin_options = $this->get_plugin_defaults();
|
| 165 |
-
|
| 166 |
-
$options = get_option( $this->plugin_slug );
|
| 167 |
-
if (!empty($options)) {
|
| 168 |
-
foreach ($options as $key => $option) {
|
| 169 |
-
if (array_key_exists($key, $admin_options)) {
|
| 170 |
-
$admin_options[$key] = $option;
|
| 171 |
-
}
|
| 172 |
-
}
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
//Save the options
|
| 176 |
-
$this->admin_options = $admin_options;
|
| 177 |
-
$this->save_admin_options();
|
| 178 |
-
}
|
| 179 |
-
return $this->admin_options;
|
| 180 |
-
} //end get_admin_options
|
| 181 |
-
|
| 182 |
-
/**
|
| 183 |
-
* get_all_admin_options()
|
| 184 |
-
*
|
| 185 |
-
* Returns an array of all admin options
|
| 186 |
-
*
|
| 187 |
-
* @return array All Admin Options
|
| 188 |
-
*/
|
| 189 |
-
public function get_all_admin_options() {
|
| 190 |
-
return $this->admin_options;
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
/**
|
| 194 |
-
* get_plugin_defaults()
|
| 195 |
-
*
|
| 196 |
-
* Returns an array of default plugin options (to be stored in the options table)
|
| 197 |
-
*
|
| 198 |
-
* @return array Default plugin keys
|
| 199 |
-
*/
|
| 200 |
-
public function get_plugin_defaults() {
|
| 201 |
-
if ( isset( $this->defaults ) ) {
|
| 202 |
-
return $this->defaults;
|
| 203 |
-
} else {
|
| 204 |
-
$this->defaults = array(
|
| 205 |
-
);
|
| 206 |
-
return $this->defaults;
|
| 207 |
-
}
|
| 208 |
-
} //end get_plugin_defaults
|
| 209 |
-
|
| 210 |
/**
|
| 211 |
* get_plugin_dir()
|
| 212 |
*
|
|
@@ -342,7 +256,7 @@ class Metronet_Profile_Picture {
|
|
| 342 |
}
|
| 343 |
?>
|
| 344 |
</div><!-- #metronet-profile-image -->
|
| 345 |
-
<div id="metronet-upload-link"><?php echo $upload_link; ?> - <span class="description"><?php esc_html_e( 'Select "
|
| 346 |
<div id="metronet-override-avatar">
|
| 347 |
<input type="hidden" name="metronet-user-avatar" value="off" />
|
| 348 |
<input type="checkbox" name="metronet-user-avatar" id="metronet-user-avatar" value="on" <?php checked( "on", get_user_meta( $user_id, 'metronet_avatar_override', true ) ); ?> /><label for="metronet-user-avatar"> <?php esc_html_e( "Override Avatar?", "metronet_profile_picture" ); ?></label>
|
|
@@ -361,41 +275,9 @@ class Metronet_Profile_Picture {
|
|
| 361 |
$post_id = $this->get_post_id( $this->get_user_id() );
|
| 362 |
wp_enqueue_media( array( 'post' => $post_id ) );
|
| 363 |
wp_enqueue_script( 'mt-pp', $this->get_plugin_url( '/js/mpp.js' ), array( 'media-editor' ) );
|
|
|
|
| 364 |
} //end print_media_scripts
|
| 365 |
|
| 366 |
-
//todo - remove
|
| 367 |
-
public function print_media_styles() {
|
| 368 |
-
//wp_enqueue_style( 'thickbox' );
|
| 369 |
-
} //end print_media_styles
|
| 370 |
-
|
| 371 |
-
/**
|
| 372 |
-
* save_admin_option()
|
| 373 |
-
*
|
| 374 |
-
* Saves an individual option to the options array
|
| 375 |
-
* @param string $key Option key to save
|
| 376 |
-
* @param mixed $value Value to save in the option
|
| 377 |
-
*/
|
| 378 |
-
public function save_admin_option( $key = '', $value = '' ) {
|
| 379 |
-
$this->admin_options[ $key ] = $value;
|
| 380 |
-
$this->save_admin_options();
|
| 381 |
-
return $value;
|
| 382 |
-
} //end save_admin_option
|
| 383 |
-
|
| 384 |
-
/**
|
| 385 |
-
* save_admin_options()
|
| 386 |
-
*
|
| 387 |
-
* Saves a group of admin options to the options table
|
| 388 |
-
* @param array $admin_options Optional array of options to save (are merged with existing options)
|
| 389 |
-
*/
|
| 390 |
-
public function save_admin_options( $admin_options = false ){
|
| 391 |
-
if (!empty($this->admin_options)) {
|
| 392 |
-
if ( is_array( $admin_options ) ) {
|
| 393 |
-
$this->admin_options = wp_parse_args( $admin_options, $this->admin_options );
|
| 394 |
-
}
|
| 395 |
-
update_option( $this->plugin_slug, $this->admin_options);
|
| 396 |
-
}
|
| 397 |
-
} //end save_admin_options
|
| 398 |
-
|
| 399 |
/**
|
| 400 |
* save_user_profile()
|
| 401 |
*
|
|
@@ -418,7 +300,7 @@ class Metronet_Profile_Picture {
|
|
| 418 |
//instantiate the class
|
| 419 |
global $mt_pp;
|
| 420 |
if (class_exists('Metronet_Profile_Picture')) {
|
| 421 |
-
if (get_bloginfo('version') >= "3.
|
| 422 |
add_action( 'plugins_loaded', 'mt_mpp_instantiate' );
|
| 423 |
}
|
| 424 |
}
|
| 4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
| 5 |
Description: Use the native WP uploader on your user profile page.
|
| 6 |
Author: Metronet
|
| 7 |
+
Version: 1.0.10
|
| 8 |
Requires at least: 3.5
|
| 9 |
Author URI: http://www.metronet.no
|
| 10 |
Contributors: ronalfy, metronet
|
| 28 |
*/
|
| 29 |
function __construct(){
|
| 30 |
|
|
|
|
| 31 |
$this->plugin_path = plugin_basename( __FILE__ );
|
| 32 |
$this->plugin_url = rtrim( plugin_dir_url(__FILE__), '/' );
|
| 33 |
$this->plugin_dir = rtrim( plugin_dir_path(__FILE__), '/' );
|
| 34 |
|
| 35 |
add_action( 'init', array( &$this, 'init' ) );
|
| 36 |
add_action( 'personal_options', array( &$this, 'insert_upload_form' ) );
|
|
|
|
| 37 |
|
| 38 |
//Scripts
|
| 39 |
add_action( 'admin_print_scripts-user-edit.php', array( &$this, 'print_media_scripts' ) );
|
| 40 |
add_action( 'admin_print_scripts-profile.php', array( &$this, 'print_media_scripts' ) );
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
//Ajax
|
| 43 |
add_action( 'wp_ajax_metronet_add_thumbnail', array( &$this, 'ajax_add_thumbnail' ) );
|
| 44 |
|
| 50 |
add_filter( 'get_avatar', array( &$this, 'avatar_override' ), 10, 5 );
|
| 51 |
} //end constructor
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
/**
|
| 54 |
* ajax_add_thumbnail()
|
| 55 |
*
|
| 121 |
return $custom_avatar;
|
| 122 |
} //end avatar_override
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
/**
|
| 125 |
* get_plugin_dir()
|
| 126 |
*
|
| 256 |
}
|
| 257 |
?>
|
| 258 |
</div><!-- #metronet-profile-image -->
|
| 259 |
+
<div id="metronet-upload-link"><?php echo $upload_link; ?> - <span class="description"><?php esc_html_e( 'Select "Set profile image" after uploading to choose the profile image', 'metronet_profile_picture' ); ?></span></div><!-- #metronet-upload-link -->
|
| 260 |
<div id="metronet-override-avatar">
|
| 261 |
<input type="hidden" name="metronet-user-avatar" value="off" />
|
| 262 |
<input type="checkbox" name="metronet-user-avatar" id="metronet-user-avatar" value="on" <?php checked( "on", get_user_meta( $user_id, 'metronet_avatar_override', true ) ); ?> /><label for="metronet-user-avatar"> <?php esc_html_e( "Override Avatar?", "metronet_profile_picture" ); ?></label>
|
| 275 |
$post_id = $this->get_post_id( $this->get_user_id() );
|
| 276 |
wp_enqueue_media( array( 'post' => $post_id ) );
|
| 277 |
wp_enqueue_script( 'mt-pp', $this->get_plugin_url( '/js/mpp.js' ), array( 'media-editor' ) );
|
| 278 |
+
wp_localize_script( 'mt-pp', 'metronet_profile_image', array( 'set_profile_text' => __( 'Set profile image', 'metronet_profile_picture' ) ) );
|
| 279 |
} //end print_media_scripts
|
| 280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
/**
|
| 282 |
* save_user_profile()
|
| 283 |
*
|
| 300 |
//instantiate the class
|
| 301 |
global $mt_pp;
|
| 302 |
if (class_exists('Metronet_Profile_Picture')) {
|
| 303 |
+
if (get_bloginfo('version') >= "3.5") {
|
| 304 |
add_action( 'plugins_loaded', 'mt_mpp_instantiate' );
|
| 305 |
}
|
| 306 |
}
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: metronet, ronalfy
|
|
| 3 |
Tags: users, user, user profile
|
| 4 |
Requires at least: 3.5
|
| 5 |
Tested up to: 3.5
|
| 6 |
-
Stable tag: 1.0.
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
|
@@ -36,7 +36,7 @@ Arguments:
|
|
| 36 |
Example Usage:
|
| 37 |
`
|
| 38 |
$avatar = mt_profile_img( $user_id, array(
|
| 39 |
-
'size' => 'thumbnail'
|
| 40 |
'attr' => array( 'alt' => 'Alternative Text' ),
|
| 41 |
'echo' => false )
|
| 42 |
);
|
|
@@ -48,10 +48,14 @@ $avatar = mt_profile_img( $user_id, array(
|
|
| 48 |
|
| 49 |
1. Visit the profile page you would like to edit.
|
| 50 |
2. Click "Upload or Change Profile Picture"
|
| 51 |
-
3. Upload a new image and select "
|
| 52 |
|
| 53 |
To override an avatar, select the "Override Avatar?" checkbox and save the profile page.
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
= How do I create specific thumbnail sizes? =
|
| 56 |
|
| 57 |
Since the plugin uses the native uploader, you'll have to make use of <a href='http://codex.wordpress.org/Function_Reference/add_image_size'>add_image_size</a> in your theme. You can then call `mt_profile_img` and pass in the custom image size.
|
|
@@ -67,6 +71,11 @@ We highly recommend the <a href='http://wordpress.org/extend/plugins/post-thumbn
|
|
| 67 |
|
| 68 |
== Changelog ==
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
= 1.0.9 =
|
| 71 |
* Adding support for the new 3.5 media uploader.
|
| 72 |
|
|
@@ -85,6 +94,14 @@ We highly recommend the <a href='http://wordpress.org/extend/plugins/post-thumbn
|
|
| 85 |
|
| 86 |
== Upgrade Notice ==
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
= 1.0.1 =
|
| 89 |
Several important bug fixes including the ability to uncheck the avatar override, and the behavior when someone deletes their profile picture.
|
| 90 |
|
| 3 |
Tags: users, user, user profile
|
| 4 |
Requires at least: 3.5
|
| 5 |
Tested up to: 3.5
|
| 6 |
+
Stable tag: 1.0.10
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
| 36 |
Example Usage:
|
| 37 |
`
|
| 38 |
$avatar = mt_profile_img( $user_id, array(
|
| 39 |
+
'size' => 'thumbnail',
|
| 40 |
'attr' => array( 'alt' => 'Alternative Text' ),
|
| 41 |
'echo' => false )
|
| 42 |
);
|
| 48 |
|
| 49 |
1. Visit the profile page you would like to edit.
|
| 50 |
2. Click "Upload or Change Profile Picture"
|
| 51 |
+
3. Upload a new image and select "Set profile image", which will save the image (ignore the "Insert Into Post" button).
|
| 52 |
|
| 53 |
To override an avatar, select the "Override Avatar?" checkbox and save the profile page.
|
| 54 |
|
| 55 |
+
= What role does a user have to be to set a profile image? =
|
| 56 |
+
|
| 57 |
+
Author or greater.
|
| 58 |
+
|
| 59 |
= How do I create specific thumbnail sizes? =
|
| 60 |
|
| 61 |
Since the plugin uses the native uploader, you'll have to make use of <a href='http://codex.wordpress.org/Function_Reference/add_image_size'>add_image_size</a> in your theme. You can then call `mt_profile_img` and pass in the custom image size.
|
| 71 |
|
| 72 |
== Changelog ==
|
| 73 |
|
| 74 |
+
= 1.0.10 =
|
| 75 |
+
* Usability enhancements.
|
| 76 |
+
* Stripping out useless code.
|
| 77 |
+
* Updating documentation
|
| 78 |
+
|
| 79 |
= 1.0.9 =
|
| 80 |
* Adding support for the new 3.5 media uploader.
|
| 81 |
|
| 94 |
|
| 95 |
== Upgrade Notice ==
|
| 96 |
|
| 97 |
+
= 1.0.10 =
|
| 98 |
+
* 3.5 media uploader support
|
| 99 |
+
* Usability enhancements
|
| 100 |
+
* Code cleanup.
|
| 101 |
+
|
| 102 |
+
= 1.0.9 =
|
| 103 |
+
* 3.5 media uploader support.
|
| 104 |
+
|
| 105 |
= 1.0.1 =
|
| 106 |
Several important bug fixes including the ability to uncheck the avatar override, and the behavior when someone deletes their profile picture.
|
| 107 |
|
screenshot-1.jpg
DELETED
|
Binary file
|
screenshot-2.jpg
DELETED
|
Binary file
|
