From dd61b51fb1eb26a538feda40ecbbb0806e301729 Mon Sep 17 00:00:00 2001 From: stiofan Date: Thu, 14 Mar 2024 16:53:04 +0000 Subject: [PATCH] 1.2.7 --- readme.txt | 5 +- userswp.php | 4 +- widgets/user-title.php | 184 +++++++++++++++++++++-------------------- 3 files changed, 99 insertions(+), 94 deletions(-) diff --git a/readme.txt b/readme.txt index e9f3ae49..d51f9dce 100644 --- a/readme.txt +++ b/readme.txt @@ -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 @@ -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 diff --git a/userswp.php b/userswp.php index 0d575395..baf50ed8 100644 --- a/userswp.php +++ b/userswp.php @@ -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+ @@ -24,7 +24,7 @@ } if ( ! defined( 'USERSWP_VERSION' ) ) { - define( 'USERSWP_VERSION', '1.2.6' ); + define( 'USERSWP_VERSION', '1.2.7' ); } if ( ! defined( 'USERSWP_PATH' ) ) { diff --git a/widgets/user-title.php b/widgets/user-title.php index 1e7a1870..dc283d37 100644 --- a/widgets/user-title.php +++ b/widgets/user-title.php @@ -1,6 +1,6 @@ '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(); + + } } \ No newline at end of file