Skip to content

Commit

Permalink
Release 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshpanchal27 committed Mar 18, 2022
1 parent 5ec25c0 commit 1b6a79f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 44 deletions.
76 changes: 38 additions & 38 deletions easy-author-avatar-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
Plugin Name: Easy Author Avatar Image
Description: Upload an author image right from your profile page with the click of a button
Version: 1.0
Version: 1.2
Author: Mukesh Panchal
Author URI: https://mukeshpanchal27.com/
Text Domain: easy-author-avatar-image
Expand All @@ -15,7 +15,7 @@ class easy_author_avatar_image {

public function __construct() {
$this->plugin_name = 'easy-author-avatar-image';
$this->version = '1.0';
$this->version = '1.2';
register_setting( 'easy_author_avatar_image_settings', 'easy_author_avatar_image_option' );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles_scripts' ] );
add_action( 'show_user_profile', [ $this, 'admin_author_img_upload' ] );
Expand All @@ -33,7 +33,6 @@ public function enqueue_styles_scripts() {

if ( $easy_author_avatar_image_option_set ) {
wp_enqueue_style( $this->plugin_name, plugin_dir_url(__FILE__) . 'css/easy-author-avatar-image.css', array(), $this->version, 'all' );


wp_enqueue_media();

Expand Down Expand Up @@ -66,34 +65,34 @@ public function admin_menu_page() {

public function easy_author_avatar_image_page_callback() { ?>
<form method="post" action="options.php">
<?php
settings_fields( 'easy_author_avatar_image_settings' );
$easy_author_avatar_image_option = get_option( 'easy_author_avatar_image_option' );
?>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="easy-author-avatar-image-lable"><?php _e( 'Enable Easy Author Avatar Image', 'easy-author-avatar-image' ); ?></label>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span>
<?php _e( 'Enable Easy Author Avatar Image', 'easy-author-avatar-image' ); ?>
</span>
</legend>
<label for="easy_author_avatar_image_option">
<input name="easy_author_avatar_image_option[_enable]" id="easy_author_avatar_image_option" type="checkbox" value="yes" <?php echo ( isset( $easy_author_avatar_image_option['_enable'] ) && ( 'yes' == $easy_author_avatar_image_option['_enable'] ) ) ? ' checked="checked"' : ''; ?> />
<?php _e( 'Enable Profile Section', 'easy-author-avatar-image' ); ?>
</label>
</fieldset>
</td>
</tr>
</tbody>
</table>
<?php submit_button( __( 'Save Changes', 'easy-author-avatar-image' ) ); ?>
</form>
<?php
settings_fields( 'easy_author_avatar_image_settings' );
$easy_author_avatar_image_option = get_option( 'easy_author_avatar_image_option' );
?>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="easy-author-avatar-image-lable"><?php _e( 'Enable Easy Author Avatar Image', 'easy-author-avatar-image' ); ?></label>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span>
<?php _e( 'Enable Easy Author Avatar Image', 'easy-author-avatar-image' ); ?>
</span>
</legend>
<label for="easy_author_avatar_image_option">
<input name="easy_author_avatar_image_option[_enable]" id="easy_author_avatar_image_option" type="checkbox" value="yes" <?php echo ( isset( $easy_author_avatar_image_option['_enable'] ) && ( 'yes' == $easy_author_avatar_image_option['_enable'] ) ) ? ' checked="checked"' : ''; ?> />
<?php _e( 'Enable Profile Section', 'easy-author-avatar-image' ); ?>
</label>
</fieldset>
</td>
</tr>
</tbody>
</table>
<?php submit_button( __( 'Save Changes', 'easy-author-avatar-image' ) ); ?>
</form>
<?php
}

Expand All @@ -106,10 +105,7 @@ public function admin_author_img_upload( $user ) {
$avatar = get_user_meta( $user->ID, 'easy-author-avatar-profile-image', true );
$avatar_url = wp_get_attachment_image_url( $avatar );

$button_class = '';
if ( ! $avatar_url ) {
$button_class = ' easy-author-avatar-image-hide';
}
$button_class = ( ! $avatar_url ) ? ' easy-author-avatar-image-hide': "";
?>

<div class="easy-author-avatar-image-upload-wrap">
Expand Down Expand Up @@ -159,13 +155,17 @@ public function get_easy_author_image( $avatar, $id_or_email, $size, $default, $
$user = false;

if ( is_numeric( $id_or_email ) ) {

$id = (int) $id_or_email;
$user = get_user_by( 'id', $id );
$user = get_user_by( 'id' , $id );

} elseif ( is_object( $id_or_email ) ) {
if ( !empty( $id_or_email->user_id ) ) {

if ( ! empty( $id_or_email->user_id ) ) {
$id = (int) $id_or_email->user_id;
$user = get_user_by( 'id', $id );
$user = get_user_by( 'id' , $id );
}

} else {
$user = get_user_by( 'email', $id_or_email );
}
Expand Down
3 changes: 3 additions & 0 deletions js/easy-author-avatar-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

uploader = wp.media.frames.file_frame = wp.media({
title: easy_author_avatar_image._media_title,
library: {
type: 'image'
},
button: {
text: easy_author_avatar_image._media_button_title
},
Expand Down
24 changes: 18 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
=== Easy Author Avatar Image ===
Contributors: mukesh27, dhavalpanchal
Tags: avatar, user profile, gravatar,custom profile photo, custom profile picture, profile photo, profile picture, author image, author photo
Tags: avatar, user profile, gravatar, custom profile photo, custom profile picture, profile photo, profile picture, author image, author photo
Donate link: https://www.paypal.com/paypalme/mukeshpanchal27
Requires at least: 5.6
Tested up to: 5.9
Requires PHP: 7.0
Stable tag: 1.0
Stable tag: 1.2
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt

Upload an author image right from your profile page with the click of a button.

== Description ==

Easy Author Avatar Image gives you the option do you exactly that -- easily add an author image to your profile page. Once you install this plugin, you'll have a new option in the Your Profile tab (under Users) called Profile Picture, complete with a media uploader box that allows you to upload your very own author picture.
Easy Author Avatar Image gives you the option do you exactly that -- easily add an author image to your profile page. Once you install this plugin, you'll have a new option in the Your Profile tab (under Users) called Profile Picture, complete with a media upload box that allows you to upload your very own author picture.

Whether you call it an avatar, an author image, or an author picture, Easy Author Avatar Image is a "Works Out Of The Box" solution to a common problem.

= What's Next =

If you find this plugin useful , please leave a good rating and consider checking out my other plugins:
If you find this plugin useful, please leave a good rating and consider checking out my other plugins:

* <a href="https://wordpress.org/plugins/enhanced-comment-validation/" rel="friend" title="Enhanced Comment Validation">Enhanced Comment Validation</a> - Setup a comment validation for comment form.

Expand Down Expand Up @@ -67,11 +67,23 @@ In addition, if you like the plugin then I'd love for you to leave a review. Tel
3. Upload Custom Avatar Image

== Changelog ==
= 1.2 =
* Fixed: Frontend warning message for avatar image.

= 1.1 =
* Added: Added compatibility for latest WordPress version of 5.9.1
* Fixed: Allow only image in Media selection. Props @ravipatel.
* Fixed: Optimize some codes.

= 1.0 =
* Released.
* Initial release.

== Upgrade Notice ==
= 1.2 =
* Fixed: Frontend warning message for avatar image.

= 1.1 =
Check latest WP version compatibility and allow only image in media upload.

= 1.0 =
* Initial version
Initial release.

0 comments on commit 1b6a79f

Please sign in to comment.