Version Description
- Added: Option to limit characters in author description
- Added: Support to work with for Co-authors plus WordPress plugin (if "auto detect author" is checked)
Download this release
Release Info
Developer | mekshq |
Plugin | Meks Smart Author Widget |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.8 to 1.1
- css/style.css +7 -1
- inc/class-author-widget.php +67 -10
- inc/meks-smart-author-widget-co-authors-template.php +58 -0
- inc/meks-smart-author-widget-template.php +8 -13
- meks-smart-author-widget.php +2 -2
- readme.txt +8 -4
css/style.css
CHANGED
@@ -3,4 +3,10 @@
|
|
3 |
margin: 0 20px 0 0;
|
4 |
}
|
5 |
|
6 |
-
.mks_author_widget .mks_autor_link_wrap{ margin: 0; padding: 0;}
|
|
|
|
|
|
|
|
|
|
|
|
3 |
margin: 0 20px 0 0;
|
4 |
}
|
5 |
|
6 |
+
.mks_author_widget .mks_autor_link_wrap{ margin: 0; padding: 0;}
|
7 |
+
.mks-co-authors-wrapper {
|
8 |
+
margin-bottom: 30px;
|
9 |
+
}
|
10 |
+
.mks-co-authors-wrapper:last-child {
|
11 |
+
margin-bottom: 0;
|
12 |
+
}
|
inc/class-author-widget.php
CHANGED
@@ -31,14 +31,12 @@ class MKS_Author_Widget extends WP_Widget {
|
|
31 |
'link_to_name' => 0,
|
32 |
'link_to_avatar' => 0,
|
33 |
'link_text' => __('View all posts', 'meks-smart-author-widget'),
|
34 |
-
'link_url' => ''
|
|
|
35 |
));
|
36 |
|
37 |
$this->defaults = $defaults;
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
}
|
43 |
|
44 |
|
@@ -53,10 +51,14 @@ class MKS_Author_Widget extends WP_Widget {
|
|
53 |
extract( $args );
|
54 |
|
55 |
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
56 |
-
|
57 |
-
include($this->meks_get_template('meks-smart-author-widget-template.php'));
|
58 |
-
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
function update( $new_instance, $old_instance ) {
|
62 |
$instance = $old_instance;
|
@@ -73,6 +75,7 @@ class MKS_Author_Widget extends WP_Widget {
|
|
73 |
$instance['link_text'] = strip_tags( $new_instance['link_text'] );
|
74 |
$instance['link_url'] = !empty( $new_instance['link_url'] ) ? esc_url($new_instance['link_url']) : '';
|
75 |
$instance['avatar_size'] = !empty($new_instance['avatar_size']) ? absint($new_instance['avatar_size']) : 64;
|
|
|
76 |
|
77 |
|
78 |
return $instance;
|
@@ -141,10 +144,14 @@ class MKS_Author_Widget extends WP_Widget {
|
|
141 |
<input id="<?php echo $this->get_field_id( 'display_desc' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'display_desc' ); ?>" value="1" <?php checked(1, $instance['display_desc']); ?>/>
|
142 |
<label for="<?php echo $this->get_field_id( 'display_desc' ); ?>"><?php _e('Display author description', 'meks-smart-author-widget'); ?></label>
|
143 |
</li>
|
|
|
|
|
|
|
|
|
|
|
144 |
</ul>
|
145 |
<hr/>
|
146 |
<ul>
|
147 |
-
|
148 |
<li>
|
149 |
<input id="<?php echo $this->get_field_id( 'link_to_name' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'link_to_name' ); ?>" value="1" <?php checked(1, $instance['link_to_name']); ?>/>
|
150 |
<label for="<?php echo $this->get_field_id( 'link_to_name' ); ?>"><?php _e('Link author name', 'meks-smart-author-widget'); ?></label>
|
@@ -173,8 +180,6 @@ class MKS_Author_Widget extends WP_Widget {
|
|
173 |
|
174 |
<?php
|
175 |
|
176 |
-
|
177 |
-
|
178 |
}
|
179 |
|
180 |
/* Check total number of users on the website */
|
@@ -199,6 +204,58 @@ class MKS_Author_Widget extends WP_Widget {
|
|
199 |
|
200 |
return $file;
|
201 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
}
|
203 |
|
204 |
?>
|
31 |
'link_to_name' => 0,
|
32 |
'link_to_avatar' => 0,
|
33 |
'link_text' => __('View all posts', 'meks-smart-author-widget'),
|
34 |
+
'link_url' => '',
|
35 |
+
'limit_chars' => ''
|
36 |
));
|
37 |
|
38 |
$this->defaults = $defaults;
|
|
|
|
|
39 |
|
|
|
40 |
}
|
41 |
|
42 |
|
51 |
extract( $args );
|
52 |
|
53 |
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
|
|
|
|
|
|
54 |
|
55 |
+
if ( $this->is_co_authors_active() && $instance['auto_detect'] ) {
|
56 |
+
include( $this->meks_get_template('meks-smart-author-widget-co-authors-template.php') );
|
57 |
+
} else {
|
58 |
+
include( $this->meks_get_template('meks-smart-author-widget-template.php') );
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
|
63 |
function update( $new_instance, $old_instance ) {
|
64 |
$instance = $old_instance;
|
75 |
$instance['link_text'] = strip_tags( $new_instance['link_text'] );
|
76 |
$instance['link_url'] = !empty( $new_instance['link_url'] ) ? esc_url($new_instance['link_url']) : '';
|
77 |
$instance['avatar_size'] = !empty($new_instance['avatar_size']) ? absint($new_instance['avatar_size']) : 64;
|
78 |
+
$instance['limit_chars'] = isset( $new_instance['limit_chars'] ) ? absint($new_instance['limit_chars']) : '';
|
79 |
|
80 |
|
81 |
return $instance;
|
144 |
<input id="<?php echo $this->get_field_id( 'display_desc' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'display_desc' ); ?>" value="1" <?php checked(1, $instance['display_desc']); ?>/>
|
145 |
<label for="<?php echo $this->get_field_id( 'display_desc' ); ?>"><?php _e('Display author description', 'meks-smart-author-widget'); ?></label>
|
146 |
</li>
|
147 |
+
<li>
|
148 |
+
<label for="<?php echo $this->get_field_id( 'limit_chars' ); ?>"><?php _e('Limit description:', 'meks-smart-author-widget'); ?></label>
|
149 |
+
<input id="<?php echo $this->get_field_id( 'limit_chars' ); ?>" type="number" name="<?php echo $this->get_field_name( 'limit_chars' ); ?>" value="<?php echo $instance['limit_chars']; ?>" class="widefat" />
|
150 |
+
<small class="howto"><?php _e('Specify number of characters to limit author description length', 'meks-smart-author-widget'); ?></small>
|
151 |
+
</li>
|
152 |
</ul>
|
153 |
<hr/>
|
154 |
<ul>
|
|
|
155 |
<li>
|
156 |
<input id="<?php echo $this->get_field_id( 'link_to_name' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'link_to_name' ); ?>" value="1" <?php checked(1, $instance['link_to_name']); ?>/>
|
157 |
<label for="<?php echo $this->get_field_id( 'link_to_name' ); ?>"><?php _e('Link author name', 'meks-smart-author-widget'); ?></label>
|
180 |
|
181 |
<?php
|
182 |
|
|
|
|
|
183 |
}
|
184 |
|
185 |
/* Check total number of users on the website */
|
204 |
|
205 |
return $file;
|
206 |
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Support for Co-Authors Plus Plugin
|
210 |
+
* Check if plugin is active
|
211 |
+
*/
|
212 |
+
public function is_co_authors_active() {
|
213 |
+
|
214 |
+
if ( in_array( 'co-authors-plus/co-authors-plus.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
215 |
+
return true;
|
216 |
+
}
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Limit character description
|
223 |
+
*
|
224 |
+
* @param string $string Content to trim
|
225 |
+
* @param int $limit Number of characters to limit
|
226 |
+
* @param string $more Chars to append after trimmed string
|
227 |
+
* @return string Trimmed part of the string
|
228 |
+
*/
|
229 |
+
public function trim_chars( $string, $limit, $more = '...' ) {
|
230 |
+
|
231 |
+
if ( !empty( $limit ) ) {
|
232 |
+
|
233 |
+
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $string ), ' ' );
|
234 |
+
preg_match_all( '/./u', $text, $chars );
|
235 |
+
$chars = $chars[0];
|
236 |
+
$count = count( $chars );
|
237 |
+
|
238 |
+
if ( $count > $limit ) {
|
239 |
+
|
240 |
+
$chars = array_slice( $chars, 0, $limit );
|
241 |
+
|
242 |
+
for ( $i = ( $limit -1 ); $i >= 0; $i-- ) {
|
243 |
+
if ( in_array( $chars[$i], array( '.', ' ', '-', '?', '!' ) ) ) {
|
244 |
+
break;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
$chars = array_slice( $chars, 0, $i );
|
249 |
+
$string = implode( '', $chars );
|
250 |
+
$string = rtrim( $string, ".,-?!" );
|
251 |
+
$string.= $more;
|
252 |
+
}
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
return $string;
|
257 |
+
}
|
258 |
+
|
259 |
}
|
260 |
|
261 |
?>
|
inc/meks-smart-author-widget-co-authors-template.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$title = apply_filters('widget_title', $instance['title'] );
|
4 |
+
|
5 |
+
echo $before_widget;
|
6 |
+
|
7 |
+
if ( !empty($title) ) {
|
8 |
+
echo $before_title . $title . $after_title;
|
9 |
+
}
|
10 |
+
|
11 |
+
?>
|
12 |
+
|
13 |
+
<?php $coauthors = get_coauthors(); ?>
|
14 |
+
|
15 |
+
<?php foreach ($coauthors as $author): ?>
|
16 |
+
|
17 |
+
<?php $author_link = esc_url( get_author_posts_url( $author->ID, $author->user_nicename) ); ?>
|
18 |
+
|
19 |
+
<div class="mks-co-authors-wrapper">
|
20 |
+
|
21 |
+
<?php if($instance['display_avatar']) : ?>
|
22 |
+
<?php
|
23 |
+
if($instance['link_to_avatar']){
|
24 |
+
$pre_avatar = '<a href="'. $author_link .'">';
|
25 |
+
$post_avatar = '</a>';
|
26 |
+
} else {
|
27 |
+
$pre_avatar = '';
|
28 |
+
$post_avatar = '';
|
29 |
+
}
|
30 |
+
echo $pre_avatar. get_avatar( $author->user_email, $instance['avatar_size'] ) . $post_avatar;
|
31 |
+
?>
|
32 |
+
<?php endif; ?>
|
33 |
+
|
34 |
+
<?php if( $instance['display_name'] ) : ?>
|
35 |
+
<?php
|
36 |
+
if($instance['link_to_name']){
|
37 |
+
$pre_name = '<a href="'. $author_link .'">';
|
38 |
+
$post_name = '</a>';
|
39 |
+
} else {
|
40 |
+
$pre_name = '';
|
41 |
+
$post_name = '';
|
42 |
+
}
|
43 |
+
echo '<h3>' . $pre_name . $author->display_name . $post_name. '</h3>';
|
44 |
+
?>
|
45 |
+
<?php endif; ?>
|
46 |
+
|
47 |
+
<?php if($instance['display_desc']) : ?>
|
48 |
+
<?php echo wpautop( $this->trim_chars( $author->description, $instance['limit_chars'] ) ); ?>
|
49 |
+
<?php endif; ?>
|
50 |
+
|
51 |
+
<?php if( $instance['display_all_posts'] && $instance['link_text'] ) : ?>
|
52 |
+
<div class="mks_autor_link_wrap"><a href="<?php echo $author_link; ?>" class="mks_author_link"><?php echo $instance['link_text']; ?></a></div>
|
53 |
+
<?php endif; ?>
|
54 |
+
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<?php endforeach;
|
58 |
+
echo $after_widget;
|
inc/meks-smart-author-widget-template.php
CHANGED
@@ -3,16 +3,13 @@
|
|
3 |
$user_id = $instance['author'];
|
4 |
if($instance['auto_detect']){
|
5 |
if(is_author()){
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
}
|
12 |
}
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
$author_link = !empty( $instance['link_url'] ) ? esc_url( $instance['link_url'] ) : get_author_posts_url(get_the_author_meta('ID',$user_id) );
|
18 |
$title = $instance['name_to_title'] ? get_the_author_meta('display_name', $user_id) : apply_filters('widget_title', $instance['title'] );
|
@@ -51,15 +48,13 @@ if ( !empty($title) ) {
|
|
51 |
<?php endif; ?>
|
52 |
|
53 |
<?php if($instance['display_desc']) : ?>
|
54 |
-
<?php
|
|
|
55 |
<?php endif; ?>
|
56 |
|
57 |
<?php if($instance['display_all_posts'] && $instance['link_text']) : ?>
|
58 |
<div class="mks_autor_link_wrap"><a href="<?php echo $author_link; ?>" class="mks_author_link"><?php echo $instance['link_text']; ?></a></div>
|
59 |
<?php endif; ?>
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
<?php
|
65 |
echo $after_widget;
|
3 |
$user_id = $instance['author'];
|
4 |
if($instance['auto_detect']){
|
5 |
if(is_author()){
|
6 |
+
$obj = get_queried_object();
|
7 |
+
$user_id = $obj->data->ID;
|
8 |
+
} elseif(is_single()){
|
9 |
+
$obj = get_queried_object();
|
10 |
+
$user_id = $obj->post_author;
|
|
|
11 |
}
|
12 |
+
}
|
|
|
|
|
13 |
|
14 |
$author_link = !empty( $instance['link_url'] ) ? esc_url( $instance['link_url'] ) : get_author_posts_url(get_the_author_meta('ID',$user_id) );
|
15 |
$title = $instance['name_to_title'] ? get_the_author_meta('display_name', $user_id) : apply_filters('widget_title', $instance['title'] );
|
48 |
<?php endif; ?>
|
49 |
|
50 |
<?php if($instance['display_desc']) : ?>
|
51 |
+
<?php $description = get_the_author_meta( 'description', $user_id ); ?>
|
52 |
+
<?php echo wpautop( $this->trim_chars( $description, $instance['limit_chars'] ) ); ?>
|
53 |
<?php endif; ?>
|
54 |
|
55 |
<?php if($instance['display_all_posts'] && $instance['link_text']) : ?>
|
56 |
<div class="mks_autor_link_wrap"><a href="<?php echo $author_link; ?>" class="mks_author_link"><?php echo $instance['link_text']; ?></a></div>
|
57 |
<?php endif; ?>
|
58 |
|
|
|
|
|
|
|
59 |
<?php
|
60 |
echo $after_widget;
|
meks-smart-author-widget.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Meks Smart Author Widget
|
|
4 |
Plugin URI: http://mekshq.com
|
5 |
Description: Easily display your author/user profile info inside WordPress widget. Smart feature of this plugin is user/author "auto detection" which means that it can optionaly show author of current post on single post templates or on specific author archive.
|
6 |
Author: Meks
|
7 |
-
Version: 1.
|
8 |
Author URI: http://mekshq.com
|
9 |
Text Domain: meks-smart-author-widget
|
10 |
Domain Path: /languages
|
@@ -30,7 +30,7 @@ Domain Path: /languages
|
|
30 |
|
31 |
define ('MKS_AUTHOR_WIDGET_URL', trailingslashit(plugin_dir_url(__FILE__)));
|
32 |
define ('MKS_AUTHOR_WIDGET_DIR', trailingslashit(plugin_dir_path(__FILE__)));
|
33 |
-
define ('MKS_AUTHOR_WIDGET_VER', '1.
|
34 |
|
35 |
/* Initialize Widget */
|
36 |
if(!function_exists('mks_author_widget_init')):
|
4 |
Plugin URI: http://mekshq.com
|
5 |
Description: Easily display your author/user profile info inside WordPress widget. Smart feature of this plugin is user/author "auto detection" which means that it can optionaly show author of current post on single post templates or on specific author archive.
|
6 |
Author: Meks
|
7 |
+
Version: 1.1
|
8 |
Author URI: http://mekshq.com
|
9 |
Text Domain: meks-smart-author-widget
|
10 |
Domain Path: /languages
|
30 |
|
31 |
define ('MKS_AUTHOR_WIDGET_URL', trailingslashit(plugin_dir_url(__FILE__)));
|
32 |
define ('MKS_AUTHOR_WIDGET_DIR', trailingslashit(plugin_dir_path(__FILE__)));
|
33 |
+
define ('MKS_AUTHOR_WIDGET_VER', '1.1');
|
34 |
|
35 |
/* Initialize Widget */
|
36 |
if(!function_exists('mks_author_widget_init')):
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: mekshq
|
|
3 |
Donate link: http://mekshq.com/
|
4 |
Tags: widget, sidebar, author, user, avatar, profile
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
@@ -25,7 +25,7 @@ Simple plugin which allows you to display author/user info inside WordPress widg
|
|
25 |
* Replace widget title with user display name (optional)
|
26 |
|
27 |
|
28 |
-
Smart Author Widget plugin is created by <a href="http://mekshq.com" target="_blank">
|
29 |
|
30 |
><strong>Live preview?</strong><br>
|
31 |
>You can see Smart Author Widget live example on our <a href="http://mekshq.com/demo/throne" target="_blank">Throne theme demo website</a>
|
@@ -38,7 +38,7 @@ Smart Author Widget plugin is created by <a href="http://mekshq.com" target="_bl
|
|
38 |
|
39 |
== Frequently Asked Questions ==
|
40 |
|
41 |
-
- For any questions, error reports and suggestions please
|
42 |
|
43 |
== Screenshots ==
|
44 |
|
@@ -47,6 +47,10 @@ Smart Author Widget plugin is created by <a href="http://mekshq.com" target="_bl
|
|
47 |
|
48 |
== Changelog ==
|
49 |
|
|
|
|
|
|
|
|
|
50 |
= 1.0.9 =
|
51 |
|
52 |
* Fixed: "Link author name" and "Link author avatar" not working if "Display author all posts archive link" option was not checked
|
3 |
Donate link: http://mekshq.com/
|
4 |
Tags: widget, sidebar, author, user, avatar, profile
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 1.1
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl.html
|
10 |
|
25 |
* Replace widget title with user display name (optional)
|
26 |
|
27 |
|
28 |
+
Smart Author Widget plugin is created by <a href="http://mekshq.com" target="_blank">Meks</a>
|
29 |
|
30 |
><strong>Live preview?</strong><br>
|
31 |
>You can see Smart Author Widget live example on our <a href="http://mekshq.com/demo/throne" target="_blank">Throne theme demo website</a>
|
38 |
|
39 |
== Frequently Asked Questions ==
|
40 |
|
41 |
+
- For any questions, error reports and suggestions please visit http://mekshq.com/contact
|
42 |
|
43 |
== Screenshots ==
|
44 |
|
47 |
|
48 |
== Changelog ==
|
49 |
|
50 |
+
= 1.1 =
|
51 |
+
* Added: Option to limit characters in author description
|
52 |
+
* Added: Support to work with for Co-authors plus WordPress plugin (if "auto detect author" is checked)
|
53 |
+
|
54 |
= 1.0.9 =
|
55 |
|
56 |
* Fixed: "Link author name" and "Link author avatar" not working if "Display author all posts archive link" option was not checked
|