PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.45
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.45
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / widgets / profile-header.php

profile-header.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.45, at widgets/profile-header.php

171 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 /**
7 * UsersWP profile header widget.
8 *
9 * @since 1.1.2
10 */
11 class UWP_Profile_Header_Widget extends WP_Super_Duper {
12
13 /**
14 * Register the profile header 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','profile']",
25 'class_name' => __CLASS__,
26 'base_id' => 'uwp_profile_header',
27 'name' => __('UWP > Profile Header','userswp'),
28 'block-wrap' => '',
29 'widget_ops' => array(
30 'classname' => 'uwp-profile-header bsui',
31 'description' => esc_html__('Displays user profile header.','userswp'),
32 ),
33 'arguments' => array(
34 'hide_cover' => array(
35 'title' => __('Hide cover image:', 'userswp'),
36 'desc' => __('Hide cover image in user profile page.', 'userswp'),
37 'type' => 'checkbox',
38 'desc_tip' => true,
39 'value' => '1',
40 'default' => 0,
41 'advanced' => true
42 ),
43 'hide_avatar' => array(
44 'title' => __('Hide avatar image:', 'userswp'),
45 'desc' => __('Hide avatar image in user profile page.', 'userswp'),
46 'type' => 'checkbox',
47 'desc_tip' => true,
48 'value' => '1',
49 'default' => 0,
50 'advanced' => true
51 ),
52 'user_id' => array(
53 'title' => __('User ID:', 'userswp'),
54 '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'),
55 'type' => 'text',
56 'desc_tip' => true,
57 'default' => '',
58 'advanced' => true
59 ),
60 'allow_change' => array(
61 'title' => __('Allow to change cover and avatar:', 'userswp'),
62 'desc' => __('Allow user to change cover and avatar image in profile page.', 'userswp'),
63 'type' => 'checkbox',
64 'desc_tip' => true,
65 'value' => '1',
66 'default' => 1,
67 'advanced' => true
68 ),
69 'disable_greedy' => array(
70 'title' => __('Disable Greedy Menu for post counts', 'userswp'),
71 'desc' => __('Greedy menu prevents a large menu falling onto another line by adding a dropdown select.', 'userswp'),
72 'type' => 'checkbox',
73 'desc_tip' => true,
74 'value' => '1',
75 'default' => '',
76 'advanced' => true,
77 ),
78 )
79
80 );
81
82
83 parent::__construct( $options );
84 }
85
86 public function output( $args = array(), $widget_args = array(), $content = '' ) {
87
88 global $post;
89
90 $enable_profile_header = uwp_get_option('enable_profile_header');
91 $defaults = array(
92 'hide_cover' => 0,
93 'hide_avatar' => 0,
94 'allow_change' => 1,
95 );
96
97 $args = wp_parse_args( $args, $defaults );
98
99 $args['hide_cover'] = !empty($args['hide_cover']) ? $args['hide_cover'] : 0;
100 $args['hide_avatar'] = !empty($args['hide_avatar']) ? $args['hide_avatar'] : 0;
101 $args['allow_change'] = !empty($args['allow_change']) ? $args['allow_change'] : 1;
102
103 if('post_author' == $args['user_id'] && $post instanceof WP_Post){
104 $user = get_userdata($post->post_author);
105 $args['user_id'] = $post->post_author;
106 } else if(isset($args['user_id']) && (int)$args['user_id'] > 0){
107 $user = get_userdata($args['user_id']);
108 } else {
109 $user = uwp_get_displayed_user();
110 }
111
112 if(empty($args['user_id']) && !empty($user->ID)){
113 $args['user_id'] = $user->ID;
114 }
115
116 if(!$user){
117 return '';
118 }
119
120 if ($enable_profile_header != '1') {
121 return '';
122 }
123
124 $args = apply_filters( 'uwp_widget_profile_header_args', $args, $widget_args, $this );
125
126 ob_start();
127
128 wp_enqueue_script( 'jcrop', array( 'jquery' ) );
129 wp_enqueue_script( 'jquery-ui-progressbar', array( 'jquery' ) );
130 wp_enqueue_style( 'jcrop' );
131 wp_enqueue_style( 'jquery-ui' );
132
133 // setup some args
134 add_filter( 'upload_dir', 'uwp_handle_multisite_profile_image', 10, 1 );
135 $uploads = wp_upload_dir();
136 remove_filter( 'upload_dir', 'uwp_handle_multisite_profile_image' );
137 $upload_url = $uploads['baseurl'];
138 $banner = uwp_get_usermeta( $user->ID, 'banner_thumb', '' );
139 if ( empty( $banner ) ) {
140 $banner = uwp_get_default_banner_uri();
141 } else {
142 $banner = $upload_url . $banner;
143 }
144
145 $avatar = uwp_get_usermeta( $user->ID, 'avatar_thumb', '' );
146 if ( empty( $avatar ) ) {
147 $avatar = get_avatar_url( $user->user_email, array( 'size' => 150 ) );
148 } else {
149 if ( strpos( $avatar, 'http:' ) === false && strpos( $avatar, 'https:' ) === false ) {
150 $avatar = $upload_url . $avatar;
151 }
152 }
153
154 $args['avatar_url'] = $avatar;
155 $args['banner_url'] = $banner;
156
157
158 $design_style = uwp_get_option("design_style",'bootstrap');
159 $template = $design_style ? $design_style."/profile-header.php" : "profile-header.php";
160
161 uwp_get_template($template, $args);
162
163 do_action('uwp_profile_header', $user, $args['hide_cover'], $args['hide_avatar'], $args['allow_change']);
164
165 $output = ob_get_clean();
166
167 return $output;
168
169 }
170
171 }