Skip to content

Commit dd61b51

Browse files
author
stiofan
committedMar 14, 2024
1.2.7
1 parent fd26a45 commit dd61b51

File tree

3 files changed

+99
-94
lines changed

3 files changed

+99
-94
lines changed
 

‎readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://www.ko-fi.com/stiofan
44
Tags: login form, registration, registration form, user profile, user registration, members, membership
55
Requires at least: 4.9
66
Tested up to: 6.5
7-
Stable tag: 1.2.6
7+
Stable tag: 1.2.7
88
License: GPLv3
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
1010

@@ -146,6 +146,9 @@ Yes, you can customize it with Elementor, but also with Gutenberg, Divi, Beaver
146146

147147
== Changelog ==
148148

149+
= 1.2.7 =
150+
* Profile title tag could be changed to non heading tag by a contributor level user - FIXED
151+
149152
= 1.2.6 =
150153
* Remove profile image ajax call had nonce check commented out for testing - FIXED
151154
* Composer packages updated to latest - UPDATED

‎userswp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: UsersWP
44
Plugin URI: https://userswp.io/
55
Description: The only lightweight user profile plugin for WordPress. UsersWP features front end user profile, users directory, a registration and a login form.
6-
Version: 1.2.6
6+
Version: 1.2.7
77
Author: AyeCode Ltd
88
Author URI: https://userswp.io
99
License: GPL-2.0+
@@ -24,7 +24,7 @@
2424
}
2525

2626
if ( ! defined( 'USERSWP_VERSION' ) ) {
27-
define( 'USERSWP_VERSION', '1.2.6' );
27+
define( 'USERSWP_VERSION', '1.2.7' );
2828
}
2929

