PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.35
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.35
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 / authorbox.php

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

203 lines 7.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 author box widget.
8 *
9 * @since 1.0.22
10 */
11 class UWP_Author_Box_Widget extends WP_Super_Duper {
12 public $arguments;
13
14 /**
15 * Register the profile widget with WordPress.
16 *
17 */
18 public function __construct() {
19
20
21 $options = array(
22 'textdomain' => 'userswp',
23 'block-icon' => 'admin-site',
24 'block-category'=> 'widgets',
25 'block-keywords'=> "['userswp','author','authorbox']",
26 'class_name' => __CLASS__,
27 'base_id' => 'uwp_author_box',
28 'name' => __('UWP > Author Box','userswp'),
29 'widget_ops' => array(
30 'classname' => 'uwp_widgets uwp_widget_author_box bsui',
31 'description' => esc_html__('Displays author box.','userswp'),
32 ),
33 );
34
35
36 parent::__construct( $options );
37 }
38
39 /**
40 * Set widget arguments.
41 *
42 */
43 public function set_arguments()
44 {
45 $arguments = array(
46 'title' => array(
47 'title' => __('Widget title', 'userswp'),
48 'desc' => __('Enter widget title.', 'userswp'),
49 'type' => 'text',
50 'desc_tip' => true,
51 'default' => '',
52 'advanced' => false
53 )
54 );
55
56 // margins mobile
57 $arguments['mt'] = sd_get_margin_input('mt', array('device_type' => 'Mobile'));
58 $arguments['mr'] = sd_get_margin_input('mr', array('device_type' => 'Mobile'));
59 $arguments['mb'] = sd_get_margin_input('mb', array('device_type' => 'Mobile'));
60 $arguments['ml'] = sd_get_margin_input('ml', array('device_type' => 'Mobile'));
61
62 // margins tablet
63 $arguments['mt_md'] = sd_get_margin_input('mt', array('device_type' => 'Tablet'));
64 $arguments['mr_md'] = sd_get_margin_input('mr', array('device_type' => 'Tablet'));
65 $arguments['mb_md'] = sd_get_margin_input('mb', array('device_type' => 'Tablet'));
66 $arguments['ml_md'] = sd_get_margin_input('ml', array('device_type' => 'Tablet'));
67
68 // margins desktop
69 $arguments['mt_lg'] = sd_get_margin_input('mt', array('device_type' => 'Desktop'));
70 $arguments['mr_lg'] = sd_get_margin_input('mr', array('device_type' => 'Desktop'));
71 $arguments['mb_lg'] = sd_get_margin_input('mb', array('device_type' => 'Desktop'));
72 $arguments['ml_lg'] = sd_get_margin_input('ml', array('device_type' => 'Desktop'));
73
74 // padding
75 $arguments['pt'] = sd_get_padding_input('pt', array('device_type' => 'Mobile'));
76 $arguments['pr'] = sd_get_padding_input('pr', array('device_type' => 'Mobile'));
77 $arguments['pb'] = sd_get_padding_input('pb', array('device_type' => 'Mobile'));
78 $arguments['pl'] = sd_get_padding_input('pl', array('device_type' => 'Mobile'));
79
80 // padding tablet
81 $arguments['pt_md'] = sd_get_padding_input('pt', array('device_type' => 'Tablet'));
82 $arguments['pr_md'] = sd_get_padding_input('pr', array('device_type' => 'Tablet'));
83 $arguments['pb_md'] = sd_get_padding_input('pb', array('device_type' => 'Tablet'));
84 $arguments['pl_md'] = sd_get_padding_input('pl', array('device_type' => 'Tablet'));
85
86 // padding desktop
87 $arguments['pt_lg'] = sd_get_padding_input('pt', array('device_type' => 'Desktop'));
88 $arguments['pr_lg'] = sd_get_padding_input('pr', array('device_type' => 'Desktop'));
89 $arguments['pb_lg'] = sd_get_padding_input('pb', array('device_type' => 'Desktop'));
90 $arguments['pl_lg'] = sd_get_padding_input('pl', array('device_type' => 'Desktop'));
91
92 // border
93 $arguments['border'] = sd_get_border_input('border');
94 $arguments['rounded'] = sd_get_border_input('rounded');
95 $arguments['rounded_size'] = sd_get_border_input('rounded_size');
96
97 // shadow
98 $arguments['shadow'] = sd_get_shadow_input('shadow');
99
100 return apply_filters('uwp_author_box_widget_arguments', $arguments);
101 }
102
103 /**
104 * The Super block output function.
105 *
106 * @param array $args
107 * @param array $widget_args
108 * @param string $content
109 *
110 * @return mixed|string|bool
111 */
112 public function output( $args = array(), $widget_args = array(), $content = '' ) {
113
114 global $post, $wpdb;
115
116 // Ensure we have an array.
117 if ( ! is_array( $args ) ) {
118 $args = array();
119 }
120
121 if(empty($post->ID)){
122 return '';
123 }
124
125 ob_start();
126
127 if(!wp_style_is('uwp-authorbox')){
128 wp_enqueue_style( 'uwp-authorbox' );
129 }
130
131 $design_style = uwp_get_option("design_style",'bootstrap');
132 if( $design_style =='bootstrap'){
133 $output = uwp_get_option('author_box_content_bootstrap');
134 if(!$output){$output = UsersWP_Defaults::author_box_content_bootstrap( $args );}
135 }else{
136 $output = uwp_get_option('author_box_content');
137 if(!$output){$output = UsersWP_Defaults::author_box_content();}
138 }
139
140 $output = apply_filters('uwp_author_box_pre_output', $output, $args);
141
142 $output = do_shortcode($output );
143
144 $author_id = $post->post_author;
145 $author_link = uwp_build_profile_tab_url($author_id);
146 $user = get_user_by('id', $author_id);
147 $author_name = esc_attr( $user->display_name );
148 $author_bio = get_user_meta($author_id, 'description', true);
149 $limit_words = apply_filters('uwp_author_bio_content_limit', uwp_get_option('author_box_bio_limit', 200));
150 $author_bio = wp_trim_words( $author_bio, $limit_words, '...' );
151 $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
152 $user_meta = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$meta_table} WHERE user_id = %d", $author_id), ARRAY_A);
153
154 $user_meta = apply_filters('uwp_author_box_user_meta_fields', $user_meta, $args);
155 $avatar_size = apply_filters('uwp_author_box_avatar_size', 100, $args);
156
157 $replace_array = array(
158 '[#post_id#]' => absint( $post->ID ),
159 '[#post_modified#]' => esc_attr( $post->post_modified ),
160 '[#post_date#]' => esc_attr( $post->post_date ),
161 '[#author_id#]' => absint( $post->post_author ),
162 '[#author_name#]' => esc_attr( $author_name ),
163 '[#author_link#]' => esc_url( $author_link ),
164 '[#author_bio#]' => esc_textarea( $author_bio ),
165 '[#author_image#]' => get_avatar($post->post_author, $avatar_size),
166 '[#author_image_url#]' => get_avatar_url($post->post_author, $avatar_size),
167 '[#author_nicename#]' => esc_attr( $user->user_nicename ),
168 '[#author_registered#]' => esc_attr( $user->user_registered ),
169 '[#author_website#]' => esc_url( $user->user_url ),
170 );
171
172 if( !empty( $user_meta ) && '' !== $user_meta ) {
173 foreach ( $user_meta as $meta_key => $meta_val ) {
174
175 if(in_array($meta_key, array('avatar_thumb', 'banner_thumb')) && !empty($meta_val)){
176 $uploads = wp_upload_dir();
177 $upload_url = $uploads['baseurl'];
178 $meta_val = esc_url( $upload_url.$meta_val );
179 }
180
181 if( in_array($meta_key, array('user_privacy')) ) {
182 continue;
183 }
184
185 $replace_array['[#'.$meta_key.'#]'] = esc_attr( $meta_val );
186 }
187 }
188
189 $replace_array = apply_filters('uwp_author_box_replace_array', $replace_array);
190
191 foreach ( $replace_array as $key => $value ) {
192 $value = apply_filters('uwp_author_box_'.$key.'_value', $value, $post);
193 $output = str_replace( $key, $value, $output );
194 }
195
196 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
197
198 $output = ob_get_clean();
199
200 return apply_filters('uwp_author_box_output', $output, $args);
201 }
202
203 }