Skip to content

Commit

Permalink
1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
stiofan committed Mar 14, 2024
1 parent fd26a45 commit dd61b51
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 94 deletions.
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.ko-fi.com/stiofan
Tags: login form, registration, registration form, user profile, user registration, members, membership
Requires at least: 4.9
Tested up to: 6.5
Stable tag: 1.2.6
Stable tag: 1.2.7
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

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

== Changelog ==

= 1.2.7 =
* Profile title tag could be changed to non heading tag by a contributor level user - FIXED

= 1.2.6 =
* Remove profile image ajax call had nonce check commented out for testing - FIXED
* Composer packages updated to latest - UPDATED
Expand Down
4 changes: 2 additions & 2 deletions userswp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: UsersWP
Plugin URI: https://userswp.io/
Description: The only lightweight user profile plugin for WordPress. UsersWP features front end user profile, users directory, a registration and a login form.
Version: 1.2.6
Version: 1.2.7
Author: AyeCode Ltd
Author URI: https://userswp.io
License: GPL-2.0+
Expand All @@ -24,7 +24,7 @@
}

if ( ! defined( 'USERSWP_VERSION' ) ) {
define( 'USERSWP_VERSION', '1.2.6' );
define( 'USERSWP_VERSION', '1.2.7' );
}

if ( ! defined( 'USERSWP_PATH' ) ) {
Expand Down
184 changes: 93 additions & 91 deletions widgets/user-title.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit;
}

/**
Expand All @@ -10,95 +10,97 @@
*/
class UWP_User_Title_Widget extends WP_Super_Duper {

/**
* Register the user title widget with WordPress.
*
*/
public function __construct() {


$options = array(
'textdomain' => 'userswp',
'block-icon' => 'admin-site',
'block-category'=> 'widgets',
'block-keywords'=> "['userswp','user']",
'class_name' => __CLASS__,
'base_id' => 'uwp_user_title',
'name' => __('UWP > User Title','userswp'),
'no_wrap' => true,
'widget_ops' => array(
'classname' => 'uwp-user-title',
'description' => esc_html__('Displays user name.','userswp'),
),
'arguments' => array(
'tag' => array(
'title' => __('Header Tag:', 'userswp'),
'desc' => __('Header tag for the user title.', 'userswp'),
'type' => 'select',
'options' => array(
"h1" => "h1",
"h2" => "h2",
"h3" => "h3",
"h4" => "h4",
"h5" => "h5",
"h6" => "h6",
),
'default' => 'h2',
'desc_tip' => true,
),
'user_id' => array(
'title' => __('User ID:', 'userswp'),
'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'),
'type' => 'text',
'desc_tip' => true,
'default' => '',
'advanced' => true
),
)

);


parent::__construct( $options );
}

public function output( $args = array(), $widget_args = array(), $content = '' ) {

global $post;

$defaults = array(
'tag' => 'h2',
);

$args = wp_parse_args( $args, $defaults );

$args = apply_filters( 'uwp_widget_user_title_args', $args, $widget_args, $this );

$title_tag = empty( $args['tag'] ) ? 'h2' : apply_filters( 'uwp_widget_user_title_tag', $args['tag'], $args, $widget_args, $this );

if('post_author' == $args['user_id'] && $post instanceof WP_Post){
$user = get_userdata($post->post_author);
$args['user_id'] = $post->post_author;
} else if(isset($args['user_id']) && (int)$args['user_id'] > 0){
$user = get_userdata((int)$args['user_id']);
} else {
$user = uwp_get_displayed_user();
}

if(empty($args['user_id']) && !empty($user->ID)){
$args['user_id'] = $user->ID;
}

if(!$user){
return '';
}

ob_start();

do_action('uwp_user_title', $user, $title_tag);

return ob_get_clean();

}
/**
* Register the user title widget with WordPress.
*
*/
public function __construct() {


$options = array(
'textdomain' => 'userswp',
'block-icon' => 'admin-site',
'block-category' => 'widgets',
'block-keywords' => "['userswp','user']",
'class_name' => __CLASS__,
'base_id' => 'uwp_user_title',
'name' => __( 'UWP > User Title', 'userswp' ),
'no_wrap' => true,
'widget_ops' => array(
'classname' => 'uwp-user-title',
'description' => esc_html__( 'Displays user name.', 'userswp' ),
),
'arguments' => array(
'tag' => array(
'title' => __( 'Header Tag:', 'userswp' ),
'desc' => __( 'Header tag for the user title.', 'userswp' ),
'type' => 'select',
'options' => array(
"h1" => "h1",
"h2" => "h2",
"h3" => "h3",
"h4" => "h4",
"h5" => "h5",
"h6" => "h6",
),
'default' => 'h2',
'desc_tip' => true,
),
'user_id' => array(
'title' => __( 'User ID:', 'userswp' ),
'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' ),
'type' => 'text',
'desc_tip' => true,
'default' => '',
'advanced' => true
),
)

);


parent::__construct( $options );
}

public function output( $args = array(), $widget_args = array(), $content = '' ) {

global $post;

$defaults = array(
'tag' => 'h2',
);

$args = wp_parse_args( $args, $defaults );

$args = apply_filters( 'uwp_widget_user_title_args', $args, $widget_args, $this );

$allowed_tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
$tag = in_array( $args['tag'], $allowed_tags ) ? esc_attr( $args['tag'] ) : 'h2';
$title_tag = empty( $args['tag'] ) ? 'h2' : apply_filters( 'uwp_widget_user_title_tag', $tag, $args, $widget_args, $this );

if ( 'post_author' == $args['user_id'] && $post instanceof WP_Post ) {
$user = get_userdata( $post->post_author );
$args['user_id'] = $post->post_author;
} else if ( isset( $args['user_id'] ) && (int) $args['user_id'] > 0 ) {
$user = get_userdata( (int) $args['user_id'] );
} else {
$user = uwp_get_displayed_user();
}

if ( empty( $args['user_id'] ) && ! empty( $user->ID ) ) {
$args['user_id'] = $user->ID;
}

if ( ! $user ) {
return '';
}

ob_start();

do_action( 'uwp_user_title', $user, $title_tag );

return ob_get_clean();

}

}

0 comments on commit dd61b51

Please sign in to comment.