3030
if ( ! defined( 'USERSWP_PATH' ) ) {

‎widgets/user-title.php

Lines changed: 93 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
if ( ! defined( 'ABSPATH' ) ) {
3-
exit;
3+
exit;
44
}
55

66
/**
@@ -10,95 +10,97 @@
1010
*/
1111
class UWP_User_Title_Widget extends WP_Super_Duper {
1212

13-
/**
14-
* Register the user title widget with WordPress.
15-
*
16-
*/
17-
public function __construct() {
18-
19-
20-
$options = array(
21-
'textdomain' => 'userswp',
22-
'block-icon' => 'admin-site',
23-
'block-category'=> 'widgets',
24-
'block-keywords'=> "['userswp','user']",
25-
'class_name' => __CLASS__,
26-
'base_id' => 'uwp_user_title',
27-
'name' => __('UWP > User Title','userswp'),
28-
'no_wrap' => true,
29-
'widget_ops' => array(
30-
'classname' => 'uwp-user-title',
31-
'description' => esc_html__('Displays user name.','userswp'),
32-
),
33-
'arguments' => array(
34-
'tag' => array(
35-
'title' => __('Header Tag:', 'userswp'),
36-
'desc' => __('Header tag for the user title.', 'userswp'),
37-
'type' => 'select',
38-
'options' => array(
39-
"h1" => "h1",
40-
"h2" => "h2",
41-
"h3" => "h3",
42-
"h4" => "h4",
43-
"h5" => "h5",
44-
"h6" => "h6",
45-
),
46-
'default' => 'h2',
47-
'desc_tip' => true,
48-
),
49-
'user_id' => array(
50-
'title' => __('User ID:', 'userswp'),
51-
'desc' => __('Leave blank to use current user ID or use post_author for current post author ID. For profile page it will take displayed user ID. Input specific user ID for other pages.', 'userswp'),
52-
'type' => 'text',
53-
'desc_tip' => true,
54-
'default' => '',
55-
'advanced' => true
56-
),
57-
)
58-
59-
);
60-
61-
62-
parent::__construct( $options );
63-
}
64-
65-
public function output( $args = array(), $widget_args = array(), $content = '' ) {
66-
67-
global $post;
68-
69-
$defaults = array(
70-
'tag' => 'h2',
71-
);
72-
73-
$args = wp_parse_args( $args, $defaults );
74-
75-
$args = apply_filters( 'uwp_widget_user_title_args', $args, $widget_args, $this );
76-
77-
$title_tag = empty( $args['tag'] ) ? 'h2' : apply_filters( 'uwp_widget_user_title_tag', $args['tag'], $args, $widget_args, $this );
78-
79-
if('post_author' == $args['user_id'] && $post instanceof WP_Post){
80-
$user = get_userdata($post->post_author);
81-
$args['user_id'] = $post->post_author;
82-
} else if(isset($args['user_id']) && (int)$args['user_id'] > 0){
83-
$user = get_userdata((int)$args['user_id']);
84-
} else {
85-
$user = uwp_get_displayed_user();
86-
}
87-
88-
if(empty($args['user_id']) && !empty($user->ID)){
89-
$args['user_id'] = $user->ID;
90-
}
91-
92-
if(!$user){
93-
return '';
94-
}
95-
96-
ob_start();
97-
98-
do_action('uwp_user_title', $user, $title_tag);
99-
100-
return ob_get_clean();
101-
102-
}
13+
/**
14+
* Register the user title widget with WordPress.
15+
*
16+
*/
17+
public function __construct() {
18+
19+
20+
$options = array(
21+
'textdomain' => 'userswp',
22+
'block-icon' => 'admin-site',
23+
'block-category' => 'widgets',
24+
'block-keywords' => "['userswp','user']",
25+
'class_name' => __CLASS__,
26+
'base_id' => 'uwp_user_title',
27+
'name' => __( 'UWP > User Title', 'userswp' ),
28+
'no_wrap' => true,
29+
'widget_ops' => array(
30+
'classname' => 'uwp-user-title',
31+
'description' => esc_html__( 'Displays user name.', 'userswp' ),
32+
),
33+
'arguments' => array(
34+
'tag' => array(
35+
'title' => __( 'Header Tag:', 'userswp' ),
36+
'desc' => __( 'Header tag for the user title.', 'userswp' ),
37+
'type' => 'select',
38+
'options' => array(
39+
"h1" => "h1",
40+
"h2" => "h2",
41+
"h3" => "h3",
42+
"h4" => "h4",
43+
"h5" => "h5",
44+
"h6" => "h6",
45+
),
46+
'default' => 'h2',
47+
'desc_tip' => true,
48+
),
49+
'user_id' => array(
50+
'title' => __( 'User ID:', 'userswp' ),
51+
'desc' => __( 'Leave blank to use current user ID or use post_author for current post author ID. For profile page it will take displayed user ID. Input specific user ID for other pages.', 'userswp' ),
52+
'type' => 'text',
53+
'desc_tip' => true,
54+
'default' => '',
55+
'advanced' => true
56+
),
57+
)
58+
59+
);
60+
61+
62+
parent::__construct( $options );
63+
}
64+
65+
public function output( $args = array(), $widget_args = array(), $content = '' ) {
66+
67+
global $post;
68+
69+
$defaults = array(
70+
'tag' => 'h2',
71+
);
72+
73+
$args = wp_parse_args( $args, $defaults );
74+
75+
$args = apply_filters( 'uwp_widget_user_title_args', $args, $widget_args, $this );
76+
77+
$allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
78+
$tag = in_array( $args['tag'], $allowed_tags ) ? esc_attr( $args['tag'] ) : 'h2';
79+
$title_tag = empty( $args['tag'] ) ? 'h2' : apply_filters( 'uwp_widget_user_title_tag', $tag, $args, $widget_args, $this );
80+
81+
if ( 'post_author' == $args['user_id'] && $post instanceof WP_Post ) {
82+
$user = get_userdata( $post->post_author );
83+
$args['user_id'] = $post->post_author;
84+
} else if ( isset( $args['user_id'] ) && (int) $args['user_id'] > 0 ) {
85+
$user = get_userdata( (int) $args['user_id'] );
86+
} else {
87+
$user = uwp_get_displayed_user();
88+
}
89+
90+
if ( empty( $args['user_id'] ) && ! empty( $user->ID ) ) {
91+
$args['user_id'] = $user->ID;
92+
}
93+
94+
if ( ! $user ) {
95+
return '';
96+
}
97+
98+
ob_start();
99+
100+
do_action( 'uwp_user_title', $user, $title_tag );
101+
102+
return ob_get_clean();
103+
104+
}
103105

104106
}

0 commit comments

Comments
 (0)